From 504f22c2002890ce5b39d30561d76cae861d0d40 Mon Sep 17 00:00:00 2001 From: jenglish Date: Thu, 25 Oct 2007 07:08:25 +0000 Subject: Move widget layout registration from TtkElements_Init() to widget *_Init() routines. Renaming/consistency: s/...ElementGeometry()/...ElementSize()/ --- ChangeLog | 7 + generic/ttk/ttkButton.c | 52 ++++- generic/ttk/ttkClamTheme.c | 56 +++--- generic/ttk/ttkClassicTheme.c | 25 +-- generic/ttk/ttkDefaultTheme.c | 5 +- generic/ttk/ttkElements.c | 264 ++++++------------------- generic/ttk/ttkFrame.c | 17 +- generic/ttk/ttkScale.c | 17 +- generic/ttk/ttkScrollbar.c | 25 ++- generic/ttk/ttkSeparator.c | 15 +- generic/ttk/ttkSquare.c | 17 +- generic/ttk/ttkTheme.h | 4 +- generic/ttk/ttkTreeview.c | 4 +- macosx/ttkMacOSXTheme.c | 50 ++--- win/ttkWinMonitor.c | 49 ++--- win/ttkWinTheme.c | 444 ++++++++++++++++-------------------------- win/ttkWinXPTheme.c | 389 +++++++++++++++++------------------- 17 files changed, 622 insertions(+), 818 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2bf0afd..d3f67b8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2007-10-24 Joe English + + * generic/ttk/*.c, win/{ttkWinMonitor,ttkWinTheme,ttkWinXPTheme}.c, + macosx/ttkMacOSXTheme.c: Move widget layout registration + from TtkElements_Init() to widget *_Init() routines. + Renaming/consistency: s/...ElementGeometry()/...ElementSize()/ + 2007-10-24 Donal K. Fellows * doc/*.n, doc/*.3, doc/*.1: Lots of changes to take advantage of the diff --git a/generic/ttk/ttkButton.c b/generic/ttk/ttkButton.c index 48dcea0..3c1651d 100644 --- a/generic/ttk/ttkButton.c +++ b/generic/ttk/ttkButton.c @@ -1,4 +1,4 @@ -/* $Id: ttkButton.c,v 1.6 2007/01/11 14:49:46 jenglish Exp $ +/* $Id: ttkButton.c,v 1.7 2007/10/25 07:08:26 jenglish Exp $ * Copyright (c) 2003, Joe English * * label, button, checkbutton, radiobutton, and menubutton widgets. @@ -194,9 +194,8 @@ BasePostConfigure(Tcl_Interp *interp, void *recordPtr, int mask) return status; } - /*------------------------------------------------------------------------ - * +++ Label widget: + * +++ Label widget. * Just a base widget that adds a few appearance-related options */ @@ -275,6 +274,12 @@ static WidgetSpec LabelWidgetSpec = TtkWidgetDisplay /* displayProc */ }; +TTK_BEGIN_LAYOUT(LabelLayout) + TTK_GROUP("Label.border", TTK_FILL_BOTH|TTK_BORDER, + TTK_GROUP("Label.padding", TTK_FILL_BOTH|TTK_BORDER, + TTK_NODE("Label.label", TTK_FILL_BOTH))) +TTK_END_LAYOUT + /*------------------------------------------------------------------------ * +++ Button widget. * Adds a new subcommand "invoke", and options "-command" and "-default" @@ -377,6 +382,13 @@ static WidgetSpec ButtonWidgetSpec = TtkWidgetDisplay /* displayProc */ }; +TTK_BEGIN_LAYOUT(ButtonLayout) + TTK_GROUP("Button.border", TTK_FILL_BOTH|TTK_BORDER, + TTK_GROUP("Button.focus", TTK_FILL_BOTH, + TTK_GROUP("Button.padding", TTK_FILL_BOTH, + TTK_NODE("Button.label", TTK_FILL_BOTH)))) +TTK_END_LAYOUT + /*------------------------------------------------------------------------ * +++ Checkbutton widget. */ @@ -569,6 +581,13 @@ static WidgetSpec CheckbuttonWidgetSpec = TtkWidgetDisplay /* displayProc */ }; +TTK_BEGIN_LAYOUT(CheckbuttonLayout) + TTK_GROUP("Checkbutton.padding", TTK_FILL_BOTH, + TTK_NODE("Checkbutton.indicator", TTK_PACK_LEFT) + TTK_GROUP("Checkbutton.focus", TTK_PACK_LEFT | TTK_STICK_W, + TTK_NODE("Checkbutton.label", TTK_FILL_BOTH))) +TTK_END_LAYOUT + /*------------------------------------------------------------------------ * +++ Radiobutton widget. */ @@ -740,6 +759,13 @@ static WidgetSpec RadiobuttonWidgetSpec = TtkWidgetDisplay /* displayProc */ }; +TTK_BEGIN_LAYOUT(RadiobuttonLayout) + TTK_GROUP("Radiobutton.padding", TTK_FILL_BOTH, + TTK_NODE("Radiobutton.indicator", TTK_PACK_LEFT) + TTK_GROUP("Radiobutton.focus", TTK_PACK_LEFT, + TTK_NODE("Radiobutton.label", TTK_FILL_BOTH))) +TTK_END_LAYOUT + /*------------------------------------------------------------------------ * +++ Menubutton widget. */ @@ -802,13 +828,29 @@ static WidgetSpec MenubuttonWidgetSpec = TtkWidgetDisplay /* displayProc */ }; -/* - * Initialization: +TTK_BEGIN_LAYOUT(MenubuttonLayout) + TTK_GROUP("Menubutton.border", TTK_FILL_BOTH, + TTK_GROUP("Menubutton.focus", 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", TTK_PACK_LEFT)))) +TTK_END_LAYOUT + +/*------------------------------------------------------------------------ + * +++ Initialization. */ MODULE_SCOPE void TtkButton_Init(Tcl_Interp *interp) { + Ttk_Theme theme = Ttk_GetDefaultTheme(interp); + + Ttk_RegisterLayout(theme, "TLabel", LabelLayout); + Ttk_RegisterLayout(theme, "TButton", ButtonLayout); + Ttk_RegisterLayout(theme, "TCheckbutton", CheckbuttonLayout); + Ttk_RegisterLayout(theme, "TRadiobutton", RadiobuttonLayout); + Ttk_RegisterLayout(theme, "TMenubutton", MenubuttonLayout); + RegisterWidget(interp, "ttk::label", &LabelWidgetSpec); RegisterWidget(interp, "ttk::button", &ButtonWidgetSpec); RegisterWidget(interp, "ttk::checkbutton", &CheckbuttonWidgetSpec); diff --git a/generic/ttk/ttkClamTheme.c b/generic/ttk/ttkClamTheme.c index f64b138..1ce75e0 100644 --- a/generic/ttk/ttkClamTheme.c +++ b/generic/ttk/ttkClamTheme.c @@ -1,10 +1,9 @@ /* - * $Id: ttkClamTheme.c,v 1.5 2007/01/11 19:59:26 jenglish Exp $ + * $Id: ttkClamTheme.c,v 1.6 2007/10/25 07:08:26 jenglish Exp $ * * Copyright (C) 2004 Joe English * - * Ttk widget set: another theme engine. - * Inspired by the XFCE family of Gnome themes. + * "clam" theme; inspired by the XFCE family of Gnome themes. */ #include @@ -131,7 +130,7 @@ static Ttk_ElementOptionSpec BorderElementOptions[] = { * the excess is used as padding. */ -static void BorderElementGeometry( +static void BorderElementSize( void *clientData, void *elementRecord, Tk_Window tkwin, int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) { @@ -184,7 +183,7 @@ static Ttk_ElementSpec BorderElementSpec = { TK_STYLE_VERSION_2, sizeof(BorderElement), BorderElementOptions, - BorderElementGeometry, + BorderElementSize, BorderElementDraw }; @@ -211,7 +210,7 @@ static Ttk_ElementOptionSpec FieldElementOptions[] = { {0,0,0} }; -static void FieldElementGeometry( +static void FieldElementSize( void *clientData, void *elementRecord, Tk_Window tkwin, int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) { @@ -237,7 +236,7 @@ static Ttk_ElementSpec FieldElementSpec = { TK_STYLE_VERSION_2, sizeof(FieldElement), FieldElementOptions, - FieldElementGeometry, + FieldElementSize, FieldElementDraw }; @@ -264,7 +263,7 @@ static Ttk_ElementSpec ComboboxFieldElementSpec = { TK_STYLE_VERSION_2, sizeof(FieldElement), FieldElementOptions, - FieldElementGeometry, + FieldElementSize, ComboboxFieldElementDraw }; @@ -297,8 +296,7 @@ static Ttk_ElementOptionSpec IndicatorElementOptions[] = { {0,0,0} }; -static void -IndicatorElementGeometry( +static void IndicatorElementSize( void *clientData, void *elementRecord, Tk_Window tkwin, int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) { @@ -309,8 +307,7 @@ IndicatorElementGeometry( *widthPtr = *heightPtr = size; } -static void -RadioIndicatorElementDraw( +static void RadioIndicatorElementDraw( void *clientData, void *elementRecord, Tk_Window tkwin, Drawable d, Ttk_Box b, unsigned state) { @@ -338,8 +335,7 @@ RadioIndicatorElementDraw( } } -static void -CheckIndicatorElementDraw( +static void CheckIndicatorElementDraw( void *clientData, void *elementRecord, Tk_Window tkwin, Drawable d, Ttk_Box b, unsigned state) { @@ -383,7 +379,7 @@ static Ttk_ElementSpec RadioIndicatorElementSpec = { TK_STYLE_VERSION_2, sizeof(IndicatorElement), IndicatorElementOptions, - IndicatorElementGeometry, + IndicatorElementSize, RadioIndicatorElementDraw }; @@ -391,7 +387,7 @@ static Ttk_ElementSpec CheckIndicatorElementSpec = { TK_STYLE_VERSION_2, sizeof(IndicatorElement), IndicatorElementOptions, - IndicatorElementGeometry, + IndicatorElementSize, CheckIndicatorElementDraw }; @@ -594,11 +590,11 @@ static Ttk_ElementSpec TroughElementSpec = { TK_STYLE_VERSION_2, sizeof(ScrollbarElement), ScrollbarElementOptions, - TtkNullElementGeometry, + TtkNullElementSize, TroughElementDraw }; -static void ThumbElementGeometry( +static void ThumbElementSize( void *clientData, void *elementRecord, Tk_Window tkwin, int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) { @@ -656,14 +652,14 @@ static Ttk_ElementSpec ThumbElementSpec = { TK_STYLE_VERSION_2, sizeof(ScrollbarElement), ScrollbarElementOptions, - ThumbElementGeometry, + ThumbElementSize, ThumbElementDraw }; /*------------------------------------------------------------------------ * +++ Slider element. */ -static void SliderElementGeometry( +static void SliderElementSize( void *clientData, void *elementRecord, Tk_Window tkwin, int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) { @@ -688,18 +684,18 @@ static Ttk_ElementSpec SliderElementSpec = { TK_STYLE_VERSION_2, sizeof(ScrollbarElement), ScrollbarElementOptions, - SliderElementGeometry, + SliderElementSize, ThumbElementDraw }; /*------------------------------------------------------------------------ * +++ Progress bar element */ -static void PbarElementGeometry( +static void PbarElementSize( void *clientData, void *elementRecord, Tk_Window tkwin, int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) { - SliderElementGeometry(clientData, elementRecord, tkwin, + SliderElementSize(clientData, elementRecord, tkwin, widthPtr, heightPtr, paddingPtr); *paddingPtr = Ttk_UniformPadding(2); } @@ -724,7 +720,7 @@ static Ttk_ElementSpec PbarElementSpec = { TK_STYLE_VERSION_2, sizeof(ScrollbarElement), ScrollbarElementOptions, - PbarElementGeometry, + PbarElementSize, PbarElementDraw }; @@ -734,7 +730,7 @@ static Ttk_ElementSpec PbarElementSpec = { */ static int ArrowElements[] = { ARROW_UP, ARROW_DOWN, ARROW_LEFT, ARROW_RIGHT }; -static void ArrowElementGeometry( +static void ArrowElementSize( void *clientData, void *elementRecord, Tk_Window tkwin, int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) { @@ -772,7 +768,7 @@ static Ttk_ElementSpec ArrowElementSpec = { TK_STYLE_VERSION_2, sizeof(ScrollbarElement), ScrollbarElementOptions, - ArrowElementGeometry, + ArrowElementSize, ArrowElementDraw }; @@ -803,7 +799,7 @@ static Ttk_ElementOptionSpec NotebookElementOptions[] = { {0,0,0} }; -static void TabElementGeometry( +static void TabElementSize( void *clientData, void *elementRecord, Tk_Window tkwin, int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) { @@ -854,11 +850,11 @@ static Ttk_ElementSpec TabElementSpec = TK_STYLE_VERSION_2, sizeof(NotebookElement), NotebookElementOptions, - TabElementGeometry, + TabElementSize, TabElementDraw }; -static void ClientElementGeometry( +static void ClientElementSize( void *clientData, void *elementRecord, Tk_Window tkwin, int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) { @@ -885,7 +881,7 @@ static Ttk_ElementSpec ClientElementSpec = TK_STYLE_VERSION_2, sizeof(NotebookElement), NotebookElementOptions, - ClientElementGeometry, + ClientElementSize, ClientElementDraw }; diff --git a/generic/ttk/ttkClassicTheme.c b/generic/ttk/ttkClassicTheme.c index 19164aa..c37b62e 100644 --- a/generic/ttk/ttkClassicTheme.c +++ b/generic/ttk/ttkClassicTheme.c @@ -1,11 +1,9 @@ /* - * $Id: ttkClassicTheme.c,v 1.3 2006/11/07 03:45:27 jenglish Exp $ + * $Id: ttkClassicTheme.c,v 1.4 2007/10/25 07:08:26 jenglish Exp $ * * Copyright (c) 2004, Joe English * - * Ttk widget set: classic theme. - * - * Implements the "classic" Motif-like Tk look. + * "classic" theme; implements the classic Motif-like Tk look. * */ @@ -35,10 +33,9 @@ static Ttk_ElementOptionSpec HighlightElementOptions[] = { {NULL} }; -static void -HighlightElementSize( - void *clientData, void *elementRecord, - Tk_Window tkwin, int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) +static void HighlightElementSize( + void *clientData, void *elementRecord, Tk_Window tkwin, + int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) { HighlightElement *hl = elementRecord; int highlightThickness = 0; @@ -47,9 +44,9 @@ HighlightElementSize( *paddingPtr = Ttk_UniformPadding((short)highlightThickness); } -static void -HighlightElementDraw(void *clientData, void *elementRecord, - Tk_Window tkwin, Drawable d, Ttk_Box b, unsigned int state) +static void HighlightElementDraw( + void *clientData, void *elementRecord, Tk_Window tkwin, + Drawable d, Ttk_Box b, unsigned int state) { HighlightElement *hl = elementRecord; int highlightThickness = 0; @@ -101,8 +98,7 @@ static Ttk_ElementOptionSpec ButtonBorderElementOptions[] = {NULL} }; -static void -ButtonBorderElementSize( +static void ButtonBorderElementSize( void *clientData, void *elementRecord, Tk_Window tkwin, int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) { @@ -124,8 +120,7 @@ ButtonBorderElementSize( * padding for default ring is drawn in the wrong color * when the button is active.) */ -static void -ButtonBorderElementDraw( +static void ButtonBorderElementDraw( void *clientData, void *elementRecord, Tk_Window tkwin, Drawable d, Ttk_Box b, unsigned int state) { diff --git a/generic/ttk/ttkDefaultTheme.c b/generic/ttk/ttkDefaultTheme.c index ec3ad93..f73abd8 100644 --- a/generic/ttk/ttkDefaultTheme.c +++ b/generic/ttk/ttkDefaultTheme.c @@ -1,4 +1,4 @@ -/* $Id: ttkDefaultTheme.c,v 1.7 2007/01/11 19:59:26 jenglish Exp $ +/* $Id: ttkDefaultTheme.c,v 1.8 2007/10/25 07:08:26 jenglish Exp $ * * Copyright (c) 2003, Joe English * @@ -276,8 +276,7 @@ static void BorderElementSize( *paddingPtr = Ttk_UniformPadding((short)borderWidth); } -static void -BorderElementDraw( +static void BorderElementDraw( void *clientData, void *elementRecord, Tk_Window tkwin, Drawable d, Ttk_Box b, unsigned int state) { diff --git a/generic/ttk/ttkElements.c b/generic/ttk/ttkElements.c index 3c5c4c8..958122c 100644 --- a/generic/ttk/ttkElements.c +++ b/generic/ttk/ttkElements.c @@ -1,4 +1,4 @@ -/* $Id: ttkElements.c,v 1.6 2007/01/11 19:59:26 jenglish Exp $ +/* $Id: ttkElements.c,v 1.7 2007/10/25 07:08:26 jenglish Exp $ * * Copyright (c) 2003, Joe English * @@ -25,7 +25,7 @@ /* public */ Ttk_ElementOptionSpec TtkNullElementOptions[] = { {NULL} }; /* public */ void -TtkNullElementGeometry( +TtkNullElementSize( void *clientData, void *elementRecord, Tk_Window tkwin, int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) { @@ -43,7 +43,7 @@ TtkNullElementDraw( TK_STYLE_VERSION_2, sizeof(NullElement), TtkNullElementOptions, - TtkNullElementGeometry, + TtkNullElementSize, TtkNullElementDraw }; @@ -67,15 +67,13 @@ static Ttk_ElementOptionSpec BackgroundElementOptions[] = {NULL} }; -static void -BackgroundElementGeometry( +static void BackgroundElementSize( void *clientData, void *elementRecord, Tk_Window tkwin, int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) { } -static void -BackgroundElementDraw( +static void BackgroundElementDraw( void *clientData, void *elementRecord, Tk_Window tkwin, Drawable d, Ttk_Box b, unsigned int state) { @@ -92,7 +90,7 @@ static Ttk_ElementSpec BackgroundElementSpec = TK_STYLE_VERSION_2, sizeof(BackgroundElement), BackgroundElementOptions, - BackgroundElementGeometry, + BackgroundElementSize, BackgroundElementDraw }; @@ -108,17 +106,16 @@ typedef struct { static Ttk_ElementOptionSpec BorderElementOptions[] = { - { "-background", TK_OPTION_BORDER, + { "-background", TK_OPTION_BORDER, Tk_Offset(BorderElement,borderObj), DEFAULT_BACKGROUND }, - { "-borderwidth", TK_OPTION_PIXELS, + { "-borderwidth", TK_OPTION_PIXELS, Tk_Offset(BorderElement,borderWidthObj), DEFAULT_BORDERWIDTH }, - { "-relief", TK_OPTION_RELIEF, + { "-relief", TK_OPTION_RELIEF, Tk_Offset(BorderElement,reliefObj), "flat" }, {NULL} }; -static void -BorderElementGeometry( +static void BorderElementSize( void *clientData, void *elementRecord, Tk_Window tkwin, int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) { @@ -128,8 +125,7 @@ BorderElementGeometry( *paddingPtr = Ttk_UniformPadding((short)borderWidth); } -static void -BorderElementDraw( +static void BorderElementDraw( void *clientData, void *elementRecord, Tk_Window tkwin, Drawable d, Ttk_Box b, unsigned int state) { @@ -152,7 +148,7 @@ static Ttk_ElementSpec BorderElementSpec = TK_STYLE_VERSION_2, sizeof(BorderElement), BorderElementOptions, - BorderElementGeometry, + BorderElementSize, BorderElementDraw }; @@ -173,8 +169,7 @@ static Ttk_ElementOptionSpec FieldElementOptions[] = { {NULL} }; -static void -FieldElementGeometry( +static void FieldElementSize( void *clientData, void *elementRecord, Tk_Window tkwin, int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) { @@ -184,8 +179,7 @@ FieldElementGeometry( *paddingPtr = Ttk_UniformPadding((short)borderWidth); } -static void -FieldElementDraw( +static void FieldElementDraw( void *clientData, void *elementRecord, Tk_Window tkwin, Drawable d, Ttk_Box b, unsigned int state) { @@ -203,7 +197,7 @@ static Ttk_ElementSpec FieldElementSpec = TK_STYLE_VERSION_2, sizeof(FieldElement), FieldElementOptions, - FieldElementGeometry, + FieldElementSize, FieldElementDraw }; @@ -213,7 +207,7 @@ static Ttk_ElementSpec FieldElementSpec = * * This element has no visual representation, only geometry. * It adds a (possibly non-uniform) internal border. - * In addition, if "-shiftrelief" is specified, + * In addition, if "-shiftrelief" is specified, * adds additional pixels to shift child elements "in" or "out" * depending on the -relief. */ @@ -235,8 +229,7 @@ static Ttk_ElementOptionSpec PaddingElementOptions[] = {NULL} }; -static void -PaddingElementGeometry( +static void PaddingElementSize( void *clientData, void *elementRecord, Tk_Window tkwin, int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) { @@ -251,8 +244,7 @@ PaddingElementGeometry( *paddingPtr = Ttk_RelievePadding(pad, relief, shiftRelief); } -static void -PaddingElementDraw( +static void PaddingElementDraw( void *clientData, void *elementRecord, Tk_Window tkwin, Drawable d, Ttk_Box b, unsigned int state) { @@ -264,7 +256,7 @@ static Ttk_ElementSpec PaddingElementSpec = TK_STYLE_VERSION_2, sizeof(PaddingElement), PaddingElementOptions, - PaddingElementGeometry, + PaddingElementSize, PaddingElementDraw }; @@ -309,8 +301,7 @@ static Ttk_ElementOptionSpec FocusElementOptions[] = { {NULL} }; -static void -FocusElementGeometry( +static void FocusElementSize( void *clientData, void *elementRecord, Tk_Window tkwin, int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) { @@ -321,8 +312,7 @@ FocusElementGeometry( *paddingPtr = Ttk_UniformPadding((short)focusThickness); } -static void -FocusElementDraw( +static void FocusElementDraw( void *clientData, void *elementRecord, Tk_Window tkwin, Drawable d, Ttk_Box b, unsigned int state) { @@ -340,7 +330,7 @@ static Ttk_ElementSpec FocusElementSpec = TK_STYLE_VERSION_2, sizeof(FocusElement), FocusElementOptions, - FocusElementGeometry, + FocusElementSize, FocusElementDraw }; @@ -366,16 +356,14 @@ static Ttk_ElementOptionSpec SeparatorElementOptions[] = {NULL} }; -static void -SeparatorElementGeometry( +static void SeparatorElementSize( void *clientData, void *elementRecord, Tk_Window tkwin, int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) { *widthPtr = *heightPtr = 2; } -static void -HorizontalSeparatorElementDraw( +static void HorizontalSeparatorElementDraw( void *clientData, void *elementRecord, Tk_Window tkwin, Drawable d, Ttk_Box b, unsigned int state) { @@ -388,8 +376,7 @@ HorizontalSeparatorElementDraw( XDrawLine(Tk_Display(tkwin), d, lightGC, b.x, b.y+1, b.x + b.width, b.y+1); } -static void -VerticalSeparatorElementDraw( +static void VerticalSeparatorElementDraw( void *clientData, void *elementRecord, Tk_Window tkwin, Drawable d, Ttk_Box b, unsigned int state) { @@ -402,8 +389,7 @@ VerticalSeparatorElementDraw( XDrawLine(Tk_Display(tkwin), d, lightGC, b.x+1, b.y, b.x+1, b.y+b.height); } -static void -GeneralSeparatorElementDraw( +static void GeneralSeparatorElementDraw( void *clientData, void *elementRecord, Tk_Window tkwin, Drawable d, Ttk_Box b, unsigned int state) { @@ -427,7 +413,7 @@ static Ttk_ElementSpec HorizontalSeparatorElementSpec = TK_STYLE_VERSION_2, sizeof(SeparatorElement), SeparatorElementOptions, - SeparatorElementGeometry, + SeparatorElementSize, HorizontalSeparatorElementDraw }; @@ -436,7 +422,7 @@ static Ttk_ElementSpec VerticalSeparatorElementSpec = TK_STYLE_VERSION_2, sizeof(SeparatorElement), SeparatorElementOptions, - SeparatorElementGeometry, + SeparatorElementSize, HorizontalSeparatorElementDraw }; @@ -445,7 +431,7 @@ static Ttk_ElementSpec SeparatorElementSpec = TK_STYLE_VERSION_2, sizeof(SeparatorElement), SeparatorElementOptions, - SeparatorElementGeometry, + SeparatorElementSize, GeneralSeparatorElementDraw }; @@ -540,8 +526,7 @@ static Ttk_ElementOptionSpec IndicatorElementOptions[] = /* * Checkbutton indicators (default): 3-D square. */ -static void -SquareIndicatorElementGeometry( +static void SquareIndicatorElementSize( void *clientData, void *elementRecord, Tk_Window tkwin, int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) { @@ -552,8 +537,7 @@ SquareIndicatorElementGeometry( *widthPtr = *heightPtr = diameter; } -static void -SquareIndicatorElementDraw( +static void SquareIndicatorElementDraw( void *clientData, void *elementRecord, Tk_Window tkwin, Drawable d, Ttk_Box b, unsigned int state) { @@ -582,8 +566,7 @@ SquareIndicatorElementDraw( /* * Radiobutton indicators: 3-D diamond. */ -static void -DiamondIndicatorElementGeometry( +static void DiamondIndicatorElementSize( void *clientData, void *elementRecord, Tk_Window tkwin, int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) { @@ -594,8 +577,7 @@ DiamondIndicatorElementGeometry( *widthPtr = *heightPtr = diameter + 3; } -static void -DiamondIndicatorElementDraw( +static void DiamondIndicatorElementDraw( void *clientData, void *elementRecord, Tk_Window tkwin, Drawable d, Ttk_Box b, unsigned int state) { @@ -636,7 +618,7 @@ static Ttk_ElementSpec CheckbuttonIndicatorElementSpec = TK_STYLE_VERSION_2, sizeof(IndicatorElement), IndicatorElementOptions, - SquareIndicatorElementGeometry, + SquareIndicatorElementSize, SquareIndicatorElementDraw }; @@ -645,7 +627,7 @@ static Ttk_ElementSpec RadiobuttonIndicatorElementSpec = TK_STYLE_VERSION_2, sizeof(IndicatorElement), IndicatorElementOptions, - DiamondIndicatorElementGeometry, + DiamondIndicatorElementSize, DiamondIndicatorElementDraw }; @@ -686,8 +668,7 @@ static Ttk_ElementOptionSpec MenuIndicatorElementOptions[] = { NULL } }; -static void -MenuIndicatorElementGeometry( +static void MenuIndicatorElementSize( void *clientData, void *elementRecord, Tk_Window tkwin, int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) { @@ -697,8 +678,7 @@ MenuIndicatorElementGeometry( Ttk_GetPaddingFromObj(NULL,tkwin,mi->marginObj,paddingPtr); } -static void -MenuIndicatorElementDraw( +static void MenuIndicatorElementDraw( void *clientData, void *elementRecord, Tk_Window tkwin, Drawable d, Ttk_Box b, unsigned int state) { @@ -719,7 +699,7 @@ static Ttk_ElementSpec MenuIndicatorElementSpec = TK_STYLE_VERSION_2, sizeof(MenuIndicatorElement), MenuIndicatorElementOptions, - MenuIndicatorElementGeometry, + MenuIndicatorElementSize, MenuIndicatorElementDraw }; @@ -742,7 +722,7 @@ typedef struct static Ttk_ElementOptionSpec ArrowElementOptions[] = { - { "-background", TK_OPTION_BORDER, + { "-background", TK_OPTION_BORDER, Tk_Offset(ArrowElement,borderObj), DEFAULT_BACKGROUND }, { "-relief",TK_OPTION_RELIEF, Tk_Offset(ArrowElement,reliefObj),"raised"}, @@ -750,15 +730,14 @@ static Ttk_ElementOptionSpec ArrowElementOptions[] = Tk_Offset(ArrowElement,borderWidthObj), "1" }, { "-arrowcolor",TK_OPTION_COLOR, Tk_Offset(ArrowElement,colorObj),"black"}, - { "-arrowsize", TK_OPTION_PIXELS, + { "-arrowsize", TK_OPTION_PIXELS, Tk_Offset(ArrowElement,sizeObj), "14" }, { NULL } }; static Ttk_Padding ArrowPadding = { 3,3,3,3 }; -static void -ArrowElementGeometry( +static void ArrowElementSize( void *clientData, void *elementRecord, Tk_Window tkwin, int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) { @@ -772,8 +751,7 @@ ArrowElementGeometry( *paddingPtr = ArrowPadding; } -static void -ArrowElementDraw( +static void ArrowElementDraw( void *clientData, void *elementRecord, Tk_Window tkwin, Drawable d, Ttk_Box b, unsigned int state) { @@ -798,11 +776,10 @@ static Ttk_ElementSpec ArrowElementSpec = TK_STYLE_VERSION_2, sizeof(ArrowElement), ArrowElementOptions, - ArrowElementGeometry, + ArrowElementSize, ArrowElementDraw }; - /*---------------------------------------------------------------------- * +++ Trough element. * @@ -827,8 +804,7 @@ static Ttk_ElementOptionSpec TroughElementOptions[] = { NULL } }; -static void -TroughElementGeometry( +static void TroughElementSize( void *clientData, void *elementRecord, Tk_Window tkwin, int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) { @@ -839,8 +815,7 @@ TroughElementGeometry( *paddingPtr = Ttk_UniformPadding((short)borderWidth); } -static void -TroughElementDraw( +static void TroughElementDraw( void *clientData, void *elementRecord, Tk_Window tkwin, Drawable d, Ttk_Box b, unsigned int state) { @@ -861,7 +836,7 @@ static Ttk_ElementSpec TroughElementSpec = TK_STYLE_VERSION_2, sizeof(TroughElement), TroughElementOptions, - TroughElementGeometry, + TroughElementSize, TroughElementDraw }; @@ -896,8 +871,7 @@ static Ttk_ElementOptionSpec ThumbElementOptions[] = { NULL } }; -static void -ThumbElementGeometry( +static void ThumbElementSize( void *clientData, void *elementRecord, Tk_Window tkwin, int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) { @@ -916,8 +890,7 @@ ThumbElementGeometry( } } -static void -ThumbElementDraw( +static void ThumbElementDraw( void *clientData, void *elementRecord, Tk_Window tkwin, Drawable d, Ttk_Box b, unsigned int state) { @@ -936,7 +909,7 @@ static Ttk_ElementSpec ThumbElementSpec = TK_STYLE_VERSION_2, sizeof(ThumbElement), ThumbElementOptions, - ThumbElementGeometry, + ThumbElementSize, ThumbElementDraw }; @@ -974,8 +947,7 @@ static Ttk_ElementOptionSpec SliderElementOptions[] = { NULL } }; -static void -SliderElementGeometry( +static void SliderElementSize( void *clientData, void *elementRecord, Tk_Window tkwin, int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) { @@ -999,8 +971,7 @@ SliderElementGeometry( } } -static void -SliderElementDraw( +static void SliderElementDraw( void *clientData, void *elementRecord, Tk_Window tkwin, Drawable d, Ttk_Box b, unsigned int state) { @@ -1047,7 +1018,7 @@ static Ttk_ElementSpec SliderElementSpec = TK_STYLE_VERSION_2, sizeof(SliderElement), SliderElementOptions, - SliderElementGeometry, + SliderElementSize, SliderElementDraw }; @@ -1057,7 +1028,7 @@ static Ttk_ElementSpec SliderElementSpec = * * -thickness specifies the size along the short axis of the bar. * -length specifies the default size along the long axis; - * the bar will be this long in indeterminate mode. + * the bar will be this long in indeterminate mode. */ #define DEFAULT_PBAR_THICKNESS "15" @@ -1090,7 +1061,7 @@ static Ttk_ElementOptionSpec PbarElementOptions[] = { NULL } }; -static void PbarElementGeometry( +static void PbarElementSize( void *clientData, void *elementRecord, Tk_Window tkwin, int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) { @@ -1136,7 +1107,7 @@ static Ttk_ElementSpec PbarElementSpec = { TK_STYLE_VERSION_2, sizeof(PbarElement), PbarElementOptions, - PbarElementGeometry, + PbarElementSize, PbarElementDraw }; @@ -1157,8 +1128,7 @@ static Ttk_ElementOptionSpec TabElementOptions[] = { {0,0,0,0} }; -static void -TabElementGeometry( +static void TabElementSize( void *clientData, void *elementRecord, Tk_Window tkwin, int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) { @@ -1169,8 +1139,7 @@ TabElementGeometry( paddingPtr->bottom = 0; } -static void -TabElementDraw( +static void TabElementDraw( void *clientData, void *elementRecord, Tk_Window tkwin, Drawable d, Ttk_Box b, unsigned int state) { @@ -1227,7 +1196,7 @@ static Ttk_ElementSpec TabElementSpec = TK_STYLE_VERSION_2, sizeof(TabElement), TabElementOptions, - TabElementGeometry, + TabElementSize, TabElementDraw }; @@ -1238,8 +1207,7 @@ static Ttk_ElementSpec TabElementSpec = typedef TabElement ClientElement; #define ClientElementOptions TabElementOptions -static void -ClientElementDraw( +static void ClientElementDraw( void *clientData, void *elementRecord, Tk_Window tkwin, Drawable d, Ttk_Box b, unsigned int state) { @@ -1253,8 +1221,7 @@ ClientElementDraw( b.x, b.y, b.width, b.height, borderWidth,TK_RELIEF_RAISED); } -static void -ClientElementGeometry( +static void ClientElementSize( void *clientData, void *elementRecord, Tk_Window tkwin, int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) { @@ -1269,97 +1236,13 @@ static Ttk_ElementSpec ClientElementSpec = TK_STYLE_VERSION_2, sizeof(ClientElement), ClientElementOptions, - ClientElementGeometry, + ClientElementSize, ClientElementDraw }; - -/*------------------------------------------------------------------------ - * +++ Widget layouts. - */ - -TTK_BEGIN_LAYOUT(FrameLayout) - TTK_NODE("Frame.border", TTK_FILL_BOTH) -TTK_END_LAYOUT - -TTK_BEGIN_LAYOUT(LabelframeLayout) - /* Note: labelframe widget does its own layout */ - TTK_NODE("Labelframe.border", TTK_FILL_BOTH) - TTK_NODE("Labelframe.text", TTK_FILL_BOTH) -TTK_END_LAYOUT - -TTK_BEGIN_LAYOUT(LabelLayout) - TTK_GROUP("Label.border", TTK_FILL_BOTH|TTK_BORDER, - TTK_GROUP("Label.padding", TTK_FILL_BOTH|TTK_BORDER, - TTK_NODE("Label.label", TTK_FILL_BOTH))) -TTK_END_LAYOUT - -TTK_BEGIN_LAYOUT(ButtonLayout) - TTK_GROUP("Button.border", TTK_FILL_BOTH|TTK_BORDER, - 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_BEGIN_LAYOUT(CheckbuttonLayout) - TTK_GROUP("Checkbutton.padding", TTK_FILL_BOTH, - TTK_NODE("Checkbutton.indicator", TTK_PACK_LEFT) - TTK_GROUP("Checkbutton.focus", TTK_PACK_LEFT | TTK_STICK_W, - TTK_NODE("Checkbutton.label", TTK_FILL_BOTH))) -TTK_END_LAYOUT - -TTK_BEGIN_LAYOUT(RadiobuttonLayout) - TTK_GROUP("Radiobutton.padding", TTK_FILL_BOTH, - TTK_NODE("Radiobutton.indicator", TTK_PACK_LEFT) - TTK_GROUP("Radiobutton.focus", TTK_PACK_LEFT, - TTK_NODE("Radiobutton.label", TTK_FILL_BOTH))) -TTK_END_LAYOUT - -TTK_BEGIN_LAYOUT(MenubuttonLayout) - TTK_GROUP("Menubutton.border", TTK_FILL_BOTH, - TTK_GROUP("Menubutton.focus", 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", TTK_PACK_LEFT)))) -TTK_END_LAYOUT - -TTK_BEGIN_LAYOUT(VerticalScrollbarLayout) - 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_NODE( - "Vertical.Scrollbar.thumb", TTK_PACK_TOP|TTK_EXPAND|TTK_FILL_BOTH)) -TTK_END_LAYOUT - -TTK_BEGIN_LAYOUT(HorizontalScrollbarLayout) - 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_NODE( - "Horizontal.Scrollbar.thumb", TTK_PACK_LEFT|TTK_EXPAND|TTK_FILL_BOTH)) -TTK_END_LAYOUT - -TTK_BEGIN_LAYOUT(VerticalScaleLayout) - TTK_GROUP("Vertical.Scale.trough", TTK_FILL_BOTH, - TTK_NODE("Vertical.Scale.slider", TTK_PACK_TOP) ) -TTK_END_LAYOUT - -TTK_BEGIN_LAYOUT(HorizontalScaleLayout) - TTK_GROUP("Horizontal.Scale.trough", TTK_FILL_BOTH, - TTK_NODE("Horizontal.Scale.slider", TTK_PACK_LEFT) ) -TTK_END_LAYOUT - -TTK_BEGIN_LAYOUT(SeparatorLayout) - TTK_NODE("Separator.separator", TTK_FILL_BOTH) -TTK_END_LAYOUT - -TTK_BEGIN_LAYOUT(SizegripLayout) - TTK_NODE("Sizegrip.sizegrip", TTK_PACK_BOTTOM|TTK_STICK_S|TTK_STICK_E) -TTK_END_LAYOUT - /*---------------------------------------------------------------------- * TtkElements_Init -- - * Register elements and default layouts. + * Register default element implementations. */ MODULE_SCOPE @@ -1406,9 +1289,9 @@ void TtkElements_Init(Tcl_Interp *interp) Ttk_RegisterElement(interp, theme, "separator", &SeparatorElementSpec, NULL); - Ttk_RegisterElement(interp, theme, "hseparator", + Ttk_RegisterElement(interp, theme, "hseparator", &HorizontalSeparatorElementSpec, NULL); - Ttk_RegisterElement(interp, theme, "vseparator", + Ttk_RegisterElement(interp, theme, "vseparator", &VerticalSeparatorElementSpec, NULL); Ttk_RegisterElement(interp, theme, "sizegrip", &SizegripElementSpec, NULL); @@ -1417,25 +1300,6 @@ void TtkElements_Init(Tcl_Interp *interp) Ttk_RegisterElement(interp, theme, "client", &ClientElementSpec, NULL); /* - * Layouts: - */ - Ttk_RegisterLayout(theme, "TFrame", FrameLayout); - Ttk_RegisterLayout(theme, "TLabelframe", LabelframeLayout); - Ttk_RegisterLayout(theme, "TLabel", LabelLayout); - Ttk_RegisterLayout(theme, "TButton", ButtonLayout); - Ttk_RegisterLayout(theme, "TCheckbutton", CheckbuttonLayout); - Ttk_RegisterLayout(theme, "TRadiobutton", RadiobuttonLayout); - Ttk_RegisterLayout(theme, "TMenubutton", MenubuttonLayout); - Ttk_RegisterLayout(theme, - "Vertical.TScrollbar", VerticalScrollbarLayout); - Ttk_RegisterLayout(theme, - "Horizontal.TScrollbar", HorizontalScrollbarLayout); - Ttk_RegisterLayout(theme, "Vertical.TScale", VerticalScaleLayout); - Ttk_RegisterLayout(theme, "Horizontal.TScale", HorizontalScaleLayout); - Ttk_RegisterLayout(theme, "TSeparator", SeparatorLayout); - Ttk_RegisterLayout(theme, "TSizegrip", SizegripLayout); - - /* * Register "default" as a user-loadable theme (for now): */ Tcl_PkgProvide(interp, "ttk::theme::default", TTK_VERSION); diff --git a/generic/ttk/ttkFrame.c b/generic/ttk/ttkFrame.c index 08f1f7f..b6f8fe8 100644 --- a/generic/ttk/ttkFrame.c +++ b/generic/ttk/ttkFrame.c @@ -1,4 +1,4 @@ -/* $Id: ttkFrame.c,v 1.6 2007/06/09 21:45:44 jenglish Exp $ +/* $Id: ttkFrame.c,v 1.7 2007/10/25 07:08:26 jenglish Exp $ * Copyright (c) 2004, Joe English * * ttk::frame and ttk::labelframe widgets. @@ -165,6 +165,10 @@ static WidgetSpec FrameWidgetSpec = TtkWidgetDisplay /* displayProc */ }; +TTK_BEGIN_LAYOUT(FrameLayout) + TTK_NODE("Frame.border", TTK_FILL_BOTH) +TTK_END_LAYOUT + /* ====================================================================== * +++ Labelframe widget: */ @@ -587,6 +591,11 @@ static WidgetSpec LabelframeWidgetSpec = TtkWidgetDisplay /* displayProc */ }; +TTK_BEGIN_LAYOUT(LabelframeLayout) + TTK_NODE("Labelframe.border", TTK_FILL_BOTH) + TTK_NODE("Labelframe.text", TTK_FILL_BOTH) +TTK_END_LAYOUT + /* ====================================================================== * +++ Initialization: */ @@ -594,6 +603,12 @@ static WidgetSpec LabelframeWidgetSpec = MODULE_SCOPE void TtkFrame_Init(Tcl_Interp *interp) { + Ttk_Theme theme = Ttk_GetDefaultTheme(interp); + + Ttk_RegisterLayout(theme, "TFrame", FrameLayout); + Ttk_RegisterLayout(theme, "TLabelframe", LabelframeLayout); + RegisterWidget(interp, "ttk::frame", &FrameWidgetSpec); RegisterWidget(interp, "ttk::labelframe", &LabelframeWidgetSpec); } + diff --git a/generic/ttk/ttkScale.c b/generic/ttk/ttkScale.c index 1f32d13..063116d 100644 --- a/generic/ttk/ttkScale.c +++ b/generic/ttk/ttkScale.c @@ -1,4 +1,4 @@ -/* $Id: ttkScale.c,v 1.5 2007/01/11 14:49:47 jenglish Exp $ +/* $Id: ttkScale.c,v 1.6 2007/10/25 07:08:26 jenglish Exp $ * Copyright (C) 2004 Pat Thoyts * * ttk::scale widget. @@ -501,12 +501,27 @@ static WidgetSpec ScaleWidgetSpec = TtkWidgetDisplay /* displayProc */ }; +TTK_BEGIN_LAYOUT(VerticalScaleLayout) + TTK_GROUP("Vertical.Scale.trough", TTK_FILL_BOTH, + TTK_NODE("Vertical.Scale.slider", TTK_PACK_TOP) ) +TTK_END_LAYOUT + +TTK_BEGIN_LAYOUT(HorizontalScaleLayout) + TTK_GROUP("Horizontal.Scale.trough", TTK_FILL_BOTH, + TTK_NODE("Horizontal.Scale.slider", TTK_PACK_LEFT) ) +TTK_END_LAYOUT + /* * Initialization. */ MODULE_SCOPE void TtkScale_Init(Tcl_Interp *interp) { + Ttk_Theme theme = Ttk_GetDefaultTheme(interp); + + Ttk_RegisterLayout(theme, "Vertical.TScale", VerticalScaleLayout); + Ttk_RegisterLayout(theme, "Horizontal.TScale", HorizontalScaleLayout); + RegisterWidget(interp, "ttk::scale", &ScaleWidgetSpec); } diff --git a/generic/ttk/ttkScrollbar.c b/generic/ttk/ttkScrollbar.c index c3be30f..1e744c2 100644 --- a/generic/ttk/ttkScrollbar.c +++ b/generic/ttk/ttkScrollbar.c @@ -1,4 +1,4 @@ -/* $Id: ttkScrollbar.c,v 1.5 2007/01/11 14:49:47 jenglish Exp $ +/* $Id: ttkScrollbar.c,v 1.6 2007/10/25 07:08:26 jenglish Exp $ * Copyright (c) 2003, Joe English * * ttk::scrollbar widget. @@ -313,6 +313,22 @@ static WidgetSpec ScrollbarWidgetSpec = TtkWidgetDisplay /* displayProc */ }; +TTK_BEGIN_LAYOUT(VerticalScrollbarLayout) + 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_NODE( + "Vertical.Scrollbar.thumb", TTK_PACK_TOP|TTK_EXPAND|TTK_FILL_BOTH)) +TTK_END_LAYOUT + +TTK_BEGIN_LAYOUT(HorizontalScrollbarLayout) + 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_NODE( + "Horizontal.Scrollbar.thumb", TTK_PACK_LEFT|TTK_EXPAND|TTK_FILL_BOTH)) +TTK_END_LAYOUT + /*------------------------------------------------------------------------ * +++ Initialization. */ @@ -320,7 +336,12 @@ static WidgetSpec ScrollbarWidgetSpec = MODULE_SCOPE void TtkScrollbar_Init(Tcl_Interp *interp) { + Ttk_Theme theme = Ttk_GetDefaultTheme(interp); + + Ttk_RegisterLayout(theme,"Vertical.TScrollbar",VerticalScrollbarLayout); + Ttk_RegisterLayout(theme,"Horizontal.TScrollbar",HorizontalScrollbarLayout); + RegisterWidget(interp, "ttk::scrollbar", &ScrollbarWidgetSpec); -} +} /*EOF*/ diff --git a/generic/ttk/ttkSeparator.c b/generic/ttk/ttkSeparator.c index 000db13..b202c35 100644 --- a/generic/ttk/ttkSeparator.c +++ b/generic/ttk/ttkSeparator.c @@ -1,4 +1,4 @@ -/* $Id: ttkSeparator.c,v 1.5 2007/01/11 14:49:47 jenglish Exp $ +/* $Id: ttkSeparator.c,v 1.6 2007/10/25 07:08:26 jenglish Exp $ * * Copyright (c) 2004, Joe English * @@ -78,6 +78,10 @@ static WidgetSpec SeparatorWidgetSpec = TtkWidgetDisplay /* displayProc */ }; +TTK_BEGIN_LAYOUT(SeparatorLayout) + TTK_NODE("Separator.separator", TTK_FILL_BOTH) +TTK_END_LAYOUT + /* +++ Sizegrip widget: * Has no options or methods other than the standard ones. */ @@ -108,12 +112,21 @@ static WidgetSpec SizegripWidgetSpec = TtkWidgetDisplay /* displayProc */ }; +TTK_BEGIN_LAYOUT(SizegripLayout) + TTK_NODE("Sizegrip.sizegrip", TTK_PACK_BOTTOM|TTK_STICK_S|TTK_STICK_E) +TTK_END_LAYOUT + /* +++ Initialization: */ MODULE_SCOPE void TtkSeparator_Init(Tcl_Interp *interp) { + Ttk_Theme theme = Ttk_GetDefaultTheme(interp); + + Ttk_RegisterLayout(theme, "TSeparator", SeparatorLayout); + Ttk_RegisterLayout(theme, "TSizegrip", SizegripLayout); + RegisterWidget(interp, "ttk::separator", &SeparatorWidgetSpec); RegisterWidget(interp, "ttk::sizegrip", &SizegripWidgetSpec); } diff --git a/generic/ttk/ttkSquare.c b/generic/ttk/ttkSquare.c index 4f1bd0f..365cb10 100644 --- a/generic/ttk/ttkSquare.c +++ b/generic/ttk/ttkSquare.c @@ -2,7 +2,7 @@ * * Minimal sample ttk widget. * - * $Id: ttkSquare.c,v 1.4 2007/01/11 14:49:47 jenglish Exp $ + * $Id: ttkSquare.c,v 1.5 2007/10/25 07:08:26 jenglish Exp $ */ #include @@ -201,10 +201,9 @@ static Ttk_ElementOptionSpec SquareElementOptions[] = * size and padding information */ -static void -SquareElementGeometry( - void *clientData, void *elementRecord, - Tk_Window tkwin, int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) +static void SquareElementSize( + void *clientData, void *elementRecord, Tk_Window tkwin, + int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) { SquareElement *square = elementRecord; int borderWidth = 0; @@ -219,9 +218,9 @@ SquareElementGeometry( * Draw the element in the box provided. */ -static void -SquareElementDraw(void *clientData, void *elementRecord, - Tk_Window tkwin, Drawable d, Ttk_Box b, unsigned int state) +static void SquareElementDraw( + void *clientData, void *elementRecord, Tk_Window tkwin, + Drawable d, Ttk_Box b, unsigned int state) { SquareElement *square = elementRecord; Tk_3DBorder border = NULL, foreground = NULL; @@ -241,7 +240,7 @@ static Ttk_ElementSpec SquareElementSpec = TK_STYLE_VERSION_2, sizeof(SquareElement), SquareElementOptions, - SquareElementGeometry, + SquareElementSize, SquareElementDraw }; diff --git a/generic/ttk/ttkTheme.h b/generic/ttk/ttkTheme.h index 1567cd0..adca259 100644 --- a/generic/ttk/ttkTheme.h +++ b/generic/ttk/ttkTheme.h @@ -1,4 +1,4 @@ -/* $Id: ttkTheme.h,v 1.10 2007/10/15 15:03:41 jenglish Exp $ +/* $Id: ttkTheme.h,v 1.11 2007/10/25 07:08:26 jenglish Exp $ * Copyright (c) 2003 Joe English. Freely redistributable. * * Declarations for Tk theme engine. @@ -270,7 +270,7 @@ typedef struct { Tcl_Obj *unused; } NullElement; -MODULE_SCOPE void TtkNullElementGeometry +MODULE_SCOPE void TtkNullElementSize (void *, void *, Tk_Window, int *, int *, Ttk_Padding *); MODULE_SCOPE void TtkNullElementDraw (void *, void *, Tk_Window, Drawable, Ttk_Box, Ttk_State); diff --git a/generic/ttk/ttkTreeview.c b/generic/ttk/ttkTreeview.c index f71a163..9d03683 100644 --- a/generic/ttk/ttkTreeview.c +++ b/generic/ttk/ttkTreeview.c @@ -1,4 +1,4 @@ -/* $Id: ttkTreeview.c,v 1.18 2007/10/15 15:03:41 jenglish Exp $ +/* $Id: ttkTreeview.c,v 1.19 2007/10/25 07:08:26 jenglish Exp $ * Copyright (c) 2004, Joe English * * ttk::treeview widget implementation. @@ -3178,7 +3178,7 @@ static Ttk_ElementSpec RowElementSpec = TK_STYLE_VERSION_2, sizeof(RowElement), RowElementOptions, - TtkNullElementGeometry, + TtkNullElementSize, RowElementDraw }; diff --git a/macosx/ttkMacOSXTheme.c b/macosx/ttkMacOSXTheme.c index a65fff0..8096969 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.10 2007/10/17 18:21:24 das Exp $ + * RCS: @(#) $Id: ttkMacOSXTheme.c,v 1.11 2007/10/25 07:08:26 jenglish Exp $ */ #include "tkMacOSXPrivate.h" @@ -158,7 +158,7 @@ static ThemeButtonDrawInfo computeButtonDrawInfo( return info; } -static void ButtonElementGeometryNoPadding( +static void ButtonElementSizeNoPadding( void *clientData, void *elementRecord, Tk_Window tkwin, int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) { @@ -172,7 +172,7 @@ static void ButtonElementGeometryNoPadding( } } -static void ButtonElementGeometry( +static void ButtonElementSize( void *clientData, void *elementRecord, Tk_Window tkwin, int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) { @@ -181,7 +181,7 @@ static void ButtonElementGeometry( Rect scratchRect, contentsRect; const int scratchSize = 100; - ButtonElementGeometryNoPadding( + ButtonElementSizeNoPadding( clientData, elementRecord, tkwin, widthPtr, heightPtr, paddingPtr); @@ -225,7 +225,7 @@ static Ttk_ElementSpec ButtonElementSpec = { TK_STYLE_VERSION_2, sizeof(NullElement), TtkNullElementOptions, - ButtonElementGeometry, + ButtonElementSize, ButtonElementDraw }; @@ -253,7 +253,7 @@ static Ttk_StateTable TabStyleTable[] = { static const int TAB_HEIGHT = 21; static const int TAB_OVERLAP = 3; -static void TabElementGeometry( +static void TabElementSize( void *clientData, void *elementRecord, Tk_Window tkwin, int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) { @@ -278,13 +278,13 @@ static Ttk_ElementSpec TabElementSpec = { TK_STYLE_VERSION_2, sizeof(NullElement), TtkNullElementOptions, - TabElementGeometry, + TabElementSize, TabElementDraw }; /* Notebook panes: */ -static void PaneElementGeometry( +static void PaneElementSize( void *clientData, void *elementRecord, Tk_Window tkwin, int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) { @@ -308,7 +308,7 @@ static Ttk_ElementSpec PaneElementSpec = { TK_STYLE_VERSION_2, sizeof(NullElement), TtkNullElementOptions, - PaneElementGeometry, + PaneElementSize, PaneElementDraw }; @@ -321,7 +321,7 @@ static Ttk_ElementSpec PaneElementSpec = { * "Maximum of 2 pixels thick" is apparently a lie; * looks more like 4 to me with shading. */ -static void GroupElementGeometry( +static void GroupElementSize( void *clientData, void *elementRecord, Tk_Window tkwin, int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) { @@ -344,7 +344,7 @@ static Ttk_ElementSpec GroupElementSpec = { TK_STYLE_VERSION_2, sizeof(NullElement), TtkNullElementOptions, - GroupElementGeometry, + GroupElementSize, GroupElementDraw }; @@ -364,7 +364,7 @@ static Ttk_ElementOptionSpec EntryElementOptions[] = { {0} }; -static void EntryElementGeometry( +static void EntryElementSize( void *clientData, void *elementRecord, Tk_Window tkwin, int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) { @@ -403,7 +403,7 @@ static Ttk_ElementSpec EntryElementSpec = { TK_STYLE_VERSION_2, sizeof(EntryElement), EntryElementOptions, - EntryElementGeometry, + EntryElementSize, EntryElementDraw }; @@ -413,8 +413,8 @@ static Ttk_ElementSpec EntryElementSpec = { * function in the Appearance Manager reference. */ -static void PopupArrowElementGeometry( - void *clientData, void *elementRecord, Tk_Window tkwin, +static void PopupArrowElementSize( + void *clientData, void *elementRecord, Tk_Window tkwin, int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) { *widthPtr = 12; /* wild-assed guess */ @@ -456,7 +456,7 @@ static Ttk_ElementSpec PopupArrowElementSpec = { TK_STYLE_VERSION_2, sizeof(NullElement), TtkNullElementOptions, - PopupArrowElementGeometry, + PopupArrowElementSize, PopupArrowElementDraw }; @@ -496,7 +496,7 @@ static Ttk_ElementOptionSpec TrackElementOptions[] = { {0,0,0} }; -static void TrackElementGeometry( +static void TrackElementSize( void *clientData, void *elementRecord, Tk_Window tkwin, int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) { @@ -557,7 +557,7 @@ static Ttk_ElementSpec TrackElementSpec = { TK_STYLE_VERSION_2, sizeof(TrackElement), TrackElementOptions, - TrackElementGeometry, + TrackElementSize, TrackElementDraw }; @@ -570,7 +570,7 @@ static Ttk_ElementSpec TrackElementSpec = { * figure out how to get the Appearance Manager to tell me the * slider size. */ -static void SliderElementGeometry( +static void SliderElementSize( void *clientData, void *elementRecord, Tk_Window tkwin, int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) { @@ -581,7 +581,7 @@ static Ttk_ElementSpec SliderElementSpec = { TK_STYLE_VERSION_2, sizeof(NullElement), TtkNullElementOptions, - SliderElementGeometry, + SliderElementSize, TtkNullElementDraw }; @@ -615,7 +615,7 @@ static Ttk_ElementOptionSpec PbarElementOptions[] = { {0,0,0,0} }; -static void PbarElementGeometry( +static void PbarElementSize( void *clientData, void *elementRecord, Tk_Window tkwin, int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) { @@ -665,7 +665,7 @@ static Ttk_ElementSpec PbarElementSpec = { TK_STYLE_VERSION_2, sizeof(PbarElement), PbarElementOptions, - PbarElementGeometry, + PbarElementSize, PbarElementDraw }; @@ -801,7 +801,7 @@ static Ttk_ElementSpec BackgroundElementSpec = { TK_STYLE_VERSION_2, sizeof(NullElement), TtkNullElementOptions, - TtkNullElementGeometry, + TtkNullElementSize, BackgroundElementDraw }; @@ -838,7 +838,7 @@ static Ttk_ElementSpec ToolbarBackgroundElementSpec = { TK_STYLE_VERSION_2, sizeof(NullElement), TtkNullElementOptions, - TtkNullElementGeometry, + TtkNullElementSize, ToolbarBackgroundElementDraw }; @@ -875,7 +875,7 @@ static Ttk_ElementSpec TreeHeaderElementSpec = { TK_STYLE_VERSION_2, sizeof(NullElement), TtkNullElementOptions, - ButtonElementGeometryNoPadding, + ButtonElementSizeNoPadding, TreeHeaderElementDraw }; diff --git a/win/ttkWinMonitor.c b/win/ttkWinMonitor.c index 2c9229f..cdfc2e6 100644 --- a/win/ttkWinMonitor.c +++ b/win/ttkWinMonitor.c @@ -1,4 +1,4 @@ -/* $Id: ttkWinMonitor.c,v 1.12 2007/09/08 16:13:45 dkf Exp $ +/* $Id: ttkWinMonitor.c,v 1.13 2007/10/25 07:08:26 jenglish Exp $ */ #ifdef _MSC_VER @@ -56,9 +56,7 @@ static SystemColorEntry sysColors[] = { { NULL, 0 } }; -static void -RegisterSystemColors( - Tcl_Interp *interp) +static void RegisterSystemColors(Tcl_Interp *interp) { Ttk_ResourceCache cache = Ttk_GetResourceCache(interp); SystemColorEntry *sysColor; @@ -74,14 +72,12 @@ RegisterSystemColors( } static HWND -CreateThemeMonitorWindow( - HINSTANCE hinst, - Tcl_Interp *interp) +CreateThemeMonitorWindow(HINSTANCE hinst, Tcl_Interp *interp) { WNDCLASSEX wc; - HWND hwnd = NULL; - CHAR title[32] = "TtkMonitorWindow"; - CHAR name[32] = "TtkMonitorClass"; + HWND hwnd = NULL; + CHAR title[32] = "TtkMonitorWindow"; + CHAR name[32] = "TtkMonitorClass"; wc.cbSize = sizeof(WNDCLASSEX); wc.style = CS_HREDRAW | CS_VREDRAW; @@ -97,9 +93,9 @@ CreateThemeMonitorWindow( wc.lpszClassName = name; if (RegisterClassEx(&wc)) { - hwnd = CreateWindow(name, title, WS_OVERLAPPEDWINDOW, - CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, - NULL, NULL, hinst, NULL); + hwnd = CreateWindow( name, title, WS_OVERLAPPEDWINDOW, + CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, + NULL, NULL, hinst, NULL ); #ifdef _WIN64 SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG)interp); #else @@ -112,20 +108,14 @@ CreateThemeMonitorWindow( } static void -DestroyThemeMonitorWindow( - void *clientData) +DestroyThemeMonitorWindow(void *clientData) { HWND hwnd = (HWND)clientData; - DestroyWindow(hwnd); } static LRESULT WINAPI -WndProc( - HWND hwnd, - UINT msg, - WPARAM wp, - LPARAM lp) +WndProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp) { #ifdef _WIN64 Tcl_Interp *interp = (Tcl_Interp *)GetWindowLongPtr(hwnd, GWLP_USERDATA); @@ -144,8 +134,9 @@ WndProc( case WM_THEMECHANGED: /* - * Reset the application theme to 'xpnative' if present, which will in - * turn fall back to 'winnative' if XP theming is disabled. + * Reset the application theme to 'xpnative' if present, + * which will in turn fall back to 'winnative' if XP theming + * is disabled. */ theme = Ttk_GetTheme(interp, "xpnative"); @@ -165,9 +156,7 @@ WndProc( MODULE_SCOPE int TtkWinTheme_Init(Tcl_Interp *, HWND hwnd); MODULE_SCOPE int TtkXPTheme_Init(Tcl_Interp *, HWND hwnd); -MODULE_SCOPE int -Ttk_WinPlatformInit( - Tcl_Interp *interp) +MODULE_SCOPE int Ttk_WinPlatformInit(Tcl_Interp *interp) { HWND hwnd; @@ -179,11 +168,3 @@ Ttk_WinPlatformInit( return TCL_OK; } - -/* - * Local Variables: - * mode: c - * c-basic-offset: 4 - * fill-column: 78 - * End: - */ diff --git a/win/ttkWinTheme.c b/win/ttkWinTheme.c index a05c0de..41754ee 100644 --- a/win/ttkWinTheme.c +++ b/win/ttkWinTheme.c @@ -1,6 +1,6 @@ /* winTheme.c - Copyright (C) 2004 Pat Thoyts * - * $Id: ttkWinTheme.c,v 1.7 2007/09/08 16:13:45 dkf Exp $ + * $Id: ttkWinTheme.c,v 1.8 2007/10/25 07:08:26 jenglish Exp $ */ #ifdef _MSC_VER @@ -16,18 +16,14 @@ #endif #include "ttk/ttkTheme.h" - + /* * BoxToRect -- * Helper routine. Converts a Ttk_Box to a Win32 RECT. */ - -static RECT -BoxToRect( - Ttk_Box b) +static RECT BoxToRect(Ttk_Box b) { RECT rc; - rc.top = b.y; rc.left = b.x; rc.bottom = b.y + b.height; @@ -37,39 +33,31 @@ BoxToRect( /* * ReliefToEdge -- - * Convert a Tk "relief" value into an Windows "edge" value. NB: Caller - * must check for RELIEF_FLAT and RELIEF_SOLID, which must be handled - * specially. + * Convert a Tk "relief" value into an Windows "edge" value. + * NB: Caller must check for RELIEF_FLAT and RELIEF_SOLID, + * 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 drawing - * anything. + * Passing the BF_FLAT flag to DrawEdge() yields something similar + * to TK_RELIEF_SOLID. TK_RELIEF_FLAT can be implemented by not + * drawing anything. */ - -static unsigned int -ReliefToEdge( - int relief) +static unsigned int ReliefToEdge(int relief) { switch (relief) { - case TK_RELIEF_RAISED: - return EDGE_RAISED; - case TK_RELIEF_SUNKEN: - return EDGE_SUNKEN; - case TK_RELIEF_RIDGE: - return EDGE_BUMP; - case TK_RELIEF_GROOVE: - return EDGE_ETCHED; - case TK_RELIEF_SOLID: - return BDR_RAISEDOUTER; - default: - case TK_RELIEF_FLAT: - return BDR_RAISEDOUTER; + case TK_RELIEF_RAISED: return EDGE_RAISED; + case TK_RELIEF_SUNKEN: return EDGE_SUNKEN; + case TK_RELIEF_RIDGE: return EDGE_BUMP; + case TK_RELIEF_GROOVE: return EDGE_ETCHED; + case TK_RELIEF_SOLID: return BDR_RAISEDOUTER; + default: + case TK_RELIEF_FLAT: return BDR_RAISEDOUTER; } } /* ---------------------------------------------------------------------- */ -static Ttk_StateTable checkbutton_statemap[] = { +static Ttk_StateTable checkbutton_statemap[] = +{ { DFCS_CHECKED|DFCS_INACTIVE, TTK_STATE_SELECTED|TTK_STATE_DISABLED, 0 }, { DFCS_CHECKED|DFCS_PUSHED, TTK_STATE_SELECTED|TTK_STATE_PRESSED, 0 }, { DFCS_CHECKED, TTK_STATE_SELECTED, 0 }, @@ -78,24 +66,27 @@ static Ttk_StateTable checkbutton_statemap[] = { { 0, 0, 0 } }; -static Ttk_StateTable pushbutton_statemap[] = { +static Ttk_StateTable pushbutton_statemap[] = +{ { DFCS_INACTIVE, TTK_STATE_DISABLED, 0 }, { DFCS_PUSHED, TTK_STATE_PRESSED, 0 }, { DFCS_HOT, TTK_STATE_ACTIVE, 0 }, { 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 }, { 0, 0, 0 } }; - + /*------------------------------------------------------------------------ * +++ FrameControlElement -- * General-purpose element for things drawn with DrawFrameControl */ -typedef struct { +typedef struct +{ const char *name; /* element name */ int classId; /* class id for DrawFrameControl */ int partId; /* part id for DrawFrameControl */ @@ -105,7 +96,8 @@ typedef struct { Ttk_Padding padding; /* additional placement padding */ } FrameControlElementData; -static FrameControlElementData FrameControlElements[] = { +static FrameControlElementData FrameControlElements[] = +{ { "Checkbutton.indicator", DFC_BUTTON, DFCS_BUTTONCHECK, SM_CYMENUCHECK, SM_CYMENUCHECK, checkbutton_statemap, {0,0,4,0} }, @@ -133,55 +125,46 @@ static FrameControlElementData FrameControlElements[] = { /* ---------------------------------------------------------------------- */ -static void -FrameControlElementGeometry( - void *clientData, - void *elementRecord, - Tk_Window tkwin, - int *widthPtr, - int *heightPtr, - Ttk_Padding *paddingPtr) +static void FrameControlElementSize( + void *clientData, void *elementRecord, Tk_Window tkwin, + int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) { FrameControlElementData *elementData = clientData; - *widthPtr = GetSystemMetrics(elementData->cxId); *heightPtr = GetSystemMetrics(elementData->cyId); *paddingPtr = elementData->padding; } -static void -FrameControlElementDraw( - void *clientData, - void *elementRecord, - Tk_Window tkwin, - Drawable d, - Ttk_Box b, - unsigned int state) +static void FrameControlElementDraw( + void *clientData, void *elementRecord, Tk_Window tkwin, + Drawable d, Ttk_Box b, unsigned int state) { FrameControlElementData *elementData = clientData; RECT rc = BoxToRect(b); TkWinDCState dcState; HDC hdc = TkWinGetDrawableDC(Tk_Display(tkwin), d, &dcState); - DrawFrameControl(hdc, &rc, elementData->classId, - elementData->partId|Ttk_StateTableLookup(elementData->stateMap,state)); + DrawFrameControl(hdc, &rc, + elementData->classId, + elementData->partId|Ttk_StateTableLookup(elementData->stateMap, state)); TkWinReleaseDrawableDC(d, hdc, &dcState); } -static Ttk_ElementSpec FrameControlElementSpec = { +static Ttk_ElementSpec FrameControlElementSpec = +{ TK_STYLE_VERSION_2, sizeof(NullElement), TtkNullElementOptions, - FrameControlElementGeometry, + FrameControlElementSize, FrameControlElementDraw }; - + /*---------------------------------------------------------------------- * +++ Border element implementation. */ typedef struct { - Tcl_Obj *reliefObj; + Tcl_Obj *reliefObj; } BorderElement; static Ttk_ElementOptionSpec BorderElementOptions[] = { @@ -189,27 +172,17 @@ static Ttk_ElementOptionSpec BorderElementOptions[] = { {NULL} }; -static void -BorderElementGeometry( - void *clientData, - void *elementRecord, - Tk_Window tkwin, - int *widthPtr, - int *heightPtr, - Ttk_Padding *paddingPtr) +static void BorderElementSize( + void *clientData, void *elementRecord, Tk_Window tkwin, + int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) { paddingPtr->left = paddingPtr->right = GetSystemMetrics(SM_CXEDGE); paddingPtr->top = paddingPtr->bottom = GetSystemMetrics(SM_CYEDGE); } -static void -BorderElementDraw( - void *clientData, - void *elementRecord, - Tk_Window tkwin, - Drawable d, - Ttk_Box b, - unsigned int state) +static void BorderElementDraw( + void *clientData, void *elementRecord, Tk_Window tkwin, + Drawable d, Ttk_Box b, unsigned int state) { BorderElement *border = elementRecord; RECT rc = BoxToRect(b); @@ -221,57 +194,49 @@ BorderElementDraw( if (relief != TK_RELIEF_FLAT) { UINT xFlags = (relief == TK_RELIEF_SOLID) ? BF_FLAT : 0; - hdc = TkWinGetDrawableDC(Tk_Display(tkwin), d, &dcState); DrawEdge(hdc, &rc, ReliefToEdge(relief), BF_RECT | xFlags); TkWinReleaseDrawableDC(d, hdc, &dcState); } } -static Ttk_ElementSpec BorderElementSpec = { +static Ttk_ElementSpec BorderElementSpec = +{ TK_STYLE_VERSION_2, sizeof(BorderElement), BorderElementOptions, - BorderElementGeometry, + BorderElementSize, BorderElementDraw }; - + /* * Entry field borders: * Sunken border; also fill with window color. */ -typedef struct { - Tcl_Obj *backgroundObj; +typedef struct +{ + Tcl_Obj *backgroundObj; } FieldElement; -static Ttk_ElementOptionSpec FieldElementOptions[] = { +static Ttk_ElementOptionSpec FieldElementOptions[] = +{ { "-fieldbackground", TK_OPTION_BORDER, Tk_Offset(FieldElement,backgroundObj), "white" }, {NULL} }; -static void -FieldElementGeometry( - void *clientData, - void *elementRecord, - Tk_Window tkwin, - int *widthPtr, - int *heightPtr, - Ttk_Padding *paddingPtr) +static void FieldElementSize( + void *clientData, void *elementRecord, Tk_Window tkwin, + int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) { paddingPtr->left = paddingPtr->right = GetSystemMetrics(SM_CXEDGE); paddingPtr->top = paddingPtr->bottom = GetSystemMetrics(SM_CYEDGE); } -static void -FieldElementDraw( - void *clientData, - void *elementRecord, - Tk_Window tkwin, - Drawable d, - Ttk_Box b, - unsigned int state) +static void FieldElementDraw( + void *clientData, void *elementRecord, Tk_Window tkwin, + Drawable d, Ttk_Box b, unsigned int state) { FieldElement *field = elementRecord; Tk_3DBorder bg = Tk_Get3DBorderFromObj(tkwin, field->backgroundObj); @@ -279,32 +244,32 @@ FieldElementDraw( TkWinDCState dcState; HDC hdc; - Tk_Fill3DRectangle(tkwin, d, bg, b.x, b.y, b.width, b.height, 0, - TK_RELIEF_FLAT); + Tk_Fill3DRectangle( + tkwin, d, bg, b.x, b.y, b.width, b.height, 0, TK_RELIEF_FLAT); hdc = TkWinGetDrawableDC(Tk_Display(tkwin), d, &dcState); DrawEdge(hdc, &rc, EDGE_SUNKEN, BF_RECT); TkWinReleaseDrawableDC(d, hdc, &dcState); } -static Ttk_ElementSpec FieldElementSpec = { +static Ttk_ElementSpec FieldElementSpec = +{ TK_STYLE_VERSION_2, sizeof(FieldElement), FieldElementOptions, - FieldElementGeometry, + FieldElementSize, FieldElementDraw }; - + /*------------------------------------------------------------------------ * +++ Button borders. * Drawn with DrawFrameControl instead of DrawEdge; * Also draw default indicator and focus ring. */ - typedef struct { - Tcl_Obj *reliefObj; - Tcl_Obj *highlightColorObj; - Tcl_Obj *defaultStateObj; + Tcl_Obj *reliefObj; + Tcl_Obj *highlightColorObj; + Tcl_Obj *defaultStateObj; } ButtonBorderElement; static Ttk_ElementOptionSpec ButtonBorderElementOptions[] = { @@ -317,14 +282,9 @@ static Ttk_ElementOptionSpec ButtonBorderElementOptions[] = { {NULL} }; -static void -ButtonBorderElementGeometry( - void *clientData, - void *elementRecord, - Tk_Window tkwin, - int *widthPtr, - int *heightPtr, - Ttk_Padding *paddingPtr) +static void ButtonBorderElementSize( + void *clientData, void *elementRecord, Tk_Window tkwin, + int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) { ButtonBorderElement *bd = elementRecord; int relief = TK_RELIEF_RAISED; @@ -339,8 +299,7 @@ ButtonBorderElementGeometry( /* Space for default indicator: */ if (defaultState != TTK_BUTTON_DEFAULT_DISABLED) { - ++cx; - ++cy; + ++cx; ++cy; } /* Space for focus ring: @@ -351,14 +310,9 @@ ButtonBorderElementGeometry( *paddingPtr = Ttk_MakePadding(cx,cy,cx,cy); } -static void -ButtonBorderElementDraw( - void *clientData, - void *elementRecord, - Tk_Window tkwin, - Drawable d, - Ttk_Box b, - unsigned int state) +static void ButtonBorderElementDraw( + void *clientData, void *elementRecord, Tk_Window tkwin, + Drawable d, Ttk_Box b, unsigned int state) { ButtonBorderElement *bd = elementRecord; int relief = TK_RELIEF_FLAT; @@ -372,7 +326,7 @@ ButtonBorderElementDraw( if (defaultState == TTK_BUTTON_DEFAULT_ACTIVE) { XColor *highlightColor = - Tk_GetColorFromObj(tkwin, bd->highlightColorObj); + Tk_GetColorFromObj(tkwin, bd->highlightColorObj); GC gc = Tk_GCForColor(highlightColor, d); XDrawRectangle(Tk_Display(tkwin), d, gc, b.x,b.y,b.width-1,b.height-1); } @@ -383,69 +337,60 @@ ButtonBorderElementDraw( hdc = TkWinGetDrawableDC(Tk_Display(tkwin), d, &dcState); rc = BoxToRect(b); - DrawFrameControl(hdc, &rc, DFC_BUTTON, /* classId */ - DFCS_BUTTONPUSH|Ttk_StateTableLookup(pushbutton_statemap, state)); + DrawFrameControl(hdc, &rc, + DFC_BUTTON, /* classId */ + DFCS_BUTTONPUSH | Ttk_StateTableLookup(pushbutton_statemap, state)); /* Draw focus ring: */ if (state & TTK_STATE_FOCUS) { short int borderWidth = 3; /* @@@ Use GetSystemMetrics?*/ - rc = BoxToRect(Ttk_PadBox(b, Ttk_UniformPadding(borderWidth))); DrawFocusRect(hdc, &rc); } TkWinReleaseDrawableDC(d, hdc, &dcState); } -static Ttk_ElementSpec ButtonBorderElementSpec = { +static Ttk_ElementSpec ButtonBorderElementSpec = +{ TK_STYLE_VERSION_2, sizeof(ButtonBorderElement), ButtonBorderElementOptions, - ButtonBorderElementGeometry, + ButtonBorderElementSize, ButtonBorderElementDraw }; - + /*------------------------------------------------------------------------ * +++ Focus element. * Draw dashed focus rectangle. */ -static void -FocusElementGeometry( - void *clientData, - void *elementRecord, - Tk_Window tkwin, - int *widthPtr, - int *heightPtr, - Ttk_Padding *paddingPtr) +static void FocusElementSize( + void *clientData, void *elementRecord, Tk_Window tkwin, + int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) { *paddingPtr = Ttk_UniformPadding(1); } -static void -FocusElementDraw( - void *clientData, - void *elementRecord, - Tk_Window tkwin, - Drawable d, - Ttk_Box b, - unsigned int state) +static void FocusElementDraw( + void *clientData, void *elementRecord, Tk_Window tkwin, + Drawable d, Ttk_Box b, unsigned int state) { if (state & TTK_STATE_FOCUS) { RECT rc = BoxToRect(b); TkWinDCState dcState; HDC hdc = TkWinGetDrawableDC(Tk_Display(tkwin), d, &dcState); - DrawFocusRect(hdc, &rc); TkWinReleaseDrawableDC(d, hdc, &dcState); } } -static Ttk_ElementSpec FocusElementSpec = { +static Ttk_ElementSpec FocusElementSpec = +{ TK_STYLE_VERSION_2, sizeof(NullElement), TtkNullElementOptions, - FocusElementGeometry, + FocusElementSize, FocusElementDraw }; @@ -464,17 +409,11 @@ static Ttk_ElementOptionSpec FillFocusElementOptions[] = { }; /* @@@ FIX THIS */ -static void -FillFocusElementDraw( - void *clientData, - void *elementRecord, - Tk_Window tkwin, - Drawable d, - Ttk_Box b, - unsigned int state) +static void FillFocusElementDraw( + void *clientData, void *elementRecord, Tk_Window tkwin, + Drawable d, Ttk_Box b, unsigned int state) { FillFocusElement *focus = elementRecord; - if (state & TTK_STATE_FOCUS) { RECT rc = BoxToRect(b); TkWinDCState dcState; @@ -493,77 +432,61 @@ FillFocusElementDraw( * ComboboxFocusElement -- * Read-only comboboxes have a filled focus ring, editable ones do not. */ - -static void -ComboboxFocusElementDraw( - void *clientData, - void *elementRecord, - Tk_Window tkwin, - Drawable d, - Ttk_Box b, - unsigned int state) +static void ComboboxFocusElementDraw( + void *clientData, void *elementRecord, Tk_Window tkwin, + Drawable d, Ttk_Box b, unsigned int state) { if (state & TTK_STATE_READONLY) { FillFocusElementDraw(clientData, elementRecord, tkwin, d, b, state); } } -static Ttk_ElementSpec ComboboxFocusElementSpec = { +static Ttk_ElementSpec ComboboxFocusElementSpec = +{ TK_STYLE_VERSION_2, sizeof(FillFocusElement), FillFocusElementOptions, - FocusElementGeometry, + FocusElementSize, ComboboxFocusElementDraw }; - + /*---------------------------------------------------------------------- * +++ Scrollbar trough element. * * The native windows scrollbar is drawn using a pattern brush giving a - * stippled appearance when the trough might otherwise be invisible. We can - * deal with this here. + * stippled appearance when the trough might otherwise be invisible. + * We can deal with this here. */ -typedef struct { /* clientData for Trough element */ - HBRUSH PatternBrush; - HBITMAP PatternBitmap; +typedef struct { /* clientData for Trough element */ + HBRUSH PatternBrush; + HBITMAP PatternBitmap; } TroughClientData; static const WORD Pattern[] = { 0x5555, 0xaaaa, 0x5555, 0xaaaa, 0x5555, 0xaaaa, 0x5555, 0xaaaa }; -static void -TroughClientDataDeleteProc( - void *clientData) +static void TroughClientDataDeleteProc(void *clientData) { TroughClientData *cd = clientData; - DeleteObject(cd->PatternBrush); DeleteObject(cd->PatternBitmap); ckfree(clientData); } -static TroughClientData * -TroughClientDataInit( - Tcl_Interp *interp) +static TroughClientData *TroughClientDataInit(Tcl_Interp *interp) { - TroughClientData *cd = (TroughClientData *) ckalloc(sizeof(*cd)); - + TroughClientData *cd = (TroughClientData*)ckalloc(sizeof(*cd)); cd->PatternBitmap = CreateBitmap(8, 8, 1, 1, Pattern); - cd->PatternBrush = CreatePatternBrush(cd->PatternBitmap); + cd->PatternBrush = CreatePatternBrush(cd->PatternBitmap); Ttk_RegisterCleanup(interp, cd, TroughClientDataDeleteProc); return cd; } -static void -TroughElementDraw( - void *clientData, - void *elementRecord, - Tk_Window tkwin, - Drawable d, - Ttk_Box b, - unsigned int state) +static void TroughElementDraw( + void *clientData, void *elementRecord, Tk_Window tkwin, + Drawable d, Ttk_Box b, unsigned int state) { TroughClientData *cd = clientData; TkWinDCState dcState; @@ -589,34 +512,33 @@ TroughElementDraw( TkWinReleaseDrawableDC(d, hdc, &dcState); } -static Ttk_ElementSpec TroughElementSpec = { +static Ttk_ElementSpec TroughElementSpec = +{ TK_STYLE_VERSION_2, sizeof(NullElement), TtkNullElementOptions, - TtkNullElementGeometry, + TtkNullElementSize, TroughElementDraw }; - + /*------------------------------------------------------------------------ * +++ Thumb element. */ -typedef struct { +typedef struct +{ Tcl_Obj *orientObj; } ThumbElement; -static Ttk_ElementOptionSpec ThumbElementOptions[] = { +static Ttk_ElementOptionSpec ThumbElementOptions[] = +{ { "-orient", TK_OPTION_ANY,Tk_Offset(ThumbElement,orientObj),"horizontal"}, { NULL } }; -static void ThumbElementGeometry( - void *clientData, - void *elementRecord, - Tk_Window tkwin, - int *widthPtr, - int *heightPtr, - Ttk_Padding *paddingPtr) +static void ThumbElementSize( + void *clientData, void *elementRecord, Tk_Window tkwin, + int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) { ThumbElement *thumbPtr = elementRecord; int orient; @@ -631,60 +553,52 @@ static void ThumbElementGeometry( } } -static void -ThumbElementDraw( - void *clientData, - void *elementRecord, - Tk_Window tkwin, - Drawable d, - Ttk_Box b, - unsigned int state) +static void ThumbElementDraw( + void *clientData, void *elementRecord, Tk_Window tkwin, + Drawable d, Ttk_Box b, unsigned int state) { RECT rc = BoxToRect(b); TkWinDCState dcState; HDC hdc; /* Windows doesn't show a thumb when the scrollbar is disabled */ - if (state & TTK_STATE_DISABLED) { + if (state & TTK_STATE_DISABLED) return; - } hdc = TkWinGetDrawableDC(Tk_Display(tkwin), d, &dcState); DrawEdge(hdc, &rc, EDGE_RAISED, BF_RECT | BF_MIDDLE); TkWinReleaseDrawableDC(d, hdc, &dcState); } -static Ttk_ElementSpec ThumbElementSpec = { +static Ttk_ElementSpec ThumbElementSpec = +{ TK_STYLE_VERSION_2, sizeof(ThumbElement), ThumbElementOptions, - ThumbElementGeometry, + ThumbElementSize, ThumbElementDraw }; - + /* ---------------------------------------------------------------------- * The slider element is the shaped thumb used in the slider widget. * Windows likes to call this a trackbar. */ -typedef struct { +typedef struct +{ Tcl_Obj *orientObj; /* orientation of the slider widget */ } SliderElement; -static Ttk_ElementOptionSpec SliderElementOptions[] = { +static Ttk_ElementOptionSpec SliderElementOptions[] = +{ { "-orient", TK_OPTION_ANY, Tk_Offset(SliderElement,orientObj), "horizontal" }, { NULL } }; -static void -SliderElementGeometry( - void *clientData, - void *elementRecord, - Tk_Window tkwin, - int *widthPtr, - int *heightPtr, - Ttk_Padding *paddingPtr) +static void SliderElementSize( + void *clientData, void *elementRecord, Tk_Window tkwin, + int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) { SliderElement *slider = elementRecord; int orient; @@ -699,14 +613,9 @@ SliderElementGeometry( } } -static void -SliderElementDraw( - void *clientData, - void *elementRecord, - Tk_Window tkwin, - Drawable d, - Ttk_Box b, - unsigned int state) +static void SliderElementDraw( + void *clientData, void *elementRecord, Tk_Window tkwin, + Drawable d, Ttk_Box b, unsigned int state) { RECT rc = BoxToRect(b); TkWinDCState dcState; @@ -717,56 +626,47 @@ SliderElementDraw( TkWinReleaseDrawableDC(d, hdc, &dcState); } -static Ttk_ElementSpec SliderElementSpec = { +static Ttk_ElementSpec SliderElementSpec = +{ TK_STYLE_VERSION_2, sizeof(SliderElement), SliderElementOptions, - SliderElementGeometry, + SliderElementSize, SliderElementDraw }; - + /*------------------------------------------------------------------------ * +++ Notebook elements. */ -static void -ClientElementGeometry( - void *clientData, - void *elementRecord, - Tk_Window tkwin, - int *widthPtr, - int *heightPtr, - Ttk_Padding *paddingPtr) +static void ClientElementSize( + void *clientData, void *elementRecord, Tk_Window tkwin, + int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) { paddingPtr->left = paddingPtr->right = GetSystemMetrics(SM_CXEDGE); paddingPtr->top = paddingPtr->bottom = GetSystemMetrics(SM_CYEDGE); } -static void -ClientElementDraw( - void *clientData, - void *elementRecord, - Tk_Window tkwin, - Drawable d, - Ttk_Box b, - unsigned int state) +static void ClientElementDraw( + void *clientData, void *elementRecord, Tk_Window tkwin, + Drawable d, Ttk_Box b, unsigned int state) { RECT rc = BoxToRect(b); TkWinDCState dcState; HDC hdc = TkWinGetDrawableDC(Tk_Display(tkwin), d, &dcState); - DrawEdge(hdc, &rc, EDGE_RAISED, BF_RECT | BF_SOFT); TkWinReleaseDrawableDC(d, hdc, &dcState); } -static Ttk_ElementSpec ClientElementSpec = { +static Ttk_ElementSpec ClientElementSpec = +{ TK_STYLE_VERSION_2, sizeof(NullElement), TtkNullElementOptions, - ClientElementGeometry, + ClientElementSize, ClientElementDraw }; - + /*------------------------------------------------------------------------ * +++ Layouts. */ @@ -784,13 +684,11 @@ TTK_BEGIN_LAYOUT(ComboboxLayout) TTK_GROUP("Combobox.focus", TTK_PACK_LEFT|TTK_EXPAND|TTK_FILL_BOTH, TTK_NODE("Combobox.textarea", TTK_FILL_BOTH)))) TTK_END_LAYOUT - + + /* ---------------------------------------------------------------------- */ -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; @@ -803,15 +701,15 @@ TtkWinTheme_Init( Ttk_RegisterElementSpec(themePtr, "border", &BorderElementSpec, NULL); Ttk_RegisterElementSpec(themePtr, "Button.border", - &ButtonBorderElementSpec, NULL); + &ButtonBorderElementSpec, NULL); Ttk_RegisterElementSpec(themePtr, "field", &FieldElementSpec, NULL); Ttk_RegisterElementSpec(themePtr, "focus", &FocusElementSpec, NULL); Ttk_RegisterElementSpec(themePtr, "Combobox.focus", - &ComboboxFocusElementSpec, NULL); + &ComboboxFocusElementSpec, NULL); Ttk_RegisterElementSpec(themePtr, "thumb", &ThumbElementSpec, NULL); Ttk_RegisterElementSpec(themePtr, "slider", &SliderElementSpec, NULL); Ttk_RegisterElementSpec(themePtr, "Scrollbar.trough", &TroughElementSpec, - TroughClientDataInit(interp)); + TroughClientDataInit(interp)); Ttk_RegisterElementSpec(themePtr, "client", &ClientElementSpec, NULL); @@ -826,11 +724,3 @@ TtkWinTheme_Init( Tcl_PkgProvide(interp, "ttk::theme::winnative", TTK_VERSION); return TCL_OK; } - -/* - * Local Variables: - * mode: c - * c-basic-offset: 4 - * fill-column: 78 - * End: - */ diff --git a/win/ttkWinXPTheme.c b/win/ttkWinXPTheme.c index 38e373b..e18d604 100644 --- a/win/ttkWinXPTheme.c +++ b/win/ttkWinXPTheme.c @@ -1,5 +1,5 @@ /* - * $Id: ttkWinXPTheme.c,v 1.12 2007/04/17 14:32:28 dkf Exp $ + * $Id: ttkWinXPTheme.c,v 1.13 2007/10/25 07:08:27 jenglish Exp $ * * Tk theme engine which uses the Windows XP "Visual Styles" API * Adapted from Georgios Petasis' XP theme patch. @@ -53,7 +53,8 @@ typedef HRESULT (STDAPICALLTYPE DrawThemeTextProc)(HTHEME hTheme, HDC hdc, typedef BOOL (STDAPICALLTYPE IsThemeActiveProc)(VOID); typedef BOOL (STDAPICALLTYPE IsAppThemedProc)(VOID); -typedef struct { +typedef struct +{ OpenThemeDataProc *OpenThemeData; CloseThemeDataProc *CloseThemeData; GetThemePartSizeProc *GetThemePartSize; @@ -66,7 +67,8 @@ typedef struct { HWND stubWindow; } XPThemeProcs; -typedef struct { +typedef struct +{ HINSTANCE hlibrary; XPThemeProcs *procs; } XPThemeData; @@ -86,39 +88,39 @@ typedef struct { */ static XPThemeProcs * -LoadXPThemeProcs( - HINSTANCE *phlib) +LoadXPThemeProcs(HINSTANCE *phlib) { /* - * Load the library "uxtheme.dll", where the native widget drawing - * routines are implemented. This will only succeed if we are running at - * least on Windows XP. + * Load the library "uxtheme.dll", where the native widget + * drawing routines are implemented. This will only succeed + * if we are running at least on Windows XP. */ - HINSTANCE handle; - *phlib = handle = LoadLibrary("uxtheme.dll"); - if (handle != 0) { + if (handle != 0) + { /* * We have successfully loaded the library. Proceed in storing the * addresses of the functions we want to use. */ - XPThemeProcs *procs = (XPThemeProcs *) ckalloc(sizeof(XPThemeProcs)); + XPThemeProcs *procs = (XPThemeProcs*)ckalloc(sizeof(XPThemeProcs)); #define LOADPROC(name) \ (0 != (procs->name = (name ## Proc *)GetProcAddress(handle, #name) )) - if ( LOADPROC(OpenThemeData) && - LOADPROC(CloseThemeData) && - LOADPROC(GetThemePartSize) && - LOADPROC(DrawThemeBackground) && - LOADPROC(GetThemeTextExtent) && - LOADPROC(DrawThemeText) && - LOADPROC(IsThemeActive) && - LOADPROC(IsAppThemed)) { + if ( LOADPROC(OpenThemeData) + && LOADPROC(CloseThemeData) + && LOADPROC(GetThemePartSize) + && LOADPROC(DrawThemeBackground) + && LOADPROC(GetThemeTextExtent) + && LOADPROC(DrawThemeText) + && LOADPROC(IsThemeActive) + && LOADPROC(IsAppThemed) + ) + { return procs; } #undef LOADPROC - ckfree((char *) procs); + ckfree((char*)procs); } return 0; } @@ -130,8 +132,7 @@ LoadXPThemeProcs( */ static void -XPThemeDeleteProc( - void *clientData) +XPThemeDeleteProc(void *clientData) { XPThemeData *themeData = clientData; FreeLibrary(themeData->hlibrary); @@ -139,9 +140,7 @@ XPThemeDeleteProc( } static int -XPThemeEnabled( - Ttk_Theme theme, - void *clientData) +XPThemeEnabled(Ttk_Theme theme, void *clientData) { XPThemeData *themeData = clientData; int active = themeData->procs->IsThemeActive(); @@ -154,8 +153,7 @@ XPThemeEnabled( * Helper routine. Returns a RECT data structure. */ static RECT -BoxToRect( - Ttk_Box b) +BoxToRect(Ttk_Box b) { RECT rc; rc.top = b.y; @@ -360,38 +358,44 @@ static Ttk_StateTable tabitem_statemap[] = * BP_PUSHBUTTONS). Set the IGNORE_THEMESIZE flag to skip this call. */ -typedef struct { /* XP element specifications */ - const char *elementName; /* Tk theme engine element name */ +typedef struct /* XP element specifications */ +{ + const char *elementName; /* Tk theme engine element name */ Ttk_ElementSpec *elementSpec; /* Element spec (usually GenericElementSpec) */ - LPCWSTR className; /* Windows window class name */ - int partId; /* BP_PUSHBUTTON, BP_CHECKBUTTON, etc. */ + LPCWSTR className; /* Windows window class name */ + int partId; /* BP_PUSHBUTTON, BP_CHECKBUTTON, etc. */ Ttk_StateTable *statemap; /* Map Tk states to XP states */ Ttk_Padding padding; /* See NOTE-GetThemeMargins */ - int flags; -#define IGNORE_THEMESIZE 0x1 /* See NOTE-GetThemePartSize */ -#define PAD_MARGINS 0x2 /* See NOTE-GetThemeMargins */ + int flags; +# define IGNORE_THEMESIZE 0x1 /* See NOTE-GetThemePartSize */ +# define PAD_MARGINS 0x2 /* See NOTE-GetThemeMargins */ } ElementInfo; -typedef struct { - /* Static data, initialized when element is registered: */ +typedef struct +{ + /* + * Static data, initialized when element is registered: + */ ElementInfo *info; XPThemeProcs *procs; /* Pointer to theme procedure table */ - /* Dynamic data, allocated by InitElementData: */ - HTHEME hTheme; - HDC hDC; - HWND hwnd; + + /* + * Dynamic data, allocated by InitElementData: + */ + HTHEME hTheme; + HDC hDC; + HWND hwnd; + /* For TkWinDrawableReleaseDC: */ - Drawable drawable; + Drawable drawable; TkWinDCState dcState; } ElementData; static ElementData * -NewElementData( - XPThemeProcs *procs, - ElementInfo *info) +NewElementData(XPThemeProcs *procs, ElementInfo *info) { - ElementData *elementData = (ElementData *) ckalloc(sizeof(ElementData)); + ElementData *elementData = (ElementData*)ckalloc(sizeof(ElementData)); elementData->procs = procs; elementData->info = info; @@ -400,29 +404,24 @@ NewElementData( return elementData; } -static void -DestroyElementData( - void *elementData) +static void DestroyElementData(void *elementData) { ckfree(elementData); } /* * InitElementData -- - * Looks up theme handle. If Drawable argument is non-NULL, also - * initializes DC. + * Looks up theme handle. If Drawable argument is non-NULL, + * also initializes DC. * * Returns: * 1 on success, 0 on error. - * Caller must later call FreeElementData() so this element can be - * reused. + * Caller must later call FreeElementData() so this element + * can be reused. */ static int -InitElementData( - ElementData *elementData, - Tk_Window tkwin, - Drawable d) +InitElementData(ElementData *elementData, Tk_Window tkwin, Drawable d) { Window win = Tk_WindowId(tkwin); @@ -448,8 +447,7 @@ InitElementData( } static void -FreeElementData( - ElementData *elementData) +FreeElementData(ElementData *elementData) { elementData->procs->CloseThemeData(elementData->hTheme); if (elementData->drawable != 0) { @@ -465,28 +463,26 @@ FreeElementData( * such as radiobutton and checkbutton indicators, scrollbar arrows, etc. */ -static void -GenericElementGeometry( - void *clientData, - void *elementRecord, - Tk_Window tkwin, - int *widthPtr, - int *heightPtr, - Ttk_Padding *paddingPtr) +static void GenericElementSize( + void *clientData, void *elementRecord, Tk_Window tkwin, + int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) { ElementData *elementData = clientData; HRESULT result; SIZE size; - if (!InitElementData(elementData, tkwin, 0)) { + if (!InitElementData(elementData, tkwin, 0)) return; - } if (!(elementData->info->flags & IGNORE_THEMESIZE)) { - result = elementData->procs->GetThemePartSize(elementData->hTheme, - elementData->hDC, elementData->info->partId, - Ttk_StateTableLookup(elementData->info->statemap, 0), - NULL /*RECT *prc*/, TS_TRUE, &size); + result = elementData->procs->GetThemePartSize( + elementData->hTheme, + elementData->hDC, + elementData->info->partId, + Ttk_StateTableLookup(elementData->info->statemap, 0), + NULL /*RECT *prc*/, + TS_TRUE, + &size); if (SUCCEEDED(result)) { *widthPtr = size.cx; @@ -499,14 +495,9 @@ GenericElementGeometry( *paddingPtr = elementData->info->padding; } -static void -GenericElementDraw( - void *clientData, - void *elementRecord, - Tk_Window tkwin, - Drawable d, - Ttk_Box b, - unsigned int state) +static void GenericElementDraw( + void *clientData, void *elementRecord, Tk_Window tkwin, + Drawable d, Ttk_Box b, unsigned int state) { ElementData *elementData = clientData; RECT rc; @@ -520,19 +511,23 @@ GenericElementDraw( } rc = BoxToRect(b); - elementData->procs->DrawThemeBackground(elementData->hTheme, - elementData->hDC, elementData->info->partId, - Ttk_StateTableLookup(elementData->info->statemap, state), - &rc, NULL/*pContentRect*/); + elementData->procs->DrawThemeBackground( + elementData->hTheme, + elementData->hDC, + elementData->info->partId, + Ttk_StateTableLookup(elementData->info->statemap, state), + &rc, + NULL/*pContentRect*/); FreeElementData(elementData); } -static Ttk_ElementSpec GenericElementSpec = { +static Ttk_ElementSpec GenericElementSpec = +{ TK_STYLE_VERSION_2, sizeof(NullElement), TtkNullElementOptions, - GenericElementGeometry, + GenericElementSize, GenericElementDraw }; @@ -541,41 +536,36 @@ static Ttk_ElementSpec GenericElementSpec = { * Same as a GenericElement, but don't draw in the disabled state. */ -static void -ThumbElementDraw( - void *clientData, - void *elementRecord, - Tk_Window tkwin, - Drawable d, - Ttk_Box b, - unsigned int state) +static void ThumbElementDraw( + void *clientData, void *elementRecord, Tk_Window tkwin, + Drawable d, Ttk_Box b, unsigned int state) { ElementData *elementData = clientData; - unsigned stateId = Ttk_StateTableLookup(elementData->info->statemap,state); + unsigned stateId = Ttk_StateTableLookup(elementData->info->statemap, state); RECT rc = BoxToRect(b); /* * Don't draw the thumb if we are disabled. */ - if (state & TTK_STATE_DISABLED) { + if (state & TTK_STATE_DISABLED) return; - } - if (!InitElementData(elementData, tkwin, d)) { + if (!InitElementData(elementData, tkwin, d)) return; - } elementData->procs->DrawThemeBackground(elementData->hTheme, - elementData->hDC, elementData->info->partId, stateId, &rc, NULL); + elementData->hDC, elementData->info->partId, stateId, + &rc, NULL); FreeElementData(elementData); } -static Ttk_ElementSpec ThumbElementSpec = { +static Ttk_ElementSpec ThumbElementSpec = +{ TK_STYLE_VERSION_2, sizeof(NullElement), TtkNullElementOptions, - GenericElementGeometry, + GenericElementSize, ThumbElementDraw }; @@ -585,20 +575,15 @@ static Ttk_ElementSpec ThumbElementSpec = { * so that indeterminate progress bars show 3 bars instead of 1. */ -static void -PbarElementGeometry( - void *clientData, - void *elementRecord, - Tk_Window tkwin, - int *widthPtr, - int *heightPtr, - Ttk_Padding *paddingPtr) +static void PbarElementSize( + void *clientData, void *elementRecord, Tk_Window tkwin, + int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) { ElementData *elementData = clientData; int nBars = 3; - GenericElementGeometry(clientData, elementRecord, tkwin, - widthPtr, heightPtr, paddingPtr); + GenericElementSize(clientData, elementRecord, tkwin, + widthPtr, heightPtr, paddingPtr); if (elementData->info->partId == PP_CHUNK) { *widthPtr *= nBars; @@ -607,103 +592,93 @@ PbarElementGeometry( } } -static Ttk_ElementSpec PbarElementSpec = { +static Ttk_ElementSpec PbarElementSpec = +{ TK_STYLE_VERSION_2, sizeof(NullElement), TtkNullElementOptions, - PbarElementGeometry, + PbarElementSize, GenericElementDraw }; /*---------------------------------------------------------------------- * +++ Notebook tab element. - - * Same as generic element, with additional logic to select proper - * iPartID for the leftmost tab. + * Same as generic element, with additional logic to select + * proper iPartID for the leftmost tab. * - * Notes: TABP_TABITEMRIGHTEDGE (or TABP_TOPTABITEMRIGHTEDGE, which - * appears to be identical) should be used if the tab is exactly at the - * right edge of the notebook, but not if it's simply the rightmost tab. - * This information is not available. + * Notes: TABP_TABITEMRIGHTEDGE (or TABP_TOPTABITEMRIGHTEDGE, + * which appears to be identical) should be used if the + * tab is exactly at the right edge of the notebook, but + * not if it's simply the rightmost tab. This information + * is not available. * - * The TIS_* and TILES_* definitions are identical, so we can use the - * same statemap no matter what the partId. + * The TIS_* and TILES_* definitions are identical, so + * we can use the same statemap no matter what the partId. */ - -static void -TabElementDraw( - void *clientData, - void *elementRecord, - Tk_Window tkwin, - Drawable d, - Ttk_Box b, - unsigned int state) +static void TabElementDraw( + void *clientData, void *elementRecord, Tk_Window tkwin, + Drawable d, Ttk_Box b, unsigned int state) { ElementData *elementData = clientData; int partId = elementData->info->partId; RECT rc = BoxToRect(b); - if (!InitElementData(elementData, tkwin, d)) { + if (!InitElementData(elementData, tkwin, d)) return; - } - if (state & TTK_STATE_USER1) { + if (state & TTK_STATE_USER1) partId = TABP_TABITEMLEFTEDGE; - } - elementData->procs->DrawThemeBackground(elementData->hTheme, - elementData->hDC, partId, - Ttk_StateTableLookup(elementData->info->statemap, state), &rc, - NULL); + elementData->procs->DrawThemeBackground( + elementData->hTheme, elementData->hDC, partId, + Ttk_StateTableLookup(elementData->info->statemap, state), &rc, NULL); FreeElementData(elementData); } -static Ttk_ElementSpec TabElementSpec = { +static Ttk_ElementSpec TabElementSpec = +{ TK_STYLE_VERSION_2, sizeof(NullElement), TtkNullElementOptions, - GenericElementGeometry, + GenericElementSize, TabElementDraw }; /*---------------------------------------------------------------------- * +++ Tree indicator element. * - * Generic element, but don't display at all if TTK_STATE_LEAF (=USER2) - * set + * Generic element, but don't display at all if TTK_STATE_LEAF (=USER2) set */ #define TTK_STATE_OPEN TTK_STATE_USER1 #define TTK_STATE_LEAF TTK_STATE_USER2 -static Ttk_StateTable header_statemap[] = { +static Ttk_StateTable header_statemap[] = +{ { HIS_PRESSED, TTK_STATE_PRESSED, 0 }, { HIS_HOT, TTK_STATE_ACTIVE, 0 }, { HIS_NORMAL, 0,0 }, }; -static Ttk_StateTable tvpglyph_statemap[] = { +static Ttk_StateTable tvpglyph_statemap[] = +{ { GLPS_OPENED, TTK_STATE_OPEN, 0 }, { GLPS_CLOSED, 0,0 }, }; -static void -TreeIndicatorElementDraw( - void *clientData, - void *elementRecord, - Tk_Window tkwin, - Drawable d, - Ttk_Box b, - unsigned int state) +static void TreeIndicatorElementDraw( + void *clientData, void *elementRecord, Tk_Window tkwin, + Drawable d, Ttk_Box b, unsigned int state) { if (!(state & TTK_STATE_LEAF)) { GenericElementDraw(clientData,elementRecord,tkwin,d,b,state); } } -static Ttk_ElementSpec TreeIndicatorElementSpec = { +static Ttk_ElementSpec TreeIndicatorElementSpec = +{ TK_STYLE_VERSION_2, sizeof(NullElement), TtkNullElementOptions, - GenericElementGeometry, + GenericElementSize, TreeIndicatorElementDraw }; @@ -713,18 +688,21 @@ static Ttk_ElementSpec TreeIndicatorElementSpec = { *---------------------------------------------------------------------- * Text element (does not work yet). * - * According to "Using Windows XP Visual Styles", we need to select a font - * into the DC before calling DrawThemeText(). There's just no easy way to get - * an HFONT out of a Tk_Font. Maybe GetThemeFont() would work? + * According to "Using Windows XP Visual Styles", we need to select + * a font into the DC before calling DrawThemeText(). + * There's just no easy way to get an HFONT out of a Tk_Font. + * Maybe GetThemeFont() would work? * */ -typedef struct { +typedef struct +{ Tcl_Obj *textObj; Tcl_Obj *fontObj; } TextElement; -static Ttk_ElementOptionSpec TextElementOptions[] = { +static Ttk_ElementOptionSpec TextElementOptions[] = +{ { "-text", TK_OPTION_STRING, Tk_Offset(TextElement,textObj), "" }, { "-font", TK_OPTION_FONT, @@ -732,76 +710,70 @@ static Ttk_ElementOptionSpec TextElementOptions[] = { { NULL } }; -static void -TextElementGeometry( - void *clientData, - void *elementRecord, - Tk_Window tkwin, - int *widthPtr, - int *heightPtr, - Ttk_Padding *paddingPtr) +static void TextElementSize( + void *clientData, void *elementRecord, Tk_Window tkwin, + int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) { TextElement *element = elementRecord; ElementData *elementData = clientData; RECT rc = {0, 0}; HRESULT hr = S_OK; - if (!InitElementData(elementData, tkwin, 0)) { + if (!InitElementData(elementData, tkwin, 0)) return; - } - hr = elementData->procs->GetThemeTextExtent(elementData->hTheme, - elementData->hDC, elementData->info->partId, + hr = elementData->procs->GetThemeTextExtent( + elementData->hTheme, + elementData->hDC, + elementData->info->partId, Ttk_StateTableLookup(elementData->info->statemap, 0), - Tcl_GetUnicode(element->textObj), -1, - DT_LEFT,/*| DT_BOTTOM | DT_NOPREFIX,*/ NULL, &rc); + Tcl_GetUnicode(element->textObj), + -1, + DT_LEFT,// | DT_BOTTOM | DT_NOPREFIX, + NULL, + &rc); if (SUCCEEDED(hr)) { *widthPtr = rc.right - rc.left; *heightPtr = rc.bottom - rc.top; } - if (*widthPtr < 80) { - *widthPtr = 80; - } - if (*heightPtr < 20) { - *heightPtr = 20; - } + if (*widthPtr < 80) *widthPtr = 80; + if (*heightPtr < 20) *heightPtr = 20; FreeElementData(elementData); } -static void -TextElementDraw( - ClientData clientData, - void *elementRecord, - Tk_Window tkwin, - Drawable d, - Ttk_Box b, - unsigned int state) +static void TextElementDraw( + ClientData clientData, void *elementRecord, Tk_Window tkwin, + Drawable d, Ttk_Box b, unsigned int state) { TextElement *element = elementRecord; ElementData *elementData = clientData; RECT rc = BoxToRect(b); HRESULT hr = S_OK; - if (!InitElementData(elementData, tkwin, d)) { + if (!InitElementData(elementData, tkwin, d)) return; - } - hr = elementData->procs->DrawThemeText(elementData->hTheme, - elementData->hDC, elementData->info->partId, + hr = elementData->procs->DrawThemeText( + elementData->hTheme, + elementData->hDC, + elementData->info->partId, Ttk_StateTableLookup(elementData->info->statemap, state), - Tcl_GetUnicode(element->textObj), -1, - DT_LEFT,/*| DT_BOTTOM | DT_NOPREFIX,*/ - (state & TTK_STATE_DISABLED) ? DTT_GRAYED : 0, &rc); + Tcl_GetUnicode(element->textObj), + -1, + DT_LEFT,// | DT_BOTTOM | DT_NOPREFIX, + (state & TTK_STATE_DISABLED) ? DTT_GRAYED : 0, + &rc); FreeElementData(elementData); } -static Ttk_ElementSpec TextElementSpec = { +static Ttk_ElementSpec TextElementSpec = +{ TK_STYLE_VERSION_2, sizeof(TextElement), TextElementOptions, - TextElementGeometry, + TextElementSize, TextElementDraw }; @@ -949,10 +921,7 @@ static ElementInfo ElementInfoTable[] = { * +++ Initialization routine: */ -MODULE_SCOPE int -TtkXPTheme_Init( - Tcl_Interp *interp, - HWND hwnd) +MODULE_SCOPE int TtkXPTheme_Init(Tcl_Interp *interp, HWND hwnd) { XPThemeData *themeData; XPThemeProcs *procs; @@ -961,9 +930,8 @@ TtkXPTheme_Init( ElementInfo *infoPtr; procs = LoadXPThemeProcs(&hlibrary); - if (!procs) { + if (!procs) return TCL_ERROR; - } procs->stubWindow = hwnd; /* @@ -972,9 +940,8 @@ TtkXPTheme_Init( parentPtr = Ttk_GetTheme(interp, "winnative"); themePtr = Ttk_CreateTheme(interp, "xpnative", parentPtr); - if (!themePtr) { + if (!themePtr) return TCL_ERROR; - } /* * Set theme data and cleanup proc @@ -992,8 +959,8 @@ TtkXPTheme_Init( */ for (infoPtr = ElementInfoTable; infoPtr->elementName != 0; ++infoPtr) { ClientData clientData = NewElementData(procs, infoPtr); - Ttk_RegisterElementSpec(themePtr, infoPtr->elementName, - infoPtr->elementSpec, clientData); + Ttk_RegisterElementSpec( + themePtr, infoPtr->elementName, infoPtr->elementSpec, clientData); Ttk_RegisterCleanup(interp, clientData, DestroyElementData); } @@ -1005,9 +972,9 @@ TtkXPTheme_Init( Ttk_RegisterLayout(themePtr, "TButton", ButtonLayout); Ttk_RegisterLayout(themePtr, "TMenubutton", MenubuttonLayout); Ttk_RegisterLayout(themePtr, "Vertical.TScrollbar", - VerticalScrollbarLayout); + VerticalScrollbarLayout); Ttk_RegisterLayout(themePtr, "Horizontal.TScrollbar", - HorizontalScrollbarLayout); + HorizontalScrollbarLayout); Ttk_RegisterLayout(themePtr, "Vertical.TScale", VerticalScaleLayout); Ttk_RegisterLayout(themePtr, "Horizontal.TScale", HorizontalScaleLayout); -- cgit v0.12