Index: ChangeLog =================================================================== RCS file: /cvsroot/tktoolkit/tk/ChangeLog,v retrieving revision 1.1594 diff -u -p -r1.1594 ChangeLog --- ChangeLog 13 Apr 2007 14:51:17 -0000 1.1594 +++ ChangeLog 15 Apr 2007 14:03:19 -0000 @@ -1,7 +1,327 @@ -2007-04-13 Donal K. Fellows +2007-04-12 Daniel Steffen - * macosx/tkMacOSXInt.h (LOG_MSG, LOG_ON_ERROR): Added macros to make - the OSX code much less #ifdef-full. + * 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.xcode/project.pbxproj: use Appearance Mgr & ThemeText + * macosx/Wish.xcodeproj/project.pbxproj: APIs to mimic native MDEF as + * unix/Makefile.in: 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/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: + + * macosx/tkMacOSXSend.c: remove duplicate/unused declarations + * macosx/tkMacOSXXStubs.c: + + * macosx/tkMacOSXDebug.c: const fixes. + * macosx/tkMacOSXInit.c: + * macosx/tkMacOSXTest.c: + * macosx/tkMacOSXWm.c: + * macosx/tkMacOSXXStubs.c: + + * macosx/Wish-Info.plist.in: add tcl document extensions/mime types and + LSMinimumSystemVersion, LSRequiresCarbon & NSAppleScriptEnabled keys. + + * macosx/Wish-Common.xcconfig: add Wish's Info.plist as __info_plist + section to tktest; enable more warnings. + + * macosx/Wish.xcodeproj/project.pbxproj: add 'DebugMemCompile' build + configuration that calls configure with --enable-symbols=all; disable + configure check for __attribute__((__visibility__("hidden"))) in Debug + configuration to restore availability of ZeroLink. + + * macosx/Wish-Common.xcconfig: fix whitespace. + * macosx/Wish-Debug.xcconfig: + * macosx/Wish-Release.xcconfig: + * macosx/tkMacOSXConfig.c: + * macosx/tkMacOSXCursors.r: + * macosx/tkMacOSXKeyboard.c: + * macosx/tkMacOSXSend.c: + * macosx/ttkMacOSXTheme.c: + + * macosx/GNUmakefile: fix/add copyright and license refs. + * macosx/Tk-Info.plist.in: + * macosx/Wish-Info.plist.in: + * macosx/Wish.xcode/project.pbxproj: + * macosx/Wish.xcodeproj/project.pbxproj: + * macosx/tkMacOSX.h: + + * unix/configure.in: install license.terms into Tk.framework. + * unix/configure: autoconf-2.59 + + * 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]. + * doc/ttk_image.n: fix 'make html' warning. 2007-04-12 Jeff Hobbs @@ -12,9 +332,10 @@ * win/ttkWinMonitor.c, win/ttkWinXPTheme.c: Re-sync with Tile codebase so patches can flow back and forth. + * win/ttkWinXPTheme.c: Skip OS version test, should work on Vista/Aero - now as well as XP [Fixes #1687299, thanks to George Petasis for - tracking this down]. + now as well as XP. Fixes [Bug 1687299], thanks to George Petasis for + tracking this down. 2007-03-21 Joe English 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 15 Apr 2007 14:03:19 -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 15 Apr 2007 14:03:19 -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 15 Apr 2007 14:03:19 -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 15 Apr 2007 14:03:20 -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/ttk_image.n =================================================================== RCS file: /cvsroot/tktoolkit/tk/doc/ttk_image.n,v retrieving revision 1.5 diff -u -p -r1.5 ttk_image.n --- doc/ttk_image.n 13 Dec 2006 23:04:33 -0000 1.5 +++ doc/ttk_image.n 15 Apr 2007 14:03:20 -0000 @@ -37,7 +37,6 @@ See \fBIMAGE STRETCHING\fR, below. Specifies a minimum height for the element. If less than zero, the base image's height is used as a default. .TP -.TP \fB-padding\fR \fIpadding\fR Specifies the element's interior padding. Defaults to \fI-border\fR if not specified. 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 15 Apr 2007 14:03:20 -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 15 Apr 2007 14:03:20 -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 15 Apr 2007 14:03:22 -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 15 Apr 2007 14:03:24 -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 15 Apr 2007 14:03:25 -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 15 Apr 2007 14:03:26 -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 15 Apr 2007 14:03:27 -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 15 Apr 2007 14:03:28 -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 15 Apr 2007 14:03:34 -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 15 Apr 2007 14:03:34 -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 15 Apr 2007 14:03:34 -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 15 Apr 2007 14:03:34 -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 15 Apr 2007 14:03:34 -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 15 Apr 2007 14:03:34 -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 15 Apr 2007 14:03:35 -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 15 Apr 2007 14:03:35 -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 15 Apr 2007 14:03:35 -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 15 Apr 2007 14:03:35 -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 15 Apr 2007 14:03:35 -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/GNUmakefile =================================================================== RCS file: /cvsroot/tktoolkit/tk/macosx/GNUmakefile,v retrieving revision 1.7 diff -u -p -r1.7 GNUmakefile --- macosx/GNUmakefile 16 Oct 2006 17:36:18 -0000 1.7 +++ macosx/GNUmakefile 15 Apr 2007 14:03:35 -0000 @@ -4,6 +4,11 @@ # uses the standard unix build system in tk/unix (which can be used directly instead of this # if you are not using the tk/macosx projects). # +# Copyright (c) 2002-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. +# # RCS: @(#) $Id: GNUmakefile,v 1.7 2006/10/16 17:36:18 das Exp $ # ######################################################################################################## Index: macosx/Tk-Info.plist.in =================================================================== RCS file: /cvsroot/tktoolkit/tk/macosx/Tk-Info.plist.in,v retrieving revision 1.1 diff -u -p -r1.1 Tk-Info.plist.in --- macosx/Tk-Info.plist.in 23 May 2005 20:24:59 -0000 1.1 +++ macosx/Tk-Info.plist.in 15 Apr 2007 14:03:35 -0000 @@ -1,5 +1,13 @@ + CFBundleDevelopmentRegion @@ -7,14 +15,17 @@ CFBundleExecutable @TK_LIB_FILE@ CFBundleGetInfoString - Tk @TK_WINDOWINGSYSTEM@ Library @TK_VERSION@, Copyright © @TK_YEAR@ Tcl Core Team. -Initial MacOS X Port by Jim Ingham <jingham@apple.com> & Ian Reid, Copyright © 2001-2002, Apple Computer, Inc. + Tk @TK_WINDOWINGSYSTEM@ @TK_VERSION@@TK_PATCH_LEVEL@, +Copyright © @TK_YEAR@ Tcl Core Team, +Copyright © 2002-@TK_YEAR@ Daniel A. Steffen, +Initial MacOS X Port by Jim Ingham & Ian Reid, +Copyright © 2001-2002, Apple Computer, Inc. CFBundleIdentifier com.tcltk.tklibrary CFBundleInfoDictionaryVersion 6.0 CFBundleName - Tk @TK_WINDOWINGSYSTEM@ Library @TK_VERSION@ + Tk @TK_WINDOWINGSYSTEM@ @TK_VERSION@ CFBundlePackageType FMWK CFBundleShortVersionString 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 15 Apr 2007 14:03:35 -0000 @@ -1,4 +1,4 @@ -// +// // Wish-Common.xcconfig -- // // This file contains the Xcode build settings comon to all @@ -14,7 +14,7 @@ HEADER_SEARCH_PATHS = $(TK_SRCROOT)/generic $(TK_SRCROOT)/xlib $(DERIVED_FILE_DIR)/tcl $(DERIVED_FILE_DIR)/tk $(HEADER_SEARCH_PATHS) REZ_SEARCH_PATHS = $(TK_SRCROOT)/generic $(TCL_SRCROOT)/generic $(REZ_SEARCH_PATHS) -OTHER_LDFLAGS = -headerpad_max_install_names -sectcreate __TEXT __tk_rsrc $(REZ_COLLECTOR_DIR)/$(PRODUCT_NAME).rsrc $(OTHER_LDFLAGS) +OTHER_LDFLAGS = -headerpad_max_install_names -sectcreate __TEXT __tk_rsrc $(REZ_COLLECTOR_DIR)/$(PRODUCT_NAME).rsrc -sectcreate __TEXT __info_plist $(DERIVED_FILE_DIR)/tk/Wish-Info.plist $(OTHER_LDFLAGS) INSTALL_PATH = "$(BINDIR)" GCC_PREFIX_HEADER = $(DERIVED_FILE_DIR)/tk/tkConfig.h OTHER_CFLAGS = -imacros $(DERIVED_FILE_DIR)/tcl/tclConfig.h $(OTHER_CFLAGS) @@ -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/Wish-Debug.xcconfig =================================================================== RCS file: /cvsroot/tktoolkit/tk/macosx/Wish-Debug.xcconfig,v retrieving revision 1.1 diff -u -p -r1.1 Wish-Debug.xcconfig --- macosx/Wish-Debug.xcconfig 28 Jan 2007 01:42:16 -0000 1.1 +++ macosx/Wish-Debug.xcconfig 15 Apr 2007 14:03:35 -0000 @@ -1,4 +1,4 @@ -// +// // Wish-Debug.xcconfig -- // // This file contains the Xcode build settings for all Debug Index: macosx/Wish-Info.plist.in =================================================================== RCS file: /cvsroot/tktoolkit/tk/macosx/Wish-Info.plist.in,v retrieving revision 1.1 diff -u -p -r1.1 Wish-Info.plist.in --- macosx/Wish-Info.plist.in 23 May 2005 20:24:59 -0000 1.1 +++ macosx/Wish-Info.plist.in 15 Apr 2007 14:03:35 -0000 @@ -1,5 +1,13 @@ + CFBundleDevelopmentRegion @@ -9,13 +17,21 @@ CFBundleTypeExtensions + tcl + TCL * + CFBundleTypeMIMETypes + + application/x-tcl + text/plain + CFBundleTypeName NSStringPboardType CFBundleTypeOSTypes TEXT + **** CFBundleTypeRole Viewer @@ -24,8 +40,11 @@ CFBundleExecutable Wish CFBundleGetInfoString - Wish Shell @TK_VERSION@, Copyright © @TK_YEAR@ Tcl Core Team. -Initial MacOS X Port by Jim Ingham <jingham@apple.com> & Ian Reid, Copyright © 2001-2002, Apple Computer, Inc. + Wish Shell @TK_VERSION@@TK_PATCH_LEVEL@, +Copyright © @TK_YEAR@ Tcl Core Team, +Copyright © 2002-@TK_YEAR@ Daniel A. Steffen, +Initial MacOS X Port by Jim Ingham & Ian Reid, +Copyright © 2001-2002, Apple Computer, Inc. CFBundleIconFile Wish.icns CFBundleIdentifier @@ -42,5 +61,11 @@ Initial MacOS X Port by Jim Ingham <j WiSH CFBundleVersion @TK_VERSION@@TK_PATCH_LEVEL@ + LSMinimumSystemVersion + 10.2.0 + LSRequiresCarbon + + NSAppleScriptEnabled + Index: macosx/Wish-Release.xcconfig =================================================================== RCS file: /cvsroot/tktoolkit/tk/macosx/Wish-Release.xcconfig,v retrieving revision 1.1 diff -u -p -r1.1 Wish-Release.xcconfig --- macosx/Wish-Release.xcconfig 28 Jan 2007 01:42:16 -0000 1.1 +++ macosx/Wish-Release.xcconfig 15 Apr 2007 14:03:35 -0000 @@ -1,4 +1,4 @@ -// +// // Wish-Release.xcconfig -- // // This file contains the Xcode build settings for all Release 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 15 Apr 2007 14:03:35 -0000 @@ -1,11 +1,10 @@ /* * tkAboutDlg.r -- * - * This file creates resources for use in most Tk applications. - * This is designed to be an example of using the Tcl/Tk - * libraries in a Macintosh Application. + * This file creates resources for the Tk "About Box" dialog. * * 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 +33,7 @@ resource 'DLOG' (128, "About Box", purgeable) { {60, 40, 332, 404}, - movableDBoxProc, + kWindowMovableModalDialogProc, visible, noGoAway, 0x0, @@ -48,8 +47,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 +58,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/tkMacOSX.h =================================================================== RCS file: /cvsroot/tktoolkit/tk/macosx/tkMacOSX.h,v retrieving revision 1.4 diff -u -p -r1.4 tkMacOSX.h --- macosx/tkMacOSX.h 24 Mar 2006 14:58:00 -0000 1.4 +++ macosx/tkMacOSX.h 15 Apr 2007 14:03:35 -0000 @@ -5,6 +5,7 @@ * * Copyright (c) 1995-1997 Sun Microsystems, Inc. * Copyright 2001, Apple Computer, Inc. + * 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. Index: macosx/tkMacOSXAETE.r =================================================================== RCS file: /cvsroot/tktoolkit/tk/macosx/tkMacOSXAETE.r,v retrieving revision 1.1 diff -u -p -r1.1 tkMacOSXAETE.r --- macosx/tkMacOSXAETE.r 25 Feb 2003 18:24:31 -0000 1.1 +++ macosx/tkMacOSXAETE.r 15 Apr 2007 14:03:35 -0000 @@ -1,11 +1,8 @@ /* * tclMacAETE.r -- * - * This file creates the Apple Event Terminology resources - * for use Tcl and Tk. It is not used in the Simple Tcl shell - * since SIOUX does not support AppleEvents. An example of its - * use in Tcl is the TclBGOnly project. And it is used in all the - * Tk Shells. + * This file creates the Apple Event Terminology resources + * for use by Wish.app. * * Copyright (c) 1997 Sun Microsystems, Inc. * Index: macosx/tkMacOSXBitmap.c =================================================================== RCS file: /cvsroot/tktoolkit/tk/macosx/tkMacOSXBitmap.c,v retrieving revision 1.5 diff -u -p -r1.5 tkMacOSXBitmap.c --- macosx/tkMacOSXBitmap.c 13 Apr 2007 14:51:17 -0000 1.5 +++ macosx/tkMacOSXBitmap.c 15 Apr 2007 14:03:35 -0000 @@ -5,32 +5,31 @@ * * 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. + * See the file "license.terms" for information on usage and redistribution + * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkMacOSXBitmap.c,v 1.5 2007/04/13 14:51:17 dkf Exp $ + * RCS: @(#) $Id: tkMacOSXBitmap.c,v 1.4 2006/03/24 14:58:01 das Exp $ */ #include "tkMacOSXInt.h" /* - * Depending on the resource type there are different ways to draw native - * icons. + * Depending on the resource type there are different ways to + * draw native icons. */ - -#define TYPE1 0 /* Family icon suite. */ -#define TYPE2 1 /* ICON resource. */ -#define TYPE3 2 /* cicn resource. */ +#define TYPE1 0 /* Family icon suite. */ +#define TYPE2 1 /* ICON resource. */ +#define TYPE3 2 /* cicn resource. */ /* - * This data structure describes the id and type of a given icon. It is used - * as the source for native icons. + * This data structure describes the id and type of a given icon. + * It is used as the source for native icons. */ - typedef struct { - int id; /* Resource Id for Icon. */ - long int type; /* Type of icon. */ + int id; /* Resource Id for Icon. */ + long int type; /* Type of icon. */ } NativeIcon; /* @@ -38,35 +37,35 @@ typedef struct { */ typedef struct { - char *name; /* Name of icon. */ - long int type; /* Type of icon. */ - int id; /* Id of icon. */ - int size; /* Size of icon. */ + const char *name; /* Name of icon. */ + long int type; /* Type of icon. */ + int id; /* Id of icon. */ + int size; /* Size of icon. */ } BuiltInIcon; /* - * This array mapps a string name to the supported builtin icons on the - * Macintosh. + * This array mapps a string name to the supported builtin icons + * on the Macintosh. */ static BuiltInIcon builtInIcons[] = { - {"document", TYPE1, kGenericDocumentIconResource, 32}, - {"stationery", TYPE1, kGenericStationeryIconResource, 32}, - {"edition", TYPE1, kGenericEditionFileIconResource, 32}, - {"application", TYPE1, kGenericApplicationIconResource, 32}, - {"accessory", TYPE1, kGenericDeskAccessoryIconResource, 32}, - {"folder", TYPE1, kGenericFolderIconResource, 32}, - {"pfolder", TYPE1, kPrivateFolderIconResource, 32}, - {"trash", TYPE1, kTrashIconResource, 32}, - {"floppy", TYPE1, kFloppyIconResource, 32}, - {"ramdisk", TYPE1, kGenericRAMDiskIconResource, 32}, - {"cdrom", TYPE1, kGenericCDROMIconResource, 32}, - {"preferences", TYPE1, kGenericPreferencesIconResource, 32}, - {"querydoc", TYPE1, kGenericQueryDocumentIconResource, 32}, - {"stop", TYPE2, kStopIcon, 32}, - {"note", TYPE2, kNoteIcon, 32}, - {"caution", TYPE2, kCautionIcon, 32}, - {(char *) NULL, 0, 0, 0} + {"document", TYPE1, kGenericDocumentIconResource, 32}, + {"stationery", TYPE1, kGenericStationeryIconResource, 32}, + {"edition", TYPE1, kGenericEditionFileIconResource, 32}, + {"application", TYPE1, kGenericApplicationIconResource, 32}, + {"accessory", TYPE1, kGenericDeskAccessoryIconResource, 32}, + {"folder", TYPE1, kGenericFolderIconResource, 32}, + {"pfolder", TYPE1, kPrivateFolderIconResource, 32}, + {"trash", TYPE1, kTrashIconResource, 32}, + {"floppy", TYPE1, kFloppyIconResource, 32}, + {"ramdisk", TYPE1, kGenericRAMDiskIconResource, 32}, + {"cdrom", TYPE1, kGenericCDROMIconResource, 32}, + {"preferences", TYPE1, kGenericPreferencesIconResource, 32}, + {"querydoc", TYPE1, kGenericQueryDocumentIconResource, 32}, + {"stop", TYPE2, kStopIcon, 32}, + {"note", TYPE2, kNoteIcon, 32}, + {"caution", TYPE2, kCautionIcon, 32}, + {(char *) NULL, 0, 0, 0} }; /* @@ -74,46 +73,46 @@ static BuiltInIcon builtInIcons[] = { * * TkpDefineNativeBitmaps -- * - * Add native bitmaps. + * Add native bitmaps. * * Results: - * A standard Tcl result. If an error occurs then TCL_ERROR is returned - * and a message is left in the interp's result. + * A standard Tcl result. If an error occurs then TCL_ERROR is + * returned and a message is left in the interp's result. * * Side effects: - * "Name" is entered into the bitmap table and may be used from here on - * to refer to the given bitmap. + * "Name" is entered into the bitmap table and may be used from + * here on to refer to the given bitmap. * *---------------------------------------------------------------------- */ void -TkpDefineNativeBitmaps(void) +TkpDefineNativeBitmaps() { - Tcl_HashTable *tablePtr = TkGetBitmapPredefTable(); + int new; + Tcl_HashEntry *predefHashPtr; + TkPredefBitmap *predefPtr; + const char * name; BuiltInIcon *builtInPtr; - - for (builtInPtr=builtInIcons ; builtInPtr->name!=NULL ; builtInPtr++) { - Tcl_HashEntry *predefHashPtr; - CONST char *name; - int isNew; - - name = Tk_GetUid(builtInPtr->name); - predefHashPtr = Tcl_CreateHashEntry(tablePtr, name, &isNew); - if (isNew) { - TkPredefBitmap *predefPtr = (TkPredefBitmap *) - ckalloc(sizeof(TkPredefBitmap)); - NativeIcon *nativeIconPtr = (NativeIcon *) - ckalloc(sizeof(NativeIcon)); - - nativeIconPtr->id = builtInPtr->id; - nativeIconPtr->type = builtInPtr->type; - predefPtr->source = (char *) nativeIconPtr; - predefPtr->width = builtInPtr->size; - predefPtr->height = builtInPtr->size; - predefPtr->native = 1; - Tcl_SetHashValue(predefHashPtr, predefPtr); - } + NativeIcon *nativeIconPtr; + Tcl_HashTable *tablePtr; + + for (builtInPtr = builtInIcons; builtInPtr->name != NULL; builtInPtr++) { + name = Tk_GetUid(builtInPtr->name); + tablePtr = TkGetBitmapPredefTable(); + predefHashPtr = Tcl_CreateHashEntry(tablePtr, name, &new); + if (!new) { + continue; + } + predefPtr = (TkPredefBitmap *) ckalloc(sizeof(TkPredefBitmap)); + nativeIconPtr = (NativeIcon *) ckalloc(sizeof(NativeIcon)); + nativeIconPtr->id = builtInPtr->id; + nativeIconPtr->type = builtInPtr->type; + predefPtr->source = (char *) nativeIconPtr; + predefPtr->width = builtInPtr->size; + predefPtr->height = builtInPtr->size; + predefPtr->native = 1; + Tcl_SetHashValue(predefHashPtr, predefPtr); } } @@ -122,15 +121,15 @@ TkpDefineNativeBitmaps(void) * * TkpCreateNativeBitmap -- * - * Add native bitmaps. + * Add native bitmaps. * * Results: - * A standard Tcl result. If an error occurs then TCL_ERROR is returned - * and a message is left in the interp's result. + * A standard Tcl result. If an error occurs then TCL_ERROR is + * returned and a message is left in the interp's result. * * Side effects: - * "Name" is entered into the bitmap table and may be used from here on - * to refer to the given bitmap. + * "Name" is entered into the bitmap table and may be used from + * here on to refer to the given bitmap. * *---------------------------------------------------------------------- */ @@ -138,42 +137,40 @@ TkpDefineNativeBitmaps(void) Pixmap TkpCreateNativeBitmap( Display *display, - CONST char *source) /* Info about the icon to build. */ + CONST char * source) /* Info about the icon to build. */ { Pixmap pix; - GWorldPtr destPort; Rect destRect; - CGrafPtr saveWorld; - GDHandle saveDevice; - NativeIcon *nativeIconPtr; - + Handle icon; + CGrafPtr savePort; + Boolean portChanged; + const NativeIcon *nativeIconPtr; + pix = Tk_GetPixmap(display, None, 32, 32, 0); - destPort = TkMacOSXGetDrawablePort(pix); + portChanged = QDSwapPort(TkMacOSXGetDrawablePort(pix), &savePort); - GetGWorld(&saveWorld, &saveDevice); - SetGWorld(destPort, NULL); - - nativeIconPtr = (NativeIcon *) source; + nativeIconPtr = (const NativeIcon *) source; SetRect(&destRect, 0, 0, 32, 32); if (nativeIconPtr->type == TYPE1) { - RGBColor white = {0xFFFF, 0xFFFF, 0xFFFF}; + RGBColor white = {0xFFFF, 0xFFFF, 0xFFFF}; - RGBForeColor(&white); - PaintRect(&destRect); - PlotIconID(&destRect, atAbsoluteCenter, ttNone, nativeIconPtr->id); + RGBForeColor(&white); + PaintRect(&destRect); + PlotIconID(&destRect, atAbsoluteCenter, ttNone, nativeIconPtr->id); } else if (nativeIconPtr->type == TYPE2) { - Handle icon = GetIcon(nativeIconPtr->id); - - if (icon != NULL) { - RGBColor black = {0, 0, 0}; - - RGBForeColor(&black); - PlotIcon(&destRect, icon); - ReleaseResource(icon); - } + icon = GetIcon(nativeIconPtr->id); + if (icon != NULL) { + RGBColor black = {0, 0, 0}; + + RGBForeColor(&black); + PlotIcon(&destRect, icon); + ReleaseResource(icon); + } } - SetGWorld(saveWorld, saveDevice); + if (portChanged) { + QDSwapPort(savePort, NULL); + } return pix; } @@ -182,102 +179,93 @@ TkpCreateNativeBitmap( * * TkpGetNativeAppBitmap -- * - * Add native bitmaps. + * Add native bitmaps. * * Results: - * A standard Tcl result. If an error occurs then TCL_ERROR is returned - * and a message is left in the interp's result. + * A standard Tcl result. If an error occurs then TCL_ERROR is + * returned and a message is left in the interp's result. * * Side effects: - * "Name" is entered into the bitmap table and may be used from here on - * to refer to the given bitmap. + * "Name" is entered into the bitmap table and may be used from + * here on to refer to the given bitmap. * *---------------------------------------------------------------------- */ Pixmap TkpGetNativeAppBitmap( - Display *display, /* The display. */ - CONST char *name, /* The name of the bitmap. */ - int *width, /* The width & height of the bitmap. */ + Display *display, /* The display. */ + CONST char *name, /* The name of the bitmap. */ + int *width, /* The width & height of the bitmap. */ 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) { - type = TYPE3; + type = TYPE3; } else { - resource = GetNamedResource('ICON', nativeName); - if (resource != NULL) { - type = TYPE2; - } + resource = GetNamedResource('ICON', nativeName); + if (resource != NULL) { + type = TYPE2; + } } - + if (resource == NULL) { - return (Pixmap) NULL; + return (Pixmap) NULL; } - + 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) { - RGBColor black = {0, 0, 0}; - - RGBForeColor(&black); - PlotIcon(&destRect, resource); - ReleaseResource(resource); + RGBColor black = {0, 0, 0}; + + RGBForeColor(&black); + PlotIcon(&destRect, resource); + ReleaseResource(resource); } else if (type == TYPE3) { - RGBColor white = {0xFFFF, 0xFFFF, 0xFFFF}; - short id; - ResType theType; - Str255 dummy; - - /* - * We need to first paint the background white. Also, for some reason - * we *must* use GetCIcon instead of GetNamedResource for PlotCIcon to - * work - so we use GetResInfo to get the id. - */ - - RGBForeColor(&white); - PaintRect(&destRect); - GetResInfo(resource, &id, &theType, dummy); - ReleaseResource(resource); - resource = (Handle) GetCIcon(id); - PlotCIcon(&destRect, (CIconHandle) resource); - DisposeCIcon((CIconHandle) resource); + RGBColor white = {0xFFFF, 0xFFFF, 0xFFFF}; + short id; + ResType theType; + Str255 dummy; + + /* + * We need to first paint the background white. Also, for + * some reason we *must* use GetCIcon instead of GetNamedResource + * for PlotCIcon to work - so we use GetResInfo to get the id. + */ + RGBForeColor(&white); + PaintRect(&destRect); + GetResInfo(resource, &id, &theType, dummy); + ReleaseResource(resource); + resource = (Handle) GetCIcon(id); + PlotCIcon(&destRect, (CIconHandle) resource); + DisposeCIcon((CIconHandle) resource); } - + *width = 32; *height = 32; - SetGWorld(saveWorld, saveDevice); + if (portChanged) { + QDSwapPort(savePort, NULL); + } return pix; } - -/* - * Local Variables: - * mode: c - * c-basic-offset: 4 - * fill-column: 78 - * End: - */ Index: macosx/tkMacOSXButton.c =================================================================== RCS file: /cvsroot/tktoolkit/tk/macosx/tkMacOSXButton.c,v retrieving revision 1.21 diff -u -p -r1.21 tkMacOSXButton.c --- macosx/tkMacOSXButton.c 13 Apr 2007 14:51:17 -0000 1.21 +++ macosx/tkMacOSXButton.c 15 Apr 2007 14:03:36 -0000 @@ -1,16 +1,17 @@ /* * tkMacOSXButton.c -- * - * This file implements the Macintosh specific portion of the button - * widgets. + * This file implements the Macintosh specific portion of the + * button widgets. * * 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. + * See the file "license.terms" for information on usage and redistribution + * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkMacOSXButton.c,v 1.21 2007/04/13 14:51:17 dkf Exp $ + * RCS: @(#) $Id: tkMacOSXButton.c,v 1.20 2006/08/18 07:30:54 das Exp $ */ #include "tkMacOSXInt.h" @@ -23,7 +24,6 @@ /* * Default insets for controls */ - #define DEF_INSET_LEFT 2 #define DEF_INSET_RIGHT 2 #define DEF_INSET_TOP 2 @@ -38,7 +38,7 @@ #define DRAW_CUSTOM 2 /* Make our own button drawing. */ #define DRAW_BEVEL 3 -/* +/* * Declaration of Mac specific button structure. */ @@ -47,77 +47,75 @@ typedef struct { SInt16 minValue; SInt16 maxValue; SInt16 procID; - int isBevel; + int isBevel; } MacControlParams; typedef struct { int drawType; Tk_3DBorder border; int relief; - int offset; /* 0 means this is a normal widget. 1 means it - * is an image button, so we offset the image - * to make the button appear to move up and - * down as the relief changes. */ - GC gc; + int offset; /* 0 means this is a normal widget. 1 means + * it is an image button, so we offset the + * image to make the button appear to move + * up and down as the relief changes. */ + GC gc; int hasImageOrBitmap; } DrawParams; + typedef struct { - TkButton info; /* Generic button info */ - int id; - int usingControl; - int useTkText; - int flags; /* Initialisation status */ - MacControlParams params; - WindowRef windowRef; - RGBColor userPaneBackground; - ControlRef userPane; /* Carbon control */ - ControlRef control; /* Carbon control */ - Str255 controlTitle; - ControlFontStyleRec fontStyle; - /* - * The following are used to store the image content for beveled buttons - - * i.e. buttons with images. + TkButton info; /* generic button info */ + int id; + int usingControl; + int useTkText; + int flags; /* initialisation status */ + MacControlParams params; + WindowRef windowRef; + unsigned long userPaneBackground; + ControlRef userPane; /* Carbon control */ + ControlRef control; /* Carbon control */ + Str255 controlTitle; + ControlFontStyleRec fontStyle; + /* + * the following are used to store the image content for + * beveled buttons - i.e. buttons with images. */ - CCTabHandle tabHandle; + CCTabHandle tabHandle; + Pixmap picPixmap; ControlButtonContentInfo bevelButtonContent; - OpenCPicParams picParams; - Pixmap picPixmap; + OpenCPicParams picParams; } MacButton; /* * Forward declarations for procedures defined later in this file: */ -static OSErr SetUserPaneDrawProc(ControlRef control, - ControlUserPaneDrawProcPtr upp); -static OSErr SetUserPaneSetUpSpecialBackgroundProc( - ControlRef control, - ControlUserPaneBackgroundProcPtr upp); -static void UserPaneDraw(ControlRef control, ControlPartCode cpc); -static void UserPaneBackgroundProc(ControlHandle, - ControlBackgroundPtr info); - -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); + +static OSStatus SetUserPaneDrawProc(ControlRef control, + ControlUserPaneDrawProcPtr upp); +static OSStatus SetUserPaneSetUpSpecialBackgroundProc(ControlRef control, + ControlUserPaneBackgroundProcPtr upp); +static void UserPaneDraw(ControlRef control, ControlPartCode cpc); +static void UserPaneBackgroundProc(ControlHandle, + ControlBackgroundPtr info); + +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. */ -Tk_ClassProcs tkpButtonProcs = { - sizeof(Tk_ClassProcs), /* size */ - TkButtonWorldChanged, /* worldChangedProc */ +Tk_ClassProcs tkpButtonProcs = { + sizeof(Tk_ClassProcs), /* size */ + TkButtonWorldChanged, /* worldChangedProc */ }; static int bCount; @@ -129,13 +127,13 @@ int tkPictureIsOpen; * * TkpCreateButton -- * - * Allocate a new TkButton structure. + * Allocate a new TkButton structure. * * Results: - * Returns a newly allocated TkButton structure. + * Returns a newly allocated TkButton structure. * * Side effects: - * Registers an event handler for the widget. + * Registers an event handler for the widget. * *---------------------------------------------------------------------- */ @@ -144,16 +142,14 @@ TkButton * TkpCreateButton( Tk_Window tkwin) { - MacButton *macButtonPtr = (MacButton *) ckalloc(sizeof(MacButton)); - + MacButton *macButtonPtr; + macButtonPtr = (MacButton *) ckalloc(sizeof(MacButton)); Tk_CreateEventHandler(tkwin, ActivateMask, - ButtonEventProc, (ClientData) macButtonPtr); + ButtonEventProc, (ClientData) macButtonPtr); 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; @@ -168,7 +164,6 @@ TkpCreateButton( macButtonPtr->bevelButtonContent.contentType = kControlContentPictHandle; bzero(&macButtonPtr->params, sizeof(macButtonPtr->params)); bzero(&macButtonPtr->fontStyle,sizeof(macButtonPtr->fontStyle)); - return (TkButton *)macButtonPtr; } @@ -177,298 +172,310 @@ TkpCreateButton( * * TkpDisplayButton -- * - * This procedure is invoked to display a button widget. It is normally - * invoked as an idle handler. + * This procedure is invoked to display a button widget. It is + * normally invoked as an idle handler. * * Results: - * None. + * None. * * Side effects: - * Commands are output to X to display the button in its current mode. - * The REDRAW_PENDING flag is cleared. + * Commands are output to X to display the button in its + * current mode. The REDRAW_PENDING flag is cleared. * *---------------------------------------------------------------------- */ void TkpDisplayButton( - ClientData clientData) /* Information about widget. */ + ClientData clientData) /* Information about widget. */ { MacButton *macButtonPtr = (MacButton *)clientData; - TkButton *butPtr = (TkButton *) clientData; - Tk_Window tkwin = butPtr->tkwin; - GWorldPtr destPort; + TkButton *butPtr = (TkButton *) clientData; + Tk_Window tkwin = butPtr->tkwin; + int width, height, fullWidth, fullHeight; + int textXOffset, textYOffset; + int haveImage = 0, haveText = 0; + CGrafPtr destPort, savePort; + Boolean portChanged; + int borderWidth; Pixmap pixmap; - int width, height, fullWidth, fullHeight, textXOffset, textYOffset; - int borderWidth, wasUsingControl; - int haveImage = 0, haveText = 0, imageWidth = 0, imageHeight = 0; - int imageXOffset = 0, imageYOffset = 0; - /* Image information that will be used to - * restrict disabled pixmap as well. */ - DrawParams drawParams, *dpPtr = &drawParams; + int wasUsingControl; + int imageWidth = 0, imageHeight = 0; + int imageXOffset = 0, imageYOffset = 0; /* image information that will + * be used to restrict disabled + * pixmap as well */ + DrawParams drawParams, * dpPtr = &drawParams; butPtr->flags &= ~REDRAW_PENDING; if ((butPtr->tkwin == NULL) || !Tk_IsMapped(tkwin)) { - return; + return; } pixmap = (Pixmap) Tk_WindowId(tkwin); wasUsingControl = macButtonPtr->usingControl; if (TkMacOSXComputeDrawParams(butPtr, &drawParams) ) { - macButtonPtr->usingControl = 1; - if (butPtr->type == TYPE_BUTTON) { - macButtonPtr->useTkText = 0; - } else { - macButtonPtr->useTkText = 1; - } + macButtonPtr->usingControl = 1; + if (butPtr->type == TYPE_BUTTON) { + macButtonPtr->useTkText = 0; + } else { + macButtonPtr->useTkText = 1; + } } else { - macButtonPtr->usingControl = 0; - macButtonPtr->useTkText = 1; + macButtonPtr->usingControl = 0; + macButtonPtr->useTkText = 1; } - - /* - * Set up clipping region. Make sure the we are using the port for this - * button, or we will set the wrong window's clip. + + /* + * set up clipping region. Make sure the we are using the port + * for this button, or we will set the wrong window's clip. */ - + destPort = TkMacOSXGetDrawablePort(pixmap); - SetGWorld(destPort, NULL); + portChanged = QDSwapPort(destPort, &savePort); TkMacOSXSetUpClippingRgn(pixmap); + /* - * See the comment in UpdateControlColors as to why we use the + * See the comment in UpdateControlColors as to why we use the * highlightbackground for the border of Macintosh buttons. */ if (macButtonPtr->useTkText) { - if (butPtr->type == TYPE_BUTTON) { - Tk_Fill3DRectangle(tkwin, pixmap, butPtr->highlightBorder, 0, 0, - Tk_Width(tkwin), Tk_Height(tkwin), 0, TK_RELIEF_FLAT); - } else { - Tk_Fill3DRectangle(tkwin, pixmap, butPtr->normalBorder, 0, 0, - Tk_Width(tkwin), Tk_Height(tkwin), 0, TK_RELIEF_FLAT); - } + if (butPtr->type == TYPE_BUTTON) { + Tk_Fill3DRectangle(tkwin, pixmap, butPtr->highlightBorder, 0, 0, + Tk_Width(tkwin), Tk_Height(tkwin), 0, TK_RELIEF_FLAT); + } else { + Tk_Fill3DRectangle(tkwin, pixmap, butPtr->normalBorder, 0, 0, + Tk_Width(tkwin), Tk_Height(tkwin), 0, TK_RELIEF_FLAT); + } } /* * Draw the native portion of the buttons. Start by creating the control - * if it doesn't already exist. Then configure the Macintosh control from - * the Tk info. Finally, we call Draw1Control to draw to the screen. + * if it doesn't already exist. Then configure the Macintosh control from + * the Tk info. Finally, we call Draw1Control to draw to the screen. */ if (macButtonPtr->usingControl) { - borderWidth = 0; - TkMacOSXDrawControl(macButtonPtr, destPort, dpPtr->gc, pixmap); - } else if (wasUsingControl && macButtonPtr->userPane) { - DisposeControl(macButtonPtr->userPane); - macButtonPtr->userPane = NULL; - macButtonPtr->control = NULL; - macButtonPtr->flags = 0; + borderWidth = 0; + TkMacOSXDrawControl(macButtonPtr, destPort, dpPtr->gc, pixmap); + } else { + if (wasUsingControl && macButtonPtr->userPane) { + DisposeControl(macButtonPtr->userPane); + macButtonPtr->userPane = NULL; + macButtonPtr->control = NULL; + macButtonPtr->flags = 0; + } } if ((dpPtr->drawType == DRAW_CUSTOM) || (dpPtr->drawType == DRAW_LABEL)) { - borderWidth = butPtr->borderWidth; + borderWidth = butPtr->borderWidth; } /* - * Display image or bitmap or text for button. This has already been done - * under Appearance with the Bevel button types. + * Display image or bitmap or text for button. This has + * already been done under Appearance with the Bevel + * button types. */ if (dpPtr->drawType == DRAW_BEVEL) { - goto applyStipple; - } - - if (butPtr->image != None) { - Tk_SizeOfImage(butPtr->image, &width, &height); - haveImage = 1; - } else if (butPtr->bitmap != None) { - Tk_SizeOfBitmap(butPtr->display, butPtr->bitmap, &width, &height); - haveImage = 1; - } - imageWidth = width; - imageHeight = height; - - haveText = (butPtr->textWidth != 0 && butPtr->textHeight != 0); - if (butPtr->compound != COMPOUND_NONE && haveImage && haveText) { - int x, y; - - textXOffset = 0; - textYOffset = 0; - fullWidth = 0; - fullHeight = 0; - - switch ((enum compound) butPtr->compound) { - case COMPOUND_TOP: - case COMPOUND_BOTTOM: - /* - * Image is above or below text. - */ - - if (butPtr->compound == COMPOUND_TOP) { - textYOffset = height + butPtr->padY; - } else { - imageYOffset = butPtr->textHeight + butPtr->padY; - } - fullHeight = height + butPtr->textHeight + butPtr->padY; - fullWidth = (width>butPtr->textWidth ? width : butPtr->textWidth); - textXOffset = (fullWidth - butPtr->textWidth)/2; - imageXOffset = (fullWidth - width)/2; - break; - - case COMPOUND_LEFT: - case COMPOUND_RIGHT: - /* - * Image is left or right of text. - */ - - if (butPtr->compound == COMPOUND_LEFT) { - textXOffset = width + butPtr->padX; - } else { - imageXOffset = butPtr->textWidth + butPtr->padX; - } - fullWidth = butPtr->textWidth + butPtr->padX + width; - fullHeight = (height > butPtr->textHeight ? height : - butPtr->textHeight); - textYOffset = (fullHeight - butPtr->textHeight)/2; - imageYOffset = (fullHeight - height)/2; - break; - - case COMPOUND_CENTER: - /* - * Image and text are superimposed. - */ - - fullWidth = (width>butPtr->textWidth ? width : butPtr->textWidth); - fullHeight = (height > butPtr->textHeight ? height : - butPtr->textHeight); - textXOffset = (fullWidth - butPtr->textWidth)/2; - imageXOffset = (fullWidth - width)/2; - textYOffset = (fullHeight - butPtr->textHeight)/2; - imageYOffset = (fullHeight - height)/2; - break; - - case COMPOUND_NONE: - break; - } - - TkComputeAnchor(butPtr->anchor, tkwin, butPtr->padX, butPtr->padY, - butPtr->indicatorSpace + fullWidth, fullHeight, &x, &y); - - x += butPtr->indicatorSpace; - - x += dpPtr->offset; - y += dpPtr->offset; - if (dpPtr->relief == TK_RELIEF_RAISED) { - x -= dpPtr->offset; - y -= dpPtr->offset; - } else if (dpPtr->relief == TK_RELIEF_SUNKEN) { - x += dpPtr->offset; - y += dpPtr->offset; - } - imageXOffset += x; - imageYOffset += y; - if (butPtr->image != NULL) { - if ((butPtr->selectImage != NULL) && (butPtr->flags & SELECTED)) { - Tk_RedrawImage(butPtr->selectImage, 0, 0, width, height, - pixmap, imageXOffset, imageYOffset); - } else if ((butPtr->tristateImage != NULL) && - (butPtr->flags & TRISTATED)) { - Tk_RedrawImage(butPtr->tristateImage, 0, 0, width, height, - pixmap, imageXOffset, imageYOffset); - } else { - Tk_RedrawImage(butPtr->image, 0, 0, width, height, pixmap, - imageXOffset, imageYOffset); - } - } else { - XSetClipOrigin(butPtr->display, dpPtr->gc, imageXOffset, - imageYOffset); - XCopyPlane(butPtr->display, butPtr->bitmap, pixmap, dpPtr->gc, - 0, 0, (unsigned int) width, (unsigned int) height, - imageXOffset, imageYOffset, 1); - XSetClipOrigin(butPtr->display, dpPtr->gc, 0, 0); - } - - if (macButtonPtr->useTkText) { - Tk_DrawTextLayout(butPtr->display, pixmap, dpPtr->gc, - butPtr->textLayout, x + textXOffset, y + textYOffset, - 0, -1); - Tk_UnderlineTextLayout(butPtr->display, pixmap, dpPtr->gc, - butPtr->textLayout, x + textXOffset, y + textYOffset, - butPtr->underline); - } - y += fullHeight/2; - } else if (haveImage) { - int x = 0, y; - - TkComputeAnchor(butPtr->anchor, tkwin, 0, 0, - butPtr->indicatorSpace + width, height, &x, &y); - x += butPtr->indicatorSpace; - - x += dpPtr->offset; - y += dpPtr->offset; - if (dpPtr->relief == TK_RELIEF_RAISED) { - x -= dpPtr->offset; - y -= dpPtr->offset; - } else if (dpPtr->relief == TK_RELIEF_SUNKEN) { - x += dpPtr->offset; - y += dpPtr->offset; - } - imageXOffset += x; - imageYOffset += y; - if (butPtr->image != NULL) { - if ((butPtr->selectImage != NULL) && (butPtr->flags & SELECTED)) { - Tk_RedrawImage(butPtr->selectImage, 0, 0, width, height, - pixmap, imageXOffset, imageYOffset); - } else if ((butPtr->tristateImage != NULL) && - (butPtr->flags & TRISTATED)) { - Tk_RedrawImage(butPtr->tristateImage, 0, 0, width, height, - pixmap, imageXOffset, imageYOffset); - } else { - Tk_RedrawImage(butPtr->image, 0, 0, width, height, pixmap, + /* Empty Body */ + } else { + if (butPtr->image != None) { + Tk_SizeOfImage(butPtr->image, &width, &height); + haveImage = 1; + } else if (butPtr->bitmap != None) { + Tk_SizeOfBitmap(butPtr->display, butPtr->bitmap, &width, &height); + haveImage = 1; + } + imageWidth = width; + imageHeight = height; + + haveText = (butPtr->textWidth != 0 && butPtr->textHeight != 0); + if (butPtr->compound != COMPOUND_NONE && haveImage && haveText) { + int x; + int y; + textXOffset = 0; + textYOffset = 0; + fullWidth = 0; + fullHeight = 0; + + switch ((enum compound) butPtr->compound) { + case COMPOUND_TOP: + case COMPOUND_BOTTOM: { + /* Image is above or below text */ + if (butPtr->compound == COMPOUND_TOP) { + textYOffset = height + butPtr->padY; + } else { + imageYOffset = butPtr->textHeight + butPtr->padY; + } + fullHeight = height + butPtr->textHeight + butPtr->padY; + fullWidth = (width > butPtr->textWidth ? width : + butPtr->textWidth); + textXOffset = (fullWidth - butPtr->textWidth)/2; + imageXOffset = (fullWidth - width)/2; + break; + } + case COMPOUND_LEFT: + case COMPOUND_RIGHT: { + /* + * Image is left or right of text + */ + + if (butPtr->compound == COMPOUND_LEFT) { + textXOffset = width + butPtr->padX; + } else { + imageXOffset = butPtr->textWidth + butPtr->padX; + } + fullWidth = butPtr->textWidth + butPtr->padX + width; + fullHeight = (height > butPtr->textHeight ? height : + butPtr->textHeight); + textYOffset = (fullHeight - butPtr->textHeight)/2; + imageYOffset = (fullHeight - height)/2; + break; + } + case COMPOUND_CENTER: { + /* + * Image and text are superimposed + */ + + fullWidth = (width > butPtr->textWidth ? width : + butPtr->textWidth); + fullHeight = (height > butPtr->textHeight ? height : + butPtr->textHeight); + textXOffset = (fullWidth - butPtr->textWidth)/2; + imageXOffset = (fullWidth - width)/2; + textYOffset = (fullHeight - butPtr->textHeight)/2; + imageYOffset = (fullHeight - height)/2; + break; + } + case COMPOUND_NONE: {break;} + } + + TkComputeAnchor(butPtr->anchor, tkwin, butPtr->padX, butPtr->padY, + butPtr->indicatorSpace + fullWidth, fullHeight, &x, &y); + + x += butPtr->indicatorSpace; + + x += dpPtr->offset; + y += dpPtr->offset; + if (dpPtr->relief == TK_RELIEF_RAISED) { + x -= dpPtr->offset; + y -= dpPtr->offset; + } else if (dpPtr->relief == TK_RELIEF_SUNKEN) { + x += dpPtr->offset; + y += dpPtr->offset; + } + imageXOffset += x; + imageYOffset += y; + if (butPtr->image != NULL) { + if ((butPtr->selectImage != NULL) && + (butPtr->flags & SELECTED)) { + Tk_RedrawImage(butPtr->selectImage, 0, 0, + width, height, pixmap, imageXOffset, imageYOffset); + } else if ((butPtr->tristateImage != NULL) && + (butPtr->flags & TRISTATED)) { + Tk_RedrawImage(butPtr->tristateImage, 0, 0, + width, height, pixmap, imageXOffset, imageYOffset); + } else { + Tk_RedrawImage(butPtr->image, 0, 0, width, + height, pixmap, imageXOffset, imageYOffset); + } + } else { + XSetClipOrigin(butPtr->display, dpPtr->gc, imageXOffset, imageYOffset); - } - } else { - XSetClipOrigin(butPtr->display, dpPtr->gc, x, y); - XCopyPlane(butPtr->display, butPtr->bitmap, pixmap, dpPtr->gc, - 0, 0, (unsigned) width, (unsigned) height, x, y, 1); - XSetClipOrigin(butPtr->display, dpPtr->gc, 0, 0); - } - y += height/2; - } else if (macButtonPtr->useTkText) { - int x = 0, y; - - TkComputeAnchor(butPtr->anchor, tkwin, butPtr->padX, butPtr->padY, - butPtr->indicatorSpace + butPtr->textWidth, - butPtr->textHeight, &x, &y); - x += butPtr->indicatorSpace; - Tk_DrawTextLayout(butPtr->display, pixmap, dpPtr->gc, - butPtr->textLayout, x, y, 0, -1); + XCopyPlane(butPtr->display, butPtr->bitmap, pixmap, dpPtr->gc, + 0, 0, (unsigned int) width, (unsigned int) height, + imageXOffset, imageYOffset, 1); + XSetClipOrigin(butPtr->display, dpPtr->gc, 0, 0); + } + + if (macButtonPtr->useTkText) { + Tk_DrawTextLayout(butPtr->display, pixmap, + dpPtr->gc, butPtr->textLayout, + x + textXOffset, y + textYOffset, 0, -1); + Tk_UnderlineTextLayout(butPtr->display, pixmap, dpPtr->gc, + butPtr->textLayout, + x + textXOffset, y + textYOffset, + butPtr->underline); + } + y += fullHeight/2; + } else { + if (haveImage) { + int x = 0; + int y; + + TkComputeAnchor(butPtr->anchor, tkwin, 0, 0, + butPtr->indicatorSpace + width, height, &x, &y); + x += butPtr->indicatorSpace; + + x += dpPtr->offset; + y += dpPtr->offset; + if (dpPtr->relief == TK_RELIEF_RAISED) { + x -= dpPtr->offset; + y -= dpPtr->offset; + } else if (dpPtr->relief == TK_RELIEF_SUNKEN) { + x += dpPtr->offset; + y += dpPtr->offset; + } + imageXOffset += x; + imageYOffset += y; + if (butPtr->image != NULL) { + if ((butPtr->selectImage != NULL) && + (butPtr->flags & SELECTED)) { + Tk_RedrawImage(butPtr->selectImage, 0, 0, width, + height, pixmap, imageXOffset, imageYOffset); + } else if ((butPtr->tristateImage != NULL) && + (butPtr->flags & TRISTATED)) { + Tk_RedrawImage(butPtr->tristateImage, 0, 0, width, + height, pixmap, imageXOffset, imageYOffset); + } else { + Tk_RedrawImage(butPtr->image, 0, 0, width, height, + pixmap, imageXOffset, imageYOffset); + } + } else { + XSetClipOrigin(butPtr->display, dpPtr->gc, x, y); + XCopyPlane(butPtr->display, butPtr->bitmap, + pixmap, dpPtr->gc, + 0, 0, (unsigned int) width, + (unsigned int) height, x, y, 1); + XSetClipOrigin(butPtr->display, dpPtr->gc, 0, 0); + } + y += height/2; + } else if (macButtonPtr->useTkText) { + int x = 0; + int y; + TkComputeAnchor(butPtr->anchor, tkwin, butPtr->padX, + butPtr->padY, + butPtr->indicatorSpace + butPtr->textWidth, + butPtr->textHeight, &x, &y); + x += butPtr->indicatorSpace; + Tk_DrawTextLayout(butPtr->display, pixmap, dpPtr->gc, + butPtr->textLayout, x, y, 0, -1); + } + } } /* * If the button is disabled with a stipple rather than a special - * foreground color, generate the stippled effect. If the widget is - * selected and we use a different background color when selected, must - * temporarily modify the GC so the stippling is the right color. + * foreground color, generate the stippled effect. If the widget + * is selected and we use a different background color when selected, + * must temporarily modify the GC so the stippling is the right color. */ - applyStipple: if (macButtonPtr->useTkText) { - if ((butPtr->state == STATE_DISABLED) - && ((butPtr->disabledFg == NULL) || (butPtr->image != NULL))) { - if ((butPtr->flags & SELECTED) && !butPtr->indicatorOn + if ((butPtr->state == STATE_DISABLED) + && ((butPtr->disabledFg == NULL) || (butPtr->image != NULL))) { + if ((butPtr->flags & SELECTED) && !butPtr->indicatorOn && (butPtr->selectBorder != NULL)) { - XSetForeground(butPtr->display, butPtr->stippleGC, + XSetForeground(butPtr->display, butPtr->stippleGC, Tk_3DBorderColor(butPtr->selectBorder)->pixel); - } - + } /* * Stipple the whole button if no disabledFg was specified, * otherwise restrict stippling only to displayed image */ - if (butPtr->disabledFg == NULL) { XFillRectangle(butPtr->display, pixmap, butPtr->stippleGC, 0, 0, (unsigned) Tk_Width(tkwin), @@ -478,25 +485,27 @@ TkpDisplayButton( imageXOffset, imageYOffset, (unsigned) imageWidth, (unsigned) imageHeight); } - if ((butPtr->flags & SELECTED) && !butPtr->indicatorOn + if ((butPtr->flags & SELECTED) && !butPtr->indicatorOn && (butPtr->selectBorder != NULL)) { XSetForeground(butPtr->display, butPtr->stippleGC, Tk_3DBorderColor(butPtr->normalBorder)->pixel); } - } - - /* - * Draw the border and traversal highlight last. This way, if the - * button's contents overflow they'll be covered up by the border. - */ - - if (dpPtr->relief != TK_RELIEF_FLAT) { - int inset = butPtr->highlightWidth; + } - Tk_Draw3DRectangle(tkwin, pixmap, dpPtr->border, inset, inset, - Tk_Width(tkwin) - 2*inset, Tk_Height(tkwin) - 2*inset, - butPtr->borderWidth, dpPtr->relief); - } + /* + * Draw the border and traversal highlight last. This way, if the + * button's contents overflow they'll be covered up by the border. + */ + + if (dpPtr->relief != TK_RELIEF_FLAT) { + int inset = butPtr->highlightWidth; + Tk_Draw3DRectangle(tkwin, pixmap, dpPtr->border, inset, inset, + Tk_Width(tkwin) - 2*inset, Tk_Height(tkwin) - 2*inset, + butPtr->borderWidth, dpPtr->relief); + } + } + if (portChanged) { + QDSwapPort(savePort, NULL); } } @@ -505,228 +514,236 @@ TkpDisplayButton( * * TkpComputeButtonGeometry -- * - * After changes in a button's text or bitmap, this procedure recomputes - * the button's geometry and passes this information along to the - * geometry manager for the window. + * After changes in a button's text or bitmap, this procedure + * recomputes the button's geometry and passes this information + * along to the geometry manager for the window. * * Results: - * None. + * None. * * Side effects: - * The button's window may change size. + * The button's window may change size. * *---------------------------------------------------------------------- */ void TkpComputeButtonGeometry( - TkButton *butPtr) /* Button whose geometry may have changed. */ + TkButton *butPtr) /* Button whose geometry may have changed. */ { int width, height, avgWidth, haveImage = 0, haveText = 0; - int xInset, yInset, txtWidth, txtHeight; + int xInset, yInset; + int txtWidth, txtHeight; Tk_FontMetrics fm; DrawParams drawParams; /* * First figure out the size of the contents of the button. */ - + width = 0; height = 0; txtWidth = 0; txtHeight = 0; avgWidth = 0; + butPtr->indicatorSpace = 0; if (butPtr->image != NULL) { - Tk_SizeOfImage(butPtr->image, &width, &height); - haveImage = 1; + Tk_SizeOfImage(butPtr->image, &width, &height); + haveImage = 1; } else if (butPtr->bitmap != None) { - Tk_SizeOfBitmap(butPtr->display, butPtr->bitmap, &width, &height); - haveImage = 1; + Tk_SizeOfBitmap(butPtr->display, butPtr->bitmap, &width, &height); + haveImage = 1; } if (haveImage == 0 || butPtr->compound != COMPOUND_NONE) { - Tk_FreeTextLayout(butPtr->textLayout); - butPtr->textLayout = Tk_ComputeTextLayout(butPtr->tkfont, - Tcl_GetString(butPtr->textPtr), -1, butPtr->wrapLength, - butPtr->justify, 0, &butPtr->textWidth, &butPtr->textHeight); - - txtWidth = butPtr->textWidth; - txtHeight = butPtr->textHeight; - avgWidth = Tk_TextWidth(butPtr->tkfont, "0", 1); - Tk_GetFontMetrics(butPtr->tkfont, &fm); - haveText = (txtWidth != 0 && txtHeight != 0); + Tk_FreeTextLayout(butPtr->textLayout); + butPtr->textLayout = Tk_ComputeTextLayout(butPtr->tkfont, + Tcl_GetString(butPtr->textPtr), -1, butPtr->wrapLength, + butPtr->justify, 0, &butPtr->textWidth, &butPtr->textHeight); + + txtWidth = butPtr->textWidth; + txtHeight = butPtr->textHeight; + avgWidth = Tk_TextWidth(butPtr->tkfont, "0", 1); + Tk_GetFontMetrics(butPtr->tkfont, &fm); + haveText = (txtWidth != 0 && txtHeight != 0); } /* - * If the button is compound (ie, it shows both an image and text), the - * new geometry is a combination of the image and text geometry. We only - * honor the compound bit if the button has both text and an image, - * because otherwise it is not really a compound button. + * If the button is compound (ie, it shows both an image and text), + * the new geometry is a combination of the image and text geometry. + * We only honor the compound bit if the button has both text and an + * image, because otherwise it is not really a compound button. */ if (butPtr->compound != COMPOUND_NONE && haveImage && haveText) { - switch ((enum compound) butPtr->compound) { - case COMPOUND_TOP: - case COMPOUND_BOTTOM: - /* - * Image is above or below text. - */ - - height += txtHeight + butPtr->padY; - width = (width > txtWidth ? width : txtWidth); - break; - case COMPOUND_LEFT: - case COMPOUND_RIGHT: - /* - * Image is left or right of text. - */ - - width += txtWidth + butPtr->padX; - height = (height > txtHeight ? height : txtHeight); - break; - case COMPOUND_CENTER: - /* - * Image and text are superimposed. - */ - - width = (width > txtWidth ? width : txtWidth); - height = (height > txtHeight ? height : txtHeight); - break; - case COMPOUND_NONE: - break; - } - if (butPtr->width > 0) { - width = butPtr->width; - } - if (butPtr->height > 0) { - height = butPtr->height; - } + switch ((enum compound) butPtr->compound) { + case COMPOUND_TOP: + case COMPOUND_BOTTOM: { + /* + * Image is above or below text + */ + + height += txtHeight + butPtr->padY; + width = (width > txtWidth ? width : txtWidth); + break; + } + case COMPOUND_LEFT: + case COMPOUND_RIGHT: { + /* + * Image is left or right of text + */ + + width += txtWidth + butPtr->padX; + height = (height > txtHeight ? height : txtHeight); + break; + } + case COMPOUND_CENTER: { + /* + * Image and text are superimposed + */ + + width = (width > txtWidth ? width : txtWidth); + height = (height > txtHeight ? height : txtHeight); + break; + } + case COMPOUND_NONE: {break;} + } + if (butPtr->width > 0) { + width = butPtr->width; + } + if (butPtr->height > 0) { + height = butPtr->height; + } + + if ((butPtr->type >= TYPE_CHECK_BUTTON) && butPtr->indicatorOn) { + butPtr->indicatorSpace = height; + if (butPtr->type == TYPE_CHECK_BUTTON) { + butPtr->indicatorDiameter = (65 * height)/100; + } else { + butPtr->indicatorDiameter = (75 * height)/100; + } + } - if ((butPtr->type >= TYPE_CHECK_BUTTON) && butPtr->indicatorOn) { - butPtr->indicatorSpace = height; - if (butPtr->type == TYPE_CHECK_BUTTON) { - butPtr->indicatorDiameter = (65 * height)/100; - } else { - butPtr->indicatorDiameter = (75 * height)/100; - } - } + width += 2 * butPtr->padX; + height += 2 * butPtr->padY; - width += 2 * butPtr->padX; - height += 2 * butPtr->padY; - } else if (haveImage) { - if (butPtr->width > 0) { - width = butPtr->width; - } - if (butPtr->height > 0) { - height = butPtr->height; - } - if ((butPtr->type >= TYPE_CHECK_BUTTON) && butPtr->indicatorOn) { - butPtr->indicatorSpace = height; - if (butPtr->type == TYPE_CHECK_BUTTON) { - butPtr->indicatorDiameter = (65 * height)/100; - } else { - butPtr->indicatorDiameter = (75 * height)/100; - } - } } else { - width = txtWidth; - height = txtHeight; - if (butPtr->width > 0) { - width = butPtr->width * avgWidth; - } - if (butPtr->height > 0) { - height = butPtr->height * fm.linespace; - } - if ((butPtr->type >= TYPE_CHECK_BUTTON) && butPtr->indicatorOn) { - butPtr->indicatorDiameter = fm.linespace; - if (butPtr->type == TYPE_CHECK_BUTTON) { - butPtr->indicatorDiameter = - (80 * butPtr->indicatorDiameter)/100; - } - butPtr->indicatorSpace = butPtr->indicatorDiameter + avgWidth; - } + if (haveImage) { + if (butPtr->width > 0) { + width = butPtr->width; + } + if (butPtr->height > 0) { + height = butPtr->height; + } + if ((butPtr->type >= TYPE_CHECK_BUTTON) && butPtr->indicatorOn) { + butPtr->indicatorSpace = height; + if (butPtr->type == TYPE_CHECK_BUTTON) { + butPtr->indicatorDiameter = (65 * height)/100; + } else { + butPtr->indicatorDiameter = (75 * height)/100; + } + } + } else { + width = txtWidth; + height = txtHeight; + if (butPtr->width > 0) { + width = butPtr->width * avgWidth; + } + if (butPtr->height > 0) { + height = butPtr->height * fm.linespace; + } + if ((butPtr->type >= TYPE_CHECK_BUTTON) && butPtr->indicatorOn) { + butPtr->indicatorDiameter = fm.linespace; + if (butPtr->type == TYPE_CHECK_BUTTON) { + butPtr->indicatorDiameter = + (80 * butPtr->indicatorDiameter)/100; + } + butPtr->indicatorSpace = butPtr->indicatorDiameter + avgWidth; + } + } } /* * Now figure out the size of the border decorations for the button. */ - + if (butPtr->highlightWidth < 0) { - butPtr->highlightWidth = 0; + butPtr->highlightWidth = 0; } - + /* - * The width and height calculation for Appearance buttons with images & - * non-Appearance buttons with images is different. In the latter case, we - * add the borderwidth to the inset, since we are going to stamp a 3-D - * border over the image. In the former, we add it to the height, + * The width and height calculation for Appearance buttons with images & + * non-Appearance buttons with images is different. In the latter case, + * we add the borderwidth to the inset, since we are going to stamp a + * 3-D border over the image. In the former, we add it to the height, * directly, since Appearance will draw the border as part of our control. * * When issuing the geometry request, add extra space for the indicator, - * if any, and for the border and padding, plus if this is an image two + * if any, and for the border and padding, plus if this is an image two * extra pixels so the display can be offset by 1 pixel in either * direction for the raised or lowered effect. * * The highlight width corresponds to the default ring on the Macintosh. * As such, the highlight width is only added if the button is the default - * button. The actual width of the default ring is one less than the - * highlight width as there is also one pixel of spacing. Appearance - * buttons with images do not have a highlight ring, because the Bevel - * button type does not support one. + * button. The actual width of the default ring is one less than the + * highlight width as there is also one pixel of spacing. + * Appearance buttons with images do not have a highlight ring, because the + * Bevel button type does not support one. */ if ((butPtr->image == None) && (butPtr->bitmap == None)) { - width += 2*butPtr->padX; - height += 2*butPtr->padY; + width += 2*butPtr->padX; + height += 2*butPtr->padY; } - + if ((butPtr->type == TYPE_BUTTON)) { - if ((butPtr->image == None) && (butPtr->bitmap == None)) { - butPtr->inset = 0; - if (butPtr->defaultState != STATE_DISABLED) { - butPtr->inset += butPtr->highlightWidth; - } - } else { - butPtr->inset = 0; - width += (2 * butPtr->borderWidth + 4); - height += (2 * butPtr->borderWidth + 4); - } - } else if (butPtr->type == TYPE_LABEL) { - butPtr->inset = butPtr->borderWidth; - } else if (butPtr->indicatorOn) { - butPtr->inset = 0; + if ((butPtr->image == None) && (butPtr->bitmap == None)) { + butPtr->inset = 0; + if (butPtr->defaultState != STATE_DISABLED) { + butPtr->inset += butPtr->highlightWidth; + } + } else { + butPtr->inset = 0; + width += (2 * butPtr->borderWidth + 4); + height += (2 * butPtr->borderWidth + 4); + } + } else if ((butPtr->type != TYPE_LABEL)) { + if (butPtr->indicatorOn) { + butPtr->inset = 0; + } else { + /* + * Under Appearance, the Checkbutton or radiobutton with an image + * is represented by a BevelButton with the Sticky defProc... + * So we must set its height in the same way as the Button + * with an image or bitmap. + */ + + if ( (butPtr->image != None) || (butPtr->bitmap != None)) { + int border; + butPtr->inset = 0; + if ( butPtr->borderWidth <= 2 ) { + border = 6; + } else { + border = 2 * butPtr->borderWidth + 2; + } + width += border; + height += border; + } else { + butPtr->inset = butPtr->borderWidth; + } + } } else { - /* - * Under Appearance, the Checkbutton or radiobutton with an image is - * represented by a BevelButton with the Sticky defProc... So we must - * set its height in the same way as the Button with an image or - * bitmap. - */ - - if ((butPtr->image != None) || (butPtr->bitmap != None)) { - int border; - - butPtr->inset = 0; - if (butPtr->borderWidth <= 2) { - border = 6; - } else { - border = 2 * butPtr->borderWidth + 2; - } - width += border; - height += border; - } else { - butPtr->inset = butPtr->borderWidth; - } + butPtr->inset = butPtr->borderWidth; } if (TkMacOSXComputeDrawParams(butPtr,&drawParams)) { - xInset = butPtr->indicatorSpace + DEF_INSET_LEFT + DEF_INSET_RIGHT; - yInset = DEF_INSET_TOP + DEF_INSET_BOTTOM; + xInset = butPtr->indicatorSpace + DEF_INSET_LEFT + DEF_INSET_RIGHT; + yInset = DEF_INSET_TOP + DEF_INSET_BOTTOM; } else { - xInset = butPtr->indicatorSpace+butPtr->inset*2; - yInset = butPtr->inset*2; + xInset = butPtr->indicatorSpace+butPtr->inset*2; + yInset = butPtr->inset*2; } Tk_GeometryRequest(butPtr->tkwin, width + xInset, height + yInset); Tk_SetInternalBorder(butPtr->tkwin, butPtr->inset); @@ -737,13 +754,13 @@ TkpComputeButtonGeometry( * * TkpDestroyButton -- * - * Free data