From 77f93393c12a891b1f70d1d192302b41fe82a5a8 Mon Sep 17 00:00:00 2001 From: csaba Date: Mon, 13 Nov 2023 17:26:02 +0000 Subject: [PATCH 1/3] Using the application's TkMainInfo struct for sharing the nbTabsStickBit in a thread-safe manner. Thanks Christian W.! --- generic/tkInt.h | 2 ++ generic/ttk/ttkClamTheme.c | 16 +++++++++++++--- generic/ttk/ttkElements.c | 15 +++++++++++++-- generic/ttk/ttkNotebook.c | 21 +++++++++++---------- win/ttkWinTheme.c | 15 +++++++++++++-- win/ttkWinXPTheme.c | 15 +++++++++++++-- 6 files changed, 65 insertions(+), 19 deletions(-) diff --git a/generic/tkInt.h b/generic/tkInt.h index e31bc1b1e..0742563b9 100644 --- a/generic/tkInt.h +++ b/generic/tkInt.h @@ -693,6 +693,8 @@ typedef struct TkMainInfo { /* Saved Tcl [update] command, used to restore * Tcl's version of [update] after Tk is shut * down */ + unsigned int ttkNbTabsStickBit; + /* Information used by ttk::notebook. */ } TkMainInfo; /* diff --git a/generic/ttk/ttkClamTheme.c b/generic/ttk/ttkClamTheme.c index 904277005..1081c4b71 100644 --- a/generic/ttk/ttkClamTheme.c +++ b/generic/ttk/ttkClamTheme.c @@ -850,12 +850,12 @@ static Ttk_ElementOptionSpec NotebookElementOptions[] = { { NULL, TK_OPTION_BOOLEAN, 0, NULL } }; -extern Ttk_PositionSpec nbTabsStickBit; /* see ttkNotebook.c */ - static void TabElementSize( void *dummy, void *elementRecord, Tk_Window tkwin, int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) { + Ttk_PositionSpec nbTabsStickBit = TTK_STICK_S; + TkMainInfo *mainInfoPtr = ((TkWindow *) tkwin)->mainPtr; int borderWidth = 2; (void)dummy; (void)elementRecord; @@ -863,6 +863,10 @@ static void TabElementSize( (void)widthPtr; (void)heightPtr; + if (mainInfoPtr != NULL) { + nbTabsStickBit = (Ttk_PositionSpec) mainInfoPtr->ttkNbTabsStickBit; + } + *paddingPtr = Ttk_UniformPadding((short)borderWidth); switch (nbTabsStickBit) { default: @@ -885,15 +889,21 @@ static void TabElementDraw( void *dummy, void *elementRecord, Tk_Window tkwin, Drawable d, Ttk_Box b, unsigned int state) { + Ttk_PositionSpec nbTabsStickBit = TTK_STICK_S; + TkMainInfo *mainInfoPtr = ((TkWindow *) tkwin)->mainPtr; + int borderWidth = 2, delta = 0; NotebookElement *tab = (NotebookElement *)elementRecord; Tk_3DBorder border = Tk_Get3DBorderFromObj(tkwin, tab->backgroundObj); Display *display = Tk_Display(tkwin); - int borderWidth = 2, delta = 0; int x1, y1, x2, y2; GC gc; const int w = WIN32_XDRAWLINE_HACK; (void)dummy; + if (mainInfoPtr != NULL) { + nbTabsStickBit = (Ttk_PositionSpec) mainInfoPtr->ttkNbTabsStickBit; + } + if (state & TTK_STATE_SELECTED) { delta = borderWidth; } diff --git a/generic/ttk/ttkElements.c b/generic/ttk/ttkElements.c index 61b73ce0e..2520ced4e 100644 --- a/generic/ttk/ttkElements.c +++ b/generic/ttk/ttkElements.c @@ -1106,17 +1106,22 @@ static Ttk_ElementOptionSpec TabElementOptions[] = { {0,0,0,0} }; -extern Ttk_PositionSpec nbTabsStickBit; /* see ttkNotebook.c */ - static void TabElementSize( void *clientData, void *elementRecord, Tk_Window tkwin, int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) { TabElement *tab = (TabElement *)elementRecord; int borderWidth = 1; + Ttk_PositionSpec nbTabsStickBit = TTK_STICK_S; + TkMainInfo *mainInfoPtr = ((TkWindow *) tkwin)->mainPtr; Tk_GetPixelsFromObj(0, tkwin, tab->borderWidthObj, &borderWidth); *paddingPtr = Ttk_UniformPadding((short)borderWidth); + + if (mainInfoPtr != NULL) { + nbTabsStickBit = (Ttk_PositionSpec) mainInfoPtr->ttkNbTabsStickBit; + } + switch (nbTabsStickBit) { default: case TTK_STICK_S: @@ -1138,6 +1143,8 @@ static void TabElementDraw( void *clientData, void *elementRecord, Tk_Window tkwin, Drawable d, Ttk_Box b, unsigned int state) { + Ttk_PositionSpec nbTabsStickBit = TTK_STICK_S; + TkMainInfo *mainInfoPtr = ((TkWindow *) tkwin)->mainPtr; TabElement *tab = (TabElement *)elementRecord; Tk_3DBorder border = Tk_Get3DBorderFromObj(tkwin, tab->backgroundObj); XPoint pts[6]; @@ -1145,6 +1152,10 @@ static void TabElementDraw( Display *disp = Tk_Display(tkwin); int borderWidth = 1; + if (mainInfoPtr != NULL) { + nbTabsStickBit = (Ttk_PositionSpec) mainInfoPtr->ttkNbTabsStickBit; + } + if (state & TTK_STATE_SELECTED) { /* * Draw slightly outside of the allocated parcel, diff --git a/generic/ttk/ttkNotebook.c b/generic/ttk/ttkNotebook.c index 02a554624..600eca91d 100644 --- a/generic/ttk/ttkNotebook.c +++ b/generic/ttk/ttkNotebook.c @@ -136,14 +136,11 @@ typedef struct Ttk_Padding padding; /* External padding */ } NotebookStyle; -/* Global variable to be set from within NotebookStyleOptions() to one - * of the values TTK_STICK_S, TTK_STICK_N, TTK_STICK_E, or TTK_STICK_W: - */ -Ttk_PositionSpec nbTabsStickBit; - -static void NotebookStyleOptions(Notebook *nb, NotebookStyle *nbstyle) +static void NotebookStyleOptions( + Notebook *nb, NotebookStyle *nbstyle, Tk_Window tkwin) { Tcl_Obj *objPtr; + TkMainInfo *mainInfoPtr = ((TkWindow *) tkwin)->mainPtr; nbstyle->tabPosition = TTK_PACK_TOP | TTK_STICK_W; if ((objPtr = Ttk_QueryOption(nb->core.layout, "-tabposition", 0)) != 0) { @@ -165,9 +162,12 @@ static void NotebookStyleOptions(Notebook *nb, NotebookStyle *nbstyle) TtkGetLabelAnchorFromObj(NULL, objPtr, &nbstyle->tabPlacement); } - /* Save the stick bit in the global variable nbTabsStickBit + /* Save the stick bit for later. One of the values + * TTK_STICK_S, TTK_STICK_N, TTK_STICK_E, or TTK_STICK_W: */ - nbTabsStickBit = (nbstyle->tabPlacement & 0x0f); + if (mainInfoPtr != NULL) { + mainInfoPtr->ttkNbTabsStickBit = (nbstyle->tabPlacement & 0x0f); + } /* Compute tabOrient as function of tabPlacement: */ @@ -395,6 +395,7 @@ static void TabrowSize( static int NotebookSize(void *clientData, int *widthPtr, int *heightPtr) { Notebook *nb = (Notebook *)clientData; + Tk_Window nbwin = nb->core.tkwin; NotebookStyle nbstyle; Ttk_Padding padding; Ttk_Element clientNode = Ttk_FindElement(nb->core.layout, "client"); @@ -403,7 +404,7 @@ static int NotebookSize(void *clientData, int *widthPtr, int *heightPtr) tabrowWidth = 0, tabrowHeight = 0; int i; - NotebookStyleOptions(nb, &nbstyle); + NotebookStyleOptions(nb, &nbstyle, nbwin); /* Compute max requested size of all content windows: */ @@ -553,7 +554,7 @@ static void NotebookDoLayout(void *recordPtr) NotebookStyle nbstyle; int currentIndex = nb->notebook.currentIndex; - NotebookStyleOptions(nb, &nbstyle); + NotebookStyleOptions(nb, &nbstyle, nbwin); /* Notebook internal padding: */ diff --git a/win/ttkWinTheme.c b/win/ttkWinTheme.c index 46be6f09e..e797206a7 100644 --- a/win/ttkWinTheme.c +++ b/win/ttkWinTheme.c @@ -658,17 +658,22 @@ static const Ttk_ElementOptionSpec TabElementOptions[] = { {0,TK_OPTION_BOOLEAN,0,0} }; -extern Ttk_PositionSpec nbTabsStickBit; /* see ttkNotebook.c */ - static void TabElementSize( void *clientData, void *elementRecord, Tk_Window tkwin, int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) { TabElement *tab = (TabElement *)elementRecord; int borderWidth = 1; + Ttk_PositionSpec nbTabsStickBit = TTK_STICK_S; + TkMainInfo *mainInfoPtr = ((TkWindow *) tkwin)->mainPtr; Tk_GetPixelsFromObj(0, tkwin, tab->borderWidthObj, &borderWidth); *paddingPtr = Ttk_UniformPadding((short)borderWidth); + + if (mainInfoPtr != NULL) { + nbTabsStickBit = (Ttk_PositionSpec) mainInfoPtr->ttkNbTabsStickBit; + } + switch (nbTabsStickBit) { default: case TTK_STICK_S: @@ -690,6 +695,8 @@ static void TabElementDraw( void *clientData, void *elementRecord, Tk_Window tkwin, Drawable d, Ttk_Box b, unsigned int state) { + Ttk_PositionSpec nbTabsStickBit = TTK_STICK_S; + TkMainInfo *mainInfoPtr = ((TkWindow *) tkwin)->mainPtr; TabElement *tab = (TabElement *)elementRecord; Tk_3DBorder border = Tk_Get3DBorderFromObj(tkwin, tab->backgroundObj); XPoint pts[6]; @@ -697,6 +704,10 @@ static void TabElementDraw( Display *disp = Tk_Display(tkwin); int borderWidth = 1; + if (mainInfoPtr != NULL) { + nbTabsStickBit = (Ttk_PositionSpec) mainInfoPtr->ttkNbTabsStickBit; + } + if (state & TTK_STATE_SELECTED) { /* * Draw slightly outside of the allocated parcel, diff --git a/win/ttkWinXPTheme.c b/win/ttkWinXPTheme.c index cfa6bf410..3593c9a54 100644 --- a/win/ttkWinXPTheme.c +++ b/win/ttkWinXPTheme.c @@ -728,12 +728,17 @@ static Ttk_ElementSpec PbarElementSpec = * we can use the same statemap no matter what the partId. */ -extern Ttk_PositionSpec nbTabsStickBit; /* see ttkNotebook.c */ - static void TabElementSize( void *clientData, void *elementRecord, Tk_Window tkwin, int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) { + Ttk_PositionSpec nbTabsStickBit = TTK_STICK_S; + TkMainInfo *mainInfoPtr = ((TkWindow *) tkwin)->mainPtr; + + if (mainInfoPtr != NULL) { + nbTabsStickBit = (Ttk_PositionSpec) mainInfoPtr->ttkNbTabsStickBit; + } + GenericElementSize(clientData, elementRecord, tkwin, widthPtr, heightPtr, paddingPtr); @@ -759,11 +764,17 @@ static void TabElementDraw( void *clientData, void *elementRecord, Tk_Window tkwin, Drawable d, Ttk_Box b, unsigned int state) { + Ttk_PositionSpec nbTabsStickBit = TTK_STICK_S; + TkMainInfo *mainInfoPtr = ((TkWindow *) tkwin)->mainPtr; ElementData *elementData = (ElementData *)clientData; int partId = elementData->info->partId; int isSelected = (state & TTK_STATE_SELECTED); int stateId = Ttk_StateTableLookup(elementData->info->statemap, state); + if (mainInfoPtr != NULL) { + nbTabsStickBit = (Ttk_PositionSpec) mainInfoPtr->ttkNbTabsStickBit; + } + /* * Correct the members of b if needed */ From 5bf51441dc9e76798a384cffcec208e3db3a2962 Mon Sep 17 00:00:00 2001 From: csaba Date: Tue, 14 Nov 2023 18:34:58 +0000 Subject: [PATCH 2/3] Using the application's TkMainInfo struct for sharing the nbTabsStickBit in a thread-safe manner. Thanks Christian W.! --- generic/tkInt.h | 3 ++- generic/ttk/ttkClamTheme.c | 37 ++++++++++++++++++++++--------------- generic/ttk/ttkElements.c | 15 +++++++++++++-- generic/ttk/ttkNotebook.c | 21 +++++++++++---------- win/ttkWinTheme.c | 15 +++++++++++++-- win/ttkWinXPTheme.c | 15 +++++++++++++-- 6 files changed, 74 insertions(+), 32 deletions(-) diff --git a/generic/tkInt.h b/generic/tkInt.h index ec6d243b5..464ef74b7 100644 --- a/generic/tkInt.h +++ b/generic/tkInt.h @@ -723,7 +723,8 @@ typedef struct TkMainInfo { * Tcl's version of [update] after Tk is shut * down, in case it's a Tcl_ObjCmdProc2 */ #endif - + unsigned int ttkNbTabsStickBit; + /* Information used by ttk::notebook. */ } TkMainInfo; /* diff --git a/generic/ttk/ttkClamTheme.c b/generic/ttk/ttkClamTheme.c index 70d19387e..e17ee8264 100644 --- a/generic/ttk/ttkClamTheme.c +++ b/generic/ttk/ttkClamTheme.c @@ -545,7 +545,7 @@ static const Ttk_ElementSpec IndicatorElementSpec = { typedef struct { Tcl_Obj *lightColorObj; Tcl_Obj *borderColorObj; - Tcl_Obj *gripCountObj; + Tcl_Obj *gripSizeObj; } GripElement; static const Ttk_ElementOptionSpec GripElementOptions[] = { @@ -553,8 +553,8 @@ static const Ttk_ElementOptionSpec GripElementOptions[] = { offsetof(GripElement,lightColorObj), LIGHT_COLOR }, { "-bordercolor", TK_OPTION_COLOR, offsetof(GripElement,borderColorObj), DARKEST_COLOR }, - { "-gripcount", TK_OPTION_PIXELS, - offsetof(GripElement,gripCountObj), "5" }, + { "-gripsize", TK_OPTION_PIXELS, + offsetof(GripElement,gripSizeObj), "7.5p" }, { NULL, TK_OPTION_BOOLEAN, 0, NULL } }; @@ -567,8 +567,7 @@ static void GripElementSize( int gripSize = 0; (void)paddingPtr; - Tk_GetPixelsFromObj(NULL, tkwin, grip->gripCountObj, &gripSize); - gripSize *= 2; + Tk_GetPixelsFromObj(NULL, tkwin, grip->gripSizeObj, &gripSize); if (orient == TTK_ORIENT_HORIZONTAL) { *widthPtr = gripSize; } else { @@ -589,8 +588,7 @@ static void GripElementDraw( int i; (void)state; - Tk_GetPixelsFromObj(NULL, tkwin, grip->gripCountObj, &gripSize); - gripSize *= 2; + Tk_GetPixelsFromObj(NULL, tkwin, grip->gripSizeObj, &gripSize); if (orient == TTK_ORIENT_HORIZONTAL) { int x = b.x + (b.width - gripSize) / 2; @@ -633,7 +631,7 @@ typedef struct { /* Common element record for scrollbar elements */ Tcl_Obj *darkColorObj; Tcl_Obj *arrowColorObj; Tcl_Obj *arrowSizeObj; - Tcl_Obj *gripCountObj; + Tcl_Obj *gripSizeObj; Tcl_Obj *sliderlengthObj; } ScrollbarElement; @@ -654,8 +652,8 @@ static const Ttk_ElementOptionSpec ScrollbarElementOptions[] = { offsetof(ScrollbarElement,arrowColorObj), "#000000" }, { "-arrowsize", TK_OPTION_PIXELS, offsetof(ScrollbarElement,arrowSizeObj), STR(SCROLLBAR_THICKNESS) }, - { "-gripcount", TK_OPTION_PIXELS, - offsetof(ScrollbarElement,gripCountObj), "5" }, + { "-gripsize", TK_OPTION_PIXELS, + offsetof(ScrollbarElement,gripSizeObj), "7.5p" }, { "-sliderlength", TK_OPTION_PIXELS, offsetof(ScrollbarElement,sliderlengthObj), "30" }, { NULL, TK_OPTION_BOOLEAN, 0, NULL } @@ -720,8 +718,7 @@ static void ThumbElementDraw( * Draw grip: */ TtkGetOrientFromObj(NULL, sb->orientObj, &orient); - Tk_GetPixelsFromObj(NULL, tkwin, sb->gripCountObj, &gripSize); - gripSize *= 2; + Tk_GetPixelsFromObj(NULL, tkwin, sb->gripSizeObj, &gripSize); lightGC = Ttk_GCForColor(tkwin,sb->lightColorObj,d); darkGC = Ttk_GCForColor(tkwin,sb->borderColorObj,d); @@ -959,12 +956,12 @@ static const Ttk_ElementOptionSpec NotebookElementOptions[] = { { NULL, TK_OPTION_BOOLEAN, 0, NULL } }; -extern Ttk_PositionSpec nbTabsStickBit; /* see ttkNotebook.c */ - static void TabElementSize( void *dummy, void *elementRecord, Tk_Window tkwin, int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) { + Ttk_PositionSpec nbTabsStickBit = TTK_STICK_S; + TkMainInfo *mainInfoPtr = ((TkWindow *) tkwin)->mainPtr; int borderWidth = 2; (void)dummy; (void)elementRecord; @@ -972,6 +969,10 @@ static void TabElementSize( (void)widthPtr; (void)heightPtr; + if (mainInfoPtr != NULL) { + nbTabsStickBit = (Ttk_PositionSpec) mainInfoPtr->ttkNbTabsStickBit; + } + *paddingPtr = Ttk_UniformPadding((short)borderWidth); switch (nbTabsStickBit) { default: @@ -994,15 +995,21 @@ static void TabElementDraw( void *dummy, void *elementRecord, Tk_Window tkwin, Drawable d, Ttk_Box b, unsigned int state) { + Ttk_PositionSpec nbTabsStickBit = TTK_STICK_S; + TkMainInfo *mainInfoPtr = ((TkWindow *) tkwin)->mainPtr; + int borderWidth = 2, delta = 0; NotebookElement *tab = (NotebookElement *)elementRecord; Tk_3DBorder border = Tk_Get3DBorderFromObj(tkwin, tab->backgroundObj); Display *display = Tk_Display(tkwin); - int borderWidth = 2, delta = 0; int x1, y1, x2, y2; GC gc; const int w = WIN32_XDRAWLINE_HACK; (void)dummy; + if (mainInfoPtr != NULL) { + nbTabsStickBit = (Ttk_PositionSpec) mainInfoPtr->ttkNbTabsStickBit; + } + if (state & TTK_STATE_SELECTED) { delta = borderWidth; } diff --git a/generic/ttk/ttkElements.c b/generic/ttk/ttkElements.c index 5e8351e7d..16296b2ce 100644 --- a/generic/ttk/ttkElements.c +++ b/generic/ttk/ttkElements.c @@ -1601,20 +1601,25 @@ static const Ttk_ElementOptionSpec TabElementOptions[] = { {0,TK_OPTION_BOOLEAN,0,0} }; -extern Ttk_PositionSpec nbTabsStickBit; /* see ttkNotebook.c */ - static void TabElementSize( void *dummy, void *elementRecord, Tk_Window tkwin, int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) { TabElement *tab = (TabElement *)elementRecord; int borderWidth = 1; + Ttk_PositionSpec nbTabsStickBit = TTK_STICK_S; + TkMainInfo *mainInfoPtr = ((TkWindow *) tkwin)->mainPtr; (void)dummy; (void)widthPtr; (void)heightPtr; Tk_GetPixelsFromObj(0, tkwin, tab->borderWidthObj, &borderWidth); *paddingPtr = Ttk_UniformPadding((short)borderWidth); + + if (mainInfoPtr != NULL) { + nbTabsStickBit = (Ttk_PositionSpec) mainInfoPtr->ttkNbTabsStickBit; + } + switch (nbTabsStickBit) { default: case TTK_STICK_S: @@ -1636,6 +1641,8 @@ static void TabElementDraw( void *dummy, void *elementRecord, Tk_Window tkwin, Drawable d, Ttk_Box b, unsigned int state) { + Ttk_PositionSpec nbTabsStickBit = TTK_STICK_S; + TkMainInfo *mainInfoPtr = ((TkWindow *) tkwin)->mainPtr; TabElement *tab = (TabElement *)elementRecord; Tk_3DBorder border = Tk_Get3DBorderFromObj(tkwin, tab->backgroundObj); int highlight = 0; @@ -1647,6 +1654,10 @@ static void TabElementDraw( int borderWidth = 1; (void)dummy; + if (mainInfoPtr != NULL) { + nbTabsStickBit = (Ttk_PositionSpec) mainInfoPtr->ttkNbTabsStickBit; + } + if (state & TTK_STATE_SELECTED) { /* * Draw slightly outside of the allocated parcel, diff --git a/generic/ttk/ttkNotebook.c b/generic/ttk/ttkNotebook.c index 7bb36836d..17ccd3a5e 100644 --- a/generic/ttk/ttkNotebook.c +++ b/generic/ttk/ttkNotebook.c @@ -135,14 +135,11 @@ typedef struct Ttk_Padding padding; /* External padding */ } NotebookStyle; -/* Global variable to be set from within NotebookStyleOptions() to one - * of the values TTK_STICK_S, TTK_STICK_N, TTK_STICK_E, or TTK_STICK_W: - */ -Ttk_PositionSpec nbTabsStickBit; - -static void NotebookStyleOptions(Notebook *nb, NotebookStyle *nbstyle) +static void NotebookStyleOptions( + Notebook *nb, NotebookStyle *nbstyle, Tk_Window tkwin) { Tcl_Obj *objPtr; + TkMainInfo *mainInfoPtr = ((TkWindow *) tkwin)->mainPtr; nbstyle->tabPosition = TTK_PACK_TOP | TTK_STICK_W; if ((objPtr = Ttk_QueryOption(nb->core.layout, "-tabposition", 0)) != 0) { @@ -164,9 +161,12 @@ static void NotebookStyleOptions(Notebook *nb, NotebookStyle *nbstyle) TtkGetLabelAnchorFromObj(NULL, objPtr, &nbstyle->tabPlacement); } - /* Save the stick bit in the global variable nbTabsStickBit + /* Save the stick bit for later. One of the values + * TTK_STICK_S, TTK_STICK_N, TTK_STICK_E, or TTK_STICK_W: */ - nbTabsStickBit = (nbstyle->tabPlacement & 0x0f); + if (mainInfoPtr != NULL) { + mainInfoPtr->ttkNbTabsStickBit = (nbstyle->tabPlacement & 0x0f); + } /* Compute tabOrient as function of tabPlacement: */ @@ -395,6 +395,7 @@ static void TabrowSize( static int NotebookSize(void *clientData, int *widthPtr, int *heightPtr) { Notebook *nb = (Notebook *)clientData; + Tk_Window nbwin = nb->core.tkwin; NotebookStyle nbstyle; Ttk_Padding padding; Ttk_Element clientNode = Ttk_FindElement(nb->core.layout, "client"); @@ -403,7 +404,7 @@ static int NotebookSize(void *clientData, int *widthPtr, int *heightPtr) tabrowWidth = 0, tabrowHeight = 0; Tcl_Size i; - NotebookStyleOptions(nb, &nbstyle); + NotebookStyleOptions(nb, &nbstyle, nbwin); /* Compute max requested size of all content windows: */ @@ -553,7 +554,7 @@ static void NotebookDoLayout(void *recordPtr) NotebookStyle nbstyle; Tcl_Size currentIndex = nb->notebook.currentIndex; - NotebookStyleOptions(nb, &nbstyle); + NotebookStyleOptions(nb, &nbstyle, nbwin); /* Notebook internal padding: */ diff --git a/win/ttkWinTheme.c b/win/ttkWinTheme.c index f914cf711..7ce9024db 100644 --- a/win/ttkWinTheme.c +++ b/win/ttkWinTheme.c @@ -738,8 +738,6 @@ static const Ttk_ElementOptionSpec TabElementOptions[] = { {0,TK_OPTION_BOOLEAN,0,0} }; -extern Ttk_PositionSpec nbTabsStickBit; /* see ttkNotebook.c */ - static void TabElementSize( TCL_UNUSED(void *), void *elementRecord, @@ -750,9 +748,16 @@ static void TabElementSize( { TabElement *tab = (TabElement *)elementRecord; int borderWidth = 1; + Ttk_PositionSpec nbTabsStickBit = TTK_STICK_S; + TkMainInfo *mainInfoPtr = ((TkWindow *) tkwin)->mainPtr; Tk_GetPixelsFromObj(0, tkwin, tab->borderWidthObj, &borderWidth); *paddingPtr = Ttk_UniformPadding((short)borderWidth); + + if (mainInfoPtr != NULL) { + nbTabsStickBit = (Ttk_PositionSpec) mainInfoPtr->ttkNbTabsStickBit; + } + switch (nbTabsStickBit) { default: case TTK_STICK_S: @@ -778,6 +783,8 @@ static void TabElementDraw( Ttk_Box b, unsigned int state) { + Ttk_PositionSpec nbTabsStickBit = TTK_STICK_S; + TkMainInfo *mainInfoPtr = ((TkWindow *) tkwin)->mainPtr; TabElement *tab = (TabElement *)elementRecord; Tk_3DBorder border = Tk_Get3DBorderFromObj(tkwin, tab->backgroundObj); XPoint pts[6]; @@ -786,6 +793,10 @@ static void TabElementDraw( Display *disp = Tk_Display(tkwin); int borderWidth = 1; + if (mainInfoPtr != NULL) { + nbTabsStickBit = (Ttk_PositionSpec) mainInfoPtr->ttkNbTabsStickBit; + } + if (state & TTK_STATE_SELECTED) { /* * Draw slightly outside of the allocated parcel, diff --git a/win/ttkWinXPTheme.c b/win/ttkWinXPTheme.c index 358726baf..d64a3594b 100644 --- a/win/ttkWinXPTheme.c +++ b/win/ttkWinXPTheme.c @@ -726,8 +726,6 @@ static const Ttk_ElementSpec PbarElementSpec = * we can use the same statemap no matter what the partId. */ -extern Ttk_PositionSpec nbTabsStickBit; /* see ttkNotebook.c */ - static void TabElementSize( void *clientData, void *elementRecord, @@ -736,6 +734,13 @@ static void TabElementSize( int *heightPtr, Ttk_Padding *paddingPtr) { + Ttk_PositionSpec nbTabsStickBit = TTK_STICK_S; + TkMainInfo *mainInfoPtr = ((TkWindow *) tkwin)->mainPtr; + + if (mainInfoPtr != NULL) { + nbTabsStickBit = (Ttk_PositionSpec) mainInfoPtr->ttkNbTabsStickBit; + } + GenericElementSize(clientData, elementRecord, tkwin, widthPtr, heightPtr, paddingPtr); @@ -765,11 +770,17 @@ static void TabElementDraw( Ttk_Box b, unsigned int state) { + Ttk_PositionSpec nbTabsStickBit = TTK_STICK_S; + TkMainInfo *mainInfoPtr = ((TkWindow *) tkwin)->mainPtr; ElementData *elementData = (ElementData *)clientData; int partId = elementData->info->partId; int isSelected = (state & TTK_STATE_SELECTED); int stateId = Ttk_StateTableLookup(elementData->info->statemap, state); + if (mainInfoPtr != NULL) { + nbTabsStickBit = (Ttk_PositionSpec) mainInfoPtr->ttkNbTabsStickBit; + } + /* * Correct the members of b if needed */ From 94ce89f89b77378ab4b463f1bbef41e3c55f4e97 Mon Sep 17 00:00:00 2001 From: csaba Date: Tue, 14 Nov 2023 19:00:14 +0000 Subject: [PATCH 3/3] For now undo the changes related to -gripcount/-gripsize, slipped from trunk into ttkClamTheme.c. --- generic/ttk/ttkClamTheme.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/generic/ttk/ttkClamTheme.c b/generic/ttk/ttkClamTheme.c index e17ee8264..2a13bb6a7 100644 --- a/generic/ttk/ttkClamTheme.c +++ b/generic/ttk/ttkClamTheme.c @@ -545,7 +545,7 @@ static const Ttk_ElementSpec IndicatorElementSpec = { typedef struct { Tcl_Obj *lightColorObj; Tcl_Obj *borderColorObj; - Tcl_Obj *gripSizeObj; + Tcl_Obj *gripCountObj; } GripElement; static const Ttk_ElementOptionSpec GripElementOptions[] = { @@ -553,8 +553,8 @@ static const Ttk_ElementOptionSpec GripElementOptions[] = { offsetof(GripElement,lightColorObj), LIGHT_COLOR }, { "-bordercolor", TK_OPTION_COLOR, offsetof(GripElement,borderColorObj), DARKEST_COLOR }, - { "-gripsize", TK_OPTION_PIXELS, - offsetof(GripElement,gripSizeObj), "7.5p" }, + { "-gripcount", TK_OPTION_PIXELS, + offsetof(GripElement,gripCountObj), "5" }, { NULL, TK_OPTION_BOOLEAN, 0, NULL } }; @@ -567,7 +567,8 @@ static void GripElementSize( int gripSize = 0; (void)paddingPtr; - Tk_GetPixelsFromObj(NULL, tkwin, grip->gripSizeObj, &gripSize); + Tk_GetPixelsFromObj(NULL, tkwin, grip->gripCountObj, &gripSize); + gripSize *= 2; if (orient == TTK_ORIENT_HORIZONTAL) { *widthPtr = gripSize; } else { @@ -588,7 +589,8 @@ static void GripElementDraw( int i; (void)state; - Tk_GetPixelsFromObj(NULL, tkwin, grip->gripSizeObj, &gripSize); + Tk_GetPixelsFromObj(NULL, tkwin, grip->gripCountObj, &gripSize); + gripSize *= 2; if (orient == TTK_ORIENT_HORIZONTAL) { int x = b.x + (b.width - gripSize) / 2; @@ -631,7 +633,7 @@ typedef struct { /* Common element record for scrollbar elements */ Tcl_Obj *darkColorObj; Tcl_Obj *arrowColorObj; Tcl_Obj *arrowSizeObj; - Tcl_Obj *gripSizeObj; + Tcl_Obj *gripCountObj; Tcl_Obj *sliderlengthObj; } ScrollbarElement; @@ -652,8 +654,8 @@ static const Ttk_ElementOptionSpec ScrollbarElementOptions[] = { offsetof(ScrollbarElement,arrowColorObj), "#000000" }, { "-arrowsize", TK_OPTION_PIXELS, offsetof(ScrollbarElement,arrowSizeObj), STR(SCROLLBAR_THICKNESS) }, - { "-gripsize", TK_OPTION_PIXELS, - offsetof(ScrollbarElement,gripSizeObj), "7.5p" }, + { "-gripcount", TK_OPTION_PIXELS, + offsetof(ScrollbarElement,gripCountObj), "5" }, { "-sliderlength", TK_OPTION_PIXELS, offsetof(ScrollbarElement,sliderlengthObj), "30" }, { NULL, TK_OPTION_BOOLEAN, 0, NULL } @@ -718,7 +720,8 @@ static void ThumbElementDraw( * Draw grip: */ TtkGetOrientFromObj(NULL, sb->orientObj, &orient); - Tk_GetPixelsFromObj(NULL, tkwin, sb->gripSizeObj, &gripSize); + Tk_GetPixelsFromObj(NULL, tkwin, sb->gripCountObj, &gripSize); + gripSize *= 2; lightGC = Ttk_GCForColor(tkwin,sb->lightColorObj,d); darkGC = Ttk_GCForColor(tkwin,sb->borderColorObj,d);