void PreviewDrawer(ControlRef Ctrl, void *Data) { // Don't need the data arg here CrosshairData &Crosshairs = GetCrosshairData(); // An alias for the global crosshair data // No need for the window context -- it's assumed Rect Bounds = {0,0,0,0}; GetControlBounds(Ctrl, &Bounds); // Get ready to draw! PenNormal(); // Draw the background RGBForeColor(&BkgdColor); PaintRect(&Bounds); // Clip to inside of box ClipRect(&Bounds); // Draw the crosshairs Crosshairs_Render(Bounds); // Draw the boundary line ForeColor(blackColor); FrameRect(&Bounds); }
void DrawTab(DialogPtr dialog, short itemNum, Boolean focus) { long id = 0; Rect r = GetDialogItemBox(dialog, itemNum); void FillRectWith3DBackground(Rect r); if (dialog == currentPreferencesDialog) if (itemNum >= M1TAB1 && itemNum <= M1TABMAX) { id = PREFERENCESPICTBASE + (itemNum - M1TAB1); if (itemNum == settings.preferencesScreen) id += 1000; } if (focus) #ifdef MAC ; #else id += 50; #endif #ifdef MAC if (id) DrawResBitmap(id, r, 0); #else r.top = r.bottom - 32; FillRectWith3DBackground(r); if (id) DrawResBitmap(id, r, SRCAND); PenNormal(); MyMoveTo(r.left + (dialog == currentPreferencesDialog ? 90 : 64), r.bottom - 2); MyLineTo(r.right, r.bottom - 2); #endif }
void box_d_item(DialogPtr dp, short item) { Rect r; Handle h; short itemType; GetDItem (dp, item, &itemType, &h, &r); PenNormal (); PenSize (2, 2); InsetRect (&r, -2, -2); FrameRect (&r); PenNormal (); }
/****************************************************** DrawCheck() - This subroutine draws a check mark at the chosen item. *****************************************************/ void DrawCheck(RECTPTR r) { PenSize(1, 2); MoveTo(r->left + 2, (r->top + r->bottom)/2); Line(2, 2); Line(6, -6); PenNormal(); }
/****************************************************** DrawArrow() - This subroutine draws an up or down arrow in the given rect. *****************************************************/ void DrawArrow(RECTPTR rPtr, short upOrDown, Boolean disabled) { short top; short mid; short i; PenNormal(); //if (disabled) PenPat((ConstPatternParam)&qd.gray); //if (disabled) PenPat((ConstPatternParam)&GRAY_BRUSH); if (disabled) PenPatQDGlobalsGray(); top = ( rPtr->bottom - rPtr->top ) / 2 + rPtr->top - 3; mid = ( rPtr->right - rPtr->left ) / 2 + rPtr->left; for ( i = 0; i < 6; i++ ) { MoveTo( mid - (6 - i), top + ( (upOrDown == kUp) ? (6 - i) : i ) ); LineTo( mid + (5 - i), top + ( (upOrDown == kUp) ? (6 - i) : i ) ); } PenNormal(); }
static pascal void drawProc(ControlRef inControl, SInt16 inPart) { #pragma unused(inControl, inPart) int i; RGBColor saveForeColor; RGBColor saveBackColor; PenState savePenState; GetForeColor(&saveForeColor); GetBackColor(&saveBackColor); GetPenState(&savePenState); RGBForeColor(&rgbBlack); RGBBackColor(&rgbWhite); PenNormal(); for (i = 0; i < sNumMonitors; i++) { RGBForeColor(&rgbGray); PaintRect(&sMonitors[i].scaledRect); if (sMonitors[i].isMain) { Rect r = sMonitors[i].scaledRect; InsetRect(&r, 1, 1); r.bottom = r.top + 6; RGBForeColor(&rgbWhite); PaintRect(&r); RGBForeColor(&rgbBlack); PenSize(1,1); MoveTo(r.left, r.bottom); LineTo(r.right, r.bottom); } if (sMonitors[i].device == sSelectedDevice) { PenSize(3,3); RGBForeColor(&rgbBlack); FrameRect(&sMonitors[i].scaledRect); } else { PenSize(1,1); RGBForeColor(&rgbBlack); FrameRect(&sMonitors[i].scaledRect); } } // restore the original pen state and colors RGBForeColor(&saveForeColor); RGBBackColor(&saveBackColor); SetPenState(&savePenState); }
static void MacInversePolyline (SHORT_POINT *points, INT n) { int i; if (n<2) return; PenMode(patXor); PenPat(qdgray); MoveTo (points[0].x, points[0].y); for (i=1; i<n; i++) LineTo (points[i].x, points[i].y); PenNormal(); }
void GetRect(Rect *zoomFrom, Rect *zoomTo) { static short numRects = 0; Rect theRect,drawRect; Point firstPt,curPt,oldPt; RgnHandle rgnHandle = NewRgn(); GrafPtr oldPort; GetPort(&oldPort); SetPort(GetWindowPort(gWindow)); PenMode(patXor); GetMouse(&firstPt); oldPt = firstPt; SetRect(&theRect,firstPt.h,firstPt.v,firstPt.h,firstPt.v); while (Button()) { GetMouse(&curPt); if (!EqualPt(curPt,oldPt)) { FixRect(&theRect,&drawRect); FrameRect(&drawRect); oldPt = curPt; theRect.right = curPt.h; theRect.bottom = curPt.v; FixRect(&theRect,&drawRect); FrameRect(&drawRect); QDFlushPortBuffer(GetWindowPort(gWindow), GetPortVisibleRegion(GetWindowPort(gWindow), rgnHandle)); } } FixRect(&theRect,&drawRect); if (numRects==0) *zoomFrom = drawRect; else *zoomTo = drawRect; numRects++; QDFlushPortBuffer(GetWindowPort(gWindow), GetPortVisibleRegion(GetWindowPort(gWindow), rgnHandle)); if (numRects >= 2) { ZoomRect(kZoomLarger, zoomFrom, zoomTo); numRects = 0; } PenNormal(); DisposeRgn(rgnHandle); SetPort(oldPort); }
void XFillPolygon( Display* display, /* Display. */ Drawable d, /* Draw on this. */ GC gc, /* Use this GC. */ XPoint* points, /* Array of points. */ int npoints, /* Number of points. */ int shape, /* Shape to draw. */ int mode) /* Drawing mode. */ { MacDrawable *macWin = (MacDrawable *) d; PolyHandle polygon; CGrafPtr saveWorld; GDHandle saveDevice; GWorldPtr destPort; int i; destPort = TkMacGetDrawablePort(d); display->request++; GetGWorld(&saveWorld, &saveDevice); SetGWorld(destPort, NULL); TkMacSetUpClippingRgn(d); TkMacSetUpGraphicsPort(gc); PenNormal(); polygon = OpenPoly(); MoveTo((short) (macWin->xOff + points[0].x), (short) (macWin->yOff + points[0].y)); for (i = 1; i < npoints; i++) { if (mode == CoordModePrevious) { Line((short) (macWin->xOff + points[i].x), (short) (macWin->yOff + points[i].y)); } else { LineTo((short) (macWin->xOff + points[i].x), (short) (macWin->yOff + points[i].y)); } } ClosePoly(); FillCPoly(polygon, gPenPat); KillPoly(polygon); SetGWorld(saveWorld, saveDevice); }
void TkMacSetUpGraphicsPort( GC gc) /* GC to apply to current port. */ { RGBColor macColor; if (gPenPat == NULL) { gPenPat = NewPixPat(); } if (TkSetMacColor(gc->foreground, &macColor) == true) { /* TODO: cache RGBPats for preformace - measure gains... */ MakeRGBPat(gPenPat, &macColor); } PenNormal(); if(gc->function == GXxor) { PenMode(patXor); } if (gc->line_width > 1) { PenSize(gc->line_width, gc->line_width); } if (gc->line_style != LineSolid) { unsigned char *p = (unsigned char *) &(gc->dashes); /* * Here the dash pattern should be set in the drawing, * environment, but I don't know how to do that for the Mac. * * p[] is an array of unsigned chars containing the dash list. * A '\0' indicates the end of this list. * * Someone knows how to implement this? If you have a more * complete implementation of SetUpGraphicsPort() for * the Mac (or for Windows), please let me know. * * Jan Nijtmans * CMG Arnhem, B.V. * email: [email protected] (private) * [email protected] (work) * url: http://purl.oclc.org/net/nijtmans/ */ } }
void x_redraw_status_lines() { // OG Disable status line #ifndef ACTIVEGS Rect rect; Pattern white_pattern; char tmp_buf[256]; char *buf; int len; int line; int height; int margin; SetPortWindowPort(g_main_window); PenNormal(); height = 16; margin = 0; TextFont(g_status_font_family); TextFace(normal); TextSize(12); SetRect(&rect, 0, X_A2_WINDOW_HEIGHT + margin, X_A2_WINDOW_WIDTH, X_A2_WINDOW_HEIGHT + margin + MAX_STATUS_LINES*height); GetQDGlobalsWhite(&white_pattern); FillRect(&rect, &white_pattern); for(line = 0; line < MAX_STATUS_LINES; line++) { buf = g_status_ptrs[line]; if(buf == 0) { /* skip it */ continue; } MoveTo(10, X_A2_WINDOW_HEIGHT + height*line + margin + height); len = MIN(250, strlen(buf)); strncpy(&tmp_buf[1], buf, len); tmp_buf[0] = len; DrawString((const unsigned char*)&tmp_buf[0]); } #endif }
void DrawObjectsList2(WindowRef w, RECTPTR r, long n) // called once for each item in VList to draw nth line { char s[256]; short right, style = normal; Point p; ListItem item = model->GetNthListItem(n, 0, &style, s); if (item.owner == 0) return; GetPen(&p); PenNormal(); right = DrawBullet(item, r, FALSE, 0); MyMoveTo(right + 4, p.v - OBJECTLINEOFFSET); // set text-face according to style requested TextFontSizeFace(kFontIDGeneva,LISTTEXTSIZE,style); drawstring(s); DrawBullet(item, r, TRUE, 0); TextFontSizeFace(kFontIDGeneva,LISTTEXTSIZE,normal); }
static void InvMarker (SHORT_POINT point) { Rect r; PolyHandle myPoly; short n,s,S,x,y; s = currgw->marker_size/2; S = 1.41*s; n = currgw->marker_id; x = point.x; y = point.y; r.top = y-s; r.bottom = y+s; r.left = x-s; r.right = x+s; switch (n) { case EMPTY_SQUARE_MARKER : PenMode(patXor); FrameRect(&r); break; case GRAY_SQUARE_MARKER : PenMode(patXor); PenPat(qdgray); PaintRect(&r); PenNormal(); break; case FILLED_SQUARE_MARKER : PenMode(patXor); PenPat(qdgray); PaintRect(&r); break; case EMPTY_CIRCLE_MARKER : PenMode(patXor); FrameOval(&r); break; case GRAY_CIRCLE_MARKER : PenMode(patXor); PenPat(qdgray); PaintOval(&r); PenNormal(); break; case FILLED_CIRCLE_MARKER : PenMode(patXor); PenPat(qdgray); PaintOval(&r); break; case EMPTY_RHOMBUS_MARKER : PenMode(patXor); PenPat(qdgray); MoveTo(x,y+S); LineTo(x+S,y); LineTo(x,y-S); LineTo(x-S,y); LineTo(x,y+S); break; case GRAY_RHOMBUS_MARKER : PenMode(patXor); PenPat(qdgray); myPoly = OpenPoly(); MoveTo(x,y+S); LineTo(x+S,y); LineTo(x,y-s); LineTo(x-S,y); LineTo(x,y+S); ClosePoly(); InvertPoly(myPoly); KillPoly(myPoly); PenNormal(); break; case FILLED_RHOMBUS_MARKER : myPoly = OpenPoly(); MoveTo(x,y+S); LineTo(x+S,y); LineTo(x,y-S); LineTo(x-S,y); LineTo(x,y+S); ClosePoly(); InvertPoly(myPoly); KillPoly(myPoly); PenNormal(); break; case PLUS_MARKER : PenMode(patXor); PenPat(qdgray); MoveTo(x,y+s); LineTo(x,y-s); MoveTo(x-s,y); LineTo(x+s,y); break; case CROSS_MARKER : PenMode(patXor); PenPat(qdgray); MoveTo(x-s,y+s); LineTo(x+s,y-s); MoveTo(x-s,y-s); LineTo(x+s,y+s); break; default : break; } PenNormal(); }
short DrawBullet(ListItem item, RECTPTR r, Boolean draw, RECTPTR box) { Rect b; Rect frame; PicHandle p = nil; #ifdef MAC MySetRect(&b, 5 + item.indent * 12, r->top + 4, 5 + item.indent * 12 + 6, r->bottom - 4); #else MySetRect(&b, 7 + item.indent * 12, r->top + 4, 7 + item.indent * 12 + 6, r->bottom - 5); #endif if (draw) { PenNormal(); RGBForeColor(&colors[BLACK]); switch (item.bullet) { case BULLET_DASH: MyMoveTo(b.left, (b.top + b.bottom) / 2); MyLineTo(b.right, (b.top + b.bottom) / 2); break; case BULLET_EMPTYBOX: b.left+=1;b.right+=1; #ifdef MAC p = GetPicture (EMPTYBOXPICT); if (!p) { SysBeep(1);break; } //frame = (**p).picFrame; frame = GetPICTFrame(p); MyOffsetRect(&frame, b.left, b.top); DrawPicture(p, &frame); #else MyFrameRect(&b); #endif b.left-=1;b.right-=1; break; case BULLET_FILLEDBOX: b.left+=1;b.right+=1; #ifdef MAC p = GetPicture (FILLEDBOXPICT); if (!p) { SysBeep(1);break; } //frame = (**p).picFrame; frame = GetPICTFrame(p); MyOffsetRect(&frame, b.left, b.top); DrawPicture(p, &frame); #else PaintRect(&b); #endif // MyFrameRect(&b); // MyMoveTo(b.left,b.top); // MyLineTo(b.right-1,b.bottom-1); // MyMoveTo(b.right-1,b.top); // MyLineTo(b.left,b.bottom-1); b.left-=1;b.right-=1; break; case BULLET_OPENTRIANGLE: case BULLET_CLOSEDTRIANGLE: DrawTriangle(b, item.bullet); break; } } if (box) (*box) = b; // line up the text with an indented bullet b.right += 3; // mac tweek by sohail return b.right; }
pascal void main(short message,MenuHandle theMenu,Rect *menuRect,Point hitPt,short *whichItem) #endif { short i,j; short currentItem; Rect r; OSErr err; long response; #if TARGET_API_MAC_CARBON MenuTrackingData *trackingData; HiliteMenuItemData *hiliteData; #endif switch (message) { case kMenuDrawMsg: /* メニューの描画 */ err=Gestalt(gestaltAppearanceAttr,&response); if (err==noErr && (response & (kGestaltMask << gestaltAppearanceExists))) { /* Appearance Managerのバージョンが1.0.1以降かどうか */ err=Gestalt(gestaltAppearanceVersion,&response); if (err==noErr && response>=0x0101) #if powerc if (DrawThemeMenuBackground != nil) #endif err=DrawThemeMenuBackground(menuRect,kThemeMenuTypePopUp); } /* チェック */ for (i=0; i<kRows; i++) for (j=0; j<kColumns; j++) { short markChar; GetItemRect(&r,menuRect,i*kColumns+j); DrawItem(&r,i,j); GetItemMark(theMenu,i*kColumns+j+1,&markChar); if (markChar != noMark) { InsetRect(&r,2,2); PenMode(srcXor); FrameRect(&r); PenNormal(); } } break; #if TARGET_API_MAC_CARBON case kMenuFindItemMsg: trackingData=(MenuTrackingData *)whichItem; currentItem=0; if (PtInRect(hitPt,menuRect)) { for (i=0; i<kRows; i++) for (j=0; j<kColumns; j++) { GetItemRect(&r,menuRect,i*kColumns+j); if (PtInRect(hitPt,&r)) { currentItem=i*kColumns+j+1; break; } } } trackingData->itemSelected = currentItem; trackingData->itemUnderMouse = currentItem; break; case kMenuHiliteItemMsg: hiliteData=(HiliteMenuItemData *)whichItem; if (hiliteData->previousItem != 0) { GetItemRect(&r,menuRect,hiliteData->previousItem-1); InsetRect(&r,1,1); PenMode(srcXor); FrameRect(&r); PenNormal(); } if (hiliteData->newItem != 0) { GetItemRect(&r,menuRect,hiliteData->newItem-1); InsetRect(&r,1,1); PenMode(srcXor); FrameRect(&r); PenNormal(); } break; #else case mChooseMsg: /* メニューの選択(反転) */ currentItem=0; if (PtInRect(hitPt,menuRect)) { for (i=0; i<kRows; i++) for (j=0; j<kColumns; j++) { GetItemRect(&r,menuRect,i*kColumns+j); if (PtInRect(hitPt,&r)) { currentItem=i*kColumns+j+1; break; } } } if (currentItem!=*whichItem) { if (currentItem!=0) { GetItemRect(&r,menuRect,currentItem-1); InsetRect(&r,1,1); PenMode(srcXor); FrameRect(&r); PenNormal(); } if (*whichItem!=0) { GetItemRect(&r,menuRect,*whichItem-1); InsetRect(&r,1,1); PenMode(srcXor); FrameRect(&r); PenNormal(); } *whichItem=currentItem; } break; #endif case kMenuSizeMsg: /* メニューのサイズを設定 */ #if TARGET_API_MAC_CARBON SetMenuWidth(theMenu,kRows*kItemWidth); SetMenuHeight(theMenu,kColumns*kItemHeight); #else (**theMenu).menuWidth=kRows*kItemWidth; (**theMenu).menuHeight=kColumns*kItemHeight; #endif break; case kMenuPopUpMsg: /* ポップアップのRectを計算 */ /* theMenu メニューへのハンドル whichItem 最初に選ばれているアイテム hitPt ポップアップメニューの左上 menuRect ポップアップのRectを入れて返す */ /* なぜかhitPtのhとvは入れ代わっている */ SetRect(menuRect,hitPt.v,hitPt.h,hitPt.v+kRows*kItemWidth,hitPt.h+kColumns*kItemHeight); break; case kMenuThemeSavvyMsg: *whichItem=kThemeSavvyMenuResponse; break; } }
static void Marker (short n, short s, short x, short y) { Rect r; PolyHandle myPoly; s = s/2; r.top = y-s; r.bottom = y+s; r.left = x-s; r.right = x+s; n = n%11; switch (n) { case 0 : FrameRect(&r); break; case 1 : PenPat(&qd.gray); PaintRect(&r); PenNormal(); break; case 2 : PaintRect(&r); break; case 3 : FrameOval(&r); break; case 4 : PenPat(&qd.gray); PaintOval(&r); PenNormal(); break; case 5 : PaintOval(&r); break; case 6 : MoveTo(x,y+s); LineTo(x+s,y); LineTo(x,y-s); LineTo(x-s,y); LineTo(x,y+s); break; case 7 : PenPat(&qd.gray); myPoly = OpenPoly(); MoveTo(x,y+s); LineTo(x+s,y); LineTo(x,y-s); LineTo(x-s,y); LineTo(x,y+s); ClosePoly(); PaintPoly(myPoly); KillPoly(myPoly); PenNormal(); break; case 8 : myPoly = OpenPoly(); MoveTo(x,y+s); LineTo(x+s,y); LineTo(x,y-s); LineTo(x-s,y); LineTo(x,y+s); ClosePoly(); PaintPoly(myPoly); KillPoly(myPoly); PenNormal(); break; case 9 : MoveTo(x,y+s); LineTo(x,y-s); MoveTo(x-s,y); LineTo(x+s,y-s); break; case 10 : MoveTo(x-s,y+s); LineTo(x+s,y-s); MoveTo(x-s,y-s); LineTo(x+s,y+s); break; } }
// Will draw in center of view rectangle in the current QD graphics context; // modeled after fps display. // It won't try to clip the ends of the lines. bool Crosshairs_Render(Rect &ViewRect) { if (!_Crosshairs_IsActive) return _Crosshairs_IsActive; // Get the crosshair data CrosshairData &Crosshairs = GetCrosshairData(); // Push previous state PenState OldPen; RGBColor OldBackColor, OldForeColor; GetPenState(&OldPen); GetBackColor(&OldBackColor); GetForeColor(&OldForeColor); // Get ready to draw the crosshairs PenNormal(); // Drawing color RGBForeColor(&Crosshairs.Color); // Get the center location from the view rectangle // Shift it down one, so that even line widths can come out right. short XCen = ((ViewRect.left + ViewRect.right) >> 1) - 1; short YCen = ((ViewRect.top + ViewRect.bottom) >> 1) - 1; // Separate for X and Y; the points are three on top/left and three on top/right: // Line-split position // Octagon vertex (half-way) // Farthest extent short OctaPoints[2][6]; short Len; switch(Crosshairs.Shape) { case CHShape_RealCrosshairs: PenSize(1,Crosshairs.Thickness); // Left MoveTo(XCen-Crosshairs.FromCenter+Crosshairs.Thickness-1,YCen); Line(-Crosshairs.Length,0); // Right MoveTo(XCen+Crosshairs.FromCenter,YCen); Line(Crosshairs.Length,0); PenSize(Crosshairs.Thickness,1); // Top MoveTo(XCen,YCen-Crosshairs.FromCenter+Crosshairs.Thickness-1); Line(0,-Crosshairs.Length); // Bottom MoveTo(XCen,YCen+Crosshairs.FromCenter); Line(0,Crosshairs.Length); break; case CHShape_Circle: // This will really be an octagon, for OpenGL-rendering convenience // Precalculate the line endpoints, for convenience Len = Crosshairs.Length; OctaPoints[0][0] = XCen - Len; OctaPoints[0][5] = XCen + Len; OctaPoints[1][0] = YCen - Len; OctaPoints[1][5] = YCen + Len; Len = Len/2; OctaPoints[0][1] = XCen - Len; OctaPoints[0][4] = XCen + Len; OctaPoints[1][1] = YCen - Len; OctaPoints[1][4] = YCen + Len; Len = MIN(Len,Crosshairs.FromCenter); OctaPoints[0][2] = XCen - Len; OctaPoints[0][3] = XCen + Len; OctaPoints[1][2] = YCen - Len; OctaPoints[1][3] = YCen + Len; // We need to do 12 line segments, so we do them in 2*2*3 fashion for (int ix=0; ix<2; ix++) { int ixi = (ix > 0) ? 5 : 0; int ixid = (ix > 0) ? -1 : 1; for (int iy=0; iy<2; iy++) { int iyi = (iy > 0) ? 5 : 0; int iyid = (iy > 0) ? -1 : 1; // Vertical PenSize(Crosshairs.Thickness,1); MoveTo(OctaPoints[0][ixi],OctaPoints[1][iyi+2*iyid]); LineTo(OctaPoints[0][ixi],OctaPoints[1][iyi+iyid]); // Diagonal PenSize(Crosshairs.Thickness,Crosshairs.Thickness); LineTo(OctaPoints[0][ixi+ixid],OctaPoints[1][iyi]); // Horizontal PenSize(1,Crosshairs.Thickness); LineTo(OctaPoints[0][ixi+2*ixid],OctaPoints[1][iyi]); } } break; } // Pop previous state SetPenState(&OldPen); RGBBackColor(&OldBackColor); RGBForeColor(&OldForeColor); return _Crosshairs_IsActive; }
Boolean ThermDialog::DisplayTherm(int k,int maxk,unsigned char *st) { Rect r; int maxr; Handle h; short itemType; long temp; GrafPtr tdp; WindowPtr window; short thePart; Rect screenRect, updateRect; Point aPoint = {100, 100}; Boolean QuitFlag = FALSE; short item = 0; EventRecord event; short the_part; DialogPtr hitdp; GetPort(&tdp); SetPort(dp); if (st != NULL) { GetDItem (dp,ids[THERM_TEXT], &itemType, &h, &r); SetIText(h,st); } GetDItem (dp, ids[THERM_BOX], &itemType, &h, &r); if (k == -1) k = old_k; if (maxk == -1) maxk = old_maxk; maxr = r.right; temp = ((long)k*((long)r.right - (long)r.left))/(long)maxk; r.right = r.left + temp; if (r.right>maxr) r.right=maxr; old_k = k; old_maxk = maxk; PenNormal (); PenPat(&qd.gray); PaintRect(&r); PenNormal (); SetPort(tdp); if (GetNextEvent(0xFFFF,&event)) { if (event.what == mouseDown) { the_part = FindWindow(event.where, &window); if (IsDialogEvent(&event)) { DialogSelect(&event,&hitdp,&item); if ((hitdp == dp) && (item == ids[THERM_CANCEL])) { Quit = TRUE; return FALSE; } } else switch (the_part) { case inSysWindow: SystemClick (&event, window); break; case inDrag: screenRect = (**GetGrayRgn()).rgnBBox; DragWindow( window, event.where, &screenRect ); break; } } else if (event.what == keyDown) { if ((event.modifiers & 0x0100) && ( (event.message) & charCodeMask == 0x02E)) { Quit = TRUE; return FALSE; } } else if (event.what == updateEvt) { window = (WindowPtr)event.message; updateRect = (**(window->visRgn)).rgnBBox; SetPort( window ) ; BeginUpdate( window ); DrawDialog( window ); if (dp == window) box_d_item(dp,ids[THERM_BOX]); EndUpdate( window ); } } if (Quit) return FALSE; return TRUE; }
void ZoomRect (Rect *smallrect, Rect *bigrect, Boolean zoomup) { #if USE_DRAG_MANAGER_FOR_ZOOMS if (gZoomOn) { if (zoomup) ZoomRects(smallrect,bigrect,10,kZoomNoAcceleration); else ZoomRects(bigrect,smallrect,10,kZoomNoAcceleration); } #else Fixed factor; Rect rect1, rect2, rect3, rect4; GrafPtr savePort, deskPort; int i; long tm; if (gZoomOn) { GetPort (&savePort); OpenPort (deskPort = (GrafPtr) NewPtr (sizeof (GrafPort))); InitPort (deskPort); SetPort (deskPort); PenPat (&qd.gray); //¥ Original, comment for black zoom. // PenPat (&qd.black); //¥ Uncomment for black zoom. PenMode (notPatXor); //¥ Original, comment for black zoom. // PenMode (patXor); //¥ Uncomment for black zoom. if (zoomup) { rect1 = *smallrect; factor = FixRatio (6, 5); fract = FixRatio (541, 10000); } else { rect1 = *bigrect; factor = FixRatio (5, 6); fract = ONE; } rect2 = rect1; rect3 = rect1; FrameRect (&rect1); for (i = 1; i <= ZOOMSTEPS; i++) { rect4.left = Blend (smallrect->left, bigrect->left); rect4.right = Blend (smallrect->right, bigrect->right); rect4.top = Blend (smallrect->top, bigrect->top); rect4.bottom = Blend (smallrect->bottom, bigrect->bottom); FrameRect (&rect4); FrameRect (&rect1); rect1 = rect2; rect2 = rect3; rect3 = rect4; fract = FixMul (fract, factor); tm = TickCount (); // These two lines are a crude waitvbl while (tm == TickCount ()); } FrameRect (&rect1); FrameRect (&rect2); FrameRect (&rect3); ClosePort (deskPort); DisposePtr ((Ptr) deskPort); PenNormal (); SetPort (savePort); } #endif }
/**************************************************************** PopDraw() is the function associated with the user item that invokes the popup menu. We draw the box to look like a menu cell, and then call the appropriate drawProc to fill in the cell with the actual contents. If the drawProc is nil, we draw the menu item as text. We gray the cell if the menu is disabled. Finally, we draw a down arrow to indicate that the button is a popup menu. If the popup item is static, we only draw the cell contents. ****************************************************************/ pascal_ifMac void PopDraw(DialogPtr theDialog, short itemNum) { GrafPtr savePort; short theType; Handle itemHandle; Rect itemBox; Rect cellBox; MenuHandle theMenu; //SysEnvRec theWorld; RGBColor SaveBack, SaveFore, DefaultBack, DefaultFore; char name[256]; short i; short drawStringFlag; // Added by Glen to code for support of Type-in Pop-Up menus // if drawStringFlag = 1 then we don't draw text string ... drawStringFlag = 0; for ( i = 0 ; i < sa_numPopUps ; i++ ) if ( (sa_popTable[i].dialogPtr == theDialog) && (sa_popTable[i].popupItemNum == itemNum) ) break; if (i == sa_numPopUps) { SysBeep(1); return; } // should not happen since the dialog must have been registered // for PopDraw to have been called GetPortGrafPtr(&savePort); SetPortDialogPort(theDialog); // SysEnvirons(curSysEnvVers,&theWorld); // if (theWorld.hasColorQD) { if (ColorQDAvailable()) { GetForeColor(&SaveFore); GetBackColor(&SaveBack); DefaultMenuColors(&DefaultFore, &DefaultBack); if (sa_popTable[i].bStatic) { DefaultFore = SaveFore; DefaultBack = SaveBack; } } theMenu = GetMenuHandle(sa_popTable[i].menuID); if (!theMenu) { SysBeep(1); return; } /* change item's width to match the menu */ GetDialogItem(theDialog,itemNum,&theType,&itemHandle,&itemBox); CalcMenuSize(theMenu); if (sa_popTable[i].itemWidth == 0) { if (sa_popTable[i].drawProc == nil) // itemBox.right = itemBox.left + (**theMenu).menuWidth + 20 + 2; itemBox.right = itemBox.left + GetMenuWidth(theMenu) + 20 + 2; else //itemBox.right = itemBox.left + (**theMenu).menuWidth + 2; itemBox.right = itemBox.left + GetMenuWidth(theMenu) + 2; } else if (sa_popTable[i].itemWidth == -1) { // Type-in Pop-Up Menu itemBox.right = itemBox.left + 20 + 2; drawStringFlag = 1; } else itemBox.right = itemBox.left + sa_popTable[i].itemWidth + 2; SetDialogItem(theDialog,itemNum,theType,itemHandle,&itemBox); /* draw the box */ if (TRUE) { // !sa_popTable[i].bStatic // if (theWorld.hasColorQD) RGBBackColor(&DefaultBack); if (ColorQDAvailable()) RGBBackColor(&DefaultBack); EraseRect( &itemBox ); // if (theWorld.hasColorQD) RGBForeColor(&SaveFore); if (ColorQDAvailable()) RGBForeColor(&SaveFore); PenNormal(); // if (sa_popTable[i].bStatic) PenPat((ConstPatternParam)&qd.gray); //if (sa_popTable[i].bStatic) PenPat((ConstPatternParam)&GRAY_BRUSH()); //if (sa_popTable[i].bStatic) PenPat((ConstPatternParam)&GRAY_BRUSH); if (sa_popTable[i].bStatic) PenPatQDGlobalsGray(); FrameRect(&itemBox); /* draw the shadow */ MoveTo(itemBox.left + 3, itemBox.bottom); Line((itemBox.right - itemBox.left) - 3, 0); Line(0, -((itemBox.bottom - itemBox.top) - 2)); PenNormal(); } else EraseRect( &itemBox ); /* draw the current item in the box */ // if (theWorld.hasColorQD) RGBForeColor(&DefaultFore); if (ColorQDAvailable()) RGBForeColor(&DefaultFore); // Draw text if no Type-in Pop-Up if(drawStringFlag == 0){ if (sa_popTable[i].drawProc != nil) { cellBox = itemBox; InsetRect(&cellBox, 1, 1); (* sa_popTable[i].drawProc) (theMenu, sa_popTable[i].lastItemSelected, &cellBox, // so the drawProc gets the same-size rect, // whether it's drawing in the menu or in the pop-box true, // since we are indeed drawing a pop box item //&theWorld, &DefaultFore, &DefaultBack); } else { MoveTo(itemBox.left + 15, itemBox.top + 4 + (itemBox.bottom - itemBox.top)/2); GetMenuItemText(theMenu, sa_popTable[i].lastItemSelected, (unsigned char *)name); DrawString((unsigned char *)name); } } if (TRUE) { // !sa_popTable[i].bStatic /* cover the item in gray if the menu is disabled */ // if (!((**theMenu).enableFlags & ENABLE_BIT)) { #if TARGET_API_MAC_CARBON Boolean menuIsEnabled = IsMenuItemEnabled(theMenu,0); #else Boolean menuIsEnabled = (**theMenu).enableFlags & ENABLE_BIT; #endif if (!menuIsEnabled) { //PenPat((ConstPatternParam)&qd.gray); //PenPat((ConstPatternParam)&GRAY_BRUSH); PenPatQDGlobalsGray(); PenMode(patOr); //if (theWorld.hasColorQD) RGBForeColor(&DefaultBack); if (ColorQDAvailable()) RGBForeColor(&DefaultBack); else ForeColor(whiteColor); PaintRect(&itemBox); PenNormal(); // if (theWorld.hasColorQD) RGBForeColor(&DefaultFore); if (ColorQDAvailable()) RGBForeColor(&DefaultFore); else ForeColor(blackColor); } /* draw the down arrow */ itemBox.left = itemBox.right - 20; DrawArrow(&itemBox, kDown, sa_popTable[i].bStatic); } //if (theWorld.hasColorQD) { if (ColorQDAvailable()) { RGBForeColor(&SaveFore); RGBBackColor(&SaveBack); } SetPortGrafPort(savePort); }
void wxMacToolTip::Draw() { if ( m_label.Length() == 0 ) return ; if ( m_window == s_ToolTipWindowRef ) { m_shown = true ; #if TARGET_CARBON HMHelpContentRec tag ; tag.version = kMacHelpVersion; SetRect( &tag.absHotRect , m_position.x - 2 , m_position.y - 2 , m_position.x + 2 , m_position.y + 2 ) ; QDLocalToGlobalRect( GetWindowPort( m_window ) , &tag.absHotRect ) ; m_helpTextRef.Assign( m_label , wxFONTENCODING_DEFAULT ) ; tag.content[kHMMinimumContentIndex].contentType = kHMCFStringContent ; tag.content[kHMMinimumContentIndex].u.tagCFString = m_helpTextRef ; tag.content[kHMMaximumContentIndex].contentType = kHMCFStringContent ; tag.content[kHMMaximumContentIndex].u.tagCFString = m_helpTextRef ; tag.tagSide = kHMDefaultSide; HMDisplayTag( &tag ); #else wxMacPortStateHelper help( (GrafPtr) GetWindowPort( m_window ) ); FontFamilyID fontId ; Str255 fontName ; SInt16 fontSize ; Style fontStyle ; GetThemeFont(kThemeSmallSystemFont , GetApplicationScript() , fontName , &fontSize , &fontStyle ) ; GetFNum( fontName, &fontId ); TextFont( fontId ) ; TextSize( fontSize ) ; TextFace( fontStyle ) ; FontInfo fontInfo; ::GetFontInfo(&fontInfo); short lineh = fontInfo.ascent + fontInfo.descent + fontInfo.leading; short height = 0 ; int i = 0 ; int length = m_label.Length() ; int width = 0 ; int thiswidth = 0 ; int laststop = 0 ; wxCharBuffer text = m_label.mb_str( wxConvLocal) ; while( i < length ) { if( text[i] == 13 || text[i] == 10) { thiswidth = ::TextWidth( text , laststop , i - laststop ) ; if ( thiswidth > width ) width = thiswidth ; height += lineh ; laststop = i+1 ; } i++ ; } if ( i - laststop > 0 ) { thiswidth = ::TextWidth( text , laststop , i - laststop ) ; if ( thiswidth > width ) width = thiswidth ; height += lineh ; } m_rect.left = m_position.x + kTipOffset; m_rect.top = m_position.y + kTipOffset; m_rect.right = m_rect.left + width + 2 * kTipBorder; m_rect.bottom = m_rect.top + height + 2 * kTipBorder; Rect r ; GetPortBounds( GetWindowPort( m_window ) , &r ) ; if ( m_rect.top < 0 ) { m_rect.bottom += -m_rect.top ; m_rect.top = 0 ; } if ( m_rect.left < 0 ) { m_rect.right += -m_rect.left ; m_rect.left = 0 ; } if ( m_rect.right > r.right ) { m_rect.left -= (m_rect.right - r.right ) ; m_rect.right = r.right ; } if ( m_rect.bottom > r.bottom ) { m_rect.top -= (m_rect.bottom - r.bottom) ; m_rect.bottom = r.bottom ; } ClipRect( &m_rect ) ; BackColor( whiteColor ) ; ForeColor(blackColor ) ; GWorldPtr port ; NewGWorld( &port , wxDisplayDepth() , &m_rect , NULL , NULL , 0 ) ; CGrafPtr origPort ; GDHandle origDevice ; GetGWorld( &origPort , &origDevice ) ; SetGWorld( port , NULL ) ; m_backpict = OpenPicture(&m_rect); CopyBits(GetPortBitMapForCopyBits(GetWindowPort(m_window)), GetPortBitMapForCopyBits(port), &m_rect, &m_rect, srcCopy, NULL); ClosePicture(); SetGWorld( origPort , origDevice ) ; DisposeGWorld( port ) ; PenNormal() ; RGBColor tooltipbackground = { 0xFFFF , 0xFFFF , 0xC000 } ; BackColor( whiteColor ) ; RGBForeColor( &tooltipbackground ) ; PaintRect( &m_rect ) ; ForeColor(blackColor ) ; FrameRect( &m_rect ) ; SetThemeTextColor(kThemeTextColorNotification,wxDisplayDepth(),true) ; ::MoveTo( m_rect.left + kTipBorder , m_rect.top + fontInfo.ascent + kTipBorder); i = 0 ; laststop = 0 ; height = 0 ; while( i < length ) { if( text[i] == 13 || text[i] == 10) { ::DrawText( text , laststop , i - laststop ) ; height += lineh ; ::MoveTo( m_rect.left + kTipBorder , m_rect.top + fontInfo.ascent + kTipBorder + height ); laststop = i+1 ; } i++ ; } ::DrawText( text , laststop , i - laststop ) ; ::TextMode( srcOr ) ; #endif } }
void DrawLatLongLines(Rect r, WorldRect view) { Boolean latDivFound = FALSE, longDivFound = FALSE; short *precision, *subSteps, latPrecision, longPrecision, latSubSteps = 0, longSubSteps = 0; long i, j, latStep, longStep, latRange, longRange, units, space; double x, y, properLatDiv, properLongDiv, firstLat, firstLong, *incVals; RGBColor saveColor; static double incVals1[NUMINCREMENTS] = { // for DEGREES format THOUSANDTH / 10, THOUSANDTH / 5, THOUSANDTH / 2, THOUSANDTH, THOUSANDTH * 2, THOUSANDTH * 5, HUNDREDTH, HUNDREDTH * 2, HUNDREDTH * 2.5, HUNDREDTH * 5, HUNDREDTH * 10, HUNDREDTH * 25, HUNDREDTH * 50, DEGREE, DEGREE * 2, DEGREE * 3, DEGREE * 5, DEGREE * 10, DEGREE * 20, DEGREE * 30, DEGREE * 60, DEGREE * 90, DEGREE * 120, DEGREE * 180 }; static short precision1[NUMINCREMENTS] = { 6, 6, 6, 6, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; static short subSteps1[NUMINCREMENTS] = { 5, 5, 4, 5, 4, 5, 5, 4, 4, 5, 5, 4, 4, 5, 4, 6, 5, 5, 4, 6, 6, 4, 4, 6 }; static double incVals2[NUMINCREMENTS] = { // for DEGMIN format THOUSANDTH / 10, THOUSANDTH / 5, THOUSANDTH / 2, THOUSANDTH, THOUSANDTH * 2, THOUSANDTH * 5, MINUTE, MINUTE * 2, MINUTE * 3, MINUTE * 5, MINUTE * 10, MINUTE * 20, MINUTE * 30, DEGREE, DEGREE * 2, DEGREE * 3, DEGREE * 5, DEGREE * 10, DEGREE * 20, DEGREE * 30, DEGREE * 60, DEGREE * 90, DEGREE * 120, DEGREE * 180 }; static short precision2[NUMINCREMENTS] = { 6, 6, 6, 6, 6, 6, 6, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; static short subSteps2[NUMINCREMENTS] = { 5, 5, 4, 5, 4, 5, 6, 4, 6, 5, 5, 4, 6, 5, 4, 6, 5, 5, 4, 6, 6, 4, 4, 6 }; static double incVals3[NUMINCREMENTS] = { // for DMS format SECOND * 2, SECOND * 2, SECOND * 2, SECOND * 5, SECOND * 15, SECOND * 30, MINUTE, MINUTE * 2, MINUTE * 3, MINUTE * 5, MINUTE * 10, MINUTE * 20, MINUTE * 30, DEGREE, DEGREE * 2, DEGREE * 3, DEGREE * 5, DEGREE * 10, DEGREE * 20, DEGREE * 30, DEGREE * 60, DEGREE * 90, DEGREE * 120, DEGREE * 180 }; static short precision3[NUMINCREMENTS] = { 6, 6, 6, 6, 6, 6, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; static short subSteps3[NUMINCREMENTS] = { 4, 4, 4, 5, 5, 6, 6, 4, 6, 5, 5, 4, 6, 5, 4, 6, 5, 5, 4, 6, 6, 4, 4, 6 }; TextFontSize(kFontIDMonaco,9); GetForeColor(&saveColor); PenNormal(); if (settings.customGrid) { longDivFound = TRUE; properLongDiv = settings.longLabelSpace; switch (settings.longLabelUnits) { case DEGREES: properLongDiv *= DEGREE; break; case MINUTES: properLongDiv *= MINUTE; break; case SECONDS: properLongDiv *= SECOND; break; } space = settings.longLineSpace; switch (settings.longLineUnits) { case DEGREES: space *= DEGREE; break; case MINUTES: space *= MINUTE; break; case SECONDS: space *= SECOND; break; } longSubSteps = properLongDiv / space; if (longSubSteps) longStep = properLongDiv / longSubSteps; switch (settings.longLineUnits) { case DEGREES: longPrecision = 0; break; case MINUTES: longPrecision = 3; break; case SECONDS: longPrecision = 6; break; } latDivFound = TRUE; properLatDiv = settings.latLabelSpace; switch (settings.latLabelUnits) { case DEGREES: properLatDiv *= DEGREE; break; case MINUTES: properLatDiv *= MINUTE; break; case SECONDS: properLatDiv *= SECOND; break; } space = settings.latLineSpace; switch (settings.latLineUnits) { case DEGREES: space *= DEGREE; break; case MINUTES: space *= MINUTE; break; case SECONDS: space *= SECOND; break; } latSubSteps = properLatDiv / space; if (latSubSteps) latStep = properLatDiv / latSubSteps; switch (settings.latLineUnits) { case DEGREES: latPrecision = 0; break; case MINUTES: latPrecision = 3; break; case SECONDS: latPrecision = 6; break; } } else { switch (settings.latLongFormat) { case DEGREES: incVals = incVals1; precision = precision1; subSteps = subSteps1; break; case DEGMIN: incVals = incVals2; precision = precision2; subSteps = subSteps2; break; case DMS: incVals = incVals3; precision = precision3; subSteps = subSteps3; break; } longRange = WRectWidth(view); latRange = WRectHeight(view); for (i = 0 ; i < NUMINCREMENTS ; i++) { if (!longDivFound && (longRange / MAXLONGS) < incVals[i]) { longDivFound = TRUE; properLongDiv = incVals[i]; if (settings.showIntermediateLines) { longSubSteps = subSteps[i]; longStep = properLongDiv / longSubSteps; } longPrecision = precision[i]; } if (!latDivFound && (latRange / MAXLATS) < incVals[i]) { latDivFound = TRUE; properLatDiv = incVals[i]; if (settings.showIntermediateLines) { latSubSteps = subSteps[i]; latStep = properLatDiv / latSubSteps; } latPrecision = precision[i]; } if (latDivFound && longDivFound) break; } } if (longDivFound) { units = view.loLong / properLongDiv - 1; // - 1 to handle western longitudes firstLong = units * properLongDiv; // modVal = _max(properLongDiv, MINUTE); // firstLong = view.loLong - (view.loLong % (long)modVal); for (x = firstLong ; x < view.hiLong ; x += properLongDiv) { DrawLong(x, r, view, longPrecision, TRUE); for (j = 1 ; j < longSubSteps ; j++) DrawLong(x + j * longStep, r, view, 0, FALSE); } } if (latDivFound) { units = view.loLat / properLatDiv - 1; // - 1 to handle southern longitudes firstLat = units * properLatDiv; // modVal = _max(properLatDiv, MINUTE); // firstLat = view.loLat - (view.loLat % (long)modVal); for (y = firstLat ; y < view.hiLat ; y += properLatDiv) { DrawLat(y, r, view, latPrecision, TRUE); for (j = 1 ; j < latSubSteps ; j++) DrawLat(y + j * latStep, r, view, 0, FALSE); } } RGBForeColor(&saveColor); // TextMode(patOr); // SetPenPat(BLACK); }
void ZoomRect(Boolean zoomLarger,Rect *smallRect, Rect *bigRect) { double firstStep,stepValue,trailer,zoomRatio; short i,step; Rect curRect; unsigned long ticks; Pattern grayPattern; //used in carbonization RgnHandle rgnHandle = NewRgn(); GrafPtr oldPort; Rect tempRect1; GetPort(&oldPort); SetPort(GetWindowPort(gWindow)); //PenPat(&qd.gray); PenPat(GetQDGlobalsGray(&grayPattern)); PenMode(patXor); firstStep=kZoomRatio; for (i=0; i<kNumSteps; i++) { firstStep *= kZoomRatio; } if (!zoomLarger) { zoomRatio = 1.0/kZoomRatio; firstStep = 1.0-firstStep; } else zoomRatio = kZoomRatio; trailer = firstStep; stepValue = firstStep; for (step=0; step<(kNumSteps+kRectsVisible); step++) { // draw new frame if (step<kNumSteps) { stepValue /= zoomRatio; CalcRect(&curRect,smallRect,bigRect,stepValue); FrameRect(&curRect); } // erase old frame if (step>=kRectsVisible) { trailer /= zoomRatio; CalcRect(&curRect,smallRect,bigRect,trailer); FrameRect(&curRect); } QDFlushPortBuffer(GetWindowPort(gWindow), GetPortVisibleRegion(GetWindowPort(gWindow), rgnHandle)); Delay(kDelayTicks,&ticks); } PenNormal(); DisposeRgn(rgnHandle); smallRect->top = bigRect->top = -1; EraseRect(GetPortBounds(GetWindowPort(gWindow), &tempRect1)); SetPort(oldPort); }
void DrawContents(void) { PenNormal(); DrawControls(GetPort()); }