? 1678582 ? ChangeLog-mega Index: ChangeLog =================================================================== RCS file: /cvsroot/tktoolkit/tk/ChangeLog,v retrieving revision 1.1591 diff -u -p -r1.1591 ChangeLog --- ChangeLog 21 Mar 2007 20:06:40 -0000 1.1591 +++ ChangeLog 27 Mar 2007 00:55:08 -0000 @@ -1,3 +1,297 @@ +2007-03-27 Daniel Steffen + + * generic/tkCanvas.c: allow -selectforeground option to be None; add + * generic/tkCanvText.c: fallback to fgColor when selFgColor is None + * generic/tkEntry.c: (new default on aqua to match native L&F). + * generic/tkListbox.c: + * generic/tkText.c: + + * generic/tkCanvas.c: add support for bypassing all of Tk's double + * generic/tkEntry.c: buffered drawing into intermediate pixmaps + * generic/tkFrame.c: (via TK_NO_DOUBLE_BUFFERING #define), it is + * generic/tkListbox.c: unnecessary & wasteful on aqua where all + * generic/tkPanedWindow.c: drawing is already double-buffered by the + * generic/tkTextDisp.c: window server. (Use of this on other + * generic/ttk/ttkWidget.c: platforms would only require implementation + * macosx/tkMacOSXPort.h: of TkpClipDrawableToRect()). + * unix/tkUnixScale.c: + + * library/bgerror.tcl: on aqua, use moveable alert resp. modal dialog + * library/dialog.tcl: window class and corresponding system + background pattern; fix button padding. + + * library/tearoff.tcl: correct aqua menu bar height. + * library/tk.tcl: + + * library/demos/goldberg.tcl: fix overwriting of widget demo global. + + * library/demos/menu.tcl: on aqua, use custom MDEF and tearoffs; + * library/demos/menubu.tcl: correct menubutton toplevel name. + + * library/demos/puzzle.tcl: fix button size & padding for aqua. + * library/demos/radio.tcl: + + * macosx/tkMacOSXCarbonEvents.c: add window event target carbon event + * macosx/tkMacOSXEvent.c: handler for all kEventClassWindow and + * macosx/tkMacOSXEvent.h: kEventClassMouse events; handle + * macosx/tkMacOSXNotify.c: additional menu carbon events to + * macosx/tkMacOSXWindowEvent.c: support <> in menus that + are not using the custom MDEF [Bug 1620826], and to clear the current + Tk active menu entry upon carbon menu opening; move all remaining + events except for kEventClassKeyboard from dispatcher to application + event handler; pass event handler callRef downstream; fix debug event + tracing for Tiger; process all tcl event types in carbon event timer; + delay carbon event timer first fire; add TkMacOSXTrackingLoop() to mark + enter/exit of event tracking loop during which all tcl events but only + carbon update events should be processed by the timer (replaces various + calls to Tcl_SetServiceMode()); rename TkMacOSXReceiveAndProcessEvent() + to TkMacOSXReceiveAndDispatchEvent(), move it from tkMacOSXEvent.c to + tkMacOSXCarbonEvents.c and modify it to dequeue only update events + during a tracking loop; add TkMacOSXRunTclEventLoop() to standardize + the various ways in use to run the tcl event loop; add handling of + kEventClassAppearance events (for ScrollBarVariantChanged event). + + * macosx/tkMacOSXDialog.c: use new TkMacOSXTrackingLoop() around + * macosx/tkMacOSXEvent.c: blocking API that puts up modal dialogs + * macosx/tkMacOSXMenu.c: or when entering/exiting menu/control + * macosx/tkMacOSXMouseEvent.c: tracking, window dragging and other + * macosx/tkMacOSXScale.c: mouse tracking loops. + * macosx/tkMacOSXScrlbr.c: + * macosx/tkMacOSXWindowEvent.c: + * macosx/tkMacOSXWm.c: + + * macosx/tkMacOSXDialog.c: use new TkMacOSXRunTclEventLoop() + * macosx/tkMacOSXScale.c: instead of Tcl_DoOneEvent(), + * macosx/tkMacOSXScrlbr.c: Tcl_ServiceAll(), TclServiceIdle() + * macosx/tkMacOSXWindowEvent.c: and Tcl_GlobalEval("update idletasks"). + + * macosx/tkMacOSXColor.c: make available as Tk system colors all + * macosx/tkMacOSXPort.h: appearance manager brushes, text colors and + backgrounds with new and legacy names, as well as the fully transparent + color "systemTransparent"; add TkMacOSXSetColorIn{Port,Context}() to + directly set an X pixel color value in the current QD port resp. the + given CG context without requiring passage through rgb representation + (lossy for most system colors); modernize/remove Classic-era code; + replace crufty strcmp() elseifs by Tcl_GetIndexFromObjStruct(). + + * macosx/tkMacOSXButton.c: use new TkMacOSXSetColorInPort() + * macosx/tkMacOSXDraw.c: instead of setting rgb color directly + * macosx/tkMacOSXMenubutton.c: to allow for non-rgb system colors. + + * macosx/tkMacOSXCursor.c: implement "none" cursor as on other + platforms [Patch 1615427]; add all missing appearance manager cursors. + + * macosx/tkMacOSXDefault.h: set SELECT_FG_COLORs to None to match aqua + L&F; use standard system color names; use new 'menu' system font; + correct default scrollbar width. + + * macosx/tkMacOSXDraw.c: standardize initialization, use and + * macosx/tkMacOSXInt.h: emptying of various static temp rgns + * macosx/tkMacOSXRegion.c: onto two global RgnHandles; in debug + * macosx/tkMacOSXSubwindows.c: builds, verify emptiness of these temp + * macosx/tkMacOSXWindowEvent.c: rgns before use. + + * macosx/tkMacOSXDraw.c: add TkMacOSX{Setup,Restore}DrawingContext() to + * macosx/tkMacOSXInt.h: abstract common setup & teardown of drawing + environment (for both CG and QD); save/restore QD theme drawing state; + handle GC clip region; add TkpClipDrawableToRect() to allow clipped + drawing into drawable regardless of GC used; use new system color + "systemWindowHeaderBackground" to setup background in themed toplevels; + correct implementation of TkMacOSXMakeStippleMap(). + + * macosx/tkMacOSXEntry.c: use new TkMacOSXSetupDrawingContext() and + * macosx/tkMacOSXFont.c: TkMacOSXRestoreDrawingContext() instead of + * macosx/ttkMacOSXTheme.c: various setup/teardown procs like + TkMacOSX{SetUp,Release}CGContext(), TkMacOSXQuarz{Start,End}Draw(), + TkMacOSXSetUpGraphicsPort() etc. + + * macosx/tkMacOSXEmbed.c: add CG context and drawable clip rgn fields + * macosx/tkMacOSXInt.h: to MacDrawable struct. + * macosx/tkMacOSXSubwindows.c: + + * macosx/tkMacOSXDialog.c: make -parent option of tk_getOpenFile et al. + use the sheet version of NavServices dialogs; ensure native parent win + exists before using StandardSheet API for tk_messageBox [Bug 1677611]; + force sheets to behave like app-modal dialogs via WindowModality() API; + use more modern ColorPicker API. + + * macosx/tkAboutDlg.r: use themed movable modal dialog, fix (c) year. + + * macosx/tkMacOSXEntry.c: take xOff/yOff of MacDrawable into account + * macosx/ttkMacOSXTheme.c: when computing locations/bounds to ensure + correct posititioning when not drawing into intermediate pixmap. + + * macosx/tkMacOSXFont.c: use appearance manager API to map system font + * macosx/tkMacOSXFont.h: names to TkFonts; add "menu" system font for + menu item text drawing from MDEF; always draw with CG; remove QD + dependent stippling algorithm; move most header declarations into the + source file (as they were not used anywhere else). + + * macosx/tkMacOSXMenu.c: large scale rewrite of custom + * macosx/tkMacOSXMenu.r (removed): MDEF and tearoff-menu code; + * macosx/Wish.xcodeproj/project.pbxproj: use Appearance Mgr & ThemeText + * unix/Makefile.in: APIs to mimic native MDEF as + closely as possible when default "menu" system font is used; remove + obsolete SICN drawing code and corresponding resources. + + * macosx/tkMacOSXMouseEvent.c: add support for async window dragging by + the window server and make it the default. + + * macosx/tkMacOSXMouseEvent.c: rationalized handling order of + non-mousedown events; add TkMacOSXModifierState() to retrieve the + current key modifiers in carbon format. + + * macosx/tkMacOSXScrlbr.c: use appearance manager API to retrieve + scrollbar component metrics; add awareness of multiple possibilites for + scrollbar arrow position in aqua and handle user changes to arrow + position pref; handle difference in metrics of small & large scrollbar + variants; handle aqua "jump to here" scrollbar behaviour; correct + computation of scroll view size and position; enforce min scrollbar + height to avoid scrollbar component overlap; erase scrollbar area + outside of standard width; remove broken auto-adjust code; account for + window class when leaving space for grow box; remove code to manually + draw grow box; use modern API for thumb scroll proc; replace + HiliteControl() by modern API; replace control mgr constants with + appearance mgr equivalents. + + * macosx/tkMacOSXSubwindows.c: use SetWindowBounds() API instead of + SizeWindow(); remove unnecessary calls to TkMacOSXInvalClipRgns() and + unnecessary setting of QD port; use native-endian pixmap on intel; + remove obsolete pixmap pixel locking. + + * macosx/tkMacOSXWindowEvent.c: handle only the first of a batch of + kEventAppAvailableWindowBoundsChanged events sent per transaction; + handle kEventWindowBoundsChanged event to support live window resizing + and centralized sending of location/size changed ConfigureNotify + events; ensure HIGrowBox is redrawn after bounds change; constrain + window after dragging to ensure titlebar is not inacessible + offscreen or under dock/menubar; handle kEventWindowGetRegion and + kEventWindowDrawContent for transparent windows to mark resp. paint + content region as transparent; handle kEventWindowConstrain for + fullscreen windows to ensure bounds match new screen size; enter/exit + fullscreen UIMode upon activation/deactivation of fullscreen window. + + * macosx/tkMacOSXWm.c: use live-resize and async-drag carbon window + * macosx/tkMacOSXWm.h: attributes for toplevels by default; implement + new [wm attributes] -topmost, -transparent and -fullscreen; refactor + WmAttributesCmd() parallelling the tkUnixWm.c implementation, use thus + factored proc to set proxy icon from [wm iconbitmap]; dynamically + determine default values for toplevel min and max sizes (similar to + tkWinWm.c impl): min sizes depend on window class & attributes to + ensure visibility of all titlebar widgets and grow box, max sizes + depend on maximal window bounds for all active displays; factor out + code that puts into effect changes to master or override_redirect; use + RepositionWindow() API to determine staggered initial window bounds; + correct resize limit calculations, handle gridding and use modern + resize API in TkMacOSXGrowToplevel(); remove sending of ConfigureNotify + after resize or zoom (now handled by BoundsChanged handler); correct + composite carbon window attribute handling, remove currently unusable + attributes and add new attributes in [tk::unsupported::MacWindowStyle]; + ensure validity of window class and attributes before use; apply + changes to window class when handling carbon window attribute changes + (if HIWindowChangeClass() API available); add debug build warning + message when deprecated window style is used instead of window class; + use transparent HIGrowBox for resizable windows; avoid unnecessary + calls to window structure width API; use tcl time API in TkpGetMS(); + add TkMacOSXEnterExitFullscreen() to enter/exit UIMode with dock and + menubar hidden; restrict wmTracing output to debug builds; remove + unnecessary calls to TkMacOSXInvalClipRgns() and unnecessary setting of + QD port. + + * macosx/tkMacOSXXStubs.c (TkMacOSXDisplayChanged): add maximal window + bounds field to Screen record (in ext_data), computed as the union of + available window positioning bounds of all graphics devices (displays). + + * macosx/tkMacOSXBitmap.c: fix macRoman encoding leak. + * macosx/tkMacOSXCursor.c: + + * macosx/tkMacOSXDebug.c (TkMacOSXCarbonEventToAscii): use static + * macosx/tkMacOSXDebug.h: buffer to simplify callers; const fixes. + + * macosx/tkMacOSXBitmap.c: use more efficient QDSwapPort() instead of + * macosx/tkMacOSXButton.c: GetPort()/SetPort()/GetGWorld()/SetGWorld(). + * macosx/tkMacOSXDraw.c: + * macosx/tkMacOSXMenubutton.c: + * macosx/tkMacOSXScale.c: + * macosx/tkMacOSXScrlbr.c: + * macosx/tkMacOSXXStubs.c: + + * macosx/tkMacOSXColor.c: use kHIToolboxVersionNumber for runtime OS + * macosx/tkMacOSXEntry.c: version check rather than Gestalt() etc. + * macosx/tkMacOSXInt.h: + * macosx/tkMacOSXWm.c: + + * macosx/tkMacOSXDraw.c: remove obsolete and now incorrect + * macosx/tkMacOSXInt.h: tkMenuCascadeRgn clipping code. + * macosx/tkMacOSXMenu.c: + + * macosx/tkMacOSXHLEvents.c: replace Tcl_GlobalEval() resp. Tcl_Eval() + * macosx/tkMacOSXScrlbr.c: by Tcl_EvalEx(). + * macosx/tkMacOSXInit.c: + + * macosx/tkMacOSXInit.c (TkpInit): reorder initialization steps. + + * macosx/tkMacOSXKeyEvent.c: remove pre-10.2 support. + + * macosx/tkMacOSXMenus.c: remove now useless call to + TkMacOSXHandleTearoffMenu(); use \x.. quoting for non-latin1 macroman + literar chars to allow file to be edited as utf-8. + + * macosx/tkMacOSXScale.c: replace TrackControl() by modern + * macosx/tkMacOSXScrlbr.c: HandleControlClick() API (using new + TkMacOSXModifierState()). + + * macosx/tkMacOSXSend.c: remove duplicate/unused declarations. + * macosx/tkMacOSXXStubs.c: + + * macosx/Wish-Common.xcconfig: enable more warnings. + + * macosx/tkMacOSXDebug.c: const fixes. + * macosx/tkMacOSXInit.c: + * macosx/tkMacOSXWm.c: + * macosx/tkMacOSXXStubs.c: + + * macosx/tkMacOSXInt.h: move all constant #defines needed to + * macosx/tkMacOSXColor.c: support building on older OS X releases + * macosx/tkMacOSXEvent.h: to a central location in tkMacOSXInt.h. + * macosx/tkMacOSXFont.c: + * macosx/tkMacOSXMenu.c: + * macosx/tkMacOSXMenubutton.c: + * macosx/tkMacOSXMenus.c: + * macosx/tkMacOSXMouseEvent.c: + * macosx/tkMacOSXWm.c: + * macosx/ttkMacOSXTheme.c: + + * macosx/tkMacOSXInt.h: add ChkErr() macro to factor out + * macosx/tkMacOSXButton.c: Carbon OSStatus return value checking + * macosx/tkMacOSXCarbonEvents.c: and TkMacOSXDbgMsg() macro to factour + * macosx/tkMacOSXClipboard.c: out debug message output; use these + * macosx/tkMacOSXColor.c: macros to replace #ifdef TK_MAC_DEBUG + * macosx/tkMacOSXCursor.c: blocks & direct printing to stderr, + * macosx/tkMacOSXDebug.c: and to do additional OSStatus return + * macosx/tkMacOSXDialog.c: checking, and to standardize OSStatus + * macosx/tkMacOSXDraw.c: usage. + * macosx/tkMacOSXEntry.c: + * macosx/tkMacOSXEvent.c: + * macosx/tkMacOSXFont.c: + * macosx/tkMacOSXHLEvents.c: + * macosx/tkMacOSXInit.c: + * macosx/tkMacOSXKeyEvent.c: + * macosx/tkMacOSXMenu.c: + * macosx/tkMacOSXMenubutton.c: + * macosx/tkMacOSXMenus.c: + * macosx/tkMacOSXMouseEvent.c: + * macosx/tkMacOSXScrlbr.c: + * macosx/tkMacOSXSubwindows.c: + * macosx/tkMacOSXWindowEvent.c: + * macosx/tkMacOSXWm.c: + * macosx/tkMacOSXXStubs.c: + + * doc/colors.n: document new Mac OS X system colors. + * doc/cursors.n: document new Mac OS X native cursors. + * doc/font.n: document new Mac OS X 'menu' system font. + * doc/wm.n: document new Mac OS X [wm attributes]. + 2007-03-21 Joe English * generic/ttk/ttkLayout.c(Ttk_BuildLayoutTemplate): BUGFIX: Index: doc/canvas.n =================================================================== RCS file: /cvsroot/tktoolkit/tk/doc/canvas.n,v retrieving revision 1.22 diff -u -p -r1.22 canvas.n --- doc/canvas.n 7 Mar 2006 22:30:55 -0000 1.22 +++ doc/canvas.n 27 Mar 2007 00:55:08 -0000 @@ -1414,7 +1414,7 @@ should also be drawn as a curve but wher such that the first coordinate pair (and every third coordinate pair thereafter) is a knot point on a cubic Bezier curve, and the other coordinates are control points on the cubic Bezier curve. Straight -line segments can be venerated within a curve by making control points +line segments can be generated within a curve by making control points equal to their neighbouring knot points. If the last point is a control point and not a knot point, the point is repeated (one or two times) so that it also becomes a knot point. Index: doc/colors.n =================================================================== RCS file: /cvsroot/tktoolkit/tk/doc/colors.n,v retrieving revision 1.5 diff -u -p -r1.5 colors.n --- doc/colors.n 16 Nov 2006 13:50:17 -0000 1.5 +++ doc/colors.n 27 Mar 2007 00:55:08 -0000 @@ -1,6 +1,7 @@ '\" '\" Copyright (c) 1998-2000 by Scriptics Corporation. '\" Copyright (c) 2003 ActiveState Corporation. +'\" Copyright (c) 2006-2007 Daniel A. Steffen '\" '\" RCS: @(#) $Id: colors.n,v 1.5 2006/11/16 13:50:17 dkf Exp $ '\" @@ -778,6 +779,153 @@ yellow3 205 205 yellow4 139 139 0 YellowGreen 154 205 50 .CE + +.SH "PORTABILITY ISSUES" + +.TP +\fBMac OS X\fR +On Mac OS X, the following additional system colors are available +(note that the actual color values depend on the currently active OS theme, +and typically many of these will in fact be patterns rather than pure colors): +.RS +.CS +systemTransparent +systemBlack +systemWhite +systemHighlight +systemPrimaryHighlightColor +systemHighlightSecondary +systemSecondaryHighlightColor +systemHighlightAlternate +systemAlternatePrimaryHighlightColor +systemHighlightText +systemDialogBackgroundActive +systemDialogBackgroundInactive +systemAlertBackgroundActive +systemAlertBackgroundInactive +systemModelessDialogBackgroundActive +systemModelessDialogBackgroundInactive +systemUtilityWindowBackgroundActive +systemUtilityWindowBackgroundInactive +systemListViewSortColumnBackground +systemListViewBackground +systemIconLabelBackground +systemListViewSeparator +systemChasingArrows +systemDragHilite +systemWindowBody +systemDocumentWindowBackground +systemFinderWindowBackground +systemScrollBarDelimiterActive +systemScrollBarDelimiterInactive +systemFocusHighlight +systemPopupArrowActive +systemPopupArrowPressed +systemPopupArrowInactive +systemAppleGuideCoachmark +systemIconLabelBackgroundSelected +systemStaticAreaFill +systemActiveAreaFill +systemButtonFrame +systemButtonFrameActive +systemButtonFrameInactive +systemButtonFace +systemButtonFaceActive +systemButtonFaceInactive +systemButtonFacePressed +systemButtonActiveDarkShadow +systemButtonActiveDarkHighlight +systemButtonActiveLightShadow +systemButtonActiveLightHighlight +systemButtonInactiveDarkShadow +systemButtonInactiveDarkHighlight +systemButtonInactiveLightShadow +systemButtonInactiveLightHighlight +systemButtonPressedDarkShadow +systemButtonPressedDarkHighlight +systemButtonPressedLightShadow +systemButtonPressedLightHighlight +systemBevelActiveLight +systemBevelActiveDark +systemBevelInactiveLight +systemBevelInactiveDark +systemNotificationWindowBackground +systemMovableModalBackground +systemSheetBackground +systemSheetBackgroundOpaque +systemDrawerBackground +systemToolbarBackground +systemSheetBackgroundTransparent +systemMenu +systemMenuBackground +systemMenuActive +systemMenuBackgroundSelected +systemListViewOddRowBackground +systemListViewEvenRowBackground +systemListViewColumnDivider +systemTabPaneBackground +systemPlacardBackground +systemWindowHeaderBackground +systemListViewWindowHeaderBackground +systemSecondaryGroupBoxBackground +systemMetalBackground +systemBlackText +systemWhiteText +systemDialogActiveText +systemDialogInactiveText +systemAlertActiveText +systemAlertInactiveText +systemModelessDialogActiveText +systemModelessDialogInactiveText +systemWindowHeaderActiveText +systemWindowHeaderInactiveText +systemPlacardActiveText +systemPlacardInactiveText +systemPlacardPressedText +systemButtonText +systemPushButtonActiveText +systemPushButtonInactiveText +systemPushButtonPressedText +systemBevelButtonActiveText +systemBevelButtonInactiveText +systemBevelButtonPressedText +systemPopupButtonActiveText +systemPopupButtonInactiveText +systemPopupButtonPressedText +systemIconLabelText +systemListViewText +systemDocumentWindowTitleActiveText +systemDocumentWindowTitleInactiveText +systemMovableModalWindowTitleActiveText +systemMovableModalWindowTitleInactiveText +systemUtilityWindowTitleActiveText +systemUtilityWindowTitleInactiveText +systemPopupWindowTitleActiveText +systemPopupWindowTitleInactiveText +systemRootMenuActiveText +systemRootMenuSelectedText +systemRootMenuDisabledText +systemMenuText +systemMenuItemActiveText +systemMenuActiveText +systemMenuItemSelectedText +systemMenuDisabled +systemMenuItemDisabledText +systemPopupLabelActiveText +systemPopupLabelInactiveText +systemTabFrontActiveText +systemTabNonFrontActiveText +systemTabNonFrontPressedText +systemTabFrontInactiveText +systemTabNonFrontInactiveText +systemIconLabelSelectedText +systemBevelButtonStickyActiveText +systemBevelButtonStickyInactiveText +systemNotificationText +systemSystemDetailText +.CE +.RE + .SH "SEE ALSO" options(n), Tk_GetColor(3) .SH KEYWORDS Index: doc/cursors.n =================================================================== RCS file: /cvsroot/tktoolkit/tk/doc/cursors.n,v retrieving revision 1.4 diff -u -p -r1.4 cursors.n --- doc/cursors.n 17 Dec 2006 00:43:06 -0000 1.4 +++ doc/cursors.n 27 Mar 2007 00:55:08 -0000 @@ -2,6 +2,8 @@ '\" Copyright (c) 1998-2000 by Scriptics Corporation. '\" All rights reserved. '\" +'\" Copyright (c) 2006-2007 Daniel A. Steffen +'\" '\" RCS: @(#) $Id: cursors.n,v 1.4 2006/12/17 00:43:06 mdejong Exp $ '\" '\" @@ -135,8 +137,8 @@ wait .RE .TP -\fBMacintosh\fR -On Macintosh systems, the following cursors are mapped to native cursors: +\fBMac OS X\fR +On Mac OS X systems, the following cursors are mapped to native cursors: .RS .CS arrow @@ -148,10 +150,28 @@ plus watch xterm .CE -And the following additional cursors are available: +And the following additional native cursors are available: .CS +copyarrow +aliasarrow +contextualmenuarrow text cross-hair +closedhand +openhand +pointinghand +resizeleft +resizeright +resizeleftright +resizeup +resizedown +resizeupdown +notallowed +poof +countinguphand +countingdownhand +countingupanddownhand +spinning .CE .RE Index: doc/font.n =================================================================== RCS file: /cvsroot/tktoolkit/tk/doc/font.n,v retrieving revision 1.9 diff -u -p -r1.9 font.n --- doc/font.n 1 Dec 2006 20:14:23 -0000 1.9 +++ doc/font.n 27 Mar 2007 00:55:09 -0000 @@ -1,5 +1,6 @@ '\" '\" Copyright (c) 1996 Sun Microsystems, Inc. +'\" Copyright (c) 2006-2007 Daniel A. Steffen '\" '\" See the file "license.terms" for information on usage and redistribution '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. @@ -274,10 +275,10 @@ MS Windows: systemfixed ansifixed oemfixed\fR .DE .TP -Macintosh: +Mac OS X: .DS .ta 3c 6c -\fBsystem application\fR +\fBsystem application menu\fR .DE .RE .SH EXAMPLE Index: doc/wm.n =================================================================== RCS file: /cvsroot/tktoolkit/tk/doc/wm.n,v retrieving revision 1.28 diff -u -p -r1.28 wm.n --- doc/wm.n 1 Dec 2006 19:48:00 -0000 1.28 +++ doc/wm.n 27 Mar 2007 00:55:09 -0000 @@ -105,6 +105,18 @@ can be dragged and dropped in lieu of th Specifies the alpha transparency level of the window. It accepts a value from \fB0.0\fR (fully transparent) to \fB1.0\fR (opaque), values outside that range will be constrained. +.TP +\fB\-topmost\fR +Specifies whether this is a topmost window (displays above all other windows). +.TP +\fB\-transparent\fR +Makes the window content area transparent and turns off the window shadow. For +the transparency to be effecive, the toplevel background needs to be set to a +color with some alpha, e.g. "systemTransparent". +.TP +\fB\-fullscreen\fR +Places the window in a mode that takes up the entire main screen and hides +the dock and menu bar. .RE .PP On X11, the following attributes may be set. Index: generic/tkCanvText.c =================================================================== RCS file: /cvsroot/tktoolkit/tk/generic/tkCanvText.c,v retrieving revision 1.23 diff -u -p -r1.23 tkCanvText.c --- generic/tkCanvText.c 13 Feb 2007 11:29:17 -0000 1.23 +++ generic/tkCanvText.c 27 Mar 2007 00:55:09 -0000 @@ -465,7 +465,9 @@ ConfigureText( gcValues.fill_style = FillStippled; mask |= GCStipple|GCFillStyle; } - gcValues.foreground = textInfoPtr->selFgColorPtr->pixel; + if (textInfoPtr->selFgColorPtr != NULL) { + gcValues.foreground = textInfoPtr->selFgColorPtr->pixel; + } newSelGC = Tk_GetGC(tkwin, mask|GCForeground, &gcValues); } if (textPtr->gc != None) { Index: generic/tkCanvas.c =================================================================== RCS file: /cvsroot/tktoolkit/tk/generic/tkCanvas.c,v retrieving revision 1.40 diff -u -p -r1.40 tkCanvas.c --- generic/tkCanvas.c 27 Nov 2005 02:36:13 -0000 1.40 +++ generic/tkCanvas.c 27 Mar 2007 00:55:09 -0000 @@ -21,6 +21,11 @@ #include "tkInt.h" #include "tkPort.h" #include "tkCanvas.h" +#ifdef TK_NO_DOUBLE_BUFFERING +#ifdef MAC_OSX_TK +#include "tkMacOSXInt.h" +#endif +#endif /* TK_NO_DOUBLE_BUFFERING */ /* * See tkCanvas.h for key data structures used to implement canvases. @@ -177,10 +182,10 @@ static Tk_ConfigSpec configSpecs[] = { TK_CONFIG_MONO_ONLY}, {TK_CONFIG_COLOR, "-selectforeground", "selectForeground", "Background", DEF_CANVAS_SELECT_FG_COLOR, Tk_Offset(TkCanvas, textInfo.selFgColorPtr), - TK_CONFIG_COLOR_ONLY}, + TK_CONFIG_COLOR_ONLY|TK_CONFIG_NULL_OK}, {TK_CONFIG_COLOR, "-selectforeground", "selectForeground", "Background", DEF_CANVAS_SELECT_FG_MONO, Tk_Offset(TkCanvas, textInfo.selFgColorPtr), - TK_CONFIG_MONO_ONLY}, + TK_CONFIG_MONO_ONLY|TK_CONFIG_NULL_OK}, {TK_CONFIG_CUSTOM, "-state", "state", "State", "normal", Tk_Offset(TkCanvas, canvas_state), TK_CONFIG_DONT_SET_DEFAULT, &stateOption}, @@ -2132,6 +2137,10 @@ DisplayCanvas( goto borders; } + width = screenX2 - screenX1; + height = screenY2 - screenY1; + +#ifndef TK_NO_DOUBLE_BUFFERING /* * Redrawing is done in a temporary pixmap that is allocated here and * freed at the end of the function. All drawing is done to the @@ -2166,14 +2175,19 @@ DisplayCanvas( (screenX2 + 30 - canvasPtr->drawableXOrigin), (screenY2 + 30 - canvasPtr->drawableYOrigin), Tk_Depth(tkwin)); +#else + canvasPtr->drawableXOrigin = canvasPtr->xOrigin; + canvasPtr->drawableYOrigin = canvasPtr->yOrigin; + pixmap = Tk_WindowId(tkwin); + TkpClipDrawableToRect(Tk_Display(tkwin), pixmap, + screenX1 - canvasPtr->xOrigin, screenY1 - canvasPtr->yOrigin, + width, height); +#endif /* TK_NO_DOUBLE_BUFFERING */ /* * Clear the area to be redrawn. */ - width = screenX2 - screenX1; - height = screenY2 - screenY1; - XFillRectangle(Tk_Display(tkwin), pixmap, canvasPtr->pixmapGC, screenX1 - canvasPtr->drawableXOrigin, screenY1 - canvasPtr->drawableYOrigin, (unsigned int) width, @@ -2211,6 +2225,7 @@ DisplayCanvas( height); } +#ifndef TK_NO_DOUBLE_BUFFERING /* * Copy from the temporary pixmap to the screen, then free up the * temporary pixmap. @@ -2220,10 +2235,12 @@ DisplayCanvas( canvasPtr->pixmapGC, screenX1 - canvasPtr->drawableXOrigin, screenY1 - canvasPtr->drawableYOrigin, - (unsigned) (screenX2 - screenX1), - (unsigned) (screenY2 - screenY1), + (unsigned int) width, (unsigned int) height, screenX1 - canvasPtr->xOrigin, screenY1 - canvasPtr->yOrigin); Tk_FreePixmap(Tk_Display(tkwin), pixmap); +#else + TkpClipDrawableToRect(Tk_Display(tkwin), pixmap, 0, 0, -1, -1); +#endif /* TK_NO_DOUBLE_BUFFERING */ } /* Index: generic/tkEntry.c =================================================================== RCS file: /cvsroot/tktoolkit/tk/generic/tkEntry.c,v retrieving revision 1.42 diff -u -p -r1.42 tkEntry.c --- generic/tkEntry.c 3 Jan 2007 05:06:26 -0000 1.42 +++ generic/tkEntry.c 27 Mar 2007 00:55:14 -0000 @@ -135,7 +135,7 @@ static const Tk_OptionSpec entryOptSpec[ 0, (ClientData) DEF_ENTRY_SELECT_BD_MONO, 0}, {TK_OPTION_COLOR, "-selectforeground", "selectForeground", "Background", DEF_ENTRY_SELECT_FG_COLOR, -1, Tk_Offset(Entry, selFgColorPtr), - 0, (ClientData) DEF_ENTRY_SELECT_FG_MONO, 0}, + TK_CONFIG_NULL_OK, (ClientData) DEF_ENTRY_SELECT_FG_MONO, 0}, {TK_OPTION_STRING, "-show", "show", "Show", DEF_ENTRY_SHOW, -1, Tk_Offset(Entry, showChar), TK_OPTION_NULL_OK, 0, 0}, @@ -281,7 +281,7 @@ static const Tk_OptionSpec sbOptSpec[] = 0, (ClientData) DEF_ENTRY_SELECT_BD_MONO, 0}, {TK_OPTION_COLOR, "-selectforeground", "selectForeground", "Background", DEF_ENTRY_SELECT_FG_COLOR, -1, Tk_Offset(Entry, selFgColorPtr), - 0, (ClientData) DEF_ENTRY_SELECT_FG_MONO, 0}, + TK_CONFIG_NULL_OK, (ClientData) DEF_ENTRY_SELECT_FG_MONO, 0}, {TK_OPTION_STRING_TABLE, "-state", "state", "State", DEF_ENTRY_STATE, -1, Tk_Offset(Entry, state), 0, (ClientData) stateStrings, 0}, @@ -1449,7 +1449,9 @@ EntryWorldChanged( } entryPtr->textGC = gc; - gcValues.foreground = entryPtr->selFgColorPtr->pixel; + if (entryPtr->selFgColorPtr != NULL) { + gcValues.foreground = entryPtr->selFgColorPtr->pixel; + } gcValues.font = Tk_FontId(entryPtr->tkfont); mask = GCForeground | GCFont; gc = Tk_GetGC(entryPtr->tkwin, mask, &gcValues); @@ -1583,6 +1585,7 @@ DisplayEntry( Tcl_Release((ClientData) entryPtr); } +#ifndef TK_NO_DOUBLE_BUFFERING /* * In order to avoid screen flashes, this function redraws the textual * area of the entry into off-screen memory, then copies it back on-screen @@ -1592,6 +1595,9 @@ DisplayEntry( pixmap = Tk_GetPixmap(entryPtr->display, Tk_WindowId(tkwin), Tk_Width(tkwin), Tk_Height(tkwin), Tk_Depth(tkwin)); +#else + pixmap = Tk_WindowId(tkwin); +#endif /* TK_NO_DOUBLE_BUFFERING */ /* * Compute x-coordinate of the pixel just after last visible one, plus @@ -1827,6 +1833,7 @@ DisplayEntry( } } +#ifndef TK_NO_DOUBLE_BUFFERING /* * Everything's been redisplayed; now copy the pixmap onto the screen and * free up the pixmap. @@ -1836,6 +1843,7 @@ DisplayEntry( 0, 0, (unsigned) Tk_Width(tkwin), (unsigned) Tk_Height(tkwin), 0, 0); Tk_FreePixmap(entryPtr->display, pixmap); +#endif /* TK_NO_DOUBLE_BUFFERING */ entryPtr->flags &= ~BORDER_NEEDED; } Index: generic/tkFrame.c =================================================================== RCS file: /cvsroot/tktoolkit/tk/generic/tkFrame.c,v retrieving revision 1.27 diff -u -p -r1.27 tkFrame.c --- generic/tkFrame.c 28 Feb 2007 04:58:24 -0000 1.27 +++ generic/tkFrame.c 27 Mar 2007 00:55:14 -0000 @@ -1427,6 +1427,7 @@ DisplayFrame( goto noLabel; } +#ifndef TK_NO_DOUBLE_BUFFERING /* * In order to avoid screen flashes, this function redraws the frame * into off-screen memory, then copies it back on-screen in a single @@ -1436,6 +1437,9 @@ DisplayFrame( pixmap = Tk_GetPixmap(framePtr->display, Tk_WindowId(tkwin), Tk_Width(tkwin), Tk_Height(tkwin), Tk_Depth(tkwin)); +#else + pixmap = Tk_WindowId(tkwin); +#endif /* TK_NO_DOUBLE_BUFFERING */ /* * Clear the pixmap. @@ -1549,6 +1553,7 @@ DisplayFrame( } +#ifndef TK_NO_DOUBLE_BUFFERING /* * Everything's been redisplayed; now copy the pixmap onto the screen * and free up the pixmap. @@ -1560,6 +1565,7 @@ DisplayFrame( (unsigned) (Tk_Height(tkwin) - 2 * hlWidth), hlWidth, hlWidth); Tk_FreePixmap(framePtr->display, pixmap); +#endif /* TK_NO_DOUBLE_BUFFERING */ } } Index: generic/tkListbox.c =================================================================== RCS file: /cvsroot/tktoolkit/tk/generic/tkListbox.c,v retrieving revision 1.38 diff -u -p -r1.38 tkListbox.c --- generic/tkListbox.c 12 Jan 2007 10:41:23 -0000 1.38 +++ generic/tkListbox.c 27 Mar 2007 00:55:15 -0000 @@ -280,7 +280,7 @@ static const Tk_OptionSpec optionSpecs[] Tk_Offset(Listbox, selBorderWidth), 0, 0, 0}, {TK_OPTION_COLOR, "-selectforeground", "selectForeground", "Background", DEF_LISTBOX_SELECT_FG_COLOR, -1, Tk_Offset(Listbox, selFgColorPtr), - 0, (ClientData) DEF_LISTBOX_SELECT_FG_MONO, 0}, + TK_CONFIG_NULL_OK, (ClientData) DEF_LISTBOX_SELECT_FG_MONO, 0}, {TK_OPTION_STRING, "-selectmode", "selectMode", "SelectMode", DEF_LISTBOX_SELECT_MODE, -1, Tk_Offset(Listbox, selectMode), TK_OPTION_NULL_OK, 0, 0}, @@ -1777,7 +1777,9 @@ ListboxWorldChanged(instanceData) } listPtr->textGC = gc; - gcValues.foreground = listPtr->selFgColorPtr->pixel; + if (listPtr->selFgColorPtr != NULL) { + gcValues.foreground = listPtr->selFgColorPtr->pixel; + } gcValues.font = Tk_FontId(listPtr->tkfont); mask = GCForeground | GCFont; gc = Tk_GetGC(listPtr->tkwin, mask, &gcValues); @@ -1863,6 +1865,7 @@ DisplayListbox(clientData) listPtr->flags &= ~(REDRAW_PENDING|UPDATE_V_SCROLLBAR|UPDATE_H_SCROLLBAR); Tcl_Release((ClientData) listPtr); +#ifndef TK_NO_DOUBLE_BUFFERING /* * Redrawing is done in a temporary pixmap that is allocated here and * freed at the end of the procedure. All drawing is done to the pixmap, @@ -1873,6 +1876,9 @@ DisplayListbox(clientData) pixmap = Tk_GetPixmap(listPtr->display, Tk_WindowId(tkwin), Tk_Width(tkwin), Tk_Height(tkwin), Tk_Depth(tkwin)); +#else + pixmap = Tk_WindowId(tkwin); +#endif /* TK_NO_DOUBLE_BUFFERING */ Tk_Fill3DRectangle(tkwin, pixmap, listPtr->normalBorder, 0, 0, Tk_Width(tkwin), Tk_Height(tkwin), 0, TK_RELIEF_FLAT); @@ -1937,7 +1943,11 @@ DisplayListbox(clientData) * Default GC has the values from the widget at large. */ - gcValues.foreground = listPtr->selFgColorPtr->pixel; + if (listPtr->selFgColorPtr) { + gcValues.foreground = listPtr->selFgColorPtr->pixel; + } else { + gcValues.foreground = listPtr->fgColorPtr->pixel; + } gcValues.font = Tk_FontId(listPtr->tkfont); gcValues.graphics_exposures = False; mask = GCForeground | GCFont | GCGraphicsExposures; @@ -2154,10 +2164,12 @@ DisplayListbox(clientData) listPtr->highlightWidth, pixmap); } } +#ifndef TK_NO_DOUBLE_BUFFERING XCopyArea(listPtr->display, pixmap, Tk_WindowId(tkwin), listPtr->textGC, 0, 0, (unsigned) Tk_Width(tkwin), (unsigned) Tk_Height(tkwin), 0, 0); Tk_FreePixmap(listPtr->display, pixmap); +#endif /* TK_NO_DOUBLE_BUFFERING */ } /* Index: generic/tkPanedWindow.c =================================================================== RCS file: /cvsroot/tktoolkit/tk/generic/tkPanedWindow.c,v retrieving revision 1.27 diff -u -p -r1.27 tkPanedWindow.c --- generic/tkPanedWindow.c 5 Jan 2007 00:00:50 -0000 1.27 +++ generic/tkPanedWindow.c 27 Mar 2007 00:55:15 -0000 @@ -1419,12 +1419,16 @@ DisplayPanedWindow( ArrangePanes(clientData); } +#ifndef TK_NO_DOUBLE_BUFFERING /* * Create a pixmap for double-buffering, if necessary. */ pixmap = Tk_GetPixmap(Tk_Display(tkwin), Tk_WindowId(tkwin), Tk_Width(tkwin), Tk_Height(tkwin), Tk_Depth(tkwin)); +#else + pixmap = Tk_WindowId(tkwin); +#endif /* TK_NO_DOUBLE_BUFFERING */ /* * Redraw the widget's background and border. @@ -1467,6 +1471,7 @@ DisplayPanedWindow( } } +#ifndef TK_NO_DOUBLE_BUFFERING /* * Copy the information from the off-screen pixmap onto the screen, then * delete the pixmap. @@ -1475,6 +1480,7 @@ DisplayPanedWindow( XCopyArea(Tk_Display(tkwin), pixmap, Tk_WindowId(tkwin), pwPtr->gc, 0, 0, (unsigned) Tk_Width(tkwin), (unsigned) Tk_Height(tkwin), 0, 0); Tk_FreePixmap(Tk_Display(tkwin), pixmap); +#endif /* TK_NO_DOUBLE_BUFFERING */ } /* @@ -2699,12 +2705,16 @@ DisplayProxyWindow( return; } +#ifndef TK_NO_DOUBLE_BUFFERING /* * Create a pixmap for double-buffering, if necessary. */ pixmap = Tk_GetPixmap(Tk_Display(tkwin), Tk_WindowId(tkwin), Tk_Width(tkwin), Tk_Height(tkwin), Tk_Depth(tkwin)); +#else + pixmap = Tk_WindowId(tkwin); +#endif /* TK_NO_DOUBLE_BUFFERING */ /* * Redraw the widget's background and border. @@ -2713,6 +2723,7 @@ DisplayProxyWindow( Tk_Fill3DRectangle(tkwin, pixmap, pwPtr->background, 0, 0, Tk_Width(tkwin), Tk_Height(tkwin), 2, pwPtr->sashRelief); +#ifndef TK_NO_DOUBLE_BUFFERING /* * Copy the pixmap to the display. */ @@ -2720,6 +2731,7 @@ DisplayProxyWindow( XCopyArea(Tk_Display(tkwin), pixmap, Tk_WindowId(tkwin), pwPtr->gc, 0, 0, (unsigned) Tk_Width(tkwin), (unsigned) Tk_Height(tkwin), 0, 0); Tk_FreePixmap(Tk_Display(tkwin), pixmap); +#endif /* TK_NO_DOUBLE_BUFFERING */ } /* Index: generic/tkText.c =================================================================== RCS file: /cvsroot/tktoolkit/tk/generic/tkText.c,v retrieving revision 1.74 diff -u -p -r1.74 tkText.c --- generic/tkText.c 23 Feb 2007 15:02:58 -0000 1.74 +++ generic/tkText.c 27 Mar 2007 00:55:17 -0000 @@ -200,7 +200,7 @@ static const Tk_OptionSpec optionSpecs[] TK_OPTION_NULL_OK, (ClientData) DEF_TEXT_SELECT_BD_MONO, 0}, {TK_OPTION_COLOR, "-selectforeground", "selectForeground", "Background", DEF_TEXT_SELECT_FG_COLOR, -1, Tk_Offset(TkText, selFgColorPtr), - 0, (ClientData) DEF_TEXT_SELECT_FG_MONO, 0}, + TK_CONFIG_NULL_OK, (ClientData) DEF_TEXT_SELECT_FG_MONO, 0}, {TK_OPTION_BOOLEAN, "-setgrid", "setGrid", "SetGrid", DEF_TEXT_SET_GRID, -1, Tk_Offset(TkText, setGrid), 0, 0, 0}, {TK_OPTION_PIXELS, "-spacing1", "spacing1", "Spacing", Index: generic/tkTextDisp.c =================================================================== RCS file: /cvsroot/tktoolkit/tk/generic/tkTextDisp.c,v retrieving revision 1.62 diff -u -p -r1.62 tkTextDisp.c --- generic/tkTextDisp.c 22 Feb 2007 13:56:33 -0000 1.62 +++ generic/tkTextDisp.c 27 Mar 2007 00:55:19 -0000 @@ -2347,16 +2347,38 @@ DisplayDLine( TextDInfo *dInfoPtr = textPtr->dInfoPtr; Display *display; int height, y_off; +#ifndef TK_NO_DOUBLE_BUFFERING + const int y = 0; +#else + const int y = dlPtr->y; +#endif /* TK_NO_DOUBLE_BUFFERING */ if (dlPtr->chunkPtr == NULL) return; + display = Tk_Display(textPtr->tkwin); + + height = dlPtr->height; + if ((height + dlPtr->y) > dInfoPtr->maxY) { + height = dInfoPtr->maxY - dlPtr->y; + } + if (dlPtr->y < dInfoPtr->y) { + y_off = dInfoPtr->y - dlPtr->y; + height -= y_off; + } else { + y_off = 0; + } + +#ifdef TK_NO_DOUBLE_BUFFERING + TkpClipDrawableToRect(display, pixmap, dInfoPtr->x, y + y_off, + dInfoPtr->maxX - dInfoPtr->x, height); +#endif /* TK_NO_DOUBLE_BUFFERING */ + /* * First, clear the area of the line to the background color for the text * widget. */ - display = Tk_Display(textPtr->tkwin); - Tk_Fill3DRectangle(textPtr->tkwin, pixmap, textPtr->border, 0, 0, + Tk_Fill3DRectangle(textPtr->tkwin, pixmap, textPtr->border, 0, y, Tk_Width(textPtr->tkwin), dlPtr->height, 0, TK_RELIEF_FLAT); /* @@ -2379,7 +2401,7 @@ DisplayDLine( int x = chunkPtr->x + dInfoPtr->x - dInfoPtr->curXPixelOffset; (*chunkPtr->displayProc)(textPtr, chunkPtr, x, - dlPtr->spaceAbove, + y + dlPtr->spaceAbove, dlPtr->height - dlPtr->spaceAbove - dlPtr->spaceBelow, dlPtr->baseline - dlPtr->spaceAbove, display, pixmap, dlPtr->y + dlPtr->spaceAbove); @@ -2426,10 +2448,10 @@ DisplayDLine( x = -chunkPtr->width; } - (*chunkPtr->displayProc)(textPtr, chunkPtr, x, dlPtr->spaceAbove, - dlPtr->height - dlPtr->spaceAbove - dlPtr->spaceBelow, - dlPtr->baseline - dlPtr->spaceAbove, display, pixmap, - dlPtr->y + dlPtr->spaceAbove); + (*chunkPtr->displayProc)(textPtr, chunkPtr, x, + y + dlPtr->spaceAbove, dlPtr->height - dlPtr->spaceAbove - + dlPtr->spaceBelow, dlPtr->baseline - dlPtr->spaceAbove, + display, pixmap, dlPtr->y + dlPtr->spaceAbove); } if (dInfoPtr->dLinesInvalidated) { @@ -2437,6 +2459,7 @@ DisplayDLine( } } +#ifndef TK_NO_DOUBLE_BUFFERING /* * Copy the pixmap onto the screen. If this is the first or last line on * the screen then copy a piece of the line, so that it doesn't overflow @@ -2446,19 +2469,12 @@ DisplayDLine( * possible. */ - height = dlPtr->height; - if ((height + dlPtr->y) > dInfoPtr->maxY) { - height = dInfoPtr->maxY - dlPtr->y; - } - if (dlPtr->y < dInfoPtr->y) { - y_off = dInfoPtr->y - dlPtr->y; - height -= y_off; - } else { - y_off = 0; - } XCopyArea(display, pixmap, Tk_WindowId(textPtr->tkwin), dInfoPtr->copyGC, - dInfoPtr->x, y_off, (unsigned) (dInfoPtr->maxX - dInfoPtr->x), + dInfoPtr->x, y + y_off, (unsigned) (dInfoPtr->maxX - dInfoPtr->x), (unsigned) height, dInfoPtr->x, dlPtr->y + y_off); +#else + TkpClipDrawableToRect(display, pixmap, 0, 0, -1, -1); +#endif /* TK_NO_DOUBLE_BUFFERING */ linesRedrawn++; } @@ -2518,7 +2534,11 @@ DisplayLineBackground( int minX, maxX, xOffset; StyleValues *sValuePtr; Display *display; - +#ifndef TK_NO_DOUBLE_BUFFERING + const int y = 0; +#else + const int y = dlPtr->y; +#endif /* TK_NO_DOUBLE_BUFFERING */ /* * Pass 1: scan through dlPtr from left to right. For each range of chunks @@ -2583,15 +2603,15 @@ DisplayLineBackground( } XFillRectangle(display, pixmap, chunkPtr->stylePtr->bgGC, - leftX + xOffset, 0, (unsigned int) (rightX - leftX), + leftX + xOffset, y, (unsigned int) (rightX - leftX), (unsigned int) dlPtr->height); if (sValuePtr->relief != TK_RELIEF_FLAT) { Tk_3DVerticalBevel(textPtr->tkwin, pixmap, sValuePtr->border, - leftX + xOffset, 0, sValuePtr->borderWidth, + leftX + xOffset, y, sValuePtr->borderWidth, dlPtr->height, 1, sValuePtr->relief); Tk_3DVerticalBevel(textPtr->tkwin, pixmap, sValuePtr->border, rightX - sValuePtr->borderWidth + xOffset, - 0, sValuePtr->borderWidth, dlPtr->height, 0, + y, sValuePtr->borderWidth, dlPtr->height, 0, sValuePtr->relief); } } @@ -2651,7 +2671,7 @@ DisplayLineBackground( chunkPtr->nextPtr->stylePtr)) { if (!matchLeft && (sValuePtr->relief != TK_RELIEF_FLAT)) { Tk_3DHorizontalBevel(textPtr->tkwin, pixmap, - sValuePtr->border, leftX + xOffset, 0, + sValuePtr->border, leftX + xOffset, y, rightX - leftX, sValuePtr->borderWidth, leftXIn, 1, 1, sValuePtr->relief); } @@ -2690,7 +2710,7 @@ DisplayLineBackground( if (matchLeft && !matchRight) { if (sValuePtr->relief != TK_RELIEF_FLAT) { Tk_3DVerticalBevel(textPtr->tkwin, pixmap, sValuePtr->border, - rightX2 - sValuePtr->borderWidth + xOffset, 0, + rightX2 - sValuePtr->borderWidth + xOffset, y, sValuePtr->borderWidth, sValuePtr->borderWidth, 0, sValuePtr->relief); } @@ -2699,11 +2719,11 @@ DisplayLineBackground( } else if (!matchLeft && matchRight && (sValuePtr->relief != TK_RELIEF_FLAT)) { Tk_3DVerticalBevel(textPtr->tkwin, pixmap, sValuePtr->border, - rightX2 + xOffset, 0, sValuePtr->borderWidth, + rightX2 + xOffset, y, sValuePtr->borderWidth, sValuePtr->borderWidth, 1, sValuePtr->relief); Tk_3DHorizontalBevel(textPtr->tkwin, pixmap, sValuePtr->border, - leftX + xOffset,0, rightX2 + sValuePtr->borderWidth -leftX, - sValuePtr->borderWidth, leftXIn, 0, 1, + leftX + xOffset, y, rightX2 + sValuePtr->borderWidth - + leftX, sValuePtr->borderWidth, leftXIn, 0, 1, sValuePtr->relief); } @@ -2767,7 +2787,7 @@ DisplayLineBackground( if (!matchLeft && (sValuePtr->relief != TK_RELIEF_FLAT)) { Tk_3DHorizontalBevel(textPtr->tkwin, pixmap, sValuePtr->border, leftX + xOffset, - dlPtr->height - sValuePtr->borderWidth, + y + dlPtr->height - sValuePtr->borderWidth, rightX - leftX, sValuePtr->borderWidth, leftXIn, 0, 0, sValuePtr->relief); } @@ -2794,7 +2814,7 @@ DisplayLineBackground( if (sValuePtr->relief != TK_RELIEF_FLAT) { Tk_3DVerticalBevel(textPtr->tkwin, pixmap, sValuePtr->border, rightX2 - sValuePtr->borderWidth + xOffset, - dlPtr->height - sValuePtr->borderWidth, + y + dlPtr->height - sValuePtr->borderWidth, sValuePtr->borderWidth, sValuePtr->borderWidth, 0, sValuePtr->relief); } @@ -2803,13 +2823,14 @@ DisplayLineBackground( } else if (!matchLeft && matchRight && (sValuePtr->relief != TK_RELIEF_FLAT)) { Tk_3DVerticalBevel(textPtr->tkwin, pixmap, sValuePtr->border, - rightX2 + xOffset, dlPtr->height - sValuePtr->borderWidth, + rightX2 + xOffset, y + dlPtr->height - sValuePtr->borderWidth, sValuePtr->borderWidth, - 1, sValuePtr->relief); + sValuePtr->borderWidth, 1, sValuePtr->relief); Tk_3DHorizontalBevel(textPtr->tkwin, pixmap, sValuePtr->border, - leftX + xOffset, dlPtr->height - sValuePtr->borderWidth, - rightX2 + sValuePtr->borderWidth - leftX, - sValuePtr->borderWidth, leftXIn, 1, 0, sValuePtr->relief); + leftX + xOffset, y + dlPtr->height - + sValuePtr->borderWidth, rightX2 + sValuePtr->borderWidth - + leftX, sValuePtr->borderWidth, leftXIn, 1, 0, + sValuePtr->relief); } nextChunk2b: @@ -4174,9 +4195,13 @@ DisplayText( } if (maxHeight > 0) { +#ifndef TK_NO_DOUBLE_BUFFERING pixmap = Tk_GetPixmap(Tk_Display(textPtr->tkwin), Tk_WindowId(textPtr->tkwin), Tk_Width(textPtr->tkwin), maxHeight, Tk_Depth(textPtr->tkwin)); +#else + pixmap = Tk_WindowId(textPtr->tkwin); +#endif /* TK_NO_DOUBLE_BUFFERING */ for (prevPtr = NULL, dlPtr = textPtr->dInfoPtr->dLinePtr; (dlPtr != NULL) && (dlPtr->y < dInfoPtr->maxY); prevPtr = dlPtr, dlPtr = dlPtr->nextPtr) { @@ -4192,7 +4217,9 @@ DisplayText( } DisplayDLine(textPtr, dlPtr, prevPtr, pixmap); if (dInfoPtr->dLinesInvalidated) { +#ifndef TK_NO_DOUBLE_BUFFERING Tk_FreePixmap(Tk_Display(textPtr->tkwin), pixmap); +#endif /* TK_NO_DOUBLE_BUFFERING */ return; } dlPtr->oldY = dlPtr->y; @@ -4246,7 +4273,9 @@ DisplayText( } } +#ifndef TK_NO_DOUBLE_BUFFERING Tk_FreePixmap(Tk_Display(textPtr->tkwin), pixmap); +#endif /* TK_NO_DOUBLE_BUFFERING */ } /* Index: generic/ttk/ttkWidget.c =================================================================== RCS file: /cvsroot/tktoolkit/tk/generic/ttk/ttkWidget.c,v retrieving revision 1.6 diff -u -p -r1.6 ttkWidget.c --- generic/ttk/ttkWidget.c 7 Mar 2007 23:49:38 -0000 1.6 +++ generic/ttk/ttkWidget.c 27 Mar 2007 00:55:19 -0000 @@ -10,6 +10,10 @@ #include "ttkTheme.h" #include "ttkWidget.h" +#ifdef MAC_OSX_TK +#define TK_NO_DOUBLE_BUFFERING 1 +#endif + /*------------------------------------------------------------------------ * +++ Internal helper routines. */ @@ -58,14 +62,17 @@ static void RedisplayWidget(ClientData r WidgetCore *corePtr = (WidgetCore *)recordPtr; Tk_Window tkwin = corePtr->tkwin; Drawable d; +#ifndef TK_NO_DOUBLE_BUFFERING XGCValues gcValues; GC gc; +#endif /* TK_NO_DOUBLE_BUFFERING */ corePtr->flags &= ~REDISPLAY_PENDING; if (!Tk_IsMapped(tkwin)) { return; } +#ifndef TK_NO_DOUBLE_BUFFERING /* * Get a Pixmap for drawing in the background: */ @@ -79,6 +86,9 @@ static void RedisplayWidget(ClientData r gcValues.function = GXcopy; gcValues.graphics_exposures = False; gc = Tk_GetGC(corePtr->tkwin, GCFunction|GCGraphicsExposures, &gcValues); +#else + d = Tk_WindowId(tkwin); +#endif /* TK_NO_DOUBLE_BUFFERING */ /* * Recompute layout and draw widget contents: @@ -86,6 +96,7 @@ static void RedisplayWidget(ClientData r corePtr->widgetSpec->layoutProc(recordPtr); corePtr->widgetSpec->displayProc(recordPtr, d); +#ifndef TK_NO_DOUBLE_BUFFERING /* * Copy to the screen. */ @@ -98,6 +109,7 @@ static void RedisplayWidget(ClientData r */ Tk_FreePixmap(Tk_Display(tkwin), d); Tk_FreeGC(Tk_Display(tkwin), gc); +#endif /* TK_NO_DOUBLE_BUFFERING */ } /* TtkRedisplayWidget -- Index: library/bgerror.tcl =================================================================== RCS file: /cvsroot/tktoolkit/tk/library/bgerror.tcl,v retrieving revision 1.32 diff -u -p -r1.32 bgerror.tcl --- library/bgerror.tcl 22 Jun 2006 00:38:16 -0000 1.32 +++ library/bgerror.tcl 27 Mar 2007 00:55:19 -0000 @@ -18,6 +18,12 @@ namespace eval ::tk::dialog::error { option add *ErrorDialog.function.text [mc "Save To Log"] \ widgetDefault option add *ErrorDialog.function.command [namespace code SaveToLog] + if {[tk windowingsystem] eq "aqua"} { + option add *ErrorDialog*background systemAlertBackgroundActive \ + widgetDefault + option add *ErrorDialog*Button.highlightBackground \ + systemAlertBackgroundActive widgetDefault + } } proc ::tk::dialog::error::Return {} { @@ -139,7 +145,7 @@ proc ::tk::dialog::error::bgerror err { wm protocol .bgerrorDialog WM_DELETE_WINDOW { } if {$windowingsystem eq "aqua"} { - ::tk::unsupported::MacWindowStyle style .bgerrorDialog zoomDocProc + ::tk::unsupported::MacWindowStyle style .bgerrorDialog moveableAlert {} } frame .bgerrorDialog.bot @@ -161,6 +167,9 @@ proc ::tk::dialog::error::bgerror err { -relief $textRelief \ -highlightthickness $textHilight \ -wrap char + if {$windowingsystem eq "aqua"} { + $W.text configure -width 80 -background white + } scrollbar $W.scroll -command [list $W.text yview] pack $W.scroll -side right -fill y @@ -218,6 +227,7 @@ proc ::tk::dialog::error::bgerror err { if {($name eq "ok") || ($name eq "dismiss")} { grid columnconfigure .bgerrorDialog.bot $i -minsize 79 } + grid configure .bgerrorDialog.$name -pady 7 } incr i } Index: library/dialog.tcl =================================================================== RCS file: /cvsroot/tktoolkit/tk/library/dialog.tcl,v retrieving revision 1.20 diff -u -p -r1.20 dialog.tcl --- library/dialog.tcl 25 Jan 2006 18:22:04 -0000 1.20 +++ library/dialog.tcl 27 Mar 2007 00:55:19 -0000 @@ -67,7 +67,10 @@ proc ::tk_dialog {w title text bitmap de set windowingsystem [tk windowingsystem] if {$windowingsystem eq "aqua"} { - ::tk::unsupported::MacWindowStyle style $w dBoxProc + ::tk::unsupported::MacWindowStyle style $w moveableModal {} + option add *Dialog*background systemDialogBackgroundActive widgetDefault + option add *Dialog*Button.highlightBackground \ + systemDialogBackgroundActive widgetDefault } frame $w.bot @@ -120,6 +123,7 @@ proc ::tk_dialog {w title text bitmap de if {$tmp eq "ok" || $tmp eq "cancel"} { grid columnconfigure $w.bot $i -minsize [expr {59 + 20}] } + grid configure $w.button$i -pady 7 } incr i } Index: library/tearoff.tcl =================================================================== RCS file: /cvsroot/tktoolkit/tk/library/tearoff.tcl,v retrieving revision 1.10 diff -u -p -r1.10 tearoff.tcl --- library/tearoff.tcl 25 Jul 2005 09:06:00 -0000 1.10 +++ library/tearoff.tcl 27 Mar 2007 00:55:19 -0000 @@ -39,7 +39,7 @@ proc ::tk::TearOffMenu {w {x 0} {y 0}} { set y [winfo rooty $w] if {[tk windowingsystem] eq "aqua"} { # Avoid the native menu bar which sits on top of everything. - if {$y < 20} { set y 20 } + if {$y < 22} { set y 22 } } } Index: library/tk.tcl =================================================================== RCS file: /cvsroot/tktoolkit/tk/library/tk.tcl,v retrieving revision 1.60 diff -u -p -r1.60 tk.tcl --- library/tk.tcl 31 Oct 2006 01:42:26 -0000 1.60 +++ library/tk.tcl 27 Mar 2007 00:55:19 -0000 @@ -128,7 +128,7 @@ proc ::tk::PlaceWindow {w {place ""} {an } if {[tk windowingsystem] eq "aqua"} { # Avoid the native menu bar which sits on top of everything. - if {$y < 20} { set y 20 } + if {$y < 22} { set y 22 } } } wm geometry $w +$x+$y Index: library/demos/goldberg.tcl =================================================================== RCS file: /cvsroot/tktoolkit/tk/library/demos/goldberg.tcl,v retrieving revision 1.2 diff -u -p -r1.2 goldberg.tcl --- library/demos/goldberg.tcl 21 Dec 2004 11:56:35 -0000 1.2 +++ library/demos/goldberg.tcl 27 Mar 2007 00:55:20 -0000 @@ -50,8 +50,7 @@ wm iconname $w "goldberg" wm resizable $w 0 0 #positionWindow $w -set font {Arial 10} -label $w.msg -font $font -wraplength 4i -justify left -text "This is a demonstration of just how complex you can make your animations become. Click the ball to start things moving!\n\n\"Man will always find a difficult means to perform a simple task\"\n - Rube Goldberg" +label $w.msg -font {Arial 10} -wraplength 4i -justify left -text "This is a demonstration of just how complex you can make your animations become. Click the ball to start things moving!\n\n\"Man will always find a difficult means to perform a simple task\"\n - Rube Goldberg" pack $w.msg -side top if 0 { Index: library/demos/menu.tcl =================================================================== RCS file: /cvsroot/tktoolkit/tk/library/demos/menu.tcl,v retrieving revision 1.10 diff -u -p -r1.10 menu.tcl --- library/demos/menu.tcl 9 Aug 2005 07:39:19 -0000 1.10 +++ library/demos/menu.tcl 27 Mar 2007 00:55:20 -0000 @@ -19,9 +19,9 @@ wm iconname $w "menu" positionWindow $w label $w.msg -font $font -wraplength 4i -justify left -if {[string equal [tk windowingsystem] "classic"] - || [string equal [tk windowingsystem] "aqua"]} { - $w.msg configure -text "This window contains a menubar with cascaded menus. You can invoke entries with an accelerator by typing Command+x, where \"x\" is the character next to the command key symbol. The rightmost menu can be torn off into a palette by dragging outside of its bounds and releasing the mouse." +if {[tk windowingsystem] eq "aqua"} { + catch {set origUseCustomMDEF $:tk::mac::useCustomMDEF; set ::tk::mac::useCustomMDEF 1} + $w.msg configure -text "This window has a menubar with cascaded menus. You can invoke entries with an accelerator by typing Command+x, where \"x\" is the character next to the command key symbol. The rightmost menu can be torn off into a palette by selecting the first item in the menu." } else { $w.msg configure -text "This window contains a menubar with cascaded menus. You can post a menu from the keyboard by typing Alt+x, where \"x\" is the character underlined on the menu. You can then traverse among the menus using the arrow keys. When a menu is posted, you can invoke the current entry by typing space, or you can invoke any entry by typing its underlined character. If a menu entry has an accelerator, you can invoke the entry without posting the menu just by typing the accelerator. The rightmost menu can be torn off into a palette by selecting the first item in the menu." } @@ -56,8 +56,7 @@ set m $w.menu.basic $w.menu add cascade -label "Basic" -menu $m -underline 0 menu $m -tearoff 0 $m add command -label "Long entry that does nothing" -if {[string equal [tk windowingsystem] "classic"] - || [string equal [tk windowingsystem] "aqua"]} { +if {[tk windowingsystem] eq "aqua"} { set modifier Command } elseif {$tcl_platform(platform) == "windows"} { set modifier Control @@ -144,7 +143,7 @@ $m entryconfigure "Does almost nothing" set m $w.menu.colors $w.menu add cascade -label "Colors" -menu $m -underline 1 -menu $m +menu $m -tearoff 1 foreach i {red orange yellow green blue} { $m add command -label $i -background $i -command [list \ puts "You invoked \"$i\"" ] @@ -160,3 +159,5 @@ bind Menu <> { set menustatus $label update idletasks } + +if {[tk windowingsystem] eq "aqua"} {catch {set ::tk::mac::useCustomMDEF $origUseCustomMDEF}} Index: library/demos/menubu.tcl =================================================================== RCS file: /cvsroot/tktoolkit/tk/library/demos/menubu.tcl,v retrieving revision 1.5 diff -u -p -r1.5 menubu.tcl --- library/demos/menubu.tcl 21 Dec 2004 11:56:35 -0000 1.5 +++ library/demos/menubu.tcl 27 Mar 2007 00:55:20 -0000 @@ -1,4 +1,4 @@ -# menubutton.tcl -- +# menubu.tcl -- # # This demonstration script creates a window with a bunch of menus # and cascaded menus using menubuttons. @@ -11,16 +11,16 @@ if {![info exists widgetDemo]} { package require Tk -set w .menubutton +set w .menubu catch {destroy $w} toplevel $w wm title $w "Menu Button Demonstration" wm iconname $w "menubutton" positionWindow $w - frame $w.body pack $w.body -expand 1 -fill both +if {[tk windowingsystem] eq "aqua"} {catch {set origUseCustomMDEF $:tk::mac::useCustomMDEF; set ::tk::mac::useCustomMDEF 1}} menubutton $w.body.below -text "Below" -underline 0 -direction below -menu $w.body.below.m -relief raised menu $w.body.below.m -tearoff 0 @@ -57,8 +57,7 @@ pack $body.buttons -padx 25 -pady 25 tk_optionMenu $body.buttons.options menubuttonoptions one two three pack $body.buttons.options -side left -padx 25 -pady 25 set m [tk_optionMenu $body.buttons.colors paletteColor Black red4 DarkGreen NavyBlue gray75 Red Green Blue gray50 Yellow Cyan Magenta White Brown DarkSeaGreen DarkViolet] -if {[string equal [tk windowingsystem] "classic"] - || [string equal [tk windowingsystem] "aqua"]} { +if {[tk windowingsystem] eq "aqua"} { set topBorderColor Black set bottomBorderColor Black } else { @@ -90,5 +89,4 @@ foreach i {Black gray75 gray50 White} { pack $body.buttons.colors -side left -padx 25 -pady 25 - - +if {[tk windowingsystem] eq "aqua"} {catch {set ::tk::mac::useCustomMDEF $origUseCustomMDEF}} Index: library/demos/puzzle.tcl =================================================================== RCS file: /cvsroot/tktoolkit/tk/library/demos/puzzle.tcl,v retrieving revision 1.6 diff -u -p -r1.6 puzzle.tcl --- library/demos/puzzle.tcl 21 Dec 2004 11:56:35 -0000 1.6 +++ library/demos/puzzle.tcl 27 Mar 2007 00:55:20 -0000 @@ -59,8 +59,8 @@ scrollbar $w.s # using place which doesn't autosize, then we need to have a # slightly larger frame here... -if {[string equal [tk windowingsystem] aqua]} { - set frameSize 160 +if {[tk windowingsystem] eq "aqua"} { + set frameSize 168 } else { set frameSize 120 } Index: library/demos/radio.tcl =================================================================== RCS file: /cvsroot/tktoolkit/tk/library/demos/radio.tcl,v retrieving revision 1.7 diff -u -p -r1.7 radio.tcl --- library/demos/radio.tcl 21 Dec 2004 11:56:35 -0000 1.7 +++ library/demos/radio.tcl 27 Mar 2007 00:55:20 -0000 @@ -29,7 +29,9 @@ labelframe $w.mid -pady 2 -text "Color" labelframe $w.right -pady 2 -text "Alignment" -padx 2 button $w.tristate -text Tristate -command "set size multi; set color multi" \ -pady 2 -padx 2 - +if {[tk windowingsystem] eq "aqua"} { + $w.tristate configure -padx 10 +} grid $w.left -column 0 -row 1 -pady .5c -padx .5c -rowspan 2 grid $w.mid -column 1 -row 1 -pady .5c -padx .5c -rowspan 2 grid $w.right -column 2 -row 1 -pady .5c -padx .5c Index: macosx/Wish-Common.xcconfig =================================================================== RCS file: /cvsroot/tktoolkit/tk/macosx/Wish-Common.xcconfig,v retrieving revision 1.2 diff -u -p -r1.2 Wish-Common.xcconfig --- macosx/Wish-Common.xcconfig 7 Mar 2007 23:46:34 -0000 1.2 +++ macosx/Wish-Common.xcconfig 27 Mar 2007 00:55:20 -0000 @@ -25,7 +25,7 @@ GCC = /usr/bin/gcc GCC_VERSION = 4.0 CC = $(GCC)-$(GCC_VERSION) WARNING_CFLAGS_GCC3 = -Wall -Wno-implicit-int -Wno-unused-parameter -Wno-deprecated-declarations -WARNING_CFLAGS = -Wextra -Wno-missing-field-initializers $(WARNING_CFLAGS_GCC3) $(WARNING_CFLAGS) +WARNING_CFLAGS = -Wextra -Wno-missing-field-initializers -Winit-self -Wpointer-arith -Wcast-align -Wdisabled-optimization -Winline $(WARNING_CFLAGS_GCC3) $(WARNING_CFLAGS) REZ_RESOURCE_MAP_READ_ONLY = YES APPLICATION_INSTALL_PATH = /Applications/Utilities BINDIR = $(PREFIX)/bin Index: macosx/tkAboutDlg.r =================================================================== RCS file: /cvsroot/tktoolkit/tk/macosx/tkAboutDlg.r,v retrieving revision 1.7 diff -u -p -r1.7 tkAboutDlg.r --- macosx/tkAboutDlg.r 28 Apr 2006 06:02:48 -0000 1.7 +++ macosx/tkAboutDlg.r 27 Mar 2007 00:55:20 -0000 @@ -6,6 +6,7 @@ * libraries in a Macintosh Application. * * Copyright (c) 1996 Sun Microsystems, Inc. + * Copyright (c) 2006-2007 Daniel A. Steffen * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. @@ -34,7 +35,7 @@ resource 'DLOG' (128, "About Box", purgeable) { {60, 40, 332, 404}, - movableDBoxProc, + kWindowMovableModalDialogProc, visible, noGoAway, 0x0, @@ -48,8 +49,8 @@ resource 'DITL' (128, "About Box", purge {232, 147, 252, 217}, Button {enabled, "Ok"}, { 20, 108, 212, 344}, StaticText {disabled, "Tcl " TCL_PATCH_LEVEL " & Tk " TK_PATCH_LEVEL "\n\n" - "© 2002-2006 Tcl Core Team." "\n\n" - "© 2002-2006 Daniel A. Steffen." "\n\n" + "© 2002-2007 Tcl Core Team." "\n\n" + "© 2002-2007 Daniel A. Steffen." "\n\n" "Jim Ingham & Ian Reid" "\n" "© 2001-2002 Apple Computer, Inc." "\n\n" "Jim Ingham & Ray Johnson" "\n" @@ -59,6 +60,13 @@ resource 'DITL' (128, "About Box", purge } }; +resource 'dlgx' (128, "About Box", purgeable) { + versionZero { + kDialogFlagsUseThemeBackground | kDialogFlagsUseControlHierarchy + | kDialogFlagsHandleMovableModal | kDialogFlagsUseThemeControls + } +}; + data 'PICT' (128, purgeable) { $"13A4 0000 0000 0064 0044 0011 02FF 0C00" $"FFFE 0000 0048 0000 0048 0000 0000 0000" Index: macosx/tkMacOSXBitmap.c =================================================================== RCS file: /cvsroot/tktoolkit/tk/macosx/tkMacOSXBitmap.c,v retrieving revision 1.4 diff -u -p -r1.4 tkMacOSXBitmap.c --- macosx/tkMacOSXBitmap.c 24 Mar 2006 14:58:01 -0000 1.4 +++ macosx/tkMacOSXBitmap.c 27 Mar 2007 00:55:20 -0000 @@ -5,6 +5,7 @@ * * Copyright (c) 1996-1997 Sun Microsystems, Inc. * Copyright 2001, Apple Computer, Inc. + * Copyright (c) 2006-2007 Daniel A. Steffen * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. @@ -36,10 +37,10 @@ typedef struct { */ typedef struct { - char *name; /* Name of icon. */ + const char *name; /* Name of icon. */ long int type; /* Type of icon. */ - int id; /* Id of icon. */ - int size; /* Size of icon. */ + int id; /* Id of icon. */ + int size; /* Size of icon. */ } BuiltInIcon; /* @@ -91,7 +92,7 @@ TkpDefineNativeBitmaps() int new; Tcl_HashEntry *predefHashPtr; TkPredefBitmap *predefPtr; - CONST char * name; + const char * name; BuiltInIcon *builtInPtr; NativeIcon *nativeIconPtr; Tcl_HashTable *tablePtr; @@ -139,20 +140,16 @@ TkpCreateNativeBitmap( CONST char * source) /* Info about the icon to build. */ { Pixmap pix; - GWorldPtr destPort; Rect destRect; Handle icon; - CGrafPtr saveWorld; - GDHandle saveDevice; - NativeIcon *nativeIconPtr; + CGrafPtr savePort; + Boolean portChanged; + const NativeIcon *nativeIconPtr; pix = Tk_GetPixmap(display, None, 32, 32, 0); - destPort = TkMacOSXGetDrawablePort(pix); - - GetGWorld(&saveWorld, &saveDevice); - SetGWorld(destPort, NULL); + portChanged = QDSwapPort(TkMacOSXGetDrawablePort(pix), &savePort); - nativeIconPtr = (NativeIcon *) source; + nativeIconPtr = (const NativeIcon *) source; SetRect(&destRect, 0, 0, 32, 32); if (nativeIconPtr->type == TYPE1) { RGBColor white = {0xFFFF, 0xFFFF, 0xFFFF}; @@ -171,7 +168,9 @@ TkpCreateNativeBitmap( } } - SetGWorld(saveWorld, saveDevice); + if (portChanged) { + QDSwapPort(savePort, NULL); + } return pix; } @@ -201,23 +200,23 @@ TkpGetNativeAppBitmap( int *height) { Pixmap pix; - CGrafPtr saveWorld; - GDHandle saveDevice; - GWorldPtr destPort; + CGrafPtr savePort; + Boolean portChanged; Rect destRect; Handle resource; int type = -1, destWrote; Str255 nativeName; + Tcl_Encoding encoding; /* * macRoman is the encoding that the resource fork uses. */ - Tcl_UtfToExternal(NULL, Tcl_GetEncoding(NULL, "macRoman"), name, - strlen(name), 0, NULL, - (char *) &nativeName[1], - 255, NULL, &destWrote, NULL); /* Internalize native */ + encoding = Tcl_GetEncoding(NULL, "macRoman"); + Tcl_UtfToExternal(NULL, encoding, name, strlen(name), 0, NULL, + (char *) &nativeName[1], 255, NULL, &destWrote, NULL); nativeName[0] = destWrote; + Tcl_FreeEncoding(encoding); resource = GetNamedResource('cicn', nativeName); if (resource != NULL) { @@ -234,10 +233,7 @@ TkpGetNativeAppBitmap( } pix = Tk_GetPixmap(display, None, 32, 32, 0); - destPort = TkMacOSXGetDrawablePort(pix); - - GetGWorld(&saveWorld, &saveDevice); - SetGWorld(destPort, NULL); + portChanged = QDSwapPort(TkMacOSXGetDrawablePort(pix), &savePort); SetRect(&destRect, 0, 0, 32, 32); if (type == TYPE2) { @@ -268,6 +264,8 @@ TkpGetNativeAppBitmap( *width = 32; *height = 32; - SetGWorld(saveWorld, saveDevice); + if (portChanged) { + QDSwapPort(savePort, NULL); + } return pix; } Index: macosx/tkMacOSXButton.c =================================================================== RCS file: /cvsroot/tktoolkit/tk/macosx/tkMacOSXButton.c,v retrieving revision 1.20 diff -u -p -r1.20 tkMacOSXButton.c --- macosx/tkMacOSXButton.c 18 Aug 2006 07:30:54 -0000 1.20 +++ macosx/tkMacOSXButton.c 27 Mar 2007 00:55:20 -0000 @@ -6,6 +6,7 @@ * * Copyright (c) 1996-1997 by Sun Microsystems, Inc. * Copyright 2001, Apple Computer, Inc. + * Copyright (c) 2006-2007 Daniel A. Steffen * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. @@ -70,7 +71,7 @@ typedef struct { int flags; /* initialisation status */ MacControlParams params; WindowRef windowRef; - RGBColor userPaneBackground; + unsigned long userPaneBackground; ControlRef userPane; /* Carbon control */ ControlRef control; /* Carbon control */ Str255 controlTitle; @@ -80,9 +81,9 @@ typedef struct { * beveled buttons - i.e. buttons with images. */ CCTabHandle tabHandle; + Pixmap picPixmap; ControlButtonContentInfo bevelButtonContent; OpenCPicParams picParams; - Pixmap picPixmap; } MacButton; /* @@ -90,23 +91,23 @@ typedef struct { */ -static OSErr SetUserPaneDrawProc(ControlRef control, +static OSStatus SetUserPaneDrawProc(ControlRef control, ControlUserPaneDrawProcPtr upp); -static OSErr SetUserPaneSetUpSpecialBackgroundProc(ControlRef control, +static OSStatus SetUserPaneSetUpSpecialBackgroundProc(ControlRef control, ControlUserPaneBackgroundProcPtr upp); static void UserPaneDraw(ControlRef control, ControlPartCode cpc); static void UserPaneBackgroundProc(ControlHandle, ControlBackgroundPtr info); -static void ButtonEventProc _ANSI_ARGS_(( ClientData clientData, XEvent *eventPtr)); -static int UpdateControlColors _ANSI_ARGS_((MacButton *mbPtr )); -static void TkMacOSXComputeControlParams _ANSI_ARGS_((TkButton * butPtr, MacControlParams * paramsPtr)); -static int TkMacOSXComputeDrawParams _ANSI_ARGS_((TkButton * butPtr, DrawParams * dpPtr)); -static void TkMacOSXDrawControl _ANSI_ARGS_((MacButton *butPtr, - GWorldPtr destPort, GC gc, Pixmap pixmap)); -static void SetupBevelButton _ANSI_ARGS_((MacButton *butPtr, - ControlRef controlHandle, - GWorldPtr destPort, GC gc, Pixmap pixmap)); +static void ButtonEventProc(ClientData clientData, XEvent *eventPtr); +static int UpdateControlColors(MacButton *mbPtr); +static void TkMacOSXComputeControlParams(TkButton * butPtr, + MacControlParams * paramsPtr); +static int TkMacOSXComputeDrawParams(TkButton * butPtr, DrawParams * dpPtr); +static void TkMacOSXDrawControl(MacButton *butPtr, GWorldPtr destPort, GC gc, + Pixmap pixmap); +static void SetupBevelButton(MacButton *butPtr, ControlRef controlHandle, + GWorldPtr destPort, GC gc, Pixmap pixmap); /* * The class procedure table for the button widgets. @@ -148,9 +149,7 @@ TkpCreateButton( macButtonPtr->id = bCount++; macButtonPtr->usingControl = 0; macButtonPtr->flags = 0; - macButtonPtr->userPaneBackground.red = 0; - macButtonPtr->userPaneBackground.green = 0; - macButtonPtr->userPaneBackground.blue = ~0; + macButtonPtr->userPaneBackground = PIXEL_MAGIC << 24; macButtonPtr->userPane = NULL; macButtonPtr->control = NULL; macButtonPtr->controlTitle[0] = 0; @@ -196,7 +195,8 @@ TkpDisplayButton( int width, height, fullWidth, fullHeight; int textXOffset, textYOffset; int haveImage = 0, haveText = 0; - GWorldPtr destPort; + CGrafPtr destPort, savePort; + Boolean portChanged; int borderWidth; Pixmap pixmap; int wasUsingControl; @@ -232,7 +232,7 @@ TkpDisplayButton( */ destPort = TkMacOSXGetDrawablePort(pixmap); - SetGWorld(destPort, NULL); + portChanged = QDSwapPort(destPort, &savePort); TkMacOSXSetUpClippingRgn(pixmap); @@ -504,6 +504,9 @@ TkpDisplayButton( butPtr->borderWidth, dpPtr->relief); } } + if (portChanged) { + QDSwapPort(savePort, NULL); + } } /* @@ -803,7 +806,6 @@ TkMacOSXInitControl ( Rect *cntrRect ) { - OSErr status; TkButton * butPtr = ( TkButton * )mbPtr; ControlRef rootControl; SInt16 procID; @@ -814,8 +816,8 @@ TkMacOSXInitControl ( SInt32 controlReference; rootControl = TkMacOSXGetRootControl(Tk_WindowId(butPtr->tkwin)); - mbPtr->windowRef - = GetWindowFromPort(TkMacOSXGetDrawablePort(Tk_WindowId(butPtr->tkwin))); + mbPtr->windowRef = GetWindowFromPort(TkMacOSXGetDrawablePort( + Tk_WindowId(butPtr->tkwin))); /* * Set up the user pane @@ -827,54 +829,31 @@ TkMacOSXInitControl ( maxValue = 1; procID = kControlUserPaneProc; controlReference = (SInt32)mbPtr; - mbPtr->userPane = NewControl(mbPtr->windowRef, - paneRect, "\p", - initiallyVisible, - initialValue, - minValue, - maxValue, - procID, - controlReference ); - + mbPtr->userPane = NewControl(mbPtr->windowRef, paneRect, "\p", + initiallyVisible, initialValue, minValue, maxValue, procID, + controlReference); if (!mbPtr->userPane) { -#ifdef TK_MAC_DEBUG - fprintf(stderr,"Failed to create user pane control\n"); -#endif + TkMacOSXDbgMsg("Failed to create user pane control"); return 1; } - - if ((status = EmbedControl(mbPtr->userPane,rootControl)) != noErr) { -#ifdef TK_MAC_DEBUG - fprintf(stderr,"Failed to embed user pane control %d\n", status); -#endif + if (ChkErr(EmbedControl, mbPtr->userPane,rootControl) != noErr) { return 1; } SetUserPaneSetUpSpecialBackgroundProc(mbPtr->userPane, - UserPaneBackgroundProc); + 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 ); - + mbPtr->control = NewControl(mbPtr->windowRef, cntrRect, "\p", + initiallyVisible, mbPtr->params.initialValue, + mbPtr->params.minValue, mbPtr->params.maxValue, + mbPtr->params.procID, controlReference); if (!mbPtr->control) { -#ifdef TK_MAC_DEBUG - fprintf(stderr,"failed to create control of type %d\n",procID); -#endif + TkMacOSXDbgMsg("failed to create control of type %d\n", procID); return 1; } - - if (EmbedControl(mbPtr->control,mbPtr->userPane) != noErr ) { -#ifdef TK_MAC_DEBUG - fprintf(stderr,"failed to embed control of type %d\n",procID); -#endif + if (ChkErr(EmbedControl, mbPtr->control,mbPtr->userPane) != noErr ) { return 1; } @@ -996,11 +975,7 @@ TkMacOSXDrawControl( if (len) { TkMacOSXInitControlFontStyle(font, &fontStyle); if (bcmp(&mbPtr->fontStyle, &fontStyle, sizeof(fontStyle)) ) { - if (SetControlFontStyle(mbPtr->control, &fontStyle) != noErr) { -#ifdef TK_MAC_DEBUG - fprintf(stderr,"SetControlFontStyle failed\n"); -#endif - } + ChkErr(SetControlFontStyle, mbPtr->control, &fontStyle); bcopy(&fontStyle, &mbPtr->fontStyle, sizeof(fontStyle)); } @@ -1063,7 +1038,7 @@ TkMacOSXDrawControl( } } - if (mbPtr->flags&2) { + if (mbPtr->flags & 2) { ShowControl(mbPtr->userPane); ShowControl(mbPtr->control); mbPtr->flags ^= 2; @@ -1104,12 +1079,13 @@ SetupBevelButton( for the bevel button */ ) { - int err; TkButton *butPtr = ( TkButton *)mbPtr; int height, width; ControlButtonGraphicAlignment theAlignment; + CGrafPtr savePort; + Boolean portChanged; - SetPort(destPort); + portChanged = QDSwapPort(destPort, &savePort); if (butPtr->image != None) { Tk_SizeOfImage(butPtr->image, @@ -1133,11 +1109,9 @@ SetupBevelButton( * Set the flag to circumvent clipping and bounds problems with OS 10.0.4 */ - if (!(mbPtr->bevelButtonContent.u.picture - = OpenCPicture(&mbPtr->picParams)) ) { -#ifdef TK_MAC_DEBUG - fprintf(stderr,"OpenCPicture failed\n"); -#endif + if (!(mbPtr->bevelButtonContent.u.picture = + OpenCPicture(&mbPtr->picParams))) { + TkMacOSXDbgMsg("OpenCPicture failed"); } tkPictureIsOpen = 1; @@ -1156,7 +1130,7 @@ SetupBevelButton( } else if (butPtr->image != NULL) { Tk_RedrawImage(butPtr->image, 0, 0, width, height, pixmap, 0, 0); - } else { + } else { XSetClipOrigin(butPtr->display, gc, 0, 0); XCopyPlane(butPtr->display, butPtr->bitmap, pixmap, gc, 0, 0, (unsigned int) width, (unsigned int) height, 0, 0, 1); @@ -1165,15 +1139,9 @@ SetupBevelButton( ClosePicture(); tkPictureIsOpen = 0; - if ((err = SetControlData(controlHandle, kControlButtonPart, - kControlBevelButtonContentTag, - sizeof(ControlButtonContentInfo), - (char *) &mbPtr->bevelButtonContent)) != noErr) { -#ifdef TK_MAC_DEBUG - fprintf(stderr, - "SetControlData BevelButtonContent failed, %d\n", err ); -#endif - } + ChkErr(SetControlData, controlHandle, kControlButtonPart, + kControlBevelButtonContentTag, sizeof(ControlButtonContentInfo), + (char *) &mbPtr->bevelButtonContent); if (butPtr->anchor == TK_ANCHOR_N) { theAlignment = kControlBevelButtonAlignTop; @@ -1195,15 +1163,9 @@ SetupBevelButton( theAlignment = kControlBevelButtonAlignCenter; } - if ((err = SetControlData(controlHandle, kControlButtonPart, + ChkErr(SetControlData, controlHandle, kControlButtonPart, kControlBevelButtonGraphicAlignTag, - sizeof(ControlButtonGraphicAlignment), - (char *) &theAlignment)) != noErr) { -#ifdef TK_MAC_DEBUG - fprintf(stderr, - "SetControlData BevelButtonGraphicAlign failed, %d\n", err ); -#endif - } + sizeof(ControlButtonGraphicAlignment), (char *) &theAlignment); if (butPtr->compound != COMPOUND_NONE) { ControlButtonTextPlacement thePlacement = \ @@ -1217,15 +1179,12 @@ SetupBevelButton( } else if (butPtr->compound == COMPOUND_RIGHT) { thePlacement = kControlBevelButtonPlaceToLeftOfGraphic; } - if ((err = SetControlData(controlHandle, kControlButtonPart, + ChkErr(SetControlData, controlHandle, kControlButtonPart, kControlBevelButtonTextPlaceTag, - sizeof(ControlButtonTextPlacement), - (char *) &thePlacement)) != noErr) { -#ifdef TK_MAC_DEBUG - fprintf(stderr, - "SetControlData BevelButtonTextPlace failed, %d\n", err ); -#endif - } + sizeof(ControlButtonTextPlacement), (char *) &thePlacement); + } + if (portChanged) { + QDSwapPort(savePort, NULL); } } @@ -1246,7 +1205,8 @@ SetupBevelButton( * *-------------------------------------------------------------- */ -OSErr SetUserPaneDrawProc ( +OSStatus +SetUserPaneDrawProc ( ControlRef control, ControlUserPaneDrawProcPtr upp) { @@ -1274,7 +1234,7 @@ OSErr SetUserPaneDrawProc ( * *-------------------------------------------------------------- */ -OSErr +OSStatus SetUserPaneSetUpSpecialBackgroundProc( ControlRef control, ControlUserPaneBackgroundProcPtr upp) @@ -1310,9 +1270,9 @@ UserPaneDraw( { Rect contrlRect; MacButton * mbPtr; - mbPtr = ( MacButton *)GetControlReference(control); + mbPtr = (MacButton *)(intptr_t)GetControlReference(control); GetControlBounds(control,&contrlRect); - RGBBackColor (&mbPtr->userPaneBackground); + TkMacOSXSetColorInPort(mbPtr->userPaneBackground, 0, NULL); EraseRect (&contrlRect); } @@ -1339,9 +1299,9 @@ UserPaneBackgroundProc( ControlBackgroundPtr info) { MacButton * mbPtr; - mbPtr = ( MacButton *)GetControlReference(control); + mbPtr = (MacButton *)(intptr_t)GetControlReference(control); if (info->colorDevice) { - RGBBackColor (&mbPtr->userPaneBackground); + TkMacOSXSetColorInPort(mbPtr->userPaneBackground, 0, NULL); } } @@ -1389,10 +1349,11 @@ UpdateControlColors(MacButton * mbPtr) } else { xcolor = Tk_3DBorderColor(butPtr->normalBorder); } - TkSetMacColor(xcolor->pixel, &mbPtr->userPaneBackground); + mbPtr->userPaneBackground = xcolor->pixel; return false; -} +} + /* *-------------------------------------------------------------- * @@ -1522,11 +1483,12 @@ TkMacOSXComputeControlParams(TkButton * } else { paramsPtr->procID = kControlBevelButtonLargeBevelProc; } - paramsPtr->isBevel = 1; + paramsPtr->isBevel = 1; } break; } -} +} + /* *---------------------------------------------------------------------- * Index: macosx/tkMacOSXCarbonEvents.c =================================================================== RCS file: /cvsroot/tktoolkit/tk/macosx/tkMacOSXCarbonEvents.c,v retrieving revision 1.13 diff -u -p -r1.13 tkMacOSXCarbonEvents.c --- macosx/tkMacOSXCarbonEvents.c 31 Oct 2006 22:33:34 -0000 1.13 +++ macosx/tkMacOSXCarbonEvents.c 27 Mar 2007 00:55:20 -0000 @@ -11,7 +11,7 @@ * application event target. * * Copyright 2001, Apple Computer, Inc. - * Copyright (c) 2005 Daniel A. Steffen + * Copyright (c) 2005-2007 Daniel A. Steffen * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. @@ -68,15 +68,15 @@ #include "tkMacOSXDebug.h" /* -#ifdef TK_MAC_DEBUG +#ifdef TK_MAC_DEBUG #define TK_MAC_DEBUG_CARBON_EVENTS #endif */ /* Declarations of functions used only in this file */ static OSStatus CarbonEventHandlerProc(EventHandlerCallRef callRef, - EventRef event, void *userData); -static OSStatus InstallStandardApplicationEventHandler(); + EventRef event, void *userData); +static OSStatus InstallStandardApplicationEventHandler(void); static void ExitRaelEventHandlerProc (EventHandlerCallRef, EventRef, void*) __attribute__ ((__noreturn__)); static void CarbonTimerProc(EventLoopTimerRef timer, void *userData); @@ -85,7 +85,11 @@ static void CarbonTimerProc(EventLoopTim static jmp_buf exitRaelJmpBuf; static EventLoopTimerRef carbonTimer = NULL; static int carbonTimerEnabled = 0; +static EventHandlerUPP carbonEventHandlerUPP = NULL; +static Tcl_Interp *carbonEventInterp = NULL; +static int inTrackingLoop = 0; + /* *---------------------------------------------------------------------- * @@ -108,22 +112,22 @@ CarbonEventHandlerProc ( EventRef event, void *userData) { - OSStatus result = eventNotHandledErr; - TkMacOSXEvent macEvent; - MacEventStatus eventStatus; + OSStatus err = eventNotHandledErr; + TkMacOSXEvent macEvent; + MacEventStatus eventStatus; macEvent.eventRef = event; - macEvent.eClass = GetEventClass(macEvent.eventRef); - macEvent.eKind = GetEventKind(macEvent.eventRef); + macEvent.eClass = GetEventClass(event); + macEvent.eKind = GetEventKind(event); macEvent.interp = (Tcl_Interp *) userData; + macEvent.callRef = callRef; bzero(&eventStatus, sizeof(eventStatus)); -#if defined(TK_MAC_DEBUG) && defined(TK_MAC_DEBUG_CARBON_EVENTS) - char buf [256]; +#ifdef TK_MAC_DEBUG_CARBON_EVENTS if (macEvent.eKind != kEventMouseMoved && macEvent.eKind != kEventMouseDragged) { - TkMacOSXCarbonEventToAscii(event, buf); - fprintf(stderr, "CarbonEventHandlerProc started handling %s\n", buf); + TkMacOSXDbgMsg("Started handling %s", + TkMacOSXCarbonEventToAscii(event)); TkMacOSXInitNamedDebugSymbol(HIToolbox, void, _DebugPrintEvent, EventRef inEvent); if (_DebugPrintEvent) { @@ -135,18 +139,18 @@ CarbonEventHandlerProc ( TkMacOSXProcessEvent(&macEvent,&eventStatus); if (eventStatus.stopProcessing) { - result = noErr; + err = noErr; } -#if defined(TK_MAC_DEBUG) && defined(TK_MAC_DEBUG_CARBON_EVENTS) +#ifdef TK_MAC_DEBUG_CARBON_EVENTS if (macEvent.eKind != kEventMouseMoved && macEvent.eKind != kEventMouseDragged) { - fprintf(stderr, - "CarbonEventHandlerProc finished handling %s: %s handled\n", - buf, eventStatus.stopProcessing ? " " : "not"); + TkMacOSXDbgMsg("Finished handling %s: %s handled", + TkMacOSXCarbonEventToAscii(event), + eventStatus.stopProcessing ? " " : "not"); } #endif /* TK_MAC_DEBUG_CARBON_EVENTS */ - return result; + return err; } /* @@ -166,92 +170,81 @@ CarbonEventHandlerProc ( */ MODULE_SCOPE void -TkMacOSXInitCarbonEvents ( +TkMacOSXInitCarbonEvents( Tcl_Interp *interp) { - OSStatus err; const EventTypeSpec dispatcherEventTypes[] = { - {kEventClassMouse, kEventMouseDown}, - {kEventClassMouse, kEventMouseUp}, - {kEventClassMouse, kEventMouseMoved}, - {kEventClassMouse, kEventMouseDragged}, - {kEventClassMouse, kEventMouseWheelMoved}, - {kEventClassWindow, kEventWindowUpdate}, - {kEventClassWindow, kEventWindowActivated}, - {kEventClassWindow, kEventWindowDeactivated}, {kEventClassKeyboard, kEventRawKeyDown}, {kEventClassKeyboard, kEventRawKeyRepeat}, {kEventClassKeyboard, kEventRawKeyUp}, {kEventClassKeyboard, kEventRawKeyModifiersChanged}, {kEventClassKeyboard, kEventRawKeyRepeat}, - {kEventClassApplication, kEventAppActivated}, - {kEventClassApplication, kEventAppDeactivated}, - {kEventClassApplication, kEventAppQuit}, }; const EventTypeSpec applicationEventTypes[] = { {kEventClassMenu, kEventMenuBeginTracking}, {kEventClassMenu, kEventMenuEndTracking}, + {kEventClassMenu, kEventMenuOpening}, + {kEventClassMenu, kEventMenuTargetItem}, {kEventClassCommand, kEventCommandProcess}, {kEventClassCommand, kEventCommandUpdateStatus}, - {kEventClassMouse, kEventMouseWheelMoved}, - {kEventClassWindow, kEventWindowExpanded}, + {kEventClassApplication, kEventAppActivated}, + {kEventClassApplication, kEventAppDeactivated}, + {kEventClassApplication, kEventAppQuit}, {kEventClassApplication, kEventAppHidden}, {kEventClassApplication, kEventAppShown}, {kEventClassApplication, kEventAppAvailableWindowBoundsChanged}, + {kEventClassAppearance, kEventAppearanceScrollBarVariantChanged}, }; - EventHandlerUPP handler = NewEventHandlerUPP(CarbonEventHandlerProc); - - err = InstallStandardApplicationEventHandler(); - if (err != noErr) { -#ifdef TK_MAC_DEBUG - fprintf(stderr, "InstallStandardApplicationEventHandler failed, %d\n", - (int) err); -#endif - } - err = InstallEventHandler(GetEventDispatcherTarget(), handler, - GetEventTypeCount(dispatcherEventTypes), dispatcherEventTypes, - (void *) interp, NULL); - if (err != noErr) { -#ifdef TK_MAC_DEBUG - fprintf(stderr, "InstallEventHandler failed, %d\n", (int) err); -#endif - } - err = InstallEventHandler(GetApplicationEventTarget(), handler, - GetEventTypeCount(applicationEventTypes), applicationEventTypes, - (void *) interp, NULL); - if (err != noErr) { -#ifdef TK_MAC_DEBUG - fprintf(stderr, "InstallEventHandler failed, %d\n", (int) err); -#endif - } -#if defined(TK_MAC_DEBUG) && defined(TK_MAC_DEBUG_CARBON_EVENTS) - TkMacOSXInitNamedDebugSymbol(HIToolbox, void, TraceEventByName, char*); - if (TraceEventByName) { + carbonEventHandlerUPP = NewEventHandlerUPP(CarbonEventHandlerProc); + carbonEventInterp = interp; + ChkErr(InstallStandardApplicationEventHandler); + ChkErr(InstallEventHandler, GetEventDispatcherTarget(), + carbonEventHandlerUPP, GetEventTypeCount(dispatcherEventTypes), + dispatcherEventTypes, (void *) carbonEventInterp, NULL); + ChkErr(InstallEventHandler, GetApplicationEventTarget(), + carbonEventHandlerUPP, GetEventTypeCount(applicationEventTypes), + applicationEventTypes, (void *) carbonEventInterp, NULL); + +#ifdef TK_MAC_DEBUG_CARBON_EVENTS + TkMacOSXInitNamedDebugSymbol(HIToolbox, void, _TraceEventByName, + CFStringRef); + if (_TraceEventByName) { /* Carbon-internal event debugging (c.f. Technote 2124) */ - TraceEventByName("kEventMouseDown"); - TraceEventByName("kEventMouseUp"); - TraceEventByName("kEventMouseWheelMoved"); - TraceEventByName("kEventMouseScroll"); - TraceEventByName("kEventWindowUpdate"); - TraceEventByName("kEventWindowActivated"); - TraceEventByName("kEventWindowDeactivated"); - TraceEventByName("kEventRawKeyDown"); - TraceEventByName("kEventRawKeyRepeat"); - TraceEventByName("kEventRawKeyUp"); - TraceEventByName("kEventRawKeyModifiersChanged"); - TraceEventByName("kEventRawKeyRepeat"); - TraceEventByName("kEventAppActivated"); - TraceEventByName("kEventAppDeactivated"); - TraceEventByName("kEventAppQuit"); - TraceEventByName("kEventMenuBeginTracking"); - TraceEventByName("kEventMenuEndTracking"); - TraceEventByName("kEventCommandProcess"); - TraceEventByName("kEventCommandUpdateStatus"); - TraceEventByName("kEventWindowExpanded"); - TraceEventByName("kEventAppHidden"); - TraceEventByName("kEventAppShown"); - TraceEventByName("kEventAppAvailableWindowBoundsChanged"); + _TraceEventByName(CFSTR("kEventMouseDown")); + _TraceEventByName(CFSTR("kEventMouseUp")); +#if 0 + _TraceEventByName(CFSTR("kEventMouseMoved")); + _TraceEventByName(CFSTR("kEventMouseDragged")); +#endif + _TraceEventByName(CFSTR("kEventMouseWheelMoved")); + _TraceEventByName(CFSTR("kEventMouseScroll")); + _TraceEventByName(CFSTR("kEventRawKeyDown")); + _TraceEventByName(CFSTR("kEventRawKeyRepeat")); + _TraceEventByName(CFSTR("kEventRawKeyUp")); + _TraceEventByName(CFSTR("kEventRawKeyModifiersChanged")); + _TraceEventByName(CFSTR("kEventRawKeyRepeat")); + _TraceEventByName(CFSTR("kEventMenuBeginTracking")); + _TraceEventByName(CFSTR("kEventMenuEndTracking")); + _TraceEventByName(CFSTR("kEventCommandProcess")); + _TraceEventByName(CFSTR("kEventCommandUpdateStatus")); + _TraceEventByName(CFSTR("kEventAppActivated")); + _TraceEventByName(CFSTR("kEventAppDeactivated")); + _TraceEventByName(CFSTR("kEventAppQuit")); + _TraceEventByName(CFSTR("kEventAppHidden")); + _TraceEventByName(CFSTR("kEventAppShown")); + _TraceEventByName(CFSTR("kEventAppAvailableWindowBoundsChanged")); + _TraceEventByName(CFSTR("kEventAppearanceScrollBarVariantChanged")); + _TraceEventByName(CFSTR("kEventWindowActivated")); + _TraceEventByName(CFSTR("kEventWindowDeactivated")); + _TraceEventByName(CFSTR("kEventWindowUpdate")); + _TraceEventByName(CFSTR("kEventWindowExpanded")); + _TraceEventByName(CFSTR("kEventWindowBoundsChanged")); + _TraceEventByName(CFSTR("kEventWindowDragStarted")); + _TraceEventByName(CFSTR("kEventWindowDragCompleted")); + _TraceEventByName(CFSTR("kEventWindowConstrain")); + _TraceEventByName(CFSTR("kEventWindowGetRegion")); + _TraceEventByName(CFSTR("kEventWindowDrawContent")); } #endif /* TK_MAC_DEBUG_CARBON_EVENTS */ } @@ -259,6 +252,50 @@ TkMacOSXInitCarbonEvents ( /* *---------------------------------------------------------------------- * + * TkMacOSXInstallWindowCarbonEventHandler -- + * + * This procedure installs our window CarbonEvent handler. + * + * Results: + * None. + * + * Side effects: + * Handler for Carbon Events is registered. + * + *---------------------------------------------------------------------- + */ + +MODULE_SCOPE void +TkMacOSXInstallWindowCarbonEventHandler( + Tcl_Interp *interp, WindowRef window) +{ + const EventTypeSpec windowEventTypes[] = { + {kEventClassMouse, kEventMouseDown}, + {kEventClassMouse, kEventMouseUp}, + {kEventClassMouse, kEventMouseMoved}, + {kEventClassMouse, kEventMouseDragged}, + {kEventClassMouse, kEventMouseWheelMoved}, + {kEventClassWindow, kEventWindowActivated}, + {kEventClassWindow, kEventWindowDeactivated}, + {kEventClassWindow, kEventWindowUpdate}, + {kEventClassWindow, kEventWindowExpanded}, + {kEventClassWindow, kEventWindowBoundsChanged}, + {kEventClassWindow, kEventWindowDragStarted}, + {kEventClassWindow, kEventWindowDragCompleted}, + {kEventClassWindow, kEventWindowConstrain}, + {kEventClassWindow, kEventWindowGetRegion}, + {kEventClassWindow, kEventWindowDrawContent}, + }; + + ChkErr(InstallEventHandler, GetWindowEventTarget(window), + carbonEventHandlerUPP, GetEventTypeCount(windowEventTypes), + windowEventTypes, (void *) (interp ? interp : carbonEventInterp), + NULL); +} + +/* + *---------------------------------------------------------------------- + * * InstallStandardApplicationEventHandler -- * * This procedure installs the carbon standard application event @@ -274,7 +311,7 @@ TkMacOSXInitCarbonEvents ( */ static OSStatus -InstallStandardApplicationEventHandler() +InstallStandardApplicationEventHandler(void) { /* * This is a hack to workaround missing Carbon API to install the standard @@ -297,16 +334,16 @@ InstallStandardApplicationEventHandler() exitRaelEventHandler = NewEventHandlerUPP( (EventHandlerProcPtr) ExitRaelEventHandlerProc); if (exitRaelEventHandler) { - err = InstallEventHandler(GetEventDispatcherTarget(), + err = ChkErr(InstallEventHandler, GetEventDispatcherTarget(), exitRaelEventHandler, 1, &exitRaelEventType, NULL, &exitRaelEventHandlerRef); } if (err == noErr) { - err = CreateEvent(NULL, kExitRaelEvent, kExitRaelEvent, + err = ChkErr(CreateEvent, NULL, kExitRaelEvent, kExitRaelEvent, GetCurrentEventTime(), kEventAttributeNone, &exitRaelEvent); } if (err == noErr) { - err = PostEventToQueue(GetMainEventQueue(), exitRaelEvent, + err = ChkErr(PostEventToQueue, GetMainEventQueue(), exitRaelEvent, kEventPriorityHigh); } if (err == noErr) { @@ -357,13 +394,38 @@ ExitRaelEventHandlerProc ( /* *---------------------------------------------------------------------- * + * TkMacOSXRunTclEventLoop -- + * + * Process a limited number of tcl events. + * + * Results: + * Returns 1 if events were handled and 0 otherwise. + * + * Side effects: + * Runs the Tcl event loop. + * + *---------------------------------------------------------------------- + */ + +MODULE_SCOPE int +TkMacOSXRunTclEventLoop(void) +{ + int i = 4, result = 0; + + /* Avoid starving main event loop: process at most 4 events. */ + while(--i && Tcl_ServiceAll()) { + result = 1; + } + return result; +} + +/* + *---------------------------------------------------------------------- + * * CarbonTimerProc -- * * This procedure is the carbon timer handler that runs the tcl - * event loop periodically. It does not process TCL_WINDOW_EVENTS - * to avoid reentry issues with Carbon, nor TCL_IDLE_EVENTS since - * it is only intended to be called during short periods of busy - * time such as during menu tracking. + * event loop periodically. * * Results: * None. @@ -379,15 +441,10 @@ CarbonTimerProc ( EventLoopTimerRef timer, void *userData) { - if(carbonTimerEnabled) { - /* Avoid starving main event loop: process at most 4 events. */ - int i = 4; - while(--i && Tcl_DoOneEvent( - TCL_FILE_EVENTS|TCL_TIMER_EVENTS|TCL_DONT_WAIT)) { -#if defined(TK_MAC_DEBUG) && defined(TK_MAC_DEBUG_CARBON_EVENTS) - fprintf(stderr, "Processed tcl event from carbon timer\n"); + if(carbonTimerEnabled > 0 && TkMacOSXRunTclEventLoop()) { +#ifdef TK_MAC_DEBUG_CARBON_EVENTS + TkMacOSXDbgMsg("Processed tcl events from carbon timer"); #endif /* TK_MAC_DEBUG_CARBON_EVENTS */ - } } } @@ -398,9 +455,9 @@ CarbonTimerProc ( * * This procedure installs (if necessary) and starts a carbon * event timer that runs the tcl event loop periodically. - * It should be called whenever a nested carbon event loop is - * run by HIToolbox (e.g. during menutracking) to ensure that - * non-window non-idle tcl events are processed. + * It should be called whenever a nested carbon event loop might + * run by HIToolbox (e.g. during mouse tracking) to ensure that + * tcl events continue to be processed. * * Results: * OS status code. @@ -412,32 +469,25 @@ CarbonTimerProc ( */ MODULE_SCOPE OSStatus -TkMacOSXStartTclEventLoopCarbonTimer() +TkMacOSXStartTclEventLoopCarbonTimer(void) { - OSStatus err; + OSStatus err = noErr; - if(!carbonTimer) { - EventLoopTimerUPP timerUPP = NewEventLoopTimerUPP(CarbonTimerProc); - err = InstallEventLoopTimer(GetMainEventLoop(), kEventDurationNoWait, - 5 * kEventDurationMillisecond, timerUPP, NULL, &carbonTimer); - if (err != noErr) { -#ifdef TK_MAC_DEBUG - fprintf(stderr, "InstallEventLoopTimer failed, %d\n", (int) err); -#endif - } - } else { - err = SetEventLoopTimerNextFireTime(carbonTimer, kEventDurationNoWait); - if (err != noErr) { -#ifdef TK_MAC_DEBUG - fprintf(stderr, "SetEventLoopTimerNextFireTime failed, %d\n", - (int) err); -#endif + if (++carbonTimerEnabled > 0) { + if(!carbonTimer) { + EventLoopTimerUPP timerUPP = NewEventLoopTimerUPP(CarbonTimerProc); + err = ChkErr(InstallEventLoopTimer, GetMainEventLoop(), + 5 * kEventDurationMillisecond, + 5 * kEventDurationMillisecond, + timerUPP, NULL, &carbonTimer); + } else { + err = ChkErr(SetEventLoopTimerNextFireTime, carbonTimer, + 5 * kEventDurationMillisecond); } } - carbonTimerEnabled = 1; return err; } - + /* *---------------------------------------------------------------------- * @@ -456,20 +506,129 @@ TkMacOSXStartTclEventLoopCarbonTimer() */ MODULE_SCOPE OSStatus -TkMacOSXStopTclEventLoopCarbonTimer() +TkMacOSXStopTclEventLoopCarbonTimer(void) { OSStatus err = noErr; - if(carbonTimer) { - err = SetEventLoopTimerNextFireTime(carbonTimer, kEventDurationForever); - if (err != noErr) { -#ifdef TK_MAC_DEBUG - fprintf(stderr, "SetEventLoopTimerNextFireTime failed, %d\n", - (int) err); -#endif + if (--carbonTimerEnabled == 0) { + if(carbonTimer) { + err = ChkErr(SetEventLoopTimerNextFireTime, carbonTimer, + kEventDurationForever); } } - carbonTimerEnabled = 0; return err; } +/* + *---------------------------------------------------------------------- + * + * TkMacOSXTrackingLoop -- + * + * Call with 1 before entering a mouse tracking loop (e.g. window + * resizing or menu tracking) to enable tcl event processing but + * disable carbon event processing (except for update events) + * during the loop, and with 0 after exiting the loop to reset. + * + * Results: + * None. + * + * Side effects: + * None. + * + *---------------------------------------------------------------------- + */ + +MODULE_SCOPE void +TkMacOSXTrackingLoop(int tracking) +{ + static int previousServiceMode = TCL_SERVICE_NONE; + + if (tracking) { + inTrackingLoop++; + previousServiceMode = Tcl_SetServiceMode(TCL_SERVICE_ALL); + TkMacOSXStartTclEventLoopCarbonTimer(); +#ifdef TK_MAC_DEBUG_CARBON_EVENTS + TkMacOSXDbgMsg("Entering tracking loop"); +#endif /* TK_MAC_DEBUG_CARBON_EVENTS */ + } else { + TkMacOSXStopTclEventLoopCarbonTimer(); + previousServiceMode = Tcl_SetServiceMode(previousServiceMode); + inTrackingLoop--; +#ifdef TK_MAC_DEBUG_CARBON_EVENTS + TkMacOSXDbgMsg("Exiting tracking loop"); +#endif /* TK_MAC_DEBUG_CARBON_EVENTS */ + } +} + +/* + *---------------------------------------------------------------------- + * + * TkMacOSXReceiveAndDispatchEvent -- + * + * This receives a carbon event and sends it to the carbon event + * dispatcher. + * + * Results: + * Mac OS status + * + * Side effects: + * This receives and dispatches the next Carbon event. + * + *---------------------------------------------------------------------- + */ +MODULE_SCOPE OSStatus +TkMacOSXReceiveAndDispatchEvent(void) +{ + static EventTargetRef targetRef = NULL; + int numEventTypes = 0; + const EventTypeSpec *eventTypes = NULL; + EventRef eventRef; + OSStatus err; + const EventTypeSpec trackingEventTypes[] = { + {'dniw', kEventWindowUpdate}, + {kEventClassWindow, kEventWindowUpdate}, + }; + + if (inTrackingLoop > 0) { + eventTypes = trackingEventTypes; + numEventTypes = GetEventTypeCount(trackingEventTypes); + } + + /* + * This is a poll, since we have already counted the events coming + * into this routine, and are guaranteed to have one waiting. + */ + + err = ReceiveNextEvent(numEventTypes, eventTypes, + kEventDurationNoWait, true, &eventRef); + if (err == noErr) { +#ifdef TK_MAC_DEBUG_CARBON_EVENTS + UInt32 kind = GetEventKind(eventRef); + + if (kind != kEventMouseMoved && kind != kEventMouseDragged) { + TkMacOSXDbgMsg("Dispatching %s", TkMacOSXCarbonEventToAscii(eventRef)); + TkMacOSXInitNamedDebugSymbol(HIToolbox, void, _DebugPrintEvent, + EventRef inEvent); + if (_DebugPrintEvent) { + /* Carbon-internal event debugging (c.f. Technote 2124) */ + _DebugPrintEvent(eventRef); + } + } +#endif /* TK_MAC_DEBUG_CARBON_EVENTS */ + if (!targetRef) { + targetRef = GetEventDispatcherTarget(); + } + TkMacOSXStartTclEventLoopCarbonTimer(); + err = SendEventToEventTarget(eventRef, targetRef); + TkMacOSXStopTclEventLoopCarbonTimer(); + if (err != noErr && err != eventLoopTimedOutErr + && err != eventNotHandledErr) { + TkMacOSXDbgMsg("SendEventToEventTarget(%s) failed: %ld", + TkMacOSXCarbonEventToAscii(eventRef), err); + } + ReleaseEvent(eventRef); + } else if (err != eventLoopTimedOutErr) { + TkMacOSXDbgMsg("ReceiveNextEvent failed: %ld", err); + } + return err; +} Index: macosx/tkMacOSXClipboard.c =================================================================== RCS file: /cvsroot/tktoolkit/tk/macosx/tkMacOSXClipboard.c,v retrieving revision 1.7 diff -u -p -r1.7 tkMacOSXClipboard.c --- macosx/tkMacOSXClipboard.c 19 Jan 2007 00:36:45 -0000 1.7 +++ macosx/tkMacOSXClipboard.c 27 Mar 2007 00:55:20 -0000 @@ -62,7 +62,7 @@ TkSelGetSelection( * Get the scrap from the Macintosh global clipboard. */ - err = GetCurrentScrap(&scrapRef); + err = ChkErr(GetCurrentScrap, &scrapRef); if (err != noErr) { Tcl_AppendResult(interp, Tk_GetAtomName(tkwin, selection), " GetCurrentScrap failed.", (char *) NULL); @@ -72,7 +72,8 @@ TkSelGetSelection( /* * Try UNICODE first */ - err = GetScrapFlavorSize(scrapRef, kScrapFlavorTypeUnicode, &length); + err = ChkErr(GetScrapFlavorSize, scrapRef, kScrapFlavorTypeUnicode, + &length); if (err == noErr && length > 0) { Tcl_DString ds; char *data; @@ -80,7 +81,7 @@ TkSelGetSelection( buf = (char *) ckalloc(length + 2); buf[length] = 0; buf[length+1] = 0; /* 2-byte unicode null */ - err = GetScrapFlavorData(scrapRef, kScrapFlavorTypeUnicode, + err = ChkErr(GetScrapFlavorData, scrapRef, kScrapFlavorTypeUnicode, &length, buf); if (err == noErr) { Tcl_DStringInit(&ds); @@ -98,7 +99,7 @@ TkSelGetSelection( } } - err = GetScrapFlavorSize(scrapRef, 'TEXT', &length); + err = ChkErr(GetScrapFlavorSize, scrapRef, 'TEXT', &length); if (err != noErr) { Tcl_AppendResult(interp, Tk_GetAtomName(tkwin, selection), " GetScrapFlavorSize failed.", (char *) NULL); @@ -110,7 +111,7 @@ TkSelGetSelection( buf = (char *) ckalloc(length + 1); buf[length] = 0; - err = GetScrapFlavorData(scrapRef, 'TEXT', &length, buf); + err = ChkErr(GetScrapFlavorData, scrapRef, 'TEXT', &length, buf); if (err != noErr) { Tcl_AppendResult(interp, Tk_GetAtomName(tkwin, selection), " GetScrapFlavorData failed.", (char *) NULL); Index: macosx/tkMacOSXColor.c =================================================================== RCS file: /cvsroot/tktoolkit/tk/macosx/tkMacOSXColor.c,v retrieving revision 1.7 diff -u -p -r1.7 tkMacOSXColor.c --- macosx/tkMacOSXColor.c 3 Nov 2006 03:05:03 -0000 1.7 +++ macosx/tkMacOSXColor.c 27 Mar 2007 00:55:21 -0000 @@ -1,13 +1,14 @@ -/* +/* * tkMacOSXColor.c -- * - * This file maintains a database of color values for the Tk - * toolkit, in order to avoid round-trips to the server to - * map color names to pixel values. + * This file maintains a database of color values for the Tk + * toolkit, in order to avoid round-trips to the server to + * map color names to pixel values. * * Copyright (c) 1990-1994 The Regents of the University of California. * Copyright (c) 1994-1996 Sun Microsystems, Inc. * Copyright 2001, Apple Computer, Inc. + * Copyright (c) 2006-2007 Daniel A. Steffen * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. @@ -18,211 +19,509 @@ #include "tkMacOSXInt.h" #include "tkColor.h" -/* Define constants only available on Mac OS X 10.3 or later */ -#if MAC_OS_X_VERSION_MAX_ALLOWED < 1030 - #define kThemeBrushAlternatePrimaryHighlightColor -5 +#if MAC_OS_X_VERSION_MIN_REQUIRED < 1040 +/* Undocumented CG API for creating CGPattern from CGImage */ +extern CGPatternRef CGPatternCreateWithImage(CGImageRef img, int i) WEAK_IMPORT_ATTRIBUTE; #endif -/* - * Default Auxillary Control Record for all controls. This is cached once - * and is updated by the system. We use this to get the default system - * colors used by controls. +struct SystemColorMapEntry { + const char *name; + ThemeBrush brush; + ThemeTextColor textColor; + ThemeBackgroundKind background; +}; /* unsigned char pixelCode; */ + +/* + * Array of system color definitions: the array index is required to equal the + * color's (pixelCode - MIN_PIXELCODE), i.e. the array order needs to be kept + * in sync with the public pixel code values in tkMacOSXPort.h ! + */ + +#define MIN_PIXELCODE 30 +static const struct SystemColorMapEntry systemColorMap[] = { + { "Transparent", 0, 0, 0 }, /* 30: TRANSPARENT_PIXEL */ + { "Highlight", kThemeBrushPrimaryHighlightColor, 0, 0 }, /* 31: HIGHLIGHT_PIXEL */ + { "HighlightSecondary", kThemeBrushSecondaryHighlightColor, 0, 0 }, /* 32: HIGHLIGHT_SECONDARY_PIXEL */ + { "HighlightText", kThemeBrushBlack, 0, 0 }, /* 33: HIGHLIGHT_TEXT_PIXEL */ + { "HighlightAlternate", kThemeBrushAlternatePrimaryHighlightColor, 0, 0 }, /* 34: HIGHLIGHT_ALTERNATE_PIXEL */ + { "ButtonText", 0, kThemeTextColorPushButtonActive, 0 }, /* 35: CONTROL_TEXT_PIXEL */ + { "PrimaryHighlightColor", kThemeBrushPrimaryHighlightColor, 0, 0 }, /* 36 */ + { "ButtonFace", kThemeBrushButtonFaceActive, 0, 0 }, /* 37: CONTROL_BODY_PIXEL */ + { "SecondaryHighlightColor", kThemeBrushSecondaryHighlightColor, 0, 0 }, /* 38 */ + { "ButtonFrame", kThemeBrushButtonFrameActive, 0, 0 }, /* 39: CONTROL_FRAME_PIXEL */ + { "AlternatePrimaryHighlightColor", kThemeBrushAlternatePrimaryHighlightColor, 0, 0 }, /* 40 */ + { "WindowBody", kThemeBrushDocumentWindowBackground, 0, 0 }, /* 41: WINDOW_BODY_PIXEL */ + { "SheetBackground", kThemeBrushSheetBackground, 0, 0 }, /* 42 */ + { "MenuActive", kThemeBrushMenuBackgroundSelected, 0, 0 }, /* 43: MENU_ACTIVE_PIXEL */ + { "Black", kThemeBrushBlack, 0, 0 }, /* 44 */ + { "MenuActiveText", 0, kThemeTextColorMenuItemSelected, 0 }, /* 45: MENU_ACTIVE_TEXT_PIXEL */ + { "White", kThemeBrushWhite, 0, 0 }, /* 46 */ + { "Menu", kThemeBrushMenuBackground, 0, 0 }, /* 47: MENU_BACKGROUND_PIXEL */ + { "DialogBackgroundActive", kThemeBrushDialogBackgroundActive, 0, 0 }, /* 48 */ + { "MenuDisabled", 0, kThemeTextColorMenuItemDisabled, 0 }, /* 49: MENU_DISABLED_PIXEL */ + { "DialogBackgroundInactive", kThemeBrushDialogBackgroundInactive, 0, 0 }, /* 50 */ + { "MenuText", 0, kThemeTextColorMenuItemActive, 0 }, /* 51: MENU_TEXT_PIXEL */ + { "AppearanceColor", 0, 0, 0 }, /* 52: APPEARANCE_PIXEL */ + { "AlertBackgroundActive", kThemeBrushAlertBackgroundActive, 0, 0 }, /* 53 */ + { "AlertBackgroundInactive", kThemeBrushAlertBackgroundInactive, 0, 0 }, /* 54 */ + { "ModelessDialogBackgroundActive", kThemeBrushModelessDialogBackgroundActive, 0, 0 }, /* 55 */ + { "ModelessDialogBackgroundInactive", kThemeBrushModelessDialogBackgroundInactive, 0, 0 }, /* 56 */ + { "UtilityWindowBackgroundActive", kThemeBrushUtilityWindowBackgroundActive, 0, 0 }, /* 57 */ + { "UtilityWindowBackgroundInactive", kThemeBrushUtilityWindowBackgroundInactive, 0, 0 }, /* 58 */ + { "ListViewSortColumnBackground", kThemeBrushListViewSortColumnBackground, 0, 0 }, /* 59 */ + { "ListViewBackground", kThemeBrushListViewBackground, 0, 0 }, /* 60 */ + { "IconLabelBackground", kThemeBrushIconLabelBackground, 0, 0 }, /* 61 */ + { "ListViewSeparator", kThemeBrushListViewSeparator, 0, 0 }, /* 62 */ + { "ChasingArrows", kThemeBrushChasingArrows, 0, 0 }, /* 63 */ + { "DragHilite", kThemeBrushDragHilite, 0, 0 }, /* 64 */ + { "DocumentWindowBackground", kThemeBrushDocumentWindowBackground, 0, 0 }, /* 65 */ + { "FinderWindowBackground", kThemeBrushFinderWindowBackground, 0, 0 }, /* 66 */ + { "ScrollBarDelimiterActive", kThemeBrushScrollBarDelimiterActive, 0, 0 }, /* 67 */ + { "ScrollBarDelimiterInactive", kThemeBrushScrollBarDelimiterInactive, 0, 0 }, /* 68 */ + { "FocusHighlight", kThemeBrushFocusHighlight, 0, 0 }, /* 69 */ + { "PopupArrowActive", kThemeBrushPopupArrowActive, 0, 0 }, /* 70 */ + { "PopupArrowPressed", kThemeBrushPopupArrowPressed, 0, 0 }, /* 71 */ + { "PopupArrowInactive", kThemeBrushPopupArrowInactive, 0, 0 }, /* 72 */ + { "AppleGuideCoachmark", kThemeBrushAppleGuideCoachmark, 0, 0 }, /* 73 */ + { "IconLabelBackgroundSelected", kThemeBrushIconLabelBackgroundSelected, 0, 0 }, /* 74 */ + { "StaticAreaFill", kThemeBrushStaticAreaFill, 0, 0 }, /* 75 */ + { "ActiveAreaFill", kThemeBrushActiveAreaFill, 0, 0 }, /* 76 */ + { "ButtonFrameActive", kThemeBrushButtonFrameActive, 0, 0 }, /* 77 */ + { "ButtonFrameInactive", kThemeBrushButtonFrameInactive, 0, 0 }, /* 78 */ + { "ButtonFaceActive", kThemeBrushButtonFaceActive, 0, 0 }, /* 79 */ + { "ButtonFaceInactive", kThemeBrushButtonFaceInactive, 0, 0 }, /* 80 */ + { "ButtonFacePressed", kThemeBrushButtonFacePressed, 0, 0 }, /* 81 */ + { "ButtonActiveDarkShadow", kThemeBrushButtonActiveDarkShadow, 0, 0 }, /* 82 */ + { "ButtonActiveDarkHighlight", kThemeBrushButtonActiveDarkHighlight, 0, 0 }, /* 83 */ + { "ButtonActiveLightShadow", kThemeBrushButtonActiveLightShadow, 0, 0 }, /* 84 */ + { "ButtonActiveLightHighlight", kThemeBrushButtonActiveLightHighlight, 0, 0 }, /* 85 */ + { "ButtonInactiveDarkShadow", kThemeBrushButtonInactiveDarkShadow, 0, 0 }, /* 86 */ + { "ButtonInactiveDarkHighlight", kThemeBrushButtonInactiveDarkHighlight, 0, 0 }, /* 87 */ + { "ButtonInactiveLightShadow", kThemeBrushButtonInactiveLightShadow, 0, 0 }, /* 88 */ + { "ButtonInactiveLightHighlight", kThemeBrushButtonInactiveLightHighlight, 0, 0 }, /* 89 */ + { "ButtonPressedDarkShadow", kThemeBrushButtonPressedDarkShadow, 0, 0 }, /* 90 */ + { "ButtonPressedDarkHighlight", kThemeBrushButtonPressedDarkHighlight, 0, 0 }, /* 91 */ + { "ButtonPressedLightShadow", kThemeBrushButtonPressedLightShadow, 0, 0 }, /* 92 */ + { "ButtonPressedLightHighlight", kThemeBrushButtonPressedLightHighlight, 0, 0 }, /* 93 */ + { "BevelActiveLight", kThemeBrushBevelActiveLight, 0, 0 }, /* 94 */ + { "BevelActiveDark", kThemeBrushBevelActiveDark, 0, 0 }, /* 95 */ + { "BevelInactiveLight", kThemeBrushBevelInactiveLight, 0, 0 }, /* 96 */ + { "BevelInactiveDark", kThemeBrushBevelInactiveDark, 0, 0 }, /* 97 */ + { "NotificationWindowBackground", kThemeBrushNotificationWindowBackground, 0, 0 }, /* 98 */ + { "MovableModalBackground", kThemeBrushMovableModalBackground, 0, 0 }, /* 99 */ + { "SheetBackgroundOpaque", kThemeBrushSheetBackgroundOpaque, 0, 0 }, /* 100 */ + { "DrawerBackground", kThemeBrushDrawerBackground, 0, 0 }, /* 101 */ + { "ToolbarBackground", kThemeBrushToolbarBackground, 0, 0 }, /* 102 */ + { "SheetBackgroundTransparent", kThemeBrushSheetBackgroundTransparent, 0, 0 }, /* 103 */ + { "MenuBackground", kThemeBrushMenuBackground, 0, 0 }, /* 104 */ + { "Pixel", 0, 0, 0 }, /* 105: PIXEL_MAGIC */ + { "MenuBackgroundSelected", kThemeBrushMenuBackgroundSelected, 0, 0 }, /* 106 */ + { "ListViewOddRowBackground", kThemeBrushListViewOddRowBackground, 0, 0 }, /* 107 */ + { "ListViewEvenRowBackground", kThemeBrushListViewEvenRowBackground, 0, 0 }, /* 108 */ + { "ListViewColumnDivider", kThemeBrushListViewColumnDivider, 0, 0 }, /* 109 */ + { "BlackText", 0, kThemeTextColorBlack, 0 }, /* 110 */ + { "DialogActiveText", 0, kThemeTextColorDialogActive, 0 }, /* 111 */ + { "DialogInactiveText", 0, kThemeTextColorDialogInactive, 0 }, /* 112 */ + { "AlertActiveText", 0, kThemeTextColorAlertActive, 0 }, /* 113 */ + { "AlertInactiveText", 0, kThemeTextColorAlertInactive, 0 }, /* 114 */ + { "ModelessDialogActiveText", 0, kThemeTextColorModelessDialogActive, 0 }, /* 115 */ + { "ModelessDialogInactiveText", 0, kThemeTextColorModelessDialogInactive, 0 }, /* 116 */ + { "WindowHeaderActiveText", 0, kThemeTextColorWindowHeaderActive, 0 }, /* 117 */ + { "WindowHeaderInactiveText", 0, kThemeTextColorWindowHeaderInactive, 0 }, /* 118 */ + { "PlacardActiveText", 0, kThemeTextColorPlacardActive, 0 }, /* 119 */ + { "PlacardInactiveText", 0, kThemeTextColorPlacardInactive, 0 }, /* 120 */ + { "PlacardPressedText", 0, kThemeTextColorPlacardPressed, 0 }, /* 121 */ + { "PushButtonActiveText", 0, kThemeTextColorPushButtonActive, 0 }, /* 122 */ + { "PushButtonInactiveText", 0, kThemeTextColorPushButtonInactive, 0 }, /* 123 */ + { "PushButtonPressedText", 0, kThemeTextColorPushButtonPressed, 0 }, /* 124 */ + { "BevelButtonActiveText", 0, kThemeTextColorBevelButtonActive, 0 }, /* 125 */ + { "BevelButtonInactiveText", 0, kThemeTextColorBevelButtonInactive, 0 }, /* 126 */ + { "BevelButtonPressedText", 0, kThemeTextColorBevelButtonPressed, 0 }, /* 127 */ + { "PopupButtonActiveText", 0, kThemeTextColorPopupButtonActive, 0 }, /* 128 */ + { "PopupButtonInactiveText", 0, kThemeTextColorPopupButtonInactive, 0 }, /* 129 */ + { "PopupButtonPressedText", 0, kThemeTextColorPopupButtonPressed, 0 }, /* 130 */ + { "IconLabelText", 0, kThemeTextColorIconLabel, 0 }, /* 131 */ + { "ListViewText", 0, kThemeTextColorListView, 0 }, /* 132 */ + { "DocumentWindowTitleActiveText", 0, kThemeTextColorDocumentWindowTitleActive, 0 }, /* 133 */ + { "DocumentWindowTitleInactiveText", 0, kThemeTextColorDocumentWindowTitleInactive, 0 }, /* 134 */ + { "MovableModalWindowTitleActiveText", 0, kThemeTextColorMovableModalWindowTitleActive, 0 }, /* 135 */ + { "MovableModalWindowTitleInactiveText",0, kThemeTextColorMovableModalWindowTitleInactive, 0 }, /* 136 */ + { "UtilityWindowTitleActiveText", 0, kThemeTextColorUtilityWindowTitleActive, 0 }, /* 137 */ + { "UtilityWindowTitleInactiveText", 0, kThemeTextColorUtilityWindowTitleInactive, 0 }, /* 138 */ + { "PopupWindowTitleActiveText", 0, kThemeTextColorPopupWindowTitleActive, 0 }, /* 139 */ + { "PopupWindowTitleInactiveText", 0, kThemeTextColorPopupWindowTitleInactive, 0 }, /* 140 */ + { "RootMenuActiveText", 0, kThemeTextColorRootMenuActive, 0 }, /* 141 */ + { "RootMenuSelectedText", 0, kThemeTextColorRootMenuSelected, 0 }, /* 142 */ + { "RootMenuDisabledText", 0, kThemeTextColorRootMenuDisabled, 0 }, /* 143 */ + { "MenuItemActiveText", 0, kThemeTextColorMenuItemActive, 0 }, /* 144 */ + { "MenuItemSelectedText", 0, kThemeTextColorMenuItemSelected, 0 }, /* 145 */ + { "MenuItemDisabledText", 0, kThemeTextColorMenuItemDisabled, 0 }, /* 146 */ + { "PopupLabelActiveText", 0, kThemeTextColorPopupLabelActive, 0 }, /* 147 */ + { "PopupLabelInactiveText", 0, kThemeTextColorPopupLabelInactive, 0 }, /* 148 */ + { "TabFrontActiveText", 0, kThemeTextColorTabFrontActive, 0 }, /* 149 */ + { "TabNonFrontActiveText", 0, kThemeTextColorTabNonFrontActive, 0 }, /* 150 */ + { "TabNonFrontPressedText", 0, kThemeTextColorTabNonFrontPressed, 0 }, /* 151 */ + { "TabFrontInactiveText", 0, kThemeTextColorTabFrontInactive, 0 }, /* 152 */ + { "TabNonFrontInactiveText", 0, kThemeTextColorTabNonFrontInactive, 0 }, /* 153 */ + { "IconLabelSelectedText", 0, kThemeTextColorIconLabelSelected, 0 }, /* 154 */ + { "BevelButtonStickyActiveText", 0, kThemeTextColorBevelButtonStickyActive, 0 }, /* 155 */ + { "BevelButtonStickyInactiveText", 0, kThemeTextColorBevelButtonStickyInactive, 0 }, /* 156 */ + { "NotificationText", 0, kThemeTextColorNotification, 0 }, /* 157 */ + { "SystemDetailText", 0, kThemeTextColorSystemDetail, 0 }, /* 158 */ + { "WhiteText", 0, kThemeTextColorWhite, 0 }, /* 159 */ + { "TabPaneBackground", 0, 0, kThemeBackgroundTabPane }, /* 160 */ + { "PlacardBackground", 0, 0, kThemeBackgroundPlacard }, /* 161 */ + { "WindowHeaderBackground", 0, 0, kThemeBackgroundWindowHeader }, /* 162 */ + { "ListViewWindowHeaderBackground", 0, 0, kThemeBackgroundListViewWindowHeader }, /* 163 */ + { "SecondaryGroupBoxBackground", 0, 0, kThemeBackgroundSecondaryGroupBox }, /* 164 */ + { "MetalBackground", 0, 0, kThemeBackgroundMetal }, /* 165 */ + { NULL, 0, 0, 0 } +}; +#define MAX_PIXELCODE 165 + +/* + *---------------------------------------------------------------------- + * + * GetThemeFromPixelCode -- + * + * When given a pixel code corresponding to a theme system color, + * set one of brush, textColor or background to the corresponding + * Appearance Mgr theme constant. + * + * Results: + * Returns false if not a real pixel, true otherwise. + * + * Side effects: + * None. + * + *---------------------------------------------------------------------- */ -/* - * Stubbed out for OS X -static AuxCtlHandle defaultAuxCtlHandle = NULL; -*/ +static int +GetThemeFromPixelCode(unsigned char code, ThemeBrush *brush, + ThemeTextColor *textColor, ThemeBackgroundKind *background) +{ + if (code >= MIN_PIXELCODE && code <= MAX_PIXELCODE && code != PIXEL_MAGIC) { + *brush = systemColorMap[code - MIN_PIXELCODE].brush; + *textColor = systemColorMap[code - MIN_PIXELCODE].textColor; + *background = systemColorMap[code - MIN_PIXELCODE].background; + } else { + *brush = 0; + *textColor = 0; + *background = 0; + } + if (!*brush && !*textColor && !*background && code != PIXEL_MAGIC) { + return false; + } else { + return true; + } +} + /* - * Forward declarations for procedures defined later in this file: + *---------------------------------------------------------------------- + * + * GetThemeColor -- + * + * Get RGB color for a given system color or pixel value. + * + * Results: + * OSStatus + * + * Side effects: + * None. + * + *---------------------------------------------------------------------- */ -static int GetControlPartColor _ANSI_ARGS_((short part, RGBColor *macColor)); -static int GetMenuPartColor _ANSI_ARGS_((int part, RGBColor *macColor)); -static int GetWindowPartColor _ANSI_ARGS_((short part, RGBColor *macColor)); +static OSStatus +GetThemeColor(unsigned long pixel, ThemeBrush brush, ThemeTextColor textColor, + ThemeBackgroundKind background, RGBColor *c) +{ + OSStatus err = noErr; + + if (brush) { + err = ChkErr(GetThemeBrushAsColor, + brush == kThemeBrushMenuBackgroundSelected ? + kThemeBrushFocusHighlight : brush, 32, true, c); + } else if (textColor) { + err = ChkErr(GetThemeTextColor, textColor, 32, true, c); + } else { + c->red = ((pixel >> 16) & 0xff) << 8; + c->green = ((pixel >> 8) & 0xff) << 8; + c->blue = ((pixel ) & 0xff) << 8; + } + return err; +} /* *---------------------------------------------------------------------- * * TkSetMacColor -- * - * Populates a Macintosh RGBColor structure from a X style - * pixel value. + * Populates a Macintosh RGBColor structure from a X style + * pixel value. * * Results: - * Returns false if not a real pixel, true otherwise. + * Returns false if not a real pixel, true otherwise. * * Side effects: - * The variable macColor is updated to the pixels value. + * The variable macColor is updated to the pixels value. * *---------------------------------------------------------------------- */ int TkSetMacColor( - unsigned long pixel, /* Pixel value to convert. */ - RGBColor *macColor) /* Mac color struct to modify. */ + unsigned long pixel, /* Pixel value to convert. */ + RGBColor *macColor) /* Mac color struct to modify. */ { - OSStatus err; - - switch (pixel >> 24) { - case HIGHLIGHT_PIXEL: - err = GetThemeBrushAsColor(kThemeBrushPrimaryHighlightColor, - 32, true, macColor); - if (err != noErr) { - LMGetHiliteRGB(macColor); - } - return true; - case HIGHLIGHT_SECONDARY_PIXEL: - err = GetThemeBrushAsColor(kThemeBrushSecondaryHighlightColor, - 32, true, macColor); - if (err != noErr) { - LMGetHiliteRGB(macColor); - } - return true; - case HIGHLIGHT_ALTERNATE_PIXEL: - err = GetThemeBrushAsColor(kThemeBrushAlternatePrimaryHighlightColor, - 32, true, macColor); - if (err != noErr) { - LMGetHiliteRGB(macColor); - } - return true; - case HIGHLIGHT_TEXT_PIXEL: - err = GetThemeBrushAsColor(kThemeBrushPrimaryHighlightColor, - 32, true, macColor); - if (err != noErr) { - LMGetHiliteRGB(macColor); - } - if ((macColor->red == 0) && (macColor->green == 0) - && (macColor->blue == 0)) { - macColor->red = macColor->green = macColor->blue = 0xFFFF; - } else { - macColor->red = macColor->green = macColor->blue = 0; - } - return true; - case CONTROL_TEXT_PIXEL: - GetControlPartColor(cTextColor, macColor); - return true; - case CONTROL_BODY_PIXEL: - GetControlPartColor(cBodyColor, macColor); - return true; - case CONTROL_FRAME_PIXEL: - GetControlPartColor(cFrameColor, macColor); - return true; - case WINDOW_BODY_PIXEL: - GetWindowPartColor(wContentColor, macColor); - return true; - case MENU_ACTIVE_PIXEL: - case MENU_ACTIVE_TEXT_PIXEL: - case MENU_BACKGROUND_PIXEL: - case MENU_DISABLED_PIXEL: - case MENU_TEXT_PIXEL: - return GetMenuPartColor((pixel >> 24), macColor); - case APPEARANCE_PIXEL: - return false; - case PIXEL_MAGIC: - default: - macColor->blue = (unsigned short) ((pixel & 0xFF) << 8); - macColor->green = (unsigned short) (((pixel >> 8) & 0xFF) << 8); - macColor->red = (unsigned short) (((pixel >> 16) & 0xFF) << 8); - return true; + OSStatus err = -1; + ThemeBrush brush; + ThemeTextColor textColor; + ThemeBackgroundKind background; + + if (GetThemeFromPixelCode((pixel >> 24) & 0xff, &brush, &textColor, + &background)) { + err = ChkErr(GetThemeColor, pixel, brush, textColor, background, + macColor); } + return (err == noErr); } -#if !TK_DRAW_IN_CONTEXT /* *---------------------------------------------------------------------- * - * TkMacOSXCompareColors -- + * TkMacOSXSetColorInPort -- * - * On Mac, color codes may specify symbolic values like "highlight - * foreground", but we really need the actual values to compare. - * Maybe see also: "TIP #154: Add Named Colors to Tk". + * Sets fore or back color in the current QD port from an X pixel + * value, and if the pixel code indicates a system color, sets + * the corresponding brush, textColor or background via + * Appearance mgr APIs. * * Results: - * Returns true if both colors are the same, false otherwise. + * None. * * Side effects: - * None. + * If penPat is non-NULL it is set to the forground color/pattern. * *---------------------------------------------------------------------- */ -int -TkMacOSXCompareColors( - unsigned long c1, - unsigned long c2) +void +TkMacOSXSetColorInPort(unsigned long pixel, int fg, PixPatHandle penPat) { - RGBColor col1, col2; - return TkSetMacColor(c1,&col1) && - TkSetMacColor(c1,&col2) && - !memcmp(&col1,&col2,sizeof(col1)); + OSStatus err; + RGBColor c; + ThemeBrush brush; + ThemeTextColor textColor; + ThemeBackgroundKind background; + + if (GetThemeFromPixelCode((pixel >> 24) & 0xff, &brush, &textColor, + &background)) { + CGrafPtr port; + + GetPort(&port); + err = ChkErr(GetThemeColor, pixel, brush, textColor, background, &c); + if (err == noErr) { + if (fg) { + RGBForeColor(&c); + if (penPat) { + MakeRGBPat(penPat, &c); + } + } else { + RGBBackColor(&c); + } + } + err = -1; + if (brush) { + err = ChkErr(SetThemeBackground, + brush == kThemeBrushMenuBackgroundSelected ? + kThemeBrushFocusHighlight : brush, 32, true); + } else if (textColor && fg) { + err = ChkErr(SetThemeTextColor, textColor, 32, true); + } else if (background) { + Rect bounds; + + GetPortBounds(port, &bounds); + err = ChkErr(ApplyThemeBackground, background, &bounds, + kThemeStateActive, 32, true); + } + if (penPat && err == noErr && !textColor) { + GetPortBackPixPat(port, penPat); + } + } } -#endif /* !TK_DRAW_IN_CONTEXT */ /* *---------------------------------------------------------------------- * - * Stub functions -- + * TkMacOSXSetColorInContext -- * - * These functions are just stubs for functions that either - * don't make sense on the Mac or have yet to be implemented. + * Sets fill and stroke color in the given CG context from an X + * pixel value, or if the pixel code indicates a system color, + * sets the corresponding brush, textColor or background via + * HITheme APIs if available or Appearance mgr APIs. * * Results: - * None. + * None. * * Side effects: - * These calls do nothing - which may not be expected. + * None. * *---------------------------------------------------------------------- */ -Status -XAllocColor( - Display *display, /* Display. */ - Colormap map, /* Not used. */ - XColor *colorPtr) /* XColor struct to modify. */ -{ - display->request++; - colorPtr->pixel = TkpGetPixel(colorPtr); - return 1; -} - -Colormap -XCreateColormap( - Display *display, /* Display. */ - Window window, /* X window. */ - Visual *visual, /* Not used. */ - int alloc) /* Not used. */ -{ - static Colormap index = 1; - - /* - * Just return a new value each time. - */ - return index++; -} - void -XFreeColormap( - Display* display, /* Display. */ - Colormap colormap) /* Colormap. */ +TkMacOSXSetColorInContext(unsigned long pixel, CGContextRef context) { -} + OSStatus err = -1; + RGBColor c; + ThemeBrush brush; + ThemeTextColor textColor; + ThemeBackgroundKind background; + + if (GetThemeFromPixelCode((pixel >> 24) & 0xff, &brush, &textColor, + &background)) { +#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1040 + if (brush) { + if (1 +#if MAC_OS_X_VERSION_MIN_REQUIRED < 1040 + && HIThemeSetFill != NULL && HIThemeSetStroke != NULL +#endif + ) { + err = ChkErr(HIThemeSetFill, brush, NULL, context, + kHIThemeOrientationNormal); + if (err == noErr) { + err = ChkErr(HIThemeSetStroke, brush, NULL, context, + kHIThemeOrientationNormal); + } + } + } else if (textColor) { + if (1 +#if MAC_OS_X_VERSION_MIN_REQUIRED < 1040 + && HIThemeSetTextFill != NULL +#endif + ) { + err = ChkErr(HIThemeSetTextFill, textColor, NULL, context, + kHIThemeOrientationNormal); + } + } else +#endif /* MAC_OS_X_VERSION_MAX_ALLOWED >= 1040 */ +#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1030 + if (background) { + if (1 +#if MAC_OS_X_VERSION_MIN_REQUIRED < 1030 + && CGContextGetClipBoundingBox != NULL + && HIThemeApplyBackground != NULL + && &kHIToolboxVersionNumber != NULL /* c.f. QA1377 */ + && kHIToolboxVersionNumber >= kHIToolboxVersionNumber10_3 +#endif + ) { + CGRect rect = CGContextGetClipBoundingBox(context); + HIThemeBackgroundDrawInfo info = { 0, kThemeStateActive, + background }; -void -XFreeColors( - Display* display, /* Display. */ - Colormap colormap, /* Colormap. */ - unsigned long* pixels, /* Array of pixels. */ - int npixels, /* Number of pixels. */ - unsigned long planes) /* Number of pixel planes. */ -{ - /* - * The Macintosh version of Tk uses TrueColor. Nothing - * needs to be done to release colors as there really is - * no colormap in the Tk sense. - */ + err = ChkErr(HIThemeApplyBackground, &rect, &info, context, + kHIThemeOrientationNormal); + } + } +#endif /* MAC_OS_X_VERSION_MAX_ALLOWED >= 1030 */ + if (err == noErr) { + return; + } +#if MAC_OS_X_VERSION_MIN_REQUIRED < 1040 + /* + * Convert Appearance theme pattern to CGPattern: + */ + if ((brush || background) && CGPatternCreateWithImage != NULL) { + static PixPatHandle pixpat = NULL; + static GWorldPtr patGWorld = NULL; + static uint32_t bitmapInfo = 0; + const short patDim = 16; + const Rect bounds = {0, 0, patDim, patDim}; + CGrafPtr savePort; + Boolean portChanged; + PixMapHandle pixmap; + long rowbytes; + CGImageRef img; + CGColorSpaceRef rgbCspace; + CGDataProviderRef provider; + + if (!pixpat) { + pixpat = NewPixPat(); + err = ChkErr(NewGWorld, &patGWorld, 32, &bounds, NULL, NULL, 0 +#ifdef __LITTLE_ENDIAN__ + | kNativeEndianPixMap +#endif + ); + if (!pixpat || err != noErr || !patGWorld) { + Tcl_Panic("TkMacOSXSetColorInContext(): " + "pattern initialization failed !"); + } + bitmapInfo = +#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1040 + (1 +#if MAC_OS_X_VERSION_MIN_REQUIRED < 1040 + && &kHIToolboxVersionNumber != NULL + && kHIToolboxVersionNumber >= kHIToolboxVersionNumber10_4 +#endif + ) ? kCGBitmapByteOrder32Host : +#endif + 0; + } + portChanged = QDSwapPort(patGWorld, &savePort); + TkMacOSXSetColorInPort(pixel, 1, pixpat); +#ifdef TK_MAC_DEBUG + Rect patBounds; + GetPixBounds((**pixpat).patMap, &patBounds); + if (patBounds.right > patDim || patBounds.bottom > patDim) { + Tcl_Panic("TkMacOSXSetColorInContext(): " + "pattern larger than expected !"); + } +#endif /* TK_MAC_DEBUG */ + FillCRect(&bounds, pixpat); + if (portChanged) { + QDSwapPort(savePort, NULL); + } + pixmap = GetPortPixMap(patGWorld); + rowbytes = GetPixRow