XControl::XControl(XWindow *window, OSType signature, UInt32 id) :mListener(0) { ControlID cid = { signature, id }; RequireNoErrString(GetControlByID(window->MacWindow(), &cid, &mControl), "GetControlByID failed"); SetControlReference(mControl, SInt32(this)); }
GuiCheckButton GuiCheckButton_create (GuiForm parent, int left, int right, int top, int bottom, const wchar_t *buttonText, void (*valueChangedCallback) (void *boss, GuiCheckButtonEvent event), void *valueChangedBoss, unsigned long flags) { GuiCheckButton me = Thing_new (GuiCheckButton); my d_shell = parent -> d_shell; my d_parent = parent; my d_valueChangedCallback = valueChangedCallback; my d_valueChangedBoss = valueChangedBoss; #if gtk my d_widget = gtk_check_button_new_with_label (Melder_peekWcsToUtf8 (buttonText)); _GuiObject_setUserData (my d_widget, me); my v_positionInForm (my d_widget, left, right, top, bottom, parent); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (my d_widget), (flags & GuiCheckButton_SET) != 0); if (flags & GuiCheckButton_INSENSITIVE) { my f_setSensitive (false); } g_signal_connect (G_OBJECT (my d_widget), "destroy", G_CALLBACK (_GuiGtkCheckButton_destroyCallback), me); my d_valueChangedHandlerId = g_signal_connect (GTK_TOGGLE_BUTTON (my d_widget), "toggled", G_CALLBACK (_GuiGtkCheckButton_valueChangedCallback), me); #elif cocoa #elif win my d_widget = _Gui_initializeWidget (xmToggleButtonWidgetClass, parent -> d_widget, buttonText); _GuiObject_setUserData (my d_widget, me); my d_widget -> isRadioButton = false; my d_widget -> window = CreateWindow (L"button", _GuiWin_expandAmpersands (buttonText), WS_CHILD | BS_AUTOCHECKBOX | WS_CLIPSIBLINGS, my d_widget -> x, my d_widget -> y, my d_widget -> width, my d_widget -> height, my d_widget -> parent -> window, (HMENU) 1, theGui.instance, NULL); SetWindowLongPtr (my d_widget -> window, GWLP_USERDATA, (LONG_PTR) my d_widget); SetWindowFont (my d_widget -> window, GetStockFont (ANSI_VAR_FONT), FALSE); my v_positionInForm (my d_widget, left, right, top, bottom, parent); if (flags & GuiCheckButton_SET) { Button_SetCheck (my d_widget -> window, BST_CHECKED); } if (flags & GuiCheckButton_INSENSITIVE) { my f_setSensitive (false); } #elif mac my d_widget = _Gui_initializeWidget (xmToggleButtonWidgetClass, parent -> d_widget, buttonText); _GuiObject_setUserData (my d_widget, me); my d_widget -> isRadioButton = false; CreateCheckBoxControl (my d_widget -> macWindow, & my d_widget -> rect, NULL, (flags & GuiCheckButton_SET) != 0, true, & my d_widget -> nat.control.handle); Melder_assert (my d_widget -> nat.control.handle != NULL); SetControlReference (my d_widget -> nat.control.handle, (long) my d_widget); my d_widget -> isControl = true; _GuiNativeControl_setFont (my d_widget, 0, 13); _GuiNativeControl_setTitle (my d_widget); my v_positionInForm (my d_widget, left, right, top, bottom, parent); if (flags & GuiCheckButton_INSENSITIVE) { my f_setSensitive (false); } #endif return me; }
AUCarbonViewControl::AUCarbonViewControl(AUCarbonViewBase *ownerView, AUParameterListenerRef listener, ControlType type, const CAAUParameter ¶m, ControlRef control) : mOwnerView(ownerView), mListener(listener), mType(type), mParam(param), mControl(control), mInControlInitialization(0) { #if !__LP64__ SetControlReference(control, SRefCon(this)); #endif }
wxListBox::~wxListBox() { FreeData() ; // avoid access during destruction SetControlReference( (ControlHandle) m_macControl , NULL ) ; if ( m_macList ) { #if !TARGET_CARBON DisposeHandle( (**(ListHandle)m_macList).listDefProc ) ; (**(ListHandle)m_macList).listDefProc = NULL ; #endif m_macList = NULL ; } }
static WindowRef DrawDialogTheMacOSXWay(void) { // Create a window. "DLOG:257" is the name of the window object. This name is set in // InterfaceBuilder when the resource file is imported. OSStatus status = noErr; IBNibRef nibRef; WindowRef window = NULL; static HIObjectClassRef theClass; if (theClass == NULL) { static EventTypeSpec kFactoryEvents[] = { { kEventClassHIObject, kEventHIObjectConstruct }, { kEventClassHIObject, kEventHIObjectInitialize }, { kEventClassHIObject, kEventHIObjectDestruct }, { kEventClassControl, kEventControlHitTest }, { kEventClassControl, kEventControlTrack }, { kEventClassControl, kEventControlBoundsChanged }, { kEventClassControl, kEventControlDraw } }; HIObjectRegisterSubclass(kCustomSpotViewClassID, kHIViewClassID, 0, CustomSpotViewHandler, GetEventTypeCount(kFactoryEvents), kFactoryEvents, 0, &theClass); } status = CreateNibReference(CFSTR("main"), &nibRef); require_noerr(status, CantGetNibRef); status = CreateWindowFromNib(nibRef, CFSTR("DLOG:257"), &window); require_noerr(status, CantCreateWindow); // Let's react to User's commands. EventTypeSpec eventTypeCP = {kEventClassCommand, kEventCommandProcess}; InstallEventHandler(GetWindowEventTarget(window), MacOSXDialogCommandProcess, 1, &eventTypeCP, window, NULL); // we still assign the key filter on our edit text box so that only digits can be entered HIViewID hidnst = {0, 9}; HIViewRef numEditText; HIViewFindByID(HIViewGetRoot(window), hidnst, &numEditText); ControlKeyFilterUPP keyFilter = MyEditKeyFilter; SetControlData(numEditText, kControlEntireControl, kControlEditTextKeyFilterTag, sizeof(keyFilter), &keyFilter); SetKeyboardFocus(window, numEditText, kControlFocusNextPart); // we still set the action proc for the scroll bar so that the PageUp/PageDown/Up/Down buttons work // and still associate the previous edit text box with the scroll bar so it gets updated HIViewID hidsb = {0, 14}; HIViewRef scrollBar; HIViewFindByID(HIViewGetRoot(window), hidsb, &scrollBar); SetControlAction(scrollBar, ScrollBar32BitActionProc); SetControlReference(scrollBar, (SInt32)numEditText); // Move it! MoveWindow(window, 854, 271, false); // and use the replacement for ModalDialog // one good thing is that our behaviors are no longer half-done at the dialog level // and half-done at the control level, they are all handled by the view handlers ShowWindow(window); CantCreateWindow: CantGetNibRef: return (window); }
static DialogRef DrawDialogTheMacOS8or9Way(void) { short i; ControlRef theControl; DialogRef theDialog = GetNewDialog(257, NULL, (WindowRef)-1L); if (theDialog == NULL) return(NULL); // Let's get a pulsing blue default button! GetDialogItemAsControl(theDialog, 1, &theControl); SetWindowDefaultButton(GetDialogWindow(theDialog), theControl); // Setting the check box GetDialogItemAsControl(theDialog, 2, &theControl); SetControl32BitValue(theControl, 1); // We need to autoembed our radio buttons in the radio group // so that they work automatically for (i = 4; i <= 8; i++) { GetDialogItemAsControl(theDialog, i, &theControl); AutoEmbedControl(theControl, GetDialogWindow(theDialog)); } // we assign a key filter on our edit text box so that only digits can be entered ControlRef theTextControl; ControlKeyFilterUPP keyFilter = MyEditKeyFilter; GetDialogItemAsControl(theDialog, 9, &theTextControl); SetKeyboardFocus(GetDialogWindow(theDialog), theTextControl, kControlFocusNextPart); SetControlData(theTextControl, kControlEntireControl, kControlEditTextKeyFilterTag, sizeof(keyFilter), &keyFilter); // Setting the action proc for the scroll bar so that the PageUp/PageDown/Up/Down buttons work // We also associate the previous edit text box with the scroll bar so it gets updated GetDialogItemAsControl(theDialog, 14, &theControl); SetControlAction(theControl, ScrollBar32BitActionProc); SetControl32BitMaximum(theControl, 0x7fffffff); SetControlReference(theControl, (SInt32)theTextControl); // The static text control is created as a resource but we could only set its title and // not its content. We set the content now! GetDialogItemAsControl(theDialog, 15, &theControl); Str255 theTitle; GetControlTitle(theControl, theTitle); SetControlData(theControl, kControlEntireControl, kControlStaticTextTextTag, theTitle[0], &theTitle[1]); // We set up our User Pane Control with the draw, hit test, and track (actually action) procs GetDialogItemAsControl(theDialog, 13, &theControl); Rect bounds; GetControlBounds(theControl, &bounds); gUserH = (bounds.left + bounds.right) / 2; gUserV = (bounds.top + bounds.bottom) / 2; ControlUserPaneDrawUPP userPaneDraw = MyUserPaneDrawProc; SetControlData(theControl, kControlEntireControl, kControlUserPaneDrawProcTag, sizeof(userPaneDraw), &userPaneDraw); ControlUserPaneHitTestUPP userPaneHitTest = MyUserPaneHitTestProc; SetControlData(theControl, kControlEntireControl, kControlUserPaneHitTestProcTag, sizeof(userPaneHitTest), &userPaneHitTest); SetControlAction(theControl, MoveSpotActionProc); ShowWindow(GetDialogWindow(theDialog)); return(theDialog); }
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; }
bool wxCheckListBox::Create(wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size, int n, const wxString choices[], long style, const wxValidator& validator, const wxString &name) { if ( !wxCheckListBoxBase::Create(parent, id, pos, size, n, choices, style, validator, name) ) return false; m_noItems = 0 ; // this will be increased by our append command m_selected = 0; m_checkBoxWidth = 12; m_checkBoxHeight= 10; long h = m_checkBoxHeight ; #if TARGET_CARBON GetThemeMetric(kThemeMetricCheckBoxWidth,(long *)&m_checkBoxWidth); GetThemeMetric(kThemeMetricCheckBoxHeight,&h); #endif const wxFont& font = GetFont(); FontInfo finfo; FetchFontInfo(font.GetMacFontNum(),font.GetMacFontSize(),font.GetMacFontStyle(),&finfo); m_TextBaseLineOffset= finfo.leading+finfo.ascent; m_checkBoxHeight= finfo.leading+finfo.ascent+finfo.descent; if (m_checkBoxHeight<h) { m_TextBaseLineOffset+= (h-m_checkBoxHeight)/2; m_checkBoxHeight= h; } Rect bounds ; Str255 title ; MacPreControlCreate( parent , id , wxEmptyString , pos , size ,style, validator , name , &bounds , title ) ; ListDefSpec listDef; listDef.defType = kListDefUserProcType; if ( macCheckListDefUPP == NULL ) { macCheckListDefUPP = NewListDefUPP( wxMacCheckListDefinition ); } listDef.u.userProc = macCheckListDefUPP ; #if TARGET_CARBON Size asize; CreateListBoxControl( MAC_WXHWND(parent->MacGetRootWindow()), &bounds, false, 0, 1, false, true, m_checkBoxHeight+2, 14, false, &listDef, (ControlRef *)&m_macControl ); GetControlData( (ControlHandle) m_macControl, kControlNoPart, kControlListBoxListHandleTag, sizeof(ListHandle), (Ptr) &m_macList, &asize); SetControlReference( (ControlHandle) m_macControl, (long) this); SetControlVisibility( (ControlHandle) m_macControl, false, false); #else long result ; wxStAppResource resload ; m_macControl = (WXWidget) ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false , kwxMacListWithVerticalScrollbar , 0 , 0, kControlListBoxProc , (long) this ) ; ::GetControlData( (ControlHandle) m_macControl , kControlNoPart , kControlListBoxListHandleTag , sizeof( ListHandle ) , (char*) &m_macList , &result ) ; HLock( (Handle) m_macList ) ; ldefHandle ldef ; ldef = (ldefHandle) NewHandle( sizeof(ldefRec) ) ; if ( (**(ListHandle)m_macList).listDefProc != NULL ) { (**ldef).instruction = 0x4EF9; /* JMP instruction */ (**ldef).function = (void(*)()) listDef.u.userProc; (**(ListHandle)m_macList).listDefProc = (Handle) ldef ; } Point pt = (**(ListHandle)m_macList).cellSize ; pt.v = 14 ; LCellSize( pt , (ListHandle)m_macList ) ; LAddColumn( 1 , 0 , (ListHandle)m_macList ) ; #endif OptionBits options = 0; if ( style & wxLB_MULTIPLE ) { options += lNoExtend ; } else if ( style & wxLB_EXTENDED ) { options += lExtendDrag ; } else { options = (OptionBits) lOnlyOne ; } SetListSelectionFlags((ListHandle)m_macList, options); MacPostControlCreate() ; for ( int i = 0 ; i < n ; i++ ) { Append( choices[i] ) ; } LSetDrawingMode( true , (ListHandle) m_macList ) ; return TRUE; }
bool wxListBox::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size, int n, const wxString choices[], long style, const wxValidator& validator, const wxString& name) { if ( !wxListBoxBase::Create(parent, id, pos, size, style & ~(wxHSCROLL|wxVSCROLL), validator, name) ) return false; m_noItems = 0 ; // this will be increased by our append command m_selected = 0; Rect bounds ; Str255 title ; MacPreControlCreate( parent , id , wxEmptyString , pos , size ,style, validator , name , &bounds , title ) ; ListDefSpec listDef; listDef.defType = kListDefUserProcType; if ( macListDefUPP == NULL ) { macListDefUPP = NewListDefUPP( wxMacListDefinition ); } listDef.u.userProc = macListDefUPP ; Str255 fontName ; SInt16 fontSize ; Style fontStyle ; #if TARGET_CARBON GetThemeFont(kThemeViewsFont , GetApplicationScript() , fontName , &fontSize , &fontStyle ) ; #else GetFontName( kFontIDMonaco , fontName ) ; fontSize = 9 ; fontStyle = normal ; #endif SetFont( wxFont (fontSize, wxSWISS, wxNORMAL, wxNORMAL , false , wxMacMakeStringFromPascal( fontName ) ) ) ; #if TARGET_CARBON Size asize; CreateListBoxControl( MAC_WXHWND(parent->MacGetRootWindow()), &bounds, false, 0, 1, (style & wxLB_HSCROLL), true, kwxMacListItemHeight, kwxMacListItemHeight, false, &listDef, (ControlRef *)&m_macControl ); GetControlData( (ControlHandle) m_macControl, kControlNoPart, kControlListBoxListHandleTag, sizeof(ListHandle), (Ptr) &m_macList, &asize); SetControlReference( (ControlHandle) m_macControl, (long) this); SetControlVisibility( (ControlHandle) m_macControl, false, false); #else long result ; wxStAppResource resload ; m_macControl = (WXWidget) ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false , (style & wxLB_HSCROLL) ? kwxMacListWithVerticalAndHorizontalScrollbar : kwxMacListWithVerticalScrollbar , 0 , 0, kControlListBoxProc , (long) this ) ; ::GetControlData( (ControlHandle) m_macControl , kControlNoPart , kControlListBoxListHandleTag , sizeof( ListHandle ) , (char*) &m_macList , &result ) ; HLock( (Handle) m_macList ) ; ldefHandle ldef ; ldef = (ldefHandle) NewHandle( sizeof(ldefRec) ) ; if ( (**(ListHandle)m_macList).listDefProc != NULL ) { (**ldef).instruction = 0x4EF9; /* JMP instruction */ (**ldef).function = (void(*)()) listDef.u.userProc; (**(ListHandle)m_macList).listDefProc = (Handle) ldef ; } Point pt = (**(ListHandle)m_macList).cellSize ; pt.v = kwxMacListItemHeight ; LCellSize( pt , (ListHandle)m_macList ) ; LAddColumn( 1 , 0 , (ListHandle)m_macList ) ; #endif OptionBits options = 0; if ( style & wxLB_MULTIPLE ) { options += lExtendDrag + lUseSense ; } else if ( style & wxLB_EXTENDED ) { // default behaviour } else { options = (OptionBits) lOnlyOne ; } SetListSelectionFlags((ListHandle)m_macList, options); for ( int i = 0 ; i < n ; i++ ) { Append( choices[i] ) ; } MacPostControlCreate() ; LSetDrawingMode( true , (ListHandle)m_macList ) ; return true; }
void TkpDisplayScrollbar( ClientData clientData) /* Information about window. */ { TkScrollbar *scrollPtr = (TkScrollbar *) clientData; MacScrollbar *macScrollPtr = (MacScrollbar *) clientData; Tk_Window tkwin = scrollPtr->tkwin; CGrafPtr destPort, savePort; Boolean portChanged; 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); if (macScrollPtr->sbHandle == NULL) { Rect r = {0, 0, 1, 1}; windowRef = TkMacOSXDrawableWindow(Tk_WindowId(tkwin)); CreateScrollBarControl(windowRef, &r, 0, 0, 0, 0, true, NULL, &(macScrollPtr->sbHandle)); SetControlReference(macScrollPtr->sbHandle, (SInt32) scrollPtr); if (IsWindowActive(windowRef)) { macScrollPtr->macFlags |= ACTIVE; } } /* * Update the control values before we draw. */ UpdateControlValues(macScrollPtr); /* * Set up port for drawing Macintosh control. */ destPort = TkMacOSXGetDrawablePort(Tk_WindowId(tkwin)); portChanged = QDSwapPort(destPort, &savePort); TkMacOSXSetUpClippingRgn(Tk_WindowId(tkwin)); /* * Scrollbars do not erase the complete control bounds if they are wider * than the standard width, so manually erase the extra space. */ if (!EmptyRect(&macScrollPtr->eraseRect)) { EraseRect(&macScrollPtr->eraseRect); } Draw1Control(macScrollPtr->sbHandle); if (portChanged) { QDSwapPort(savePort, NULL); } done: scrollPtr->flags &= ~REDRAW_PENDING; }
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; }