/* * Graphics routine for High-High-School Adventure. * Copyright(c)2003 ZOBplus hiro */ #include #include #include "high.h" #include "graph2.h" #include "glue.h" #define MAX_QUEUE_SIZE (1024) typedef struct { int _Qstart, _Qend; PointType _Queue[MAX_QUEUE_SIZE]; } GPointQueueType; typedef GPointQueueType *GPointQueuePtr; /* global variables */ typedef struct { GPointQueueType _pointQ; Boolean _hDensity; /* OS5 high-density */ UInt16 _hrLib; /* OS4 CLIe High-Resolution */ UInt16 _hrVer; /* CLIe High-Resolution API Version */ IndexedColorType _colors[gColorNameCandidate]; /* color map */ RGBColorType _defrgb[gColorNameCandidate]; /* dafault map */ WinHandle _canvas; /* offscreen window */ BitmapPtr _bmpP; /* canvas bitmap */ UInt8 *_baseP; /* canvas bitmap body */ UInt16 _rowBytes; /* row bytes */ RectangleType _border; /* canvas border */ UInt32 _width, _height, _depth; /* properties */ FontID _fntTable[8]; /* for CLIe High Resolution Fonts */ } GraphGlobalVarType; static GraphGlobalVarType * CreateGlobalVariables() { GraphGlobalVarType *ptr = NULL; Err err; if ((err = FtrPtrNew(ZAMA_CREATOR_ID, ZAMA_GRAPH_VAR, sizeof(GraphGlobalVarType), &ptr)) != errNone) { return NULL; } return ptr; } static void DeleteGlobalVariables() { FtrPtrFree(ZAMA_CREATOR_ID, ZAMA_GRAPH_VAR); } static GraphGlobalVarType * GetGlobalVariables() { GraphGlobalVarType *ptr; Err err; if ((err = FtrGet(ZAMA_CREATOR_ID, ZAMA_GRAPH_VAR, &ptr)) != errNone) { return NULL; } return ptr; } static void HDWinDrawChars(Char *strP_, UInt16 len_, Coord x_, Coord y_) { WinHandle curH, offH; BitmapPtr bmpP; BitmapPtrV3 bmp3P; RectangleType r; Coord w, h; Err err; UInt16 coordSys; curH = WinGetDrawWindow(); coordSys = WinSetCoordinateSystem(kCoordinatesDouble); w = FntCharsWidth(strP_, len_); h = FntCharHeight(); bmpP = BmpCreate(w, h, 8, NULL, &err); bmp3P = BmpCreateBitmapV3(bmpP, kCoordinatesStandard, BmpGetBits(bmpP), NULL); offH = WinCreateBitmapWindow((BitmapPtr)bmp3P, &err); WinSetDrawWindow(offH); WinDrawChars(strP_, len_, 0, 0); WinDeleteWindow(offH, false); BmpSetDensity((BitmapPtr)bmp3P, kCoordinatesDouble); offH = WinCreateBitmapWindow((BitmapPtr)bmp3P, &err); RctSetRectangle(&r, 0, 0, w / 2, h / 2); WinCopyRectangle(offH, curH, &r, x_, y_, winOverlay); WinDeleteWindow(offH, false); BmpDelete((BitmapPtr)bmp3P); BmpDelete(bmpP); WinSetCoordinateSystem(coordSys); } static inline UInt16 GCoord2Offset(Coord x_, Coord y_) { GraphGlobalVarType *g = GetGlobalVariables(); if (g->_hDensity || g->_hrLib) { /* High Resolution */ return y_ * g->_rowBytes + x_; } else { return y_ * g->_rowBytes + (x_ / 2); } } static inline void GSetPixel(Coord x_, Coord y_, IndexedColorType c_) { GraphGlobalVarType *g = GetGlobalVariables(); UInt16 o = GCoord2Offset(x_, y_); if (g->_hDensity) { #if 0 WinHandle draw = WinGetDrawWindow(); WinSetDrawWindow(_canvas); WinDrawPixel(x_, y_); WinSetDrawWindow(draw); #else g->_baseP[o] = c_; #endif } else if (_hrLib) { g->_baseP[o] = c_; } else { if (x_ % 2) { g->_baseP[o] &= 0xf0; g->_baseP[o] |= (c_ & 0x0f); } else { g->_baseP[o] &= 0x0f; g->_baseP[o] |= (c_ << 4); } } } static inline IndexedColorType GFetchPixel(Coord x_, Coord y_) { GraphGlobalVarType *g = GetGlobalVariables(); UInt16 o = GCoord2Offset(x_, y_); if (g->_hDensity) { #if 0 IndexedColorType c; WinHandle draw = WinGetDrawWindow(); WinSetDrawWindow(_canvas); c = WinGetPixel(x_, y_); WinSetDrawWindow(draw); return c; #else return g->_baseP[o]; #endif } else if (g->_hrLib) { return g->_baseP[o]; } else { if (x_ % 2) { return g->_baseP[o] & 0x0f; } else { return (g->_baseP[o] & 0xf0) >> 4; } } } #define isSjis(k_) (((k_) >= 0x80 && (k_) < 0xa0)||((k_) >= 0xe0)) static inline void GInitQueue(void) { GraphGlobalVarType *g = GetGlobalVariables(); g->_pointQ._Qstart = g->_pointQ._Qend = 0; } static inline void GShiftPoint(Coord x_, Coord y_) { GraphGlobalVarType *g = GetGlobalVariables(); g->_pointQ._Queue[g->_pointQ._Qstart].x = x_; g->_pointQ._Queue[g->_pointQ._Qstart].y = y_; if (++g->_pointQ._Qstart == MAX_QUEUE_SIZE) { g->_pointQ._Qstart = 0; } } static inline PointType* GUnshiftPoint(void) { PointType *p; GraphGlobalVarType *g = GetGlobalVariables(); if (g->_pointQ._Qstart == g->_pointQ._Qend) return NULL; p = &g->_pointQ._Queue[g->_pointQ._Qend++]; if (g->_pointQ._Qend == MAX_QUEUE_SIZE) { g->_pointQ._Qend = 0; } return p; } static void GInitColors(void) { UInt16 i; RGBColorType rgb[] = { { 0, 0x00, 0x00, 0x00}, { 0, 0x00, 0x00, 0xff}, { 0, 0xff, 0x00, 0x00}, { 0, 0xff, 0x00, 0xff}, { 0, 0x00, 0xff, 0x00}, { 0, 0x00, 0xff, 0xff}, { 0, 0xff, 0xff, 0x00}, { 0, 0xff, 0xff, 0xff}, { 0, 0x55, 0x55, 0x55}, { 0, 0x00, 0x00, 0x80}, { 0, 0x80, 0x00, 0x00}, { 0, 0x80, 0x00, 0x80}, { 0, 0x00, 0x80, 0x00}, { 0, 0x00, 0x80, 0x80}, { 0, 0x80, 0x80, 0x00}, { 0, 0xaa, 0xaa, 0xaa}, }; GraphGlobalVarType *g = GetGlobalVariables(); for (i = 0 ; i < gColorNameCandidate ; i++) { g->_colors[i] = WinRGBToIndex(&rgb[i]); WinIndexToRGB(g->_colors[i], &g->_defrgb[i]); if (g->_hrLib == 0 && !g->_hDensity) { g->_colors[i] = i; } } } /* API */ Boolean GInit(void) { SonySysFtrSysInfoP sonySysFtrSysInfoP; /* Sony CLIe System Information */ UInt32 wmVer, wmAttr; Err err = 0; Boolean res = false; Boolean col = true; UInt16 i; FontID ftab[] = { hrTinyFont, hrTinyBoldFont, hrSmallFont, hrSmallBoldFont, hrStdFont, hrBoldFont, hrLargeFont, hrLargeBoldFont }; GraphGlobalVarType *g = CreateGlobalVariables(); /* OS5 High Density Check */ g->_hDensity = false; if (FtrGet(sysFtrCreator, sysFtrNumWinVersion, &wmVer) == errNone) { if (wmVer >= 4) { /* hd interface existing */ WinScreenGetAttribute(winScreenDensity, &wmAttr); if (wmAttr == kDensityDouble) { _hDensity = true; WinSetCoordinateSystem(kCoordinatesStandard); } } } /* CLIe High Resolution Check */ if ((err = FtrGet(sonySysFtrCreator, sonySysFtrNumSysInfoP, (UInt32*)&sonySysFtrSysInfoP)) == 0) { if (sonySysFtrSysInfoP->libr & sonySysFtrSysInfoLibrHR) { /* High-resolution library available */ if ((err = SysLibFind(sonySysLibNameHR, &_hrLib))) { if (err == sysErrLibNotFound) { err = SysLibLoad('libr', sonySysFileCHRLib, &_hrLib); } } } } if (!g->_hDensity && (err || g->_hrLib == 0)) { g->_hrLib = 0; /* no library existing */ g->_width = g->_height = 160; g->_depth = 8; WinScreenMode(winScreenModeSet, &g->_width, &g->_height, &g->_depth, &col); res = true; } else { g->_width = g->_height = 320; g->_depth = 8; res = true; /* only High-resolution CLIE/OS5 high density device support */ if (g->_hDensity) { WinScreenMode(winScreenModeSet, &g->_width, &g->_height, &g->_depth, &col); } else { HROpen(g->_hrLib); HRGetAPIVersion(g->_hrLib, &g->_hrVer); HRWinScreenMode(g->_hrLib, winScreenModeSet, &g->_width, &g->_height, &g->_depth, &col); for (i = 0 ; i < 8 ; i++) { g->_fntTable[i] = ftab[i]; } } } WinScreenMode(winScreenModeGet, NULL, NULL, NULL, &col); if (!col) { if (g->_hrLib && !g->_hDensity) { HRClose(g->_hrLib); } return false; /* mono-chrome mode */ } GInitColors(); RctSetRectangle(&g->_border, 0, 0, g->_width, g->_height); if (g->_hDensity) { UInt16 coordSys = WinSetCoordinateSystem(kCoordinatesDouble); g->_canvas = WinCreateOffscreenWindow(g->_width, g->_height, nativeFormat, &err); WinSetCoordinateSystem(coordSys); } else if (g->_hrLib) { g->_canvas = HRWinCreateOffscreenWindow(g->_hrLib, g->_width, g->_height, screenFormat, &err); } if (g->_canvas == NULL) { res = false; } else { _bmpP = WinGetBitmap(g->_canvas); _baseP = BmpGetBits(g->_bmpP); GlueBmpGetDimensions(g->_bmpP, NULL, NULL, &g->_rowBytes); } return res; } Boolean GFinalize(void) { GraphGlobalVarType *g = GetGlobalVariables(); if (g->_hrLib && !g->_hDensity) { HRClose(g->_hrLib); } if (g->_canvas) { WinDeleteWindow(g->_canvas, false); } DeleteGlobalVariables(); return true; } void GChromakeyPaint(RectanglePtr clipP_, UInt8 *patP_, Boolean line_) { IndexedColorType c; WinHandle cur; UInt8 r, g, b, off; Coord x, y, dx, lx, ox; UInt16 i, j, n, coordSys; UInt16 bl, bu, br, bd; RectangleType rs; UInt8 pattern[][3] = { { 0x00, 0x00, 0x00 }, { 0xff, 0x00, 0x00 }, { 0x00, 0xff, 0x00 }, { 0xff, 0xff, 0x00 }, { 0x00, 0x00, 0xff }, { 0xff, 0x00, 0xff }, { 0x00, 0xff, 0xff }, { 0xff, 0xff, 0xff }, }; GraphGlobalVarType *g = GetGlobalVariables(); i = 0; n = patP_[i++]; for (j = 0 ; j < n ; j++) { pattern[j + 1][0] = patP_[i + j * 3 + 0]; pattern[j + 1][1] = patP_[i + j * 3 + 1]; pattern[j + 1][2] = patP_[i + j * 3 + 2]; } bl = clipP_->topLeft.x; bu = clipP_->topLeft.y; br = bl + clipP_->extent.x; bd = bu + clipP_->extent.y; cur = WinGetDrawWindow(); if (g->_hDensity) { coordSys = WinSetCoordinateSystem(kCoordinatesDouble); } for (y = bu; y < bd ; y++) { for (x = bl ; x < br ; x += 8) { lx = (br - x < 8) ? br - x : 8; for (dx = 0, ox = 7 ; dx < lx ; dx++, ox--) { c = GFetchPixel(x + dx, y); off = 1 << ox; for (j = 1 ; j <= n ; j++) { if (_colors[j] == c) { b = (pattern[j][0] & off) >> ox; r = (pattern[j][1] & off) >> ox; g = (pattern[j][2] & off) >> ox; GSetPixel(x + dx, y, _colors[(r << 1) | (g << 2) | b]); break; } } } } if (line_) { RctSetRectangle(&rs, bl, y, br - bl, 1); if (g->_hrLib) { HRWinCopyRectangle(g->_hrLib, g->_canvas, cur, &rs, bl, y, winPaint); } else { WinCopyRectangle(g->_canvas, cur, &rs, bl, y, winPaint); } } } if (!line_) { if (g->_hrLib) { HRWinCopyRectangle(g->_hrLib, g->_canvas, cur, clipP_, bl, bu, winPaint); } else { WinCopyRectangle(g->_canvas, cur, clipP_, bl, bu, winPaint); } } if (g->_hDensity) { WinSetCoordinateSystem(coordSys); } } static inline Boolean _chk(Coord x_, Coord y_, IndexedColorType c_, IndexedColorType b_) { IndexedColorType c = GFetchPixel(x_, y_); return c != c_ && c != b_; } void GPaintSpec(GPaintSpecPtr specP_) { PointType *pP; Coord bl, bu, br, bd; Coord l, r, x, y; Coord wx, wy; WinHandle cur; Coord ltx, lty, lbx, lby; Boolean uf, df; UInt16 coordSys; GraphGlobalVarType *g = GetGlobalVariables(); bl = specP_->_clipP->topLeft.x; bu = specP_->_clipP->topLeft.y; br = bl + specP_->_clipP->extent.x; bd = bu + specP_->_clipP->extent.y; x = specP_->_x + bl; y = specP_->_y + bu; ltx = lty = lbx = lby = -1; cur = WinGetDrawWindow(); if (!_chk(x, y, g->_colors[specP_->_fg], g->_colors[specP_->_bg])){ /* needless to paint */ return; } GInitQueue(); GShiftPoint(x, y); if (g->_hDensity) { coordSys = WinSetCoordinateSystem(kCoordinatesDouble); } WinSetForeColor(g->_colors[specP_->_fg]); while ((pP = GUnshiftPoint()) != NULL) { if (!_chk(pP->x, pP->y, g->_colors[specP_->_fg], g->_colors[specP_->_bg])) { /* needless to paint */ continue; } for (l = pP->x ; l >= bl ; l--) { if (!_chk(l, pP->y, g->_colors[specP_->_fg], g->_colors[specP_->_bg])) { break; } } ++l; for (r = pP->x ; r < br ; r++) { if (!_chk(r, pP->y, g->_colors[specP_->_fg], g->_colors[specP_->_bg])) { break; } } --r; /* draw current line */ if (g->_hrLib) { WinSetDrawWindow(g->_canvas); HRWinDrawLine(g->_hrLib, l, pP->y, r, pP->y); WinSetDrawWindow(cur); HRWinDrawLine(g->_hrLib, l, pP->y, r, pP->y); } else { WinSetDrawWindow(g->_canvas); WinDrawLine(l, pP->y, r, pP->y); WinSetDrawWindow(cur); WinDrawLine(l, pP->y, r, pP->y); } for (wx = l ; wx <= r ; wx++) { uf = df = false; /* scan upper line */ wy = pP->y - 1; if (wy >= bu) { uf = _chk(wx, wy, g->_colors[specP_->_fg], g->_colors[specP_->_bg]); if (uf) { if (wx + 1 <= r && !_chk(wx + 1, wy, g->_colors[specP_->_fg], g->_colors[specP_->_bg])) { /* found right edge */ GShiftPoint(wx, wy); uf = false; } else if (wx == r) { GShiftPoint(wx, wy); } } } /* scan lower line */ wy = pP->y + 1; if (wy < bd) { df = _chk(wx, wy, g->_colors[specP_->_fg], g->_colors[specP_->_bg]); if (df) { if (wx + 1 <= r && !_chk(wx + 1, wy, g->_colors[specP_->_fg], g->_colors[specP_->_bg])) { /* found right edge */ GShiftPoint(wx, wy); df = false; } else if (wx == r) { GShiftPoint(wx, wy); } } } } } if (_hDensity) { WinSetCoordinateSystem(coordSys); } } void GPaint(RectanglePtr clipP_, Coord x_, Coord y_, GColorName f_, GColorName b_) { GPaintSpecType spec; spec._clipP = clipP_; spec._x = x_; spec._y = y_; spec._fg = f_; spec._bg = b_; spec._bgBmpP = NULL; GPaintSpec(&spec); } void GDrawLine(RectanglePtr clipP_, Coord x0_, Coord y0_, Coord x1_, Coord y1_, GColorName c_) { RectangleType cur; WinHandle draw, windows[2]; UInt16 i; UInt16 coordSys; GraphGlobalVarType *g = GetGlobalVariables(); if (g->_hDensity) { coordSys = WinSetCoordinateSystem(kCoordinatesDouble); } draw = WinGetDrawWindow(); WinSetForeColor(g->_colors[c_]); windows[0] = g->_canvas; windows[1] = draw; for (i = 0 ; i < 2; i++) { WinSetDrawWindow(windows[i]); if (g->_hrLib) { if (clipP_) { HRWinGetClip(g->_hrLib, &cur); HRWinSetClip(g->_hrLib, clipP_); } HRWinDrawLine(g->_hrLib, x0_, y0_, x1_, y1_); if (clipP_) { HRWinSetClip(g->_hrLib, &cur); } } else { if (clipP_) { WinGetClip(&cur); WinSetClip(clipP_); } WinDrawLine(x0_, y0_, x1_, y1_); if (clipP_) { WinSetClip(&cur); } } } if (g->_hDensity) { WinSetCoordinateSystem(coordSys); } } GColorName GGetPixel(Coord x0_, Coord y0_) { UInt16 i, coordSys; IndexedColorType c; GColorName r = gColorInvalid; GraphGlobalVarType *g = GetGlobalVariables(); if (g->_hDensity) { coordSys = WinSetCoordinateSystem(kCoordinatesDouble); } c = GFetchPixel(x0_, y0_); for (i = 0 ; i < gColorNameCandidate ; i++) { if (g->_colors[i] == c) { r = i; break; } } if (g->_hDensity) { WinSetCoordinateSystem(coordSys); } return r; } void GDrawPixel(RectanglePtr clipP_, Coord x0_, Coord y0_, GColorName c_) { UInt16 coordSys; GraphGlobalVarType *g = GetGlobalVariables(); if (g->_hDensity) { coordSys = WinSetCoordinateSystem(kCoordinatesDouble); } WinSetForeColor(g->_colors[c_]); GSetPixel(x0_, y0_, g->_colors[c_]); if (g->_hrLib) { HRWinDrawPixel(g->_hrLib, x0_, y0_); } else { WinDrawPixel(x0_, y0_); } if (g->_hDensity) { WinSetCoordinateSystem(coordSys); } } void GDrawRectangle(RectanglePtr rP_, GColorName c_) { UInt16 coordSys; WinHandle draw = WinGetDrawWindow(); GraphGlobalVarType *g = GetGlobalVariables(); if (g->_hDensity) { coordSys = WinSetCoordinateSystem(kCoordinatesDouble); } WinSetForeColor(g->_colors[c_]); if (g->_hrLib) { WinSetDrawWindow(g->_canvas); HRWinDrawRectangle(g->_hrLib, rP_, 0); WinSetDrawWindow(draw); HRWinDrawRectangle(g->_hrLib, rP_, 0); } else { WinSetDrawWindow(g->_canvas); WinDrawRectangle(rP_, 0); WinSetDrawWindow(draw); WinDrawRectangle(rP_, 0); } if (g->_hDensity) { WinSetCoordinateSystem(coordSys); } } void GDrawChars(Boolean small_, Char *strP_, UInt16 len_, Coord x_, Coord y_, GColorName c_) { UInt16 i; UInt16 coordSys; WinHandle windows[2]; GraphGlobalVarType *g = GetGlobalVariables(); if (g->_hDensity) { coordSys = WinSetCoordinateSystem(kCoordinatesDouble); } WinSetTextColor(g->_colors[c_]); windows[0] = g->_canvas; windows[1] = WinGetDrawWindow(); if (strP_[len_ - 1] < ' ') { --len_; } for(i = 0 ; i < 2 ; i++) { WinSetDrawWindow(windows[i]); if (g->_hDensity) { if (small_){ HDWinDrawChars(strP_, len_, x_, y_); } else { WinDrawChars(strP_, len_, x_, y_); } } else { HRWinDrawChars(g->_hrLib, strP_, len_, x_, y_); } } if (g->_hDensity) { WinSetCoordinateSystem(coordSys); } } void GPaletteChange(GColorName c_) { UInt16 i; RGBColorType *mapP, rgb; MemHandle hRGB; GraphGlobalVarType *g = GetGlobalVariables(); hRGB = MemHandleNew(sizeof(RGBColorType) * 256); mapP = (RGBColorType*)MemHandleLock(hRGB); WinPalette(winPaletteGet, 0, 256, mapP); if (c_ != gColorInvalid) { WinIndexToRGB(g->_colors[c_], &rgb); } for (i = gColorBlue ; i < gColorWhite ; i++) { mapP[g->_colors[i]] = (c_ == gColorInvalid) ? g->_defrgb[i] : rgb; } WinPalette(winPaletteSet, 0, 256, mapP); MemHandleUnlock(hRGB); MemHandleFree(hRGB); } FontID GGetFont(void) { GraphGlobalVarType *g = GetGlobalVariables(); return (!g->_hDensity && g->_hrLib) ? HRFntGetFont(g->_hrLib) : FntGetFont(); } FontID GSetFont(FontID id_) { GraphGlobalVarType *g = GetGlobalVariables(); return (!g->_hDensity && g->_hrLib) ? HRFntSetFont(g->_hrLib, id_) : FntSetFont(id_); } void GFldModifyField(FieldPtr fldP) { GraphGlobalVarType *g = GetGlobalVariables(); if (g->_hDensity || g->_hrLib) { FldSetUsable(fldP, false); } } void GFldDrawField(FieldPtr fldP) { UInt16 lines, pos, offset, maxLength; UInt16 h, w, l; FontID curFont = stdFont, fldFont; Char *textP; RectangleType b; Boolean small = false; GraphGlobalVarType *g = GetGlobalVariables(); if (!g->_hDensity && g->_hrLib == 0) { FldDrawField(fldP); return; } WinPushDrawState(); if (g->_hDensity) { WinSetCoordinateSystem(kCoordinatesDouble); } FldGetBounds(fldP, &b); if (_hDensity || _hrLib) { b.topLeft.x <<= 1; b.topLeft.y <<= 1; b.extent.x <<= 1; b.extent.y <<= 1; } fldFont = FldGetFont(fldP); textP = FldGetTextPtr(fldP); maxLength = FldGetTextLength(fldP); if (textP) { GFldEraseField(fldP); if (g->_hDensity) { if (fldFont & fntAppFontCustomBase) { fldFont -= fntAppFontCustomBase; small = true; } curFont = FntSetFont(fldFont); } else if (g->_hrLib) { FontID hrFont; if (fldFont & fntAppFontCustomBase) { /* use small font */ fldFont -= fntAppFontCustomBase; small = true; } hrFont = g->_fntTable[fldFont + ((small) ? 0 : 4)]; if (fldFont == largeBoldFont) { hrFont = g->_fntTable[(small) ? 3 : 7]; } curFont = HRFntSetFont(g->_hrLib, hrFont); } h = FntLineHeight(); w = b.extent.x; if (small) { if (g->_hDensity) { h /= 2; w *= 2; } } if (!g->_hDensity && g->_hrLib && g->_hrVer >= HR_VERSION_SUPPORT_FNTSIZE) { h = HRFntLineHeight(g->_hrLib); } lines = FldGetVisibleLines(fldP); if (g->_hDensity) { lines = b.extent.y / h; } offset = FldGetScrollPosition(fldP); for (pos = 0 ; pos < lines ; pos++) { l = FldWordWrap(&textP[offset], w); GDrawChars(small, &textP[offset], l, b.topLeft.x, b.topLeft.y + pos * h, gColorBlue); offset += l; if (offset >= maxLength) { break; } } if (g->_hDensity) { FntSetFont(curFont); } else if (g->_hrLib) { HRFntSetFont(g->_hrLib, curFont); } } WinPopDrawState(); } void GFldEraseField(FieldPtr fldP) { RectangleType b; GraphGlobalVarType *g = GetGlobalVariables(); if (!g->_hDensity && g->_hrLib == 0) { FldEraseField(fldP); return; } FldGetBounds(fldP, &b); b.topLeft.x <<= 1; b.topLeft.y <<= 1; b.extent.x <<= 1; b.extent.y <<= 1; if (g->_hDensity) { WinPushDrawState(); WinSetCoordinateSystem(kCoordinatesDouble); WinEraseRectangle(&b, 0); WinPopDrawState(); } else if (g->_hrLib) { HRWinEraseRectangle(g->_hrLib, &b, 0); } } void GGetDisplayExtent(Coord *xP, Coord *yP, Boolean hd) { WinPushDrawState(); if (_hDensity) { WinSetCoordinateSystem((hd) ? kCoordinatesDouble : kCoordinatesStandard); } WinGetDisplayExtent(xP, yP); WinPopDrawState(); } UInt16 GScale(void) { GraphGlobalVarType *g = GetGlobalVariables(); return (g->_hDensity || g->_hrLib) ? 2 : 1; }