diff options
author | patthoyts <patthoyts@users.sourceforge.net> | 2011-03-22 20:48:22 (GMT) |
---|---|---|
committer | patthoyts <patthoyts@users.sourceforge.net> | 2011-03-22 20:48:22 (GMT) |
commit | 5ba1f53457e736aca5c53ac1ff82a69aa27f46b1 (patch) | |
tree | f4f009187b2e165e99d4c542cdff536925aa2504 /win/ttkWinXPTheme.c | |
parent | 2d6d54e8eddb42bb1f0ea1d7e8f2a36f07b93cc8 (diff) | |
download | tk-5ba1f53457e736aca5c53ac1ff82a69aa27f46b1.zip tk-5ba1f53457e736aca5c53ac1ff82a69aa27f46b1.tar.gz tk-5ba1f53457e736aca5c53ac1ff82a69aa27f46b1.tar.bz2 |
[Bug 3000002]: enable use of system sizes for vsapi elements
Added additional flags to the vsapi element engine to enable specifying
the system metrics to use when calculating the size of certain elements.
This was being done already for the XP theme but the scripted definitions
using the vsapi engine for vista/win7 could not use such flags.
This fixes scrollbars not reflecting the users configured scrollbar size.
Reported-by: Mark Garvey <dunkfan@users.sourceforge.net>
Signed-off-by: Pat Thoyts <patthoyts@users.sourceforge.net>
Diffstat (limited to 'win/ttkWinXPTheme.c')
-rw-r--r-- | win/ttkWinXPTheme.c | 72 |
1 files changed, 69 insertions, 3 deletions
diff --git a/win/ttkWinXPTheme.c b/win/ttkWinXPTheme.c index c4a921e..4ab990c 100644 --- a/win/ttkWinXPTheme.c +++ b/win/ttkWinXPTheme.c @@ -386,6 +386,8 @@ typedef struct /* XP element specifications */ # define IGNORE_THEMESIZE 0x80000000 /* See NOTE-GetThemePartSize */ # define PAD_MARGINS 0x40000000 /* See NOTE-GetThemeMargins */ # define HEAP_ELEMENT 0x20000000 /* ElementInfo is on heap */ +# define HALF_HEIGHT 0x10000000 /* Used by GenericSizedElements */ +# define HALF_WIDTH 0x08000000 /* Used by GenericSizedElements */ } ElementInfo; typedef struct @@ -588,6 +590,10 @@ GenericSizedElementSize( (elementData->info->flags >> 8) & 0xff); *heightPtr = elementData->procs->GetThemeSysSize(NULL, elementData->info->flags & 0xff); + if (elementData->info->flags & HALF_HEIGHT) + *heightPtr /= 2; + if (elementData->info->flags & HALF_WIDTH) + *widthPtr /= 2; } static Ttk_ElementSpec GenericSizedElementSpec = { @@ -1035,6 +1041,42 @@ static ElementInfo ElementInfoTable[] = { }; #undef PAD + +static int +GetSysFlagFromObj(Tcl_Interp *interp, Tcl_Obj *objPtr, int *resultPtr) +{ + static const char *names[] = { + "SM_CXBORDER", "SM_CYBORDER", "SM_CXVSCROLL", "SM_CYVSCROLL", + "SM_CXHSCROLL", "SM_CYHSCROLL", "SM_CXMENUCHECK", "SM_CYMENUCHECK", + "SM_CXMENUSIZE", "SM_CYMENUSIZE", "SM_CXSIZE", "SM_CYSIZE", "SM_CXSMSIZE", + "SM_CYSMSIZE" + }; + int flags[] = { + SM_CXBORDER, SM_CYBORDER, SM_CXVSCROLL, SM_CYVSCROLL, + SM_CXHSCROLL, SM_CYHSCROLL, SM_CXMENUCHECK, SM_CYMENUCHECK, + SM_CXMENUSIZE, SM_CYMENUSIZE, SM_CXSIZE, SM_CYSIZE, SM_CXSMSIZE, + SM_CYSMSIZE + }; + + Tcl_Obj **objv; + int i, objc; + + if (Tcl_ListObjGetElements(interp, objPtr, &objc, &objv) != TCL_OK) + return TCL_ERROR; + if (objc != 2) { + Tcl_SetResult(interp, "wrong # args", TCL_STATIC); + return TCL_ERROR; + } + for (i = 0; i < objc; ++i) { + int option; + if (Tcl_GetIndexFromObj(interp, objv[i], names, "system constant", 0, &option) + != TCL_OK) + return TCL_ERROR; + *resultPtr |= (flags[option] << (8 * (1 - i))); + } + return TCL_OK; +} + /*---------------------------------------------------------------------- * Windows Visual Styles API Element Factory * @@ -1067,10 +1109,13 @@ Ttk_CreateVsapiElement( int length = 0; char *name; LPWSTR wname; + Ttk_ElementSpec *elementSpec = &GenericElementSpec; const char *optionStrings[] = - { "-padding","-width","-height","-margins",NULL }; - enum { O_PADDING, O_WIDTH, O_HEIGHT, O_MARGINS }; + { "-padding","-width","-height","-margins", "-syssize", + "-halfheight", "-halfwidth", NULL }; + enum { O_PADDING, O_WIDTH, O_HEIGHT, O_MARGINS, O_SYSSIZE, + O_HALFHEIGHT, O_HALFWIDTH }; if (objc < 2) { Tcl_AppendResult(interp, @@ -1122,6 +1167,27 @@ Ttk_CreateVsapiElement( pad.top = pad.bottom = tmp; flags |= IGNORE_THEMESIZE; break; + case O_SYSSIZE: + if (GetSysFlagFromObj(interp, objv[i+1], &tmp) != TCL_OK) { + return TCL_ERROR; + } + elementSpec = &GenericSizedElementSpec; + flags |= (tmp & 0xFFFF); + break; + case O_HALFHEIGHT: + if (Tcl_GetBooleanFromObj(interp, objv[i+1], &tmp) != TCL_OK) { + return TCL_ERROR; + } + if (tmp) + flags |= HALF_HEIGHT; + break; + case O_HALFWIDTH: + if (Tcl_GetBooleanFromObj(interp, objv[i+1], &tmp) != TCL_OK) { + return TCL_ERROR; + } + if (tmp) + flags |= HALF_WIDTH; + break; } } } @@ -1156,7 +1222,7 @@ Ttk_CreateVsapiElement( } elementPtr = (ElementInfo *)ckalloc(sizeof(ElementInfo)); - elementPtr->elementSpec = &GenericElementSpec; + elementPtr->elementSpec = elementSpec; elementPtr->partId = partId; elementPtr->statemap = stateTable; elementPtr->padding = pad; |