summaryrefslogtreecommitdiffstats
path: root/win
diff options
context:
space:
mode:
authorjenglish <jenglish@flightlab.com>2007-12-02 04:32:22 (GMT)
committerjenglish <jenglish@flightlab.com>2007-12-02 04:32:22 (GMT)
commitb9257b2ca5a2c1098db948daf8a8b050caa0e96c (patch)
treedcc1e3b870946ba7a2888ef66bd97ad71aa71aa3 /win
parent547f91bd5d798f6eb0d2993c410a0e4c6d31b8dd (diff)
downloadtk-b9257b2ca5a2c1098db948daf8a8b050caa0e96c.zip
tk-b9257b2ca5a2c1098db948daf8a8b050caa0e96c.tar.gz
tk-b9257b2ca5a2c1098db948daf8a8b050caa0e96c.tar.bz2
Improved macrology for statically-initialized layout template tables.
Diffstat (limited to 'win')
-rw-r--r--win/ttkWinTheme.c43
-rw-r--r--win/ttkWinXPTheme.c51
2 files changed, 43 insertions, 51 deletions
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);