void SetupPauseResumeButtons(void) { Str255 pPauseLabel, pResumeLabel; /* rename labels to pause/resume */ if (gControls->backB) { GetResourcedString(pPauseLabel, rInstList, sPauseBtn); SetControlTitle(gControls->backB, pPauseLabel); ShowControl(gControls->backB); } if (gControls->nextB) { GetResourcedString(pResumeLabel, rInstList, sResumeBtn); SetControlTitle(gControls->nextB, pResumeLabel); ShowControl(gControls->nextB); } /* disable cancel button */ if (gControls->cancelB) HiliteControl(gControls->cancelB, kDisableControl); /* disable pause button */ if (gControls->nextB) HiliteControl(gControls->nextB, kDisableControl); /* enable resume button */ if (gControls->backB) HiliteControl(gControls->backB, kEnableControl); gControls->state = eDownloading; }
static pascal Boolean about_filter(DialogPtr dptr, EventRecord *theEvent, short *theItem){ if( theEvent->what == keyDown || theEvent->what == autoKey){ unsigned char theKey = (unsigned char)(theEvent->message & charCodeMask); if( theKey == 0x0D || (theKey == 0x03 && !(theEvent->modifiers & controlKey))){ short itemType; ControlHandle okHdl; Rect itemRect; #if UNIVERSAL_INTERFACES_VERSION >= 0x0301 unsigned long Ticks; #else long Ticks; #endif GetDialogItem( dptr, ok, &itemType, (Handle*) &okHdl, &itemRect); HiliteControl( okHdl, kControlButtonPart); #ifdef __cplusplus Delay( 3, &Ticks); #else Delay( 3, (void *)&Ticks); #endif HiliteControl( okHdl, 0); *theItem = ok; return true; } } return false; }
void EnableTerminalWin(void) { if (gControls->state == eInstallNotStarted) { EnableNavButtons(); if (gControls->tw->siteSelector) HiliteControl(gControls->tw->siteSelector, kEnableControl); if (gControls->tw->saveBitsCheckbox) HiliteControl(gControls->tw->saveBitsCheckbox, kEnableControl); if (gControls->tw->proxySettingsBtn) HiliteControl(gControls->tw->proxySettingsBtn, kEnableControl); } else if (gControls->state == eDownloading || gControls->state == eResuming) { if (gControls->nextB) HiliteControl(gControls->nextB, kDisableControl); if (gControls->backB) HiliteControl(gControls->backB, kEnableControl); if (gControls->cancelB) HiliteControl(gControls->cancelB, kDisableControl); } else if (gControls->state == ePaused) { if (gControls->nextB) HiliteControl(gControls->nextB, kEnableControl); if (gControls->backB) HiliteControl(gControls->backB, kDisableControl); if (gControls->cancelB) HiliteControl(gControls->cancelB, kDisableControl); } }
void DisableNavButtons(void) { if (gControls->backB) HiliteControl(gControls->backB, kDisableControl); if(gControls->nextB) HiliteControl(gControls->nextB, kDisableControl); if (gControls->cancelB) HiliteControl(gControls->cancelB, kDisableControl); }
void DisablePauseAndResume() { /* disable pause button */ if (gControls->nextB) HiliteControl(gControls->nextB, kDisableControl); /* disable resume button */ if (gControls->backB) HiliteControl(gControls->backB, kDisableControl); }
void EnableNavButtons(void) { if (gControls->backB && gCurrWin!=kWelcomeID) HiliteControl(gControls->backB, kEnableControl); if (gControls->nextB) HiliteControl(gControls->nextB, kEnableControl); if (gControls->cancelB) HiliteControl(gControls->cancelB, kEnableControl); }
void DisableTerminalWin(void) { DisableNavButtons(); if (gControls->tw->siteSelector) HiliteControl(gControls->tw->siteSelector, kDisableControl); if (gControls->tw->saveBitsCheckbox) HiliteControl(gControls->tw->saveBitsCheckbox, kDisableControl); if (gControls->tw->proxySettingsBtn) HiliteControl(gControls->tw->proxySettingsBtn, kDisableControl); }
void SetResumedState(void) { /* disable pause button */ if (gControls->nextB) HiliteControl(gControls->nextB, kDisableControl); /* enable resume button */ if (gControls->backB) HiliteControl(gControls->backB, kEnableControl); gControls->state = eResuming; }
/* set the controls in the TextEdit window correctly */ void NATEsetscroll(na_win *winp, Boolean moved, Rect *hrect, Rect *vrect) { short vmax, vvalue, hmax, hvalue; TEPtr te = *teinfo->hTE; ControlHandle vctrl, hctrl; vmax = te->nLines + (*(*te->hText + te->teLength - 1) == '\015' ? 1 : 0) - (te->viewRect.bottom - te->viewRect.top) / teinfo->lheight; hmax = (short) teinfo->docwidth - (te->viewRect.right - te->viewRect.left); if (vmax < 0) vmax = 0; if (hmax < 0) hmax = 0; vvalue = (te->viewRect.top - te->destRect.top) / teinfo->lheight; hvalue = te->viewRect.left - te->destRect.left; if (!(winp->flags & NATE_NOVSCROLL)) { if (teinfo->vctrl == (ControlHandle) NULL) { teinfo->vctrl = NewControl(winp->pwin, vrect, "\p", true, vvalue, 0, vmax, scrollBarProc, 0); if (winp->pwin != FrontWindow()) HiliteControl(teinfo->vctrl, 255); } else { if (vvalue < 0) vvalue = 0; if (vvalue > vmax) vvalue = vmax; SetCtlMax(vctrl = teinfo->vctrl, vmax); SetCtlValue(vctrl, vvalue); if (moved) { MoveControl(vctrl, vrect->left, vrect->top); SizeControl(vctrl, vrect->right - vrect->left, vrect->bottom - vrect->top); ShowControl(vctrl); } } } if (!(winp->flags & NATE_NOHSCROLL)) { if (teinfo->hctrl == (ControlHandle) NULL) { teinfo->hctrl = NewControl(winp->pwin, hrect, "\p", true, hvalue, 0, hmax, scrollBarProc, 0); if (winp->pwin != FrontWindow()) HiliteControl(teinfo->hctrl, 255); } else { if (hvalue < 0) hvalue = 0; if (hvalue > hmax) hvalue = hmax; SetCtlMax(hctrl = teinfo->hctrl, hmax); SetCtlValue(hctrl, hvalue); if (moved) { MoveControl(hctrl, hrect->left, hrect->top); SizeControl(hctrl, hrect->right - hrect->left, hrect->bottom - hrect->top); ShowControl(hctrl); } } } }
/* Flash a dialog button when its accelerator key is pressed */ void FlashButton(DialogRef wind, short item) { short type; Handle handle; Rect rect; unsigned long ticks; /* Apple recommends 8 ticks */ GetDialogItem(wind, item, &type, &handle, &rect); HiliteControl((ControlHandle)handle, kControlButtonPart); Delay(8, &ticks); HiliteControl((ControlHandle)handle, 0); return; }
void ShowNavButtons(unsigned char* backTitle, unsigned char* nextTitle) { Boolean bDefault = true; gControls->backB = GetNewControl( rBackBtn, gWPtr); gControls->nextB = GetNewControl( rNextBtn, gWPtr); if( gControls->backB != NULL) { SetControlTitle( gControls->backB, backTitle); ShowControl( gControls->backB); if (gCurrWin==kWelcomeID || gCurrWin==kSetupTypeID) HiliteControl(gControls->backB, kDisableControl); } if ( gControls->nextB != NULL) { SetControlTitle( gControls->nextB, nextTitle); ShowControl( gControls->nextB); SetControlData(gControls->nextB, kControlNoPart, kControlPushButtonDefaultTag, sizeof(bDefault),(Ptr) &bDefault); } ShowCancelButton(); }
Boolean TActiveScroller::HandleMouseClick(Point inPoint) { #if TARGET_API_MAC_CARBON==1 UPortSaver safe(GetControlOwner(scrollBar)); #else UPortSaver safe((**scrollBar).contrlOwner); #endif short partCode; if (partCode=TestControl(scrollBar,inPoint)) { switch (partCode) { case kControlUpButtonPart: case kControlDownButtonPart: case kControlPageDownPart: case kControlPageUpPart: case kControlIndicatorPart: SetupScroll(); if (partCode==kControlIndicatorPart) { // Dim the thumb HiliteControl(scrollBar,kControlIndicatorPart); IndicatorProc(inPoint); // Undim the thumb HiliteControl(scrollBar,kControlNoPart); } else { // Must call this to pass the current object to the tracking proc SetTrackingObject(this); TrackControl(scrollBar,inPoint,scrollBarProcUPP); } ShutdownScroll(); return true; break; } } return false; // missed the scroll bar }
void EnableLicenseWin(void) { GrafPtr oldPort; GetPort(&oldPort); SetPort(gWPtr); EnableNavButtons(); if(gControls->lw->licBox) HiliteControl(gControls->lw->licBox, kEnableControl); if(gControls->lw->scrollBar) HiliteControl(gControls->lw->scrollBar, kEnableControl); ShowTxt(); SetPort(oldPort); // TO DO }
void DisableLicenseWin(void) { DisableNavButtons(); /* if(gControls->lw->licBox) HiliteControl(gControls->lw->licBox, kDisableControl); */ if(gControls->lw->scrollBar) HiliteControl(gControls->lw->scrollBar, kDisableControl); }
void TActiveScroller::DisableScroller() { if (disabled) return; disabled=true; #if TARGET_API_MAC_CARBON==1 wasScrollHilight=GetControlHilite(scrollBar); #else wasScrollHilight=(**scrollBar).contrlHilite; #endif if (wasScrollHilight!=kControlInactivePart) HiliteControl(scrollBar,kControlInactivePart); }
static void mac_activatekey(WindowPtr window, EventRecord *event) { DialogRef dialog; DialogItemType itemtype; Handle itemhandle; short item; Rect itemrect; int active; dialog = GetDialogFromWindow(window); active = (event->modifiers & activeFlag) != 0; GetDialogItem(dialog, wiKeyGenerate, &itemtype, &itemhandle, &itemrect); HiliteControl((ControlHandle)itemhandle, active ? 0 : 255); DialogSelect(event, &dialog, &item); }
void disablescrollbar (hdlscrollbar hscrollbar) { hdlscrollbar h = hscrollbar; if (h == nil) /*defensive driving*/ return; scrollbarpushclip (h); HiliteControl (h, -1); /*validscrollbar (h);*/ popclip (); } /*disablescrollbar*/
void TActiveScroller::EnableScroller() { UInt8 temp; if (!disabled) return; disabled=false; #if TARGET_API_MAC_CARBON==1 temp=GetControlHilite(scrollBar); #else temp=(**scrollBar).contrlHilite; #endif if (wasScrollHilight!=temp) HiliteControl(scrollBar,wasScrollHilight); }
void tool_wind_fix_enable(void) { int n,nsel,type,index,seg_type,group_idx; bool has_fc_seg; // add-sub-tesselate vertex buttons has_fc_seg=FALSE; nsel=select_count(); for (n=0;n!=nsel;n++) { select_get(0,&type,&index); if (type==segment_piece) { seg_type=map.segments[index].type; if ((seg_type==sg_floor) || (seg_type==sg_ceiling)) { has_fc_seg=TRUE; break; } } } if (!has_fc_seg) { HiliteControl(tool_ctrl[16],255); HiliteControl(tool_ctrl[17],255); HiliteControl(tool_ctrl[18],255); } else { HiliteControl(tool_ctrl[16],0); HiliteControl(tool_ctrl[17],0); HiliteControl(tool_ctrl[18],0); } // group combo group_idx=-1; if (select_count()==1) { select_get(0,&type,&index); if ((type==segment_piece) || (type==primitive_piece)) group_idx=map.segments[index].group_idx; } if (group_idx==-1) { SetControl32BitValue(group_combo,1); } else { SetControl32BitValue(group_combo,(3+group_idx)); } }
void enablescrollbar (hdlscrollbar hscrollbar) { hdlscrollbar h = hscrollbar; if (h == nil) /*defensive driving*/ return; if (!(**h).contrlRfCon) { /*the window containing the scrollbar is inactive*/ disablescrollbar (h); return; } scrollbarpushclip (h); HiliteControl (h, 0); /*validscrollbar (h);*/ popclip (); } /*enablescrollbar*/
// -------------------------------------------------------------------------------------- static Boolean dialogFilter(EventRecord *event, DialogRef *theDialog, DialogItemIndex *itemHit) { /* See the comments for HandleKeyDown in PrefsWindow.c about why we're using virtual key codes instead of character codes. */ Boolean eventHandled = false; char charCode, keyCode; switch (event->what) { case keyDown: // handle key presses not handled by DialogSelect case autoKey: *theDialog = GetDialogFromWindow(FrontNonFloatingWindow()); SetPortDialogPort(*theDialog); charCode = event->message & charCodeMask; keyCode = (event->message & keyCodeMask) >> 8; if ((event->modifiers & cmdKey) != 0) // check to see if any menu commands { // were selected - this isn't necessarily handling the event UInt32 menuChoice; OSErr error; MenuCommand commandID; menuChoice = MenuEvent(event); error = GetMenuItemCommandID(GetMenuRef(HiWord(menuChoice)), LoWord(menuChoice), &commandID); if (error == noErr) { if (commandID == 0) // if the menu item chosen does not have a commandID = (MenuCommand)menuChoice; // command ID HandleMenuChoice(commandID); // (but they all should) } } if ( (keyCode == kEnterKeyCode) || (keyCode == kReturnKeyCode) || (keyCode == kEscapeKeyCode) || ( ((event->modifiers & cmdKey) != 0) && (charCode == '.') ) ) { ControlRef button; unsigned long finalTicks; if ( (keyCode == kEnterKeyCode) || (keyCode == kReturnKeyCode) ) { GetDialogItemAsControl(*theDialog, kStdOkItemIndex, &button); *itemHit = kStdOkItemIndex; } else { GetDialogItemAsControl(*theDialog, kStdCancelItemIndex, &button); *itemHit = kStdCancelItemIndex; } HiliteControl(button, kControlButtonPart); Delay(8, &finalTicks); HiliteControl(button, kControlNoPart); eventHandled = true; } } return eventHandled; }
void TkpDisplayScale( ClientData clientData) /* Widget record for scale. */ { TkScale *scalePtr = (TkScale *) clientData; Tk_Window tkwin = scalePtr->tkwin; Tcl_Interp *interp = scalePtr->interp; int result; char string[TCL_DOUBLE_SPACE]; MacScale *macScalePtr = (MacScale *) clientData; Rect r; WindowRef windowRef; CGrafPtr destPort, savePort; Boolean portChanged; MacDrawable *macDraw; SInt32 initialValue, minValue, maxValue; UInt16 numTicks; #ifdef TK_MAC_DEBUG_SCALE TkMacOSXDbgMsg("TkpDisplayScale"); #endif scalePtr->flags &= ~REDRAW_PENDING; if ((scalePtr->tkwin == NULL) || !Tk_IsMapped(scalePtr->tkwin)) { goto done; } /* * Invoke the scale's command if needed. */ Tcl_Preserve((ClientData) scalePtr); if ((scalePtr->flags & INVOKE_COMMAND) && (scalePtr->command != NULL)) { Tcl_Preserve((ClientData) interp); sprintf(string, scalePtr->format, scalePtr->value); result = Tcl_VarEval(interp, scalePtr->command, " ", string, NULL); if (result != TCL_OK) { Tcl_AddErrorInfo(interp, "\n (command executed by scale)"); Tcl_BackgroundError(interp); } Tcl_Release((ClientData) interp); } scalePtr->flags &= ~INVOKE_COMMAND; if (scalePtr->flags & SCALE_DELETED) { Tcl_Release((ClientData) scalePtr); return; } Tcl_Release((ClientData) scalePtr); /* * Now handle the part of redisplay that is the same for * horizontal and vertical scales: border and traversal * highlight. */ if (scalePtr->highlightWidth != 0) { GC gc = Tk_GCForColor(scalePtr->highlightColorPtr, Tk_WindowId(tkwin)); Tk_DrawFocusHighlight(tkwin, gc, scalePtr->highlightWidth, Tk_WindowId(tkwin)); } Tk_Draw3DRectangle(tkwin, Tk_WindowId(tkwin), scalePtr->bgBorder, scalePtr->highlightWidth, scalePtr->highlightWidth, Tk_Width(tkwin) - 2*scalePtr->highlightWidth, Tk_Height(tkwin) - 2*scalePtr->highlightWidth, scalePtr->borderWidth, scalePtr->relief); /* * Set up port for drawing Macintosh control. */ macDraw = (MacDrawable *) Tk_WindowId(tkwin); destPort = TkMacOSXGetDrawablePort(Tk_WindowId(tkwin)); windowRef = TkMacOSXDrawableWindow(Tk_WindowId(tkwin)); portChanged = QDSwapPort(destPort, &savePort); TkMacOSXSetUpClippingRgn(Tk_WindowId(tkwin)); /* * Create Macintosh control. */ #define MAC_OSX_SCROLL_WIDTH 10 if (scalePtr->orient == ORIENT_HORIZONTAL) { int offset = (Tk_Height(tkwin) - MAC_OSX_SCROLL_WIDTH)/2; if (offset < 0) { offset = 0; } r.left = macDraw->xOff + scalePtr->inset; r.top = macDraw->yOff + offset; r.right = macDraw->xOff+Tk_Width(tkwin) - scalePtr->inset; r.bottom = macDraw->yOff + offset + MAC_OSX_SCROLL_WIDTH/2; } else { int offset = (Tk_Width(tkwin) - MAC_OSX_SCROLL_WIDTH)/2; if (offset < 0) { offset = 0; } r.left = macDraw->xOff + offset; r.top = macDraw->yOff + scalePtr->inset; r.right = macDraw->xOff + offset + MAC_OSX_SCROLL_WIDTH/2; r.bottom = macDraw->yOff+Tk_Height(tkwin) - scalePtr->inset; } if (macScalePtr->scaleHandle == NULL) { #ifdef TK_MAC_DEBUG_SCALE TkMacOSXDbgMsg("Initialising scale"); #endif initialValue = scalePtr->value; if (scalePtr->orient == ORIENT_HORIZONTAL) { minValue = scalePtr->fromValue; maxValue = scalePtr->toValue; } else { minValue = scalePtr->fromValue; maxValue = scalePtr->toValue; } if (scalePtr->tickInterval == 0) { numTicks = 0; } else { numTicks = (maxValue - minValue)/scalePtr->tickInterval; } CreateSliderControl(windowRef, &r, initialValue, minValue, maxValue, kControlSliderPointsDownOrRight, numTicks, 1, scaleActionProc, &(macScalePtr->scaleHandle)); SetControlReference(macScalePtr->scaleHandle, (UInt32) scalePtr); if (IsWindowActive(windowRef)) { macScalePtr->flags |= ACTIVE; } } else { SetControlBounds(macScalePtr->scaleHandle, &r); SetControl32BitValue(macScalePtr->scaleHandle, scalePtr->value); SetControl32BitMinimum(macScalePtr->scaleHandle, scalePtr->fromValue); SetControl32BitMaximum(macScalePtr->scaleHandle, scalePtr->toValue); } /* * Finally draw the control. */ SetControlVisibility(macScalePtr->scaleHandle,true,true); HiliteControl(macScalePtr->scaleHandle,0); Draw1Control(macScalePtr->scaleHandle); if (portChanged) { QDSwapPort(savePort, NULL); } done: scalePtr->flags &= ~REDRAW_ALL; }
ALIST_API void ALActivate(Boolean isActive, ALHandle hAL) { short status; short hilite; ALPtr pAL; // Sanity check! if (hAL == nil || *hAL == nil) return; // Get current status of the active flag status = BTST((*hAL)->flags, alFActive) ? alBitSet : alBitClear; if ((isActive && status == alBitSet) || (!isActive && status == alBitClear)) return; // Do nothing, we're already the way the user wants us to be. else { // Hide the selection hiliting. _ALHiliteSelected(hAL); pAL = *hAL; if ( isActive ) { BSET(pAL->flags, alFComingActive); BSET(pAL->flags, alFActive); hilite = kControlNoPart; } else { BCLR(pAL->flags, alFActive); hilite = kControlInactivePart; // Dispose of the offscreen port if we're inactive. if (pAL->offscreenPort != nil) { DisposeGWorld(pAL->offscreenPort); (*hAL)->offscreenPort = nil; } } // Show the selection hiliting. _ALHiliteSelected(hAL); #if ALIST_USEAPPEARANCEMGR if (BTST((*hAL)->flags, alFHasAppearanceMgr) != 0) { if ((*hAL)->vScroll != nil) { if (hilite == kControlInactivePart) DeactivateControl((*hAL)->vScroll); else ActivateControl((*hAL)->vScroll); } if ((*hAL)->hScroll != nil) { if (hilite == kControlInactivePart) DeactivateControl((*hAL)->hScroll); else ActivateControl((*hAL)->hScroll); } } else #endif { if ((*hAL)->vScroll != nil) HiliteControl((*hAL)->vScroll, hilite); if ((*hAL)->hScroll != nil) HiliteControl((*hAL)->hScroll, hilite); } ALUpdate( nil, hAL ); } } // ALActivate
/* VARARGS ARGSUSED */ void TclpPanic TCL_VARARGS_DEF(CONST char *, format) { va_list varg; char msg[256]; WindowRef macWinPtr, foundWinPtr; Rect macRect; Rect buttonRect = PANIC_BUTTON_RECT; Rect iconRect = PANIC_ICON_RECT; Rect textRect = PANIC_TEXT_RECT; ControlHandle okButtonHandle; EventRecord event; Handle stopIconHandle; int part; Boolean done = false; va_start(varg, format); vsprintf(msg, format, varg); va_end(varg); /* * Put up an alert without using the Resource Manager (there may * be no resources to load). Use the Window and Control Managers instead. * We want the window centered on the main monitor. The following * should be tested with multiple monitors. Look and see if there is a way * not using qd.screenBits. */ macRect.top = (qd.screenBits.bounds.top + qd.screenBits.bounds.bottom) / 2 - (PANICHEIGHT / 2); macRect.bottom = (qd.screenBits.bounds.top + qd.screenBits.bounds.bottom) / 2 + (PANICHEIGHT / 2); macRect.left = (qd.screenBits.bounds.left + qd.screenBits.bounds.right) / 2 - (PANICWIDTH / 2); macRect.right = (qd.screenBits.bounds.left + qd.screenBits.bounds.right) / 2 + (PANICWIDTH / 2); macWinPtr = NewWindow(NULL, &macRect, "\p", true, dBoxProc, (WindowRef) -1, false, 0); if (macWinPtr == NULL) { goto exitNow; } okButtonHandle = NewControl(macWinPtr, &buttonRect, "\pOK", true, 0, 0, 1, pushButProc, 0); if (okButtonHandle == NULL) { CloseWindow(macWinPtr); goto exitNow; } SelectWindow(macWinPtr); SetCursor(&qd.arrow); stopIconHandle = GetIcon(kStopIcon); while (!done) { if (WaitNextEvent(mDownMask | keyDownMask | updateMask, &event, 0, NULL)) { switch(event.what) { case mouseDown: part = FindWindow(event.where, &foundWinPtr); if ((foundWinPtr != macWinPtr) || (part != inContent)) { SysBeep(1); } else { SetPortWindowPort(macWinPtr); GlobalToLocal(&event.where); part = FindControl(event.where, macWinPtr, &okButtonHandle); if ((kControlButtonPart == part) && (TrackControl(okButtonHandle, event.where, NULL))) { done = true; } } break; case keyDown: switch (event.message & charCodeMask) { case ENTERCODE: case RETURNCODE: HiliteControl(okButtonHandle, 1); HiliteControl(okButtonHandle, 0); done = true; } break; case updateEvt: SetPortWindowPort(macWinPtr); TextFont(systemFont); BeginUpdate(macWinPtr); if (stopIconHandle != NULL) { PlotIcon(&iconRect, stopIconHandle); } TETextBox(msg, strlen(msg), &textRect, teFlushDefault); DrawControls(macWinPtr); EndUpdate(macWinPtr); } } } CloseWindow(macWinPtr); exitNow: #ifdef TCL_DEBUG Debugger(); #else abort(); #endif }
void TkpDisplayScrollbar( ClientData clientData) /* Information about window. */ { TkScrollbar *scrollPtr = (TkScrollbar *) clientData; MacScrollbar *macScrollPtr = (MacScrollbar *) clientData; Tk_Window tkwin = scrollPtr->tkwin; MacDrawable *macDraw; CGrafPtr saveWorld; GDHandle saveDevice; GWorldPtr destPort; WindowRef windowRef; if ((scrollPtr->tkwin == NULL) || !Tk_IsMapped(tkwin)) { goto done; } /* * Draw the focus or any 3D relief we may have. */ if (scrollPtr->highlightWidth != 0) { GC fgGC, bgGC; bgGC = Tk_GCForColor(scrollPtr->highlightBgColorPtr, Tk_WindowId(tkwin)); if (scrollPtr->flags & GOT_FOCUS) { fgGC = Tk_GCForColor(scrollPtr->highlightColorPtr, Tk_WindowId(tkwin)); TkpDrawHighlightBorder(tkwin, fgGC, bgGC, scrollPtr->highlightWidth, Tk_WindowId(tkwin)); } else { TkpDrawHighlightBorder(tkwin, bgGC, bgGC, scrollPtr->highlightWidth, Tk_WindowId(tkwin)); } } Tk_Draw3DRectangle(tkwin, Tk_WindowId(tkwin), scrollPtr->bgBorder, scrollPtr->highlightWidth, scrollPtr->highlightWidth, Tk_Width(tkwin) - 2*scrollPtr->highlightWidth, Tk_Height(tkwin) - 2*scrollPtr->highlightWidth, scrollPtr->borderWidth, scrollPtr->relief); /* * Set up port for drawing Macintosh control. */ macDraw = (MacDrawable *) Tk_WindowId(tkwin); destPort = TkMacOSXGetDrawablePort(Tk_WindowId(tkwin)); GetGWorld(&saveWorld, &saveDevice); SetGWorld(destPort, NULL); TkMacOSXSetUpClippingRgn(Tk_WindowId(tkwin)); if (macScrollPtr->sbHandle == NULL) { Rect r; SInt16 initialValue; SInt16 minValue; SInt16 maxValue; SInt16 procID; WindowRef frontNonFloating; r.left = r.top = 0; r.right = r.bottom = 1; minValue = MIN_SCROLLBAR_VALUE; maxValue = MAX_SCROLLBAR_VALUE; initialValue = (minValue + maxValue)/2; procID = kControlScrollBarLiveProc; windowRef = GetWindowFromPort(destPort); CreateScrollBarControl(windowRef, &r, initialValue, minValue, maxValue, maxValue - minValue, true, NULL, &(macScrollPtr->sbHandle)); SetControlReference(macScrollPtr->sbHandle, (SInt32) scrollPtr); /* * If we are foremost then make us active. */ frontNonFloating = FrontNonFloatingWindow(); if ((windowRef == FrontWindow()) || TkpIsWindowFloating(windowRef)) { macScrollPtr->macFlags |= ACTIVE; } } /* * Adjust the control size based on its width... */ if (macScrollPtr->info.width < 13) { SetControlData(macScrollPtr->sbHandle, kControlNoPart, kControlSizeTag, sizeof(kControlSizeSmall), (void *) kControlSizeSmall); } else { SetControlData(macScrollPtr->sbHandle, kControlNoPart, kControlSizeTag, sizeof(kControlSizeSmall), (void *) kControlSizeLarge); } /* * Update the control values before we draw. */ windowRef = GetControlOwner (macScrollPtr->sbHandle); UpdateControlValues(macScrollPtr); if (macScrollPtr->macFlags & ACTIVE) { Draw1Control(macScrollPtr->sbHandle); if (macScrollPtr->macFlags & DRAW_GROW) { DrawGrowIcon(windowRef); } } else { HiliteControl (macScrollPtr->sbHandle, 255 ); Draw1Control(macScrollPtr->sbHandle); if (macScrollPtr->macFlags & DRAW_GROW) { DrawGrowIcon(windowRef); Tk_Fill3DRectangle(tkwin, Tk_WindowId(tkwin), scrollPtr->bgBorder, Tk_Width(tkwin) - 13, Tk_Height(tkwin) - 13, Tk_Width(tkwin), Tk_Height(tkwin), 0, TK_RELIEF_FLAT); } } SetGWorld(saveWorld, saveDevice); done: scrollPtr->flags &= ~REDRAW_PENDING; }
static pascal Boolean MyFilter(DialogPtr dlog, EventRecord *evt, short *itemHit) { Boolean ans=FALSE,doHilite=FALSE; WindowPtr w; short type,ch; Handle hndl; Rect box; static long then; static Point clickPt; w = (WindowPtr)(evt->message); switch(evt->what) { case updateEvt: if (w == dlog) { /* Update our dialog contents */ DoDialogUpdate(dlog); ans = TRUE; *itemHit = 0; } else { /* * Call your main event loop DoUpdate(w) routine here if you * don't want unsightly holes in background windows caused * by nested alerts, balloon help, or screen savers (see * Tech Note #304). */ } break; case activateEvt: if (w == dlog) { DoDialogActivate(dlog,(evt->modifiers & activeFlag)!=0); *itemHit = 0; } else { /* * Call your main event loop DoActivate(w) routine here if * you want to deactivate the former frontmost window, in order * to unhighlight any selection, scroll bars, etc. */ } break; case mouseDown: case mouseUp: where = evt->where; /* Make info available to DoDialog() */ GlobalToLocal(&where); modifiers = evt->modifiers; ans = CheckUserItems(where,itemHit); break; case keyDown: if ((ch=(unsigned char)evt->message)=='\r' || ch==ENTERkey) { *itemHit = OK_ITEM /* Default Item Number here */; doHilite = ans = TRUE; } else if (evt->modifiers & cmdKey) { ch = (unsigned char)evt->message; switch(ch) { case 'x': case 'X': if (TextSelected(dlog)) { SystemEdit(3); ZeroScrap(); DialogCut(dlog); TEToScrap(); } else { /* Cut from anything else cuttable, like a list */ } break; case 'c': case 'C': if (TextSelected(dlog)) { SystemEdit(3); ZeroScrap(); DialogCopy(dlog); TEToScrap(); } else { /* Copy from anything else copyable, like a list */ } break; case 'v': case 'V': if (CanPaste(1,'TEXT')) { TEFromScrap(); DialogPaste(dlog); } else { /* Deal with any other pasteable scraps here */ } break; case 'a': case 'A': if (((DialogPeek)dlog)->editField >= 0) { /* Dialog has text edit item: select all */ SelectDialogItemText(dlog,((DialogPeek)dlog)->editField+1,0,32767); } else { } *itemHit = 0; break; case '.': *itemHit = CANCEL_ITEM; doHilite = TRUE; break; } ans = TRUE; /* Other cmd-chars ignored */ } break; } if (doHilite) { GetDialogItem(dlog,*itemHit,&type,&hndl,&box); /* Reality check */ if (type == (btnCtrl+ctrlItem)) { long soon = TickCount() + 7; /* Or whatever feels right */ HiliteControl((ControlHandle)hndl,1); while (TickCount() < soon) ; /* Leave hilited for a bit */ } } return(ans); }
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); } } }
void TkpDisplayMenuButton( ClientData clientData) /* Information about widget. */ { TkMenuButton *butPtr = (TkMenuButton *) clientData; Tk_Window tkwin = butPtr->tkwin; TkWindow * winPtr; Pixmap pixmap; MacMenuButton * mbPtr = (MacMenuButton *) butPtr; GWorldPtr dstPort; CGrafPtr saveWorld; GDHandle saveDevice; int hasImageOrBitmap = 0; int width, height; int err; ControlButtonGraphicAlignment theAlignment; Rect paneRect, cntrRect; butPtr->flags &= ~REDRAW_PENDING; if ((butPtr->tkwin == NULL) || !Tk_IsMapped(tkwin)) { return; } pixmap = ( Pixmap )Tk_WindowId(tkwin); GetGWorld(&saveWorld, &saveDevice); dstPort = TkMacOSXGetDrawablePort(Tk_WindowId(tkwin)); SetGWorld(dstPort, NULL); TkMacOSXSetUpClippingRgn(Tk_WindowId(tkwin)); winPtr=(TkWindow *)butPtr->tkwin; paneRect.left=winPtr->privatePtr->xOff; paneRect.top=winPtr->privatePtr->yOff; paneRect.right=paneRect.left+Tk_Width(butPtr->tkwin)-1; paneRect.bottom=paneRect.top+Tk_Height(butPtr->tkwin)-1; cntrRect=paneRect; cntrRect.left+=butPtr->inset; cntrRect.top+=butPtr->inset; cntrRect.right-=butPtr->inset; cntrRect.bottom-=butPtr->inset; if (mbPtr->userPane) { MenuButtonControlParams params; bzero(¶ms, sizeof(params)); ComputeMenuButtonControlParams(butPtr, ¶ms ); if (bcmp(¶ms,&mbPtr->params,sizeof(params))) { if (mbPtr->userPane) { DisposeControl(mbPtr->userPane); mbPtr->userPane = NULL; mbPtr->control = NULL; } } } if (!mbPtr->userPane) { if (MenuButtonInitControl(mbPtr,&paneRect,&cntrRect ) ) { fprintf(stderr,"Init Control failed\n" ); return; } } SetControlBounds(mbPtr->userPane,&paneRect); SetControlBounds(mbPtr->control,&cntrRect); /* * We need to cache the title and its style */ if (!(mbPtr->flags&2)) { ControlTitleParams titleParams; int titleChanged; int styleChanged; ComputeControlTitleParams(butPtr,&titleParams); CompareControlTitleParams(&titleParams,&mbPtr->titleParams, &titleChanged,&styleChanged); if (titleChanged) { CFStringRef cf; cf = CFStringCreateWithCString(NULL, titleParams.title, kCFStringEncodingUTF8); if (hasImageOrBitmap) { SetControlTitleWithCFString(mbPtr->control, cf); } else { SetMenuItemTextWithCFString(mbPtr->menuRef, 1, cf); } CFRelease(cf); bcopy(titleParams.title,mbPtr->titleParams.title,titleParams.len+1); mbPtr->titleParams.len = titleParams.len; } if ((titleChanged||styleChanged) && titleParams .len) { if (hasImageOrBitmap) { if ((err=SetControlFontStyle(mbPtr->control,&titleParams.style))!=noErr) { fprintf(stderr,"SetControlFontStyle failed %d\n", err); return; } } bcopy(&titleParams.style,&mbPtr->titleParams.style,sizeof(titleParams.style)); } } if (butPtr->image != None) { Tk_SizeOfImage(butPtr->image, &width, &height); hasImageOrBitmap = 1; } else if (butPtr->bitmap != None) { Tk_SizeOfBitmap(butPtr->display, butPtr->bitmap, &width, &height); hasImageOrBitmap = 1; } if (hasImageOrBitmap) { mbPtr->picParams.srcRect.right = width; mbPtr->picParams.srcRect.bottom = height; /* Set the flag to circumvent clipping and bounds problems with OS 10.0.4 */ tkPictureIsOpen = 1; if (!(mbPtr->bevelButtonContent.u.picture = OpenCPicture(&mbPtr->picParams)) ) { fprintf(stderr,"OpenCPicture failed\n"); } /* * TO DO - There is one case where XCopyPlane calls CopyDeepMask, * which does not get recorded in the picture. So the bitmap code * will fail in that case. */ if (butPtr->image != NULL) { Tk_RedrawImage(butPtr->image, 0, 0, width, height, pixmap, 0, 0); } else { XCopyPlane(butPtr->display, butPtr->bitmap, pixmap, NULL, 0, 0, (unsigned int) width, (unsigned int) height, 0, 0, 1); } ClosePicture(); tkPictureIsOpen = 0; if ( (err=SetControlData(mbPtr->control, kControlButtonPart, kControlBevelButtonContentTag, sizeof(ControlButtonContentInfo), (char *) &mbPtr->bevelButtonContent)) != noErr ) { fprintf(stderr,"SetControlData BevelButtonContent failed, %d\n", err ); } switch (butPtr->anchor) { case TK_ANCHOR_N: theAlignment = kControlBevelButtonAlignTop; break; case TK_ANCHOR_NE: theAlignment = kControlBevelButtonAlignTopRight; break; case TK_ANCHOR_E: theAlignment = kControlBevelButtonAlignRight; break; case TK_ANCHOR_SE: theAlignment = kControlBevelButtonAlignBottomRight; break; case TK_ANCHOR_S: theAlignment = kControlBevelButtonAlignBottom; break; case TK_ANCHOR_SW: theAlignment = kControlBevelButtonAlignBottomLeft; break; case TK_ANCHOR_W: theAlignment = kControlBevelButtonAlignLeft; break; case TK_ANCHOR_NW: theAlignment = kControlBevelButtonAlignTopLeft; break; case TK_ANCHOR_CENTER: theAlignment = kControlBevelButtonAlignCenter; break; } if ((err=SetControlData(mbPtr->control, kControlButtonPart, kControlBevelButtonGraphicAlignTag, sizeof(ControlButtonGraphicAlignment), (char *) &theAlignment)) != noErr ) { fprintf(stderr,"SetControlData BevelButtonGraphicAlign failed, %d\n", err ); } } if (butPtr->flags & GOT_FOCUS) { HiliteControl(mbPtr->control,kControlButtonPart); } else { HiliteControl(mbPtr->control,kControlNoPart); } UpdateControlColors(mbPtr); if (mbPtr->flags&2) { ShowControl(mbPtr->control); ShowControl(mbPtr->userPane); mbPtr->flags ^= 2; } else { Draw1Control(mbPtr->userPane); SetControlVisibility(mbPtr->control, true, true); } if (hasImageOrBitmap) { KillPicture(mbPtr->bevelButtonContent.u.picture); } SetGWorld(saveWorld, saveDevice); }
// ----------------------------------------------------------------------------- // HITestViewTrack // ----------------------------------------------------------------------------- // This is overkill, and probably #ifdef'd out, but is here as an example of // a custom tracking handler. // OSStatus HITestViewTrack( EventRef inEvent, HITestViewData* inData ) { OSStatus err; HIRect bounds; HIPoint where; ControlPartCode part; Boolean inside; Boolean wasInside; Point qdPt; MouseTrackingResult mouseResult; PixMapHandle portPixMap; // Extract the mouse location err = GetEventParameter( inEvent, kEventParamMouseLocation, typeHIPoint, NULL, sizeof( HIPoint ), NULL, &where ); require_noerr( err, ParameterMissing ); // Is the mouse location in the view? err = HIViewGetBounds( inData->view, &bounds ); if ( CGRectContainsPoint( bounds, where ) ) part = 1; else part = kControlNoPart; HiliteControl( inData->view, part ); wasInside = true; // Need the port's pixMap's bounds to convert the mouse location portPixMap = GetPortPixMap( GetWindowPort( GetControlOwner( inData->view ) ) ); // The tracking loop while ( true ) { // Check again to see if the mouse is in the view if ( CGRectContainsPoint( bounds, where ) ) part = 1; else part = kControlNoPart; inside = ( part != kControlNoPart ); // If that changed, update if ( inside != wasInside ) HiliteControl( inData->view, part ); wasInside = inside; // Watch the mouse for change err = TrackMouseLocation( (GrafPtr)-1L, &qdPt, &mouseResult ); // Need to convert from global QDGlobalToLocalPoint( GetWindowPort( GetControlOwner( inData->view ) ), &qdPt ); where.x = qdPt.h - (**portPixMap).bounds.left; where.y = qdPt.v - (**portPixMap).bounds.top; HIViewConvertPoint( &where, NULL, inData->view ); // Bail out when the mouse is released if ( mouseResult == kMouseTrackingMouseReleased ) break; } // Restore the original highlight HiliteControl( inData->view, kControlNoPart ); // Send back the part upon which the mouse was released err = SetEventParameter( inEvent, kEventParamControlPart, typeControlPartCode, sizeof( ControlPartCode ), &part ); ParameterMissing: return err; }
/***************************************************** * * Handle_WindowCommandProcess(inHandlerCallRef, inEvent, inUserData) * * Purpose: called to handle of the events generated by the various controls of the HICustomView_Tester window * * 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 - noErr indicates the event was handled * eventNotHandledErr indicates the event was not handled and the Toolbox should take over */ static pascal OSStatus Handle_WindowCommandProcess(EventHandlerCallRef inHandlerCallRef, EventRef inEvent, void *inUserData) { OSStatus status; HIViewRef customView = (HIViewRef)inUserData; // getting the command HICommandExtended aCommand; status = GetEventParameter(inEvent, kEventParamDirectObject, typeHICommand, NULL, sizeof(aCommand), NULL, &aCommand); require_noerr(status, ExitCommandProcess); status = eventNotHandledErr; // cheking that the command came from a control if ( ! (aCommand.attributes & kHICommandFromControl) ) goto ExitCommandProcess; switch (aCommand.commandID) { // // Asking for a refresh of the custom view // case 'SNDt': HIViewSetNeedsDisplay(customView, true); status = noErr; break; // // Setting the control value of the custom view // case 'SV00': SetControl32BitValue(customView, 0); status = noErr; break; case 'SV01': SetControl32BitValue(customView, 1); status = noErr; break; case 'SV17': SetControl32BitValue(customView, 17); status = noErr; break; case 'SVTH': SetControl32BitValue(customView, 1000); status = noErr; break; case 'SVet': { HIViewRef editText; HIViewFindByID(HIViewGetRoot(GetControlOwner(customView)), kSetValueEditID, &editText); char buffer[11]; Size actualSize; GetControlData(editText, kControlEntireControl, kControlEditTextTextTag, 10, buffer, &actualSize); if (actualSize > 10) actualSize = 10; buffer[actualSize] = 0; SetControl32BitValue(customView, atoi(buffer)); } status = noErr; break; // // Setting the state of the custom view // case 'CHlt': // setting the hilite to non-0 also stomps the previous hilite state if any // and we don't want that in our testing if (GetControl32BitValue(aCommand.source.control) == 1) HiliteControl(customView, 1); else HiliteControl(customView, 0); status = noErr; break; case 'CEnb': { HIViewRef hiliteControl; HIViewFindByID(HIViewGetRoot(GetControlOwner(customView)), kCheckHiliteID, &hiliteControl); if (GetControl32BitValue(aCommand.source.control) == 1) EnableControl(customView); else DisableControl(customView); UInt16 prevHilite = GetControlHilite(customView); if ((prevHilite == kControlInactivePart) || (prevHilite == kControlDisabledPart)) DisableControl(hiliteControl); else EnableControl(hiliteControl); HIViewSetNeedsDisplay(customView, true); } status = noErr; break; case 'CAct': { HIViewRef hiliteControl; HIViewFindByID(HIViewGetRoot(GetControlOwner(customView)), kCheckHiliteID, &hiliteControl); if (GetControl32BitValue(aCommand.source.control) == 1) ActivateControl(customView); else DeactivateControl(customView); UInt16 prevHilite = GetControlHilite(customView); if ((prevHilite == kControlInactivePart) || (prevHilite == kControlDisabledPart)) DisableControl(hiliteControl); else EnableControl(hiliteControl); HIViewSetNeedsDisplay(customView, true); } status = noErr; break; // // Testing the custom view in or as a scroller in a HIScrollView // case 'CTiS': case 'CTaS': if (GetControl32BitValue(aCommand.source.control) == 1) { // create a HIScrollView and install it where and as the custom view was HIViewRef scrollView; status = HIScrollViewCreate(kHIScrollViewValidOptions, &scrollView); require_noerr(status, ExitCommandProcess); HIRect frame; status = HIViewGetFrame(customView, &frame); require_noerr(status, ExitCommandProcess); status = HIViewSetFrame(scrollView, &frame); require_noerr(status, ExitCommandProcess); HIViewSetLayoutInfo(scrollView, &kBindToParentLayout); HIViewSetLayoutInfo(customView, &kNoBindLayout); status = HIViewAddSubview(HIViewGetSuperview(customView), scrollView); require_noerr(status, ExitCommandProcess); if (aCommand.commandID == 'CTiS') { // if we are testing the custom view in a scroller, we embed it in a scrolling User Pane // that we embed in the HIScrollView Rect boundsRect = {0, 0, 1000, 1000}; HIViewRef userPane; status = CreateUserPaneControl(NULL, &boundsRect, kControlSupportsEmbedding, &userPane); require_noerr(status, ExitCommandProcess); EventTypeSpec userPaneEvents[] = { {kEventClassScrollable, kEventScrollableGetInfo}, {kEventClassScrollable, kEventScrollableScrollTo} }; InstallControlEventHandler(userPane, UserPaneHandler, 2, userPaneEvents, userPane, NULL); status = HIViewAddSubview(scrollView, userPane); require_noerr(status, ExitCommandProcess); status = HIViewAddSubview(userPane, customView); require_noerr(status, ExitCommandProcess); HIViewSetVisible(userPane, true); } else { // else we just embed the custom view directly in the HIScrollView status = HIViewAddSubview(scrollView, customView); require_noerr(status, ExitCommandProcess); } HIViewSetVisible(scrollView, true); // the 2 modes are not compatible so we disable the other check box HIViewRef otherCheckToDisable; if (aCommand.commandID == 'CTiS') HIViewFindByID(HIViewGetRoot(GetControlOwner(customView)), kCheckTestAsScrollID, &otherCheckToDisable); else HIViewFindByID(HIViewGetRoot(GetControlOwner(customView)), kCheckTestInScrollID, &otherCheckToDisable); require_noerr(status, ExitCommandProcess); DisableControl(otherCheckToDisable); // if we reach here, status is already set to noErr so we don't set it again } else { // we remove the HIScrollView and set the custom view back to where and as it was HIViewRef scrollView; if (aCommand.commandID == 'CTiS') scrollView = HIViewGetSuperview(HIViewGetSuperview(customView)); else scrollView = HIViewGetSuperview(customView); status = HIViewAddSubview(HIViewGetSuperview(scrollView), customView); require_noerr(status, ExitCommandProcess); HIRect frame; status = HIViewGetFrame(scrollView, &frame); require_noerr(status, ExitCommandProcess); status = HIViewSetFrame(customView, &frame); require_noerr(status, ExitCommandProcess); HIViewSetLayoutInfo(customView, &kBindToParentLayout); // by releasing the HIScrollView, we also release the scrolling User Pane if any // which was embedded inside CFRelease(scrollView); // we renable the other check box HIViewRef otherCheckToEnable; if (aCommand.commandID == 'CTiS') HIViewFindByID(HIViewGetRoot(GetControlOwner(customView)), kCheckTestAsScrollID, &otherCheckToEnable); else HIViewFindByID(HIViewGetRoot(GetControlOwner(customView)), kCheckTestInScrollID, &otherCheckToEnable); require_noerr(status, ExitCommandProcess); EnableControl(otherCheckToEnable); // if we reach here, status is already set to noErr so we don't set it again } break; } ExitCommandProcess: return status; } // Handle_WindowCommandProcess