/* DrawDialogCmd(cmd, lineHeight) Draws command starting from current pen loc. This is a help routine for DisplayDialogCmd. Thread Safety: DrawDialogCmd is not thread-safe. */ static void DrawDialogCmd(const char *cmd, int lineHeight) { PenState penState; char temp[MAXCMDLEN+1]; const char *p1, *p2; int done = FALSE; int h, v; int len; GetPenState(&penState); h = penState.pnLoc.h; v = penState.pnLoc.v; p1 = cmd; // p1 marches through command. do { p2 = strchr(p1, 0x0d); // Find CR. if (p2 == NULL) { // No more CRs ? strcpy(temp, p1); done = TRUE; } else { len = p2-p1; strncpy(temp, p1, len); temp[len] = 0; } CopyCStringToPascal(temp, (unsigned char*)temp); DrawString((unsigned char*)temp); v += lineHeight; // Move to next line. MoveTo(h, v); p1 = p2+1; // Point to start of next line. } while (!done); }
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); }
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); }
void SaveQDDrawingState( QDDrawingState *ioDrawingState, const Boolean inSaveTextState ) { GWorldPtr tempWorld; GDHandle tempDevice; Assert( ioDrawingState != nil ); // Get the current GWorld, so I can access it's fields. GetGWorld( &tempWorld, &tempDevice ); // Get the background state. GetBackColor( &ioDrawingState->backColor ); /*#if !( defined( TARGET_API_MAC_CARBON ) && ( TARGET_API_MAC_CARBON == 1 ) ) if ( tempWorld->bkPixPat == nil ) ioDrawingState->backPixPatH = nil; else #endif ioDrawingState->backPixPatH = NewPixPat( ); if ( ioDrawingState->backPixPatH != nil ) GetPortBackPixPat( tempWorld, ioDrawingState->backPixPatH ); */ // Get the pen/foreground state. GetForeColor( &ioDrawingState->foreColor ); /*#if !( defined( TARGET_API_MAC_CARBON ) && ( TARGET_API_MAC_CARBON == 1 ) ) if ( tempWorld->pnPixPat == nil ) ioDrawingState->penPixPatH = nil; else #endif ioDrawingState->penPixPatH = NewPixPat( ); if ( ioDrawingState->penPixPatH != nil ) GetPortPenPixPat( tempWorld, ioDrawingState->penPixPatH ); */ GetPenState( &ioDrawingState->penState ); // Optionally save the text font, face, size and mode. ioDrawingState->haveTextState = inSaveTextState; if ( inSaveTextState ) { ioDrawingState->textStyle.tsFont = GetPortTextFont( tempWorld ); ioDrawingState->textStyle.tsFace = GetPortTextFace( tempWorld ); ioDrawingState->textStyle.tsSize = GetPortTextSize( tempWorld ); ioDrawingState->textMode = GetPortTextMode( tempWorld ); } #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 ( local_AppearanceMgrVersion( ) > 0x0110 ) ioDrawingState->haveThemeState = ( GetThemeDrawingState( &ioDrawingState->themeState ) == noErr ); else { ioDrawingState->haveThemeState = false; ioDrawingState->themeState = nil; } #endif }
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 setUpPalette(Lcd *x, RGBColor *oldColor, PaletteHandle *oldPalette) { if (hasColorQD) { if (numPaletteColors>2){ GetForeColor(oldColor); *oldPalette = GetPalette(&x->lcd_box.b_patcher->p_wind->w_gp); SetPalette(&x->lcd_box.b_patcher->p_wind->w_gp,x->lcd_palette,FALSE); PmForeColor(x->lcd_pIndex); } } GetPenState(&x->lcd_penState); PenMode(x->lcd_penMode); PenSize(1,1); }
static bool openPostScript (void) { PenState pen; /* * Flush GrafPort state. */ SetPort ((GrafPtr) theMacPort); /* Some warning message could have drawn ThePort away... */ GetPenState (& pen); PenSize (0, 0); Line (0, 0); PenSize (pen. pnSize.h, pen. pnSize.v); /* * Send direct PostScript commands. */ if (PMSessionPostScriptBegin (theMacPrintSession)) { return Melder_error1 (L"Cannot begin PostScript."); } initPostScriptPage (); return true; }
// 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; }