diff options
Diffstat (limited to 'win')
-rw-r--r-- | win/ttkWinTheme.c | 22 | ||||
-rw-r--r-- | win/ttkWinXPTheme.c | 48 |
2 files changed, 64 insertions, 6 deletions
diff --git a/win/ttkWinTheme.c b/win/ttkWinTheme.c index 749fe3f..e224f57 100644 --- a/win/ttkWinTheme.c +++ b/win/ttkWinTheme.c @@ -1,6 +1,6 @@ /* winTheme.c - Copyright (C) 2004 Pat Thoyts <patthoyts@users.sf.net> * - * $Id: ttkWinTheme.c,v 1.13 2008/01/08 17:01:00 jenglish Exp $ + * $Id: ttkWinTheme.c,v 1.14 2008/11/01 15:34:24 patthoyts Exp $ */ #ifdef _MSC_VER @@ -104,10 +104,12 @@ typedef struct { Ttk_Padding margins; /* additional placement padding */ } FrameControlElementData; -#define _FIXEDSIZE 0x8000 +#define _FIXEDSIZE 0x80000000L +#define _HALFMETRIC 0x40000000L #define FIXEDSIZE(id) (id|_FIXEDSIZE) +#define HALFMETRIC(id) (id|_HALFMETRIC) #define GETMETRIC(m) \ - ((m) & _FIXEDSIZE ? (m) & ~_FIXEDSIZE : GetSystemMetrics(m)) + ((m) & _FIXEDSIZE ? (m) & ~_FIXEDSIZE : GetSystemMetrics((m)&0x0fffffff)) static FrameControlElementData FrameControlElements[] = { { "Checkbutton.indicator", @@ -131,6 +133,12 @@ static FrameControlElementData FrameControlElements[] = { { "sizegrip", DFC_SCROLL, DFCS_SCROLLSIZEGRIP, SM_CXVSCROLL, SM_CYHSCROLL, arrow_statemap, {0,0,0,0} }, + { "Spinbox.uparrow", + DFC_SCROLL, DFCS_SCROLLUP, SM_CXVSCROLL, HALFMETRIC(SM_CYVSCROLL), + arrow_statemap, {0,0,0,0} }, + { "Spinbox.downarrow", + DFC_SCROLL, DFCS_SCROLLDOWN, SM_CXVSCROLL, HALFMETRIC(SM_CYVSCROLL), + arrow_statemap, {0,0,0,0} }, { 0,0,0,0,0,0, {0,0,0,0} } }; @@ -142,8 +150,12 @@ static void FrameControlElementSize( int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) { FrameControlElementData *p = clientData; - *widthPtr = GETMETRIC(p->cxId) + Ttk_PaddingWidth(p->margins); - *heightPtr = GETMETRIC(p->cyId) + Ttk_PaddingHeight(p->margins); + int cx = GETMETRIC(p->cxId); + int cy = GETMETRIC(p->cyId); + if (p->cxId & _HALFMETRIC) cx /= 2; + if (p->cyId & _HALFMETRIC) cy /= 2; + *widthPtr = cx + Ttk_PaddingWidth(p->margins); + *heightPtr = cy + Ttk_PaddingHeight(p->margins); } static void FrameControlElementDraw( diff --git a/win/ttkWinXPTheme.c b/win/ttkWinXPTheme.c index 03eaab9..27416e0 100644 --- a/win/ttkWinXPTheme.c +++ b/win/ttkWinXPTheme.c @@ -1,5 +1,5 @@ /* - * $Id: ttkWinXPTheme.c,v 1.20 2008/04/27 22:39:17 dkf Exp $ + * $Id: ttkWinXPTheme.c,v 1.21 2008/11/01 15:34:24 patthoyts Exp $ * * Tk theme engine which uses the Windows XP "Visual Styles" API * Adapted from Georgios Petasis' XP theme patch. @@ -316,6 +316,14 @@ static Ttk_StateTable rightarrow_statemap[] = { ABS_RIGHTNORMAL, 0, 0 } }; +static Ttk_StateTable spinbutton_statemap[] = +{ + { DNS_DISABLED, TTK_STATE_DISABLED, 0 }, + { DNS_PRESSED, TTK_STATE_PRESSED, 0 }, + { DNS_HOT, TTK_STATE_ACTIVE, 0 }, + { DNS_NORMAL, 0, 0 }, +}; + /* * Trackbar thumb: (Tk: "scale slider") */ @@ -586,6 +594,36 @@ static Ttk_ElementSpec GenericSizedElementSpec = { }; /*---------------------------------------------------------------------- + * +++ Spinbox arrow element. + * These are half-height scrollbar buttons. + */ + +static void +SpinboxArrowElementSize( + void *clientData, void *elementRecord, Tk_Window tkwin, + int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) +{ + ElementData *elementData = clientData; + + if (!InitElementData(elementData, tkwin, 0)) + return; + + GenericSizedElementSize(clientData, elementRecord, tkwin, + widthPtr, heightPtr, paddingPtr); + + /* force the arrow button height to half size */ + *heightPtr /= 2; +} + +static Ttk_ElementSpec SpinboxArrowElementSpec = { + TK_STYLE_VERSION_2, + sizeof(NullElement), + TtkNullElementOptions, + SpinboxArrowElementSize, + GenericElementDraw +}; + +/*---------------------------------------------------------------------- * +++ Scrollbar thumb element. * Same as a GenericElement, but don't draw in the disabled state. */ @@ -964,6 +1002,14 @@ static ElementInfo ElementInfoTable[] = { HP_HEADERITEM, header_statemap, PAD(4,0,4,0),0 }, { "sizegrip", &GenericElementSpec, L"STATUS", SP_GRIPPER, null_statemap, NOPAD,0 }, + { "Spinbox.field", &GenericElementSpec, L"EDIT", + EP_EDITTEXT, edittext_statemap, PAD(1, 1, 1, 1), 0 }, + { "Spinbox.uparrow", &SpinboxArrowElementSpec, L"SPIN", + SPNP_UP, spinbutton_statemap, NOPAD, + PAD_MARGINS | ((SM_CXVSCROLL << 8) | SM_CYVSCROLL) }, + { "Spinbox.downarrow", &SpinboxArrowElementSpec, L"SPIN", + SPNP_DOWN, spinbutton_statemap, NOPAD, + PAD_MARGINS | ((SM_CXVSCROLL << 8) | SM_CYVSCROLL) }, #if BROKEN_TEXT_ELEMENT { "Labelframe.text", &TextElementSpec, L"BUTTON", |