diff options
-rw-r--r-- | ChangeLog | 9 | ||||
-rw-r--r-- | generic/ttk/ttkClamTheme.c | 25 | ||||
-rw-r--r-- | generic/ttk/ttkClassicTheme.c | 43 | ||||
-rw-r--r-- | generic/ttk/ttkLayout.c | 22 | ||||
-rw-r--r-- | generic/ttk/ttkTheme.c | 5 | ||||
-rw-r--r-- | generic/ttk/ttkTheme.h | 26 | ||||
-rw-r--r-- | generic/ttk/ttkThemeInt.h | 7 | ||||
-rw-r--r-- | generic/ttk/ttkTreeview.c | 37 | ||||
-rw-r--r-- | macosx/ttkMacOSXTheme.c | 68 | ||||
-rw-r--r-- | win/ttkWinTheme.c | 43 | ||||
-rw-r--r-- | win/ttkWinXPTheme.c | 51 |
11 files changed, 169 insertions, 167 deletions
@@ -1,3 +1,12 @@ +2007-12-01 Joe English <jenglish@users.sourceforge.net> + + * generic/ttk/ttkTheme.h, generic/ttk/ttkThemeInt.h, + generic/ttk/ttkTheme.c, generic/ttk/ttkLayout.c, + generic/ttk/ttkClamTheme.c, generic/ttk/ttkClassicTheme.c, + generic/ttk/ttkTreeview.c, macosx/ttkMacOSXTheme.c, + win/ttkWinTheme.c, win/ttkWinXPTheme.c: Improved macrology for + statically-initialized layout template tables. + 2007-11-28 Don Porter <dgp@users.sourceforge.net> * unix/tkUnixPort.h: When unix/configure determines whether the diff --git a/generic/ttk/ttkClamTheme.c b/generic/ttk/ttkClamTheme.c index 39d38b4..a5b0392 100644 --- a/generic/ttk/ttkClamTheme.c +++ b/generic/ttk/ttkClamTheme.c @@ -1,5 +1,5 @@ /* - * $Id: ttkClamTheme.c,v 1.7 2007/11/08 01:40:24 jenglish Exp $ + * $Id: ttkClamTheme.c,v 1.8 2007/12/02 04:32:22 jenglish Exp $ * * Copyright (C) 2004 Joe English * @@ -896,22 +896,23 @@ static Ttk_ElementSpec ClientElementSpec = * +++ Modified widget layouts. */ -TTK_BEGIN_LAYOUT(ComboboxLayout) +TTK_BEGIN_LAYOUT_TABLE(LayoutTable) + +TTK_LAYOUT("TCombobox", TTK_NODE("Combobox.downarrow", TTK_PACK_RIGHT|TTK_FILL_Y) TTK_GROUP("Combobox.field", TTK_PACK_LEFT|TTK_FILL_BOTH|TTK_EXPAND, TTK_GROUP("Combobox.padding", TTK_FILL_BOTH, - TTK_NODE("Combobox.textarea", TTK_FILL_BOTH))) -TTK_END_LAYOUT + TTK_NODE("Combobox.textarea", TTK_FILL_BOTH)))) -TTK_BEGIN_LAYOUT(HorizontalSashLayout) +TTK_LAYOUT("Horizontal.Sash", TTK_GROUP("Sash.hsash", TTK_FILL_BOTH, - TTK_NODE("Sash.hgrip", TTK_FILL_BOTH)) -TTK_END_LAYOUT + TTK_NODE("Sash.hgrip", TTK_FILL_BOTH))) -TTK_BEGIN_LAYOUT(VerticalSashLayout) +TTK_LAYOUT("Vertical.Sash", TTK_GROUP("Sash.vsash", TTK_FILL_BOTH, - TTK_NODE("Sash.vgrip", TTK_FILL_BOTH)) -TTK_END_LAYOUT + TTK_NODE("Sash.vgrip", TTK_FILL_BOTH))) + +TTK_END_LAYOUT_TABLE /*------------------------------------------------------------------------ * +++ Initialization. @@ -964,9 +965,7 @@ TtkClamTheme_Init(Tcl_Interp *interp) Ttk_RegisterElement(interp, theme, "vgrip", &GripElementSpec, &GripClientData[1]); - Ttk_RegisterLayout(theme, "TCombobox", ComboboxLayout); - Ttk_RegisterLayout(theme, "Horizontal.Sash", HorizontalSashLayout); - Ttk_RegisterLayout(theme, "Vertical.Sash", VerticalSashLayout); + Ttk_RegisterLayouts(theme, LayoutTable); Tcl_PkgProvide(interp, "ttk::theme::clam", TTK_VERSION); diff --git a/generic/ttk/ttkClassicTheme.c b/generic/ttk/ttkClassicTheme.c index c37b62e..6ca027b 100644 --- a/generic/ttk/ttkClassicTheme.c +++ b/generic/ttk/ttkClassicTheme.c @@ -1,5 +1,5 @@ /* - * $Id: ttkClassicTheme.c,v 1.4 2007/10/25 07:08:26 jenglish Exp $ + * $Id: ttkClassicTheme.c,v 1.5 2007/12/02 04:32:23 jenglish Exp $ * * Copyright (c) 2004, Joe English * @@ -419,51 +419,49 @@ static Ttk_ElementSpec SashElementSpec = { * +++ Widget layouts. */ -TTK_BEGIN_LAYOUT(ButtonLayout) +TTK_BEGIN_LAYOUT_TABLE(LayoutTable) + +TTK_LAYOUT("TButton", TTK_GROUP("Button.highlight", TTK_FILL_BOTH, TTK_GROUP("Button.border", TTK_FILL_BOTH|TTK_BORDER, TTK_GROUP("Button.padding", TTK_FILL_BOTH, - TTK_NODE("Button.label", TTK_FILL_BOTH)))) -TTK_END_LAYOUT + TTK_NODE("Button.label", TTK_FILL_BOTH))))) -TTK_BEGIN_LAYOUT(CheckbuttonLayout) +TTK_LAYOUT("TCheckbutton", TTK_GROUP("Checkbutton.highlight", TTK_FILL_BOTH, TTK_GROUP("Checkbutton.border", TTK_FILL_BOTH, TTK_GROUP("Checkbutton.padding", TTK_FILL_BOTH, TTK_NODE("Checkbutton.indicator", TTK_PACK_LEFT) - TTK_NODE("Checkbutton.label", TTK_PACK_LEFT|TTK_FILL_BOTH)))) -TTK_END_LAYOUT + TTK_NODE("Checkbutton.label", TTK_PACK_LEFT|TTK_FILL_BOTH))))) -TTK_BEGIN_LAYOUT(RadiobuttonLayout) +TTK_LAYOUT("TRadiobutton", TTK_GROUP("Radiobutton.highlight", TTK_FILL_BOTH, TTK_GROUP("Radiobutton.border", TTK_FILL_BOTH, TTK_GROUP("Radiobutton.padding", TTK_FILL_BOTH, TTK_NODE("Radiobutton.indicator", TTK_PACK_LEFT) - TTK_NODE("Radiobutton.label", TTK_PACK_LEFT|TTK_FILL_BOTH)))) -TTK_END_LAYOUT + TTK_NODE("Radiobutton.label", TTK_PACK_LEFT|TTK_FILL_BOTH))))) -TTK_BEGIN_LAYOUT(MenubuttonLayout) +TTK_LAYOUT("TMenubutton", TTK_GROUP("Menubutton.highlight", TTK_FILL_BOTH, TTK_GROUP("Menubutton.border", TTK_FILL_BOTH, TTK_NODE("Menubutton.indicator", TTK_PACK_RIGHT) TTK_GROUP("Menubutton.padding", TTK_PACK_LEFT|TTK_EXPAND|TTK_FILL_X, - TTK_NODE("Menubutton.label", 0)))) -TTK_END_LAYOUT + TTK_NODE("Menubutton.label", 0))))) /* "classic" entry, includes highlight border */ -TTK_BEGIN_LAYOUT(EntryLayout) +TTK_LAYOUT("TEntry", TTK_GROUP("Entry.highlight", TTK_FILL_BOTH, TTK_GROUP("Entry.field", TTK_FILL_BOTH|TTK_BORDER, TTK_GROUP("Entry.padding", TTK_FILL_BOTH, - TTK_NODE("Entry.textarea", TTK_FILL_BOTH)))) -TTK_END_LAYOUT + TTK_NODE("Entry.textarea", TTK_FILL_BOTH))))) /* Notebook tabs -- omit focus ring */ -TTK_BEGIN_LAYOUT(TabLayout) +TTK_LAYOUT("Tab", TTK_GROUP("Notebook.tab", TTK_FILL_BOTH, TTK_GROUP("Notebook.padding", TTK_FILL_BOTH, - TTK_NODE("Notebook.label", TTK_FILL_BOTH))) -TTK_END_LAYOUT + TTK_NODE("Notebook.label", TTK_FILL_BOTH)))) + +TTK_END_LAYOUT_TABLE /* POSSIBLY: include Scale layouts w/focus border */ @@ -509,12 +507,7 @@ MODULE_SCOPE int TtkClassicTheme_Init(Tcl_Interp *interp) /* * Register layouts: */ - Ttk_RegisterLayout(theme, "TButton", ButtonLayout); - Ttk_RegisterLayout(theme, "TCheckbutton", CheckbuttonLayout); - Ttk_RegisterLayout(theme, "TRadiobutton", RadiobuttonLayout); - Ttk_RegisterLayout(theme, "TMenubutton", MenubuttonLayout); - Ttk_RegisterLayout(theme, "TEntry", EntryLayout); - Ttk_RegisterLayout(theme, "TNotebook.Tab", TabLayout); + Ttk_RegisterLayouts(theme, LayoutTable); Tcl_PkgProvide(interp, "ttk::theme::classic", TTK_VERSION); diff --git a/generic/ttk/ttkLayout.c b/generic/ttk/ttkLayout.c index 76754e7..3606c59 100644 --- a/generic/ttk/ttkLayout.c +++ b/generic/ttk/ttkLayout.c @@ -5,7 +5,7 @@ * * Copyright (c) 2003 Joe English. Freely redistributable. * - * $Id: ttkLayout.c,v 1.9 2007/11/18 17:28:02 jenglish Exp $ + * $Id: ttkLayout.c,v 1.10 2007/12/02 04:32:23 jenglish Exp $ */ #include <string.h> @@ -722,7 +722,7 @@ Ttk_LayoutTemplate Ttk_BuildLayoutTemplate(Ttk_LayoutSpec spec) { Ttk_TemplateNode *first = 0, *last = 0; - for ( ; !(spec->opcode & TTK_LAYOUT_END) ; ++spec) { + for ( ; !(spec->opcode & _TTK_LAYOUT_END) ; ++spec) { if (spec->elementName) { Ttk_TemplateNode *node = Ttk_NewTemplateNode(spec->elementName, spec->opcode); @@ -735,7 +735,7 @@ Ttk_LayoutTemplate Ttk_BuildLayoutTemplate(Ttk_LayoutSpec spec) last = node; } - if (spec->opcode & TTK_CHILDREN) { + if (spec->opcode & _TTK_CHILDREN) { int depth = 1; last->child = Ttk_BuildLayoutTemplate(spec+1); @@ -743,19 +743,31 @@ Ttk_LayoutTemplate Ttk_BuildLayoutTemplate(Ttk_LayoutSpec spec) */ while (depth) { ++spec; - if (spec->opcode & TTK_CHILDREN) { + if (spec->opcode & _TTK_CHILDREN) { ++depth; } - if (spec->opcode & TTK_LAYOUT_END) { + if (spec->opcode & _TTK_LAYOUT_END) { --depth; } } } + } /* for */ return first; } +void Ttk_RegisterLayouts(Ttk_Theme theme, Ttk_LayoutSpec spec) +{ + while (!(spec->opcode & _TTK_LAYOUT_END)) { + Ttk_LayoutTemplate layoutTemplate = Ttk_BuildLayoutTemplate(spec+1); + Ttk_RegisterLayoutTemplate(theme, spec->elementName, layoutTemplate); + do { + ++spec; + } while (!(spec->opcode & _TTK_LAYOUT)); + } +} + Tcl_Obj *Ttk_UnparseLayoutTemplate(Ttk_TemplateNode *node) { Tcl_Obj *result = Tcl_NewListObj(0,0); diff --git a/generic/ttk/ttkTheme.c b/generic/ttk/ttkTheme.c index de63d71..3099f18 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.8 2007/11/19 18:49:59 patthoyts Exp $ + * $Id: ttkTheme.c,v 1.9 2007/12/02 04:32:23 jenglish Exp $ */ #include <stdlib.h> @@ -671,7 +671,8 @@ Ttk_GetResourceCache(Tcl_Interp *interp) * Register a new layout specification with a style. * @@@ TODO: Make sure layoutName is not ".", root style must not have a layout */ -static void Ttk_RegisterLayoutTemplate( +MODULE_SCOPE +void Ttk_RegisterLayoutTemplate( Ttk_Theme theme, /* Target theme */ const char *layoutName, /* Name of new layout */ Ttk_LayoutTemplate layoutTemplate) /* Template */ diff --git a/generic/ttk/ttkTheme.h b/generic/ttk/ttkTheme.h index adca259..a0be12e 100644 --- a/generic/ttk/ttkTheme.h +++ b/generic/ttk/ttkTheme.h @@ -1,4 +1,4 @@ -/* $Id: ttkTheme.h,v 1.11 2007/10/25 07:08:26 jenglish Exp $ +/* $Id: ttkTheme.h,v 1.12 2007/12/02 04:32:23 jenglish Exp $ * Copyright (c) 2003 Joe English. Freely redistributable. * * Declarations for Tk theme engine. @@ -181,8 +181,9 @@ typedef unsigned int Ttk_PositionSpec; /* See below */ /* * Extra bits for layout specifications */ -#define TTK_CHILDREN (0x1000)/* for LayoutSpecs -- children follow */ -#define TTK_LAYOUT_END (0x2000)/* for LayoutSpecs -- end of child list */ +#define _TTK_CHILDREN (0x1000)/* for LayoutSpecs -- children follow */ +#define _TTK_LAYOUT_END (0x2000)/* for LayoutSpecs -- end of child list */ +#define _TTK_LAYOUT (0x4000)/* for LayoutSpec tables -- define layout */ #define _TTK_MASK_STICK (0x0F) /* See Ttk_UnparseLayout() */ #define _TTK_MASK_PACK (0xF0) /* See Ttk_UnparseLayout(), packStrings */ @@ -285,17 +286,28 @@ typedef struct { unsigned opcode; } TTKLayoutInstruction, *Ttk_LayoutSpec; -#define TTK_BEGIN_LAYOUT(name) static TTKLayoutInstruction name[] = { +#define TTK_BEGIN_LAYOUT_TABLE(name) \ + static TTKLayoutInstruction name[] = { +#define TTK_LAYOUT(name, content) \ + { name, _TTK_CHILDREN|_TTK_LAYOUT }, \ + content \ + { 0, _TTK_LAYOUT_END }, #define TTK_GROUP(name, flags, children) \ - { name, flags | TTK_CHILDREN }, \ + { name, flags | _TTK_CHILDREN }, \ children \ - { 0, TTK_LAYOUT_END }, + { 0, _TTK_LAYOUT_END }, #define TTK_NODE(name, flags) { name, flags }, -#define TTK_END_LAYOUT { 0, TTK_LAYOUT_END } }; +#define TTK_END_LAYOUT_TABLE { 0, _TTK_LAYOUT | _TTK_LAYOUT_END } }; + +#define TTK_BEGIN_LAYOUT(name) static TTKLayoutInstruction name[] = { +#define TTK_END_LAYOUT { 0, _TTK_LAYOUT_END } }; TTKAPI void Ttk_RegisterLayout( Ttk_Theme theme, const char *className, Ttk_LayoutSpec layoutSpec); +TTKAPI void Ttk_RegisterLayouts( + Ttk_Theme theme, Ttk_LayoutSpec layoutTable); + /*------------------------------------------------------------------------ * +++ Layout instances. */ diff --git a/generic/ttk/ttkThemeInt.h b/generic/ttk/ttkThemeInt.h index 9a904de..0d94649 100644 --- a/generic/ttk/ttkThemeInt.h +++ b/generic/ttk/ttkThemeInt.h @@ -1,5 +1,5 @@ /* - * $Id: ttkThemeInt.h,v 1.3 2006/12/10 19:19:44 jenglish Exp $ + * $Id: ttkThemeInt.h,v 1.4 2007/12/02 04:32:23 jenglish Exp $ * * Theme engine: private definitions. * @@ -28,10 +28,13 @@ MODULE_SCOPE void Ttk_DrawElement( MODULE_SCOPE Tcl_Obj *Ttk_QueryStyle( Ttk_Style, void *, Tk_OptionTable, const char *, Ttk_State state); -MODULE_SCOPE Ttk_LayoutTemplate Ttk_ParseLayoutTemplate(Tcl_Interp *, Tcl_Obj *); +MODULE_SCOPE Ttk_LayoutTemplate Ttk_ParseLayoutTemplate( + Tcl_Interp *, Tcl_Obj *); MODULE_SCOPE Tcl_Obj *Ttk_UnparseLayoutTemplate(Ttk_LayoutTemplate); MODULE_SCOPE Ttk_LayoutTemplate Ttk_BuildLayoutTemplate(Ttk_LayoutSpec); MODULE_SCOPE void Ttk_FreeLayoutTemplate(Ttk_LayoutTemplate); +MODULE_SCOPE void Ttk_RegisterLayoutTemplate( + Ttk_Theme theme, const char *layoutName, Ttk_LayoutTemplate); MODULE_SCOPE Ttk_Style Ttk_GetStyle(Ttk_Theme themePtr, const char *styleName); MODULE_SCOPE Ttk_LayoutTemplate Ttk_FindLayoutTemplate( diff --git a/generic/ttk/ttkTreeview.c b/generic/ttk/ttkTreeview.c index a9d53e3..bca2c10 100644 --- a/generic/ttk/ttkTreeview.c +++ b/generic/ttk/ttkTreeview.c @@ -1,4 +1,4 @@ -/* $Id: ttkTreeview.c,v 1.21 2007/11/08 01:40:25 jenglish Exp $ +/* $Id: ttkTreeview.c,v 1.22 2007/12/02 04:32:23 jenglish Exp $ * Copyright (c) 2004, Joe English * * ttk::treeview widget implementation. @@ -3041,36 +3041,35 @@ static WidgetSpec TreeviewWidgetSpec = * +++ Layout specifications. */ -TTK_BEGIN_LAYOUT(TreeviewLayout) +TTK_BEGIN_LAYOUT_TABLE(LayoutTable) + +TTK_LAYOUT("Treeview", TTK_GROUP("Treeview.field", TTK_FILL_BOTH|TTK_BORDER, TTK_GROUP("Treeview.padding", TTK_FILL_BOTH, - TTK_NODE("Treeview.treearea", TTK_FILL_BOTH))) -TTK_END_LAYOUT + TTK_NODE("Treeview.treearea", TTK_FILL_BOTH)))) -TTK_BEGIN_LAYOUT(ItemLayout) +TTK_LAYOUT("Item", TTK_GROUP("Treeitem.padding", TTK_FILL_BOTH, TTK_NODE("Treeitem.indicator", TTK_PACK_LEFT) TTK_NODE("Treeitem.image", TTK_PACK_LEFT) TTK_GROUP("Treeitem.focus", TTK_PACK_LEFT, - TTK_NODE("Treeitem.text", TTK_PACK_LEFT))) -TTK_END_LAYOUT + TTK_NODE("Treeitem.text", TTK_PACK_LEFT)))) -TTK_BEGIN_LAYOUT(CellLayout) +TTK_LAYOUT("Cell", TTK_GROUP("Treedata.padding", TTK_FILL_BOTH, - TTK_NODE("Treeitem.text", TTK_FILL_BOTH)) -TTK_END_LAYOUT + TTK_NODE("Treeitem.text", TTK_FILL_BOTH))) -TTK_BEGIN_LAYOUT(HeadingLayout) +TTK_LAYOUT("Heading", TTK_NODE("Treeheading.cell", TTK_FILL_BOTH) TTK_GROUP("Treeheading.border", TTK_FILL_BOTH, TTK_GROUP("Treeheading.padding", TTK_FILL_BOTH, TTK_NODE("Treeheading.image", TTK_PACK_RIGHT) - TTK_NODE("Treeheading.text", TTK_FILL_X))) -TTK_END_LAYOUT + TTK_NODE("Treeheading.text", TTK_FILL_X)))) + +TTK_LAYOUT("Row", + TTK_NODE("Treeitem.row", TTK_FILL_BOTH)) -TTK_BEGIN_LAYOUT(RowLayout) - TTK_NODE("Treeitem.row", TTK_FILL_BOTH) -TTK_END_LAYOUT +TTK_END_LAYOUT_TABLE /*------------------------------------------------------------------------ * +++ Tree indicator element. @@ -3201,11 +3200,7 @@ void TtkTreeview_Init(Tcl_Interp *interp) Ttk_RegisterElement(interp, theme, "Treeheading.cell", &RowElementSpec, 0); Ttk_RegisterElement(interp, theme, "treearea", &ttkNullElementSpec, 0); - Ttk_RegisterLayout(theme, TreeviewWidgetSpec.className, TreeviewLayout); - Ttk_RegisterLayout(theme, "Item", ItemLayout); - Ttk_RegisterLayout(theme, "Cell", CellLayout); - Ttk_RegisterLayout(theme, "Heading", HeadingLayout); - Ttk_RegisterLayout(theme, "Row", RowLayout); + Ttk_RegisterLayouts(theme, LayoutTable); } /*EOF*/ diff --git a/macosx/ttkMacOSXTheme.c b/macosx/ttkMacOSXTheme.c index 310cf52..4e834bf 100644 --- a/macosx/ttkMacOSXTheme.c +++ b/macosx/ttkMacOSXTheme.c @@ -27,7 +27,7 @@ * top-level window, not to the Tk_Window. BoxToRect() * accounts for this. * - * RCS: @(#) $Id: ttkMacOSXTheme.c,v 1.18 2007/11/19 01:49:07 jenglish Exp $ + * RCS: @(#) $Id: ttkMacOSXTheme.c,v 1.19 2007/12/02 04:32:23 jenglish Exp $ */ #include "tkMacOSXPrivate.h" @@ -936,66 +936,61 @@ static Ttk_ElementSpec DisclosureElementSpec = { /*---------------------------------------------------------------------- * +++ Widget layouts. */ -TTK_BEGIN_LAYOUT(ToolbarLayout) - TTK_NODE("Toolbar.background", TTK_FILL_BOTH) -TTK_END_LAYOUT -TTK_BEGIN_LAYOUT(ButtonLayout) +TTK_BEGIN_LAYOUT_TABLE(LayoutTable) + +TTK_LAYOUT("Toolbar", + TTK_NODE("Toolbar.background", TTK_FILL_BOTH)) + +TTK_LAYOUT("TButton", TTK_GROUP("Button.button", TTK_FILL_BOTH, TTK_GROUP("Button.padding", TTK_FILL_BOTH, - TTK_NODE("Button.label", TTK_FILL_BOTH))) -TTK_END_LAYOUT + TTK_NODE("Button.label", TTK_FILL_BOTH)))) -TTK_BEGIN_LAYOUT(RadiobuttonLayout) +TTK_LAYOUT("TRadiobutton", TTK_GROUP("Radiobutton.button", TTK_FILL_BOTH, TTK_GROUP("Radiobutton.padding", TTK_FILL_BOTH, - TTK_NODE("Radiobutton.label", TTK_PACK_LEFT))) -TTK_END_LAYOUT + TTK_NODE("Radiobutton.label", TTK_PACK_LEFT)))) -TTK_BEGIN_LAYOUT(CheckbuttonLayout) +TTK_LAYOUT("TCheckbutton", TTK_GROUP("Checkbutton.button", TTK_FILL_BOTH, TTK_GROUP("Checkbutton.padding", TTK_FILL_BOTH, - TTK_NODE("Checkbutton.label", TTK_PACK_LEFT))) -TTK_END_LAYOUT + TTK_NODE("Checkbutton.label", TTK_PACK_LEFT)))) -TTK_BEGIN_LAYOUT(MenubuttonLayout) +TTK_LAYOUT("TMenubutton", TTK_GROUP("Menubutton.button", TTK_FILL_BOTH, TTK_GROUP("Menubutton.padding", TTK_FILL_BOTH, - TTK_NODE("Menubutton.label", TTK_PACK_LEFT))) -TTK_END_LAYOUT + TTK_NODE("Menubutton.label", TTK_PACK_LEFT)))) -TTK_BEGIN_LAYOUT(ComboboxLayout) +TTK_LAYOUT("TCombobox", TTK_GROUP("Combobox.button", TTK_PACK_TOP|TTK_FILL_X, TTK_GROUP("Combobox.padding", TTK_FILL_BOTH, - TTK_NODE("Combobox.textarea", TTK_PACK_LEFT|TTK_FILL_X))) -TTK_END_LAYOUT + TTK_NODE("Combobox.textarea", TTK_PACK_LEFT|TTK_FILL_X)))) /* Notebook tabs -- no focus ring */ -TTK_BEGIN_LAYOUT(TabLayout) +TTK_LAYOUT("Tab", TTK_GROUP("Notebook.tab", TTK_FILL_BOTH, TTK_GROUP("Notebook.padding", TTK_EXPAND|TTK_FILL_BOTH, - TTK_NODE("Notebook.label", TTK_EXPAND|TTK_FILL_BOTH))) -TTK_END_LAYOUT + TTK_NODE("Notebook.label", TTK_EXPAND|TTK_FILL_BOTH)))) /* Progress bars -- track only */ -TTK_BEGIN_LAYOUT(ProgressbarLayout) - TTK_NODE("Progressbar.track", TTK_EXPAND|TTK_FILL_BOTH) -TTK_END_LAYOUT +TTK_LAYOUT("TProgressbar", + TTK_NODE("Progressbar.track", TTK_EXPAND|TTK_FILL_BOTH)) /* Tree heading -- no border, fixed height */ -TTK_BEGIN_LAYOUT(TreeheadingLayout) +TTK_LAYOUT("Heading", TTK_NODE("Treeheading.cell", TTK_FILL_X) TTK_NODE("Treeheading.image", TTK_PACK_RIGHT) - TTK_NODE("Treeheading.text", 0) -TTK_END_LAYOUT + TTK_NODE("Treeheading.text", 0)) /* Tree items -- omit focus ring */ -TTK_BEGIN_LAYOUT(TreeitemLayout) +TTK_LAYOUT("Item", TTK_GROUP("Treeitem.padding", TTK_FILL_BOTH, TTK_NODE("Treeitem.indicator", TTK_PACK_LEFT) TTK_NODE("Treeitem.image", TTK_PACK_LEFT) - TTK_NODE("Treeitem.text", TTK_PACK_LEFT)) -TTK_END_LAYOUT + TTK_NODE("Treeitem.text", TTK_PACK_LEFT))) + +TTK_END_LAYOUT_TABLE /*---------------------------------------------------------------------- * +++ Initialization. @@ -1060,16 +1055,7 @@ static int AquaTheme_Init(Tcl_Interp *interp) /* * Layouts: */ - Ttk_RegisterLayout(themePtr, "Toolbar", ToolbarLayout); - Ttk_RegisterLayout(themePtr, "TButton", ButtonLayout); - Ttk_RegisterLayout(themePtr, "TCheckbutton", CheckbuttonLayout); - Ttk_RegisterLayout(themePtr, "TRadiobutton", RadiobuttonLayout); - Ttk_RegisterLayout(themePtr, "TMenubutton", MenubuttonLayout); - Ttk_RegisterLayout(themePtr, "TCombobox", ComboboxLayout); - Ttk_RegisterLayout(themePtr, "TProgressbar", ProgressbarLayout); - Ttk_RegisterLayout(themePtr, "TNotebook.Tab", TabLayout); - Ttk_RegisterLayout(themePtr, "Heading", TreeheadingLayout); - Ttk_RegisterLayout(themePtr, "Item", TreeitemLayout); + Ttk_RegisterLayouts(themePtr, LayoutTable); Tcl_PkgProvide(interp, "ttk::theme::aqua", TTK_VERSION); return TCL_OK; diff --git a/win/ttkWinTheme.c b/win/ttkWinTheme.c index 18c6405..e8b32e4 100644 --- a/win/ttkWinTheme.c +++ b/win/ttkWinTheme.c @@ -1,6 +1,6 @@ /* winTheme.c - Copyright (C) 2004 Pat Thoyts <patthoyts@users.sf.net> * - * $Id: ttkWinTheme.c,v 1.9 2007/11/08 01:40:25 jenglish Exp $ + * $Id: ttkWinTheme.c,v 1.10 2007/12/02 04:32:23 jenglish Exp $ */ #ifdef _MSC_VER @@ -38,7 +38,7 @@ static RECT BoxToRect(Ttk_Box b) * which must be handled specially. * * Passing the BF_FLAT flag to DrawEdge() yields something similar - * to TK_RELIEF_SOLID. TK_RELIEF_FLAT can be implemented by not + * to TK_RELIEF_SOLID. TK_RELIEF_FLAT can be implemented by not * drawing anything. */ static unsigned int ReliefToEdge(int relief) @@ -53,7 +53,7 @@ static unsigned int ReliefToEdge(int relief) case TK_RELIEF_FLAT: return BDR_RAISEDOUTER; } } - + /* ---------------------------------------------------------------------- */ static Ttk_StateTable checkbutton_statemap[] = @@ -74,7 +74,7 @@ static Ttk_StateTable pushbutton_statemap[] = { 0, 0, 0 } }; -static Ttk_StateTable arrow_statemap[] = +static Ttk_StateTable arrow_statemap[] = { { DFCS_INACTIVE, TTK_STATE_DISABLED, 0 }, { DFCS_PUSHED | DFCS_FLAT, TTK_STATE_PRESSED, 0 }, @@ -98,7 +98,7 @@ typedef struct static FrameControlElementData FrameControlElements[] = { - { "Checkbutton.indicator", + { "Checkbutton.indicator", DFC_BUTTON, DFCS_BUTTONCHECK, SM_CYMENUCHECK, SM_CYMENUCHECK, checkbutton_statemap, {0,0,4,0} }, { "Radiobutton.indicator", @@ -149,7 +149,7 @@ static void FrameControlElementDraw( TkWinReleaseDrawableDC(d, hdc, &dcState); } -static Ttk_ElementSpec FrameControlElementSpec = +static Ttk_ElementSpec FrameControlElementSpec = { TK_STYLE_VERSION_2, sizeof(NullElement), @@ -220,7 +220,7 @@ typedef struct static Ttk_ElementOptionSpec FieldElementOptions[] = { - { "-fieldbackground", TK_OPTION_BORDER, + { "-fieldbackground", TK_OPTION_BORDER, Tk_Offset(FieldElement,backgroundObj), "white" }, {NULL} }; @@ -392,7 +392,7 @@ static Ttk_ElementSpec FocusElementSpec = FocusElementSize, FocusElementDraw }; - + /* FillFocusElement -- * Draws a focus ring filled with the selection color */ @@ -426,7 +426,7 @@ static void FillFocusElementDraw( TkWinReleaseDrawableDC(d, hdc, &dcState); } } - + /* * ComboboxFocusElement -- * Read-only comboboxes have a filled focus ring, editable ones do not. @@ -578,7 +578,7 @@ static Ttk_ElementSpec ThumbElementSpec = ThumbElementDraw }; -/* ---------------------------------------------------------------------- +/* ---------------------------------------------------------------------- * The slider element is the shaped thumb used in the slider widget. * Windows likes to call this a trackbar. */ @@ -670,24 +670,26 @@ static Ttk_ElementSpec ClientElementSpec = * +++ Layouts. */ -TTK_BEGIN_LAYOUT(ButtonLayout) +TTK_BEGIN_LAYOUT_TABLE(LayoutTable) + +TTK_LAYOUT("TButton", TTK_GROUP("Button.border", TTK_FILL_BOTH, TTK_GROUP("Button.padding", TTK_FILL_BOTH, - TTK_NODE("Button.label", TTK_FILL_BOTH))) -TTK_END_LAYOUT + TTK_NODE("Button.label", TTK_FILL_BOTH)))) -TTK_BEGIN_LAYOUT(ComboboxLayout) +TTK_LAYOUT("TCombobox", TTK_GROUP("Combobox.field", TTK_FILL_BOTH, TTK_NODE("Combobox.downarrow", TTK_PACK_RIGHT|TTK_FILL_Y) TTK_GROUP("Combobox.padding", TTK_PACK_LEFT|TTK_EXPAND|TTK_FILL_BOTH, TTK_GROUP("Combobox.focus", TTK_PACK_LEFT|TTK_EXPAND|TTK_FILL_BOTH, - TTK_NODE("Combobox.textarea", TTK_FILL_BOTH)))) -TTK_END_LAYOUT + TTK_NODE("Combobox.textarea", TTK_FILL_BOTH))))) +TTK_END_LAYOUT_TABLE /* ---------------------------------------------------------------------- */ -MODULE_SCOPE int TtkWinTheme_Init(Tcl_Interp *interp, HWND hwnd) +MODULE_SCOPE +int TtkWinTheme_Init(Tcl_Interp *interp, HWND hwnd) { Ttk_Theme themePtr, parentPtr; FrameControlElementData *fce = FrameControlElements; @@ -699,11 +701,11 @@ MODULE_SCOPE int TtkWinTheme_Init(Tcl_Interp *interp, HWND hwnd) } Ttk_RegisterElementSpec(themePtr, "border", &BorderElementSpec, NULL); - Ttk_RegisterElementSpec(themePtr, "Button.border", + Ttk_RegisterElementSpec(themePtr, "Button.border", &ButtonBorderElementSpec, NULL); Ttk_RegisterElementSpec(themePtr, "field", &FieldElementSpec, NULL); Ttk_RegisterElementSpec(themePtr, "focus", &FocusElementSpec, NULL); - Ttk_RegisterElementSpec(themePtr, "Combobox.focus", + Ttk_RegisterElementSpec(themePtr, "Combobox.focus", &ComboboxFocusElementSpec, NULL); Ttk_RegisterElementSpec(themePtr, "thumb", &ThumbElementSpec, NULL); Ttk_RegisterElementSpec(themePtr, "slider", &SliderElementSpec, NULL); @@ -717,8 +719,7 @@ MODULE_SCOPE int TtkWinTheme_Init(Tcl_Interp *interp, HWND hwnd) &FrameControlElementSpec, fce); } - Ttk_RegisterLayout(themePtr, "TButton", ButtonLayout); - Ttk_RegisterLayout(themePtr, "TCombobox", ComboboxLayout); + Ttk_RegisterLayouts(themePtr, LayoutTable); Tcl_PkgProvide(interp, "ttk::theme::winnative", TTK_VERSION); return TCL_OK; diff --git a/win/ttkWinXPTheme.c b/win/ttkWinXPTheme.c index e6a7642..34371f2 100644 --- a/win/ttkWinXPTheme.c +++ b/win/ttkWinXPTheme.c @@ -1,5 +1,5 @@ /* - * $Id: ttkWinXPTheme.c,v 1.15 2007/11/18 00:35:11 patthoyts Exp $ + * $Id: ttkWinXPTheme.c,v 1.16 2007/12/02 04:32:23 jenglish Exp $ * * Tk theme engine which uses the Windows XP "Visual Styles" API * Adapted from Georgios Petasis' XP theme patch. @@ -825,49 +825,47 @@ static Ttk_ElementSpec TextElementSpec = * +++ Widget layouts: */ -TTK_BEGIN_LAYOUT(ButtonLayout) +TTK_BEGIN_LAYOUT_TABLE(LayoutTable) + +TTK_LAYOUT("TButton", TTK_GROUP("Button.button", TTK_FILL_BOTH, TTK_GROUP("Button.focus", TTK_FILL_BOTH, TTK_GROUP("Button.padding", TTK_FILL_BOTH, - TTK_NODE("Button.label", TTK_FILL_BOTH)))) -TTK_END_LAYOUT + TTK_NODE("Button.label", TTK_FILL_BOTH))))) -TTK_BEGIN_LAYOUT(MenubuttonLayout) +TTK_LAYOUT("TMenubutton", TTK_NODE("Menubutton.dropdown", TTK_PACK_RIGHT|TTK_FILL_Y) TTK_GROUP("Menubutton.button", TTK_PACK_RIGHT|TTK_EXPAND|TTK_FILL_BOTH, TTK_GROUP("Menubutton.padding", TTK_PACK_LEFT|TTK_EXPAND|TTK_FILL_X, - TTK_NODE("Menubutton.label", 0))) -TTK_END_LAYOUT + TTK_NODE("Menubutton.label", 0)))) -TTK_BEGIN_LAYOUT(HorizontalScrollbarLayout) +TTK_LAYOUT("Horizontal.TScrollbar", TTK_GROUP("Horizontal.Scrollbar.trough", TTK_FILL_X, TTK_NODE("Horizontal.Scrollbar.leftarrow", TTK_PACK_LEFT) TTK_NODE("Horizontal.Scrollbar.rightarrow", TTK_PACK_RIGHT) TTK_GROUP("Horizontal.Scrollbar.thumb", TTK_FILL_BOTH|TTK_UNIT, - TTK_NODE("Horizontal.Scrollbar.grip", 0))) -TTK_END_LAYOUT + TTK_NODE("Horizontal.Scrollbar.grip", 0)))) -TTK_BEGIN_LAYOUT(VerticalScrollbarLayout) +TTK_LAYOUT("Vertical.TScrollbar", TTK_GROUP("Vertical.Scrollbar.trough", TTK_FILL_Y, TTK_NODE("Vertical.Scrollbar.uparrow", TTK_PACK_TOP) TTK_NODE("Vertical.Scrollbar.downarrow", TTK_PACK_BOTTOM) TTK_GROUP("Vertical.Scrollbar.thumb", TTK_FILL_BOTH|TTK_UNIT, - TTK_NODE("Vertical.Scrollbar.grip", 0))) -TTK_END_LAYOUT + TTK_NODE("Vertical.Scrollbar.grip", 0)))) + +TTK_LAYOUT("Horizontal.TScale", + TTK_GROUP("Scale.focus", TTK_EXPAND|TTK_FILL_BOTH, + TTK_GROUP("Horizontal.Scale.trough", TTK_EXPAND|TTK_FILL_BOTH, + TTK_NODE("Horizontal.Scale.track", TTK_FILL_X) + TTK_NODE("Horizontal.Scale.slider", TTK_PACK_LEFT) ))) -TTK_BEGIN_LAYOUT(VerticalScaleLayout) +TTK_LAYOUT("Vertical.TScale", TTK_GROUP("Scale.focus", TTK_EXPAND|TTK_FILL_BOTH, TTK_GROUP("Vertical.Scale.trough", TTK_EXPAND|TTK_FILL_BOTH, TTK_NODE("Vertical.Scale.track", TTK_FILL_Y) - TTK_NODE("Vertical.Scale.slider", TTK_PACK_TOP) )) -TTK_END_LAYOUT + TTK_NODE("Vertical.Scale.slider", TTK_PACK_TOP) ))) -TTK_BEGIN_LAYOUT(HorizontalScaleLayout) - TTK_GROUP("Scale.focus", TTK_EXPAND|TTK_FILL_BOTH, - TTK_GROUP("Horizontal.Scale.trough", TTK_EXPAND|TTK_FILL_BOTH, - TTK_NODE("Horizontal.Scale.track", TTK_FILL_X) - TTK_NODE("Horizontal.Scale.slider", TTK_PACK_LEFT) )) -TTK_END_LAYOUT +TTK_END_LAYOUT_TABLE /*---------------------------------------------------------------------- * +++ XP element info table: @@ -1016,14 +1014,7 @@ MODULE_SCOPE int TtkXPTheme_Init(Tcl_Interp *interp, HWND hwnd) /* * Layouts: */ - Ttk_RegisterLayout(themePtr, "TButton", ButtonLayout); - Ttk_RegisterLayout(themePtr, "TMenubutton", MenubuttonLayout); - Ttk_RegisterLayout(themePtr, "Vertical.TScrollbar", - VerticalScrollbarLayout); - Ttk_RegisterLayout(themePtr, "Horizontal.TScrollbar", - HorizontalScrollbarLayout); - Ttk_RegisterLayout(themePtr, "Vertical.TScale", VerticalScaleLayout); - Ttk_RegisterLayout(themePtr, "Horizontal.TScale", HorizontalScaleLayout); + Ttk_RegisterLayouts(themePtr, LayoutTable); Tcl_PkgProvide(interp, "ttk::theme::xpnative", TTK_VERSION); |