summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2007-11-25 19:19:21 (GMT)
committerdgp <dgp@users.sourceforge.net>2007-11-25 19:19:21 (GMT)
commit0d5bca3169f4ef93357a7a379ca5c0aa69e8131c (patch)
tree2fd7bf20dacfae0b55220ec099b052d5bb20a5ab
parent9b25df64820fb2cc1ae0bdc5d0b6ce2a81942844 (diff)
downloadtk-0d5bca3169f4ef93357a7a379ca5c0aa69e8131c.zip
tk-0d5bca3169f4ef93357a7a379ca5c0aa69e8131c.tar.gz
tk-0d5bca3169f4ef93357a7a379ca5c0aa69e8131c.tar.bz2
merge updates from HEAD
-rw-r--r--ChangeLog12
-rw-r--r--doc/ttk_notebook.n62
-rw-r--r--generic/ttk/ttkFrame.c15
-rw-r--r--generic/ttk/ttkManager.c18
-rw-r--r--generic/ttk/ttkManager.h8
-rw-r--r--generic/ttk/ttkNotebook.c103
-rw-r--r--generic/ttk/ttkPanedwindow.c37
-rw-r--r--tests/ttk/notebook.test56
-rw-r--r--tests/ttk/panedwindow.test50
-rw-r--r--tests/ttk/ttk.test6
10 files changed, 261 insertions, 106 deletions
diff --git a/ChangeLog b/ChangeLog
index eb7cfdd..95664b2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2007-11-25 Joe English <jenglish@users.sourceforge.net>
+
+ * generic/ttk/ttkManager.h, generic/ttk/ttkManager.c,
+ generic/ttk/ttkFrame.c, generic/ttk/ttkNotebook.c,
+ generic/ttk/ttkPanedwindow.c: Internal Ttk_Manager API
+ updates; Fixed [Bug 1343984]; Added [$nb hide] method;
+ [$nb add] on already-managed windows no longer throws
+ an error, can be used to re-add a hidden tab.
+
+ * doc/ttk_notebook.n, tests/ttk/notebook.test,
+ tests/ttk/panedwindow.test: Updated docs and test suite.
+
2007-11-23 Donal K. Fellows <donal.k.fellows@manchester.ac.uk>
* unix/README: General improvements.
diff --git a/doc/ttk_notebook.n b/doc/ttk_notebook.n
index 7247a96..d86331a 100644
--- a/doc/ttk_notebook.n
+++ b/doc/ttk_notebook.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_notebook.n,v 1.3.2.3 2007/11/01 16:37:16 dgp Exp $
+'\" RCS: @(#) $Id: ttk_notebook.n,v 1.3.2.4 2007/11/25 19:19:21 dgp Exp $
'\"
.so man.macros
.TH ttk::notebook n 8.5 Tk "Tk Themed Widget"
@@ -13,17 +13,17 @@
ttk::notebook \- Multi-paned container widget
.SH SYNOPSIS
.nf
-\fBttk::notebook\fR \fIpathName \fR?\fIoptions\fR?
+\fBttk::notebook\fR \fIpathName \fR?\fIoptions...\fR?
.br
-\fIpathName \fBadd\fR \fIpathName\fR.\fIsubwindow\fR ?\fIoptions...\fR?
-\fIpathName \fBinsert\fR \fIindex\fR \fIpathName\fR.\fIsubwindow\fR ?\fIoptions...\fR?
+\fIpathName \fBadd\fR \fIwindow\fR ?\fIoptions...\fR?
+\fIpathName \fBinsert\fR \fIindex\fR \fIwindow\fR ?\fIoptions...\fR?
.fi
.BE
.SH DESCRIPTION
-A \fBttk::notebook\fR widget manages a collection of subpanes
+A \fBttk::notebook\fR widget manages a collection of windows
and displays a single one at a time.
-Each pane is associated with a tab, which the user
-may select to change the currently-displayed pane.
+Each slave window is associated with a \fItab\fR,
+which the user may select to change the currently-displayed window.
.SO
\-class \-cursor \-takefocus \-style
.SE
@@ -51,14 +51,14 @@ Otherwise, the maximum width of all panes is used.
The following options may be specified for individual notebook panes:
.OP \-state state State
Either \fBnormal\fR, \fBdisabled\fR or \fBhidden\fR.
-If \fBdisabled\fR, then the tab is not selectable. If \fBhidden\fR,
-then the tab is not shown.
+If \fBdisabled\fR, then the tab is not selectable.
+If \fBhidden\fR, then the tab is not shown.
.OP \-sticky sticky Sticky
-Specifies how the child pane is positioned within the pane area.
+Specifies how the slave window is positioned within the pane area.
Value is a string containing zero or more of the characters
\fBn, s, e,\fR or \fBw\fR.
Each letter refers to a side (north, south, east, or west)
-that the child window will
+that the slave window will
.QW stick
to, as per the \fBgrid\fR geometry manager.
.OP \-padding padding Padding
@@ -67,8 +67,8 @@ Syntax is the same as for the widget \fB\-padding\fR option.
.OP \-text text Text
Specifies a string to be displayed in the tab.
.OP \-image image Image
-Specifies an image to display in the tab,
-which must have been created with the \fBimage create\fR command.
+Specifies an image to display in the tab.
+See \fIttk_widget(n)\fR for details.
.OP \-compound compound Compound
Specifies how to display the image relative to the text,
in the case both \fB\-text\fR and \fB\-image\fR are present.
@@ -80,12 +80,11 @@ The underlined character is used for mnemonic activation
if \fBttk::notebook::enableTraversal\fR is called.
.SH "WIDGET COMMAND"
.TP
-\fIpathname \fBadd \fIchild\fR ?\fIoptions...\fR?
+\fIpathname \fBadd\fR \fIwindow\fR ?\fIoptions...\fR?
Adds a new tab to the notebook.
-When the tab is selected, the \fIchild\fR window
-will be displayed.
-\fIchild\fR must be a direct child of the notebook window.
See \fBTAB OPTIONS\fR for the list of available \fIoptions\fR.
+If \fIwindow\fR is currently managed by the notebook but hidden,
+it is restored to its previous position.
.TP
\fIpathname \fBconfigure\fR ?\fIoptions\fR?
See \fIttk::widget(n)\fR.
@@ -95,7 +94,13 @@ See \fIttk::widget(n)\fR.
.TP
\fIpathname \fBforget\fR \fItabid\fR
Removes the tab specified by \fItabid\fR,
-unmaps and unmanages the associated child window.
+unmaps and unmanages the associated window.
+.TP
+\fIpathname \fBhide\fR \fItabid\fR
+Hides the tab specified by \fItabid\fR.
+The tab will not be displayed, but the associated window
+remains managed by the notebook and its configuration remembered.
+Hidden tabs may be restored with the \fBadd\fR command.
.TP
\fIpathname \fBindex\fR \fItabid\fR
Returns the numeric index of the tab specified by \fItabid\fR,
@@ -114,25 +119,26 @@ See \fBTAB OPTIONS\fR for the list of available options.
See \fIttk::widget(n)\fR.
.TP
\fIpathname \fBselect\fR ?\fItabid\fR?
-Selects the specified tab. The associated child pane will be displayed,
-and the previously-selected pane (if different) is unmapped.
+Selects the specified tab.
+The associated slave window will be displayed,
+and the previously-selected window (if different) is unmapped.
If \fItabid\fR is omitted, returns the widget name of the
currently selected pane.
.TP
\fIpathname \fBstate\fR ?\fIstatespec\fR?
See \fIttk::widget(n)\fR.
.TP
-\fIpathname \fBtab\fR \fItabid\fR ?\fI\-options \fR?\fIvalue ...\fR
+\fIpathname \fBtab\fR \fItabid\fR ?\fI\-option \fR?\fIvalue ...\fR
Query or modify the options of the specific tab.
-If no \fI\-option\fR is specified, returns a dictionary of the tab
-option values.
-If one \fI\-option\fR is specified, returns the value of that \fIoption\fR.
+If no \fI\-option\fR is specified,
+returns a dictionary of the tab 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.
See \fBTAB OPTIONS\fR for the available options.
.TP
\fIpathname \fBtabs\fR
-Returns a list of all windows managed by the widget.
-.\" Perhaps "panes" is a better name for this command?
+Returns the list of windows managed by the notebook.
.SH "KEYBOARD TRAVERSAL"
To enable keyboard traversal for a toplevel window
containing a notebook widget \fI$nb\fR, call:
@@ -140,7 +146,7 @@ containing a notebook widget \fI$nb\fR, call:
ttk::notebook::enableTraversal $nb
.CE
.PP
-This will extend the bindings for the toplevel widget
+This will extend the bindings for the toplevel window
containing the notebook as follows:
.IP \(bu
\fBControl-Tab\fR selects the tab following the currently selected one.
@@ -160,7 +166,7 @@ any of the following forms:
.IP \(bu
An integer between zero and the number of tabs;
.IP \(bu
-The name of a child pane window;
+The name of a slave window;
.IP \(bu
A positional specification of the form
.QW @\fIx\fR,\fIy\fR ,
diff --git a/generic/ttk/ttkFrame.c b/generic/ttk/ttkFrame.c
index 1c37065..b4cf916 100644
--- a/generic/ttk/ttkFrame.c
+++ b/generic/ttk/ttkFrame.c
@@ -1,4 +1,4 @@
-/* $Id: ttkFrame.c,v 1.5.2.3 2007/11/21 16:46:27 dgp Exp $
+/* $Id: ttkFrame.c,v 1.5.2.4 2007/11/25 19:19:21 dgp Exp $
* Copyright (c) 2004, Joe English
*
* ttk::frame and ttk::labelframe widgets.
@@ -482,6 +482,11 @@ static void LabelframePlaceSlaves(void *recordPtr)
}
}
+static int LabelRequest(void *managerData, int index, int width, int height)
+{
+ return 1;
+}
+
/* LabelRemoved --
* Unset the -labelwidget option.
*
@@ -489,17 +494,17 @@ static void LabelframePlaceSlaves(void *recordPtr)
* This routine is also called when the widget voluntarily forgets
* the slave in LabelframeConfigure.
*/
-static void LabelRemoved(Ttk_Manager *mgr, int slaveIndex)
+static void LabelRemoved(void *managerData, int slaveIndex)
{
- Labelframe *lframe = Ttk_ManagerData(mgr);
+ Labelframe *lframe = managerData;
lframe->label.labelWidget = 0;
}
-static Ttk_ManagerSpec LabelframeManagerSpec =
-{
+static Ttk_ManagerSpec LabelframeManagerSpec = {
{ "labelframe", Ttk_GeometryRequestProc, Ttk_LostSlaveProc },
LabelframeSize,
LabelframePlaceSlaves,
+ LabelRequest,
LabelRemoved
};
diff --git a/generic/ttk/ttkManager.c b/generic/ttk/ttkManager.c
index f83bf2a..b3ee977 100644
--- a/generic/ttk/ttkManager.c
+++ b/generic/ttk/ttkManager.c
@@ -1,4 +1,4 @@
-/* $Id: ttkManager.c,v 1.3.2.1 2007/06/12 16:22:40 dgp Exp $
+/* $Id: ttkManager.c,v 1.3.2.2 2007/11/25 19:19:21 dgp Exp $
*
* Copyright 2005, Joe English. Freely redistributable.
*
@@ -287,7 +287,7 @@ static void RemoveSlave(Ttk_Manager *mgr, int index)
/* Notify manager:
*/
- mgr->managerSpec->SlaveRemoved(mgr, index);
+ mgr->managerSpec->SlaveRemoved(mgr->managerData, index);
/* Remove from array:
*/
@@ -317,7 +317,15 @@ static void RemoveSlave(Ttk_Manager *mgr, int index)
void Ttk_GeometryRequestProc(ClientData clientData, Tk_Window slaveWindow)
{
Ttk_Manager *mgr = clientData;
- ScheduleUpdate(mgr, MGR_RESIZE_REQUIRED);
+ int slaveIndex = Ttk_SlaveIndex(mgr, slaveWindow);
+ int reqWidth = Tk_ReqWidth(slaveWindow);
+ int reqHeight= Tk_ReqHeight(slaveWindow);
+
+ if (mgr->managerSpec->SlaveRequest(
+ mgr->managerData, slaveIndex, reqWidth, reqHeight))
+ {
+ ScheduleUpdate(mgr, MGR_RESIZE_REQUIRED);
+ }
}
void Ttk_LostSlaveProc(ClientData clientData, Tk_Window slaveWindow)
@@ -404,10 +412,6 @@ int Ttk_NumberSlaves(Ttk_Manager *mgr)
{
return mgr->nSlaves;
}
-void *Ttk_ManagerData(Ttk_Manager *mgr)
-{
- return mgr->managerData;
-}
void *Ttk_SlaveData(Ttk_Manager *mgr, int slaveIndex)
{
return mgr->slaves[slaveIndex]->slaveData;
diff --git a/generic/ttk/ttkManager.h b/generic/ttk/ttkManager.h
index 777b940..58df8f0 100644
--- a/generic/ttk/ttkManager.h
+++ b/generic/ttk/ttkManager.h
@@ -1,4 +1,4 @@
-/* $Id: ttkManager.h,v 1.5.2.1 2007/06/12 16:22:41 dgp Exp $
+/* $Id: ttkManager.h,v 1.5.2.2 2007/11/25 19:19:21 dgp Exp $
*
* Copyright (c) 2005, Joe English. Freely redistributable.
*
@@ -23,13 +23,17 @@ typedef struct TtkManager_ Ttk_Manager;
* SlaveRemoved() is called immediately before a slave is removed.
* NB: the associated slave window may have been destroyed when this
* routine is called.
+ *
+ * SlaveRequest() is called when a slave requests a size change.
+ * It should return 1 if the request should propagate, 0 otherwise.
*/
typedef struct { /* Manager hooks */
Tk_GeomMgr tkGeomMgr; /* "real" Tk Geometry Manager */
int (*RequestedSize)(void *managerData, int *widthPtr, int *heightPtr);
void (*PlaceSlaves)(void *managerData);
- void (*SlaveRemoved)(Ttk_Manager *, int slaveIndex);
+ int (*SlaveRequest)(void *managerData, int slaveIndex, int w, int h);
+ void (*SlaveRemoved)(void *managerData, int slaveIndex);
} Ttk_ManagerSpec;
/*
diff --git a/generic/ttk/ttkNotebook.c b/generic/ttk/ttkNotebook.c
index e1285af..f08aedd 100644
--- a/generic/ttk/ttkNotebook.c
+++ b/generic/ttk/ttkNotebook.c
@@ -1,8 +1,5 @@
-/* $Id: ttkNotebook.c,v 1.8.2.2 2007/10/27 04:23:16 dgp Exp $
+/* $Id: ttkNotebook.c,v 1.8.2.3 2007/11/25 19:19:21 dgp Exp $
* Copyright (c) 2004, Joe English
- *
- * NOTE-ACTIVE: activeTabIndex is not always correct (it's
- * more trouble than it's worth to track this 100%)
*/
#include <string.h>
@@ -645,35 +642,36 @@ static int NextTab(Notebook *nb, int index)
/* SelectNearestTab --
* Handles the case where the current tab is forgotten, hidden,
- * or destroyed. Select the next available tab; or, if there is none,
- * leaves all tabs unselected.
+ * or destroyed.
+ *
+ * Unmap the current tab and schedule the next available one
+ * to be mapped at the next GM update.
*/
static void SelectNearestTab(Notebook *nb)
{
- int nextIndex = NextTab(nb, nb->notebook.currentIndex);
+ int currentIndex = nb->notebook.currentIndex;
+ int nextIndex = NextTab(nb, currentIndex);
- if (nextIndex >= 0) {
- SelectTab(nb, nextIndex);
- } else {
- /* No available tabs -- unmap current one.
- * ASSERT: this is safe to do even when the slave is being destroyed.
- */
- if (nb->notebook.currentIndex >= 0) {
- Ttk_UnmapSlave(nb->notebook.mgr, nb->notebook.currentIndex);
- TtkSendVirtualEvent(nb->core.tkwin, "NotebookTabChanged");
- }
- nb->notebook.currentIndex = -1;
+ if (currentIndex >= 0) {
+ Ttk_UnmapSlave(nb->notebook.mgr, currentIndex);
+ }
+ if (currentIndex != nextIndex) {
+ TtkSendVirtualEvent(nb->core.tkwin, "NotebookTabChanged");
}
+
+ nb->notebook.currentIndex = nextIndex;
+ Ttk_ManagerLayoutChanged(nb->notebook.mgr);
+ TtkRedisplayWidget(&nb->core);
}
/* TabRemoved -- GM SlaveRemoved hook.
* Select the next tab if the current one is being removed.
* Adjust currentIndex to account for removed slave.
*/
-static void TabRemoved(Ttk_Manager *mgr, int index)
+static void TabRemoved(void *managerData, int index)
{
- Notebook *nb = Ttk_ManagerData(mgr);
- Tab *tab = Ttk_SlaveData(mgr, index);
+ Notebook *nb = managerData;
+ Tab *tab = Ttk_SlaveData(nb->notebook.mgr, index);
if (index == nb->notebook.currentIndex) {
SelectNearestTab(nb);
@@ -688,6 +686,11 @@ static void TabRemoved(Ttk_Manager *mgr, int index)
TtkRedisplayWidget(&nb->core);
}
+static int TabRequest(void *managerData, int index, int width, int height)
+{
+ return 1;
+}
+
/* AddTab --
* Add new tab at specified index.
*/
@@ -700,12 +703,14 @@ static int AddTab(
if (!Ttk_Maintainable(interp, slaveWindow, nb->core.tkwin)) {
return TCL_ERROR;
}
+#if 0 /* can't happen */
if (Ttk_SlaveIndex(nb->notebook.mgr, slaveWindow) >= 0) {
Tcl_AppendResult(interp,
Tk_PathName(slaveWindow), " already added",
NULL);
return TCL_ERROR;
}
+#endif
/* Create and insert tab.
*/
@@ -731,12 +736,12 @@ static int AddTab(
return TCL_OK;
}
-static Ttk_ManagerSpec NotebookManagerSpec =
-{
+static Ttk_ManagerSpec NotebookManagerSpec = {
{ "notebook", Ttk_GeometryRequestProc, Ttk_LostSlaveProc },
NotebookSize,
NotebookPlaceSlaves,
- TabRemoved,
+ TabRequest,
+ TabRemoved
};
/*------------------------------------------------------------------------
@@ -853,6 +858,8 @@ static int NotebookAddCommand(
Notebook *nb = recordPtr;
int index = Ttk_NumberSlaves(nb->notebook.mgr);
Tk_Window slaveWindow;
+ int slaveIndex;
+ Tab *tab;
if (objc <= 2 || objc % 2 != 1) {
Tcl_WrongNumArgs(interp, 2, objv, "window ?options...?");
@@ -863,14 +870,21 @@ static int NotebookAddCommand(
if (!slaveWindow) {
return TCL_ERROR;
}
+ slaveIndex = Ttk_SlaveIndex(nb->notebook.mgr, slaveWindow);
- /* Create and initialize new tab:
- */
- if (AddTab(interp, nb, index, slaveWindow, objc-3,objv+3) != TCL_OK) {
+ if (slaveIndex < 0) { /* New tab */
+ return AddTab(interp, nb, index, slaveWindow, objc-3,objv+3);
+ }
+
+ tab = Ttk_SlaveData(nb->notebook.mgr, slaveIndex);
+ if (tab->state == TAB_STATE_HIDDEN) {
+ tab->state = TAB_STATE_NORMAL;
+ }
+ if (ConfigureTab(interp, nb, tab, slaveWindow, objc-4,objv+4) != TCL_OK) {
return TCL_ERROR;
}
- TtkResizeWidget(&nb->core);
+ TtkRedisplayWidget(&nb->core);
return TCL_OK;
}
@@ -949,8 +963,8 @@ static int NotebookInsertCommand(
return TCL_OK;
}
-/* $nb forget $item --
- * Removes the selected tab.
+/* $nb forget $tab --
+ * Removes the specified tab.
*/
static int NotebookForgetCommand(
Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[], void *recordPtr)
@@ -972,6 +986,34 @@ static int NotebookForgetCommand(
return TCL_OK;
}
+/* $nb hide $tab --
+ * Hides the specified tab.
+ */
+static int NotebookHideCommand(
+ Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[], void *recordPtr)
+{
+ Notebook *nb = recordPtr;
+ int index;
+ Tab *tab;
+
+ if (objc != 3) {
+ Tcl_WrongNumArgs(interp, 2, objv, "tab");
+ return TCL_ERROR;
+ }
+
+ if (GetTabIndex(interp, nb, objv[2], &index) != TCL_OK) {
+ return TCL_ERROR;
+ }
+
+ tab = Ttk_SlaveData(nb->notebook.mgr, index);
+ tab->state = TAB_STATE_HIDDEN;
+ if (index == nb->notebook.currentIndex) {
+ SelectNearestTab(nb);
+ }
+
+ return TCL_OK;
+}
+
/* $nb identify $x $y --
* Returns name of tab element at $x,$y; empty string if none.
*/
@@ -1153,6 +1195,7 @@ static WidgetCommandSpec NotebookCommands[] =
{ "configure", TtkWidgetConfigureCommand },
{ "cget", TtkWidgetCgetCommand },
{ "forget", NotebookForgetCommand },
+ { "hide", NotebookHideCommand },
{ "identify", NotebookIdentifyCommand },
{ "index", NotebookIndexCommand },
{ "insert", NotebookInsertCommand },
diff --git a/generic/ttk/ttkPanedwindow.c b/generic/ttk/ttkPanedwindow.c
index 7a613aa..819b210 100644
--- a/generic/ttk/ttkPanedwindow.c
+++ b/generic/ttk/ttkPanedwindow.c
@@ -1,4 +1,4 @@
-/* $Id: ttkPanedwindow.c,v 1.9.2.1 2007/06/12 16:22:41 dgp Exp $
+/* $Id: ttkPanedwindow.c,v 1.9.2.2 2007/11/25 19:19:21 dgp Exp $
*
* Copyright (c) 2005, Joe English. Freely redistributable.
*
@@ -404,10 +404,10 @@ static void PanedPlaceSlaves(void *managerData)
PlacePanes(pw);
}
-static void PaneRemoved(Ttk_Manager *mgr, int index)
+static void PaneRemoved(void *managerData, int index)
{
- Paned *pw = Ttk_ManagerData(mgr);
- Pane *pane = Ttk_SlaveData(mgr, index);
+ Paned *pw = managerData;
+ Pane *pane = Ttk_SlaveData(pw->paned.mgr, index);
DestroyPane(pw, pane);
}
@@ -440,35 +440,30 @@ static int AddPane(
return TCL_OK;
}
-/* PanedGeometryRequestProc --
- * Update pane request size, but only if slave is currently unmapped.
- * Geometry requests from mapped slaves are not directly honored,
+/* PaneRequest --
+ * Only update pane request size if slave is currently unmapped.
+ * Geometry requests from mapped slaves are not directly honored
* in order to avoid unexpected pane resizes (esp. while the
* user is dragging a sash [#1325286]).
*/
-static void PanedGeometryRequestProc(
- ClientData clientData, Tk_Window slaveWindow)
+static int PaneRequest(void *managerData, int index, int width, int height)
{
- Ttk_Manager *mgr = clientData;
- Paned *pw = Ttk_ManagerData(mgr);
+ Paned *pw = managerData;
+ Pane *pane = Ttk_SlaveData(pw->paned.mgr, index);
+ Tk_Window slaveWindow = Ttk_SlaveWindow(pw->paned.mgr, index);
+ int horizontal = pw->paned.orient == TTK_ORIENT_HORIZONTAL;
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);
+ pane->reqSize = horizontal ? width : height;
}
-
- /* Continue with default GeometryRequestProc:
- */
- Ttk_GeometryRequestProc(clientData, slaveWindow);
+ return 1;
}
static Ttk_ManagerSpec PanedManagerSpec = {
- { "panedwindow", PanedGeometryRequestProc, Ttk_LostSlaveProc },
+ { "panedwindow", Ttk_GeometryRequestProc, Ttk_LostSlaveProc },
PanedSize,
PanedPlaceSlaves,
+ PaneRequest,
PaneRemoved
};
diff --git a/tests/ttk/notebook.test b/tests/ttk/notebook.test
index de286f9..93b555e 100644
--- a/tests/ttk/notebook.test
+++ b/tests/ttk/notebook.test
@@ -1,5 +1,5 @@
#
-# $Id: notebook.test,v 1.1.2.2 2007/10/27 04:23:17 dgp Exp $
+# $Id: notebook.test,v 1.1.2.3 2007/11/25 19:19:22 dgp Exp $
#
package require Tk 8.5
@@ -158,9 +158,10 @@ test notebook-6.1 "Hide selected tab" -setup {
} -body {
set result [list]
lappend result [$nb index current] [winfo ismapped $nb.f2]
- $nb tab $nb.f2 -state hidden
+ $nb hide $nb.f2
lappend result [$nb index current] [winfo ismapped $nb.f2]
-} -result [list 1 1 2 0]
+ update idletasks; lappend result [winfo ismapped $nb.f3]
+} -result [list 1 1 2 0 1]
# See 1370833
test notebook-6.2 "Forget selected tab" -setup {
@@ -188,7 +189,7 @@ test notebook-6.3 "Hide first tab when it's the current" -setup {
} -body {
set result [list]
lappend result [$nb index current] [winfo ismapped $nb.f1]
- $nb tab $nb.f1 -state hidden
+ $nb hide $nb.f1
lappend result [$nb index current] [winfo ismapped $nb.f1]
} -result [list 0 1 1 0]
@@ -218,7 +219,7 @@ test notebook-6.5 "Hide last tab when it's the current" -setup {
} -body {
set result [list]
lappend result [$nb index current] [winfo ismapped $nb.f3]
- $nb tab $nb.f3 -state hidden
+ $nb hide $nb.f3
lappend result [$nb index current] [winfo ismapped $nb.f3]
} -result [list 2 1 1 0]
@@ -248,7 +249,7 @@ test notebook-6.7 "Hide a middle tab when it's the current" -setup {
} -body {
set result [list]
lappend result [$nb index current] [winfo ismapped $nb.f2]
- $nb tab $nb.f2 -state hidden
+ $nb hide $nb.f2
lappend result [$nb index current] [winfo ismapped $nb.f2]
} -result [list 1 1 2 0]
@@ -278,7 +279,7 @@ test notebook-6.9 "Hide a non-current tab < current" -setup {
} -body {
set result [list]
lappend result [$nb index current] [winfo ismapped $nb.f2]
- $nb tab $nb.f1 -state hidden
+ $nb hide $nb.f1
lappend result [$nb index current] [winfo ismapped $nb.f2]
} -result [list 1 1 1 1]
@@ -308,10 +309,27 @@ test notebook-6.11 "Hide a non-current tab > current" -setup {
} -body {
set result [list]
lappend result [$nb index current] [winfo ismapped $nb.f2]
- $nb tab $nb.f3 -state hidden
+ $nb hide $nb.f3
lappend result [$nb index current] [winfo ismapped $nb.f2]
} -result [list 1 1 1 1]
+test notebook-6.12 "Hide and re-add a tab" -setup {
+ pack [set nb [ttk::notebook .nb]]; update
+ $nb add [ttk::frame $nb.f1]
+ $nb add [ttk::frame $nb.f2]
+ $nb add [ttk::frame $nb.f3]
+ $nb select $nb.f2
+} -cleanup {
+ destroy $nb
+} -body {
+ set result [list]
+ lappend result [$nb index current] [$nb tab $nb.f2 -state]
+ $nb hide $nb.f2
+ lappend result [$nb index current] [$nb tab $nb.f2 -state]
+ $nb add $nb.f2
+ lappend result [$nb index current] [$nb tab $nb.f2 -state]
+} -result [list 1 normal 2 hidden 2 normal]
+
#
# Insert:
#
@@ -454,4 +472,26 @@ test notebook-1817596-3 "insert/configure" -body {
} -result [list [list .nb.l2 .nb.l0 .nb.l1] L2 L0 L1] -cleanup { destroy .nb }
+
+# See #1343984
+test notebook-1343984-1 "don't autoselect on destroy - setup" -body {
+ ttk::notebook .nb
+ set ::history [list]
+ bind TestFrame <Map> { lappend history MAP %W }
+ bind TestFrame <Destroy> { lappend history DESTROY %W }
+ .nb add [ttk::frame .nb.frame1 -class TestFrame] -text "Frame 1"
+ .nb add [ttk::frame .nb.frame2 -class TestFrame] -text "Frame 2"
+ .nb add [ttk::frame .nb.frame3 -class TestFrame] -text "Frame 3"
+ pack .nb -fill both -expand 1
+ update
+ set ::history
+} -result [list MAP .nb.frame1]
+
+test notebook-1343984-2 "don't autoselect on destroy" -body {
+ set ::history [list]
+ destroy .nb
+ update
+ set ::history
+} -result [list DESTROY .nb.frame1 DESTROY .nb.frame2 DESTROY .nb.frame3]
+
tcltest::cleanupTests
diff --git a/tests/ttk/panedwindow.test b/tests/ttk/panedwindow.test
index c5c509f..68cbfe4 100644
--- a/tests/ttk/panedwindow.test
+++ b/tests/ttk/panedwindow.test
@@ -1,11 +1,12 @@
#
-# $Id: panedwindow.test,v 1.2.2.1 2007/06/12 16:22:43 dgp Exp $
+# $Id: panedwindow.test,v 1.2.2.2 2007/11/25 19:19:22 dgp Exp $
#
package require Tk 8.5
package require tcltest ; namespace import -force tcltest::*
loadTestedCommands
+proc propagate-geometry {} { update idletasks }
# Basic sanity checks:
#
@@ -220,7 +221,7 @@ test paned-sashpos-setup "Setup for sash position test" -body {
.pw add [frame .pw.f3 -width 20 -height 20]
.pw add [frame .pw.f4 -width 20 -height 20]
- update idletasks
+ propagate-geometry
list [winfo reqwidth .pw] [winfo reqheight .pw]
} -result [list 20 [expr {20*4 + 5*3}]]
@@ -246,4 +247,49 @@ test paned-sashpos-restore "Set height then sash positions" -body {
test paned-sashpos-cleanup "Clean up" -body { destroy .pw }
+test paned-propagation-setup "Setup." -body {
+ ttk::style theme use default
+ ttk::style configure -sashthickness 5
+ wm geometry . {}
+ ttk::panedwindow .pw -orient vertical
+
+ frame .pw.f1 -width 100 -height 50
+ frame .pw.f2 -width 100 -height 50
+
+ list [winfo reqwidth .pw.f1] [winfo reqheight .pw.f1]
+} -result [list 100 50]
+
+test paned-propagation-1 "Initial request size" -body {
+ .pw add .pw.f1
+ .pw add .pw.f2
+ propagate-geometry
+ list [winfo reqwidth .pw] [winfo reqheight .pw]
+} -result [list 100 105]
+
+test paned-propagation-2 "Slave change before map" -body {
+ .pw.f1 configure -width 200 -height 100
+ propagate-geometry
+ list [winfo reqwidth .pw] [winfo reqheight .pw]
+} -result [list 200 155]
+
+test paned-propagation-3 "Map window" -body {
+ pack .pw -expand true -fill both
+ update
+ list [winfo width .pw] [winfo height .pw] [.pw sashpos 0]
+} -result [list 200 155 100]
+
+test paned-propagation-4 "Slave change after map, off-axis" -body {
+ .pw.f1 configure -width 100 ;# should be granted
+ propagate-geometry
+ list [winfo reqwidth .pw] [winfo reqheight .pw] [.pw sashpos 0]
+} -result [list 100 155 100]
+
+test paned-propagation-5 "Slave change after map, on-axis" -body {
+ .pw.f1 configure -height 50 ;# should be denied
+ propagate-geometry
+ list [winfo reqwidth .pw] [winfo reqheight .pw] [.pw sashpos 0]
+} -result [list 100 155 100]
+
+test paned-propagation-cleanup "Clean up." -body { destroy .pw }
+
tcltest::cleanupTests
diff --git a/tests/ttk/ttk.test b/tests/ttk/ttk.test
index cd3291b..fab6c2c 100644
--- a/tests/ttk/ttk.test
+++ b/tests/ttk/ttk.test
@@ -589,13 +589,13 @@ test ttk-14.3 "-textvariable in nonexistant namespace" -body {
test ttk-15.1 "style element create: insufficient args" -body {
ttk::style element create
-} -returnCodes 1 -match glob -result "wrong # args:*"
+} -returnCodes 1 -result "wrong # args: should be \"ttk::style element create name type ?options...?\""
test ttk-15.2 "style element create: insufficient args" -body {
ttk::style element create plain.background
-} -returnCodes 1 -match glob -result "wrong # args:*"
+} -returnCodes 1 -result "wrong # args: should be \"ttk::style element create name type ?options...?\""
test ttk-15.3 "style element create: insufficient args" -body {
ttk::style element create plain.background from
-} -returnCodes 1 -match glob -result "wrong # args:*"
+} -returnCodes 1 -result "wrong # args: should be \"theme ?element?\""
test ttk-15.4 "style element create: valid" -body {
ttk::style element create plain.background from default
} -returnCodes 0 -result ""