static pascal void ListBoxDrawProc( ControlRef browser , DataBrowserItemID item , DataBrowserPropertyID property , DataBrowserItemState itemState , const Rect *itemRect , SInt16 depth , Boolean isColorDevice ) { CFStringRef cfString; long systemVersion; cfString = CFStringCreateWithFormat( NULL, NULL, CFSTR("Row %d"), item ); ThemeDrawingState themeState ; GetThemeDrawingState( &themeState ) ; if ( itemState == kDataBrowserItemIsSelected ) // In this sample we handle the "selected" state, all others fall through to our "active" state { Gestalt( gestaltSystemVersion, &systemVersion ); if ( (systemVersion >= 0x00001030) && (IsControlActive( browser ) == false) ) // Panther DB starts using kThemeBrushSecondaryHighlightColor for inactive browser hilighting SetThemePen( kThemeBrushSecondaryHighlightColor, 32, true ); else SetThemePen( kThemeBrushPrimaryHighlightColor, 32, true ); PaintRect( itemRect ); // First paint the hilite rect, then the text on top SetThemeDrawingState( themeState , false ) ; } DrawThemeTextBox( cfString, kThemeApplicationFont, kThemeStateActive, true, itemRect, teFlushDefault, NULL ); if ( cfString != NULL ) CFRelease( cfString ); SetThemeDrawingState( themeState , true ) ; }
static void MyUserPaneDrawProc(ControlRef control, SInt16 part) { // we now use a User Pane Control instead of a dialog user item // the draw, hit test, and track are more separated Rect bounds; GetControlBounds(control, &bounds); PenSize(3, 3); if (!IsControlActive(control)) { RGBColor gray = {32767, 32767, 32767}; RGBForeColor(&gray); } FrameRect(&bounds); Rect userRect = {gUserV-4, gUserH-4, gUserV+4, gUserH+4}; PaintRect(&userRect); }
// -------------------------------------------------------------------------------------- pascal void DrawIconDataBrowserItem86CB(ControlRef browser, DataBrowserItemID item, DataBrowserPropertyID property, DataBrowserItemState itemState, const Rect *theRect, SInt16 gdDepth, Boolean colorDevice) { #pragma unused (theRect) Rect enclosingRect, iconRect, textRect; Boolean active; IconDBItemDataRec *itemData; /* The data browser currently gives us the content part bounds in the theRect parameter but we want the enclosing part bounds to draw in so that we can draw a fill style highlight. */ GetDataBrowserItemPartBounds(browser, item, property, kDataBrowserPropertyEnclosingPart, &enclosingRect); active = IsControlActive(browser); if ((itemState & kDataBrowserItemIsSelected) != 0) { ThemeDrawingState savedState; GetThemeDrawingState(&savedState); SetThemePen(active ? kThemeBrushPrimaryHighlightColor : kThemeBrushSecondaryHighlightColor, gdDepth, colorDevice); PaintRect(&enclosingRect); SetThemeDrawingState(savedState, true); } calculateDrawingBounds(&enclosingRect, &iconRect, &textRect); itemData = (IconDBItemDataRec *)item; PlotIconRef(&iconRect, kAlignNone, active ? kTransformNone : kTransformDisabled, kIconServicesNormalUsageFlag, itemData->icon); DrawThemeTextBox(itemData->name, kThemeViewsFont, active ? kThemeStateActive : kThemeStateInactive, true, &textRect, teCenter, NULL); }
static pascal void ListBoxDrawProc( ControlRef browser, DataBrowserItemID item, DataBrowserPropertyID property, DataBrowserItemState itemState, const Rect *itemRect, SInt16 depth, Boolean isColorDevice ) { CFStringRef cfString; ThemeDrawingState themeState; long systemVersion; GetThemeDrawingState( &themeState ); cfString = CFStringCreateWithFormat( NULL, NULL, CFSTR("Row %d"), item ); // In this sample we handle the "selected" state; all others fall through to our "active" state if ( itemState == kDataBrowserItemIsSelected ) { ThemeBrush colorBrushID; // TODO: switch over to wxSystemSettingsNative::GetColour() when kThemeBrushSecondaryHighlightColor // is incorporated Panther DB starts using kThemeBrushSecondaryHighlightColor // for inactive browser highlighting if ( !IsControlActive( browser ) ) colorBrushID = kThemeBrushSecondaryHighlightColor; else colorBrushID = kThemeBrushPrimaryHighlightColor; // First paint the hilite rect, then the text on top SetThemePen( colorBrushID, 32, true ); PaintRect( itemRect ); SetThemeDrawingState( themeState, false ); } DrawThemeTextBox( cfString, kThemeApplicationFont, kThemeStateActive, true, itemRect, teFlushDefault, NULL ); SetThemeDrawingState( themeState, true ); if ( cfString != NULL ) CFRelease( cfString ); }
static pascal OSStatus CustomSpotViewHandler(EventHandlerCallRef inCaller, EventRef inEvent, void* inRefcon) { OSStatus result = eventNotHandledErr; CustomSpotViewData* myData = (CustomSpotViewData*)inRefcon; switch (GetEventClass(inEvent)) { case kEventClassHIObject: switch (GetEventKind(inEvent)) { case kEventHIObjectConstruct: { myData = (CustomSpotViewData*) calloc(1, sizeof(CustomSpotViewData)); GetEventParameter(inEvent, kEventParamHIObjectInstance, typeHIObjectRef, NULL, sizeof(myData->view), NULL, &myData->view); result = SetEventParameter(inEvent, kEventParamHIObjectInstance, typeVoidPtr, sizeof(myData), &myData); break; } case kEventHIObjectInitialize: { HIRect bounds; GetEventParameter(inEvent, kEventParamBounds, typeHIRect, NULL, sizeof(bounds), NULL, &bounds); myData->spot.x = CGRectGetMidX(bounds) - CGRectGetMinX(bounds); myData->spot.y = CGRectGetMidY(bounds) - CGRectGetMinY(bounds); HIViewSetVisible(myData->view, true); break; } case kEventHIObjectDestruct: { free(myData); result = noErr; break; } default: break; } break; case kEventClassControl: switch (GetEventKind(inEvent)) { case kEventControlDraw: { CGContextRef context; HIRect bounds; result = GetEventParameter(inEvent, kEventParamCGContextRef, typeCGContextRef, NULL, sizeof(context), NULL, &context); HIViewGetBounds(myData->view, &bounds); if (!IsControlActive(myData->view)) { CGContextSetGrayStrokeColor(context, 0.5, 0.3); CGContextSetGrayFillColor(context, 0.5, 0.3); } else { CGContextSetRGBStrokeColor(context, 0.0, 0.0, 0.0, 0.7); CGContextSetRGBFillColor(context, 0.0, 0.0, 0.0, 0.7); } CGContextSetLineWidth(context, 3.0); CGContextStrokeRect(context, bounds); HIRect spot = { {myData->spot.x - 4.0, myData->spot.y - 4.0}, {8.0, 8.0} }; CGContextFillRect(context, spot); result = noErr; break; } case kEventControlBoundsChanged: { HIRect newHIBounds; GetEventParameter(inEvent, kEventParamCurrentBounds, typeHIRect, NULL, sizeof(newHIBounds), NULL, &newHIBounds); myData->spot.x = CGRectGetMidX(newHIBounds) - CGRectGetMinX(newHIBounds); myData->spot.y = CGRectGetMidY(newHIBounds) - CGRectGetMinY(newHIBounds); break; } case kEventControlHitTest: { HIPoint pt; HIRect bounds; GetEventParameter(inEvent, kEventParamMouseLocation, typeHIPoint, NULL, sizeof(pt), NULL, &pt); HIViewGetBounds(myData->view, &bounds); ControlPartCode part = (CGRectContainsPoint(bounds, pt))?kControlButtonPart:kControlNoPart; result = SetEventParameter(inEvent, kEventParamControlPart, typeControlPartCode, sizeof(part), &part); break; } case kEventControlTrack: { Point qdPoint; Rect qdWindowBounds; HIPoint hiPoint; HIRect hiViewBounds; MouseTrackingResult mouseStatus = kMouseTrackingMouseDown; HIViewGetBounds(myData->view, &hiViewBounds); GetWindowBounds(GetControlOwner(myData->view), kWindowStructureRgn, &qdWindowBounds); // handle the first mouseDown before moving GetEventParameter(inEvent, kEventParamMouseLocation, typeHIPoint, NULL, sizeof(hiPoint), NULL, &hiPoint); while (mouseStatus != kMouseTrackingMouseUp) { if (CGRectContainsPoint(hiViewBounds, hiPoint)) { if (hiPoint.x < hiViewBounds.origin.x+4) hiPoint.x = hiViewBounds.origin.x+4; if (hiPoint.x > hiViewBounds.origin.x+hiViewBounds.size.width-4) hiPoint.x = hiViewBounds.origin.x+hiViewBounds.size.width-4; if (hiPoint.y < hiViewBounds.origin.y+4) hiPoint.y = hiViewBounds.origin.y+4; if (hiPoint.y > hiViewBounds.origin.y+hiViewBounds.size.height-4) hiPoint.y = hiViewBounds.origin.y+hiViewBounds.size.height-4; myData->spot = hiPoint; HIViewSetNeedsDisplay(myData->view, true); } // a -1 GrafPtr to TrackMouseLocation yields global coordinates TrackMouseLocation((GrafPtr)-1L, &qdPoint, &mouseStatus); // convert to window-relative coordinates hiPoint.x = qdPoint.h - qdWindowBounds.left; hiPoint.y = qdPoint.v - qdWindowBounds.top; // convert to view-relative coordinates HIViewConvertPoint(&hiPoint, NULL, myData->view); } break; } default: break; } break; default: break; } return result; }
/***************************************************** * * Internal_HICustomViewHandler(inHandlerCallRef, inEvent, inUserData) * * Purpose: Event handler that implements our HICustomView custom view * * Inputs: inHandlerCallRef - reference to the current handler call chain * inEvent - the event * inUserData - app-specified data you passed in the call to InstallEventHandler * * Returns: OSStatus - error code (0 == no error) */ static pascal OSStatus Internal_HICustomViewHandler(EventHandlerCallRef inHandlerCallRef, EventRef inEvent, void * inUserData) { OSStatus status = eventNotHandledErr; HICustomViewData * myData = (HICustomViewData *)inUserData; switch (GetEventClass(inEvent)) { case kEventClassHIObject: switch (GetEventKind(inEvent)) { case kEventHIObjectConstruct: { // allocate some instance data myData = (HICustomViewData *) calloc(1, sizeof(HICustomViewData)); require_action(myData != NULL, ConstructExit, status = memFullErr); // get our superclass instance HIViewRef epView; status = GetEventParameter(inEvent, kEventParamHIObjectInstance, typeHIObjectRef, NULL, sizeof(epView), NULL, &epView); require_noerr(status, ConstructExit); // remember our superclass in our instance data myData->view = epView; // store our instance data into the event status = SetEventParameter(inEvent, kEventParamHIObjectInstance, typeVoidPtr, sizeof(myData), &myData); require_noerr(status, ConstructExit); ConstructExit: break; } #pragma mark * kEventHIObjectInitialize case kEventHIObjectInitialize: { // always begin kEventHIObjectInitialize by calling through to the previous handler status = CallNextEventHandler(inHandlerCallRef, inEvent); require_noerr(status, InitializeExit); // if that succeeded, do our own initialization // in this sample code, there is nothing to do InitializeExit: break; } case kEventHIObjectDestruct: { // freeing our storage if (myData != NULL) free(myData); status = noErr; break; } default: break; } break; case kEventClassControl: switch (GetEventKind(inEvent)) { #pragma mark * kEventControlDraw case kEventControlDraw: { CGContextRef context; status = GetEventParameter(inEvent, kEventParamCGContextRef, typeCGContextRef, NULL, sizeof(context), NULL, &context); require_noerr(status, ControlDrawExit); HIRect bounds, viewBounds; HIViewGetBounds(myData->view, &viewBounds); // setting our colors according to state: IsControlEnabled, IsControlActive, IsControlHilited if (!IsControlEnabled(myData->view)) { CGContextSetRGBFillColor(context, 0.3, 0.3, 0.3, 0.8); CGContextSetRGBStrokeColor(context, 0.5, 0.5, 0.5, 0.8); } else if (!IsControlActive(myData->view)) { CGContextSetRGBFillColor(context, 0.7, 0.7, 0.7, 0.8); CGContextSetRGBStrokeColor(context, 0.8, 0.8, 0.8, 0.8); } else if (!IsControlHilited(myData->view)) { CGContextSetRGBFillColor(context, 1, 0, 0, 0.8); CGContextSetRGBStrokeColor(context, 0, 0, 1, 0.8); } else { CGContextSetRGBFillColor(context, 0.7, 0, 0, 0.8); CGContextSetRGBStrokeColor(context, 0, 0, 0.7, 0.8); } // using a line thickness of 3 CGContextSetLineWidth(context, 3); bounds = CGRectInset(viewBounds, 3, 3); float minDim = (bounds.size.height < bounds.size.width) ? bounds.size.height / 2 : bounds.size.width / 2; float cx = bounds.origin.x + minDim, cy = bounds.origin.y + minDim; UInt32 i, n = GetControl32BitValue(myData->view); // having some fun with geometric shapes based on the value of the custom view CGContextBeginPath(context); switch (n) { case 0: CGContextAddArc(context, cx, cy, minDim, 0, 2 * pi, true); break; case 1: CGContextAddEllipseInRect(context, CGRectInset(bounds, bounds.size.width * 0.4, 0)); break; default: { float deltangle = pi / n, angle = 0, r = minDim / 2; CGContextMoveToPoint(context, cx + minDim, cy); for (i = 0; i < n; i++) { angle += deltangle; CGContextAddLineToPoint(context, cx + r * cos(angle), cy + r * sin(angle)); angle += deltangle; CGContextAddLineToPoint(context, cx + minDim * cos(angle), cy + minDim * sin(angle)); } CGContextAddLineToPoint(context, cx + minDim, cy); } } CGContextClosePath(context); CGContextDrawPath(context, kCGPathFillStroke); status = noErr; ControlDrawExit: break; } #pragma mark * kEventControl___Changed case kEventControlValueFieldChanged: case kEventControlHiliteChanged: { // just asking for a refresh HIViewSetNeedsDisplay(myData->view, true); break; } default: break; } break; default: break; } return status; } // Internal_HICustomViewHandler
static void TkMacOSXDrawControl( MacButton *mbPtr, /* Mac button. */ GWorldPtr destPort, /* Off screen GWorld. */ GC gc, /* The GC we are drawing into - needed for the * bevel button */ Pixmap pixmap) /* The pixmap we are drawing into - needed for * the bevel button */ { TkButton *butPtr = (TkButton *) mbPtr; TkWindow *winPtr; Rect paneRect, cntrRect; int active, enabled; int rebuild; winPtr = (TkWindow *) butPtr->tkwin; paneRect.left = winPtr->privatePtr->xOff; paneRect.top = winPtr->privatePtr->yOff; paneRect.right = paneRect.left + Tk_Width(butPtr->tkwin); paneRect.bottom = paneRect.top + Tk_Height(butPtr->tkwin); cntrRect = paneRect; /* cntrRect.left += butPtr->inset; cntrRect.top += butPtr->inset; cntrRect.right -= butPtr->inset; cntrRect.bottom -= butPtr->inset; */ cntrRect.left += DEF_INSET_LEFT; cntrRect.top += DEF_INSET_TOP; cntrRect.right -= DEF_INSET_RIGHT; cntrRect.bottom -= DEF_INSET_BOTTOM; /* * The control has been previously initialised. * It may need to be re-initialised */ #if 0 rebuild = (winPtr->flags & TK_REBUILD_TOPLEVEL); winPtr->flags &= ~TK_REBUILD_TOPLEVEL; #else rebuild = 0; #endif if (mbPtr->flags) { MacControlParams params; TkMacOSXComputeControlParams(butPtr, ¶ms); if (rebuild || bcmp(¶ms, &mbPtr->params, sizeof(params))) { /* * The type of control has changed. * Clean it up and clear the flag. */ if (mbPtr->userPane) { DisposeControl(mbPtr->userPane); mbPtr->userPane = NULL; mbPtr->control = NULL; } mbPtr->flags = 0; } } if (!(mbPtr->flags & CONTROL_INITIALIZED)) { if (TkMacOSXInitControl(mbPtr, destPort, gc, pixmap, &paneRect, &cntrRect)) { return; } } SetControlBounds(mbPtr->userPane, &paneRect); SetControlBounds(mbPtr->control, &cntrRect); if (!mbPtr->useTkText) { Str255 controlTitle; ControlFontStyleRec fontStyle; Tk_Font font; int len; if (((mbPtr->info.image == NULL) && (mbPtr->info.bitmap == None)) || (mbPtr->info.compound != COMPOUND_NONE)) { len = TkFontGetFirstTextLayout(butPtr->textLayout, &font, (char*) controlTitle); controlTitle[len] = 0; } else { len = 0; controlTitle[0] = 0; } if (rebuild || bcmp(mbPtr->controlTitle, controlTitle, len+1)) { CFStringRef cf = CFStringCreateWithCString(NULL, (char*) controlTitle, kCFStringEncodingUTF8); if (cf != NULL) { SetControlTitleWithCFString(mbPtr->control, cf); CFRelease(cf); } bcopy(controlTitle, mbPtr->controlTitle, len+1); } if (len) { TkMacOSXInitControlFontStyle(font, &fontStyle); if (bcmp(&mbPtr->fontStyle, &fontStyle, sizeof(fontStyle)) ) { ChkErr(SetControlFontStyle, mbPtr->control, &fontStyle); bcopy(&fontStyle, &mbPtr->fontStyle, sizeof(fontStyle)); } } } if (mbPtr->params.isBevel) { /* * Initialiase the image/button parameters. */ SetupBevelButton(mbPtr, mbPtr->control, destPort, gc, pixmap); } if (butPtr->flags & SELECTED) { SetControlValue(mbPtr->control, 1); #if 0 } else if (butPtr->flags & TRISTATED) { SetControlValue(mbPtr->control, 2); #endif } else { SetControlValue(mbPtr->control, 0); } active = ((mbPtr->flags & ACTIVE) != 0); if (active != IsControlActive(mbPtr->control)) { if (active) { ChkErr(ActivateControl, mbPtr->control); } else { ChkErr(DeactivateControl, mbPtr->control); } } enabled = !(butPtr->state == STATE_DISABLED); if (enabled != IsControlEnabled(mbPtr->control)) { if (enabled) { ChkErr(EnableControl, mbPtr->control); } else { ChkErr(DisableControl, mbPtr->control); } } if (active && enabled) { if (butPtr->state == STATE_ACTIVE) { if (mbPtr->params.isBevel) { HiliteControl(mbPtr->control, kControlButtonPart); } else { switch (butPtr->type) { case TYPE_BUTTON: HiliteControl(mbPtr->control, kControlButtonPart); break; case TYPE_RADIO_BUTTON: HiliteControl(mbPtr->control, kControlRadioButtonPart); break; case TYPE_CHECK_BUTTON: HiliteControl(mbPtr->control, kControlCheckBoxPart); break; } } } else { HiliteControl(mbPtr->control, kControlNoPart); } } UpdateControlColors(mbPtr); if (butPtr->type == TYPE_BUTTON && !mbPtr->params.isBevel) { Boolean isDefault; if (butPtr->defaultState == STATE_ACTIVE) { isDefault = true; } else { isDefault = false; } ChkErr(SetControlData, mbPtr->control, kControlNoPart, kControlPushButtonDefaultTag, sizeof(isDefault), &isDefault); } if (mbPtr->flags & FIRST_DRAW) { ShowControl(mbPtr->userPane); ShowControl(mbPtr->control); mbPtr->flags ^= FIRST_DRAW; } else { SetControlVisibility(mbPtr->control, true, true); Draw1Control(mbPtr->userPane); } if (mbPtr->params.isBevel) { if (mbPtr->bevelButtonContent.contentType == kControlContentPictHandle) { KillPicture(mbPtr->bevelButtonContent.u.picture); } } }
// -------------------------------------------------------------------------------------- pascal void DrawIconDataBrowserItem104CB(ControlRef browser, DataBrowserItemID item, DataBrowserPropertyID property, DataBrowserItemState itemState, const Rect *theRect, SInt16 gdDepth, Boolean colorDevice) { #pragma unused (theRect, gdDepth, colorDevice) Rect enclosingRect, portBounds; GrafPtr port; CGRect enclosingCGRect, iconCGRect, textCGRect; Boolean active; CGContextRef context; IconDBItemDataRec *itemData; RGBColor labelColor; HIThemeTextInfo textInfo; /* The data browser currently gives us the content part bounds in the theRect parameter but we want the enclosing part bounds to draw in so that we can draw a fill style highlight. */ GetDataBrowserItemPartBounds(browser, item, property, kDataBrowserPropertyEnclosingPart, &enclosingRect); /* In Mac OS X we're going to use Quartz 2D/Core Graphics for the drawing, so we need to convert the enclosing part bounds to a CGRect */ GetPort(&port); // the data browser sets the port up for us so we just need to get it GetPortBounds(port, &portBounds); enclosingCGRect = CGRectMake(enclosingRect.left, portBounds.bottom - portBounds.top - enclosingRect.bottom, enclosingRect.right - enclosingRect.left, enclosingRect.bottom - enclosingRect.top); calculateCGDrawingBounds(enclosingCGRect, &iconCGRect, &textCGRect); active = IsControlActive(browser); if ((itemState & kDataBrowserItemIsSelected) != 0) { CGRect clipRect; clipRect = getClipCGRect(&portBounds); // call this before beginning the context QDBeginCGContext(port, &context); CGContextClipToRect(context, clipRect); CGContextSaveGState(context); HIThemeSetFill(active ? kThemeBrushPrimaryHighlightColor : kThemeBrushSecondaryHighlightColor, NULL, context, kHIThemeOrientationInverted); CGContextFillRect(context, enclosingCGRect); CGContextRestoreGState(context); } else { /* The data browser will redraw items on the edge of its content view. Because HIThemeDrawTextBox does not erase the drawing rectangle before it draws, the text becomes thicker with every draw due to anti-aliasing. As a workaround, this section erases the text rectangle (if the item was selected then the enclosing rectangle was erased above). */ CGRect clipRect; RGBColor backgroundColor; clipRect = getClipCGRect(&portBounds); // call these before beginning the context GetBackColor(&backgroundColor); QDBeginCGContext(port, &context); CGContextClipToRect(context, clipRect); CGContextSaveGState(context); CGContextSetRGBFillColor(context, (float)backgroundColor.red / (float)USHRT_MAX, (float)backgroundColor.green / (float)USHRT_MAX, (float)backgroundColor.blue / (float)USHRT_MAX, 1.0); CGContextFillRect(context, textCGRect); CGContextRestoreGState(context); } itemData = (IconDBItemDataRec *)item; labelColor.red = 0; labelColor.green = 0; labelColor.blue = 0; PlotIconRefInContext(context, &iconCGRect, kAlignNone, active ? kTransformNone : kTransformDisabled, &labelColor, kPlotIconRefNormalFlags, itemData->icon); textInfo.version = kHIThemeTextInfoVersionZero; textInfo.state = active ? kThemeStateActive : kThemeStateInactive; textInfo.fontID = kThemeViewsFont; textInfo.horizontalFlushness = kHIThemeTextHorizontalFlushCenter; textInfo.verticalFlushness = kHIThemeTextVerticalFlushTop; textInfo.options = kHIThemeTextBoxOptionNone; textInfo.truncationPosition = kHIThemeTextTruncationNone; HIThemeDrawTextBox(itemData->name, &textCGRect, &textInfo, context, kHIThemeOrientationInverted); QDEndCGContext(port, &context); } // DrawIconDataBrowserItem104CB
// -------------------------------------------------------------------------------------- pascal void DrawIconDataBrowserItem101CB(ControlRef browser, DataBrowserItemID item, DataBrowserPropertyID property, DataBrowserItemState itemState, const Rect *theRect, SInt16 gdDepth, Boolean colorDevice) { #pragma unused (theRect) Rect enclosingRect, portBounds, iconRect, textRect; GrafPtr port; CGRect enclosingCGRect, iconCGRect, textCGRect; Boolean active; ThemeDrawingState savedState = NULL; CGContextRef context; IconDBItemDataRec *itemData; RGBColor labelColor; /* The data browser currently gives us the content part bounds in the theRect parameter but we want the enclosing part bounds to draw in so that we can draw a fill style highlight. */ GetDataBrowserItemPartBounds(browser, item, property, kDataBrowserPropertyEnclosingPart, &enclosingRect); /* In Mac OS X we're going to use Quartz 2D/Core Graphics for the drawing, so we need to convert the enclosing part bounds to a CGRect */ GetPort(&port); // the data browser sets the port up for us so we just need to get it GetPortBounds(port, &portBounds); enclosingCGRect = CGRectMake(enclosingRect.left, portBounds.bottom - portBounds.top - enclosingRect.bottom, enclosingRect.right - enclosingRect.left, enclosingRect.bottom - enclosingRect.top); active = IsControlActive(browser); if ((itemState & kDataBrowserItemIsSelected) != 0) { CGRect clipRect; RGBColor foregroundColor; GetThemeDrawingState(&savedState); SetThemePen(active ? kThemeBrushPrimaryHighlightColor : kThemeBrushSecondaryHighlightColor, gdDepth, colorDevice); clipRect = getClipCGRect(&portBounds); // call these before beginning the context GetForeColor(&foregroundColor); QDBeginCGContext(port, &context); CGContextClipToRect(context, clipRect); CGContextSaveGState(context); CGContextSetRGBFillColor(context, (float)foregroundColor.red / (float)USHRT_MAX, (float)foregroundColor.green / (float)USHRT_MAX, (float)foregroundColor.blue / (float)USHRT_MAX, 1.0); CGContextFillRect(context, enclosingCGRect); CGContextRestoreGState(context); } else { CGRect clipRect; clipRect = getClipCGRect(&portBounds); // call this before beginning the context QDBeginCGContext(port, &context); CGContextClipToRect(context, clipRect); } calculateCGDrawingBounds(enclosingCGRect, &iconCGRect, &textCGRect); /* DrawThemeTextBox wants the bounding rectangle to be QuickDraw coordinates relative to the current port, not Core Graphics coordinates relative to the passed context. */ calculateDrawingBounds(&enclosingRect, &iconRect, &textRect); itemData = (IconDBItemDataRec *)item; labelColor.red = 0; labelColor.green = 0; labelColor.blue = 0; PlotIconRefInContext(context, &iconCGRect, kAlignNone, active ? kTransformNone : kTransformDisabled, &labelColor, kPlotIconRefNormalFlags, itemData->icon); DrawThemeTextBox(itemData->name, kThemeViewsFont, active ? kThemeStateActive : kThemeStateInactive, true, &textRect, teCenter, context); QDEndCGContext(port, &context); if (savedState != NULL) SetThemeDrawingState(savedState, true); } // DrawIconDataBrowserItem101CB