From e533770d061a74bb7d2e59f1fd3347fb70782bb9 Mon Sep 17 00:00:00 2001 From: dgp Date: Tue, 12 Jun 2007 16:22:40 +0000 Subject: merge updates from HEAD --- ChangeLog | 99 +++++- doc/ttk_panedwindow.n | 35 +- generic/ttk/ttkFrame.c | 77 ++--- generic/ttk/ttkManager.c | 179 ++++------ generic/ttk/ttkManager.h | 52 +-- generic/ttk/ttkNotebook.c | 177 +++++++--- generic/ttk/ttkPanedwindow.c | 318 +++++++++++++----- library/ttk/panedwindow.tcl | 6 +- macosx/Wish-Debug.xcconfig | 4 +- macosx/Wish-Release.xcconfig | 4 +- macosx/Wish.xcodeproj/project.pbxproj | 10 +- macosx/tkMacOSXColor.c | 62 ++-- macosx/tkMacOSXDraw.c | 609 +++++++++++++++------------------- macosx/tkMacOSXEntry.c | 51 ++- macosx/tkMacOSXEvent.c | 15 +- macosx/tkMacOSXInit.c | 50 ++- macosx/tkMacOSXInt.h | 119 ++++++- macosx/tkMacOSXMenu.c | 4 +- macosx/tkMacOSXMouseEvent.c | 19 +- macosx/tkMacOSXRegion.c | 6 +- macosx/tkMacOSXScale.c | 14 +- macosx/tkMacOSXScrlbr.c | 14 +- macosx/tkMacOSXSubwindows.c | 39 +-- macosx/tkMacOSXWindowEvent.c | 4 +- macosx/tkMacOSXWm.c | 81 ++--- macosx/tkMacOSXXStubs.c | 5 +- tests/ttk/notebook.test | 45 ++- tests/ttk/panedwindow.test | 56 +++- unix/configure | 52 +-- unix/configure.in | 16 +- unix/tcl.m4 | 23 +- win/tkWinMenu.c | 31 +- win/tkWinWm.c | 20 +- 33 files changed, 1300 insertions(+), 996 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6f4aa52..4864d16 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,100 @@ +2007-06-09 Joe English + + * generic/ttk/ttkPanedwindow.c, doc/ttk_panedwindow.n, + tests/ttk/panedwindow.test: Added -width and -height options. + Added 'panes' method, return list of managed windows. + 'sashpos' method is now documented as part of the public + interface, and details clarified. Should be easier + to set initial sash positions now [Alleviates #1659067]. + +2007-06-09 Jeff Hobbs + + * win/tkWinWm.c (WmIconphotoCmd): fix wm iconphoto RGBA issues. + [Bug 1467997] (janssen) + + * win/tkWinMenu.c (TkWinHandleMenuEvent): improve handling to + allow for unicode char menu indices and not use CharUpper on Tcl + utf strings. [Bug #1734223] + +2007-06-09 Joe English + + * generic/ttk/ttkManager.h, generic/ttk/ttkManager.c, + generic/ttk/ttkNotebook.c, generic/ttk/ttkPanedwindow.c, + generic/ttk/ttkFrame.c: Ttk_Manager API overhaul: + + Ttk_Manager no longer responsible for managing slave records + + Ttk_Manager structure now opaque + + Ttk_Slave structure now private + + Pass Ttk_Manager * to Tk_GeomMgr hooks instead of Ttk_Slave * + + * generic/ttk/ttkFrame.c: Simplified -labelwidget management. + + * doc/ttk_panedwindow.n, library/ttk/panedwindow.tcl: + Changed documentation of ttk::panedwindow 'identify' command + to match implementation. + + * generic/ttk/ttkNotebook.c, tests/ttk/notebook.test: + BUGFIX: ttk::noteboook 'insert' command didn't correctly + maintain current tab. + +2007-06-09 Daniel Steffen + + * macosx/tkMacOSXColor.c: fix issues with TK_{IF,ELSE,ENDIF} macros; + * macosx/tkMacOSXDraw.c: implement Jaguar equivalent of unavailable + * macosx/tkMacOSXEntry.c: kHIToolboxVersion global; panic at startup + * macosx/tkMacOSXEvent.c: if MAC_OS_X_VERSION_MIN_REQUIRED constraint + * macosx/tkMacOSXInit.c: is not satisfied. + * macosx/tkMacOSXInt.h: + * macosx/tkMacOSXWm.c: + + * macosx/tkMacOSXDraw.c (XCopyArea, XCopyPlane, TkPutImage) + (TkMacOSXSetupDrawingContext): factor out common code and standardize + setup/restore of port, context and clipping; formatting cleanup. + + * macosx/tkMacOSXWindowEvent.c: add error checking. + * macosx/tkMacOSXMenu.c: fix gcc3 warning. + * macosx/tkMacOSXScrlbr.c: fix testsuite crash. + * macosx/tkMacOSXSubwindows.c: formatting cleanup. + * macosx/tkMacOSXRegion.c: fix typos. + * macosx/tkMacOSXScale.c: + + * macosx/tkMacOSXXStubs.c (Tk_GetUserInactiveTime): remove superfluous + CFRetain/CFRelease. + + * macosx/Wish-Release.xcconfig: disable tktest release build stripping. + + * macosx/Wish.xcodeproj/project.pbxproj: add new Tclsh-Info.plist.in. + +2007-06-06 Daniel Steffen + + * macosx/tkMacOSXInt.h: use native debug message API when available. + * macosx/Wish-Debug.xcconfig: + + * macosx/tkMacOSXMouseEvent.c (GenerateMouseWheelEvent): enable + processing of mousewheel events in background windows. + + * macosx/tkMacOSXScrlbr.c: modernize checks for active/front window. + * macosx/tkMacOSXScale.c: + * macosx/tkMacOSXWm.c: + + * macosx/tkMacOSXColor.c: factor out verbose #ifdef checks of + * macosx/tkMacOSXDraw.c: MAC_OS_X_VERSION_{MAX_ALLOWED,MIN_REQUIRED} + * macosx/tkMacOSXEntry.c: and runtime checks of kHIToolboxVersion into + * macosx/tkMacOSXEvent.c: new TK_{IF,ELSE,ENDIF}_MAC_OS_X macros. + * macosx/tkMacOSXInit.c: + * macosx/tkMacOSXInt.h: + * macosx/tkMacOSXWm.c: + + * macosx/tkMacOSXDraw.c: factor out clip clearing in QD ports; + * macosx/tkMacOSXEntry.c: formatting cleanup. + + * macosx/Wish.xcodeproj/project.pbxproj: add settings for Fix&Continue. + + * unix/configure.in (Darwin): link the Tk and Wish plists into their + binaries in all cases; fix 64bit arch removal in fat 32&64bit builds. + + * unix/tcl.m4 (Darwin): fix CF checks in fat 32&64bit builds. + * unix/configure: autoconf-2.59 + 2007-06-05 Donal K. Fellows * doc/photo.n: Clarified the fact that base64 support for the -data @@ -51,7 +148,7 @@ to native button drawing calls. * macosx/tkMacOSXWm.c (TkMacOSXIsWindowZoomed, TkMacOSXZoomToplevel): - correct handle gridded windows in max size calculations. + correct handling of gridded windows in max size calculations. * macosx/tkMacOSXEvent.c (TkMacOSXFlushWindows): use HIWindowFlush API when available. diff --git a/doc/ttk_panedwindow.n b/doc/ttk_panedwindow.n index d823473..b664f95 100644 --- a/doc/ttk_panedwindow.n +++ b/doc/ttk_panedwindow.n @@ -4,7 +4,7 @@ '\" See the file "license.terms" for information on usage and redistribution '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. '\" -'\" RCS: @(#) $Id: ttk_panedwindow.n,v 1.4 2007/05/03 23:55:30 dkf Exp $ +'\" RCS: @(#) $Id: ttk_panedwindow.n,v 1.4.2.1 2007/06/12 16:22:40 dgp Exp $ '\" .so man.macros .TH ttk_panedwindow n 8.5 Tk "Tk Themed Widget" @@ -34,6 +34,16 @@ of the subwindows by dragging the sash between panes. Specifies the orientation of the window. If \fBvertical\fR, subpanes are stacked top-to-bottom; if \fBhorizontal\fR, subpanes are stacked left-to-right. +.OP \-width width Width +If present and greater than zero, +specifies the desired width of the widget in pixels. +Otherwise, the requested width is determined by the width +of the managed windows. +.OP \-height height Height +If present and greater than zero, +specifies the desired height of the widget in pixels. +Otherwise, the requested height is determined by the height +of the managed windows. .SH "PANE OPTIONS" The following options may be specified for each pane: @@ -71,20 +81,23 @@ If no \fI-option\fR is specified, returns a dictionary of the pane option values. If one \fI-option\fR is specified, returns the value of that \fIoption\fR. Otherwise, sets the \fI-option\fRs to the corresponding \fIvalue\fRs. - -.SH "INTERNAL ROUTINES" -The following routines are used internally by the \fBpaned\fR widget -binding code. .TP \fIpathname\fR \fBsashpos\fR \fIindex\fR ?\fInewpos\fR? -If \fInewpos\fR is specified, sets the sash position -(subject to constraints). -Returns the position of sash number \fIindex\fR. +If \fInewpos\fR is specified, sets the position +of sash number \fIindex\fR. +May adjust the positions of adjacent sashes +to ensure that positions are monotonically increasing. +Sash positions are further constrained to be between 0 +and the total size of the widget. +.\" Full story: "total size" is either the -height (resp -width), +.\" or the actual window height (resp actual window width), +.\" depending on which changed most recently. +Returns the new position of sash number \fIindex\fR. +.\" Full story: new position may be different than the requested position. .TP \fIpathname\fR \fBidentify\fR \fIx y\fR -Returns a list consisting of the sash index at point \fIx,y\fR -and the name of the sash subelement at that point. -Returns the empty list if \fIx,y\fR is not over a sash. +Returns the index of the sash at point \fIx,y\fR, +or the empty string if \fIx,y\fR is not over a sash. .SH "SEE ALSO" ttk_widget(n), ttk_notebook(n), panedwindow(n) diff --git a/generic/ttk/ttkFrame.c b/generic/ttk/ttkFrame.c index ee5259f..9732d7c 100644 --- a/generic/ttk/ttkFrame.c +++ b/generic/ttk/ttkFrame.c @@ -1,4 +1,4 @@ -/* $Id: ttkFrame.c,v 1.5 2007/01/11 14:49:47 jenglish Exp $ +/* $Id: ttkFrame.c,v 1.5.2.1 2007/06/12 16:22:40 dgp Exp $ * Copyright (c) 2004, Joe English * * ttk::frame and ttk::labelframe widgets. @@ -234,10 +234,9 @@ typedef struct { Tcl_Obj *labelAnchorObj; Tcl_Obj *textObj; Tcl_Obj *underlineObj; - Tcl_Obj *labelWidgetObj; + Tk_Window labelWidget; Ttk_Manager *mgr; - Tk_Window labelWidget; /* Set in configureProc */ Ttk_Box labelParcel; /* Set in layoutProc */ } LabelframePart; @@ -262,7 +261,7 @@ static Tk_OptionSpec LabelframeOptionSpecs[] = "-1", Tk_Offset(Labelframe,label.underlineObj), -1, 0,0,0 }, {TK_OPTION_WINDOW, "-labelwidget", "labelWidget", "LabelWidget", NULL, - Tk_Offset(Labelframe,label.labelWidgetObj), -1, + -1, Tk_Offset(Labelframe,label.labelWidget), TK_OPTION_NULL_OK,0,LABELWIDGET_CHANGED|GEOMETRY_CHANGED }, WIDGET_INHERIT_OPTIONS(FrameOptionSpecs) @@ -454,47 +453,26 @@ static void LabelframePlaceSlaves(void *recordPtr) /* Labelframe geometry manager: */ -static void LabelAdded(Ttk_Manager *mgr, int slaveIndex) { /* no-op */ } -static void LabelRemoved(Ttk_Manager *mgr, int slaveIndex) { /* no-op */ } -static int LabelConfigured( - Tcl_Interp *interp, Ttk_Manager *mgr, Ttk_Slave *slave, unsigned mask) - { return TCL_OK; } - -/* LabelframeLostSlave -- - * Called when the labelWidget slave is involuntarily lost; - * unset the -labelwidget option. - * Notes: - * Do this here instead of in the SlaveRemoved hook, - * since the latter is also called when the widget voluntarily - * forgets the slave. The latter happens in the ConfigureProc - * at a time when the widget is in an inconsistent state. + +/* LabelRemoved -- + * Unset the -labelwidget option. + * + * <>: + * This routine is also called when the widget voluntarily forgets + * the slave in LabelframeConfigure. */ -static void LabelframeLostSlave(ClientData clientData, Tk_Window slaveWindow) +static void LabelRemoved(Ttk_Manager *mgr, int slaveIndex) { - Ttk_Slave *slave = clientData; - Labelframe *lframePtr = slave->manager->managerData; - - Tcl_DecrRefCount(lframePtr->label.labelWidgetObj); - lframePtr->label.labelWidgetObj = 0; - lframePtr->label.labelWidget = 0; - Ttk_LostSlaveProc(clientData, slaveWindow); + Labelframe *lframe = Ttk_ManagerData(mgr); + lframe->label.labelWidget = 0; } -static Tk_OptionSpec LabelOptionSpecs[] = { - {TK_OPTION_END, 0,0,0, NULL, -1,-1, 0, 0,0} -}; - static Ttk_ManagerSpec LabelframeManagerSpec = { - { "labelframe", Ttk_GeometryRequestProc, LabelframeLostSlave }, - LabelOptionSpecs, 0, - + { "labelframe", Ttk_GeometryRequestProc, Ttk_LostSlaveProc }, LabelframeSize, LabelframePlaceSlaves, - - LabelAdded, - LabelRemoved, - LabelConfigured + LabelRemoved }; /* LabelframeInitialize -- @@ -546,22 +524,14 @@ static void RaiseLabelWidget(Labelframe *lframe) static int LabelframeConfigure(Tcl_Interp *interp,void *recordPtr,int mask) { Labelframe *lframePtr = recordPtr; - Tk_Window labelWidget = NULL; + Tk_Window labelWidget = lframePtr->label.labelWidget; Ttk_PositionSpec unused; - /* Validate -labelwidget option: + /* Validate options: */ - if (lframePtr->label.labelWidgetObj) { - const char *pathName = Tcl_GetString(lframePtr->label.labelWidgetObj); - if (pathName && *pathName) { - labelWidget = - Tk_NameToWindow(interp, pathName, lframePtr->core.tkwin); - if (!labelWidget) { - return TCL_ERROR; - } - if (!Ttk_Maintainable(interp, labelWidget, lframePtr->core.tkwin)) { - return TCL_ERROR; - } + if (mask & LABELWIDGET_CHANGED && labelWidget != NULL) { + if (!Ttk_Maintainable(interp, labelWidget, lframePtr->core.tkwin)) { + return TCL_ERROR; } } @@ -582,12 +552,13 @@ static int LabelframeConfigure(Tcl_Interp *interp,void *recordPtr,int mask) if (mask & LABELWIDGET_CHANGED) { if (Ttk_NumberSlaves(lframePtr->label.mgr) == 1) { Ttk_ForgetSlave(lframePtr->label.mgr, 0); + /* Restore labelWidget field (see <>) + */ + lframePtr->label.labelWidget = labelWidget; } - lframePtr->label.labelWidget = labelWidget; - if (labelWidget) { - Ttk_AddSlave(interp, lframePtr->label.mgr, labelWidget, 0, 0,0); + Ttk_InsertSlave(lframePtr->label.mgr, 0, labelWidget, NULL); RaiseLabelWidget(lframePtr); } } diff --git a/generic/ttk/ttkManager.c b/generic/ttk/ttkManager.c index 319e465..f83bf2a 100644 --- a/generic/ttk/ttkManager.c +++ b/generic/ttk/ttkManager.c @@ -1,8 +1,8 @@ -/* $Id: ttkManager.c,v 1.3 2007/01/11 19:59:26 jenglish Exp $ +/* $Id: ttkManager.c,v 1.3.2.1 2007/06/12 16:22:40 dgp Exp $ * * Copyright 2005, Joe English. Freely redistributable. * - * Ttk widget set: support routines for geometry managers. + * Support routines for geometry managers. */ #include @@ -41,19 +41,38 @@ * in this case Tk does _not_ call the LostSlaveProc (documented behavior). * Tk doesn't handle case (3) either; to account for that we * register an event handler on the slave widget to track events. - * */ -/* ++ manager->flags bits: +/* ++ Data structures. */ -#define MGR_UPDATE_PENDING 0x1 -#define MGR_RESIZE_REQUIRED 0x2 -#define MGR_RELAYOUT_REQUIRED 0x4 +typedef struct +{ + Tk_Window slaveWindow; + Ttk_Manager *manager; + void *slaveData; + unsigned flags; +} Ttk_Slave; -/* ++ slave->flags bits: +/* slave->flags bits: */ #define SLAVE_MAPPED 0x1 /* slave to be mapped when master is */ +struct TtkManager_ +{ + Ttk_ManagerSpec *managerSpec; + void *managerData; + Tk_Window masterWindow; + unsigned flags; + int nSlaves; + Ttk_Slave **slaves; +}; + +/* manager->flags bits: + */ +#define MGR_UPDATE_PENDING 0x1 +#define MGR_RESIZE_REQUIRED 0x2 +#define MGR_RELAYOUT_REQUIRED 0x4 + static void ManagerIdleProc(void *); /* forward */ /* ++ ScheduleUpdate -- @@ -103,7 +122,7 @@ static void ManagerIdleProc(ClientData clientData) if (mgr->flags & MGR_RESIZE_REQUIRED) { RecomputeSize(mgr); - } + } if (mgr->flags & MGR_RELAYOUT_REQUIRED) { if (mgr->flags & MGR_UPDATE_PENDING) { /* RecomputeSize has scheduled another update; relayout later */ @@ -127,7 +146,7 @@ static void ManagerEventHandler(ClientData clientData, XEvent *eventPtr) Ttk_Manager *mgr = clientData; int i; - switch (eventPtr->type) + switch (eventPtr->type) { case ConfigureNotify: RecomputeLayout(mgr); @@ -159,7 +178,7 @@ static void SlaveEventHandler(ClientData clientData, XEvent *eventPtr) Ttk_Slave *slave = clientData; if (eventPtr->type == DestroyNotify) { slave->manager->managerSpec->tkGeomMgr.lostSlaveProc( - clientData, slave->slaveWindow); + slave->manager, slave->slaveWindow); } } @@ -167,40 +186,21 @@ static void SlaveEventHandler(ClientData clientData, XEvent *eventPtr) * +++ Slave initialization and cleanup. */ -static Ttk_Slave *CreateSlave( - Tcl_Interp *interp, Ttk_Manager *mgr, Tk_Window slaveWindow) +static Ttk_Slave *NewSlave( + Ttk_Manager *mgr, Tk_Window slaveWindow, void *slaveData) { Ttk_Slave *slave = (Ttk_Slave*)ckalloc(sizeof(*slave)); - int status; slave->slaveWindow = slaveWindow; slave->manager = mgr; slave->flags = 0; - slave->slaveData = ckalloc(mgr->managerSpec->slaveSize); - memset(slave->slaveData, 0, mgr->managerSpec->slaveSize); - - if (!mgr->slaveOptionTable) { - mgr->slaveOptionTable = - Tk_CreateOptionTable(interp, mgr->managerSpec->slaveOptionSpecs); - } - - status = Tk_InitOptions( - interp, slave->slaveData, mgr->slaveOptionTable, slaveWindow); - - if (status != TCL_OK) { - ckfree((ClientData)slave->slaveData); - ckfree((ClientData)slave); - return NULL; - } + slave->slaveData = slaveData; return slave; } static void DeleteSlave(Ttk_Slave *slave) { - Tk_FreeConfigOptions( - slave->slaveData, slave->manager->slaveOptionTable, slave->slaveWindow); - ckfree((ClientData)slave->slaveData); ckfree((ClientData)slave); } @@ -216,7 +216,6 @@ Ttk_Manager *Ttk_CreateManager( mgr->managerSpec = managerSpec; mgr->managerData = managerData; mgr->masterWindow = masterWindow; - mgr->slaveOptionTable= 0; mgr->nSlaves = 0; mgr->slaves = NULL; mgr->flags = 0; @@ -238,9 +237,6 @@ void Ttk_DeleteManager(Ttk_Manager *mgr) if (mgr->slaves) { ckfree((ClientData)mgr->slaves); } - if (mgr->slaveOptionTable) { - Tk_DeleteOptionTable(mgr->slaveOptionTable); - } Tk_CancelIdleCall(ManagerIdleProc, mgr); @@ -268,7 +264,7 @@ static void InsertSlave(Ttk_Manager *mgr, Ttk_Slave *slave, int index) mgr->slaves[index] = slave; Tk_ManageGeometry(slave->slaveWindow, - &mgr->managerSpec->tkGeomMgr, (ClientData)slave); + &mgr->managerSpec->tkGeomMgr, (ClientData)mgr); Tk_CreateEventHandler(slave->slaveWindow, SlaveEventMask, SlaveEventHandler, (ClientData)slave); @@ -281,7 +277,7 @@ static void InsertSlave(Ttk_Manager *mgr, Ttk_Slave *slave, int index) * * NOTES/ASSUMPTIONS: * - * [1] It's safe to call Tk_UnmapWindow / Tk_UnmaintainGeometry even if this + * [1] It's safe to call Tk_UnmapWindow / Tk_UnmaintainGeometry even if this * routine is called from the slave's DestroyNotify event handler. */ static void RemoveSlave(Ttk_Manager *mgr, int index) @@ -320,85 +316,31 @@ static void RemoveSlave(Ttk_Manager *mgr, int index) void Ttk_GeometryRequestProc(ClientData clientData, Tk_Window slaveWindow) { - Ttk_Slave *slave = clientData; - ScheduleUpdate(slave->manager, MGR_RESIZE_REQUIRED); + Ttk_Manager *mgr = clientData; + ScheduleUpdate(mgr, MGR_RESIZE_REQUIRED); } void Ttk_LostSlaveProc(ClientData clientData, Tk_Window slaveWindow) { - Ttk_Slave *slave = clientData; - int index = Ttk_SlaveIndex(slave->manager, slave->slaveWindow); + Ttk_Manager *mgr = clientData; + int index = Ttk_SlaveIndex(mgr, slaveWindow); /* ASSERT: index >= 0 */ - RemoveSlave(slave->manager, index); + RemoveSlave(mgr, index); } /*------------------------------------------------------------------------ * +++ Public API. */ -/* ++ Ttk_AddSlave -- - * Create and configure new slave window, insert at specified index. - * - * Returns: - * TCL_OK or TCL_ERROR; in the case of TCL_ERROR, the slave - * is not added and an error message is left in interp. +/* ++ Ttk_InsertSlave -- + * Add a new slave window at the specified index. */ -int Ttk_AddSlave( - Tcl_Interp *interp, Ttk_Manager *mgr, Tk_Window slaveWindow, - int index, int objc, Tcl_Obj *CONST objv[]) +void Ttk_InsertSlave( + Ttk_Manager *mgr, int index, Tk_Window tkwin, void *slaveData) { - Ttk_Slave *slave; - - /* Sanity-checks: - */ - if (!Ttk_Maintainable(interp, slaveWindow, mgr->masterWindow)) { - return TCL_ERROR; - } - if (Ttk_SlaveIndex(mgr, slaveWindow) >= 0) { - Tcl_AppendResult(interp, - Tk_PathName(slaveWindow), " already added", - NULL); - return TCL_ERROR; - } - - /* Create, configure, and insert slave: - */ - slave = CreateSlave(interp, mgr, slaveWindow); - if (Ttk_ConfigureSlave(interp, mgr, slave, objc, objv) != TCL_OK) { - DeleteSlave(slave); - return TCL_ERROR; - } + Ttk_Slave *slave = NewSlave(mgr, tkwin, slaveData); InsertSlave(mgr, slave, index); - mgr->managerSpec->SlaveAdded(mgr, index); - return TCL_OK; -} - -/* ++ Ttk_ConfigureSlave -- - */ -int Ttk_ConfigureSlave( - Tcl_Interp *interp, Ttk_Manager *mgr, Ttk_Slave *slave, - int objc, Tcl_Obj *CONST objv[]) -{ - Tk_SavedOptions savedOptions; - int mask = 0; - - /* ASSERT: mgr->slaveOptionTable != NULL */ - - if (Tk_SetOptions(interp, slave->slaveData, mgr->slaveOptionTable, - objc, objv, slave->slaveWindow, &savedOptions, &mask) != TCL_OK) - { - return TCL_ERROR; - } - - if (mgr->managerSpec->SlaveConfigured(interp,mgr,slave,mask) != TCL_OK) { - Tk_RestoreSavedOptions(&savedOptions); - return TCL_ERROR; - } - - Tk_FreeSavedOptions(&savedOptions); - ScheduleUpdate(mgr, MGR_RELAYOUT_REQUIRED); - return TCL_OK; } /* ++ Ttk_ForgetSlave -- @@ -437,7 +379,7 @@ void Ttk_UnmapSlave(Ttk_Manager *mgr, int slaveIndex) Ttk_Slave *slave = mgr->slaves[slaveIndex]; Tk_UnmaintainGeometry(slave->slaveWindow, mgr->masterWindow); slave->flags &= ~SLAVE_MAPPED; - /* Contrary to documentation, Tk_UnmaintainGeometry doesn't always + /* Contrary to documentation, Tk_UnmaintainGeometry doesn't always * unmap the slave: */ Tk_UnmapWindow(slave->slaveWindow); @@ -458,9 +400,13 @@ void Ttk_ManagerSizeChanged(Ttk_Manager *mgr) /* +++ Accessors. */ -int Ttk_NumberSlaves(Ttk_Manager *mgr) +int Ttk_NumberSlaves(Ttk_Manager *mgr) { - return mgr->nSlaves; + return mgr->nSlaves; +} +void *Ttk_ManagerData(Ttk_Manager *mgr) +{ + return mgr->managerData; } void *Ttk_SlaveData(Ttk_Manager *mgr, int slaveIndex) { @@ -487,17 +433,16 @@ int Ttk_SlaveIndex(Ttk_Manager *mgr, Tk_Window slaveWindow) return -1; } -/* ++ Ttk_GetSlaveFromObj(interp, mgr, objPtr, indexPtr) -- +/* ++ Ttk_GetSlaveIndexFromObj(interp, mgr, objPtr, indexPtr) -- * Return the index of the slave specified by objPtr. * Slaves may be specified as an integer index or * as the name of the managed window. * * Returns: - * Pointer to slave; stores slave index in *indexPtr. - * On error, returns NULL and leaves an error message in interp. + * Standard Tcl completion code. Leaves an error message in case of error. */ -Ttk_Slave *Ttk_GetSlaveFromObj( +int Ttk_GetSlaveIndexFromObj( Tcl_Interp *interp, Ttk_Manager *mgr, Tcl_Obj *objPtr, int *indexPtr) { const char *string = Tcl_GetString(objPtr); @@ -512,10 +457,10 @@ Ttk_Slave *Ttk_GetSlaveFromObj( Tcl_AppendResult(interp, "Slave index ", Tcl_GetString(objPtr), " out of bounds", NULL); - return NULL; + return TCL_ERROR; } *indexPtr = slaveIndex; - return mgr->slaves[slaveIndex]; + return TCL_OK; } /* Try interpreting as a slave window name; @@ -529,15 +474,15 @@ Ttk_Slave *Ttk_GetSlaveFromObj( Tcl_AppendResult(interp, string, " is not managed by ", Tk_PathName(mgr->masterWindow), NULL); - return NULL; + return TCL_ERROR; } *indexPtr = slaveIndex; - return mgr->slaves[slaveIndex]; + return TCL_OK; } Tcl_ResetResult(interp); Tcl_AppendResult(interp, "Invalid slave specification ", string, NULL); - return NULL; + return TCL_ERROR; } /* ++ Ttk_ReorderSlave(mgr, fromIndex, toIndex) -- @@ -569,7 +514,7 @@ void Ttk_ReorderSlave(Ttk_Manager *mgr, int fromIndex, int toIndex) /* ++ Ttk_Maintainable(interp, slave, master) -- * Utility routine. Verifies that 'master' may be used to maintain * the geometry of 'slave' via Tk_MaintainGeometry: - * + * * + 'master' is either 'slave's parent -OR- * + 'master is a descendant of 'slave's parent. * + 'slave' is not a toplevel window @@ -596,7 +541,7 @@ int Ttk_Maintainable(Tcl_Interp *interp, Tk_Window slave, Tk_Window master) return 1; badWindow: - Tcl_AppendResult(interp, + Tcl_AppendResult(interp, "can't add ", Tk_PathName(slave), " as slave of ", Tk_PathName(master), NULL); diff --git a/generic/ttk/ttkManager.h b/generic/ttk/ttkManager.h index c03c3da..777b940 100644 --- a/generic/ttk/ttkManager.h +++ b/generic/ttk/ttkManager.h @@ -1,10 +1,8 @@ -/* $Id: ttkManager.h,v 1.5 2007/01/11 14:49:47 jenglish Exp $ +/* $Id: ttkManager.h,v 1.5.2.1 2007/06/12 16:22:41 dgp Exp $ * * Copyright (c) 2005, Joe English. Freely redistributable. * - * Ttk widget set: Geometry management utilities. - * - * TODO: opacify data structures. + * Geometry manager utilities. */ #ifndef _TTKMANAGER @@ -12,8 +10,7 @@ #include "ttkTheme.h" -typedef struct TtkManager_ Ttk_Manager; /* forward */ -typedef struct TtkSlave_ Ttk_Slave; /* forward */ +typedef struct TtkManager_ Ttk_Manager; /* * Geometry manager specification record: @@ -23,24 +20,16 @@ typedef struct TtkSlave_ Ttk_Slave; /* forward */ * PlaceSlaves sets the position and size of all managed slaves * by calling Ttk_PlaceSlave(). * - * SlaveAdded() is called after a new slave has been added. - * * SlaveRemoved() is called immediately before a slave is removed. * NB: the associated slave window may have been destroyed when this * routine is called. */ typedef struct { /* Manager hooks */ Tk_GeomMgr tkGeomMgr; /* "real" Tk Geometry Manager */ - Tk_OptionSpec *slaveOptionSpecs; /* slave record options */ - size_t slaveSize; /* size of slave record */ int (*RequestedSize)(void *managerData, int *widthPtr, int *heightPtr); void (*PlaceSlaves)(void *managerData); - - void (*SlaveAdded)(Ttk_Manager *, int slaveIndex); void (*SlaveRemoved)(Ttk_Manager *, int slaveIndex); - int (*SlaveConfigured)( - Tcl_Interp *, Ttk_Manager *, Ttk_Slave *, unsigned mask); } Ttk_ManagerSpec; /* @@ -49,25 +38,6 @@ typedef struct { /* Manager hooks */ MODULE_SCOPE void Ttk_GeometryRequestProc(ClientData, Tk_Window slave); MODULE_SCOPE void Ttk_LostSlaveProc(ClientData, Tk_Window slave); -struct TtkSlave_ -{ - Tk_Window slaveWindow; - Ttk_Manager *manager; - void *slaveData; - unsigned flags; /* private; see manager.c */ -}; - -struct TtkManager_ -{ - Ttk_ManagerSpec *managerSpec; - void *managerData; - Tk_Window masterWindow; - Tk_OptionTable slaveOptionTable; - unsigned flags; /* private; see manager.c */ - int nSlaves; - Ttk_Slave **slaves; -}; - /* * Public API: */ @@ -75,16 +45,11 @@ MODULE_SCOPE Ttk_Manager *Ttk_CreateManager( Ttk_ManagerSpec *, void *managerData, Tk_Window masterWindow); MODULE_SCOPE void Ttk_DeleteManager(Ttk_Manager *); -MODULE_SCOPE int Ttk_AddSlave( - Tcl_Interp *, Ttk_Manager *, Tk_Window, int position, - int objc, Tcl_Obj *CONST objv[]); +MODULE_SCOPE void Ttk_InsertSlave( + Ttk_Manager *, int position, Tk_Window, void *slaveData); MODULE_SCOPE void Ttk_ForgetSlave(Ttk_Manager *, int slaveIndex); -MODULE_SCOPE int Ttk_ConfigureSlave( - Tcl_Interp *interp, Ttk_Manager *, Ttk_Slave *, - int objc, Tcl_Obj *CONST objv[]); - MODULE_SCOPE void Ttk_ReorderSlave(Ttk_Manager *, int fromIndex, int toIndex); /* Rearrange slave positions */ @@ -104,7 +69,7 @@ MODULE_SCOPE void Ttk_ManagerLayoutChanged(Ttk_Manager *); MODULE_SCOPE int Ttk_SlaveIndex(Ttk_Manager *, Tk_Window); /* Returns: index in slave array of specified window, -1 if not found */ -MODULE_SCOPE Ttk_Slave *Ttk_GetSlaveFromObj( +MODULE_SCOPE int Ttk_GetSlaveIndexFromObj( Tcl_Interp *, Ttk_Manager *, Tcl_Obj *, int *indexPtr); /* Accessor functions: @@ -112,8 +77,11 @@ MODULE_SCOPE Ttk_Slave *Ttk_GetSlaveFromObj( MODULE_SCOPE int Ttk_NumberSlaves(Ttk_Manager *); /* Returns: number of managed slaves */ +MODULE_SCOPE void *Ttk_ManagerData(Ttk_Manager *); + /* Returns: client data associated with master */ + MODULE_SCOPE void *Ttk_SlaveData(Ttk_Manager *, int slaveIndex); - /* Returns: private data associated with slave */ + /* Returns: client data associated with slave */ MODULE_SCOPE Tk_Window Ttk_SlaveWindow(Ttk_Manager *, int slaveIndex); /* Returns: slave window */ diff --git a/generic/ttk/ttkNotebook.c b/generic/ttk/ttkNotebook.c index a9596b9..3fe4c08 100644 --- a/generic/ttk/ttkNotebook.c +++ b/generic/ttk/ttkNotebook.c @@ -1,4 +1,4 @@ -/* $Id: ttkNotebook.c,v 1.8 2007/01/11 19:59:26 jenglish Exp $ +/* $Id: ttkNotebook.c,v 1.8.2.1 2007/06/12 16:22:41 dgp Exp $ * Copyright (c) 2004, Joe English * * NOTE-ACTIVE: activeTabIndex is not always correct (it's @@ -188,6 +188,67 @@ static void NotebookStyleOptions(Notebook *nb, NotebookStyle *nbstyle) * +++ Tab management. */ +static Tab *CreateTab(Tcl_Interp *interp, Notebook *nb, Tk_Window slaveWindow) +{ + Tk_OptionTable optionTable = nb->notebook.paneOptionTable; + void *record = ckalloc(sizeof(Tab)); + memset(record, 0, sizeof(Tab)); + + if (Tk_InitOptions(interp, record, optionTable, slaveWindow) != TCL_OK) { + ckfree(record); + return NULL; + } + + return record; +} + +static void DestroyTab(Notebook *nb, Tab *tab) +{ + void *record = tab; + Tk_FreeConfigOptions(record, nb->notebook.paneOptionTable, nb->core.tkwin); + ckfree(record); +} + +static int ConfigureTab( + Tcl_Interp *interp, Notebook *nb, Tab *tab, Tk_Window slaveWindow, + int objc, Tcl_Obj *CONST objv[]) +{ + Ttk_Sticky sticky = tab->sticky; + Ttk_Padding padding = tab->padding; + Tk_SavedOptions savedOptions; + int mask = 0; + + if (Tk_SetOptions(interp, (ClientData)tab, nb->notebook.paneOptionTable, + objc, objv, slaveWindow, &savedOptions, &mask) != TCL_OK) + { + return TCL_ERROR; + } + + /* Check options: + * @@@ TODO: validate -image option. + */ + if (Ttk_GetStickyFromObj(interp, tab->stickyObj, &sticky) != TCL_OK) + { + goto error; + } + if (Ttk_GetPaddingFromObj(interp, slaveWindow, tab->paddingObj, &padding) + != TCL_OK) + { + goto error; + } + + tab->sticky = sticky; + tab->padding = padding; + + Tk_FreeSavedOptions(&savedOptions); + Ttk_ManagerSizeChanged(nb->notebook.mgr); + + return TCL_OK; +error: + Tk_RestoreSavedOptions(&savedOptions); + return TCL_ERROR; +} + /* * IdentifyTab -- * Return the index of the tab at point x,y, @@ -605,17 +666,14 @@ static void SelectNearestTab(Notebook *nb) } } -/* TabAdded -- GM SlaveAdded hook. - */ -static void TabAdded(Ttk_Manager *mgr, int slaveIndex) { /* No-op */ } - /* TabRemoved -- GM SlaveRemoved hook. * Select the next tab if the current one is being removed. - * Adjust currentIndex to account for removed slave if needed. + * Adjust currentIndex to account for removed slave. */ static void TabRemoved(Ttk_Manager *mgr, int index) { - Notebook *nb = mgr->managerData; + Notebook *nb = Ttk_ManagerData(mgr); + Tab *tab = Ttk_SlaveData(mgr, index); if (index == nb->notebook.currentIndex) { SelectNearestTab(nb); @@ -625,44 +683,49 @@ static void TabRemoved(Ttk_Manager *mgr, int index) --nb->notebook.currentIndex; } + DestroyTab(nb, tab); + TtkRedisplayWidget(&nb->core); } -/* TabConfigured -- GM slaveConfigured hook. - */ -static int TabConfigured( - Tcl_Interp *interp, Ttk_Manager *mgr, Ttk_Slave *slave, unsigned mask) + +static int AddTab( + Tcl_Interp *interp, Notebook *nb, + int destIndex, Tk_Window slaveWindow, + int objc, Tcl_Obj *const objv[]) { - Tab *tab = slave->slaveData; - Ttk_Sticky sticky = tab->sticky; - Tk_Window tkwin = mgr->masterWindow; + Tab *tab; + if (!Ttk_Maintainable(interp, slaveWindow, nb->core.tkwin)) { + return TCL_ERROR; + } + if (Ttk_SlaveIndex(nb->notebook.mgr, slaveWindow) >= 0) { + Tcl_AppendResult(interp, + Tk_PathName(slaveWindow), " already added", + NULL); + return TCL_ERROR; + } - /* Check options: - * @@@ TODO: validate -image option. + /* Create and insert tab. */ - if (Ttk_GetStickyFromObj(interp, tab->stickyObj, &sticky) != TCL_OK) { + tab = CreateTab(interp, nb, slaveWindow); + if (!tab) { return TCL_ERROR; } - if (Ttk_GetPaddingFromObj(interp,tkwin,tab->paddingObj,&tab->padding) - != TCL_OK) - { + if (ConfigureTab(interp, nb, tab, slaveWindow, objc, objv) != TCL_OK) { + DestroyTab(nb, tab); return TCL_ERROR; } - tab->sticky = sticky; + Ttk_InsertSlave(nb->notebook.mgr, destIndex, slaveWindow, tab); return TCL_OK; } static Ttk_ManagerSpec NotebookManagerSpec = { { "notebook", Ttk_GeometryRequestProc, Ttk_LostSlaveProc }, - PaneOptionSpecs, sizeof(Tab), - NotebookSize, NotebookPlaceSlaves, - TabAdded, TabRemoved, - TabConfigured }; /*------------------------------------------------------------------------ @@ -736,13 +799,13 @@ static int FindTabIndex( /* ... or integer index or slave window name: */ - if (Ttk_GetSlaveFromObj( - interp, nb->notebook.mgr, objPtr, index_rtn) != NULL) + if (Ttk_GetSlaveIndexFromObj( + interp, nb->notebook.mgr, objPtr, index_rtn) == TCL_OK) { return TCL_OK; } - /* Nothing matched; Ttk_GetSlaveFromObj will have left error message. + /* Nothing matched; Ttk_GetSlaveIndexFromObj will have left error message. */ return TCL_ERROR; } @@ -777,7 +840,7 @@ static int NotebookAddCommand( Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[], void *recordPtr) { Notebook *nb = recordPtr; - int index = nb->notebook.mgr->nSlaves; + int index = Ttk_NumberSlaves(nb->notebook.mgr); Tk_Window slaveWindow; if (objc <= 2 || objc % 2 != 1) { @@ -792,10 +855,8 @@ static int NotebookAddCommand( /* Create and initialize new tab: */ - if (TCL_OK != Ttk_AddSlave( - interp, nb->notebook.mgr, slaveWindow, index, objc-3,objv+3) ) - { - return TCL_ERROR; + if (AddTab(interp, nb, index, slaveWindow, objc-3,objv+3) != TCL_OK) { + return TCL_ERROR; } /* If no tab is currently selected (or if this is the first tab), @@ -818,6 +879,7 @@ static int NotebookInsertCommand( { Notebook *nb = recordPtr; int current = nb->notebook.currentIndex; + int nSlaves = Ttk_NumberSlaves(nb->notebook.mgr); int srcIndex, destIndex; int status = TCL_OK; @@ -828,26 +890,28 @@ static int NotebookInsertCommand( if (!strcmp(Tcl_GetString(objv[2]), "end")) { destIndex = Ttk_NumberSlaves(nb->notebook.mgr); - } else if (!Ttk_GetSlaveFromObj( + } else if (TCL_OK != Ttk_GetSlaveIndexFromObj( interp, nb->notebook.mgr, objv[2], &destIndex)) { return TCL_ERROR; } - if (!Ttk_GetSlaveFromObj(interp, nb->notebook.mgr, objv[3], &srcIndex)) { + if (TCL_OK != Ttk_GetSlaveIndexFromObj( + interp, nb->notebook.mgr, objv[3], &srcIndex)) + { /* Try adding new slave: */ Tk_Window slaveWindow = Tk_NameToWindow(interp,Tcl_GetString(objv[3]),nb->core.tkwin); + + /* Check validity. + */ if (!slaveWindow) { return TCL_ERROR; } - - if (Ttk_AddSlave(interp, nb->notebook.mgr, slaveWindow, - destIndex, objc - 4, objv + 4) != TCL_OK) - { + if (TCL_OK != AddTab(interp,nb,destIndex,slaveWindow,objc-4,objv+4)) { return TCL_ERROR; } - if (nb->notebook.currentIndex <= destIndex) { + if (nb->notebook.currentIndex >= destIndex) { ++nb->notebook.currentIndex; } return TCL_OK; @@ -855,8 +919,8 @@ static int NotebookInsertCommand( /* else - move existing slave: */ - if (destIndex >= nb->notebook.mgr->nSlaves) { - destIndex = nb->notebook.mgr->nSlaves - 1; + if (destIndex >= nSlaves) { + destIndex = nSlaves - 1; } Ttk_ReorderSlave(nb->notebook.mgr, srcIndex, destIndex); @@ -872,8 +936,10 @@ static int NotebookInsertCommand( } if (objc > 4) { - status = Ttk_ConfigureSlave(interp, nb->notebook.mgr, - nb->notebook.mgr->slaves[destIndex], objc-4,objv+4); + status = ConfigureTab(interp, nb, + Ttk_SlaveData(nb->notebook.mgr,destIndex), + Ttk_SlaveWindow(nb->notebook.mgr,destIndex), + objc-4,objv+4); } TtkRedisplayWidget(&nb->core); @@ -934,7 +1000,7 @@ static int NotebookIdentifyCommand( Ttk_RebindSublayout(tabLayout, tab); Ttk_PlaceLayout(tabLayout, state, tab->parcel); - node = Ttk_LayoutIdentify(tabLayout, x, y); + node = Ttk_LayoutIdentify(tabLayout, x, y); } if (node) { @@ -965,7 +1031,8 @@ static int NotebookIndexCommand( * Special-case for "end": */ if (!strcmp("end", Tcl_GetString(objv[2]))) { - Tcl_SetObjResult(interp, Tcl_NewIntObj(nb->notebook.mgr->nSlaves)); + int nSlaves = Ttk_NumberSlaves(nb->notebook.mgr); + Tcl_SetObjResult(interp, Tcl_NewIntObj(nSlaves)); return TCL_OK; } @@ -1021,7 +1088,7 @@ static int NotebookTabsCommand( } result = Tcl_NewListObj(0, NULL); - for (i = 0; i < mgr->nSlaves; ++i) { + for (i = 0; i < Ttk_NumberSlaves(mgr); ++i) { const char *pathName = Tk_PathName(Ttk_SlaveWindow(mgr,i)); Tcl_ListObjAppendElement(interp, result, Tcl_NewStringObj(pathName,-1)); } @@ -1038,7 +1105,7 @@ static int NotebookTabCommand( Notebook *nb = recordPtr; Ttk_Manager *mgr = nb->notebook.mgr; int index; - Ttk_Slave *slave; + Tk_Window slaveWindow; Tab *tab; if (objc < 3) { @@ -1050,18 +1117,18 @@ static int NotebookTabCommand( return TCL_ERROR; } - slave = mgr->slaves[index]; tab = Ttk_SlaveData(mgr, index); + slaveWindow = Ttk_SlaveWindow(mgr, index); if (objc == 3) { return TtkEnumerateOptions(interp, tab, - PaneOptionSpecs, nb->notebook.paneOptionTable, nb->core.tkwin); + PaneOptionSpecs, nb->notebook.paneOptionTable, slaveWindow); } else if (objc == 4) { return TtkGetOptionValue(interp, tab, objv[3], - nb->notebook.paneOptionTable, nb->core.tkwin); + nb->notebook.paneOptionTable, slaveWindow); } /* else */ - if (Ttk_ConfigureSlave(interp, mgr, slave, objc - 3,objv + 3) != TCL_OK) { + if (ConfigureTab(interp, nb, tab, slaveWindow, objc-3,objv+3) != TCL_OK) { return TCL_ERROR; } @@ -1180,7 +1247,8 @@ static Ttk_Layout NotebookGetLayout( return notebookLayout; } -/* +++ Display routines. +/*------------------------------------------------------------------------ + * +++ Display routines. */ static void DisplayTab(Notebook *nb, int index, Drawable d) @@ -1199,6 +1267,7 @@ static void DisplayTab(Notebook *nb, int index, Drawable d) static void NotebookDisplay(void *clientData, Drawable d) { Notebook *nb = clientData; + int nSlaves = Ttk_NumberSlaves(nb->notebook.mgr); int index; /* Draw notebook background (base layout): @@ -1208,7 +1277,7 @@ static void NotebookDisplay(void *clientData, Drawable d) /* Draw tabs from left to right, but draw the current tab last * so it will overwrite its neighbors. */ - for (index = 0; index < nb->notebook.mgr->nSlaves; ++index) { + for (index = 0; index < nSlaves; ++index) { if (index != nb->notebook.currentIndex) { DisplayTab(nb, index, d); } diff --git a/generic/ttk/ttkPanedwindow.c b/generic/ttk/ttkPanedwindow.c index ccc376d..7a613aa 100644 --- a/generic/ttk/ttkPanedwindow.c +++ b/generic/ttk/ttkPanedwindow.c @@ -1,4 +1,4 @@ -/* $Id: ttkPanedwindow.c,v 1.9 2007/01/11 14:49:47 jenglish Exp $ +/* $Id: ttkPanedwindow.c,v 1.9.2.1 2007/06/12 16:22:41 dgp Exp $ * * Copyright (c) 2005, Joe English. Freely redistributable. * @@ -26,7 +26,7 @@ * * Pane geometry is determined by the sash positions. * When resizing, sash positions are computed from the request sizes, - * the available space, and pane weights (see ComputePositions()). + * the available space, and pane weights (see PlaceSashes()). * This ensures continuous resize behavior (that is: changing * the size by X pixels then changing the size by Y pixels * gives the same result as changing the size by X+Y pixels @@ -61,9 +61,12 @@ */ typedef struct { - Tcl_Obj *orientObj; + Tcl_Obj *orientObj; int orient; + int width; + int height; Ttk_Manager *mgr; + Tk_OptionTable paneOptionTable; Ttk_Layout sashLayout; int sashThickness; } PanedPart; @@ -79,6 +82,12 @@ static Tk_OptionSpec PanedOptionSpecs[] = { {TK_OPTION_STRING_TABLE, "-orient", "orient", "Orient", "vertical", Tk_Offset(Paned,paned.orientObj), Tk_Offset(Paned,paned.orient), 0,(ClientData)ttkOrientStrings,READONLY_OPTION|STYLE_CHANGED }, + {TK_OPTION_INT, "-width", "width", "Width", "0", + -1,Tk_Offset(Paned,paned.width), + 0,0,GEOMETRY_CHANGED }, + {TK_OPTION_INT, "-height", "height", "Height", "0", + -1,Tk_Offset(Paned,paned.height), + 0,0,GEOMETRY_CHANGED }, WIDGET_INHERIT_OPTIONS(ttkCoreOptionSpecs) }; @@ -98,8 +107,76 @@ static Tk_OptionSpec PaneOptionSpecs[] = { {TK_OPTION_END, 0,0,0, NULL, -1,-1, 0,0,0} }; +/* CreatePane -- + * Create a new pane record. + */ +static Pane *CreatePane(Tcl_Interp *interp, Paned *pw, Tk_Window slaveWindow) +{ + Tk_OptionTable optionTable = pw->paned.paneOptionTable; + void *record = ckalloc(sizeof(Pane)); + Pane *pane = record; + + memset(record, 0, sizeof(Pane)); + if (Tk_InitOptions(interp, record, optionTable, slaveWindow) != TCL_OK) { + ckfree(record); + return NULL; + } + + pane->reqSize + = pw->paned.orient == TTK_ORIENT_HORIZONTAL + ? Tk_ReqWidth(slaveWindow) : Tk_ReqHeight(slaveWindow); + + return pane; +} + +/* DestroyPane -- + * Free pane record. + */ +static void DestroyPane(Paned *pw, Pane *pane) +{ + void *record = pane; + Tk_FreeConfigOptions(record, pw->paned.paneOptionTable, pw->core.tkwin); + ckfree(record); +} + +/* ConfigurePane -- + * Set pane options. + */ +static int ConfigurePane( + Tcl_Interp *interp, Paned *pw, Pane *pane, Tk_Window slaveWindow, + int objc, Tcl_Obj *CONST objv[]) +{ + Ttk_Manager *mgr = pw->paned.mgr; + Tk_SavedOptions savedOptions; + int mask = 0; + + if (Tk_SetOptions(interp, (void*)pane, pw->paned.paneOptionTable, + objc, objv, slaveWindow, &savedOptions, &mask) != TCL_OK) + { + return TCL_ERROR; + } + + /* Sanity-check: + */ + if (pane->weight < 0) { + Tcl_AppendResult(interp, "-weight must be nonnegative", NULL); + goto error; + } + + /* Done. + */ + Tk_FreeSavedOptions(&savedOptions); + Ttk_ManagerSizeChanged(mgr); + return TCL_OK; + +error: + Tk_RestoreSavedOptions(&savedOptions); + return TCL_ERROR; +} + + /*------------------------------------------------------------------------ - * +++ Layout algorithm. + * +++ Sash adjustment. */ /* ShoveUp -- @@ -135,7 +212,7 @@ static int ShoveDown(Paned *pw, int i, int pos) Pane *pane = Ttk_SlaveData(pw->paned.mgr,i); int sashThickness = pw->paned.sashThickness; - if (i == pw->paned.mgr->nSlaves - 1) { + if (i == Ttk_NumberSlaves(pw->paned.mgr) - 1) { pos = pane->sashPos; /* Sentinel value == master window size */ } else { Pane *nextPane = Ttk_SlaveData(pw->paned.mgr,i+1); @@ -146,8 +223,10 @@ static int ShoveDown(Paned *pw, int i, int pos) } /* PanedSize -- - * Compute the requested size of the paned widget. - * Used as both the WidgetSpec sizeProc and the ManagerSpec sizeProc. + * Compute the requested size of the paned widget + * from the individual pane request sizes. + * + * Used as the WidgetSpec sizeProc and the ManagerSpec sizeProc. */ static int PanedSize(void *recordPtr, int *widthPtr, int *heightPtr) { @@ -180,8 +259,8 @@ static int PanedSize(void *recordPtr, int *widthPtr, int *heightPtr) height += nSashes * sashThickness; } - *widthPtr = width; - *heightPtr = height; + *widthPtr = pw->paned.width > 0 ? pw->paned.width : width; + *heightPtr = pw->paned.height > 0 ? pw->paned.height : height; return 1; } @@ -189,7 +268,7 @@ static int PanedSize(void *recordPtr, int *widthPtr, int *heightPtr) * Set pane request sizes from sash positions. * * NOTE: - * AdjustPanes followed by ComputePositions (called during relayout) + * AdjustPanes followed by PlaceSashes (called during relayout) * will leave the sashes in the same place, as long as available size * remains contant. */ @@ -207,8 +286,9 @@ static void AdjustPanes(Paned *pw) } } -/* ComputePositions -- +/* PlaceSashes -- * Set sash positions from pane request sizes and available space. + * The sentinel sash position is set to the available space. * * Allocate pane->reqSize pixels to each pane, and distribute * the difference = available size - requested size according @@ -222,14 +302,12 @@ static void AdjustPanes(Paned *pw) * This doesn't distribute the remainder pixels as evenly as it could * when more than one pane has weight > 1. */ -static void ComputePositions(Paned *pw) +static void PlaceSashes(Paned *pw, int width, int height) { Ttk_Manager *mgr = pw->paned.mgr; int nPanes = Ttk_NumberSlaves(mgr); int sashThickness = pw->paned.sashThickness; - int available - = pw->paned.orient == TTK_ORIENT_HORIZONTAL - ? Tk_Width(pw->core.tkwin) : Tk_Height(pw->core.tkwin); + int available = pw->paned.orient == TTK_ORIENT_HORIZONTAL ? width : height; int reqSize = 0, totalWeight = 0; int difference, delta, remainder, pos, i; @@ -322,33 +400,43 @@ static void PlacePanes(Paned *pw) static void PanedPlaceSlaves(void *managerData) { Paned *pw = managerData; - ComputePositions(pw); + PlaceSashes(pw, Tk_Width(pw->core.tkwin), Tk_Height(pw->core.tkwin)); PlacePanes(pw); } -static void PaneAdded(Ttk_Manager *mgr, int index) +static void PaneRemoved(Ttk_Manager *mgr, int index) { + Paned *pw = Ttk_ManagerData(mgr); Pane *pane = Ttk_SlaveData(mgr, index); - Tk_Window slaveWindow = Ttk_SlaveWindow(mgr, index); - Paned *pw = mgr->managerData; - - /* See also: PanedGeometryRequestProc */ - pane->reqSize - = pw->paned.orient == TTK_ORIENT_HORIZONTAL - ? Tk_ReqWidth(slaveWindow) : Tk_ReqHeight(slaveWindow); + DestroyPane(pw, pane); } -static void PaneRemoved(Ttk_Manager *mgr, int i) { /*no-op*/ } - -static int PaneConfigured( - Tcl_Interp *interp, Ttk_Manager *mgr, Ttk_Slave *slave, unsigned mask) +static int AddPane( + Tcl_Interp *interp, Paned *pw, + int destIndex, Tk_Window slaveWindow, + int objc, Tcl_Obj *const objv[]) { - Pane *pane = slave->slaveData; - if (pane->weight < 0) { - Tcl_AppendResult(interp, "-weight must be nonnegative", NULL); - pane->weight = 0; + Pane *pane; + if (!Ttk_Maintainable(interp, slaveWindow, pw->core.tkwin)) { + return TCL_ERROR; + } + if (Ttk_SlaveIndex(pw->paned.mgr, slaveWindow) >= 0) { + Tcl_AppendResult(interp, + Tk_PathName(slaveWindow), " already added", + NULL); + return TCL_ERROR; + } + + pane = CreatePane(interp, pw, slaveWindow); + if (!pane) { return TCL_ERROR; } + if (ConfigurePane(interp, pw, pane, slaveWindow, objc, objv) != TCL_OK) { + DestroyPane(pw, pane); + return TCL_ERROR; + } + + Ttk_InsertSlave(pw->paned.mgr, destIndex, slaveWindow, pane); return TCL_OK; } @@ -358,15 +446,15 @@ static int PaneConfigured( * in order to avoid unexpected pane resizes (esp. while the * user is dragging a sash [#1325286]). */ - static void PanedGeometryRequestProc( ClientData clientData, Tk_Window slaveWindow) { - Ttk_Slave *slave = clientData; - Pane *pane = slave->slaveData; - Paned *pw = slave->manager->managerData; + Ttk_Manager *mgr = clientData; + Paned *pw = Ttk_ManagerData(mgr); if (!Tk_IsMapped(slaveWindow)) { + int slaveIndex = Ttk_SlaveIndex(mgr, slaveWindow); /* ASSERT: != -1 */ + Pane *pane = Ttk_SlaveData(mgr, slaveIndex); pane->reqSize = pw->paned.orient == TTK_ORIENT_HORIZONTAL ? Tk_ReqWidth(slaveWindow) : Tk_ReqHeight(slaveWindow); @@ -379,12 +467,9 @@ static void PanedGeometryRequestProc( static Ttk_ManagerSpec PanedManagerSpec = { { "panedwindow", PanedGeometryRequestProc, Ttk_LostSlaveProc }, - PaneOptionSpecs, sizeof(Pane), PanedSize, PanedPlaceSlaves, - PaneAdded, - PaneRemoved, - PaneConfigured, + PaneRemoved }; /*------------------------------------------------------------------------ @@ -422,6 +507,7 @@ static int PanedInitialize(Tcl_Interp *interp, void *recordPtr) Tk_CreateEventHandler(pw->core.tkwin, PanedEventMask, PanedEventProc, recordPtr); pw->paned.mgr = Ttk_CreateManager(&PanedManagerSpec, pw, pw->core.tkwin); + pw->paned.paneOptionTable = Tk_CreateOptionTable(interp,PaneOptionSpecs); pw->paned.sashLayout = 0; pw->paned.sashThickness = 1; @@ -439,6 +525,25 @@ static void PanedCleanup(void *recordPtr) Ttk_DeleteManager(pw->paned.mgr); } +/* Post-configuration hook. + */ +static int PanedPostConfigure(Tcl_Interp *interp, void *clientData, int mask) +{ + Paned *pw = clientData; + + if (mask & GEOMETRY_CHANGED) { + /* User has changed -width or -height. + * Recalculate sash positions based on requested size. + */ + Tk_Window tkwin = pw->core.tkwin; + PlaceSashes(pw, + pw->paned.width > 0 ? pw->paned.width : Tk_Width(tkwin), + pw->paned.height > 0 ? pw->paned.height : Tk_Height(tkwin)); + } + + return TCL_OK; +} + /*------------------------------------------------------------------------ * +++ Layout management hooks. */ @@ -450,7 +555,7 @@ static Ttk_Layout PanedGetLayout( if (panedLayout) { int horizontal = pw->paned.orient == TTK_ORIENT_HORIZONTAL; - const char *layoutName = + const char *layoutName = horizontal ? ".Vertical.Sash" : ".Horizontal.Sash"; Ttk_Layout sashLayout = Ttk_CreateSublayout( interp, themePtr, panedLayout, layoutName, pw->core.optionTable); @@ -478,35 +583,39 @@ static Ttk_Layout PanedGetLayout( return panedLayout; } -static void PanedDisplay(void *recordPtr, Drawable d) +/*------------------------------------------------------------------------ + * +++ Drawing routines. + */ + +static void DrawSash(Paned *pw, Drawable d, Ttk_Box b) { - Paned *pw = recordPtr; - int horizontal = pw->paned.orient == TTK_ORIENT_HORIZONTAL; Ttk_Layout sashLayout = pw->paned.sashLayout; - int sashThickness = pw->paned.sashThickness; Ttk_State state = pw->core.state; - int nPanes = Ttk_NumberSlaves(pw->paned.mgr); + + Ttk_PlaceLayout(sashLayout, state, b); + Ttk_DrawLayout(sashLayout, state, d); +} + +static void PanedDisplay(void *recordPtr, Drawable d) +{ + Paned *pw = recordPtr; + int nPanes = Ttk_NumberSlaves(pw->paned.mgr), + horizontal = pw->paned.orient == TTK_ORIENT_HORIZONTAL, + thickness = pw->paned.sashThickness, + height = Tk_Height(pw->core.tkwin), + width = Tk_Width(pw->core.tkwin); int i; TtkWidgetDisplay(recordPtr, d); /* Draw sashes: */ - if (horizontal) { - int height = Tk_Height(pw->core.tkwin); - for (i = 0; i < nPanes; ++i) { - Pane *pane = Ttk_SlaveData(pw->paned.mgr, i); - Ttk_PlaceLayout(sashLayout, state, - Ttk_MakeBox(pane->sashPos, 0, sashThickness, height)); - Ttk_DrawLayout(sashLayout, state, d); - } - } else { - int width = Tk_Width(pw->core.tkwin); - for (i = 0; i < nPanes; ++i) { - Pane *pane = Ttk_SlaveData(pw->paned.mgr, i); - Ttk_PlaceLayout(sashLayout, state, - Ttk_MakeBox(0, pane->sashPos, width, sashThickness)); - Ttk_DrawLayout(sashLayout, state, d); + for (i = 0; i < nPanes; ++i) { + Pane *pane = Ttk_SlaveData(pw->paned.mgr, i); + if (horizontal) { + DrawSash(pw, d, Ttk_MakeBox(pane->sashPos, 0, thickness, height)); + } else { + DrawSash(pw, d, Ttk_MakeBox(0, pane->sashPos, width, thickness)); } } } @@ -535,8 +644,8 @@ static int PanedAddCommand( return TCL_ERROR; } - return Ttk_AddSlave(interp, pw->paned.mgr, slaveWindow, - Ttk_NumberSlaves(pw->paned.mgr), objc - 3, objv + 3); + return AddPane(interp, pw, Ttk_NumberSlaves(pw->paned.mgr), slaveWindow, + objc - 3, objv + 3); } /* $pw insert $index $slave ?options...? @@ -546,6 +655,7 @@ static int PanedInsertCommand( Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[], void *recordPtr) { Paned *pw = recordPtr; + int nSlaves = Ttk_NumberSlaves(pw->paned.mgr); int srcIndex, destIndex; Tk_Window slaveWindow; @@ -562,23 +672,26 @@ static int PanedInsertCommand( if (!strcmp(Tcl_GetString(objv[2]), "end")) { destIndex = Ttk_NumberSlaves(pw->paned.mgr); - } else if (!Ttk_GetSlaveFromObj(interp,pw->paned.mgr,objv[2],&destIndex)) { + } else if (TCL_OK != Ttk_GetSlaveIndexFromObj( + interp,pw->paned.mgr,objv[2],&destIndex)) + { return TCL_ERROR; } srcIndex = Ttk_SlaveIndex(pw->paned.mgr, slaveWindow); if (srcIndex < 0) { /* New slave: */ - return Ttk_AddSlave(interp, pw->paned.mgr, slaveWindow, - destIndex, objc - 4, objv + 4); + return AddPane(interp, pw, destIndex, slaveWindow, objc-4, objv+4); } /* else -- move existing slave: */ - if (destIndex >= pw->paned.mgr->nSlaves) - destIndex = pw->paned.mgr->nSlaves - 1; + if (destIndex >= nSlaves) + destIndex = nSlaves - 1; Ttk_ReorderSlave(pw->paned.mgr, srcIndex, destIndex); return objc == 4 ? TCL_OK : - Ttk_ConfigureSlave(interp, pw->paned.mgr, - pw->paned.mgr->slaves[destIndex], objc-4,objv+4); + ConfigurePane(interp, pw, + Ttk_SlaveData(pw->paned.mgr, destIndex), + Ttk_SlaveWindow(pw->paned.mgr, destIndex), + objc-4,objv+4); } /* $pw forget $pane @@ -594,7 +707,9 @@ static int PanedForgetCommand( return TCL_ERROR; } - if (!Ttk_GetSlaveFromObj(interp, pw->paned.mgr, objv[2], &paneIndex)) { + if (TCL_OK != Ttk_GetSlaveIndexFromObj( + interp, pw->paned.mgr, objv[2], &paneIndex)) + { return TCL_ERROR; } Ttk_ForgetSlave(pw->paned.mgr, paneIndex); @@ -602,14 +717,15 @@ static int PanedForgetCommand( return TCL_OK; } -/* $pw identify $x $y - * @@@ TODO: implement as documented, or change documentation. +/* $pw identify $x $y -- + * Return index of sash at $x,$y */ static int PanedIdentifyCommand( Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[], void *recordPtr) { Paned *pw = recordPtr; int sashThickness = pw->paned.sashThickness; + int nSashes = Ttk_NumberSlaves(pw->paned.mgr) - 1; int x, y, pos; int index; @@ -624,7 +740,7 @@ static int PanedIdentifyCommand( } pos = pw->paned.orient == TTK_ORIENT_HORIZONTAL ? x : y; - for (index = 0; index < pw->paned.mgr->nSlaves - 1; ++index) { + for (index = 0; index < nSashes; ++index) { Pane *pane = Ttk_SlaveData(pw->paned.mgr, index); if (pane->sashPos <= pos && pos <= pane->sashPos + sashThickness) { Tcl_SetObjResult(interp, Tcl_NewIntObj(index)); @@ -632,7 +748,7 @@ static int PanedIdentifyCommand( } } - return TCL_OK; /* empty list */ + return TCL_OK; /* return empty string */ } /* $pw pane $pane ?-option ?value -option value ...?? @@ -643,31 +759,62 @@ static int PanedPaneCommand( { Paned *pw = recordPtr; int paneIndex; - Ttk_Slave *slave; + Tk_Window slaveWindow; + Pane *pane; if (objc < 3) { Tcl_WrongNumArgs(interp, 2,objv, "pane ?-option value...?"); return TCL_ERROR; } - slave = Ttk_GetSlaveFromObj(interp,pw->paned.mgr,objv[2],&paneIndex); - if (!slave) { + if (TCL_OK != Ttk_GetSlaveIndexFromObj( + interp,pw->paned.mgr,objv[2],&paneIndex)) + { return TCL_ERROR; } + pane = Ttk_SlaveData(pw->paned.mgr, paneIndex); + slaveWindow = Ttk_SlaveWindow(pw->paned.mgr, paneIndex); + switch (objc) { case 3: - return TtkEnumerateOptions(interp, slave->slaveData, PaneOptionSpecs, - pw->paned.mgr->slaveOptionTable, slave->slaveWindow); + return TtkEnumerateOptions(interp, pane, PaneOptionSpecs, + pw->paned.paneOptionTable, slaveWindow); case 4: - return TtkGetOptionValue(interp, slave->slaveData,objv[3], - pw->paned.mgr->slaveOptionTable, slave->slaveWindow); + return TtkGetOptionValue(interp, pane, objv[3], + pw->paned.paneOptionTable, slaveWindow); default: - return Ttk_ConfigureSlave( - interp, pw->paned.mgr, slave, objc-3,objv+3); + return ConfigurePane(interp, pw, pane, slaveWindow, objc-3,objv+3); + } +} + +/* $pw panes -- + * Return list of managed panes. + */ +static int PanedPanesCommand( + Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[], void *recordPtr) +{ + Paned *pw = recordPtr; + Ttk_Manager *mgr = pw->paned.mgr; + Tcl_Obj *panes; + int i; + + if (objc != 2) { + Tcl_WrongNumArgs(interp, 2, objv, ""); + return TCL_ERROR; + } + + panes = Tcl_NewListObj(0, NULL); + for (i = 0; i < Ttk_NumberSlaves(mgr); ++i) { + const char *pathName = Tk_PathName(Ttk_SlaveWindow(mgr,i)); + Tcl_ListObjAppendElement(interp, panes, Tcl_NewStringObj(pathName,-1)); } + Tcl_SetObjResult(interp, panes); + + return TCL_OK; } + /* $pw sashpos $index ?$newpos? * Query or modify sash position. */ @@ -727,6 +874,7 @@ static WidgetCommandSpec PanedCommands[] = { "insert", PanedInsertCommand }, { "instate", TtkWidgetInstateCommand }, { "pane", PanedPaneCommand }, + { "panes", PanedPanesCommand }, { "sashpos", PanedSashposCommand }, { "state", TtkWidgetStateCommand }, { 0,0 } @@ -745,7 +893,7 @@ static WidgetSpec PanedWidgetSpec = PanedInitialize, /* initializeProc */ PanedCleanup, /* cleanupProc */ TtkCoreConfigure, /* configureProc */ - TtkNullPostConfigure, /* postConfigureProc */ + PanedPostConfigure, /* postConfigureProc */ PanedGetLayout, /* getLayoutProc */ PanedSize, /* sizeProc */ TtkWidgetDoLayout, /* layoutProc */ diff --git a/library/ttk/panedwindow.tcl b/library/ttk/panedwindow.tcl index 15ec4f8..a24988b 100644 --- a/library/ttk/panedwindow.tcl +++ b/library/ttk/panedwindow.tcl @@ -1,5 +1,5 @@ # -# $Id: panedwindow.tcl,v 1.3 2007/04/13 00:21:47 hobbs Exp $ +# $Id: panedwindow.tcl,v 1.3.2.1 2007/06/12 16:22:41 dgp Exp $ # # Bindings for ttk::panedwindow widget. # @@ -33,8 +33,8 @@ bind TPanedwindow <> { ttk::panedwindow::ResetCursor %W } proc ttk::panedwindow::Press {w x y} { variable State - lassign [$w identify $x $y] sash element - if {![info exists sash] || $sash eq ""} { + set sash [$w identify $x $y] + if {$sash eq ""} { set State(pressed) 0 return } diff --git a/macosx/Wish-Debug.xcconfig b/macosx/Wish-Debug.xcconfig index 19c1f71..e9468ee 100644 --- a/macosx/Wish-Debug.xcconfig +++ b/macosx/Wish-Debug.xcconfig @@ -9,7 +9,7 @@ // See the file "license.terms" for information on usage and redistribution // of this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// RCS: @(#) $Id: Wish-Debug.xcconfig,v 1.2 2007/04/23 21:24:32 das Exp $ +// RCS: @(#) $Id: Wish-Debug.xcconfig,v 1.2.2.1 2007/06/12 16:22:41 dgp Exp $ // #include "Wish-Common.xcconfig" @@ -17,6 +17,6 @@ DEBUG_INFORMATION_FORMAT = dwarf DEPLOYMENT_POSTPROCESSING = NO GCC_OPTIMIZATION_LEVEL = 0 -GCC_PREPROCESSOR_DEFINITIONS = DEBUG_ASSERT_PRODUCTION_CODE=0 $(TCL_DEFS) $(TK_DEFS) $(GCC_PREPROCESSOR_DEFINITIONS) +GCC_PREPROCESSOR_DEFINITIONS = DEBUGLEVEL=4 $(TCL_DEFS) $(TK_DEFS) $(GCC_PREPROCESSOR_DEFINITIONS) CONFIGURE_ARGS = --enable-symbols $(TCL_CONFIGURE_ARGS) $(CONFIGURE_ARGS) MAKE_TARGET = develop diff --git a/macosx/Wish-Release.xcconfig b/macosx/Wish-Release.xcconfig index e1a8752..1c5f859 100644 --- a/macosx/Wish-Release.xcconfig +++ b/macosx/Wish-Release.xcconfig @@ -9,13 +9,13 @@ // See the file "license.terms" for information on usage and redistribution // of this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// RCS: @(#) $Id: Wish-Release.xcconfig,v 1.2 2007/04/23 21:24:32 das Exp $ +// RCS: @(#) $Id: Wish-Release.xcconfig,v 1.2.2.1 2007/06/12 16:22:41 dgp Exp $ // #include "Wish-Common.xcconfig" DEBUG_INFORMATION_FORMAT = dwarf-with-dsym -DEPLOYMENT_POSTPROCESSING = YES +// DEPLOYMENT_POSTPROCESSING = YES GCC_OPTIMIZATION_LEVEL = s GCC_PREPROCESSOR_DEFINITIONS = NDEBUG $(TCL_DEFS) $(TK_DEFS) $(GCC_PREPROCESSOR_DEFINITIONS) CONFIGURE_ARGS = --disable-symbols $(TCL_CONFIGURE_ARGS) $(CONFIGURE_ARGS) diff --git a/macosx/Wish.xcodeproj/project.pbxproj b/macosx/Wish.xcodeproj/project.pbxproj index d314f6f..f72e4e0 100644 --- a/macosx/Wish.xcodeproj/project.pbxproj +++ b/macosx/Wish.xcodeproj/project.pbxproj @@ -313,6 +313,7 @@ /* Begin PBXFileReference section */ 8DD76FB20486AB0100D96B5E /* tktest */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = tktest; sourceTree = BUILT_PRODUCTS_DIR; }; + F91E62260C1AE686006C9D96 /* Tclsh-Info.plist.in */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = "Tclsh-Info.plist.in"; sourceTree = ""; }; F93E5EFD09CF8711008FA367 /* tkMacOSXFont.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tkMacOSXFont.h; sourceTree = ""; }; F9408AF20B195C08009F7CAC /* tclMathOp.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tclMathOp.c; sourceTree = ""; }; F966BA0408F27A37005CB29B /* error.xbm */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.h; fileEncoding = 4; path = error.xbm; sourceTree = ""; }; @@ -1779,7 +1780,7 @@ F966C06F08F281DC005CB29B /* Frameworks */, 1AB674ADFE9D54B511CA2CBB /* Products */, ); - comments = "Copyright (c) 2004-2007 Daniel A. Steffen \n\nSee the file \"license.terms\" for information on usage and redistribution of\nthis file, and for a DISCLAIMER OF ALL WARRANTIES.\n\nRCS: @(#) $Id: project.pbxproj,v 1.21.2.1 2007/05/29 11:36:45 dgp Exp $\n"; + comments = "Copyright (c) 2004-2007 Daniel A. Steffen \n\nSee the file \"license.terms\" for information on usage and redistribution of\nthis file, and for a DISCLAIMER OF ALL WARRANTIES.\n\nRCS: @(#) $Id: project.pbxproj,v 1.21.2.2 2007/06/12 16:22:43 dgp Exp $\n"; name = Wish; path = .; sourceTree = SOURCE_ROOT; @@ -3217,10 +3218,11 @@ F96D432E08F272B5004A47F5 /* configure.ac */, F96D432F08F272B5004A47F5 /* GNUmakefile */, F96D433108F272B5004A47F5 /* README */, - F96D433208F272B5004A47F5 /* Tcl-Info.plist.in */, F96D433908F272B5004A47F5 /* tclMacOSXBundle.c */, F96D433D08F272B5004A47F5 /* tclMacOSXFCmd.c */, F96D433E08F272B5004A47F5 /* tclMacOSXNotify.c */, + F96D433208F272B5004A47F5 /* Tcl-Info.plist.in */, + F91E62260C1AE686006C9D96 /* Tclsh-Info.plist.in */, ); path = macosx; sourceTree = ""; @@ -3570,7 +3572,7 @@ hasScannedForEncodings = 1; mainGroup = 08FB7794FE84155DC02AAC07 /* Wish */; projectDirPath = ""; - projectRoot = ""; + projectRoot = ..; targets = ( F9E61D16090A3E94002B3151 /* Tk */, 8DD76FA90486AB0100D96B5E /* tktest */, @@ -4045,11 +4047,13 @@ isa = XCBuildConfiguration; buildSettings = { CONFIGURE_ARGS = "tcl_cv_cc_visibility_hidden=no $(CONFIGURE_ARGS)"; + GCC_DYNAMIC_NO_PIC = NO; GCC_ENABLE_FIX_AND_CONTINUE = YES; GCC_PREPROCESSOR_DEFINITIONS = ( "__private_extern__=extern", "$(GCC_PREPROCESSOR_DEFINITIONS)", ); + GCC_SYMBOLS_PRIVATE_EXTERN = NO; PRODUCT_NAME = tktest; ZERO_LINK = YES; }; diff --git a/macosx/tkMacOSXColor.c b/macosx/tkMacOSXColor.c index a41c9b9..022c1e9 100644 --- a/macosx/tkMacOSXColor.c +++ b/macosx/tkMacOSXColor.c @@ -13,7 +13,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkMacOSXColor.c,v 1.8.2.1 2007/06/01 04:01:32 dgp Exp $ + * RCS: @(#) $Id: tkMacOSXColor.c,v 1.8.2.2 2007/06/12 16:22:41 dgp Exp $ */ #include "tkMacOSXInt.h" @@ -382,50 +382,34 @@ TkMacOSXSetColorInContext(unsigned long pixel, CGContextRef context) if (GetThemeFromPixelCode((pixel >> 24) & 0xff, &brush, &textColor, &background)) { -#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1040 if (brush) { - if (1 -#if MAC_OS_X_VERSION_MIN_REQUIRED < 1040 - && HIThemeSetFill != NULL && HIThemeSetStroke != NULL -#endif - ) { + TK_IF_MAC_OS_X_API (4, HIThemeSetFill, err = ChkErr(HIThemeSetFill, brush, NULL, context, kHIThemeOrientationNormal); - if (err == noErr) { + TK_IF_MAC_OS_X_API_COND (4, HIThemeSetFill, err == noErr, err = ChkErr(HIThemeSetStroke, brush, NULL, context, kHIThemeOrientationNormal); - } - } + ) TK_ENDIF + ) TK_ENDIF } else if (textColor) { - if (1 -#if MAC_OS_X_VERSION_MIN_REQUIRED < 1040 - && HIThemeSetTextFill != NULL -#endif - ) { + TK_IF_MAC_OS_X_API (4, HIThemeSetTextFill, err = ChkErr(HIThemeSetTextFill, textColor, NULL, context, kHIThemeOrientationNormal); - } - } else -#endif /* MAC_OS_X_VERSION_MAX_ALLOWED >= 1040 */ -#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1030 - if (background) { - if (1 -#if MAC_OS_X_VERSION_MIN_REQUIRED < 1030 - && CGContextGetClipBoundingBox != NULL - && HIThemeApplyBackground != NULL - && &kHIToolboxVersionNumber != NULL /* c.f. QA1377 */ - && kHIToolboxVersionNumber >= kHIToolboxVersionNumber10_3 -#endif - ) { + ) TK_ENDIF + } else if (background) { + TK_IF_MAC_OS_X_API (3, CGContextGetClipBoundingBox, CGRect rect = CGContextGetClipBoundingBox(context); HIThemeBackgroundDrawInfo info = { 0, kThemeStateActive, background }; - err = ChkErr(HIThemeApplyBackground, &rect, &info, context, - kHIThemeOrientationNormal); - } + TK_IF_MAC_OS_X_API (3, HIThemeApplyBackground, + TK_IF_HI_TOOLBOX (3, /* c.f. QA1377 */ + err = ChkErr(HIThemeApplyBackground, &rect, &info, + context, kHIThemeOrientationNormal); + ) TK_ENDIF + ) TK_ENDIF + ) TK_ENDIF } -#endif /* MAC_OS_X_VERSION_MAX_ALLOWED >= 1030 */ if (err == noErr) { return; } @@ -458,17 +442,9 @@ TkMacOSXSetColorInContext(unsigned long pixel, CGContextRef context) Tcl_Panic("TkMacOSXSetColorInContext(): " "pattern initialization failed !"); } - bitmapInfo = -#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1040 - (1 -#if MAC_OS_X_VERSION_MIN_REQUIRED < 1040 - && &kHIToolboxVersionNumber != NULL - && kHIToolboxVersionNumber >= - kHIToolboxVersionNumber10_4 -#endif - ) ? kCGBitmapByteOrder32Host : -#endif - 0; + TK_IF_HI_TOOLBOX (4, + bitmapInfo = kCGBitmapByteOrder32Host; + ) TK_ENDIF } portChanged = QDSwapPort(patGWorld, &savePort); TkMacOSXSetColorInPort(pixel, 1, pixpat); diff --git a/macosx/tkMacOSXDraw.c b/macosx/tkMacOSXDraw.c index ec825cb..5629102 100644 --- a/macosx/tkMacOSXDraw.c +++ b/macosx/tkMacOSXDraw.c @@ -12,7 +12,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkMacOSXDraw.c,v 1.21.2.3 2007/06/04 15:19:00 dgp Exp $ + * RCS: @(#) $Id: tkMacOSXDraw.c,v 1.21.2.4 2007/06/12 16:22:41 dgp Exp $ */ #include "tkMacOSXInt.h" @@ -39,7 +39,7 @@ RgnHandle tkMacOSXtmpRgn1 = NULL; RgnHandle tkMacOSXtmpRgn2 = NULL; -static PixPatHandle gPenPat = NULL; +static PixPatHandle penPat = NULL; static int useCGDrawing = 1; static int tkMacOSXCGAntiAliasLimit = 0; @@ -52,6 +52,8 @@ static int useThemedFrame = 0; * Prototypes for functions used only in this file. */ static unsigned char InvertByte(unsigned char data); +static void ClipToGC(Drawable d, GC gc, CGrafPtr port, RgnHandle clipRgn); +static void NoQDClip(CGrafPtr port); /* @@ -156,88 +158,43 @@ XCopyArea( int dest_x, /* Dest X & Y on dest rect. */ int dest_y) { - Rect srcRect, dstRect, *srcPtr, *dstPtr; - const BitMap *srcBit, *dstBit; + Rect srcRect, dstRect, *srcPtr = &srcRect, *dstPtr = &dstRect; MacDrawable *srcDraw = (MacDrawable *) src, *dstDraw = (MacDrawable *) dst; - CGrafPtr srcPort, dstPort, savePort; + CGrafPtr srcPort, destPort, savePort; Boolean portChanged; - RGBColor origForeColor, origBackColor, whiteColor, blackColor; - - dstPort = TkMacOSXGetDrawablePort(dst); - srcPort = TkMacOSXGetDrawablePort(src); + const BitMap *srcBit, *dstBit; + RGBColor origForeColor, origBackColor; + RGBColor black = {0, 0, 0}, white = {0xffff, 0xffff, 0xffff}; display->request++; - portChanged = QDSwapPort(dstPort, &savePort); - GetForeColor(&origForeColor); - GetBackColor(&origBackColor); - whiteColor.red = 0; - whiteColor.blue = 0; - whiteColor.green = 0; - RGBForeColor(&whiteColor); - blackColor.red = 0xFFFF; - blackColor.blue = 0xFFFF; - blackColor.green = 0xFFFF; - RGBBackColor(&blackColor); - - srcPtr = &srcRect; - SetRect(&srcRect, (short) (srcDraw->xOff + src_x), - (short) (srcDraw->yOff + src_y), - (short) (srcDraw->xOff + src_x + width), - (short) (srcDraw->yOff + src_y + height)); - if (tkPictureIsOpen) { - dstPtr = &srcRect; - } else { - dstPtr = &dstRect; - SetRect(&dstRect, (short) (dstDraw->xOff + dest_x), - (short) (dstDraw->yOff + dest_y), - (short) (dstDraw->xOff + dest_x + width), - (short) (dstDraw->yOff + dest_y + height)); - } - TkMacOSXSetUpClippingRgn(dst); - - /* - * We will change the clip rgn in this routine, so we need to - * be able to restore it when we exit. - */ - + srcPort = TkMacOSXGetDrawablePort(src); + destPort = TkMacOSXGetDrawablePort(dst); + srcBit = GetPortBitMapForCopyBits(srcPort); + dstBit = GetPortBitMapForCopyBits(destPort); + SetRect(srcPtr, srcDraw->xOff + src_x, srcDraw->yOff + src_y, + srcDraw->xOff + src_x + width, srcDraw->yOff + src_y + height); TkMacOSXCheckTmpRgnEmpty(2); - GetClip(tkMacOSXtmpRgn2); + GetPortClipRegion(destPort, tkMacOSXtmpRgn2); if (tkPictureIsOpen) { - /* - * When rendering into a picture, after a call to "OpenCPicture" - * the drawable clipping is incorrect, so clip to the whole window. - */ - - Rect clpRect; - - GetPortBounds(dstPort, &clpRect); - ClipRect(&clpRect); - } - if (gc->clip_mask && ((TkpClipMask*)gc->clip_mask)->type - == TKP_CLIP_REGION) { - RgnHandle gcClipRgn = (RgnHandle) - ((TkpClipMask*)gc->clip_mask)->value.region; - int xOffset = dstDraw->xOff + gc->clip_x_origin; - int yOffset = dstDraw->yOff + gc->clip_y_origin; - - if (!tkPictureIsOpen) { - OffsetRgn(gcClipRgn, xOffset, yOffset); - } - TkMacOSXCheckTmpRgnEmpty(1); - GetClip(tkMacOSXtmpRgn1); - SectRgn(tkMacOSXtmpRgn1, gcClipRgn, tkMacOSXtmpRgn1); - SetClip(tkMacOSXtmpRgn1); - SetEmptyRgn(tkMacOSXtmpRgn1); - if (!tkPictureIsOpen) { - OffsetRgn(gcClipRgn, -xOffset, -yOffset); - } + dstPtr = srcPtr; + NoQDClip(destPort); + } else { + SetRect(dstPtr, dstDraw->xOff + dest_x, dstDraw->yOff + dest_y, + dstDraw->xOff + dest_x + width, + dstDraw->yOff + dest_y + height); + TkMacOSXSetUpClippingRgn(dst); } - srcBit = GetPortBitMapForCopyBits(srcPort); - dstBit = GetPortBitMapForCopyBits(dstPort); + TkMacOSXCheckTmpRgnEmpty(1); + ClipToGC(dst, gc, destPort, tkMacOSXtmpRgn1); + portChanged = QDSwapPort(destPort, &savePort); + GetPortForeColor(destPort, &origForeColor); + GetPortBackColor(destPort, &origBackColor); + RGBForeColor(&black); + RGBBackColor(&white); CopyBits(srcBit, dstBit, srcPtr, dstPtr, srcCopy, NULL); RGBForeColor(&origForeColor); RGBBackColor(&origBackColor); - SetClip(tkMacOSXtmpRgn2); + SetPortClipRegion(destPort, tkMacOSXtmpRgn2); SetEmptyRgn(tkMacOSXtmpRgn2); if (portChanged) { QDSwapPort(savePort, NULL); @@ -268,93 +225,82 @@ XCopyPlane( Display *display, /* Display. */ Drawable src, /* Source drawable. */ Drawable dst, /* Destination drawable. */ - GC gc, /* The GC to use. */ - int src_x, int src_y, /* X, Y, width & height define the source - * rect. */ - unsigned int width, unsigned int height, - int dest_x, int dest_y, /* X & Y on dest where we will copy. */ + GC gc, /* GC to use. */ + int src_x, /* X & Y, width & height */ + int src_y, /* define the source rectangle */ + unsigned int width, /* the will be copied. */ + unsigned int height, + int dest_x, /* Dest X & Y on dest rect. */ + int dest_y, unsigned long plane) /* Which plane to copy. */ { - Rect srcRect, dstRect, *srcPtr, *dstPtr; - const BitMap *srcBit, *dstBit, *mskBit; + Rect srcRect, dstRect, *srcPtr = &srcRect, *dstPtr = &dstRect; MacDrawable *srcDraw = (MacDrawable *) src, *dstDraw = (MacDrawable *) dst; - CGrafPtr srcPort, dstPort, mskPort, savePort; + CGrafPtr srcPort, destPort, savePort; Boolean portChanged; + const BitMap *srcBit, *dstBit; + RGBColor origForeColor, origBackColor; TkpClipMask *clipPtr = (TkpClipMask *) gc->clip_mask; - short tmode; - - srcPort = TkMacOSXGetDrawablePort(src); - dstPort = TkMacOSXGetDrawablePort(dst); display->request++; - portChanged = QDSwapPort(dstPort, &savePort); - TkMacOSXSetUpClippingRgn(dst); - + srcPort = TkMacOSXGetDrawablePort(src); + destPort = TkMacOSXGetDrawablePort(dst); srcBit = GetPortBitMapForCopyBits(srcPort); - dstBit = GetPortBitMapForCopyBits(dstPort); - SetRect(&srcRect, (short) (srcDraw->xOff + src_x), - (short) (srcDraw->yOff + src_y), - (short) (srcDraw->xOff + src_x + width), - (short) (srcDraw->yOff + src_y + height)); - srcPtr = &srcRect; + dstBit = GetPortBitMapForCopyBits(destPort); + SetRect(srcPtr, srcDraw->xOff + src_x, srcDraw->yOff + src_y, + srcDraw->xOff + src_x + width, srcDraw->yOff + src_y + height); + TkMacOSXCheckTmpRgnEmpty(2); + GetPortClipRegion(destPort, tkMacOSXtmpRgn2); if (tkPictureIsOpen) { - /* - * When rendering into a picture, after a call to "OpenCPicture" - * the drawable clipping is incorrect, so clip to the whole window. - */ - - Rect clpRect; - - GetPortBounds(dstPort, &clpRect); - ClipRect(&clpRect); - dstPtr = &srcRect; + dstPtr = srcPtr; + NoQDClip(destPort); } else { - dstPtr = &dstRect; - SetRect(&dstRect, (short) (dstDraw->xOff + dest_x), - (short) (dstDraw->yOff + dest_y), - (short) (dstDraw->xOff + dest_x + width), - (short) (dstDraw->yOff + dest_y + height)); + SetRect(dstPtr, dstDraw->xOff + dest_x, dstDraw->yOff + dest_y, + dstDraw->xOff + dest_x + width, + dstDraw->yOff + dest_y + height); + TkMacOSXSetUpClippingRgn(dst); } - tmode = srcOr; - tmode = srcCopy + transparent; - + TkMacOSXCheckTmpRgnEmpty(1); + GetPortClipRegion(destPort, tkMacOSXtmpRgn1); + ClipToGC(dst, gc, destPort, tkMacOSXtmpRgn1); + SetPortClipRegion(destPort, tkMacOSXtmpRgn1); + SetEmptyRgn(tkMacOSXtmpRgn1); + portChanged = QDSwapPort(destPort, &savePort); + GetPortForeColor(destPort, &origForeColor); + GetPortBackColor(destPort, &origBackColor); TkMacOSXSetColorInPort(gc->foreground, 1, NULL); - - if (clipPtr == NULL || clipPtr->type == TKP_CLIP_REGION) { + if (!clipPtr || clipPtr->type == TKP_CLIP_REGION) { /* - * Case 1: opaque bitmaps. + * Opaque bitmaps. */ TkMacOSXSetColorInPort(gc->background, 0, NULL); - tmode = srcCopy; - CopyBits(srcBit, dstBit, srcPtr, dstPtr, tmode, NULL); + CopyBits(srcBit, dstBit, srcPtr, dstPtr, srcCopy, NULL); } else if (clipPtr->type == TKP_CLIP_PIXMAP) { if (clipPtr->value.pixmap == src) { - PixMapHandle pm; /* - * Case 2: transparent bitmaps. If it's color we ignore - * the forecolor. + * Transparent bitmaps. If it's color we ignore the forecolor. */ + short tmode = GetPixDepth(GetPortPixMap(srcPort)) == 1 ? + srcOr : transparent; - pm = GetPortPixMap(srcPort); - if (GetPixDepth(pm) == 1) { - tmode = srcOr; - } else { - tmode = transparent; - } CopyBits(srcBit, dstBit, srcPtr, dstPtr, tmode, NULL); } else { /* - * Case 3: two arbitrary bitmaps. + * Two arbitrary bitmaps. */ - tmode = srcCopy; - mskPort = TkMacOSXGetDrawablePort(clipPtr->value.pixmap); - mskBit = GetPortBitMapForCopyBits(mskPort); - CopyDeepMask(srcBit, mskBit, dstBit, - srcPtr, srcPtr, dstPtr, tmode, NULL); + CGrafPtr mskPort = TkMacOSXGetDrawablePort(clipPtr->value.pixmap); + const BitMap *mskBit = GetPortBitMapForCopyBits(mskPort); + + CopyDeepMask(srcBit, mskBit, dstBit, srcPtr, srcPtr, dstPtr, + srcCopy, NULL); } } + RGBForeColor(&origForeColor); + RGBBackColor(&origBackColor); + SetPortClipRegion(destPort, tkMacOSXtmpRgn2); + SetEmptyRgn(tkMacOSXtmpRgn2); if (portChanged) { QDSwapPort(savePort, NULL); } @@ -392,49 +338,48 @@ TkPutImage( unsigned int width, /* Same width & height for both */ unsigned int height) /* distination and source. */ { + Rect srcRect, dstRect, *srcPtr = &srcRect, *dstPtr = &dstRect; + MacDrawable *dstDraw = (MacDrawable *) d; CGrafPtr destPort, savePort; Boolean portChanged; - const BitMap * destBits; - MacDrawable *dstDraw = (MacDrawable *) d; + const BitMap *dstBit; + RGBColor origForeColor, origBackColor; + RGBColor black = {0, 0, 0}, white = {0xffff, 0xffff, 0xffff}; int i, j; char *newData = NULL; - Rect destRect, srcRect, *destPtr, *srcPtr; char *dataPtr, *newPtr, *oldPtr; int rowBytes = image->bytes_per_line; int slices, sliceRowBytes, lastSliceRowBytes, sliceWidth, lastSliceWidth; display->request++; destPort = TkMacOSXGetDrawablePort(d); - portChanged = QDSwapPort(destPort, &savePort); - TkMacOSXSetUpClippingRgn(d); - - destBits = GetPortBitMapForCopyBits(destPort); - srcPtr = &srcRect; + dstBit = GetPortBitMapForCopyBits(destPort); SetRect(srcPtr, src_x, src_y, src_x + width, src_y + height); + TkMacOSXCheckTmpRgnEmpty(2); + GetPortClipRegion(destPort, tkMacOSXtmpRgn2); if (tkPictureIsOpen) { - /* - * When rendering into a picture, after a call to "OpenCPicture" - * the drawable clipping is incorrect, so clip to the whole window. - */ - - Rect clpRect; - - GetPortBounds(destPort, &clpRect); - ClipRect(&clpRect); - destPtr = srcPtr; + dstPtr = srcPtr; + NoQDClip(destPort); } else { - destPtr = &destRect; - SetRect(destPtr, dstDraw->xOff + dest_x, dstDraw->yOff + dest_y, - dstDraw->xOff + dest_x + width, dstDraw->yOff + dest_y + height); + SetRect(dstPtr, dstDraw->xOff + dest_x, dstDraw->yOff + dest_y, + dstDraw->xOff + dest_x + width, + dstDraw->yOff + dest_y + height); + TkMacOSXSetUpClippingRgn(d); } - + TkMacOSXCheckTmpRgnEmpty(1); + ClipToGC(d, gc, destPort, tkMacOSXtmpRgn1); + portChanged = QDSwapPort(destPort, &savePort); + GetPortForeColor(destPort, &origForeColor); + GetPortBackColor(destPort, &origBackColor); + RGBForeColor(&black); + RGBBackColor(&white); if (image->obdata) { /* * Image from XGetImage, copy from containing GWorld directly. */ CopyBits(GetPortBitMapForCopyBits(TkMacOSXGetDrawablePort((Drawable) - image->obdata)), destBits, srcPtr, destPtr, srcCopy, NULL); + image->obdata)), dstBit, srcPtr, dstPtr, srcCopy, NULL); } else if (image->depth == 1) { /* * BW image @@ -487,12 +432,13 @@ TkPutImage( } bitmap.baseAddr = newData; bitmap.rowBytes = sliceRowBytes + odd; - CopyBits(&bitmap, destBits, srcPtr, destPtr, srcCopy, NULL); + CopyBits(&bitmap, dstBit, srcPtr, dstPtr, srcCopy, NULL); if (slices) { bitmap.bounds.left = bitmap.bounds.right; dataPtr += sliceRowBytes; } } while (slices--); + ckfree(newData); } else { /* * Color image @@ -548,24 +494,25 @@ TkPutImage( } pixmap.baseAddr = newData; pixmap.rowBytes = sliceRowBytes | 0x8000; - CopyBits((BitMap *) &pixmap, destBits, srcPtr, destPtr, - srcCopy, NULL); + CopyBits((BitMap*) &pixmap, dstBit, srcPtr, dstPtr, srcCopy, + NULL); if (slices) { pixmap.bounds.left = pixmap.bounds.right; dataPtr += sliceRowBytes; } } while (slices--); + ckfree(newData); } else { pixmap.bounds.right = (short) image->width; pixmap.baseAddr = image->data; pixmap.rowBytes = rowBytes | 0x8000; - CopyBits((BitMap *) &pixmap, destBits, srcPtr, destPtr, - srcCopy, NULL); + CopyBits((BitMap*) &pixmap, dstBit, srcPtr, dstPtr, srcCopy, NULL); } } - if (newData != NULL) { - ckfree(newData); - } + RGBForeColor(&origForeColor); + RGBBackColor(&origBackColor); + SetPortClipRegion(destPort, tkMacOSXtmpRgn2); + SetEmptyRgn(tkMacOSXtmpRgn2); if (portChanged) { QDSwapPort(savePort, NULL); } @@ -1009,17 +956,10 @@ XDrawArc( macWin->xOff + x + o, macWin->yOff + y + o, width, height); - -#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1040 - if (angle1 == 0 && angle2 == 23040 -#if MAC_OS_X_VERSION_MIN_REQUIRED < 1040 - && CGContextStrokeEllipseInRect != NULL -#endif - ) { + TK_IF_MAC_OS_X_API_COND (4, CGContextStrokeEllipseInRect, + angle1 == 0 && angle2 == 23040, CGContextStrokeEllipseInRect(dc.context, rect); - } else -#endif - { + ) TK_ELSE ( CGMutablePathRef p = CGPathCreateMutable(); CGAffineTransform t = CGAffineTransformIdentity; CGPoint c = CGPointMake(CGRectGetMidX(rect), CGRectGetMidY(rect)); @@ -1034,7 +974,7 @@ XDrawArc( CGContextAddPath(dc.context, p); CGPathRelease(p); CGContextStrokePath(dc.context); - } + ) TK_ENDIF } else { Rect theRect; short start, extent; @@ -1104,16 +1044,10 @@ XDrawArcs( macWin->yOff + arcPtr->y + o, arcPtr->width, arcPtr->height); -#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1040 - if (arcPtr->angle1 == 0 && arcPtr->angle2 == 23040 -#if MAC_OS_X_VERSION_MIN_REQUIRED < 1040 - && CGContextStrokeEllipseInRect != NULL -#endif - ) { + TK_IF_MAC_OS_X_API_COND (4, CGContextStrokeEllipseInRect, + arcPtr->angle1 == 0 && arcPtr->angle2 == 23040, CGContextStrokeEllipseInRect(dc.context, rect); - } else -#endif - { + ) TK_ELSE ( CGMutablePathRef p = CGPathCreateMutable(); CGAffineTransform t = CGAffineTransformIdentity; CGPoint c = CGPointMake(CGRectGetMidX(rect), @@ -1132,7 +1066,7 @@ XDrawArcs( CGContextAddPath(dc.context, p); CGPathRelease(p); CGContextStrokePath(dc.context); - } + ) TK_ENDIF } } else { Rect theRect; @@ -1202,16 +1136,10 @@ XFillArc( macWin->yOff + y + o, width - u, height - u); -#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1040 - if (angle1 == 0 && angle2 == 23040 -#if MAC_OS_X_VERSION_MIN_REQUIRED < 1040 - && CGContextFillEllipseInRect != NULL -#endif - ) { + TK_IF_MAC_OS_X_API_COND (4, CGContextFillEllipseInRect, + angle1 == 0 && angle2 == 23040, CGContextFillEllipseInRect(dc.context, rect); - } else -#endif - { + ) TK_ELSE ( CGMutablePathRef p = CGPathCreateMutable(); CGAffineTransform t = CGAffineTransformIdentity; CGPoint c = CGPointMake(CGRectGetMidX(rect), CGRectGetMidY(rect)); @@ -1230,7 +1158,7 @@ XFillArc( CGContextAddPath(dc.context, p); CGPathRelease(p); CGContextFillPath(dc.context); - } + ) TK_ENDIF } else { Rect theRect; short start, extent; @@ -1326,17 +1254,10 @@ XFillArcs( macWin->xOff + arcPtr->x + o, macWin->yOff + arcPtr->y + o, arcPtr->width - u, arcPtr->height - u); - -#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1040 - if (arcPtr->angle1 == 0 && arcPtr->angle2 == 23040 -#if MAC_OS_X_VERSION_MIN_REQUIRED < 1040 - && CGContextFillEllipseInRect != NULL -#endif - ) { + TK_IF_MAC_OS_X_API_COND (4, CGContextFillEllipseInRect, + arcPtr->angle1 == 0 && arcPtr->angle2 == 23040, CGContextFillEllipseInRect(dc.context, rect); - } else -#endif - { + ) TK_ELSE ( CGMutablePathRef p = CGPathCreateMutable(); CGAffineTransform t = CGAffineTransformIdentity; CGPoint c = CGPointMake(CGRectGetMidX(rect), @@ -1359,7 +1280,7 @@ XFillArcs( CGContextAddPath(dc.context, p); CGPathRelease(p); CGContextFillPath(dc.context); - } + ) TK_ENDIF } } else { Rect theRect; @@ -1458,14 +1379,11 @@ TkScrollWindow( TkRegion damageRgn) /* Region to accumulate damage in. */ { MacDrawable *destDraw = (MacDrawable *) Tk_WindowId(tkwin); - RgnHandle rgn = (RgnHandle) damageRgn; CGrafPtr destPort, savePort; Boolean portChanged; Rect srcRect, scrollRect; - - destPort = TkMacOSXGetDrawablePort(Tk_WindowId(tkwin)); - portChanged = QDSwapPort(destPort, &savePort); - TkMacOSXSetUpClippingRgn(Tk_WindowId(tkwin)); + int result; + RgnHandle rgn = (RgnHandle) damageRgn; /* * Due to the implementation below the behavior may be differnt @@ -1477,11 +1395,11 @@ TkScrollWindow( * destination rects disjoint and non-aligned. */ - SetRect(&srcRect, (short) (destDraw->xOff + x), + SetRect(&scrollRect, (short) (destDraw->xOff + x), (short) (destDraw->yOff + y), (short) (destDraw->xOff + x + width), (short) (destDraw->yOff + y + height)); - scrollRect = srcRect; + srcRect = scrollRect; if (dx < 0) { scrollRect.left += dx; } else { @@ -1493,11 +1411,8 @@ TkScrollWindow( scrollRect.bottom += dy; } - /* - * Adjust clip region so that we don't copy any windows - * that may overlap us. - */ - + destPort = TkMacOSXGetDrawablePort(Tk_WindowId(tkwin)); + TkMacOSXSetUpClippingRgn(Tk_WindowId(tkwin)); TkMacOSXCheckTmpRgnEmpty(1); TkMacOSXCheckTmpRgnEmpty(2); RectRgn(rgn, &srcRect); @@ -1507,25 +1422,26 @@ TkScrollWindow( GetPortClipRegion(destPort, tkMacOSXtmpRgn2); DiffRgn(tkMacOSXtmpRgn2, rgn, tkMacOSXtmpRgn2); SetPortClipRegion(destPort, tkMacOSXtmpRgn2); - SetEmptyRgn(tkMacOSXtmpRgn1); SetEmptyRgn(tkMacOSXtmpRgn2); + SetEmptyRgn(tkMacOSXtmpRgn1); SetEmptyRgn(rgn); + portChanged = QDSwapPort(destPort, &savePort); ScrollRect(&scrollRect, dx, dy, rgn); if (portChanged) { QDSwapPort(savePort, NULL); } + /* * Fortunately, the region returned by ScrollRect is semantically * the same as what we need to return in this function. If the * region is empty we return zero to denote that no damage was * created. */ - if (EmptyRgn(rgn)) { - return 0; - } else { - return 1; - } + + result = EmptyRgn(rgn) ? 0 : 1; + + return result; } /* @@ -1551,11 +1467,11 @@ TkMacOSXSetUpGraphicsPort( { PenNormal(); if (gc) { - if (gPenPat == NULL) { - gPenPat = NewPixPat(); + if (penPat == NULL) { + penPat = NewPixPat(); } - TkMacOSXSetColorInPort(gc->foreground, 1, gPenPat); - PenPixPat(gPenPat); + TkMacOSXSetColorInPort(gc->foreground, 1, penPat); + PenPixPat(penPat); if(gc->function == GXxor) { PenMode(patXor); } @@ -1599,71 +1515,25 @@ TkMacOSXSetupDrawingContext( CGrafPtr port; Rect portBounds; + dc->saveState = NULL; + dc->penPat = NULL; + dc->portChanged = false; port = TkMacOSXGetDrawablePort(d); if (port) { GetPortBounds(port, &portBounds); } - dc->saveState = NULL; - if (port && !context) { - dc->portChanged = QDSwapPort(port, &(dc->savePort)); - TkMacOSXSetUpClippingRgn(d); - TkMacOSXCheckTmpRgnEmpty(1); - if (useCG) { - if (ChkErr(QDBeginCGContext, port, &context) == noErr) { - /* - * Now clip the CG Context to the port. Note, we have already - * set up the port with our clip region, so we can just get - * the clip back out of there. If we use the macWin->clipRgn - * directly at this point, we get some odd drawing effects. - * - * We also have to intersect our clip region with the port - * visible region so we don't overwrite the window decoration. - */ - - RectRgn(tkMacOSXtmpRgn1, &portBounds); - SectRegionWithPortClipRegion(port, tkMacOSXtmpRgn1); - SectRegionWithPortVisibleRegion(port, tkMacOSXtmpRgn1); - if (gc && gc->clip_mask && ((TkpClipMask*)gc->clip_mask)->type - == TKP_CLIP_REGION) { - RgnHandle gcClipRgn = (RgnHandle) - ((TkpClipMask*)gc->clip_mask)->value.region; - int xOffset = macDraw->xOff + gc->clip_x_origin; - int yOffset = macDraw->yOff + gc->clip_y_origin; - - OffsetRgn(gcClipRgn, xOffset, yOffset); - SectRgn(gcClipRgn, tkMacOSXtmpRgn1, tkMacOSXtmpRgn1); - OffsetRgn(gcClipRgn, -xOffset, -yOffset); - } - ClipCGContextToRegion(context, &portBounds, tkMacOSXtmpRgn1); - SetEmptyRgn(tkMacOSXtmpRgn1); - - /* - * Note: You have to call SyncCGContextOriginWithPort - * AFTER all the clip region manipulations. - */ - - SyncCGContextOriginWithPort(context, port); - } else { - context = NULL; - useCG = 0; - } + if (context) { + if (!port) { + TK_IF_MAC_OS_X_API (3, CGContextGetClipBoundingBox, + CGRect r = CGContextGetClipBoundingBox(context); + + SetRect(&portBounds, r.origin.x + macDraw->xOff, + r.origin.y + macDraw->yOff, + r.origin.x + r.size.width + macDraw->xOff, + r.origin.y + r.size.height + macDraw->yOff); + ) TK_ENDIF } - } else if (context) { TkMacOSXCheckTmpRgnEmpty(1); -#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1030 - if (!port -#if MAC_OS_X_VERSION_MIN_REQUIRED < 1030 - && CGContextGetClipBoundingBox != NULL -#endif - ) { - CGRect r = CGContextGetClipBoundingBox(context); - - SetRect(&portBounds, r.origin.x + macDraw->xOff, - r.origin.y + macDraw->yOff, - r.origin.x + r.size.width + macDraw->xOff, - r.origin.y + r.size.height + macDraw->yOff); - } -#endif RectRgn(tkMacOSXtmpRgn1, &portBounds); if (port) { TkMacOSXSetUpClippingRgn(d); @@ -1674,24 +1544,31 @@ TkMacOSXSetupDrawingContext( SectRgn(macDraw->clipRgn, macDraw->drawRgn, tkMacOSXtmpRgn1); OffsetRgn(macDraw->drawRgn, -macDraw->xOff, -macDraw->yOff); } - if (gc && gc->clip_mask && ((TkpClipMask*)gc->clip_mask)->type - == TKP_CLIP_REGION) { - RgnHandle gcClipRgn = (RgnHandle) - ((TkpClipMask*)gc->clip_mask)->value.region; - int xOffset = macDraw->xOff + gc->clip_x_origin; - int yOffset = macDraw->yOff + gc->clip_y_origin; - - OffsetRgn(gcClipRgn, xOffset, yOffset); - SectRgn(gcClipRgn, tkMacOSXtmpRgn1, tkMacOSXtmpRgn1); - OffsetRgn(gcClipRgn, -xOffset, -yOffset); - } + ClipToGC(d, gc, NULL, tkMacOSXtmpRgn1); CGContextSaveGState(context); + dc->saveState = (void*)1; ClipCGContextToRegion(context, &portBounds, tkMacOSXtmpRgn1); SetEmptyRgn(tkMacOSXtmpRgn1); port = NULL; - dc->portChanged = false; - dc->saveState = (void*)1; useCG = 1; + } else if (port) { + dc->portChanged = QDSwapPort(port, &(dc->savePort)); + TkMacOSXSetUpClippingRgn(d); + if (useCG) { + if (ChkErr(QDBeginCGContext, port, &context) == noErr) { + TkMacOSXCheckTmpRgnEmpty(1); + RectRgn(tkMacOSXtmpRgn1, &portBounds); + SectRegionWithPortClipRegion(port, tkMacOSXtmpRgn1); + SectRegionWithPortVisibleRegion(port, tkMacOSXtmpRgn1); + ClipToGC(d, gc, NULL, tkMacOSXtmpRgn1); + ClipCGContextToRegion(context, &portBounds, tkMacOSXtmpRgn1); + SetEmptyRgn(tkMacOSXtmpRgn1); + SyncCGContextOriginWithPort(context, port); + } else { + context = NULL; + useCG = 0; + } + } } else { Tcl_Panic("TkMacOSXSetupDrawingContext(): " "no port or context to draw into !"); @@ -1719,7 +1596,6 @@ TkMacOSXSetupDrawingContext( CGContextSetShouldAntialias(context, 1); } CGContextSetLineWidth(context, w); - if (gc->line_style != LineSolid) { int num = 0; char *p = &(gc->dashes); @@ -1732,7 +1608,6 @@ TkMacOSXSetupDrawingContext( } CGContextSetLineDash(context, dashOffset, lengths, num); } - if (gc->cap_style == CapButt) { /* * What about CapNotLast, CapProjecting? @@ -1744,7 +1619,6 @@ TkMacOSXSetupDrawingContext( } else if (gc->cap_style == CapProjecting) { CGContextSetLineCap(context, kCGLineCapSquare); } - if (gc->join_style == JoinMiter) { CGContextSetLineJoin(context, kCGLineJoinMiter); } else if (gc->join_style == JoinRound) { @@ -1754,36 +1628,21 @@ TkMacOSXSetupDrawingContext( } } } else { + PixPatHandle savePat = penPat; + ChkErr(GetThemeDrawingState, &(dc->saveState)); + penPat = NULL; + TkMacOSXSetUpGraphicsPort(gc, port); + dc->penPat = penPat; + penPat = savePat; if (gc) { - PixPatHandle savePat = gPenPat; - - gPenPat = NULL; - TkMacOSXSetUpGraphicsPort(gc, port); - dc->penPat = gPenPat; - gPenPat = savePat; - if (gc->clip_mask && ((TkpClipMask*)gc->clip_mask)->type - == TKP_CLIP_REGION) { - RgnHandle gcClipRgn = (RgnHandle) - ((TkpClipMask*)gc->clip_mask)->value.region; - int xOffset = macDraw->xOff + gc->clip_x_origin; - int yOffset = macDraw->yOff + gc->clip_y_origin; - - OffsetRgn(gcClipRgn, xOffset, yOffset); - GetClip(tkMacOSXtmpRgn1); - SectRgn(gcClipRgn, tkMacOSXtmpRgn1, tkMacOSXtmpRgn1); - SetClip(tkMacOSXtmpRgn1); - SetEmptyRgn(tkMacOSXtmpRgn1); - OffsetRgn(gcClipRgn, -xOffset, -yOffset); - } - } else { - TkMacOSXSetUpGraphicsPort(NULL, port); - dc->penPat = NULL; + TkMacOSXCheckTmpRgnEmpty(1); + ClipToGC(d, gc, port, tkMacOSXtmpRgn1); } ShowPen(); } - dc->port = port; dc->portBounds = portBounds; + dc->port = port; dc->context = context; return useCG; } @@ -1855,32 +1714,29 @@ TkMacOSXSetUpClippingRgn( Drawable drawable) /* Drawable to update. */ { MacDrawable *macDraw = (MacDrawable *) drawable; + CGrafPtr port = TkMacOSXGetDrawablePort(drawable); - if (macDraw->winPtr != NULL) { - if (macDraw->flags & TK_CLIP_INVALID) { - TkMacOSXUpdateClipRgn(macDraw->winPtr); - } - + if (macDraw->winPtr && macDraw->flags & TK_CLIP_INVALID) { + TkMacOSXUpdateClipRgn(macDraw->winPtr); #ifdef TK_MAC_DEBUG_DRAWING - TkMacOSXDebugFlashRegion(TkMacOSXGetDrawablePort(drawable), - macDraw->clipRgn); + TkMacOSXDebugFlashRegion(port, macDraw->clipRgn); #endif /* TK_MAC_DEBUG_DRAWING */ } - if (macDraw->clipRgn != NULL) { + if (macDraw->clipRgn) { if (macDraw->flags & TK_CLIPPED_DRAW) { TkMacOSXCheckTmpRgnEmpty(1); OffsetRgn(macDraw->drawRgn, macDraw->xOff, macDraw->yOff); SectRgn(macDraw->clipRgn, macDraw->drawRgn, tkMacOSXtmpRgn1); OffsetRgn(macDraw->drawRgn, -macDraw->xOff, -macDraw->yOff); - SetClip(tkMacOSXtmpRgn1); + SetPortClipRegion(port, tkMacOSXtmpRgn1); SetEmptyRgn(tkMacOSXtmpRgn1); } else { - SetClip(macDraw->clipRgn); + SetPortClipRegion(port, macDraw->clipRgn); } } else if (macDraw->flags & TK_CLIPPED_DRAW) { OffsetRgn(macDraw->drawRgn, macDraw->xOff, macDraw->yOff); - SetClip(macDraw->drawRgn); + SetPortClipRegion(port, macDraw->drawRgn); OffsetRgn(macDraw->drawRgn, -macDraw->xOff, -macDraw->yOff); } } @@ -1925,6 +1781,83 @@ TkpClipDrawableToRect( /* *---------------------------------------------------------------------- * + * ClipToGC -- + * + * Helper function to intersect the given port's clip region (or if + * port is NULL, the given clipRgn) with gc clip region. + * + * Results: + * None. + * + * Side effects: + * None. + * + *---------------------------------------------------------------------- + */ + +static void +ClipToGC( + Drawable d, + GC gc, + CGrafPtr port, /* can be NULL */ + RgnHandle clipRgn) /* tmp region or if port == NULL, region to intersect */ +{ + if (gc && gc->clip_mask && + ((TkpClipMask*)gc->clip_mask)->type == TKP_CLIP_REGION) { + RgnHandle gcClipRgn = (RgnHandle) + ((TkpClipMask*)gc->clip_mask)->value.region; + int xOffset = ((MacDrawable *) d)->xOff + gc->clip_x_origin; + int yOffset = ((MacDrawable *) d)->yOff + gc->clip_y_origin; + + if (!tkPictureIsOpen) { + OffsetRgn(gcClipRgn, xOffset, yOffset); + } + if (port) { + GetPortClipRegion(port, clipRgn); + } + SectRgn(clipRgn, gcClipRgn, clipRgn); + if (port) { + SetPortClipRegion(port, clipRgn); + SetEmptyRgn(clipRgn); + } + if (!tkPictureIsOpen) { + OffsetRgn(gcClipRgn, -xOffset, -yOffset); + } + } +} + +/* + *---------------------------------------------------------------------- + * + * NoQDClip -- + * + * Helper function to setup a QD port to not clip anything. + * + * Results: + * None. + * + * Side effects: + * None. + * + *---------------------------------------------------------------------- + */ + +static void +NoQDClip( + CGrafPtr port) +{ + static RgnHandle noClipRgn = NULL; + + if (!noClipRgn) { + noClipRgn = NewRgn(); + SetRectRgn(noClipRgn, SHRT_MIN, SHRT_MIN, SHRT_MAX, SHRT_MAX); + } + SetPortClipRegion(port, noClipRgn); +} + +/* + *---------------------------------------------------------------------- + * * TkMacOSXMakeStippleMap -- * * Given a drawable and a stipple pattern this function draws the diff --git a/macosx/tkMacOSXEntry.c b/macosx/tkMacOSXEntry.c index 60e4a99..4cdf4d8 100644 --- a/macosx/tkMacOSXEntry.c +++ b/macosx/tkMacOSXEntry.c @@ -53,7 +53,7 @@ * software in accordance with the terms specified in this * license. * - * RCS: @(#) $Id: tkMacOSXEntry.c,v 1.8.2.1 2007/06/04 15:19:00 dgp Exp $ + * RCS: @(#) $Id: tkMacOSXEntry.c,v 1.8.2.2 2007/06/12 16:22:42 dgp Exp $ */ #include "tkMacOSXInt.h" @@ -80,40 +80,37 @@ static ThemeButtonKind ComputeIncDecParameters (int height, int *width); *-------------------------------------------------------------- */ static ThemeButtonKind -ComputeIncDecParameters (int height, int *width) +ComputeIncDecParameters(int height, int *width) { -#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1030 - if (1 -#if MAC_OS_X_VERSION_MIN_REQUIRED < 1030 - && &kHIToolboxVersionNumber != NULL - && kHIToolboxVersionNumber >= kHIToolboxVersionNumber10_3 -#endif - ) { + ThemeButtonKind kind; + + TK_IF_HI_TOOLBOX (3, if (height < 11 || height > 28) { *width = 0; - return (ThemeButtonKind) 0; - } - - if (height >= 21) { - *width = 13; - return kThemeIncDecButton; - } else if (height >= 18) { - *width = 12; - return kThemeIncDecButtonSmall; + kind = (ThemeButtonKind) 0; } else { - *width = 11; - return kThemeIncDecButtonMini; + if (height >= 21) { + *width = 13; + kind = kThemeIncDecButton; + } else if (height >= 18) { + *width = 12; + kind = kThemeIncDecButtonSmall; + } else { + *width = 11; + kind = kThemeIncDecButtonMini; + } } - } else -#endif - { + ) TK_ELSE_HI_TOOLBOX (3, if (height < 21 || height > 28) { *width = 0; - return (ThemeButtonKind) 0; + kind = (ThemeButtonKind) 0; + } else { + *width = 13; + kind = kThemeIncDecButton; } - *width = 13; - return kThemeIncDecButton; - } + ) TK_ENDIF + + return kind; } /* diff --git a/macosx/tkMacOSXEvent.c b/macosx/tkMacOSXEvent.c index 677b158..bf0ad4a 100644 --- a/macosx/tkMacOSXEvent.c +++ b/macosx/tkMacOSXEvent.c @@ -10,7 +10,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkMacOSXEvent.c,v 1.16.2.2 2007/06/01 04:01:33 dgp Exp $ + * RCS: @(#) $Id: tkMacOSXEvent.c,v 1.16.2.3 2007/06/12 16:22:42 dgp Exp $ */ #include "tkMacOSXInt.h" @@ -41,22 +41,15 @@ TkMacOSXFlushWindows(void) WindowRef wRef = GetWindowList(); while (wRef) { -#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1030 - if (1 -#if MAC_OS_X_VERSION_MIN_REQUIRED < 1030 - && HIWindowFlush != NULL -#endif - ) { + TK_IF_MAC_OS_X_API (3, HIWindowFlush, ChkErr(HIWindowFlush, wRef); - } else -#endif - { + ) TK_ELSE_MAC_OS_X (3, CGrafPtr portPtr = GetWindowPort(wRef); if (QDIsPortBuffered(portPtr)) { QDFlushPortBuffer(portPtr, NULL); } - } + ) TK_ENDIF wRef = GetNextWindow(wRef); } } diff --git a/macosx/tkMacOSXInit.c b/macosx/tkMacOSXInit.c index 0dc3826..7fbf3f3 100644 --- a/macosx/tkMacOSXInit.c +++ b/macosx/tkMacOSXInit.c @@ -11,7 +11,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkMacOSXInit.c,v 1.28.2.1 2007/06/04 15:19:00 dgp Exp $ + * RCS: @(#) $Id: tkMacOSXInit.c,v 1.28.2.2 2007/06/12 16:22:42 dgp Exp $ */ #include "tkMacOSXInt.h" @@ -19,6 +19,7 @@ #include "tclInt.h" /* for Tcl_GetStartupScript() & Tcl_SetStartupScript() */ #include +#include #include #include @@ -93,6 +94,8 @@ Tcl_Encoding TkMacOSXCarbonEncoding = NULL; */ static char scriptPath[PATH_MAX + 1] = ""; +float tkMacOSXToolboxVersionNumber = 0; + /* *---------------------------------------------------------------------- @@ -117,7 +120,7 @@ TkpInit( Tcl_Interp *interp) { static char tkLibPath[PATH_MAX + 1]; - static int tkMacOSXInitialized = 0; + static int initialized = 0; Tk_MacOSXSetupTkNotifier(); @@ -127,15 +130,44 @@ TkpInit( * we protect against doing it more than once. */ - if (!tkMacOSXInitialized) { + if (!initialized) { int bundledExecutable = 0; CFBundleRef bundleRef; CFURLRef bundleUrl = NULL; CFStringEncoding encoding; const char *encodingStr = NULL; int i; + struct utsname name; + long osVersion = 0; - tkMacOSXInitialized = 1; + initialized = 1; + + /* + * Initialize/check OS version variable for runtime checks. + */ + + if (!uname(&name)) { + osVersion = strtol(name.release, NULL, 10) - 4; + } + if (osVersion && osVersion < (MAC_OS_X_VERSION_MIN_REQUIRED-1000)/10) { + Tcl_Panic("Mac OS X 10.%d or later required !", + (MAC_OS_X_VERSION_MIN_REQUIRED-1000)/10); + } + TK_IF_MAC_OS_X_API (3, &kHIToolboxVersionNumber, + tkMacOSXToolboxVersionNumber = kHIToolboxVersionNumber; + ) TK_ELSE_MAC_OS_X (3, + if (osVersion > 5) { + tkMacOSXToolboxVersionNumber = INFINITY; + } else if (osVersion >= 3) { + static const float tbVersions[3] = { + kHIToolboxVersionNumber10_3, + kHIToolboxVersionNumber10_4, + kHIToolboxVersionNumber10_5, + }; + + tkMacOSXToolboxVersionNumber = tbVersions[osVersion-3]; + } + ) TK_ENDIF /* * When Tk is in a framework, force tcl_findLibrary to look in the @@ -255,16 +287,10 @@ TkpInit( OSStatus err = procNotFound; ProcessSerialNumber psn = { 0, kCurrentProcess }; -#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1030 - if (1 -#if MAC_OS_X_VERSION_MIN_REQUIRED < 1030 - && TransformProcessType != NULL -#endif - ) { + TK_IF_MAC_OS_X_API (3, TransformProcessType, err = ChkErr(TransformProcessType, &psn, kProcessTransformToForegroundApplication); - } -#endif + ) TK_ENDIF #if MAC_OSX_TK_USE_CPS_SPI if (err != noErr) { /* diff --git a/macosx/tkMacOSXInt.h b/macosx/tkMacOSXInt.h index a6e7b86..acdd282 100644 --- a/macosx/tkMacOSXInt.h +++ b/macosx/tkMacOSXInt.h @@ -10,7 +10,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkMacOSXInt.h,v 1.24 2007/05/09 12:55:15 das Exp $ + * RCS: @(#) $Id: tkMacOSXInt.h,v 1.24.2.1 2007/06/12 16:22:42 dgp Exp $ */ #ifndef _TKMACINT @@ -20,6 +20,8 @@ #include "tkInt.h" #endif +#define kComponentSignatureString "TkMacOSX" +#define COMPONENT_SIGNATURE 'Tk ' #define TextStyle MacTextStyle #include #undef TextStyle @@ -47,6 +49,7 @@ #define kAppearancePartPageUpArea 22 #define kAppearancePartPageDownArea 23 #define kAppearancePartIndicator 129 + #define kUIModeAllSuppressed 4 #define FixedToInt(a) ((short)(((Fixed)(a) + fixed1/2) >> 16)) #define IntToFixed(a) ((Fixed)(a) << 16) #endif @@ -73,7 +76,7 @@ #define kWindowUnifiedTitleAndToolbarAttribute (1L << 7) #define kWindowTexturedSquareCornersAttribute (1L << 10) #endif -/* Runtime HIToolbox version checking */ +/* HIToolbox version constants */ #ifndef kHIToolboxVersionNumber10_3 #define kHIToolboxVersionNumber10_3 (145) #endif @@ -81,8 +84,100 @@ #define kHIToolboxVersionNumber10_4 (219) #endif #ifndef kHIToolboxVersionNumber10_5 - #define kHIToolboxVersionNumber10_5 (291) + #define kHIToolboxVersionNumber10_5 (303) #endif +/* Macros for HIToolbox runtime version checking */ +MODULE_SCOPE float tkMacOSXToolboxVersionNumber; +#define TK_IF_HI_TOOLBOX(vers, ...) \ + tk_if_mac_os_x_min_10_##vers(tkMacOSXToolboxVersionNumber >= \ + kHIToolboxVersionNumber10_##vers, 1, __VA_ARGS__) +#define TK_ELSE_HI_TOOLBOX(vers, ...) \ + tk_else_mac_os_x_min_10_##vers(__VA_ARGS__) +/* Macros for Mac OS X API availability checking */ +#define TK_IF_MAC_OS_X_API(vers, symbol, ...) \ + tk_if_mac_os_x_10_##vers(symbol != NULL, 1, __VA_ARGS__) +#define TK_ELSE_MAC_OS_X(vers, ...) \ + tk_else_mac_os_x_10_##vers(__VA_ARGS__) +#define TK_IF_MAC_OS_X_API_COND(vers, symbol, cond, ...) \ + tk_if_mac_os_x_10_##vers(symbol != NULL, cond, __VA_ARGS__) +#define TK_ELSE(...) \ + } else { __VA_ARGS__ +#define TK_ENDIF \ + } +/* Private macros that implement the checking macros above */ +#define tk_if_mac_os_x_yes(chk, cond, ...) \ + if (cond) { __VA_ARGS__ +#define tk_else_mac_os_x_yes(...) \ + } else { +#define tk_if_mac_os_x_chk(chk, cond, ...) \ + if ((chk) && (cond)) { __VA_ARGS__ +#define tk_else_mac_os_x_chk(...) \ + } else { __VA_ARGS__ +#define tk_if_mac_os_x_no(chk, cond, ...) \ + if (0) { +#define tk_else_mac_os_x_no(...) \ + } else { __VA_ARGS__ +/* Private mapping macros defined according to Mac OS X version requirements */ +/* 10.3 Panther */ +#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1030 +#define tk_if_mac_os_x_min_10_3 tk_if_mac_os_x_yes +#define tk_else_mac_os_x_min_10_3 tk_else_mac_os_x_yes +#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1030 +#define tk_if_mac_os_x_10_3 tk_if_mac_os_x_yes +#define tk_else_mac_os_x_10_3 tk_else_mac_os_x_yes +#endif /* MAC_OS_X_VERSION_MAX_ALLOWED */ +#else /* MAC_OS_X_VERSION_MIN_REQUIRED */ +#define tk_if_mac_os_x_min_10_3 tk_if_mac_os_x_chk +#define tk_else_mac_os_x_min_10_3 tk_else_mac_os_x_chk +#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1030 +#define tk_if_mac_os_x_10_3 tk_if_mac_os_x_chk +#define tk_else_mac_os_x_10_3 tk_else_mac_os_x_chk +#endif /* MAC_OS_X_VERSION_MAX_ALLOWED */ +#endif /* MAC_OS_X_VERSION_MIN_REQUIRED */ +#if MAC_OS_X_VERSION_MAX_ALLOWED < 1030 +#define tk_if_mac_os_x_10_3 tk_if_mac_os_x_no +#define tk_else_mac_os_x_10_3 tk_else_mac_os_x_no +#endif /* MAC_OS_X_VERSION_MAX_ALLOWED */ +/* 10.4 Tiger */ +#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1040 +#define tk_if_mac_os_x_min_10_4 tk_if_mac_os_x_yes +#define tk_else_mac_os_x_min_10_4 tk_else_mac_os_x_yes +#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1040 +#define tk_if_mac_os_x_10_4 tk_if_mac_os_x_yes +#define tk_else_mac_os_x_10_4 tk_else_mac_os_x_yes +#endif /* MAC_OS_X_VERSION_MAX_ALLOWED */ +#else /* MAC_OS_X_VERSION_MIN_REQUIRED */ +#define tk_if_mac_os_x_min_10_4 tk_if_mac_os_x_chk +#define tk_else_mac_os_x_min_10_4 tk_else_mac_os_x_chk +#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1040 +#define tk_if_mac_os_x_10_4 tk_if_mac_os_x_chk +#define tk_else_mac_os_x_10_4 tk_else_mac_os_x_chk +#endif /* MAC_OS_X_VERSION_MAX_ALLOWED */ +#endif /* MAC_OS_X_VERSION_MIN_REQUIRED */ +#if MAC_OS_X_VERSION_MAX_ALLOWED < 1040 +#define tk_if_mac_os_x_10_4 tk_if_mac_os_x_no +#define tk_else_mac_os_x_10_4 tk_else_mac_os_x_no +#endif /* MAC_OS_X_VERSION_MAX_ALLOWED */ +/* 10.5 Leopard */ +#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050 +#define tk_if_mac_os_x_min_10_5 tk_if_mac_os_x_yes +#define tk_else_mac_os_x_min_10_5 tk_else_mac_os_x_yes +#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1050 +#define tk_if_mac_os_x_10_5 tk_if_mac_os_x_yes +#define tk_else_mac_os_x_10_5 tk_else_mac_os_x_yes +#endif /* MAC_OS_X_VERSION_MAX_ALLOWED */ +#else /* MAC_OS_X_VERSION_MIN_REQUIRED */ +#define tk_if_mac_os_x_min_10_5 tk_if_mac_os_x_chk +#define tk_else_mac_os_x_min_10_5 tk_else_mac_os_x_chk +#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1050 +#define tk_if_mac_os_x_10_5 tk_if_mac_os_x_chk +#define tk_else_mac_os_x_10_5 tk_else_mac_os_x_chk +#endif /* MAC_OS_X_VERSION_MAX_ALLOWED */ +#endif /* MAC_OS_X_VERSION_MIN_REQUIRED */ +#if MAC_OS_X_VERSION_MAX_ALLOWED < 1050 +#define tk_if_mac_os_x_10_5 tk_if_mac_os_x_no +#define tk_else_mac_os_x_10_5 tk_else_mac_os_x_no +#endif /* MAC_OS_X_VERSION_MAX_ALLOWED */ /* * Include platform specific public interfaces. @@ -100,7 +195,7 @@ struct TkWindowPrivate { int xOff; /* X offset from toplevel window */ int yOff; /* Y offset from toplevel window */ RgnHandle clipRgn; /* Visible region of window */ - RgnHandle aboveClipRgn; /* Visible region of window & it's children */ + RgnHandle aboveClipRgn; /* Visible region of window & its children */ RgnHandle drawRgn; /* Clipped drawing region */ int referenceCount; /* Don't delete toplevel until children are * gone. */ @@ -218,13 +313,26 @@ MODULE_SCOPE int TkMacOSXCompareColors(unsigned long c1, unsigned long c2); __LINE__, __func__, ##__VA_ARGS__); \ } while (0) /* + * Macro to do debug API failure message output. + */ +#if !defined(DEBUGLEVEL) || !DEBUGLEVEL +#define TkMacOSXDbgOSErr(f, err) do { \ + TkMacOSXDbgMsg("%s failed: %ld", #f, err); \ + } while (0) +#else +#define TkMacOSXDbgOSErr(f, err) do { \ + DEBUG_ASSERT_MESSAGE(kComponentSignatureString, #f " failed:", \ + __func__, 0, strrchr(__FILE__, '/')+1, __LINE__, err); \ + } while (0) +#endif +/* * Macro to do very common check for noErr return from given API and output * debug message in case of failure. */ #define ChkErr(f, ...) ({ \ OSStatus err = f(__VA_ARGS__); \ if (err != noErr) { \ - TkMacOSXDbgMsg("%s failed: %ld", #f, err); \ + TkMacOSXDbgOSErr(f, err); \ } \ err;}) /* @@ -237,6 +345,7 @@ MODULE_SCOPE int TkMacOSXCompareColors(unsigned long c1, unsigned long c2); } while(0) #else /* TK_MAC_DEBUG */ #define TkMacOSXDbgMsg(m, ...) +#define TkMacOSXDbgOSErr(f, err) #define ChkErr(f, ...) ({f(__VA_ARGS__);}) #define TkMacOSXCheckTmpRgnEmpty(r) #endif /* TK_MAC_DEBUG */ diff --git a/macosx/tkMacOSXMenu.c b/macosx/tkMacOSXMenu.c index 25f414d..6e8a59f 100644 --- a/macosx/tkMacOSXMenu.c +++ b/macosx/tkMacOSXMenu.c @@ -10,7 +10,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkMacOSXMenu.c,v 1.37.2.2 2007/06/04 15:19:00 dgp Exp $ + * RCS: @(#) $Id: tkMacOSXMenu.c,v 1.37.2.3 2007/06/12 16:22:42 dgp Exp $ */ #include "tkMacOSXInt.h" @@ -1672,7 +1672,7 @@ DrawMenuBarWhenIdle( ClientData clientData) /* ignored here */ { TkMenuReferences *menuRefPtr; - TkMenu *appleMenuPtr, *helpMenuPtr, *menuBarPtr; + TkMenu *appleMenuPtr, *helpMenuPtr, *menuBarPtr = NULL; MenuHandle macMenuHdl; Tcl_HashEntry *hashEntryPtr; diff --git a/macosx/tkMacOSXMouseEvent.c b/macosx/tkMacOSXMouseEvent.c index 782ca69..d58a9f5 100644 --- a/macosx/tkMacOSXMouseEvent.c +++ b/macosx/tkMacOSXMouseEvent.c @@ -54,7 +54,7 @@ * software in accordance with the terms specified in this * license. * - * RCS: @(#) $Id: tkMacOSXMouseEvent.c,v 1.29 2007/05/09 12:55:15 das Exp $ + * RCS: @(#) $Id: tkMacOSXMouseEvent.c,v 1.29.2.1 2007/06/12 16:22:42 dgp Exp $ */ #include "tkMacOSXInt.h" @@ -600,19 +600,14 @@ GenerateMouseWheelEvent(MouseEventData * medPtr) TkWindow *winPtr; XEvent xEvent; - if ((!TkpIsWindowFloating(medPtr->whichWin) - && (medPtr->activeNonFloating != medPtr->whichWin))) { + dispPtr = TkGetDisplayList(); + rootwin = Tk_IdToWindow(dispPtr->display, medPtr->window); + if (rootwin == NULL) { tkwin = NULL; } else { - dispPtr = TkGetDisplayList(); - rootwin = Tk_IdToWindow(dispPtr->display, medPtr->window); - if (rootwin == NULL) { - tkwin = NULL; - } else { - tkwin = Tk_TopCoordsToWindow(rootwin, - medPtr->local.h, medPtr->local.v, - &xEvent.xbutton.x, &xEvent.xbutton.y); - } + tkwin = Tk_TopCoordsToWindow(rootwin, + medPtr->local.h, medPtr->local.v, + &xEvent.xbutton.x, &xEvent.xbutton.y); } /* diff --git a/macosx/tkMacOSXRegion.c b/macosx/tkMacOSXRegion.c index a8654d0..8cca286 100644 --- a/macosx/tkMacOSXRegion.c +++ b/macosx/tkMacOSXRegion.c @@ -10,7 +10,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkMacOSXRegion.c,v 1.6.2.1 2007/05/30 13:47:43 dgp Exp $ + * RCS: @(#) $Id: tkMacOSXRegion.c,v 1.6.2.2 2007/06/12 16:22:42 dgp Exp $ */ #include "tkMacOSXInt.h" @@ -68,7 +68,7 @@ TkDestroyRegion( * * TkIntersectRegion -- * - * Implements the equivilent of the X window function + * Implements the equivalent of the X window function * XIntersectRegion. See X window documentation for more details. * * Results: @@ -94,7 +94,7 @@ TkIntersectRegion( * * TkSubtractRegion -- * - * Implements the equivilent of the X window function + * Implements the equivalent of the X window function * XSubtractRegion. See X window documentation for more details. * * Results: diff --git a/macosx/tkMacOSXScale.c b/macosx/tkMacOSXScale.c index f0fca13..d259dbe 100644 --- a/macosx/tkMacOSXScale.c +++ b/macosx/tkMacOSXScale.c @@ -11,7 +11,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkMacOSXScale.c,v 1.11 2007/04/23 21:24:34 das Exp $ + * RCS: @(#) $Id: tkMacOSXScale.c,v 1.11.2.1 2007/06/12 16:22:42 dgp Exp $ */ #include "tkMacOSXInt.h" @@ -210,7 +210,7 @@ TkpDisplayScale( macDraw = (MacDrawable *) Tk_WindowId(tkwin); destPort = TkMacOSXGetDrawablePort(Tk_WindowId(tkwin)); windowRef = GetWindowFromPort(destPort); - portChanged = QDSwapPort(dstPort, &savePort); + portChanged = QDSwapPort(destPort, &savePort); TkMacOSXSetUpClippingRgn(Tk_WindowId(tkwin)); /* @@ -267,11 +267,7 @@ TkpDisplayScale( &(macScalePtr->scaleHandle)); SetControlReference(macScalePtr->scaleHandle, (UInt32) scalePtr); - /* - * If we are foremost than make us active. - */ - - if (windowRef == FrontWindow()) { + if (IsWindowActive(windowRef)) { macScalePtr->flags |= ACTIVE; } } else { @@ -331,7 +327,7 @@ TkpScaleElement( TkMacOSXDbgMsg("TkpScaleElement"); #endif destPort = TkMacOSXGetDrawablePort(Tk_WindowId(scalePtr->tkwin)); - portChanged = QDSwapPort(dstPort, &savePort); + portChanged = QDSwapPort(destPort, &savePort); /* * All of the calculations in this procedure mirror those in @@ -412,7 +408,7 @@ MacScaleEventProc( */ destPort = TkMacOSXGetDrawablePort(Tk_WindowId(macScalePtr->info.tkwin)); - portChanged = QDSwapPort(dstPort, &savePort); + portChanged = QDSwapPort(destPort, &savePort); TkMacOSXSetUpClippingRgn(Tk_WindowId(macScalePtr->info.tkwin)); TkMacOSXWinBounds((TkWindow *) macScalePtr->info.tkwin, &bounds); diff --git a/macosx/tkMacOSXScrlbr.c b/macosx/tkMacOSXScrlbr.c index 8e1148e..b7b5c29 100644 --- a/macosx/tkMacOSXScrlbr.c +++ b/macosx/tkMacOSXScrlbr.c @@ -12,7 +12,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkMacOSXScrlbr.c,v 1.22 2007/05/09 12:55:16 das Exp $ + * RCS: @(#) $Id: tkMacOSXScrlbr.c,v 1.22.2.1 2007/06/12 16:22:42 dgp Exp $ */ #include "tkMacOSXInt.h" @@ -274,7 +274,6 @@ TkpDisplayScrollbar( if (macScrollPtr->sbHandle == NULL) { Rect r = {0, 0, 1, 1}; - WindowRef frontNonFloating; windowRef = GetWindowFromPort(destPort); CreateScrollBarControl(windowRef, &r, MIN_SCROLLBAR_VALUE + @@ -283,13 +282,7 @@ TkpDisplayScrollbar( MIN_SCROLLBAR_VALUE, true, NULL, &(macScrollPtr->sbHandle)); SetControlReference(macScrollPtr->sbHandle, (SInt32) scrollPtr); - /* - * If we are foremost then make us active. - */ - - frontNonFloating = ActiveNonFloatingWindow(); - - if ((windowRef == FrontWindow()) || TkpIsWindowFloating(windowRef)) { + if (IsWindowActive(windowRef)) { macScrollPtr->macFlags |= ACTIVE; } } @@ -961,7 +954,8 @@ UpdateControlValues( if (portRect.bottom == contrlRect.bottom && portRect.right == contrlRect.right) { TkMacOSXSetScrollbarGrow((TkWindow *) tkwin, true); - if (TkMacOSXResizable(macDraw->toplevel->winPtr)) { + if (macDraw->toplevel && + TkMacOSXResizable(macDraw->toplevel->winPtr)) { int growSize; switch (TkMacOSXWindowClass(macDraw->toplevel->winPtr)) { diff --git a/macosx/tkMacOSXSubwindows.c b/macosx/tkMacOSXSubwindows.c index e71a05b..7fb0719 100644 --- a/macosx/tkMacOSXSubwindows.c +++ b/macosx/tkMacOSXSubwindows.c @@ -10,7 +10,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkMacOSXSubwindows.c,v 1.18.2.3 2007/06/04 15:19:01 dgp Exp $ + * RCS: @(#) $Id: tkMacOSXSubwindows.c,v 1.18.2.4 2007/06/12 16:22:42 dgp Exp $ */ #include "tkMacOSXInt.h" @@ -688,23 +688,25 @@ void TkMacOSXUpdateClipRgn( TkWindow *winPtr) { + MacDrawable *macWin; + if (winPtr == NULL) { return; } - - if (winPtr->privatePtr && winPtr->privatePtr->flags & TK_CLIP_INVALID) { + macWin = winPtr->privatePtr; + if (macWin && macWin->flags & TK_CLIP_INVALID) { TkWindow *win2Ptr; if (Tk_IsMapped(winPtr)) { int x, y; - RgnHandle rgn = winPtr->privatePtr->aboveClipRgn; + RgnHandle rgn = macWin->aboveClipRgn; /* * Start with a region defined by the window bounds. */ - x = winPtr->privatePtr->xOff; - y = winPtr->privatePtr->yOff; + x = macWin->xOff; + y = macWin->yOff; SetRectRgn(rgn, (short) x, (short) y, (short) (winPtr->changes.width + x), (short) (winPtr->changes.height + y)); @@ -766,8 +768,8 @@ TkMacOSXUpdateClipRgn( * of the embedded window. */ - rgn = winPtr->privatePtr->clipRgn; - CopyRgn(winPtr->privatePtr->aboveClipRgn, rgn); + rgn = macWin->clipRgn; + CopyRgn(macWin->aboveClipRgn, rgn); win2Ptr = winPtr->childList; while (win2Ptr) { if (Tk_IsTopLevel(win2Ptr) || !Tk_IsMapped(win2Ptr)) { @@ -816,17 +818,15 @@ TkMacOSXUpdateClipRgn( TkMacOSXUpdateClipRgn(win2Ptr); } } - SetEmptyRgn(winPtr->privatePtr->aboveClipRgn); - SetEmptyRgn(winPtr->privatePtr->clipRgn); + SetEmptyRgn(macWin->aboveClipRgn); + SetEmptyRgn(macWin->clipRgn); } - winPtr->privatePtr->flags &= ~TK_CLIP_INVALID; + macWin->flags &= ~TK_CLIP_INVALID; #ifdef TK_MAC_DEBUG_CLIP_REGIONS - TkMacOSXDebugFlashRegion(TkMacOSXGetDrawablePort( - (Drawable) winPtr->privatePtr), - ((MacDrawable*) winPtr->privatePtr)->clipRgn); + TkMacOSXDebugFlashRegion(TkMacOSXGetDrawablePort((Drawable) macWin), + macWin->visRgn); #endif /* TK_MAC_DEBUG_CLIP_REGIONS */ - } } @@ -1051,18 +1051,19 @@ TkMacOSXInvalClipRgns( { TkWindow *winPtr = (TkWindow *) tkwin; TkWindow *childPtr; + MacDrawable *macWin = winPtr->privatePtr; /* * If already marked we can stop because all * decendants will also already be marked. */ - if (!winPtr->privatePtr || winPtr->privatePtr->flags & TK_CLIP_INVALID) { + if (!macWin || macWin->flags & TK_CLIP_INVALID) { return; } - winPtr->privatePtr->flags |= TK_CLIP_INVALID; - SetEmptyRgn(winPtr->privatePtr->aboveClipRgn); - SetEmptyRgn(winPtr->privatePtr->clipRgn); + macWin->flags |= TK_CLIP_INVALID; + SetEmptyRgn(macWin->aboveClipRgn); + SetEmptyRgn(macWin->clipRgn); /* * Invalidate clip regions for all children & diff --git a/macosx/tkMacOSXWindowEvent.c b/macosx/tkMacOSXWindowEvent.c index c73d8ae..9ec0411 100644 --- a/macosx/tkMacOSXWindowEvent.c +++ b/macosx/tkMacOSXWindowEvent.c @@ -54,7 +54,7 @@ * software in accordance with the terms specified in this * license. * - * RCS: @(#) $Id: tkMacOSXWindowEvent.c,v 1.22.2.3 2007/06/04 15:19:01 dgp Exp $ + * RCS: @(#) $Id: tkMacOSXWindowEvent.c,v 1.22.2.4 2007/06/12 16:22:42 dgp Exp $ */ #include "tkMacOSXInt.h" @@ -456,7 +456,7 @@ GenerateUpdateEvent(Window window) TkMacOSXCheckTmpRgnEmpty(1); destPort = TkMacOSXGetDrawablePort(window); macWindow = GetWindowFromPort(destPort); - GetWindowRegion(macWindow, kWindowUpdateRgn, tkMacOSXtmpRgn1); + ChkErr(GetWindowRegion, macWindow, kWindowUpdateRgn, tkMacOSXtmpRgn1); QDGlobalToLocalRegion(destPort, tkMacOSXtmpRgn1); SectRegionWithPortVisibleRegion(destPort, tkMacOSXtmpRgn1); GetRegionBounds(tkMacOSXtmpRgn1, &updateBounds); diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c index 9c96537..4205e43 100644 --- a/macosx/tkMacOSXWm.c +++ b/macosx/tkMacOSXWm.c @@ -13,7 +13,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkMacOSXWm.c,v 1.49.2.3 2007/06/04 15:19:01 dgp Exp $ + * RCS: @(#) $Id: tkMacOSXWm.c,v 1.49.2.4 2007/06/12 16:22:43 dgp Exp $ */ #include "tkMacOSXInt.h" @@ -804,17 +804,9 @@ static int WmSetAttribute( err = ChkErr(FSPathMakeRef, (const unsigned char*) path, &ref, &d); if (err == noErr) { -#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1040 - if (1 -#if MAC_OS_X_VERSION_MIN_REQUIRED < 1040 - && HIWindowSetProxyFSRef != NULL -#endif - ) { + TK_IF_MAC_OS_X_API (4, HIWindowSetProxyFSRef, err = ChkErr(HIWindowSetProxyFSRef, macWindow, &ref); - } else -#endif - { -#if MAC_OS_X_VERSION_MIN_REQUIRED < 1040 + ) TK_ELSE_MAC_OS_X (4, AliasHandle alias; err = ChkErr(FSNewAlias, NULL, &ref, &alias); @@ -823,8 +815,7 @@ static int WmSetAttribute( alias); DisposeHandle((Handle) alias); } -#endif - } + ) TK_ENDIF } } else { int len; @@ -871,12 +862,7 @@ static int WmSetAttribute( if (boolean) { wmPtr->flags |= WM_TRANSPARENT; wmPtr->attributes |= kWindowNoShadowAttribute; -#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1030 - if (1 -#if MAC_OS_X_VERSION_MIN_REQUIRED < 1030 - && HIWindowChangeFeatures != NULL -#endif - ) { + TK_IF_MAC_OS_X_API (3, HIWindowChangeFeatures, UInt32 features; ChkErr(GetWindowFeatures, macWindow, &features); @@ -884,8 +870,7 @@ static int WmSetAttribute( ChkErr(HIWindowChangeFeatures, macWindow, 0, kWindowIsOpaque); } - } -#endif + ) TK_ENDIF } else { wmPtr->flags &= ~WM_TRANSPARENT; wmPtr->attributes &= ~kWindowNoShadowAttribute; @@ -944,17 +929,9 @@ static Tcl_Obj *WmGetAttribute( UInt8 path[PATH_MAX+1]; OSStatus err; -#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1040 - if (1 -#if MAC_OS_X_VERSION_MIN_REQUIRED < 1040 - && HIWindowSetProxyFSRef != NULL -#endif - ) { + TK_IF_MAC_OS_X_API (4, HIWindowSetProxyFSRef, err = ChkErr(HIWindowGetProxyFSRef, macWindow, &ref); - } else -#endif -#if MAC_OS_X_VERSION_MIN_REQUIRED < 1040 - { + ) TK_ELSE_MAC_OS_X (4, Boolean wasChanged; AliasHandle alias; @@ -963,8 +940,7 @@ static Tcl_Obj *WmGetAttribute( err = ChkErr(FSResolveAlias, NULL, alias, &ref, &wasChanged); } - } -#endif + ) TK_ENDIF if (err == noErr) { err = ChkErr(FSRefMakePath, &ref, path, PATH_MAX); } @@ -5784,8 +5760,7 @@ TkWmStackorderToplevel(parentPtr) goto done; } - frontWindow = (WindowRef) FrontWindow(); - + frontWindow = GetFrontWindowOfClass(kAllWindowClasses, false); if (frontWindow == NULL) { ckfree((char *) windows); windows = NULL; @@ -5794,11 +5769,11 @@ TkWmStackorderToplevel(parentPtr) *window_ptr-- = NULL; while (frontWindow != NULL) { hPtr = Tcl_FindHashEntry(&table, (char *) frontWindow); - if (hPtr != NULL) { - childWinPtr = (TkWindow *) Tcl_GetHashValue(hPtr); - *window_ptr-- = childWinPtr; - } - frontWindow = GetNextWindow(frontWindow); + if (hPtr != NULL) { + childWinPtr = (TkWindow *) Tcl_GetHashValue(hPtr); + *window_ptr-- = childWinPtr; + } + frontWindow = GetNextWindow(frontWindow); } if (window_ptr != (windows-1)) Tcl_Panic("num matched toplevel windows does not equal num " @@ -5859,16 +5834,12 @@ ApplyWindowClassAttributeChanges( macWindow = GetWindowFromPort(TkMacOSXGetDrawablePort( winPtr->window)); } -#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1030 - if (wmPtr->macClass != oldClass -#if MAC_OS_X_VERSION_MIN_REQUIRED < 1030 - && HIWindowChangeClass != NULL -#endif - ) { - ChkErr(HIWindowChangeClass, macWindow, wmPtr->macClass); + if (wmPtr->macClass != oldClass) { + TK_IF_MAC_OS_X_API (4, HIWindowChangeClass, + ChkErr(HIWindowChangeClass, macWindow, wmPtr->macClass); + ) TK_ENDIF ChkErr(GetWindowClass, macWindow, &(wmPtr->macClass)); } -#endif if (newAttributes != oldAttributes) { newAttributes &= GetAvailableWindowAttributes(wmPtr->macClass); ChkErr(ChangeWindowAttributes, macWindow, @@ -6090,20 +6061,12 @@ TkMacOSXEnterExitFullscreen( static SystemUIOptions fullscreenOptions = 0; if (!fullscreenMode) { -#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1030 - if (1 -#if MAC_OS_X_VERSION_MIN_REQUIRED < 1030 - && &kHIToolboxVersionNumber != NULL - && kHIToolboxVersionNumber >= kHIToolboxVersionNumber10_3 -#endif - ) { + TK_IF_HI_TOOLBOX (3, fullscreenMode = kUIModeAllSuppressed; - } else -#endif - { + ) TK_ELSE_HI_TOOLBOX (3, fullscreenMode = kUIModeAllHidden; fullscreenOptions = kUIOptionAutoShowMenuBar; - } + ) TK_ENDIF } if (mode != fullscreenMode) { ChkErr(SetSystemUIMode, fullscreenMode, fullscreenOptions); diff --git a/macosx/tkMacOSXXStubs.c b/macosx/tkMacOSXXStubs.c index 805d07d..15bc1d2 100644 --- a/macosx/tkMacOSXXStubs.c +++ b/macosx/tkMacOSXXStubs.c @@ -13,7 +13,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkMacOSXXStubs.c,v 1.17.2.2 2007/06/04 15:19:01 dgp Exp $ + * RCS: @(#) $Id: tkMacOSXXStubs.c,v 1.17.2.3 2007/06/12 16:22:43 dgp Exp $ */ #include "tkMacOSXInt.h" @@ -1143,7 +1143,6 @@ Tk_GetUserInactiveTime(Display *dpy) timeObj = CFDictionaryGetValue(props, CFSTR("HIDIdleTime")); if (timeObj) { - CFRetain(timeObj); CFTypeID type = CFGetTypeID(timeObj); if (type == CFDataGetTypeID()) { /* Jaguar */ @@ -1161,8 +1160,6 @@ Tk_GetUserInactiveTime(Display *dpy) } else { ret = -1l; } - - CFRelease(timeObj); } /* Cleanup */ CFRelease(props); diff --git a/tests/ttk/notebook.test b/tests/ttk/notebook.test index ecb614a..76b6403 100644 --- a/tests/ttk/notebook.test +++ b/tests/ttk/notebook.test @@ -1,5 +1,5 @@ # -# $Id: notebook.test,v 1.1 2006/10/31 01:42:27 hobbs Exp $ +# $Id: notebook.test,v 1.1.2.1 2007/06/12 16:22:43 dgp Exp $ # package require Tk 8.5 @@ -380,6 +380,49 @@ test notebook-7.7d "insert - current tab undisturbed" -body { .nb index current } -result 4 +test notebook-7.8a "move tabs - current tab undisturbed - exhaustive" -body { + .nb select .nb.f0 + foreach i {0 1 2 3 4} { + .nb insert $i .nb.f$i + } + + foreach i {0 1 2 3 4} { + .nb select .nb.f$i + foreach j {0 1 2 3 4} { + foreach k {0 1 2 3 4} { + .nb insert $j $k + set current [lindex [.nb tabs] [.nb index current]] + if {$current != ".nb.f$i"} { + error "($i,$j,$k) current = $current" + } + .nb insert $k $j + if {[.nb tabs] ne [list .nb.f0 .nb.f1 .nb.f2 .nb.f3 .nb.f4]} { + error "swap $j $k; swap $k $j => [.nb tabs]" + } + } + } + } + .nb tabs +} -result [list .nb.f0 .nb.f1 .nb.f2 .nb.f3 .nb.f4] + +test notebook-7.8b "insert new - current tab undisturbed - exhaustive" -body { + foreach i {0 1 2 3 4} { + .nb select .nb.f$i + foreach j {0 1 2 3 4} { +.nb select .nb.f$i + .nb insert $j [frame .nb.newf] + set current [lindex [.nb tabs] [.nb index current]] + if {$current != ".nb.f$i"} { + puts stderr "new tab at $j, current = $current, expect .nb.f$i" + } + destroy .nb.newf + if {[.nb tabs] ne [list .nb.f0 .nb.f1 .nb.f2 .nb.f3 .nb.f4]} { + error "tabs disturbed" + } + } + } +} + test notebook-7.end "insert - cleanup" -body { destroy .nb } diff --git a/tests/ttk/panedwindow.test b/tests/ttk/panedwindow.test index 190e6b5..c5c509f 100644 --- a/tests/ttk/panedwindow.test +++ b/tests/ttk/panedwindow.test @@ -1,5 +1,5 @@ # -# $Id: panedwindow.test,v 1.2 2006/11/07 03:45:28 jenglish Exp $ +# $Id: panedwindow.test,v 1.2.2.1 2007/06/12 16:22:43 dgp Exp $ # package require Tk 8.5 @@ -156,10 +156,11 @@ test panedwindow-4.2 "forget forgotten" -body { # proc checkorder {winlist} { set pos -1 + set positions [list] foreach win $winlist { - set nextpos [winfo y $win] + lappend positions [set nextpos [winfo y $win]] if {$nextpos <= $pos} { - error "window $win out of order" + error "window $win out of order ($positions)" } set pos $nextpos } @@ -181,7 +182,7 @@ test panedwindow-4.END "cleanup" -body { # See #1292219 -test panedwindow-5.1 "Propage Map/Unmap state to children" -body { +test panedwindow-5.1 "Propagate Map/Unmap state to children" -body { set result [list] pack [ttk::panedwindow .pw] .pw add [ttk::button .pw.b] @@ -198,4 +199,51 @@ test panedwindow-5.1 "Propage Map/Unmap state to children" -body { destroy .pw } +### sashpos tests. +# +proc sashpositions {pw} { + set positions [list] + set npanes [llength [winfo children $pw]] + for {set i 0} {$i < $npanes - 1} {incr i} { + lappend positions [$pw sashpos $i] + } + return $positions +} + +test paned-sashpos-setup "Setup for sash position test" -body { + ttk::style theme use default + ttk::style configure -sashthickness 5 + + ttk::panedwindow .pw + .pw add [frame .pw.f1 -width 20 -height 20] + .pw add [frame .pw.f2 -width 20 -height 20] + .pw add [frame .pw.f3 -width 20 -height 20] + .pw add [frame .pw.f4 -width 20 -height 20] + + update idletasks + list [winfo reqwidth .pw] [winfo reqheight .pw] +} -result [list 20 [expr {20*4 + 5*3}]] + +test paned-sashpos-attempt-restore "Attempt to set sash positions" -body { + # This is not expected to succeed, since .pw isn't large enough yet. + # + .pw sashpos 0 30 + .pw sashpos 1 60 + .pw sashpos 2 90 + + list [winfo reqwidth .pw] [winfo reqheight .pw] [sashpositions .pw] +} -result [list 20 95 [list 0 5 10]] + +test paned-sashpos-restore "Set height then sash positions" -body { + # Setting sash positions after setting -height _should_ succeed. + # + .pw configure -height 120 + .pw sashpos 0 30 + .pw sashpos 1 60 + .pw sashpos 2 90 + list [winfo reqwidth .pw] [winfo reqheight .pw] [sashpositions .pw] +} -result [list 20 120 [list 30 60 90]] + +test paned-sashpos-cleanup "Clean up" -body { destroy .pw } + tcltest::cleanupTests diff --git a/unix/configure b/unix/configure index 9d81384..94682d3 100755 --- a/unix/configure +++ b/unix/configure @@ -6025,13 +6025,13 @@ if test "${tcl_cv_lib_corefoundation+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else - hold_libs=$LIBS; hold_cflags=$CFLAGS - if test "$fat_32_64" = yes; then + hold_libs=$LIBS + if test "$fat_32_64" = yes; then for v in CFLAGS CPPFLAGS LDFLAGS; do # On Tiger there is no 64-bit CF, so remove 64-bit archs - # from CFLAGS while testing for presence of CF. + # from CFLAGS et al. while testing for presence of CF. # 64-bit CF is disabled in tclUnixPort.h if necessary. - CFLAGS="`echo "$CFLAGS " | sed -e 's/-arch ppc64 / /g' -e 's/-arch x86_64 / /g'`" - fi + eval 'hold_'$v'="$'$v'";'$v'="`echo "$'$v' "|sed -e "s/-arch ppc64 / /g" -e "s/-arch x86_64 / /g"`"' + done; fi LIBS="$LIBS -framework CoreFoundation" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ @@ -6079,7 +6079,9 @@ tcl_cv_lib_corefoundation=no fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext - LIBS=$hold_libs; CFLAGS=$hold_cflags + if test "$fat_32_64" = yes; then for v in CFLAGS CPPFLAGS LDFLAGS; do + eval $v'="$hold_'$v'"' + done; fi; LIBS=$hold_libs fi echo "$as_me:$LINENO: result: $tcl_cv_lib_corefoundation" >&5 echo "${ECHO_T}$tcl_cv_lib_corefoundation" >&6 @@ -6100,8 +6102,9 @@ if test "${tcl_cv_lib_corefoundation_64+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else - hold_cflags=$CFLAGS - CFLAGS="`echo "$CFLAGS " | sed -e 's/-arch ppc / /g' -e 's/-arch i386 / /g'`" + for v in CFLAGS CPPFLAGS LDFLAGS; do + eval 'hold_'$v'="$'$v'";'$v'="`echo "$'$v' "|sed -e "s/-arch ppc / /g" -e "s/-arch i386 / /g"`"' + done cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -6148,7 +6151,9 @@ tcl_cv_lib_corefoundation_64=no fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext - CFLAGS=$hold_cflags + for v in CFLAGS CPPFLAGS LDFLAGS; do + eval $v'="$hold_'$v'"' + done fi echo "$as_me:$LINENO: result: $tcl_cv_lib_corefoundation_64" >&5 echo "${ECHO_T}$tcl_cv_lib_corefoundation_64" >&6 @@ -8587,10 +8592,10 @@ echo "$as_me: WARNING: Aqua requires Mac OS X 10.2 or later" >&2;} fi echo "$as_me:$LINENO: result: $tk_aqua" >&5 echo "${ECHO_T}$tk_aqua" >&6 - # remove 64-bit arch flags from CFLAGS for combined 32-bit and 64-bit fat + # remove 64-bit arch flags from CFLAGS et al. for combined 32 & 64 bit fat # builds, as neither TkAqua nor TkX11 can be built for 64-bit at present. - test "$fat_32_64" = yes && \ - CFLAGS="`echo "$CFLAGS " | sed -e 's/-arch ppc64 / /g' -e 's/-arch x86_64 / /g'`" + test "$fat_32_64" = yes && for v in CFLAGS CPPFLAGS LDFLAGS; do + eval $v'="`echo "$'$v' "|sed -e "s/-arch ppc64 / /g" -e "s/-arch x86_64 / /g"`"'; done if test $tk_aqua = no; then # check if weak linking whole libraries is possible. echo "$as_me:$LINENO: checking if ld accepts -weak-l flag" >&5 @@ -8778,7 +8783,7 @@ ac_x_header_dirs=' /usr/openwin/share/include' if test "$ac_x_includes" = no; then - # Guess where to find include files, by looking for Xlib.h. + # Guess where to find include files, by looking for Intrinsic.h. # First, try using that file with no special directory specified. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ @@ -8786,7 +8791,7 @@ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -#include +#include _ACEOF if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 @@ -8813,7 +8818,7 @@ else sed 's/^/| /' conftest.$ac_ext >&5 for ac_dir in $ac_x_header_dirs; do - if test -r "$ac_dir/X11/Xlib.h"; then + if test -r "$ac_dir/X11/Intrinsic.h"; then ac_x_includes=$ac_dir break fi @@ -8827,18 +8832,18 @@ if test "$ac_x_libraries" = no; then # See if we find them without any special options. # Don't add to $LIBS permanently. ac_save_LIBS=$LIBS - LIBS="-lX11 $LIBS" + LIBS="-lXt $LIBS" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -#include +#include int main () { -XrmInitialize () +XtMalloc (0) ; return 0; } @@ -9987,6 +9992,10 @@ echo "${ECHO_T}static library" >&6 TK_SHLIB_LD_EXTRAS="-compatibility_version ${TK_VERSION} -current_version ${TK_VERSION}`echo ${TK_PATCH_LEVEL} | awk '{match($0, "\\\.[0-9]+"); print substr($0,RSTART,RLENGTH)}'`" TK_SHLIB_LD_EXTRAS="${TK_SHLIB_LD_EXTRAS}"' -install_name ${DYLIB_INSTALL_DIR}/${TK_LIB_FILE} -seg1addr 0xb000000 -unexported_symbols_list $$(f=$(TCL_STUB_LIB_FILE).E && nm -gjp $(TCL_BIN_DIR)/$(TCL_STUB_LIB_FILE) | grep ^_[^_] > $$f && echo $$f)' + TK_SHLIB_LD_EXTRAS="${TK_SHLIB_LD_EXTRAS}"' -sectcreate __TEXT __info_plist Tk-Info.plist' + EXTRA_WISH_LIBS='-sectcreate __TEXT __info_plist Wish-Info.plist' + ac_config_files="$ac_config_files Tk-Info.plist:../macosx/Tk-Info.plist.in Wish-Info.plist:../macosx/Wish-Info.plist.in" + fi if test "$FRAMEWORK_BUILD" = "1" ; then @@ -9995,8 +10004,6 @@ cat >>confdefs.h <<\_ACEOF #define TK_FRAMEWORK 1 _ACEOF - ac_config_files="$ac_config_files Tk-Info.plist:../macosx/Tk-Info.plist.in" - # Construct a fake local framework structure to make linking with # '-framework Tk' and running of tktest work ac_config_commands="$ac_config_commands Tk.framework" @@ -10064,9 +10071,6 @@ fi # Support for building the Aqua resource files if test $tk_aqua = yes; then - ac_config_files="$ac_config_files Wish-Info.plist:../macosx/Wish-Info.plist.in" - - EXTRA_WISH_LIBS='-sectcreate __TEXT __info_plist Wish-Info.plist' LIB_RSRC_FILE='${TK_RSRC_FILE}' APP_RSRC_FILE='${WISH_RSRC_FILE}' REZ=/Developer/Tools/Rez @@ -10075,7 +10079,7 @@ if test $tk_aqua = yes; then EXTRA_INSTALL_BINARIES='@echo "Installing $(TK_RSRC_FILE) to $(LIB_INSTALL_DIR)" && $(INSTALL_DATA) $(TK_RSRC_FILE) $(LIB_INSTALL_DIR)' TK_BUILD_LIB_SPEC="$TK_BUILD_LIB_SPEC -sectcreate __TEXT __tk_rsrc `pwd`/\${TK_RSRC_FILE}" TK_LIB_SPEC="$TK_LIB_SPEC -sectcreate __TEXT __tk_rsrc ${libdir}/\${TK_RSRC_FILE}" - elif test "$FRAMEWORK_BUILD" = "0"; then + else TK_SHLIB_LD_EXTRAS="$TK_SHLIB_LD_EXTRAS -sectcreate __TEXT __tk_rsrc \${TK_RSRC_FILE}" fi fi diff --git a/unix/configure.in b/unix/configure.in index e5406bb..3a4b26b 100644 --- a/unix/configure.in +++ b/unix/configure.in @@ -3,7 +3,7 @@ dnl This file is an input file used by the GNU "autoconf" program to dnl generate the file "configure", which is run during Tk installation dnl to configure the system for the local environment. # -# RCS: @(#) $Id: configure.in,v 1.134.2.1 2007/05/22 20:34:53 dgp Exp $ +# RCS: @(#) $Id: configure.in,v 1.134.2.2 2007/06/12 16:22:44 dgp Exp $ AC_INIT([tk],[8.5]) AC_PREREQ(2.59) @@ -256,10 +256,10 @@ if test "`uname -s`" = "Darwin" ; then fi fi AC_MSG_RESULT([$tk_aqua]) - # remove 64-bit arch flags from CFLAGS for combined 32-bit and 64-bit fat + # remove 64-bit arch flags from CFLAGS et al. for combined 32 & 64 bit fat # builds, as neither TkAqua nor TkX11 can be built for 64-bit at present. - test "$fat_32_64" = yes && \ - CFLAGS="`echo "$CFLAGS " | sed -e 's/-arch ppc64 / /g' -e 's/-arch x86_64 / /g'`" + test "$fat_32_64" = yes && for v in CFLAGS CPPFLAGS LDFLAGS; do + eval $v'="`echo "$'$v' "|sed -e "s/-arch ppc64 / /g" -e "s/-arch x86_64 / /g"`"'; done if test $tk_aqua = no; then # check if weak linking whole libraries is possible. AC_CACHE_CHECK([if ld accepts -weak-l flag], tcl_cv_ld_weak_l, [ @@ -530,11 +530,13 @@ if test "`uname -s`" = "Darwin" ; then SC_ENABLE_FRAMEWORK TK_SHLIB_LD_EXTRAS="-compatibility_version ${TK_VERSION} -current_version ${TK_VERSION}`echo ${TK_PATCH_LEVEL} | awk ['{match($0, "\\\.[0-9]+"); print substr($0,RSTART,RLENGTH)}']`" TK_SHLIB_LD_EXTRAS="${TK_SHLIB_LD_EXTRAS}"' -install_name ${DYLIB_INSTALL_DIR}/${TK_LIB_FILE} -seg1addr 0xb000000 -unexported_symbols_list $$(f=$(TCL_STUB_LIB_FILE).E && nm -gjp $(TCL_BIN_DIR)/$(TCL_STUB_LIB_FILE) | grep ^_[[^_]] > $$f && echo $$f)' + TK_SHLIB_LD_EXTRAS="${TK_SHLIB_LD_EXTRAS}"' -sectcreate __TEXT __info_plist Tk-Info.plist' + EXTRA_WISH_LIBS='-sectcreate __TEXT __info_plist Wish-Info.plist' + AC_CONFIG_FILES([Tk-Info.plist:../macosx/Tk-Info.plist.in Wish-Info.plist:../macosx/Wish-Info.plist.in]) fi if test "$FRAMEWORK_BUILD" = "1" ; then AC_DEFINE(TK_FRAMEWORK, 1, [Is Tk built as a framework?]) - AC_CONFIG_FILES([Tk-Info.plist:../macosx/Tk-Info.plist.in]) # Construct a fake local framework structure to make linking with # '-framework Tk' and running of tktest work AC_CONFIG_COMMANDS([Tk.framework], [n=Tk && @@ -608,8 +610,6 @@ fi # Support for building the Aqua resource files if test $tk_aqua = yes; then - AC_CONFIG_FILES([Wish-Info.plist:../macosx/Wish-Info.plist.in]) - EXTRA_WISH_LIBS='-sectcreate __TEXT __info_plist Wish-Info.plist' LIB_RSRC_FILE='${TK_RSRC_FILE}' APP_RSRC_FILE='${WISH_RSRC_FILE}' REZ=/Developer/Tools/Rez @@ -618,7 +618,7 @@ if test $tk_aqua = yes; then EXTRA_INSTALL_BINARIES='@echo "Installing $(TK_RSRC_FILE) to $(LIB_INSTALL_DIR)" && $(INSTALL_DATA) $(TK_RSRC_FILE) $(LIB_INSTALL_DIR)' TK_BUILD_LIB_SPEC="$TK_BUILD_LIB_SPEC -sectcreate __TEXT __tk_rsrc `pwd`/\${TK_RSRC_FILE}" TK_LIB_SPEC="$TK_LIB_SPEC -sectcreate __TEXT __tk_rsrc ${libdir}/\${TK_RSRC_FILE}" - elif test "$FRAMEWORK_BUILD" = "0"; then + else TK_SHLIB_LD_EXTRAS="$TK_SHLIB_LD_EXTRAS -sectcreate __TEXT __tk_rsrc \${TK_RSRC_FILE}" fi fi diff --git a/unix/tcl.m4 b/unix/tcl.m4 index d2e82c6..3b3dcad 100644 --- a/unix/tcl.m4 +++ b/unix/tcl.m4 @@ -1680,18 +1680,20 @@ dnl AC_CHECK_TOOL(AR, ar) AC_MSG_RESULT([$tcl_corefoundation]) if test $tcl_corefoundation = yes; then AC_CACHE_CHECK([for CoreFoundation.framework], tcl_cv_lib_corefoundation, [ - hold_libs=$LIBS; hold_cflags=$CFLAGS - if test "$fat_32_64" = yes; then + hold_libs=$LIBS + if test "$fat_32_64" = yes; then for v in CFLAGS CPPFLAGS LDFLAGS; do # On Tiger there is no 64-bit CF, so remove 64-bit archs - # from CFLAGS while testing for presence of CF. + # from CFLAGS et al. while testing for presence of CF. # 64-bit CF is disabled in tclUnixPort.h if necessary. - CFLAGS="`echo "$CFLAGS " | sed -e 's/-arch ppc64 / /g' -e 's/-arch x86_64 / /g'`" - fi + eval 'hold_'$v'="$'$v'";'$v'="`echo "$'$v' "|sed -e "s/-arch ppc64 / /g" -e "s/-arch x86_64 / /g"`"' + done; fi LIBS="$LIBS -framework CoreFoundation" AC_TRY_LINK([#include ], [CFBundleRef b = CFBundleGetMainBundle();], tcl_cv_lib_corefoundation=yes, tcl_cv_lib_corefoundation=no) - LIBS=$hold_libs; CFLAGS=$hold_cflags]) + if test "$fat_32_64" = yes; then for v in CFLAGS CPPFLAGS LDFLAGS; do + eval $v'="$hold_'$v'"' + done; fi; LIBS=$hold_libs]) if test $tcl_cv_lib_corefoundation = yes; then LIBS="$LIBS -framework CoreFoundation" AC_DEFINE(HAVE_COREFOUNDATION, 1, @@ -1701,12 +1703,15 @@ dnl AC_CHECK_TOOL(AR, ar) fi if test "$fat_32_64" = yes -a $tcl_corefoundation = yes; then AC_CACHE_CHECK([for 64-bit CoreFoundation], tcl_cv_lib_corefoundation_64, [ - hold_cflags=$CFLAGS - CFLAGS="`echo "$CFLAGS " | sed -e 's/-arch ppc / /g' -e 's/-arch i386 / /g'`" + for v in CFLAGS CPPFLAGS LDFLAGS; do + eval 'hold_'$v'="$'$v'";'$v'="`echo "$'$v' "|sed -e "s/-arch ppc / /g" -e "s/-arch i386 / /g"`"' + done AC_TRY_LINK([#include ], [CFBundleRef b = CFBundleGetMainBundle();], tcl_cv_lib_corefoundation_64=yes, tcl_cv_lib_corefoundation_64=no) - CFLAGS=$hold_cflags]) + for v in CFLAGS CPPFLAGS LDFLAGS; do + eval $v'="$hold_'$v'"' + done]) if test $tcl_cv_lib_corefoundation_64 = no; then AC_DEFINE(NO_COREFOUNDATION_64, 1, [Is Darwin CoreFoundation unavailable for 64-bit?]) diff --git a/win/tkWinMenu.c b/win/tkWinMenu.c index 5852d58..5d5f6fd 100644 --- a/win/tkWinMenu.c +++ b/win/tkWinMenu.c @@ -10,7 +10,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkWinMenu.c,v 1.56 2007/05/05 07:33:08 dkf Exp $ + * RCS: @(#) $Id: tkWinMenu.c,v 1.56.2.1 2007/06/12 16:22:45 dgp Exp $ */ #define OEMRESOURCE @@ -1100,35 +1100,34 @@ TkWinHandleMenuEvent( break; case WM_MENUCHAR: { - unsigned char menuChar = (unsigned char) LOWORD(*pwParam); - hashEntryPtr = Tcl_FindHashEntry(&tsdPtr->winMenuTable, (char *) *plParam); if (hashEntryPtr != NULL) { int i, len, underline; Tcl_Obj *labelPtr; + Tcl_UniChar *wlabel, menuChar; *plResult = 0; menuPtr = (TkMenu *) Tcl_GetHashValue(hashEntryPtr); + /* + * Assume we have something directly convertable to Tcl_UniChar. + * True at least for wide systems. + */ + menuChar = Tcl_UniCharToUpper((Tcl_UniChar) LOWORD(*pwParam)); + for (i = 0; i < menuPtr->numEntries; i++) { underline = menuPtr->entries[i]->underline; labelPtr = menuPtr->entries[i]->labelPtr; if ((underline >= 0) && (labelPtr != NULL)) { /* - * Do the unicode call just to prevent overruns. + * Ensure we don't exceed the label length, then check */ - - Tcl_GetUnicodeFromObj(labelPtr, &len); - if (underline < len) { - char *label = Tcl_GetString(labelPtr); - char underlined = *Tcl_UtfAtIndex(label, underline); - - if (CharUpper((LPTSTR) menuChar) == - CharUpper((LPTSTR) underlined)) { - *plResult = (2 << 16) | i; - returnResult = 1; - break; - } + wlabel = Tcl_GetUnicodeFromObj(labelPtr, &len); + if ((underline < len) && (menuChar == + Tcl_UniCharToUpper(wlabel[underline]))) { + *plResult = (2 << 16) | i; + returnResult = 1; + break; } } } diff --git a/win/tkWinWm.c b/win/tkWinWm.c index e089985..2b6fde3 100644 --- a/win/tkWinWm.c +++ b/win/tkWinWm.c @@ -12,7 +12,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkWinWm.c,v 1.116 2007/05/04 21:29:23 patthoyts Exp $ + * RCS: @(#) $Id: tkWinWm.c,v 1.116.2.1 2007/06/12 16:22:45 dgp Exp $ */ #include "tkWinInt.h" @@ -4327,7 +4327,8 @@ WmIconphotoCmd( TkWindow *useWinPtr = winPtr; /* window to apply to (NULL if -default) */ Tk_PhotoHandle photo; Tk_PhotoImageBlock block; - int i, width, height, startObj = 3; + int i, width, height, idx, bufferSize, startObj = 3; + unsigned char *bgraPixelPtr; BlockOfIconImagesPtr lpIR; WinIconPtr titlebaricon = NULL; HICON hIcon; @@ -4380,11 +4381,20 @@ WmIconphotoCmd( Tk_PhotoGetImage(photo, &block); /* - * Encode the image data into an HICON. + * Convert the image data into BGRA format (RGBQUAD) and then + * encode the image data into an HICON. */ - + bufferSize = height * width * block.pixelSize; + bgraPixelPtr = ckalloc(bufferSize); + for (idx = 0 ; idx < bufferSize ; idx += 4) { + bgraPixelPtr[idx] = block.pixelPtr[idx+2]; + bgraPixelPtr[idx+1] = block.pixelPtr[idx+1]; + bgraPixelPtr[idx+2] = block.pixelPtr[idx+0]; + bgraPixelPtr[idx+3] = block.pixelPtr[idx+3]; + } hIcon = CreateIcon(Tk_GetHINSTANCE(), width, height, 1, 32, - NULL, (BYTE *) block.pixelPtr); + NULL, (BYTE *) bgraPixelPtr); + ckfree(bgraPixelPtr); if (hIcon == NULL) { /* * XXX should free up created icons. -- cgit v0.12