diff options
Diffstat (limited to 'win/ttkWinXPTheme.c')
-rw-r--r-- | win/ttkWinXPTheme.c | 123 |
1 files changed, 86 insertions, 37 deletions
diff --git a/win/ttkWinXPTheme.c b/win/ttkWinXPTheme.c index b166f1e..723b7d7 100644 --- a/win/ttkWinXPTheme.c +++ b/win/ttkWinXPTheme.c @@ -1,5 +1,5 @@ /* - * $Id: ttkWinXPTheme.c,v 1.8 2007/02/04 00:10:55 mistachkin Exp $ + * $Id: ttkWinXPTheme.c,v 1.9 2007/02/22 13:56:35 dkf Exp $ * * Tk theme engine which uses the Windows XP "Visual Styles" API * Adapted from Georgios Petasis' XP theme patch. @@ -88,7 +88,8 @@ typedef struct */ static XPThemeProcs * -LoadXPThemeProcs(HINSTANCE *phlib) +LoadXPThemeProcs( + HINSTANCE *phlib) { OSVERSIONINFO os; @@ -145,7 +146,8 @@ LoadXPThemeProcs(HINSTANCE *phlib) */ static void -XPThemeDeleteProc(void *clientData) +XPThemeDeleteProc( + void *clientData) { XPThemeData *themeData = clientData; FreeLibrary(themeData->hlibrary); @@ -153,7 +155,9 @@ XPThemeDeleteProc(void *clientData) } static int -XPThemeEnabled(Ttk_Theme theme, void *clientData) +XPThemeEnabled( + Ttk_Theme theme, + void *clientData) { XPThemeData *themeData = clientData; int active = themeData->procs->IsThemeActive(); @@ -166,7 +170,8 @@ XPThemeEnabled(Ttk_Theme theme, void *clientData) * Helper routine. Returns a RECT data structure. */ static RECT -BoxToRect(Ttk_Box b) +BoxToRect( + Ttk_Box b) { RECT rc; rc.top = b.y; @@ -406,7 +411,9 @@ typedef struct } ElementData; static ElementData * -NewElementData(XPThemeProcs *procs, ElementInfo *info) +NewElementData( + XPThemeProcs *procs, + ElementInfo *info) { ElementData *elementData = (ElementData*)ckalloc(sizeof(ElementData)); @@ -417,7 +424,9 @@ NewElementData(XPThemeProcs *procs, ElementInfo *info) return elementData; } -static void DestroyElementData(void *elementData) +static void +DestroyElementData( + void *elementData) { ckfree(elementData); } @@ -434,7 +443,10 @@ static void DestroyElementData(void *elementData) */ static int -InitElementData(ElementData *elementData, Tk_Window tkwin, Drawable d) +InitElementData( + ElementData *elementData, + Tk_Window tkwin, + Drawable d) { Window win = Tk_WindowId(tkwin); @@ -460,7 +472,8 @@ InitElementData(ElementData *elementData, Tk_Window tkwin, Drawable d) } static void -FreeElementData(ElementData *elementData) +FreeElementData( + ElementData *elementData) { elementData->procs->CloseThemeData(elementData->hTheme); if (elementData->drawable != 0) { @@ -471,15 +484,19 @@ FreeElementData(ElementData *elementData) /*---------------------------------------------------------------------- * +++ Generic element implementation. - * + * * Used for elements which are handled entirely by the XP Theme API, * 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) + void *clientData, + void *elementRecord, + Tk_Window tkwin, + int *widthPtr, + int *heightPtr, + Ttk_Padding *paddingPtr) { ElementData *elementData = clientData; HRESULT result; @@ -511,8 +528,12 @@ GenericElementGeometry( static void GenericElementDraw( - void *clientData, void *elementRecord, Tk_Window tkwin, - Drawable d, Ttk_Box b, unsigned int state) + void *clientData, + void *elementRecord, + Tk_Window tkwin, + Drawable d, + Ttk_Box b, + unsigned int state) { ElementData *elementData = clientData; RECT rc; @@ -553,8 +574,12 @@ static Ttk_ElementSpec GenericElementSpec = static void ThumbElementDraw( - void *clientData, void *elementRecord, Tk_Window tkwin, - Drawable d, Ttk_Box b, unsigned int state) + 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); @@ -588,12 +613,17 @@ static Ttk_ElementSpec ThumbElementSpec = /*---------------------------------------------------------------------- * +++ Progress bar element. * Increases the requested length of PP_CHUNK and PP_CHUNKVERT parts - * so that indeterminate progress bars show 3 bars instead of 1. + * 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 +PbarElementGeometry( + void *clientData, + void *elementRecord, + Tk_Window tkwin, + int *widthPtr, + int *heightPtr, + Ttk_Padding *paddingPtr) { ElementData *elementData = clientData; int nBars = 3; @@ -621,19 +651,25 @@ static Ttk_ElementSpec PbarElementSpec = * +++ Notebook tab element. * Same as generic element, with additional logic to select * proper iPartID for the leftmost tab. - * - * Notes: TABP_TABITEMRIGHTEDGE (or TABP_TOPTABITEMRIGHTEDGE, + * + * 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 + * 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; @@ -667,7 +703,7 @@ static Ttk_ElementSpec TabElementSpec = #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 }, @@ -680,9 +716,14 @@ static Ttk_StateTable tvpglyph_statemap[] = { 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); @@ -704,11 +745,11 @@ static Ttk_ElementSpec TreeIndicatorElementSpec = *---------------------------------------------------------------------- * Text element (does not work yet). * - * According to "Using Windows XP Visual Styles", we need to select + * 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 @@ -728,8 +769,12 @@ static Ttk_ElementOptionSpec TextElementOptions[] = static void TextElementGeometry( - void *clientData, void *elementRecord, Tk_Window tkwin, - int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) + void *clientData, + void *elementRecord, + Tk_Window tkwin, + int *widthPtr, + int *heightPtr, + Ttk_Padding *paddingPtr) { TextElement *element = elementRecord; ElementData *elementData = clientData; @@ -760,10 +805,14 @@ TextElementGeometry( FreeElementData(elementData); } -static void +static void TextElementDraw( - ClientData clientData, void *elementRecord, Tk_Window tkwin, - Drawable d, Ttk_Box b, unsigned int state) + ClientData clientData, + void *elementRecord, + Tk_Window tkwin, + Drawable d, + Ttk_Box b, + unsigned int state) { TextElement *element = elementRecord; ElementData *elementData = clientData; |