diff options
-rw-r--r-- | generic/ttk/ttkClamTheme.c | 10 | ||||
-rw-r--r-- | generic/ttk/ttkDefaultTheme.c | 3 | ||||
-rw-r--r-- | generic/ttk/ttkNotebook.c | 4 | ||||
-rw-r--r-- | generic/ttk/ttkState.c | 84 | ||||
-rw-r--r-- | generic/ttk/ttkThemeInt.h | 9 | ||||
-rw-r--r-- | generic/ttk/ttkTreeview.c | 3 | ||||
-rw-r--r-- | macosx/ttkMacOSXTheme.c | 34 | ||||
-rw-r--r-- | macosx/ttkMacOSXTheme.h | 2 | ||||
-rw-r--r-- | win/ttkWinXPTheme.c | 5 |
9 files changed, 75 insertions, 79 deletions
diff --git a/generic/ttk/ttkClamTheme.c b/generic/ttk/ttkClamTheme.c index caa58b7..b1c897e 100644 --- a/generic/ttk/ttkClamTheme.c +++ b/generic/ttk/ttkClamTheme.c @@ -5,7 +5,7 @@ */ #include "tkInt.h" -#include "ttkTheme.h" +#include "ttkThemeInt.h" /* * Under windows, the Tk-provided XDrawLine and XDrawArc have an @@ -1032,7 +1032,7 @@ static void TabElementDraw( switch (nbTabsStickBit) { default: case TTK_STICK_S: - if (state & TTK_STATE_USER2) { /* rightmost tab */ + if (state & TTK_STATE_LAST) { /* rightmost tab */ --b.width; } @@ -1054,7 +1054,7 @@ static void TabElementDraw( break; case TTK_STICK_N: - if (state & TTK_STATE_USER2) { /* rightmost tab */ + if (state & TTK_STATE_LAST) { /* rightmost tab */ --b.width; } @@ -1076,7 +1076,7 @@ static void TabElementDraw( break; case TTK_STICK_E: - if (state & TTK_STATE_USER2) { /* bottommost tab */ + if (state & TTK_STATE_LAST) { /* bottommost tab */ --b.height; } @@ -1098,7 +1098,7 @@ static void TabElementDraw( break; case TTK_STICK_W: - if (state & TTK_STATE_USER2) { /* bottommost tab */ + if (state & TTK_STATE_LAST) { /* bottommost tab */ --b.height; } diff --git a/generic/ttk/ttkDefaultTheme.c b/generic/ttk/ttkDefaultTheme.c index 3cfa8c0..4c2fcd3 100644 --- a/generic/ttk/ttkDefaultTheme.c +++ b/generic/ttk/ttkDefaultTheme.c @@ -1208,9 +1208,6 @@ static const Ttk_ElementSpec SliderElementSpec = { * +++ Tree indicator element. */ -#define TTK_STATE_OPEN TTK_STATE_USER1 /* XREF: treeview.c */ -#define TTK_STATE_LEAF TTK_STATE_USER2 - typedef struct { Tcl_Obj *colorObj; Tcl_Obj *marginObj; diff --git a/generic/ttk/ttkNotebook.c b/generic/ttk/ttkNotebook.c index 173eeb7..416ee7f 100644 --- a/generic/ttk/ttkNotebook.c +++ b/generic/ttk/ttkNotebook.c @@ -317,7 +317,7 @@ static Ttk_State TabState(Notebook *nb, Tcl_Size index) continue; } if (index == i) { - state |= TTK_STATE_USER1; + state |= TTK_STATE_FIRST; } break; } @@ -327,7 +327,7 @@ static Ttk_State TabState(Notebook *nb, Tcl_Size index) continue; } if (index == i) { - state |= TTK_STATE_USER2; + state |= TTK_STATE_LAST; } break; } diff --git a/generic/ttk/ttkState.c b/generic/ttk/ttkState.c index 595a3a6..be15fdb 100644 --- a/generic/ttk/ttkState.c +++ b/generic/ttk/ttkState.c @@ -9,28 +9,29 @@ #include "ttkTheme.h" /* - * Table of state names. Must be kept in sync with TTK_STATE_* - * #defines in ttkTheme.h. + * Table of state names. */ -static const char *const stateNames[] = -{ - "active", /* Mouse cursor is over widget or element */ - "disabled", /* Widget is disabled */ - "focus", /* Widget has keyboard focus */ - "pressed", /* Pressed or "armed" */ - "selected", /* "on", "true", "current", etc. */ - "background", /* Top-level window lost focus (Mac,Win "inactive") */ - "alternate", /* Widget-specific alternate display style */ - "invalid", /* Bad value */ - "readonly", /* Editing/modification disabled */ - "hover", /* Mouse cursor is over widget */ - "user6", /* User-definable state */ - "user5", /* User-definable state */ - "user4", /* User-definable state */ - "user3", /* User-definable state */ - "user2", /* User-definable state */ - "user1", /* User-definable state */ - NULL +static const struct { + char name[12]; + int value; +} stateNames[] = { + {"active", TTK_STATE_ACTIVE}, /* Mouse cursor is over widget or element */ + {"alternate", TTK_STATE_ALTERNATE}, /* Widget-specific alternate display style */ + {"background", TTK_STATE_BACKGROUND}, /* Top-level window lost focus (Mac,Win "inactive") */ + {"disabled", TTK_STATE_DISABLED}, /* Widget is disabled */ + {"focus", TTK_STATE_FOCUS}, /* Widget has keyboard focus */ + {"hover", TTK_STATE_HOVER}, /* Mouse cursor is over widget */ + {"invalid", TTK_STATE_INVALID}, /* Bad value */ + {"pressed", TTK_STATE_PRESSED}, /* Pressed or "armed" */ + {"readonly", TTK_STATE_READONLY}, /* Editing/modification disabled */ + {"selected", TTK_STATE_SELECTED}, /* "on", "true", "current", etc. */ + {"user1", TTK_STATE_USER1}, /* User-definable state */ + {"user2", TTK_STATE_USER2}, /* User-definable state */ + {"user3", TTK_STATE_USER3}, /* User-definable state */ + {"user4", TTK_STATE_USER4}, /* User-definable state */ + {"user5", TTK_STATE_USER5}, /* User-definable state */ + {"user6", TTK_STATE_USER6}, /* User-definable state */ + {"", 0} }; /*------------------------------------------------------------------------ @@ -39,14 +40,12 @@ static const char *const stateNames[] = * The string representation consists of a list of state names, * each optionally prefixed by an exclamation point (!). * - * The internal representation uses the upper half of the longValue + * The internal representation uses the upper half of the wideValue * to store the on bits and the lower half to store the off bits. - * If we ever get more than 16 states, this will need to be reconsidered... + * If we ever get more than 32 states, this will need to be reconsidered... */ static int StateSpecSetFromAny(Tcl_Interp *interp, Tcl_Obj *obj); -/* static void StateSpecFreeIntRep(Tcl_Obj *); */ -#define StateSpecFreeIntRep 0 /* not needed */ static void StateSpecDupIntRep(Tcl_Obj *, Tcl_Obj *); static void StateSpecUpdateString(Tcl_Obj *); @@ -54,7 +53,7 @@ static const TkObjType StateSpecObjType = { {"StateSpec", - StateSpecFreeIntRep, + 0, StateSpecDupIntRep, StateSpecUpdateString, StateSpecSetFromAny, @@ -64,7 +63,7 @@ TkObjType StateSpecObjType = static void StateSpecDupIntRep(Tcl_Obj *srcPtr, Tcl_Obj *copyPtr) { - copyPtr->internalRep.longValue = srcPtr->internalRep.longValue; + copyPtr->internalRep.wideValue = srcPtr->internalRep.wideValue; copyPtr->typePtr = &StateSpecObjType.objType; } @@ -90,12 +89,12 @@ static int StateSpecSetFromAny(Tcl_Interp *interp, Tcl_Obj *objPtr) on = 1; } - for (j = 0; stateNames[j] != 0; ++j) { - if (strcmp(stateName, stateNames[j]) == 0) + for (j = 0; stateNames[j].value; ++j) { + if (strcmp(stateName, stateNames[j].name) == 0) break; } - if (stateNames[j] == 0) { + if (stateNames[j].value == 0) { if (interp) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "Invalid state name %s", stateName)); @@ -105,9 +104,9 @@ static int StateSpecSetFromAny(Tcl_Interp *interp, Tcl_Obj *objPtr) } if (on) { - onbits |= (1<<j); + onbits |= stateNames[j].value; } else { - offbits |= (1<<j); + offbits |= stateNames[j].value; } } @@ -118,15 +117,15 @@ static int StateSpecSetFromAny(Tcl_Interp *interp, Tcl_Obj *objPtr) } objPtr->typePtr = &StateSpecObjType.objType; - objPtr->internalRep.longValue = (onbits << 16) | offbits; + objPtr->internalRep.wideValue = ((Tcl_WideInt)onbits << 32) | offbits; return TCL_OK; } static void StateSpecUpdateString(Tcl_Obj *objPtr) { - unsigned int onbits = (objPtr->internalRep.longValue & 0xFFFF0000) >> 16; - unsigned int offbits = objPtr->internalRep.longValue & 0x0000FFFF; + unsigned int onbits = objPtr->internalRep.wideValue >> 32; + unsigned int offbits = objPtr->internalRep.wideValue & 0xFFFFFFFFLL; unsigned int mask = onbits | offbits; Tcl_DString result; int i; @@ -134,11 +133,12 @@ static void StateSpecUpdateString(Tcl_Obj *objPtr) Tcl_DStringInit(&result); - for (i=0; stateNames[i] != NULL; ++i) { - if (mask & (1<<i)) { - if (offbits & (1<<i)) + for (i=0; stateNames[i].value; ++i) { + if (mask & stateNames[i].value) { + if (offbits & stateNames[i].value) { Tcl_DStringAppend(&result, "!", 1); - Tcl_DStringAppend(&result, stateNames[i], TCL_INDEX_NONE); + } + Tcl_DStringAppend(&result, stateNames[i].name, TCL_INDEX_NONE); Tcl_DStringAppend(&result, " ", 1); } } @@ -166,7 +166,7 @@ Tcl_Obj *Ttk_NewStateSpecObj(unsigned int onbits, unsigned int offbits) Tcl_InvalidateStringRep(objPtr); objPtr->typePtr = &StateSpecObjType.objType; - objPtr->internalRep.longValue = (onbits << 16) | offbits; + objPtr->internalRep.wideValue = ((Tcl_WideInt)onbits << 32) | offbits; return objPtr; } @@ -182,8 +182,8 @@ int Ttk_GetStateSpecFromObj( return status; } - spec->onbits = (objPtr->internalRep.longValue & 0xFFFF0000) >> 16; - spec->offbits = objPtr->internalRep.longValue & 0x0000FFFF; + spec->onbits = objPtr->internalRep.wideValue >> 32; + spec->offbits = objPtr->internalRep.wideValue & 0xFFFFFFFFLL; return TCL_OK; } diff --git a/generic/ttk/ttkThemeInt.h b/generic/ttk/ttkThemeInt.h index 3414a2a..79848d0 100644 --- a/generic/ttk/ttkThemeInt.h +++ b/generic/ttk/ttkThemeInt.h @@ -9,6 +9,15 @@ #include "ttkTheme.h" +/*------------------------------------------------------------------------ + * +++ Widget states (internal). + */ + +#define TTK_STATE_OPEN (1<<16) +#define TTK_STATE_LEAF (1<<17) +#define TTK_STATE_FIRST (1<<18) +#define TTK_STATE_LAST (1<<19) + typedef struct Ttk_TemplateNode_ Ttk_TemplateNode, *Ttk_LayoutTemplate; MODULE_SCOPE Ttk_ElementClass *Ttk_GetElement(Ttk_Theme, const char *name); diff --git a/generic/ttk/ttkTreeview.c b/generic/ttk/ttkTreeview.c index ef2da74..3e950ee 100644 --- a/generic/ttk/ttkTreeview.c +++ b/generic/ttk/ttkTreeview.c @@ -23,9 +23,6 @@ static const Tk_Anchor DEFAULT_IMAGEANCHOR = TK_ANCHOR_W; static const int DEFAULT_INDENT = 20; static const int HALO = 4; /* heading separator */ -#define TTK_STATE_OPEN TTK_STATE_USER1 -#define TTK_STATE_LEAF TTK_STATE_USER2 - #define STATE_CHANGED (0x100) /* item state option changed */ #define MAX(a,b) (((a) > (b)) ? (a) : (b)) diff --git a/macosx/ttkMacOSXTheme.c b/macosx/ttkMacOSXTheme.c index 9231f80..ff850f0 100644 --- a/macosx/ttkMacOSXTheme.c +++ b/macosx/ttkMacOSXTheme.c @@ -30,7 +30,7 @@ */ #include "tkMacOSXPrivate.h" -#include "ttk/ttkTheme.h" +#include "ttk/ttkThemeInt.h" #include "ttkMacOSXTheme.h" #include "tkColor.h" #include <math.h> @@ -1488,11 +1488,11 @@ DrawTab( CGContextClipToRect(context, bounds); if (OSVersion < 110000 || !(state & TTK_STATE_SELECTED)) { - if (!(state & TTK_STATE_FIRST_TAB)) { + if (!(state & TTK_STATE_FIRST)) { bounds.origin.x -= 10; bounds.size.width += 10; } - if (!(state & TTK_STATE_LAST_TAB)) { + if (!(state & TTK_STATE_LAST)) { bounds.size.width += 10; } } @@ -1510,7 +1510,7 @@ DrawTab( * not first. */ - if (!(state & TTK_STATE_FIRST_TAB)) { + if (!(state & TTK_STATE_FIRST)) { CGContextSaveGState(context); strokeColor = CGColorFromGray(darkTabSeparator); CGContextSetStrokeColorWithColor(context, strokeColor); @@ -1530,7 +1530,7 @@ DrawTab( * (The selected tab is always drawn last.) */ - if ((state & TTK_STATE_FIRST_TAB) && !(state & TTK_STATE_LAST_TAB)) { + if ((state & TTK_STATE_FIRST) && !(state & TTK_STATE_LAST)) { bounds.size.width += 1; } if (!(state & TTK_STATE_BACKGROUND)) { @@ -1559,12 +1559,12 @@ DrawTab11( * rounded rectangle behind the entire tab bar. */ - if (!(state & TTK_STATE_FIRST_TAB)) { + if (!(state & TTK_STATE_FIRST)) { clipRect.origin.x -= 5; bounds.origin.x -= 5; bounds.size.width += 5; } - if (!(state & TTK_STATE_LAST_TAB)) { + if (!(state & TTK_STATE_LAST)) { clipRect.size.width += 5; bounds.size.width += 5; } @@ -1874,15 +1874,15 @@ static const Ttk_StateTable TabStyleTable[] = { {kThemeTabNonFront, 0, 0} }; static const Ttk_StateTable TabAdornmentTable[] = { - {kHIThemeTabAdornmentNone, TTK_STATE_FIRST_TAB | TTK_STATE_LAST_TAB, 0}, - {kHIThemeTabAdornmentTrailingSeparator, TTK_STATE_FIRST_TAB, 0}, - {kHIThemeTabAdornmentNone, TTK_STATE_LAST_TAB, 0}, + {kHIThemeTabAdornmentNone, TTK_STATE_FIRST | TTK_STATE_LAST, 0}, + {kHIThemeTabAdornmentTrailingSeparator, TTK_STATE_FIRST, 0}, + {kHIThemeTabAdornmentNone, TTK_STATE_LAST, 0}, {kHIThemeTabAdornmentTrailingSeparator, 0, 0}, }; static const Ttk_StateTable TabPositionTable[] = { - {kHIThemeTabPositionOnly, TTK_STATE_FIRST_TAB | TTK_STATE_LAST_TAB, 0}, - {kHIThemeTabPositionFirst, TTK_STATE_FIRST_TAB, 0}, - {kHIThemeTabPositionLast, TTK_STATE_LAST_TAB, 0}, + {kHIThemeTabPositionOnly, TTK_STATE_FIRST | TTK_STATE_LAST, 0}, + {kHIThemeTabPositionFirst, TTK_STATE_FIRST, 0}, + {kHIThemeTabPositionLast, TTK_STATE_LAST, 0}, {kHIThemeTabPositionMiddle, 0, 0}, }; @@ -3321,10 +3321,8 @@ static Ttk_ElementSpec TreeHeaderElementSpec = { * +++ Disclosure triangles -- */ -#define TTK_TREEVIEW_STATE_OPEN TTK_STATE_USER1 -#define TTK_TREEVIEW_STATE_LEAF TTK_STATE_USER2 static const Ttk_StateTable DisclosureValueTable[] = { - {kThemeDisclosureDown, TTK_TREEVIEW_STATE_OPEN, 0}, + {kThemeDisclosureDown, TTK_STATE_OPEN, 0}, {kThemeDisclosureRight, 0, 0}, }; static void DisclosureElementSize( @@ -3351,7 +3349,7 @@ static void DisclosureElementDraw( Ttk_Box b, Ttk_State state) { - if (!(state & TTK_TREEVIEW_STATE_LEAF)) { + if (!(state & TTK_STATE_LEAF)) { int triangleState = TkMacOSXInDarkMode(tkwin) ? kThemeStateInactive : kThemeStateActive; CGRect bounds = BoxToRect(d, b); @@ -3370,7 +3368,7 @@ static void DisclosureElementDraw( NSColor *stroke = [[NSColor textColor] colorUsingColorSpace: deviceRGB]; [stroke getComponents: rgba]; - if (state & TTK_TREEVIEW_STATE_OPEN) { + if (state & TTK_STATE_OPEN) { DrawOpenDisclosure(dc.context, bounds, 2, 8, rgba); } else { DrawClosedDisclosure(dc.context, bounds, 2, 12, rgba); diff --git a/macosx/ttkMacOSXTheme.h b/macosx/ttkMacOSXTheme.h index 994cb10..1e2b7ae 100644 --- a/macosx/ttkMacOSXTheme.h +++ b/macosx/ttkMacOSXTheme.h @@ -38,8 +38,6 @@ * Meanings of Ttk states represented by User1 and User2. */ -#define TTK_STATE_FIRST_TAB TTK_STATE_USER1 -#define TTK_STATE_LAST_TAB TTK_STATE_USER2 #define TTK_STATE_IS_ACCENTED TTK_STATE_USER2 #define TTK_TREEVIEW_STATE_SORTARROW TTK_STATE_USER1 diff --git a/win/ttkWinXPTheme.c b/win/ttkWinXPTheme.c index 15a28d0..463d60d 100644 --- a/win/ttkWinXPTheme.c +++ b/win/ttkWinXPTheme.c @@ -19,7 +19,7 @@ #include <windows.h> #include <uxtheme.h> #include <vssym32.h> -#include "ttk/ttkTheme.h" +#include "ttk/ttkThemeInt.h" typedef HTHEME (STDAPICALLTYPE OpenThemeDataProc)(HWND hwnd, LPCWSTR pszClassList); @@ -866,9 +866,6 @@ static const Ttk_ElementSpec TabElementSpec = * 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 const Ttk_StateTable header_statemap[] = { { HIS_PRESSED, TTK_STATE_PRESSED, 0 }, |