diff options
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | generic/ttk/ttkButton.c | 89 | ||||
-rw-r--r-- | generic/ttk/ttkEntry.c | 151 | ||||
-rw-r--r-- | generic/ttk/ttkFrame.c | 16 | ||||
-rw-r--r-- | generic/ttk/ttkNotebook.c | 51 | ||||
-rw-r--r-- | generic/ttk/ttkPanedwindow.c | 43 | ||||
-rw-r--r-- | generic/ttk/ttkProgress.c | 29 | ||||
-rw-r--r-- | generic/ttk/ttkScale.c | 29 | ||||
-rw-r--r-- | generic/ttk/ttkScrollbar.c | 33 | ||||
-rw-r--r-- | generic/ttk/ttkSeparator.c | 32 | ||||
-rw-r--r-- | generic/ttk/ttkSquare.c | 17 | ||||
-rw-r--r-- | generic/ttk/ttkTheme.c | 32 | ||||
-rw-r--r-- | generic/ttk/ttkTheme.h | 18 | ||||
-rw-r--r-- | generic/ttk/ttkTreeview.c | 130 | ||||
-rw-r--r-- | generic/ttk/ttkWidget.c | 40 | ||||
-rw-r--r-- | generic/ttk/ttkWidget.h | 28 | ||||
-rw-r--r-- | tests/ttk/ttk.test | 43 |
17 files changed, 384 insertions, 404 deletions
@@ -1,3 +1,10 @@ +2010-01-31 Joe English <jenglish@users.sourceforge.net> + + * generic/ttk/ttkTheme.h, generic/ttk/ttkWidget.h, + generic/ttk/*.c: Change signature of widget subcommand + procedures to match Tcl_ObjCmdProc. Merge now-redundant + ensemble dispatch code. + 2010-01-29 Jan Nijtmans <nijtmans@users.sf.net> * generic/ttk/ttkGenStubs.tcl: No longer generate a space after "*" and diff --git a/generic/ttk/ttkButton.c b/generic/ttk/ttkButton.c index 1b199be..30818b1 100644 --- a/generic/ttk/ttkButton.c +++ b/generic/ttk/ttkButton.c @@ -1,4 +1,4 @@ -/* $Id: ttkButton.c,v 1.11 2008/11/13 01:13:54 jenglish Exp $ +/* $Id: ttkButton.c,v 1.12 2010/01/31 22:50:55 jenglish Exp $ * Copyright (c) 2003, Joe English * * label, button, checkbutton, radiobutton, and menubutton widgets. @@ -247,14 +247,13 @@ static Tk_OptionSpec LabelOptionSpecs[] = WIDGET_INHERIT_OPTIONS(BaseOptionSpecs) }; -static WidgetCommandSpec LabelCommands[] = -{ - { "configure", TtkWidgetConfigureCommand }, - { "cget", TtkWidgetCgetCommand }, - { "instate", TtkWidgetInstateCommand }, - { "state", TtkWidgetStateCommand }, - { "identify", TtkWidgetIdentifyCommand }, - { NULL, NULL } +static const Ttk_Ensemble LabelCommands[] = { + { "configure", TtkWidgetConfigureCommand,0 }, + { "cget", TtkWidgetCgetCommand,0 }, + { "instate", TtkWidgetInstateCommand,0 }, + { "state", TtkWidgetStateCommand,0 }, + { "identify", TtkWidgetIdentifyCommand,0 }, + { 0,0,0 } }; static WidgetSpec LabelWidgetSpec = @@ -341,7 +340,7 @@ static int ButtonConfigure(Tcl_Interp *interp, void *recordPtr, int mask) */ static int ButtonInvokeCommand( - Tcl_Interp *interp, int objc, Tcl_Obj *const objv[], void *recordPtr) + void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { Button *buttonPtr = recordPtr; if (objc > 2) { @@ -354,15 +353,14 @@ ButtonInvokeCommand( return Tcl_EvalObjEx(interp, buttonPtr->button.commandObj, TCL_EVAL_GLOBAL); } -static WidgetCommandSpec ButtonCommands[] = -{ - { "configure", TtkWidgetConfigureCommand }, - { "cget", TtkWidgetCgetCommand }, - { "invoke", ButtonInvokeCommand }, - { "instate", TtkWidgetInstateCommand }, - { "state", TtkWidgetStateCommand }, - { "identify", TtkWidgetIdentifyCommand }, - { NULL, NULL } +static const Ttk_Ensemble ButtonCommands[] = { + { "configure", TtkWidgetConfigureCommand,0 }, + { "cget", TtkWidgetCgetCommand,0 }, + { "invoke", ButtonInvokeCommand,0 }, + { "instate", TtkWidgetInstateCommand,0 }, + { "state", TtkWidgetStateCommand,0 }, + { "identify", TtkWidgetIdentifyCommand,0 }, + { 0,0,0 } }; static WidgetSpec ButtonWidgetSpec = @@ -521,7 +519,7 @@ CheckbuttonPostConfigure(Tcl_Interp *interp, void *recordPtr, int mask) */ static int CheckbuttonInvokeCommand( - Tcl_Interp *interp, int objc, Tcl_Obj *const objv[], void *recordPtr) + void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { Checkbutton *checkPtr = recordPtr; WidgetCore *corePtr = &checkPtr->core; @@ -555,16 +553,15 @@ CheckbuttonInvokeCommand( checkPtr->checkbutton.commandObj, TCL_EVAL_GLOBAL); } -static WidgetCommandSpec CheckbuttonCommands[] = -{ - { "configure", TtkWidgetConfigureCommand }, - { "cget", TtkWidgetCgetCommand }, - { "invoke", CheckbuttonInvokeCommand }, - { "instate", TtkWidgetInstateCommand }, - { "state", TtkWidgetStateCommand }, - { "identify", TtkWidgetIdentifyCommand }, +static const Ttk_Ensemble CheckbuttonCommands[] = { + { "configure", TtkWidgetConfigureCommand,0 }, + { "cget", TtkWidgetCgetCommand,0 }, + { "invoke", CheckbuttonInvokeCommand,0 }, + { "instate", TtkWidgetInstateCommand,0 }, + { "state", TtkWidgetStateCommand,0 }, + { "identify", TtkWidgetIdentifyCommand,0 }, /* MISSING: select, deselect, toggle */ - { NULL, NULL } + { 0,0,0 } }; static WidgetSpec CheckbuttonWidgetSpec = @@ -707,7 +704,7 @@ RadiobuttonPostConfigure(Tcl_Interp *interp, void *recordPtr, int mask) */ static int RadiobuttonInvokeCommand( - Tcl_Interp *interp, int objc, Tcl_Obj *const objv[], void *recordPtr) + void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { Radiobutton *radioPtr = recordPtr; WidgetCore *corePtr = &radioPtr->core; @@ -733,16 +730,15 @@ RadiobuttonInvokeCommand( radioPtr->radiobutton.commandObj, TCL_EVAL_GLOBAL); } -static WidgetCommandSpec RadiobuttonCommands[] = -{ - { "configure", TtkWidgetConfigureCommand }, - { "cget", TtkWidgetCgetCommand }, - { "invoke", RadiobuttonInvokeCommand }, - { "instate", TtkWidgetInstateCommand }, - { "state", TtkWidgetStateCommand }, - { "identify", TtkWidgetIdentifyCommand }, +static const Ttk_Ensemble RadiobuttonCommands[] = { + { "configure", TtkWidgetConfigureCommand,0 }, + { "cget", TtkWidgetCgetCommand,0 }, + { "invoke", RadiobuttonInvokeCommand,0 }, + { "instate", TtkWidgetInstateCommand,0 }, + { "state", TtkWidgetStateCommand,0 }, + { "identify", TtkWidgetIdentifyCommand,0 }, /* MISSING: select, deselect */ - { NULL, NULL } + { 0,0,0 } }; static WidgetSpec RadiobuttonWidgetSpec = @@ -804,14 +800,13 @@ static Tk_OptionSpec MenubuttonOptionSpecs[] = WIDGET_INHERIT_OPTIONS(BaseOptionSpecs) }; -static WidgetCommandSpec MenubuttonCommands[] = -{ - { "configure", TtkWidgetConfigureCommand }, - { "cget", TtkWidgetCgetCommand }, - { "instate", TtkWidgetInstateCommand }, - { "state", TtkWidgetStateCommand }, - { "identify", TtkWidgetIdentifyCommand }, - { NULL, NULL } +static const Ttk_Ensemble MenubuttonCommands[] = { + { "configure", TtkWidgetConfigureCommand,0 }, + { "cget", TtkWidgetCgetCommand,0 }, + { "instate", TtkWidgetInstateCommand,0 }, + { "state", TtkWidgetStateCommand,0 }, + { "identify", TtkWidgetIdentifyCommand,0 }, + { 0,0,0 } }; static WidgetSpec MenubuttonWidgetSpec = diff --git a/generic/ttk/ttkEntry.c b/generic/ttk/ttkEntry.c index 8656e5b..18591b6 100644 --- a/generic/ttk/ttkEntry.c +++ b/generic/ttk/ttkEntry.c @@ -1,5 +1,5 @@ /* - * $Id: ttkEntry.c,v 1.18 2010/01/22 14:17:53 nijtmans Exp $ + * $Id: ttkEntry.c,v 1.19 2010/01/31 22:50:55 jenglish Exp $ * * DERIVED FROM: tk/generic/tkEntry.c r1.35. * @@ -1360,7 +1360,7 @@ badIndex: */ static int EntryBBoxCommand( - Tcl_Interp *interp, int objc, Tcl_Obj *const objv[], void *recordPtr) + void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { Entry *entryPtr = recordPtr; Ttk_Box b; @@ -1390,7 +1390,7 @@ EntryBBoxCommand( */ static int EntryDeleteCommand( - Tcl_Interp *interp, int objc, Tcl_Obj *const objv[], void *recordPtr) + void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { Entry *entryPtr = recordPtr; int first, last; @@ -1419,7 +1419,7 @@ EntryDeleteCommand( */ static int EntryGetCommand( - Tcl_Interp *interp, int objc, Tcl_Obj *const objv[], void *recordPtr) + void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { Entry *entryPtr = recordPtr; if (objc != 2) { @@ -1435,7 +1435,7 @@ EntryGetCommand( */ static int EntryICursorCommand( - Tcl_Interp *interp, int objc, Tcl_Obj *const objv[], void *recordPtr) + void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { Entry *entryPtr = recordPtr; if (objc != 3) { @@ -1455,7 +1455,7 @@ EntryICursorCommand( */ static int EntryIndexCommand( - Tcl_Interp *interp, int objc, Tcl_Obj *const objv[], void *recordPtr) + void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { Entry *entryPtr = recordPtr; int index; @@ -1477,7 +1477,7 @@ EntryIndexCommand( */ static int EntryInsertCommand( - Tcl_Interp *interp, int objc, Tcl_Obj *const objv[], void *recordPtr) + void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { Entry *entryPtr = recordPtr; int index; @@ -1495,11 +1495,11 @@ EntryInsertCommand( return TCL_OK; } -/* selection clear -- +/* $entry selection clear -- * Clear selection. */ static int EntrySelectionClearCommand( - Tcl_Interp *interp, int objc, Tcl_Obj *const objv[], void *recordPtr) + void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { Entry *entryPtr = recordPtr; @@ -1516,7 +1516,7 @@ static int EntrySelectionClearCommand( * Returns 1 if any characters are selected, 0 otherwise. */ static int EntrySelectionPresentCommand( - Tcl_Interp *interp, int objc, Tcl_Obj *const objv[], void *recordPtr) + void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { Entry *entryPtr = recordPtr; if (objc != 3) { @@ -1532,7 +1532,7 @@ static int EntrySelectionPresentCommand( * Explicitly set the selection range. */ static int EntrySelectionRangeCommand( - Tcl_Interp *interp, int objc, Tcl_Obj *const objv[], void *recordPtr) + void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { Entry *entryPtr = recordPtr; int start, end; @@ -1559,27 +1559,18 @@ static int EntrySelectionRangeCommand( return TCL_OK; } -/* $entry selection $command ?arg arg...? - * Ensemble, see above. - */ -static int EntrySelectionCommand( - Tcl_Interp *interp, int objc, Tcl_Obj *const objv[], void *recordPtr) -{ - static WidgetCommandSpec EntrySelectionCommands[] = { - { "clear", EntrySelectionClearCommand }, - { "present", EntrySelectionPresentCommand }, - { "range", EntrySelectionRangeCommand }, - {0,0} - }; - return TtkWidgetEnsembleCommand( - EntrySelectionCommands, 2, interp, objc, objv, recordPtr); -} +static const Ttk_Ensemble EntrySelectionCommands[] = { + { "clear", EntrySelectionClearCommand,0 }, + { "present", EntrySelectionPresentCommand,0 }, + { "range", EntrySelectionRangeCommand,0 }, + { 0,0,0 } +}; /* $entry set $value * Sets the value of an entry widget. */ static int EntrySetCommand( - Tcl_Interp *interp, int objc, Tcl_Obj *const objv[], void *recordPtr) + void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { Entry *entryPtr = recordPtr; if (objc != 3) { @@ -1595,7 +1586,7 @@ static int EntrySetCommand( * or error status from -validatecommand / -invalidcommand. */ static int EntryValidateCommand( - Tcl_Interp *interp, int objc, Tcl_Obj *const objv[], void *recordPtr) + void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { Entry *entryPtr = recordPtr; int code; @@ -1617,28 +1608,28 @@ static int EntryValidateCommand( /* $entry xview -- horizontal scrolling interface */ static int EntryXViewCommand( - Tcl_Interp *interp, int objc, Tcl_Obj *const objv[], void *recordPtr) + void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { Entry *entryPtr = recordPtr; return TtkScrollviewCommand(interp, objc, objv, entryPtr->entry.xscrollHandle); } -static WidgetCommandSpec EntryCommands[] = { - { "bbox", EntryBBoxCommand }, - { "cget", TtkWidgetCgetCommand }, - { "configure", TtkWidgetConfigureCommand }, - { "delete", EntryDeleteCommand }, - { "get", EntryGetCommand }, - { "icursor", EntryICursorCommand }, - { "identify", TtkWidgetIdentifyCommand }, - { "index", EntryIndexCommand }, - { "insert", EntryInsertCommand }, - { "instate", TtkWidgetInstateCommand }, - { "selection", EntrySelectionCommand }, - { "state", TtkWidgetStateCommand }, - { "validate", EntryValidateCommand }, - { "xview", EntryXViewCommand }, - {0,0} +static const Ttk_Ensemble EntryCommands[] = { + { "bbox", EntryBBoxCommand,0 }, + { "cget", TtkWidgetCgetCommand,0 }, + { "configure", TtkWidgetConfigureCommand,0 }, + { "delete", EntryDeleteCommand,0 }, + { "get", EntryGetCommand,0 }, + { "icursor", EntryICursorCommand,0 }, + { "identify", TtkWidgetIdentifyCommand,0 }, + { "index", EntryIndexCommand,0 }, + { "insert", EntryInsertCommand,0 }, + { "instate", TtkWidgetInstateCommand,0 }, + { "selection", 0,EntrySelectionCommands }, + { "state", TtkWidgetStateCommand,0 }, + { "validate", EntryValidateCommand,0 }, + { "xview", EntryXViewCommand,0 }, + { 0,0,0 } }; /*------------------------------------------------------------------------ @@ -1727,7 +1718,7 @@ ComboboxConfigure(Tcl_Interp *interp, void *recordPtr, int mask) * in sync at all times, [$cb current] double-checks */ static int ComboboxCurrentCommand( - Tcl_Interp *interp, int objc, Tcl_Obj *const objv[], void *recordPtr) + void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { Combobox *cbPtr = recordPtr; int currentIndex = cbPtr->combobox.currentIndex; @@ -1784,23 +1775,23 @@ static int ComboboxCurrentCommand( /*------------------------------------------------------------------------ * +++ Combobox widget definition. */ -static WidgetCommandSpec ComboboxCommands[] = { - { "bbox", EntryBBoxCommand }, - { "cget", TtkWidgetCgetCommand }, - { "configure", TtkWidgetConfigureCommand }, - { "current", ComboboxCurrentCommand }, - { "delete", EntryDeleteCommand }, - { "get", EntryGetCommand }, - { "icursor", EntryICursorCommand }, - { "identify", TtkWidgetIdentifyCommand }, - { "index", EntryIndexCommand }, - { "insert", EntryInsertCommand }, - { "instate", TtkWidgetInstateCommand }, - { "selection", EntrySelectionCommand }, - { "state", TtkWidgetStateCommand }, - { "set", EntrySetCommand }, - { "xview", EntryXViewCommand }, - {0,0} +static const Ttk_Ensemble ComboboxCommands[] = { + { "bbox", EntryBBoxCommand,0 }, + { "cget", TtkWidgetCgetCommand,0 }, + { "configure", TtkWidgetConfigureCommand,0 }, + { "current", ComboboxCurrentCommand,0 }, + { "delete", EntryDeleteCommand,0 }, + { "get", EntryGetCommand,0 }, + { "icursor", EntryICursorCommand,0 }, + { "identify", TtkWidgetIdentifyCommand,0 }, + { "index", EntryIndexCommand,0 }, + { "insert", EntryInsertCommand,0 }, + { "instate", TtkWidgetInstateCommand,0 }, + { "selection", 0,EntrySelectionCommands }, + { "state", TtkWidgetStateCommand,0 }, + { "set", EntrySetCommand,0 }, + { "xview", EntryXViewCommand,0 }, + { 0,0,0 } }; static WidgetSpec ComboboxWidgetSpec = { @@ -1896,23 +1887,23 @@ SpinboxConfigure(Tcl_Interp *interp, void *recordPtr, int mask) return EntryConfigure(interp, recordPtr, mask); } -static WidgetCommandSpec SpinboxCommands[] = { - { "bbox", EntryBBoxCommand }, - { "cget", TtkWidgetCgetCommand }, - { "configure", TtkWidgetConfigureCommand }, - { "delete", EntryDeleteCommand }, - { "get", EntryGetCommand }, - { "icursor", EntryICursorCommand }, - { "identify", TtkWidgetIdentifyCommand }, - { "index", EntryIndexCommand }, - { "insert", EntryInsertCommand }, - { "instate", TtkWidgetInstateCommand }, - { "selection", EntrySelectionCommand }, - { "state", TtkWidgetStateCommand }, - { "set", EntrySetCommand }, - { "validate", EntryValidateCommand }, - { "xview", EntryXViewCommand }, - {0,0} +static const Ttk_Ensemble SpinboxCommands[] = { + { "bbox", EntryBBoxCommand,0 }, + { "cget", TtkWidgetCgetCommand,0 }, + { "configure", TtkWidgetConfigureCommand,0 }, + { "delete", EntryDeleteCommand,0 }, + { "get", EntryGetCommand,0 }, + { "icursor", EntryICursorCommand,0 }, + { "identify", TtkWidgetIdentifyCommand,0 }, + { "index", EntryIndexCommand,0 }, + { "insert", EntryInsertCommand,0 }, + { "instate", TtkWidgetInstateCommand,0 }, + { "selection", 0,EntrySelectionCommands }, + { "state", TtkWidgetStateCommand,0 }, + { "set", EntrySetCommand,0 }, + { "validate", EntryValidateCommand,0 }, + { "xview", EntryXViewCommand,0 }, + { 0,0,0 } }; static WidgetSpec SpinboxWidgetSpec = { diff --git a/generic/ttk/ttkFrame.c b/generic/ttk/ttkFrame.c index f7edfe3..cf22cda 100644 --- a/generic/ttk/ttkFrame.c +++ b/generic/ttk/ttkFrame.c @@ -1,4 +1,4 @@ -/* $Id: ttkFrame.c,v 1.14 2009/02/06 08:12:07 das Exp $ +/* $Id: ttkFrame.c,v 1.15 2010/01/31 22:50:55 jenglish Exp $ * Copyright (c) 2004, Joe English * * ttk::frame and ttk::labelframe widgets. @@ -47,13 +47,13 @@ static Tk_OptionSpec FrameOptionSpecs[] = { WIDGET_INHERIT_OPTIONS(ttkCoreOptionSpecs) }; -static WidgetCommandSpec FrameCommands[] = { - { "configure", TtkWidgetConfigureCommand }, - { "cget", TtkWidgetCgetCommand }, - { "instate", TtkWidgetInstateCommand }, - { "state", TtkWidgetStateCommand }, - { "identify", TtkWidgetIdentifyCommand }, - { NULL, NULL } +static const Ttk_Ensemble FrameCommands[] = { + { "configure", TtkWidgetConfigureCommand,0 }, + { "cget", TtkWidgetCgetCommand,0 }, + { "instate", TtkWidgetInstateCommand,0 }, + { "state", TtkWidgetStateCommand,0 }, + { "identify", TtkWidgetIdentifyCommand,0 }, + { 0,0,0 } }; /* diff --git a/generic/ttk/ttkNotebook.c b/generic/ttk/ttkNotebook.c index 96797d7..5088d1e 100644 --- a/generic/ttk/ttkNotebook.c +++ b/generic/ttk/ttkNotebook.c @@ -1,4 +1,4 @@ -/* $Id: ttkNotebook.c,v 1.22 2010/01/22 14:17:53 nijtmans Exp $ +/* $Id: ttkNotebook.c,v 1.23 2010/01/31 22:50:55 jenglish Exp $ * Copyright (c) 2004, Joe English */ @@ -876,7 +876,7 @@ static int GetTabIndex( /* $nb add window ?options ... ? */ static int NotebookAddCommand( - Tcl_Interp *interp, int objc, Tcl_Obj *const objv[], void *recordPtr) + void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { Notebook *nb = recordPtr; int index = Ttk_NumberSlaves(nb->notebook.mgr); @@ -916,7 +916,7 @@ static int NotebookAddCommand( * Insert new tab, or move existing one. */ static int NotebookInsertCommand( - Tcl_Interp *interp, int objc, Tcl_Obj *const objv[], void *recordPtr) + void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { Notebook *nb = recordPtr; int current = nb->notebook.currentIndex; @@ -990,7 +990,7 @@ static int NotebookInsertCommand( * Removes the specified tab. */ static int NotebookForgetCommand( - Tcl_Interp *interp, int objc, Tcl_Obj *const objv[], void *recordPtr) + void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { Notebook *nb = recordPtr; int index; @@ -1014,7 +1014,7 @@ static int NotebookForgetCommand( * Hides the specified tab. */ static int NotebookHideCommand( - Tcl_Interp *interp, int objc, Tcl_Obj *const objv[], void *recordPtr) + void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { Notebook *nb = recordPtr; int index; @@ -1044,7 +1044,7 @@ static int NotebookHideCommand( * Returns name of tab element at $x,$y; empty string if none. */ static int NotebookIdentifyCommand( - Tcl_Interp *interp, int objc, Tcl_Obj *const objv[], void *recordPtr) + void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { static const char *whatTable[] = { "element", "tab", NULL }; enum { IDENTIFY_ELEMENT, IDENTIFY_TAB }; @@ -1101,7 +1101,7 @@ static int NotebookIdentifyCommand( * See above for valid item formats. */ static int NotebookIndexCommand( - Tcl_Interp *interp, int objc, Tcl_Obj *const objv[], void *recordPtr) + void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { Notebook *nb = recordPtr; int index, status; @@ -1133,7 +1133,7 @@ static int NotebookIndexCommand( * the currently-selected pane. */ static int NotebookSelectCommand( - Tcl_Interp *interp, int objc, Tcl_Obj *const objv[], void *recordPtr) + void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { Notebook *nb = recordPtr; @@ -1159,7 +1159,7 @@ static int NotebookSelectCommand( * Return list of tabs. */ static int NotebookTabsCommand( - Tcl_Interp *interp, int objc, Tcl_Obj *const objv[], void *recordPtr) + void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { Notebook *nb = recordPtr; Ttk_Manager *mgr = nb->notebook.mgr; @@ -1184,7 +1184,7 @@ static int NotebookTabsCommand( /* $nb tab $tab ?-option ?value -option value...?? */ static int NotebookTabCommand( - Tcl_Interp *interp, int objc, Tcl_Obj *const objv[], void *recordPtr) + void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { Notebook *nb = recordPtr; Ttk_Manager *mgr = nb->notebook.mgr; @@ -1228,22 +1228,21 @@ static int NotebookTabCommand( /* Subcommand table: */ -static WidgetCommandSpec NotebookCommands[] = -{ - { "add", NotebookAddCommand }, - { "configure", TtkWidgetConfigureCommand }, - { "cget", TtkWidgetCgetCommand }, - { "forget", NotebookForgetCommand }, - { "hide", NotebookHideCommand }, - { "identify", NotebookIdentifyCommand }, - { "index", NotebookIndexCommand }, - { "insert", NotebookInsertCommand }, - { "instate", TtkWidgetInstateCommand }, - { "select", NotebookSelectCommand }, - { "state", TtkWidgetStateCommand }, - { "tab", NotebookTabCommand }, - { "tabs", NotebookTabsCommand }, - { 0,0 } +static const Ttk_Ensemble NotebookCommands[] = { + { "add", NotebookAddCommand,0 }, + { "configure", TtkWidgetConfigureCommand,0 }, + { "cget", TtkWidgetCgetCommand,0 }, + { "forget", NotebookForgetCommand,0 }, + { "hide", NotebookHideCommand,0 }, + { "identify", NotebookIdentifyCommand,0 }, + { "index", NotebookIndexCommand,0 }, + { "insert", NotebookInsertCommand,0 }, + { "instate", TtkWidgetInstateCommand,0 }, + { "select", NotebookSelectCommand,0 }, + { "state", TtkWidgetStateCommand,0 }, + { "tab", NotebookTabCommand,0 }, + { "tabs", NotebookTabsCommand,0 }, + { 0,0,0 } }; /*------------------------------------------------------------------------ diff --git a/generic/ttk/ttkPanedwindow.c b/generic/ttk/ttkPanedwindow.c index 2fa7953..be9e549 100644 --- a/generic/ttk/ttkPanedwindow.c +++ b/generic/ttk/ttkPanedwindow.c @@ -1,4 +1,4 @@ -/* $Id: ttkPanedwindow.c,v 1.19 2010/01/22 14:17:53 nijtmans Exp $ +/* $Id: ttkPanedwindow.c,v 1.20 2010/01/31 22:50:56 jenglish Exp $ * * Copyright (c) 2005, Joe English. Freely redistributable. * @@ -617,7 +617,7 @@ static void PanedDisplay(void *recordPtr, Drawable d) /* $pw add window [ options ... ] */ static int PanedAddCommand( - Tcl_Interp *interp, int objc, Tcl_Obj *const objv[], void *recordPtr) + void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { Paned *pw = recordPtr; Tk_Window slaveWindow; @@ -642,7 +642,7 @@ static int PanedAddCommand( * Insert new slave, or move existing one. */ static int PanedInsertCommand( - Tcl_Interp *interp, int objc, Tcl_Obj *const objv[], void *recordPtr) + void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { Paned *pw = recordPtr; int nSlaves = Ttk_NumberSlaves(pw->paned.mgr); @@ -687,7 +687,7 @@ static int PanedInsertCommand( /* $pw forget $pane */ static int PanedForgetCommand( - Tcl_Interp *interp, int objc, Tcl_Obj *const objv[], void *recordPtr) + void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { Paned *pw = recordPtr; int paneIndex; @@ -711,7 +711,7 @@ static int PanedForgetCommand( * Return index of sash at $x,$y */ static int PanedIdentifyCommand( - Tcl_Interp *interp, int objc, Tcl_Obj *const objv[], void *recordPtr) + void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { const char *whatTable[] = { "element", "sash", NULL }; enum { IDENTIFY_ELEMENT, IDENTIFY_SASH }; @@ -766,7 +766,7 @@ static int PanedIdentifyCommand( * Query/modify pane options. */ static int PanedPaneCommand( - Tcl_Interp *interp, int objc, Tcl_Obj *const objv[], void *recordPtr) + void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { Paned *pw = recordPtr; int paneIndex; @@ -803,7 +803,7 @@ static int PanedPaneCommand( * Return list of managed panes. */ static int PanedPanesCommand( - Tcl_Interp *interp, int objc, Tcl_Obj *const objv[], void *recordPtr) + void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { Paned *pw = recordPtr; Ttk_Manager *mgr = pw->paned.mgr; @@ -830,7 +830,7 @@ static int PanedPanesCommand( * Query or modify sash position. */ static int PanedSashposCommand( - Tcl_Interp *interp, int objc, Tcl_Obj *const objv[], void *recordPtr) + void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { Paned *pw = recordPtr; int sashIndex, position = -1; @@ -875,20 +875,19 @@ static int PanedSashposCommand( return TCL_OK; } -static WidgetCommandSpec PanedCommands[] = -{ - { "add", PanedAddCommand }, - { "configure", TtkWidgetConfigureCommand }, - { "cget", TtkWidgetCgetCommand }, - { "forget", PanedForgetCommand }, - { "identify", PanedIdentifyCommand }, - { "insert", PanedInsertCommand }, - { "instate", TtkWidgetInstateCommand }, - { "pane", PanedPaneCommand }, - { "panes", PanedPanesCommand }, - { "sashpos", PanedSashposCommand }, - { "state", TtkWidgetStateCommand }, - { 0,0 } +static const Ttk_Ensemble PanedCommands[] = { + { "add", PanedAddCommand,0 }, + { "configure", TtkWidgetConfigureCommand,0 }, + { "cget", TtkWidgetCgetCommand,0 }, + { "forget", PanedForgetCommand,0 }, + { "identify", PanedIdentifyCommand,0 }, + { "insert", PanedInsertCommand,0 }, + { "instate", TtkWidgetInstateCommand,0 }, + { "pane", PanedPaneCommand,0 }, + { "panes", PanedPanesCommand,0 }, + { "sashpos", PanedSashposCommand,0 }, + { "state", TtkWidgetStateCommand,0 }, + { 0,0,0 } }; /*------------------------------------------------------------------------ diff --git a/generic/ttk/ttkProgress.c b/generic/ttk/ttkProgress.c index 9b64a27..679cc0b 100644 --- a/generic/ttk/ttkProgress.c +++ b/generic/ttk/ttkProgress.c @@ -1,4 +1,4 @@ -/* $Id: ttkProgress.c,v 1.8 2009/02/08 19:35:35 jenglish Exp $ +/* $Id: ttkProgress.c,v 1.9 2010/01/31 22:50:56 jenglish Exp $ * * Copyright (c) Joe English, Pat Thoyts, Michael Kirkham * @@ -393,7 +393,7 @@ static Ttk_Layout ProgressbarGetLayout( /* $sb step ?amount? */ static int ProgressbarStepCommand( - Tcl_Interp *interp, int objc, Tcl_Obj *const objv[], void *recordPtr) + void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { Progressbar *pb = recordPtr; double value = 0.0, stepAmount = 1.0; @@ -467,30 +467,29 @@ static int ProgressbarStartStopCommand( } static int ProgressbarStartCommand( - Tcl_Interp *interp, int objc, Tcl_Obj *const objv[], void *recordPtr) + void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { return ProgressbarStartStopCommand( interp, "::ttk::progressbar::start", objc, objv); } static int ProgressbarStopCommand( - Tcl_Interp *interp, int objc, Tcl_Obj *const objv[], void *recordPtr) + void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { return ProgressbarStartStopCommand( interp, "::ttk::progressbar::stop", objc, objv); } -static WidgetCommandSpec ProgressbarCommands[] = -{ - { "configure", TtkWidgetConfigureCommand }, - { "cget", TtkWidgetCgetCommand }, - { "identify", TtkWidgetIdentifyCommand }, - { "instate", TtkWidgetInstateCommand }, - { "start", ProgressbarStartCommand }, - { "state", TtkWidgetStateCommand }, - { "step", ProgressbarStepCommand }, - { "stop", ProgressbarStopCommand }, - { NULL, NULL } +static const Ttk_Ensemble ProgressbarCommands[] = { + { "configure", TtkWidgetConfigureCommand,0 }, + { "cget", TtkWidgetCgetCommand,0 }, + { "identify", TtkWidgetIdentifyCommand,0 }, + { "instate", TtkWidgetInstateCommand,0 }, + { "start", ProgressbarStartCommand,0 }, + { "state", TtkWidgetStateCommand,0 }, + { "step", ProgressbarStepCommand,0 }, + { "stop", ProgressbarStopCommand,0 }, + { 0,0,0 } }; /* diff --git a/generic/ttk/ttkScale.c b/generic/ttk/ttkScale.c index 6645dc0..619401f 100644 --- a/generic/ttk/ttkScale.c +++ b/generic/ttk/ttkScale.c @@ -1,4 +1,4 @@ -/* $Id: ttkScale.c,v 1.10 2009/02/08 19:35:35 jenglish Exp $ +/* $Id: ttkScale.c,v 1.11 2010/01/31 22:50:56 jenglish Exp $ * Copyright (C) 2004 Pat Thoyts <patthoyts@users.sourceforge.net> * * ttk::scale widget. @@ -242,7 +242,7 @@ static double ScaleFraction(Scale *scalePtr, double value) */ static int ScaleGetCommand( - Tcl_Interp *interp, int objc, Tcl_Obj *const objv[], void *recordPtr) + void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { Scale *scalePtr = recordPtr; int x, y, r = TCL_OK; @@ -270,7 +270,7 @@ ScaleGetCommand( */ static int ScaleSetCommand( - Tcl_Interp *interp, int objc, Tcl_Obj *const objv[], void *recordPtr) + void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { Scale *scalePtr = recordPtr; double from = 0.0, to = 1.0, value; @@ -338,7 +338,7 @@ ScaleSetCommand( static int ScaleCoordsCommand( - Tcl_Interp *interp, int objc, Tcl_Obj *const objv[], void *recordPtr) + void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { Scale *scalePtr = recordPtr; double value; @@ -462,17 +462,16 @@ ValueToPoint(Scale *scalePtr, double value) return pt; } -static WidgetCommandSpec ScaleCommands[] = -{ - { "configure", TtkWidgetConfigureCommand }, - { "cget", TtkWidgetCgetCommand }, - { "state", TtkWidgetStateCommand }, - { "instate", TtkWidgetInstateCommand }, - { "identify", TtkWidgetIdentifyCommand }, - { "set", ScaleSetCommand }, - { "get", ScaleGetCommand }, - { "coords", ScaleCoordsCommand }, - { 0, 0 } +static const Ttk_Ensemble ScaleCommands[] = { + { "configure", TtkWidgetConfigureCommand,0 }, + { "cget", TtkWidgetCgetCommand,0 }, + { "state", TtkWidgetStateCommand,0 }, + { "instate", TtkWidgetInstateCommand,0 }, + { "identify", TtkWidgetIdentifyCommand,0 }, + { "set", ScaleSetCommand,0 }, + { "get", ScaleGetCommand,0 }, + { "coords", ScaleCoordsCommand,0 }, + { 0,0,0 } }; static WidgetSpec ScaleWidgetSpec = diff --git a/generic/ttk/ttkScrollbar.c b/generic/ttk/ttkScrollbar.c index e7c0bf0..c467b07 100644 --- a/generic/ttk/ttkScrollbar.c +++ b/generic/ttk/ttkScrollbar.c @@ -1,4 +1,4 @@ -/* $Id: ttkScrollbar.c,v 1.10 2009/02/08 19:35:35 jenglish Exp $ +/* $Id: ttkScrollbar.c,v 1.11 2010/01/31 22:50:56 jenglish Exp $ * Copyright (c) 2003, Joe English * * ttk::scrollbar widget. @@ -130,7 +130,7 @@ static void ScrollbarDoLayout(void *recordPtr) */ static int ScrollbarSetCommand( - Tcl_Interp *interp, int objc, Tcl_Obj *const objv[], void *recordPtr) + void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { Scrollbar *scrollbar = recordPtr; Tcl_Obj *firstObj, *lastObj; @@ -181,7 +181,7 @@ ScrollbarSetCommand( */ static int ScrollbarGetCommand( - Tcl_Interp *interp, int objc, Tcl_Obj *const objv[], void *recordPtr) + void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { Scrollbar *scrollbar = recordPtr; Tcl_Obj *result[2]; @@ -204,7 +204,7 @@ ScrollbarGetCommand( */ static int ScrollbarDeltaCommand( - Tcl_Interp *interp, int objc, Tcl_Obj *const objv[], void *recordPtr) + void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { Scrollbar *sb = recordPtr; double dx, dy; @@ -244,7 +244,7 @@ ScrollbarDeltaCommand( */ static int ScrollbarFractionCommand( - Tcl_Interp *interp, int objc, Tcl_Obj *const objv[], void *recordPtr) + void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { Scrollbar *sb = recordPtr; Ttk_Box b = sb->scrollbar.troughBox; @@ -278,18 +278,17 @@ ScrollbarFractionCommand( return TCL_OK; } -static WidgetCommandSpec ScrollbarCommands[] = -{ - { "configure", TtkWidgetConfigureCommand }, - { "cget", TtkWidgetCgetCommand }, - { "delta", ScrollbarDeltaCommand }, - { "fraction", ScrollbarFractionCommand }, - { "get", ScrollbarGetCommand }, - { "identify", TtkWidgetIdentifyCommand }, - { "instate", TtkWidgetInstateCommand }, - { "set", ScrollbarSetCommand }, - { "state", TtkWidgetStateCommand }, - { 0,0 } +static const Ttk_Ensemble ScrollbarCommands[] = { + { "configure", TtkWidgetConfigureCommand,0 }, + { "cget", TtkWidgetCgetCommand,0 }, + { "delta", ScrollbarDeltaCommand,0 }, + { "fraction", ScrollbarFractionCommand,0 }, + { "get", ScrollbarGetCommand,0 }, + { "identify", TtkWidgetIdentifyCommand,0 }, + { "instate", TtkWidgetInstateCommand,0 }, + { "set", ScrollbarSetCommand,0 }, + { "state", TtkWidgetStateCommand,0 }, + { 0,0,0 } }; /*------------------------------------------------------------------------ diff --git a/generic/ttk/ttkSeparator.c b/generic/ttk/ttkSeparator.c index aff3f1b..cfa53dc 100644 --- a/generic/ttk/ttkSeparator.c +++ b/generic/ttk/ttkSeparator.c @@ -1,4 +1,4 @@ -/* $Id: ttkSeparator.c,v 1.7 2007/12/13 15:26:26 dgp Exp $ +/* $Id: ttkSeparator.c,v 1.8 2010/01/31 22:50:56 jenglish Exp $ * * Copyright (c) 2004, Joe English * @@ -49,14 +49,13 @@ static Ttk_Layout SeparatorGetLayout( /* * Widget commands: */ -static WidgetCommandSpec SeparatorCommands[] = -{ - { "configure", TtkWidgetConfigureCommand }, - { "cget", TtkWidgetCgetCommand }, - { "identify", TtkWidgetIdentifyCommand }, - { "instate", TtkWidgetInstateCommand }, - { "state", TtkWidgetStateCommand }, - { NULL, NULL } +static const Ttk_Ensemble SeparatorCommands[] = { + { "configure", TtkWidgetConfigureCommand,0 }, + { "cget", TtkWidgetCgetCommand,0 }, + { "identify", TtkWidgetIdentifyCommand,0 }, + { "instate", TtkWidgetInstateCommand,0 }, + { "state", TtkWidgetStateCommand,0 }, + { 0,0,0 } }; /* @@ -86,14 +85,13 @@ TTK_END_LAYOUT * Has no options or methods other than the standard ones. */ -static WidgetCommandSpec SizegripCommands[] = -{ - { "configure", TtkWidgetConfigureCommand }, - { "cget", TtkWidgetCgetCommand }, - { "identify", TtkWidgetIdentifyCommand }, - { "instate", TtkWidgetInstateCommand }, - { "state", TtkWidgetStateCommand }, - { NULL, NULL } +static const Ttk_Ensemble SizegripCommands[] = { + { "configure", TtkWidgetConfigureCommand,0 }, + { "cget", TtkWidgetCgetCommand,0 }, + { "identify", TtkWidgetIdentifyCommand,0 }, + { "instate", TtkWidgetInstateCommand,0 }, + { "state", TtkWidgetStateCommand,0 }, + { 0,0,0 } }; static WidgetSpec SizegripWidgetSpec = diff --git a/generic/ttk/ttkSquare.c b/generic/ttk/ttkSquare.c index 1229b9f..17b3525 100644 --- a/generic/ttk/ttkSquare.c +++ b/generic/ttk/ttkSquare.c @@ -2,7 +2,7 @@ * * Minimal sample ttk widget. * - * $Id: ttkSquare.c,v 1.8 2010/01/22 14:17:53 nijtmans Exp $ + * $Id: ttkSquare.c,v 1.9 2010/01/31 22:50:56 jenglish Exp $ */ #include <tk.h> @@ -131,14 +131,13 @@ SquareDoLayout(void *clientData) * that are sufficient for our needs. */ -static WidgetCommandSpec SquareCommands[] = -{ - { "configure", TtkWidgetConfigureCommand }, - { "cget", TtkWidgetCgetCommand }, - { "identify", TtkWidgetIdentifyCommand }, - { "instate", TtkWidgetInstateCommand }, - { "state", TtkWidgetStateCommand }, - { NULL, NULL } +static const Ttk_Ensemble SquareCommands[] = { + { "configure", TtkWidgetConfigureCommand,0 }, + { "cget", TtkWidgetCgetCommand,0 }, + { "identify", TtkWidgetIdentifyCommand,0 }, + { "instate", TtkWidgetInstateCommand,0 }, + { "state", TtkWidgetStateCommand,0 }, + { 0,0,0 } }; /* diff --git a/generic/ttk/ttkTheme.c b/generic/ttk/ttkTheme.c index e19ca20..6bc3e42 100644 --- a/generic/ttk/ttkTheme.c +++ b/generic/ttk/ttkTheme.c @@ -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. * - * $Id: ttkTheme.c,v 1.19 2009/03/25 09:06:58 dkf Exp $ + * $Id: ttkTheme.c,v 1.20 2010/01/31 22:50:56 jenglish Exp $ */ #include <stdlib.h> @@ -1626,13 +1626,7 @@ StyleThemeUseCmd( * Implementation of the [style] command. */ -struct Ensemble { - const char *name; /* subcommand name */ - Tcl_ObjCmdProc *command; /* subcommand implementation, OR: */ - struct Ensemble *ensemble; /* subcommand ensemble */ -}; - -static struct Ensemble StyleThemeEnsemble[] = { +static const Ttk_Ensemble StyleThemeEnsemble[] = { { "create", StyleThemeCreateCmd, 0 }, { "names", StyleThemeNamesCmd, 0 }, { "settings", StyleThemeSettingsCmd, 0 }, @@ -1640,14 +1634,14 @@ static struct Ensemble StyleThemeEnsemble[] = { { NULL, 0, 0 } }; -static struct Ensemble StyleElementEnsemble[] = { +static const Ttk_Ensemble StyleElementEnsemble[] = { { "create", StyleElementCreateCmd, 0 }, { "names", StyleElementNamesCmd, 0 }, { "options", StyleElementOptionsCmd, 0 }, { NULL, 0, 0 } }; -static struct Ensemble StyleEnsemble[] = { +static const Ttk_Ensemble StyleEnsemble[] = { { "configure", StyleConfigureCmd, 0 }, { "map", StyleMapCmd, 0 }, { "lookup", StyleLookupCmd, 0 }, @@ -1664,13 +1658,17 @@ StyleObjCmd( int objc, /* Number of arguments */ Tcl_Obj *const objv[]) /* Argument objects */ { - struct Ensemble *ensemble = StyleEnsemble; - int optPtr = 1; - int index; + return Ttk_InvokeEnsemble(StyleEnsemble, 1, clientData,interp,objc,objv); +} - while (optPtr < objc) { +MODULE_SCOPE int Ttk_InvokeEnsemble( /* Run an ensemble command */ + const Ttk_Ensemble *ensemble, int cmdIndex, + void *clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) +{ + while (cmdIndex < objc) { + int index; if (Tcl_GetIndexFromObjStruct(interp, - objv[optPtr], ensemble, sizeof(ensemble[0]), + objv[cmdIndex], ensemble, sizeof(ensemble[0]), "command", 0, &index) != TCL_OK) { @@ -1681,9 +1679,9 @@ StyleObjCmd( return ensemble[index].command(clientData, interp, objc, objv); } ensemble = ensemble[index].ensemble; - ++optPtr; + ++cmdIndex; } - Tcl_WrongNumArgs(interp, optPtr, objv, "option ?arg arg...?"); + Tcl_WrongNumArgs(interp, cmdIndex, objv, "option ?arg ...?"); return TCL_ERROR; } diff --git a/generic/ttk/ttkTheme.h b/generic/ttk/ttkTheme.h index 1f7840f..a123db5 100644 --- a/generic/ttk/ttkTheme.h +++ b/generic/ttk/ttkTheme.h @@ -1,4 +1,4 @@ -/* $Id: ttkTheme.h,v 1.17 2009/02/08 19:35:35 jenglish Exp $ +/* $Id: ttkTheme.h,v 1.18 2010/01/31 22:50:56 jenglish Exp $ * Copyright (c) 2003 Joe English. Freely redistributable. * * Declarations for Tk theme engine. @@ -408,7 +408,21 @@ typedef enum { /* -orient option values */ } Ttk_Orient; /*------------------------------------------------------------------------ - * +++ Stub table declarations: + * +++ Utilities. + */ + +typedef struct TtkEnsemble { + const char *name; /* subcommand name */ + Tcl_ObjCmdProc *command; /* subcommand implementation, OR: */ + const struct TtkEnsemble *ensemble; /* subcommand ensemble */ +} Ttk_Ensemble; + +MODULE_SCOPE int Ttk_InvokeEnsemble( /* Run an ensemble command */ + const Ttk_Ensemble *commands, int cmdIndex, + void *clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); + +/*------------------------------------------------------------------------ + * +++ Stub table declarations. */ #include "ttkDecls.h" diff --git a/generic/ttk/ttkTreeview.c b/generic/ttk/ttkTreeview.c index a5b823f..617aabf 100644 --- a/generic/ttk/ttkTreeview.c +++ b/generic/ttk/ttkTreeview.c @@ -1,4 +1,4 @@ -/* $Id: ttkTreeview.c,v 1.33 2010/01/22 14:17:53 nijtmans Exp $ +/* $Id: ttkTreeview.c,v 1.34 2010/01/31 22:50:56 jenglish Exp $ * Copyright (c) 2004, Joe English * * ttk::treeview widget implementation. @@ -1936,7 +1936,7 @@ static TreeItem *DeleteItems(TreeItem *item, TreeItem *delq) * Return the list of children associated with $item */ static int TreeviewChildrenCommand( - Tcl_Interp *interp, int objc, Tcl_Obj *const objv[], void *recordPtr) + void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { Treeview *tv = recordPtr; TreeItem *item; @@ -2016,7 +2016,7 @@ static int TreeviewChildrenCommand( * Return the item ID of $item's parent. */ static int TreeviewParentCommand( - Tcl_Interp *interp, int objc, Tcl_Obj *const objv[], void *recordPtr) + void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { Treeview *tv = recordPtr; TreeItem *item; @@ -2044,7 +2044,7 @@ static int TreeviewParentCommand( * Return the ID of $item's next sibling. */ static int TreeviewNextCommand( - Tcl_Interp *interp, int objc, Tcl_Obj *const objv[], void *recordPtr) + void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { Treeview *tv = recordPtr; TreeItem *item; @@ -2069,7 +2069,7 @@ static int TreeviewNextCommand( * Return the ID of $item's previous sibling. */ static int TreeviewPrevCommand( - Tcl_Interp *interp, int objc, Tcl_Obj *const objv[], void *recordPtr) + void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { Treeview *tv = recordPtr; TreeItem *item; @@ -2094,7 +2094,7 @@ static int TreeviewPrevCommand( * Return the index of $item within its parent. */ static int TreeviewIndexCommand( - Tcl_Interp *interp, int objc, Tcl_Obj *const objv[], void *recordPtr) + void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { Treeview *tv = recordPtr; TreeItem *item; @@ -2122,7 +2122,7 @@ static int TreeviewIndexCommand( * Test if the specified item id is present in the tree. */ static int TreeviewExistsCommand( - Tcl_Interp *interp, int objc, Tcl_Obj *const objv[], void *recordPtr) + void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { Treeview *tv = recordPtr; Tcl_HashEntry *entryPtr; @@ -2141,7 +2141,7 @@ static int TreeviewExistsCommand( * Return bounding box [x y width height] of specified item. */ static int TreeviewBBoxCommand( - Tcl_Interp *interp, int objc, Tcl_Obj *const objv[], void *recordPtr) + void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { Treeview *tv = recordPtr; TreeItem *item = 0; @@ -2251,7 +2251,7 @@ done: */ static int TreeviewIdentifyCommand( - Tcl_Interp *interp, int objc, Tcl_Obj *const objv[], void *recordPtr) + void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { static const char *submethodStrings[] = { "region", "item", "column", "row", "element", NULL }; @@ -2357,7 +2357,7 @@ static int TreeviewIdentifyCommand( * Query or configure item options. */ static int TreeviewItemCommand( - Tcl_Interp *interp, int objc, Tcl_Obj *const objv[], void *recordPtr) + void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { Treeview *tv = recordPtr; TreeItem *item; @@ -2385,7 +2385,7 @@ static int TreeviewItemCommand( * Column data accessor */ static int TreeviewColumnCommand( - Tcl_Interp *interp, int objc, Tcl_Obj *const objv[], void *recordPtr) + void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { Treeview *tv = recordPtr; TreeColumn *column; @@ -2413,7 +2413,7 @@ static int TreeviewColumnCommand( * Heading data accessor */ static int TreeviewHeadingCommand( - Tcl_Interp *interp, int objc, Tcl_Obj *const objv[], void *recordPtr) + void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { Treeview *tv = recordPtr; Tk_OptionTable optionTable = tv->tree.headingOptionTable; @@ -2443,7 +2443,7 @@ static int TreeviewHeadingCommand( * Query or configure cell values */ static int TreeviewSetCommand( - Tcl_Interp *interp, int objc, Tcl_Obj *const objv[], void *recordPtr) + void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { Treeview *tv = recordPtr; TreeItem *item; @@ -2535,7 +2535,7 @@ static int TreeviewSetCommand( * Insert a new item. */ static int TreeviewInsertCommand( - Tcl_Interp *interp, int objc, Tcl_Obj *const objv[], void *recordPtr) + void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { Treeview *tv = recordPtr; TreeItem *parent, *sibling, *newItem; @@ -2613,7 +2613,7 @@ static int TreeviewInsertCommand( * Unlink $item from the tree. */ static int TreeviewDetachCommand( - Tcl_Interp *interp, int objc, Tcl_Obj *const objv[], void *recordPtr) + void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { Treeview *tv = recordPtr; TreeItem **items; @@ -2658,7 +2658,7 @@ static int TreeviewDetachCommand( */ static int TreeviewDeleteCommand( - Tcl_Interp *interp, int objc, Tcl_Obj *const objv[], void *recordPtr) + void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { Treeview *tv = recordPtr; TreeItem **items, *delq; @@ -2709,7 +2709,7 @@ static int TreeviewDeleteCommand( * Move $item to the specified $index in $parent's child list. */ static int TreeviewMoveCommand( - Tcl_Interp *interp, int objc, Tcl_Obj *const objv[], void *recordPtr) + void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { Treeview *tv = recordPtr; TreeItem *item, *parent; @@ -2772,14 +2772,14 @@ static int TreeviewMoveCommand( */ static int TreeviewXViewCommand( - Tcl_Interp *interp, int objc, Tcl_Obj *const objv[], void *recordPtr) + void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { Treeview *tv = recordPtr; return TtkScrollviewCommand(interp, objc, objv, tv->tree.xscrollHandle); } static int TreeviewYViewCommand( - Tcl_Interp *interp, int objc, Tcl_Obj *const objv[], void *recordPtr) + void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { Treeview *tv = recordPtr; return TtkScrollviewCommand(interp, objc, objv, tv->tree.yscrollHandle); @@ -2789,7 +2789,7 @@ static int TreeviewYViewCommand( * Ensure that $item is visible. */ static int TreeviewSeeCommand( - Tcl_Interp *interp, int objc, Tcl_Obj *const objv[], void *recordPtr) + void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { Treeview *tv = recordPtr; TreeItem *item, *parent; @@ -2835,7 +2835,7 @@ static int TreeviewSeeCommand( * Set right edge of display column $column to x position $X */ static int TreeviewDragCommand( - Tcl_Interp *interp, int objc, Tcl_Obj *const objv[], void *recordPtr) + void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { Treeview *tv = recordPtr; int left = tv->tree.treeArea.x - tv->tree.xscroll.first; @@ -2880,7 +2880,7 @@ static int TreeviewDragCommand( /* + $tree focus ?item? */ static int TreeviewFocusCommand( - Tcl_Interp *interp, int objc, Tcl_Obj *const objv[], void *recordPtr) + void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { Treeview *tv = recordPtr; @@ -2905,7 +2905,7 @@ static int TreeviewFocusCommand( /* + $tree selection ?add|remove|set|toggle $items? */ static int TreeviewSelectionCommand( - Tcl_Interp *interp, int objc, Tcl_Obj *const objv[], void *recordPtr) + void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { enum { SELECTION_SET, SELECTION_ADD, SELECTION_REMOVE, SELECTION_TOGGLE @@ -2982,7 +2982,7 @@ static int TreeviewSelectionCommand( /* + $tv tag bind $tag ?$sequence ?$script?? */ static int TreeviewTagBindCommand( - Tcl_Interp *interp, int objc, Tcl_Obj *const objv[], void *recordPtr) + void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { Treeview *tv = recordPtr; Ttk_Tag tag; @@ -3030,7 +3030,7 @@ static int TreeviewTagBindCommand( /* + $tv tag configure $tag ?-option ?value -option value...?? */ static int TreeviewTagConfigureCommand( - Tcl_Interp *interp, int objc, Tcl_Obj *const objv[], void *recordPtr) + void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { Treeview *tv = recordPtr; Ttk_TagTable tagTable = tv->tree.tagTable; @@ -3061,7 +3061,7 @@ static int TreeviewTagConfigureCommand( /* + $tv tag has $tag ?$item? */ static int TreeviewTagHasCommand( - Tcl_Interp *interp, int objc, Tcl_Obj *const objv[], void *recordPtr) + void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { Treeview *tv = recordPtr; @@ -3094,53 +3094,45 @@ static int TreeviewTagHasCommand( } } -/* + $tv tag option args... - */ -static int TreeviewTagCommand( - Tcl_Interp *interp, int objc, Tcl_Obj *const objv[], void *recordPtr) -{ - static WidgetCommandSpec TreeviewTagCommands[] = { - { "bind", TreeviewTagBindCommand }, - { "configure", TreeviewTagConfigureCommand }, - { "has", TreeviewTagHasCommand }, - {0,0} - }; - return TtkWidgetEnsembleCommand( - TreeviewTagCommands, 2, interp, objc, objv, recordPtr); -} +static const Ttk_Ensemble TreeviewTagCommands[] = { + { "bind", TreeviewTagBindCommand,0 }, + { "configure", TreeviewTagConfigureCommand,0 }, + { "has", TreeviewTagHasCommand,0 }, + { 0,0,0 } +}; /*------------------------------------------------------------------------ * +++ Widget commands record. */ -static WidgetCommandSpec TreeviewCommands[] = { - { "bbox", TreeviewBBoxCommand }, - { "children", TreeviewChildrenCommand }, - { "cget", TtkWidgetCgetCommand }, - { "column", TreeviewColumnCommand }, - { "configure", TtkWidgetConfigureCommand }, - { "delete", TreeviewDeleteCommand }, - { "detach", TreeviewDetachCommand }, - { "drag", TreeviewDragCommand }, - { "exists", TreeviewExistsCommand }, - { "focus", TreeviewFocusCommand }, - { "heading", TreeviewHeadingCommand }, - { "identify", TreeviewIdentifyCommand }, - { "index", TreeviewIndexCommand }, - { "instate", TtkWidgetInstateCommand }, - { "insert", TreeviewInsertCommand }, - { "item", TreeviewItemCommand }, - { "move", TreeviewMoveCommand }, - { "next", TreeviewNextCommand }, - { "parent", TreeviewParentCommand }, - { "prev", TreeviewPrevCommand }, - { "see", TreeviewSeeCommand }, - { "selection" , TreeviewSelectionCommand }, - { "set", TreeviewSetCommand }, - { "state", TtkWidgetStateCommand }, - { "tag", TreeviewTagCommand }, - { "xview", TreeviewXViewCommand }, - { "yview", TreeviewYViewCommand }, - { NULL, NULL } +static const Ttk_Ensemble TreeviewCommands[] = { + { "bbox", TreeviewBBoxCommand,0 }, + { "children", TreeviewChildrenCommand,0 }, + { "cget", TtkWidgetCgetCommand,0 }, + { "column", TreeviewColumnCommand,0 }, + { "configure", TtkWidgetConfigureCommand,0 }, + { "delete", TreeviewDeleteCommand,0 }, + { "detach", TreeviewDetachCommand,0 }, + { "drag", TreeviewDragCommand,0 }, + { "exists", TreeviewExistsCommand,0 }, + { "focus", TreeviewFocusCommand,0 }, + { "heading", TreeviewHeadingCommand,0 }, + { "identify", TreeviewIdentifyCommand,0 }, + { "index", TreeviewIndexCommand,0 }, + { "instate", TtkWidgetInstateCommand,0 }, + { "insert", TreeviewInsertCommand,0 }, + { "item", TreeviewItemCommand,0 }, + { "move", TreeviewMoveCommand,0 }, + { "next", TreeviewNextCommand,0 }, + { "parent", TreeviewParentCommand,0 }, + { "prev", TreeviewPrevCommand,0 }, + { "see", TreeviewSeeCommand,0 }, + { "selection" , TreeviewSelectionCommand,0 }, + { "set", TreeviewSetCommand,0 }, + { "state", TtkWidgetStateCommand,0 }, + { "tag", 0,TreeviewTagCommands }, + { "xview", TreeviewXViewCommand,0 }, + { "yview", TreeviewYViewCommand,0 }, + { 0,0,0 } }; /*------------------------------------------------------------------------ diff --git a/generic/ttk/ttkWidget.c b/generic/ttk/ttkWidget.c index de29d35..f6f3885 100644 --- a/generic/ttk/ttkWidget.c +++ b/generic/ttk/ttkWidget.c @@ -1,4 +1,4 @@ -/* $Id: ttkWidget.c,v 1.23 2010/01/13 23:08:13 nijtmans Exp $ +/* $Id: ttkWidget.c,v 1.24 2010/01/31 22:50:56 jenglish Exp $ * Copyright (c) 2003, Joe English * * Core widget utilities. @@ -146,30 +146,6 @@ void TtkWidgetChangeState(WidgetCore *corePtr, } } -/* TtkWidgetEnsembleCommand -- - * Invoke an ensemble defined by a WidgetCommandSpec. - */ -int TtkWidgetEnsembleCommand( - const WidgetCommandSpec *commands, /* Ensemble definition */ - int cmdIndex, /* Index of command word */ - Tcl_Interp *interp, /* Interpreter to use */ - int objc, Tcl_Obj *const objv[], /* Argument vector */ - void *clientData) /* User data (widget record pointer) */ -{ - int index; - - if (objc <= cmdIndex) { - Tcl_WrongNumArgs(interp, cmdIndex, objv, "option ?arg arg...?"); - return TCL_ERROR; - } - if (Tcl_GetIndexFromObjStruct(interp, objv[cmdIndex], commands, - sizeof(commands[0]), "command", 0, &index) != TCL_OK) - { - return TCL_ERROR; - } - return commands[index].command(interp, objc, objv, clientData); -} - /* WidgetInstanceObjCmd -- * Widget instance command implementation. */ @@ -178,11 +154,11 @@ WidgetInstanceObjCmd( ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { WidgetCore *corePtr = clientData; - const WidgetCommandSpec *commands = corePtr->widgetSpec->commands; + const Ttk_Ensemble *commands = corePtr->widgetSpec->commands; int status; Tcl_Preserve(clientData); - status = TtkWidgetEnsembleCommand(commands,1, interp,objc,objv,clientData); + status = Ttk_InvokeEnsemble(commands,1, clientData,interp,objc,objv); Tcl_Release(clientData); return status; @@ -615,7 +591,7 @@ int TtkWidgetSize(void *recordPtr, int *widthPtr, int *heightPtr) /* $w cget -option */ int TtkWidgetCgetCommand( -Tcl_Interp *interp, int objc, Tcl_Obj *const objv[], void *recordPtr) + void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { WidgetCore *corePtr = recordPtr; Tcl_Obj *result; @@ -635,7 +611,7 @@ Tcl_Interp *interp, int objc, Tcl_Obj *const objv[], void *recordPtr) /* $w configure ?-option ?value ....?? */ int TtkWidgetConfigureCommand( -Tcl_Interp *interp, int objc, Tcl_Obj *const objv[], void *recordPtr) + void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { WidgetCore *corePtr = recordPtr; Tcl_Obj *result; @@ -704,7 +680,7 @@ Tcl_Interp *interp, int objc, Tcl_Obj *const objv[], void *recordPtr) */ int TtkWidgetStateCommand( - Tcl_Interp *interp, int objc, Tcl_Obj *const objv[], void *recordPtr) + void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { WidgetCore *corePtr = recordPtr; Ttk_StateSpec spec; @@ -744,7 +720,7 @@ int TtkWidgetStateCommand( */ int TtkWidgetInstateCommand( - Tcl_Interp *interp, int objc, Tcl_Obj *const objv[], void *recordPtr) + void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { WidgetCore *corePtr = recordPtr; Ttk_State state = corePtr->state; @@ -775,7 +751,7 @@ int TtkWidgetInstateCommand( * Returns: name of element at $x, $y */ int TtkWidgetIdentifyCommand( - Tcl_Interp *interp, int objc, Tcl_Obj *const objv[], void *recordPtr) + void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { WidgetCore *corePtr = recordPtr; Ttk_Element element; diff --git a/generic/ttk/ttkWidget.h b/generic/ttk/ttkWidget.h index f3a3e8d..0f86cc3 100644 --- a/generic/ttk/ttkWidget.h +++ b/generic/ttk/ttkWidget.h @@ -1,4 +1,4 @@ -/* $Id: ttkWidget.h,v 1.11 2008/11/09 23:53:09 jenglish Exp $ +/* $Id: ttkWidget.h,v 1.12 2010/01/31 22:50:56 jenglish Exp $ * Copyright (c) 2003, Joe English * Helper routines for widget implementations. */ @@ -49,20 +49,6 @@ typedef struct } WidgetCore; /* - * Subcommand specifications: - */ -typedef int (*WidgetSubcommandProc)( - Tcl_Interp *interp, int objc, Tcl_Obj *const objv[], void *recordPtr); -typedef struct { - const char *name; - WidgetSubcommandProc command; -} WidgetCommandSpec; - -MODULE_SCOPE int TtkWidgetEnsembleCommand( /* Run an ensemble command */ - const WidgetCommandSpec *commands, int cmdIndex, - Tcl_Interp *interp, int objc, Tcl_Obj *const objv[], void *recordPtr); - -/* * Widget specifications: */ struct WidgetSpec_ @@ -70,7 +56,7 @@ struct WidgetSpec_ const char *className; /* Widget class name */ size_t recordSize; /* #bytes in widget record */ const Tk_OptionSpec *optionSpecs; /* Option specifications */ - const WidgetCommandSpec *commands; /* Widget instance subcommands */ + const Ttk_Ensemble *commands; /* Widget instance subcommands */ /* * Hooks: @@ -104,15 +90,15 @@ MODULE_SCOPE int TtkCoreConfigure(Tcl_Interp*, void *, int mask); /* Common widget commands: */ MODULE_SCOPE int TtkWidgetConfigureCommand( - Tcl_Interp *, int, Tcl_Obj*const[], void *); + void *,Tcl_Interp *, int, Tcl_Obj*const[]); MODULE_SCOPE int TtkWidgetCgetCommand( - Tcl_Interp *, int, Tcl_Obj*const[], void *); + void *,Tcl_Interp *, int, Tcl_Obj*const[]); MODULE_SCOPE int TtkWidgetInstateCommand( - Tcl_Interp *, int, Tcl_Obj*const[], void *); + void *,Tcl_Interp *, int, Tcl_Obj*const[]); MODULE_SCOPE int TtkWidgetStateCommand( - Tcl_Interp *, int, Tcl_Obj*const[], void *); + void *,Tcl_Interp *, int, Tcl_Obj*const[]); MODULE_SCOPE int TtkWidgetIdentifyCommand( - Tcl_Interp *, int, Tcl_Obj*const[], void *); + void *,Tcl_Interp *, int, Tcl_Obj*const[]); /* Widget constructor: */ diff --git a/tests/ttk/ttk.test b/tests/ttk/ttk.test index 2747727..9732f46 100644 --- a/tests/ttk/ttk.test +++ b/tests/ttk/ttk.test @@ -538,16 +538,45 @@ test ttk-14.3 "-textvariable in nonexistant namespace" -body { } -returnCodes 1 -result {can't trace *: parent namespace doesn't exist} \ -match glob -cleanup { destroy .tw } -test ttk-15.1 "style element create: insufficient args" -body { + +## Test ensemble processing: +# +# (See also: SF#2021443) +# +proc wrong#args {args} { + return "wrong # args: should be \"$args\"" +} +proc wrong#varargs {varpart args} { + set usage $args + append usage " ?$varpart ...?" + return "wrong # args: should be \"$usage\"" +} + +test ttk-ensemble-0 "style element create: insufficient args" -body { + ttk::style +} -returnCodes 1 -result \ + [wrong#varargs arg ttk::style option] + +test ttk-ensemble-1 "style element create: insufficient args" -body { + ttk::style element +} -returnCodes 1 -result \ + [wrong#varargs arg ttk::style element option] + +test ttk-ensemble-2 "style element create: insufficient args" -body { ttk::style element create -} -returnCodes 1 -result "wrong # args: should be \"ttk::style element create name type ?-option value ...?\"" -test ttk-15.2 "style element create: insufficient args" -body { +} -returnCodes 1 -result \ + [wrong#varargs {-option value} ttk::style element create name type] + +test ttk-ensemble-3 "style element create: insufficient args" -body { ttk::style element create plain.background -} -returnCodes 1 -result "wrong # args: should be \"ttk::style element create name type ?-option value ...?\"" -test ttk-15.3 "style element create: insufficient args" -body { +} -returnCodes 1 -result \ + [wrong#varargs {-option value} ttk::style element create name type] + +test ttk-ensemble-4 "style element create: insufficient args" -body { ttk::style element create plain.background from -} -returnCodes 1 -result "wrong # args: should be \"theme ?element?\"" -test ttk-15.4 "style element create: valid" -body { +} -returnCodes 1 -result [wrong#args theme ?element?] + +test ttk-ensemble-5 "style element create: valid" -body { ttk::style element create plain.background from default } -returnCodes 0 -result "" |