static void MyDrawUserItem(DialogRef theDialog, DialogItemIndex itemNo) { DialogItemType itemType; Handle itemHandle; Rect itemBox; GetDialogItem(theDialog, itemNo, &itemType, &itemHandle, &itemBox); CGrafPtr savePort; GetPort(&savePort); SetPortDialogPort(theDialog); PenState penState; GetPenState(&penState); PenSize(3, 3); if (itemType & itemDisable) { Pattern gray; PenPat(GetQDGlobalsGray(&gray)); } FrameRect(&itemBox); Rect userRect = {gUserV-4, gUserH-4, gUserV+4, gUserH+4}; PaintRect(&userRect); SetPenState(&penState); SetPort(savePort); }
void restorePalette(Lcd *x, RGBColor *oldColor, PaletteHandle *oldPalette) { if (hasColorQD) { if (numPaletteColors>2){ SetPalette(&x->lcd_box.b_patcher->p_wind->w_gp,*oldPalette,FALSE); RGBForeColor(oldColor); } } SetPenState(&x->lcd_penState); }
static pascal void outline_hook(DialogRef dptr, short theItem){ short itemType; Handle itemHdl; Rect itemRect; PenState oldpen; GetDialogItem( dptr, theItem, &itemType, &itemHdl, &itemRect); GetPenState( &oldpen); PenSize( 3, 3); FrameRoundRect( &itemRect, 16, 16); SetPenState( &oldpen); }
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); }
void _HYPlatformGraphicPane::_DrawHatchedLine (_HYRect lineDesc) { PenState savePen; GetPenState (&savePen); if (abs(lineDesc.left-lineDesc.right)>5) PenPat (&penHatchPattern); else PenPat (&vertPenHatchPattern); PenSize (lineDesc.width, lineDesc.width); MoveTo (lineDesc.left, lineDesc.top); LineTo (lineDesc.right,lineDesc.bottom); SetPenState (&savePen); }
void RestoreQDDrawingState( QDDrawingState *inDrawingState, const Boolean inDisposeNow ) {// PixPatHandle tempPixPat; #if !(ALIST_USEAPPEARANCEMGR && TARGET_RT_MAC_CFM ) #pragma unused( inDisposeNow ) // Eliminate compiler warnings in 68K targets because PixPatHandle stuff is screwed up! #endif Assert( inDrawingState != nil ); // Restore the pen/foreground state. /* if ( !inDisposeNow && inDrawingState->penPixPatH != nil ) { // Make a copy of the penPixPatH so we can put it somewhere else later because we're not supposed to dispose of it now. tempPixPat = NewPixPat( ); if ( tempPixPat != nil ) CopyPixPat( inDrawingState->penPixPatH, tempPixPat ); } else tempPixPat = nil; PenPixPat( inDrawingState->penPixPatH ); inDrawingState->penPixPatH = tempPixPat; */ RGBForeColor( &inDrawingState->foreColor ); SetPenState( &inDrawingState->penState ); // Restore the background state. /* if ( !inDisposeNow && inDrawingState->backPixPatH != nil ) { // Make a copy of the backPixPatH so we can put it somewhere else later because we're not supposed to dispose of it now. tempPixPat = NewPixPat( ); if ( tempPixPat != nil ) CopyPixPat( inDrawingState->backPixPatH, tempPixPat ); } else tempPixPat = nil; BackPixPat( inDrawingState->backPixPatH ); inDrawingState->penPixPatH = tempPixPat; */ RGBBackColor( &inDrawingState->backColor ); // Optionally restore the text state. if ( inDrawingState->haveTextState ) { TextFont( inDrawingState->textStyle.tsFont ); TextFace( inDrawingState->textStyle.tsFace ); TextSize( inDrawingState->textStyle.tsSize ); TextMode( inDrawingState->textMode ); } #if ALIST_USEAPPEARANCEMGR && TARGET_RT_MAC_CFM // If we're running under CFM and have Appearance Mgr 1.1 or later, use the ThemeDrawingState routines. if ( inDrawingState->haveThemeState ) { SetThemeDrawingState( inDrawingState->themeState, inDisposeNow ); if ( inDisposeNow ) inDrawingState->themeState = nil; } #endif }
// 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; }
void InvertObject (CMap *Map, ObjectRecHdl theObjectHdl) { GrafPtr SavePort; PenState penStatus; Rect thisObjectRect; OSType thisObjectType; GetPort (&SavePort); // now draw the selection points on the grouped / single region GetPenState (&penStatus); // save original pen state PenSize (4, 4); PenMode (srcXor); GetObjectType (theObjectHdl, &thisObjectType); if (thisObjectType == kLineType) { LineObjectRecHdl lineObjectHdl; LongPoint LineStartLPoint, LineEndLPoint; Point LineStartPoint, LineEndPoint; lineObjectHdl = (LineObjectRecHdl) theObjectHdl; LineStartLPoint = (**lineObjectHdl).lineStartLPoint; LineEndLPoint = (**lineObjectHdl).lineEndLPoint; Map -> GetScrPoint (&LineStartLPoint, &LineStartPoint); Map -> GetScrPoint (&LineEndLPoint, &LineEndPoint); MyMoveTo (LineStartPoint.h, LineStartPoint.v); MyLineTo (LineStartPoint.h, LineStartPoint.v); MyMoveTo (LineEndPoint.h, LineEndPoint.v); MyLineTo (LineEndPoint.h, LineEndPoint.v); } else { GetObjectScrRect (Map, theObjectHdl, &thisObjectRect); thisObjectRect.top -= 1; thisObjectRect.left -= 1; thisObjectRect.right -= 3; thisObjectRect.bottom -= 3; MyMoveTo (thisObjectRect.left, thisObjectRect.top); MyLineTo (thisObjectRect.left, thisObjectRect.top); MyMoveTo (thisObjectRect.right, thisObjectRect.top); MyLineTo (thisObjectRect.right, thisObjectRect.top); MyMoveTo (thisObjectRect.right, thisObjectRect.bottom); MyLineTo (thisObjectRect.right, thisObjectRect.bottom); MyMoveTo (thisObjectRect.left, thisObjectRect.bottom); MyLineTo (thisObjectRect.left, thisObjectRect.bottom); } SetPenState (&penStatus); SetPort (SavePort); return; }