MODULE_SCOPE int TkMacOSXProcessMouseEvent(TkMacOSXEvent *eventPtr, MacEventStatus * statusPtr) { Tk_Window tkwin; Point where, where2; int result; TkDisplay * dispPtr; OSStatus err; MouseEventData mouseEventData, * medPtr = &mouseEventData; int isFrontProcess; switch (eventPtr->eKind) { case kEventMouseDown: case kEventMouseUp: case kEventMouseMoved: case kEventMouseDragged: case kEventMouseWheelMoved: break; default: return false; break; } err = ChkErr(GetEventParameter, eventPtr->eventRef, kEventParamMouseLocation, typeQDPoint, NULL, sizeof(where), NULL, &where); if (err != noErr) { GetGlobalMouse(&where); } err = ChkErr(GetEventParameter, eventPtr->eventRef, kEventParamWindowRef, typeWindowRef, NULL, sizeof(WindowRef), NULL, &medPtr->whichWin); if (err == noErr) { err = ChkErr(GetEventParameter, eventPtr->eventRef, kEventParamWindowPartCode, typeWindowPartCode, NULL, sizeof(WindowPartCode), NULL, &medPtr->windowPart); } if (err != noErr) { medPtr->windowPart = FindWindow(where, &medPtr->whichWin); } medPtr->window = TkMacOSXGetXWindow(medPtr->whichWin); if (medPtr->whichWin != NULL && medPtr->window == None) { return false; } if (eventPtr->eKind == kEventMouseDown) { if (IsWindowActive(medPtr->whichWin) && IsWindowPathSelectEvent( medPtr->whichWin, eventPtr->eventRef)) { ChkErr(WindowPathSelect, medPtr->whichWin, NULL, NULL); return false; } if (medPtr->windowPart == inProxyIcon) { TkMacOSXTrackingLoop(1); err = ChkErr(TrackWindowProxyDrag, medPtr->whichWin, where); TkMacOSXTrackingLoop(0); if (err == errUserWantsToDragWindow) { medPtr->windowPart = inDrag; } else { return false; } } } isFrontProcess = Tk_MacOSXIsAppInFront(); if (isFrontProcess) { medPtr->state = ButtonModifiers2State(GetCurrentEventButtonState(), GetCurrentEventKeyModifiers()); } else { medPtr->state = ButtonModifiers2State(GetCurrentButtonState(), GetCurrentKeyModifiers()); } medPtr->global = where; err = ChkErr(GetEventParameter, eventPtr->eventRef, kEventParamWindowMouseLocation, typeQDPoint, NULL, sizeof(Point), NULL, &medPtr->local); if (err == noErr) { if (medPtr->whichWin) { Rect widths; GetWindowStructureWidths(medPtr->whichWin, &widths); medPtr->local.h -= widths.left; medPtr->local.v -= widths.top; } } else { medPtr->local = where; if (medPtr->whichWin) { QDGlobalToLocalPoint(GetWindowPort(medPtr->whichWin), &medPtr->local); } } medPtr->activeNonFloating = ActiveNonFloatingWindow(); dispPtr = TkGetDisplayList(); tkwin = Tk_IdToWindow(dispPtr->display, medPtr->window); if (eventPtr->eKind != kEventMouseDown) { int res = false; switch (eventPtr->eKind) { case kEventMouseUp: /* * The window manager only needs to know about mouse down * events and sometimes we need to "eat" the mouse up. * Otherwise, we just pass the event to Tk. */ if (TkMacOSXGetEatButtonUp()) { TkMacOSXSetEatButtonUp(false); } else { res = GenerateButtonEvent(medPtr); } break; case kEventMouseWheelMoved: err = ChkErr(GetEventParameter, eventPtr->eventRef, kEventParamMouseWheelDelta, typeLongInteger, NULL, sizeof(long), NULL, &medPtr->delta); if (err != noErr ) { statusPtr->err = 1; } else { EventMouseWheelAxis axis; err = ChkErr(GetEventParameter, eventPtr->eventRef, kEventParamMouseWheelAxis, typeMouseWheelAxis, NULL, sizeof(EventMouseWheelAxis), NULL, &axis); if (err == noErr && axis == kEventMouseWheelAxisX) { medPtr->state |= ShiftMask; } res = GenerateMouseWheelEvent(medPtr); } break; case kEventMouseMoved: case kEventMouseDragged: res = GeneratePollingEvents(medPtr); break; default: Tcl_Panic("Unknown mouse event !"); } if (res) { statusPtr->stopProcessing = 1; } return res; } TkMacOSXSetEatButtonUp(false); if (medPtr->whichWin) { /* * We got a mouse down in a window * See if this is the activate click * This click moves the window forward. We don't want * the corresponding mouse-up to be reported to the application * or else it will mess up some Tk scripts. */ if (!(TkpIsWindowFloating(medPtr->whichWin)) && (medPtr->whichWin != medPtr->activeNonFloating || !isFrontProcess)) { int frontWindowOnly = 1; int cmdDragGrow = ((medPtr->windowPart == inDrag || medPtr->windowPart == inGrow) && medPtr->state & Mod1Mask); if (!cmdDragGrow) { Tk_Window grabWin = GetGrabWindowForWindow(tkwin); frontWindowOnly = !grabWin; if (grabWin && grabWin != tkwin) { TkMacOSXSetEatButtonUp(true); BringWindowForward(TkMacOSXDrawableWindow( ((TkWindow*)grabWin)->window), isFrontProcess, frontWindowOnly); return false; } } /* * Clicks in the titlebar widgets are handled without bringing the * window forward. */ if ((result = HandleWindowTitlebarMouseDown(medPtr, tkwin)) != -1) { statusPtr->stopProcessing = 1; return result; } else { /* * Only windows with the kWindowNoActivatesAttribute can * receive mouse events in the background. */ if (!(((TkWindow *)tkwin)->wmInfoPtr->attributes & kWindowNoActivatesAttribute)) { /* * Allow background window dragging & growing with Command * down. */ if (!cmdDragGrow) { TkMacOSXSetEatButtonUp(true); BringWindowForward(medPtr->whichWin, isFrontProcess, frontWindowOnly); } /* * Allow dragging & growing of windows that were/are in the * background. */ if (!(medPtr->windowPart == inDrag || medPtr->windowPart == inGrow)) { return false; } } } } else { if ((result = HandleWindowTitlebarMouseDown(medPtr, tkwin)) != -1) { statusPtr->stopProcessing = 1; return result; } } switch (medPtr->windowPart) { case inDrag: { WindowAttributes attributes; GetWindowAttributes(medPtr->whichWin, &attributes); if (!(attributes & kWindowAsyncDragAttribute)) { TkMacOSXTrackingLoop(1); DragWindow(medPtr->whichWin, where, NULL); TkMacOSXTrackingLoop(0); where2.h = where2.v = 0; QDLocalToGlobalPoint(GetWindowPort(medPtr->whichWin), &where2); if (EqualPt(where, where2)) { return false; } return true; } break; } case inGrow: /* * Generally the content region is the domain of Tk * sub-windows. However, one exception is the grow * region. A button down in this area will be handled * by the window manager. Note: this means that Tk * may not get button down events in this area! */ if (TkMacOSXGrowToplevel(medPtr->whichWin, where) == true) { statusPtr->stopProcessing = 1; return true; } else { return GenerateButtonEvent(medPtr); } break; case inContent: return GenerateButtonEvent(medPtr); break; default: return false; break; } } return false; }
int HandleWindowTitlebarMouseDown(MouseEventData * medPtr, Tk_Window tkwin) { int result = INT_MAX; switch (medPtr->windowPart) { case inGoAway: case inCollapseBox: case inZoomIn: case inZoomOut: case inToolbarButton: if (!IsWindowActive(medPtr->whichWin)) { WindowRef frontWindow = FrontNonFloatingWindow(); WindowModality frontWindowModality = kWindowModalityNone; if (frontWindow && frontWindow != medPtr->whichWin) { ChkErr(GetWindowModality, frontWindow, &frontWindowModality, NULL); } if (frontWindowModality == kWindowModalityAppModal) { result = 0; } } break; default: result = -1; break; } if (result == INT_MAX) { result = 0; TkMacOSXTrackingLoop(1); switch (medPtr->windowPart) { case inGoAway: if (TrackGoAway(medPtr->whichWin, medPtr->global) && tkwin) { TkGenWMDestroyEvent(tkwin); result = 1; } break; case inCollapseBox: if (TrackBox(medPtr->whichWin, medPtr->global, medPtr->windowPart) && tkwin) { TkpWmSetState((TkWindow *)tkwin, IconicState); result = 1; } break; case inZoomIn: case inZoomOut: if (TrackBox(medPtr->whichWin, medPtr->global, medPtr->windowPart)) { result = TkMacOSXZoomToplevel(medPtr->whichWin, medPtr->windowPart); } break; case inToolbarButton: if (TrackBox(medPtr->whichWin, medPtr->global, medPtr->windowPart)) { result = GenerateToolbarButtonEvent(medPtr); } break; } TkMacOSXTrackingLoop(0); } return result; }
pascal OSStatus MouseEventHandler( EventHandlerCallRef handler , EventRef event , void *data ) { OSStatus result = eventNotHandledErr ; wxTopLevelWindowMac* toplevelWindow = (wxTopLevelWindowMac*) data ; Point point ; UInt32 modifiers = 0; EventMouseButton button = 0 ; UInt32 click = 0 ; GetEventParameter( event, kEventParamMouseLocation, typeQDPoint, NULL, sizeof( Point ), NULL, &point ); GetEventParameter( event, kEventParamKeyModifiers, typeUInt32, NULL, sizeof( UInt32 ), NULL, &modifiers ); GetEventParameter( event, kEventParamMouseButton, typeMouseButton, NULL, sizeof( EventMouseButton ), NULL, &button ); GetEventParameter( event, kEventParamClickCount, typeUInt32, NULL, sizeof( UInt32 ), NULL, &click ); if ( button == 0 || GetEventKind( event ) == kEventMouseUp ) modifiers += btnState ; // temporary hack to support true two button mouse if ( button == kEventMouseButtonSecondary ) { modifiers |= controlKey ; } WindowRef window ; short windowPart = ::FindWindow(point, &window); // either we really are active or we are capturing mouse events if ( (IsWindowActive(window) && windowPart == inContent) || (wxTheApp->s_captureWindow && wxTheApp->s_captureWindow->MacGetTopLevelWindow() == toplevelWindow) ) { switch ( GetEventKind( event ) ) { case kEventMouseDown : toplevelWindow->MacFireMouseEvent( mouseDown , point.h , point.v , modifiers , EventTimeToTicks( GetEventTime( event ) ) ) ; result = noErr ; break ; case kEventMouseUp : toplevelWindow->MacFireMouseEvent( mouseUp , point.h , point.v , modifiers , EventTimeToTicks( GetEventTime( event ) ) ) ; result = noErr ; break ; case kEventMouseMoved : wxTheApp->MacHandleMouseMovedEvent( point.h , point.v , modifiers , EventTimeToTicks( GetEventTime( event ) ) ) ; result = noErr ; break ; case kEventMouseDragged : toplevelWindow->MacFireMouseEvent( nullEvent , point.h , point.v , modifiers , EventTimeToTicks( GetEventTime( event ) ) ) ; result = noErr ; break ; case kEventMouseWheelMoved : { //bClearTooltip = false; EventMouseWheelAxis axis = kEventMouseWheelAxisY; SInt32 delta = 0; Point mouseLoc = {0, 0}; if (::GetEventParameter(event, kEventParamMouseWheelAxis, typeMouseWheelAxis, NULL, sizeof(EventMouseWheelAxis), NULL, &axis) == noErr && ::GetEventParameter(event, kEventParamMouseWheelDelta, typeLongInteger, NULL, sizeof(SInt32), NULL, &delta) == noErr && ::GetEventParameter(event, kEventParamMouseLocation, typeQDPoint, NULL, sizeof(Point), NULL, &mouseLoc) == noErr) { wxMouseEvent wheelEvent(wxEVT_MOUSEWHEEL); wheelEvent.m_x = mouseLoc.h; wheelEvent.m_y = mouseLoc.v; wheelEvent.m_wheelRotation = delta; wheelEvent.m_wheelDelta = 1; wheelEvent.m_linesPerAction = 1; wxWindow* currentMouseWindow = NULL; wxWindow::MacGetWindowFromPoint(wxPoint(mouseLoc.h, mouseLoc.v), ¤tMouseWindow); if (currentMouseWindow) { currentMouseWindow->GetEventHandler()->ProcessEvent(wheelEvent); result = noErr; } } } break ; default : break ; } } return result ; }
BOOL CVisualManager::OnNcPaint (CWnd* pWnd, const CObList& lstSysButtons, CRect rectRedraw) { if (!CanDrawImage ()) { return CBCGPWinXPVisualManager::OnNcPaint (pWnd, lstSysButtons, rectRedraw); } ASSERT_VALID (pWnd); if (pWnd->GetSafeHwnd () == NULL) { return FALSE; } CWindowDC dc (pWnd); if (dc.GetSafeHdc () != NULL) { CRgn rgn; if (!rectRedraw.IsRectEmpty ()) { rgn.CreateRectRgnIndirect (rectRedraw); dc.SelectClipRgn (&rgn); } CRect rtWindow; pWnd->GetWindowRect (rtWindow); pWnd->ScreenToClient (rtWindow); CRect rtClient; pWnd->GetClientRect (rtClient); rtClient.OffsetRect (-rtWindow.TopLeft ()); dc.ExcludeClipRect (rtClient); rtWindow.OffsetRect (-rtWindow.TopLeft ()); BOOL bActive = IsWindowActive (pWnd); CRect rectCaption (rtWindow); CSize szSysBorder (GetSystemBorders ()); rectCaption.bottom = rectCaption.top + szSysBorder.cy; const DWORD dwStyle = pWnd->GetStyle (); BOOL bMaximized = (dwStyle & WS_MAXIMIZE) == WS_MAXIMIZE; const int nSysCaptionHeight = ::GetSystemMetrics (SM_CYCAPTION); rectCaption.bottom += nSysCaptionHeight; const DWORD dwStyleEx = pWnd->GetExStyle (); BOOL bDestroyIcon = FALSE; HICON hIcon = globalUtils.GetWndIcon (pWnd, &bDestroyIcon); CString strText; pWnd->GetWindowText (strText); CString strTitle (strText); CString strDocument; BOOL bPrefix = FALSE; if ((dwStyle & FWS_ADDTOTITLE) == FWS_ADDTOTITLE) { bPrefix = (dwStyle & FWS_PREFIXTITLE) == FWS_PREFIXTITLE; CFrameWnd* pFrameWnd = DYNAMIC_DOWNCAST(CFrameWnd, pWnd); if (pFrameWnd != NULL) { strTitle = pFrameWnd->GetTitle(); if (!strTitle.IsEmpty ()) { if (strText.GetLength () >= strTitle.GetLength ()) { if (bPrefix) { int pos = strText.Find (strTitle, strText.GetLength () - strTitle.GetLength ()); if (pos != -1) { strTitle = strText.Right (strTitle.GetLength () + 3); strDocument = strText.Left (strText.GetLength () - strTitle.GetLength ()); } } else { int pos = strText.Find (strTitle); if (pos != -1) { strTitle = strText.Left (strTitle.GetLength () + 3); strDocument = strText.Right (strText.GetLength () - strTitle.GetLength ()); } } } } else { strDocument = strText; } } } if (bMaximized) { rectCaption.InflateRect (szSysBorder.cx, szSysBorder.cy, szSysBorder.cx, 0); } DrawNcCaption (&dc, rectCaption, dwStyle, dwStyleEx, strTitle, strDocument, hIcon, bPrefix, bActive, FALSE, lstSysButtons); if (bDestroyIcon) { ::DestroyIcon (hIcon); } if (bMaximized) { return TRUE; } rtWindow.top = rectCaption.bottom; dc.ExcludeClipRect (rectCaption); int indexBorder = 0; int indexNavi = IsLargeNaviControl () ? 1 : 0; CRect rtPart (rtWindow); rtPart.right = rtPart.left + szSysBorder.cx; rtPart.bottom = rtPart.top + m_ctrlMainBorderExplorerL.GetParams ().m_rectImage.Height (); m_ctrlMainBorderExplorerL.Draw (&dc, rtPart, indexBorder); rtPart.top = rtPart.bottom; rtPart.bottom = rtWindow.bottom - (m_ctrlMainBorderNaviL[indexNavi].GetParams ().m_rectImage.Height () + m_ctrlMainBorderNaviB[indexNavi].GetParams ().m_rectImage.Height ()); m_ctrlMainBorderL.Draw (&dc, rtPart, indexBorder); rtPart.top = rtPart.bottom; rtPart.bottom = rtWindow.bottom - m_ctrlMainBorderNaviB[indexNavi].GetParams ().m_rectImage.Height (); m_ctrlMainBorderNaviL[indexNavi].Draw (&dc, rtPart, indexBorder); rtPart = rtWindow; rtPart.left = rtPart.right - szSysBorder.cx; rtPart.bottom = rtPart.top + m_ctrlMainBorderExplorerR.GetParams ().m_rectImage.Height (); m_ctrlMainBorderExplorerR.Draw (&dc, rtPart, indexBorder); rtPart.top = rtPart.bottom; rtPart.bottom = rtWindow.bottom - (m_ctrlMainBorderNaviR[indexNavi].GetParams ().m_rectImage.Height () + m_ctrlMainBorderNaviB[indexNavi].GetParams ().m_rectImage.Height ()); m_ctrlMainBorderR.Draw (&dc, rtPart, indexBorder); rtPart.top = rtPart.bottom; rtPart.bottom = rtWindow.bottom - m_ctrlMainBorderNaviB[indexNavi].GetParams ().m_rectImage.Height (); m_ctrlMainBorderNaviR[indexNavi].Draw (&dc, rtPart, indexBorder); rtPart = rtWindow; rtPart.top = rtPart.bottom - m_ctrlMainBorderNaviB[indexNavi].GetParams ().m_rectImage.Height (); m_ctrlMainBorderNaviB[indexNavi].Draw (&dc, rtPart, indexBorder); if (indexNavi == 1) { m_ctrlMainBorderNaviBCtrl.DrawEx (&dc, rtPart, 0, CBCGPToolBarImages::ImageAlignHorzCenter, CBCGPToolBarImages::ImageAlignVertBottom); } dc.SelectClipRgn (NULL); return TRUE; } return CBCGPWinXPVisualManager::OnNcPaint (pWnd, lstSysButtons, rectRedraw); }
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; }
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; }
static int TkMacOSXInitControl( MacButton *mbPtr, /* Mac button. */ GWorldPtr destPort, GC gc, Pixmap pixmap, Rect *paneRect, Rect *cntrRect) { TkButton *butPtr = (TkButton *) mbPtr; ControlRef rootControl; SInt16 procID, initialValue, minValue, maxValue; Boolean initiallyVisible; SInt32 controlReference; rootControl = TkMacOSXGetRootControl(Tk_WindowId(butPtr->tkwin)); mbPtr->windowRef = TkMacOSXDrawableWindow(Tk_WindowId(butPtr->tkwin)); /* * Set up the user pane. */ initiallyVisible = false; initialValue = kControlSupportsEmbedding|kControlHasSpecialBackground; minValue = 0; maxValue = 1; procID = kControlUserPaneProc; controlReference = (SInt32)mbPtr; mbPtr->userPane = NewControl(mbPtr->windowRef, paneRect, "\p", initiallyVisible, initialValue, minValue, maxValue, procID, controlReference); if (!mbPtr->userPane) { TkMacOSXDbgMsg("Failed to create user pane control"); return 1; } if (ChkErr(EmbedControl, mbPtr->userPane,rootControl) != noErr) { return 1; } SetUserPaneSetUpSpecialBackgroundProc(mbPtr->userPane, UserPaneBackgroundProc); SetUserPaneDrawProc(mbPtr->userPane,UserPaneDraw); initiallyVisible = false; TkMacOSXComputeControlParams(butPtr,&mbPtr->params); mbPtr->control = NewControl(mbPtr->windowRef, cntrRect, "\p", initiallyVisible, mbPtr->params.initialValue, mbPtr->params.minValue, mbPtr->params.maxValue, mbPtr->params.procID, controlReference); if (!mbPtr->control) { TkMacOSXDbgMsg("Failed to create control of type %d\n", procID); return 1; } if (ChkErr(EmbedControl, mbPtr->control,mbPtr->userPane) != noErr ) { return 1; } mbPtr->flags |= (CONTROL_INITIALIZED | FIRST_DRAW); if (IsWindowActive(mbPtr->windowRef)) { mbPtr->flags |= ACTIVE; } return 0; }