summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--generic/ttk/ttkButton.c13
-rw-r--r--generic/ttk/ttkEntry.c3
-rw-r--r--generic/ttk/ttkFrame.c1
-rw-r--r--generic/ttk/ttkInit.c2
-rw-r--r--generic/ttk/ttkNotebook.c3
-rw-r--r--generic/ttk/ttkPanedwindow.c1
-rw-r--r--generic/ttk/ttkProgress.c2
-rw-r--r--generic/ttk/ttkScale.c3
-rw-r--r--generic/ttk/ttkScrollbar.c1
-rw-r--r--generic/ttk/ttkSeparator.c11
-rw-r--r--generic/ttk/ttkSquare.c3
-rw-r--r--generic/ttk/ttkTreeview.c3
-rw-r--r--generic/ttk/ttkWidget.h23
-rw-r--r--tests/ttk/ttk.test28
14 files changed, 60 insertions, 37 deletions
diff --git a/generic/ttk/ttkButton.c b/generic/ttk/ttkButton.c
index ae0f20a..2954184 100644
--- a/generic/ttk/ttkButton.c
+++ b/generic/ttk/ttkButton.c
@@ -244,6 +244,7 @@ static Tk_OptionSpec LabelOptionSpecs[] =
NULL, Tk_Offset(Label, label.wrapLengthObj), -1,
TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED /*SB: SIZE_CHANGED*/ },
+ WIDGET_TAKEFOCUS_FALSE,
WIDGET_INHERIT_OPTIONS(BaseOptionSpecs)
};
@@ -301,14 +302,13 @@ typedef struct
*/
static Tk_OptionSpec ButtonOptionSpecs[] =
{
- WIDGET_TAKES_FOCUS,
-
{TK_OPTION_STRING, "-command", "command", "Command",
"", Tk_Offset(Button, button.commandObj), -1, 0,0,0},
{TK_OPTION_STRING_TABLE, "-default", "default", "Default",
"normal", Tk_Offset(Button, button.defaultStateObj), -1,
0, (ClientData) ttkDefaultStrings, DEFAULTSTATE_CHANGED},
+ WIDGET_TAKEFOCUS_TRUE,
WIDGET_INHERIT_OPTIONS(BaseOptionSpecs)
};
@@ -412,8 +412,6 @@ typedef struct
*/
static Tk_OptionSpec CheckbuttonOptionSpecs[] =
{
- WIDGET_TAKES_FOCUS,
-
{TK_OPTION_STRING, "-variable", "variable", "Variable",
"", Tk_Offset(Checkbutton, checkbutton.variableObj), -1,
TK_OPTION_DONT_SET_DEFAULT,0,0},
@@ -427,6 +425,7 @@ static Tk_OptionSpec CheckbuttonOptionSpecs[] =
"", Tk_Offset(Checkbutton, checkbutton.commandObj), -1,
0,0,0},
+ WIDGET_TAKEFOCUS_TRUE,
WIDGET_INHERIT_OPTIONS(BaseOptionSpecs)
};
@@ -613,8 +612,6 @@ typedef struct
*/
static Tk_OptionSpec RadiobuttonOptionSpecs[] =
{
- WIDGET_TAKES_FOCUS,
-
{TK_OPTION_STRING, "-variable", "variable", "Variable",
"::selectedButton", Tk_Offset(Radiobutton, radiobutton.variableObj),-1,
0,0,0},
@@ -625,6 +622,7 @@ static Tk_OptionSpec RadiobuttonOptionSpecs[] =
"", Tk_Offset(Radiobutton, radiobutton.commandObj), -1,
0,0,0},
+ WIDGET_TAKEFOCUS_TRUE,
WIDGET_INHERIT_OPTIONS(BaseOptionSpecs)
};
@@ -789,14 +787,13 @@ static const char *const directionStrings[] = {
};
static Tk_OptionSpec MenubuttonOptionSpecs[] =
{
- WIDGET_TAKES_FOCUS,
-
{TK_OPTION_STRING, "-menu", "menu", "Menu",
"", Tk_Offset(Menubutton, menubutton.menuObj), -1, 0,0,0},
{TK_OPTION_STRING_TABLE, "-direction", "direction", "Direction",
"below", Tk_Offset(Menubutton, menubutton.directionObj), -1,
0,(ClientData)directionStrings,GEOMETRY_CHANGED},
+ WIDGET_TAKEFOCUS_TRUE,
WIDGET_INHERIT_OPTIONS(BaseOptionSpecs)
};
diff --git a/generic/ttk/ttkEntry.c b/generic/ttk/ttkEntry.c
index f4750e1..c4b1b6a 100644
--- a/generic/ttk/ttkEntry.c
+++ b/generic/ttk/ttkEntry.c
@@ -155,8 +155,6 @@ typedef struct {
#define DEF_LIST_HEIGHT "10"
static Tk_OptionSpec EntryOptionSpecs[] = {
- WIDGET_TAKES_FOCUS,
-
{TK_OPTION_BOOLEAN, "-exportselection", "exportSelection",
"ExportSelection", "1", -1, Tk_Offset(Entry, entry.exportSelection),
0,0,0 },
@@ -200,6 +198,7 @@ static Tk_OptionSpec EntryOptionSpecs[] = {
NULL, Tk_Offset(Entry, entry.styleData.backgroundObj), -1,
TK_OPTION_NULL_OK,0,0},
+ WIDGET_TAKEFOCUS_TRUE,
WIDGET_INHERIT_OPTIONS(ttkCoreOptionSpecs)
};
diff --git a/generic/ttk/ttkFrame.c b/generic/ttk/ttkFrame.c
index 5971e0d..7860024 100644
--- a/generic/ttk/ttkFrame.c
+++ b/generic/ttk/ttkFrame.c
@@ -44,6 +44,7 @@ static Tk_OptionSpec FrameOptionSpecs[] = {
Tk_Offset(Frame,frame.heightObj), -1,
0,0,GEOMETRY_CHANGED },
+ WIDGET_TAKEFOCUS_FALSE,
WIDGET_INHERIT_OPTIONS(ttkCoreOptionSpecs)
};
diff --git a/generic/ttk/ttkInit.c b/generic/ttk/ttkInit.c
index be30ee7..78676c6 100644
--- a/generic/ttk/ttkInit.c
+++ b/generic/ttk/ttkInit.c
@@ -177,8 +177,6 @@ int TtkGetOptionValue(
/* public */
Tk_OptionSpec ttkCoreOptionSpecs[] =
{
- {TK_OPTION_STRING, "-takefocus", "takeFocus", "TakeFocus",
- "", Tk_Offset(WidgetCore, takeFocusPtr), -1, 0,0,0 },
{TK_OPTION_CURSOR, "-cursor", "cursor", "Cursor", NULL,
Tk_Offset(WidgetCore, cursorObj), -1, TK_OPTION_NULL_OK,0,0 },
{TK_OPTION_STRING, "-style", "style", "Style", "",
diff --git a/generic/ttk/ttkNotebook.c b/generic/ttk/ttkNotebook.c
index 405553b..551f4a6 100644
--- a/generic/ttk/ttkNotebook.c
+++ b/generic/ttk/ttkNotebook.c
@@ -113,8 +113,6 @@ typedef struct
static Tk_OptionSpec NotebookOptionSpecs[] =
{
- WIDGET_TAKES_FOCUS,
-
{TK_OPTION_INT, "-width", "width", "Width", "0",
Tk_Offset(Notebook,notebook.widthObj),-1,
0,0,GEOMETRY_CHANGED },
@@ -125,6 +123,7 @@ static Tk_OptionSpec NotebookOptionSpecs[] =
Tk_Offset(Notebook,notebook.paddingObj),-1,
TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED },
+ WIDGET_TAKEFOCUS_TRUE,
WIDGET_INHERIT_OPTIONS(ttkCoreOptionSpecs)
};
diff --git a/generic/ttk/ttkPanedwindow.c b/generic/ttk/ttkPanedwindow.c
index 771d266..065774e 100644
--- a/generic/ttk/ttkPanedwindow.c
+++ b/generic/ttk/ttkPanedwindow.c
@@ -86,6 +86,7 @@ static Tk_OptionSpec PanedOptionSpecs[] = {
-1,Tk_Offset(Paned,paned.height),
0,0,GEOMETRY_CHANGED },
+ WIDGET_TAKEFOCUS_FALSE,
WIDGET_INHERIT_OPTIONS(ttkCoreOptionSpecs)
};
diff --git a/generic/ttk/ttkProgress.c b/generic/ttk/ttkProgress.c
index 7971e43..4dc50a2 100644
--- a/generic/ttk/ttkProgress.c
+++ b/generic/ttk/ttkProgress.c
@@ -68,6 +68,8 @@ static Tk_OptionSpec ProgressbarOptionSpecs[] =
{TK_OPTION_INT, "-phase", "phase", "Phase",
"0", Tk_Offset(Progressbar,progress.phaseObj), -1,
0, 0, 0 },
+
+ WIDGET_TAKEFOCUS_FALSE,
WIDGET_INHERIT_OPTIONS(ttkCoreOptionSpecs)
};
diff --git a/generic/ttk/ttkScale.c b/generic/ttk/ttkScale.c
index 0745ebd..69753d1 100644
--- a/generic/ttk/ttkScale.c
+++ b/generic/ttk/ttkScale.c
@@ -45,8 +45,6 @@ typedef struct
static Tk_OptionSpec ScaleOptionSpecs[] =
{
- WIDGET_TAKES_FOCUS,
-
{TK_OPTION_STRING, "-command", "command", "Command", "",
Tk_Offset(Scale,scale.commandObj), -1,
TK_OPTION_NULL_OK,0,0},
@@ -68,6 +66,7 @@ static Tk_OptionSpec ScaleOptionSpecs[] =
DEF_SCALE_LENGTH, Tk_Offset(Scale,scale.lengthObj), -1, 0, 0,
GEOMETRY_CHANGED},
+ WIDGET_TAKEFOCUS_TRUE,
WIDGET_INHERIT_OPTIONS(ttkCoreOptionSpecs)
};
diff --git a/generic/ttk/ttkScrollbar.c b/generic/ttk/ttkScrollbar.c
index 641b0dc..5b0c212 100644
--- a/generic/ttk/ttkScrollbar.c
+++ b/generic/ttk/ttkScrollbar.c
@@ -42,6 +42,7 @@ static Tk_OptionSpec ScrollbarOptionSpecs[] =
Tk_Offset(Scrollbar,scrollbar.orient),
0,(ClientData)ttkOrientStrings,STYLE_CHANGED },
+ WIDGET_TAKEFOCUS_FALSE,
WIDGET_INHERIT_OPTIONS(ttkCoreOptionSpecs)
};
diff --git a/generic/ttk/ttkSeparator.c b/generic/ttk/ttkSeparator.c
index 6c8ee6b..b52e6f4 100644
--- a/generic/ttk/ttkSeparator.c
+++ b/generic/ttk/ttkSeparator.c
@@ -23,13 +23,13 @@ typedef struct
SeparatorPart separator;
} Separator;
-static Tk_OptionSpec SeparatorOptionSpecs[] =
-{
+static Tk_OptionSpec SeparatorOptionSpecs[] = {
{TK_OPTION_STRING_TABLE, "-orient", "orient", "Orient", "horizontal",
Tk_Offset(Separator,separator.orientObj),
Tk_Offset(Separator,separator.orient),
0,(ClientData)ttkOrientStrings,STYLE_CHANGED },
+ WIDGET_TAKEFOCUS_FALSE,
WIDGET_INHERIT_OPTIONS(ttkCoreOptionSpecs)
};
@@ -84,6 +84,11 @@ TTK_END_LAYOUT
* Has no options or methods other than the standard ones.
*/
+static Tk_OptionSpec SizegripOptionSpecs[] = {
+ WIDGET_TAKEFOCUS_FALSE,
+ WIDGET_INHERIT_OPTIONS(ttkCoreOptionSpecs)
+};
+
static const Ttk_Ensemble SizegripCommands[] = {
{ "configure", TtkWidgetConfigureCommand,0 },
{ "cget", TtkWidgetCgetCommand,0 },
@@ -97,7 +102,7 @@ static WidgetSpec SizegripWidgetSpec =
{
"TSizegrip", /* className */
sizeof(WidgetCore), /* recordSize */
- ttkCoreOptionSpecs, /* optionSpecs */
+ SizegripOptionSpecs, /* optionSpecs */
SizegripCommands, /* subcommands */
TtkNullInitialize, /* initializeProc */
TtkNullCleanup, /* cleanupProc */
diff --git a/generic/ttk/ttkSquare.c b/generic/ttk/ttkSquare.c
index 23caeb4..d002f2f 100644
--- a/generic/ttk/ttkSquare.c
+++ b/generic/ttk/ttkSquare.c
@@ -50,8 +50,6 @@ typedef struct
static Tk_OptionSpec SquareOptionSpecs[] =
{
- WIDGET_TAKES_FOCUS,
-
{TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth",
DEFAULT_BORDERWIDTH, Tk_Offset(Square,square.borderWidthObj), -1,
0,0,GEOMETRY_CHANGED },
@@ -76,6 +74,7 @@ static Tk_OptionSpec SquareOptionSpecs[] =
{TK_OPTION_ANCHOR, "-anchor", "anchor", "Anchor",
NULL, Tk_Offset(Square,square.anchorObj), -1, TK_OPTION_NULL_OK, 0, 0},
+ WIDGET_TAKEFOCUS_TRUE,
WIDGET_INHERIT_OPTIONS(ttkCoreOptionSpecs)
};
diff --git a/generic/ttk/ttkTreeview.c b/generic/ttk/ttkTreeview.c
index f521b38..222b280 100644
--- a/generic/ttk/ttkTreeview.c
+++ b/generic/ttk/ttkTreeview.c
@@ -438,8 +438,6 @@ typedef struct {
static const char *SelectModeStrings[] = { "none", "browse", "extended", NULL };
static Tk_OptionSpec TreeviewOptionSpecs[] = {
- WIDGET_TAKES_FOCUS,
-
{TK_OPTION_STRING, "-columns", "columns", "Columns",
"", Tk_Offset(Treeview,tree.columnsObj), -1,
0,0,COLUMNS_CHANGED | GEOMETRY_CHANGED /*| READONLY_OPTION*/ },
@@ -468,6 +466,7 @@ static Tk_OptionSpec TreeviewOptionSpecs[] = {
NULL, -1, Tk_Offset(Treeview, tree.yscroll.scrollCmd),
TK_OPTION_NULL_OK, 0, SCROLLCMD_CHANGED},
+ WIDGET_TAKEFOCUS_TRUE,
WIDGET_INHERIT_OPTIONS(ttkCoreOptionSpecs)
};
diff --git a/generic/ttk/ttkWidget.h b/generic/ttk/ttkWidget.h
index fffd82b..9e9ab69 100644
--- a/generic/ttk/ttkWidget.h
+++ b/generic/ttk/ttkWidget.h
@@ -109,14 +109,18 @@ MODULE_SCOPE int TtkWidgetConstructorObjCmd(
Tcl_CreateObjCommand(interp, name, \
TtkWidgetConstructorObjCmd, (ClientData)specPtr,NULL)
-/* WIDGET_TAKES_FOCUS --
- * Add this to the OptionSpecs table of widgets that
- * take keyboard focus during traversal to override
- * CoreOptionSpec's -takefocus default value:
+/* WIDGET_TAKEFOCUS_TRUE --
+ * WIDGET_TAKEFOCUS_FALSE --
+ * Add one or the other of these to each OptionSpecs table
+ * to indicate whether the widget should take focus
+ * during keyboard traversal.
*/
-#define WIDGET_TAKES_FOCUS \
+#define WIDGET_TAKEFOCUS_TRUE \
{TK_OPTION_STRING, "-takefocus", "takeFocus", "TakeFocus", \
"ttk::takefocus", Tk_Offset(WidgetCore, takeFocusPtr), -1, 0,0,0 }
+#define WIDGET_TAKEFOCUS_FALSE \
+ {TK_OPTION_STRING, "-takefocus", "takeFocus", "TakeFocus", \
+ "", Tk_Offset(WidgetCore, takeFocusPtr), -1, 0,0,0 }
/* WIDGET_INHERIT_OPTIONS(baseOptionSpecs) --
* Add this at the end of an OptionSpecs table to inherit
@@ -125,6 +129,10 @@ MODULE_SCOPE int TtkWidgetConstructorObjCmd(
#define WIDGET_INHERIT_OPTIONS(baseOptionSpecs) \
{TK_OPTION_END, 0,0,0, NULL, -1,-1, 0, (ClientData)baseOptionSpecs, 0}
+/* All widgets should inherit from ttkCoreOptionSpecs[].
+ */
+MODULE_SCOPE Tk_OptionSpec ttkCoreOptionSpecs[];
+
/*
* Useful routines for use inside widget implementations:
*/
@@ -235,11 +243,6 @@ MODULE_SCOPE void Ttk_TagSetValues(Ttk_TagTable, Ttk_TagSet, void *record);
MODULE_SCOPE void Ttk_TagSetApplyStyle(Ttk_TagTable,Ttk_Style,Ttk_State,void*);
/*
- * Useful widget base classes:
- */
-MODULE_SCOPE Tk_OptionSpec ttkCoreOptionSpecs[];
-
-/*
* String tables for widget resource specifications:
*/
diff --git a/tests/ttk/ttk.test b/tests/ttk/ttk.test
index 5a982b6..def709e 100644
--- a/tests/ttk/ttk.test
+++ b/tests/ttk/ttk.test
@@ -6,6 +6,14 @@ loadTestedCommands
proc skip args {}
proc ok {} { return }
+variable widgetClasses {
+ button checkbutton radiobutton menubutton label entry
+ frame labelframe scrollbar
+ notebook progressbar combobox separator
+ panedwindow treeview sizegrip
+ scale
+}
+
proc bgerror {error} {
variable bgerror $error
variable bgerrorInfo $::errorInfo
@@ -62,10 +70,7 @@ test ttk-6.6 "Bad color spec in styles" -body {
} -result {unknown color name "badColor"}
test ttk-6.7 "Basic destruction test" -body {
- foreach widget {
- button checkbutton radiobutton sizegrip separator notebook
- progressbar panedwindow scrollbar
- } {
+ foreach widget $widgetClasses {
ttk::$widget .w
pack .w
destroy .w
@@ -214,6 +219,21 @@ test ttk-2.8 "bug 3223850: button state disabled during click" -setup {
unset -nocomplain ttk28 aid
} -result 1
+foreach wc $widgetClasses {
+ test ttk-coreoptions-$wc "$wc has all core options" -body {
+ ttk::$wc .w
+ foreach option {
+ -class
+ -style
+ -cursor
+ -takefocus
+ } {
+ .w cget $option
+ }
+ destroy .w
+ }
+}
+
# misc. error detection
test ttk-3.0 "Bad option" -body {
ttk::button .bad -badoption foo