From 3c2b81f90f8bb785d3f364558c578685d85943fd Mon Sep 17 00:00:00 2001 From: csaba Date: Fri, 10 Nov 2023 20:28:59 +0000 Subject: Extended the man page for ttk::notebook; updated ttkWinTheme.c and ttkWinXPTheme.c. --- doc/ttk_notebook.n | 41 ++++++++++++++++++++++++++++++++- win/ttkWinTheme.c | 19 --------------- win/ttkWinXPTheme.c | 66 ++++++++++++++++++++++++----------------------------- 3 files changed, 70 insertions(+), 56 deletions(-) diff --git a/doc/ttk_notebook.n b/doc/ttk_notebook.n index 869e4bf..007ef92 100644 --- a/doc/ttk_notebook.n +++ b/doc/ttk_notebook.n @@ -230,7 +230,15 @@ are: .br \fB\-tabmargins\fP \fIpadding\fP .br -\fB\-tabposition\fP \fIside\fP +\fB\-tabposition\fP \fIposition\fP +.RS +Specifies the position of the tab row or column as a string of length +1 or 2. The first character indicates the size as \fBn\fP, \fBs\fP, +\fBw\fP, or \fBe\fP, while the second character (if present) is the +sticky bit (specified as \fBw\fP, \fBe\fP, \fBn\fP, or \fBs\fP) within +the tab position. The default position is \fBn\fP for the \fBaqua\fP +theme and \fBnw\fP for all the other built-in themes. +.RE .br .PP \fBTNotebook.Tab\fP styling options configurable with \fBttk::style\fP @@ -247,12 +255,43 @@ are: Defines how much the tab grows in size. Usually used with the \fBselected\fP dynamic state. \fB\-tabmargins\fP should be set appropriately so that there is room for the tab growth. +For example, the Ttk library file \fBvistaTheme.tcl\fP contains +the lines +.CS +ttk::style configure TNotebook -tabmargins {2 2 2 0} +ttk::style map TNotebook.Tab -expand {selected {2 2 2 2}} +.CE +which are valid for the default value \fBnw\fP of the \fB\-tabposition\fP +style option. For a \fBttk::notebook\fP style \fBnbStyle\fP defined by +.CS +set nbStyle SW.TNotebook +ttk::style configure $nbStyle -tabposition sw +.CE +you will have to adapt the above settings as follows: +.CS +ttk::style configure $nbStyle -tabmargins {2 0 2 2} +ttk::style map $nbStyle.Tab -expand {selected {2 2 2 2}} +.CE .RE \fB\-font\fP \fIfont\fP .br \fB\-foreground\fP \fIcolor\fP .br \fB\-padding\fP \fIpadding\fP +.RS +Some themes (e.g., \fBclam\fP) use a different \fIpadding\fP for the +selected tab. For example, the Ttk library file \fBclamTheme.tcl\fP +contains the lines +.CS +ttk::style configure TNotebook.Tab \\ + -padding {4.5p 1.5p 4.5p 1.5p} +ttk::style map TNotebook.Tab \\ + -padding {selected {4.5p 3p 4.5p 1.5p}} +.CE +which are valid for the default value \fBnw\fP of the \fB\-tabposition\fP +style option. Again, for a different tab position you will have to adapt +the above settings accordingly. +.RE .PP Some options are only available for specific themes. .PP diff --git a/win/ttkWinTheme.c b/win/ttkWinTheme.c index 0f2f732..0c1c651 100644 --- a/win/ttkWinTheme.c +++ b/win/ttkWinTheme.c @@ -786,24 +786,6 @@ static void TabElementDraw( Display *disp = Tk_Display(tkwin); int borderWidth = 1; - /* - * Correct the members of b if needed. - */ - switch (nbTabsStickBit) { - default: - case TTK_STICK_S: - break; - case TTK_STICK_N: - b.y -= 2; - break; - case TTK_STICK_E: - b.width += 2; - break; - case TTK_STICK_W: - b.x -= 2; b.width +=2; - break; - } - if (state & TTK_STATE_SELECTED) { /* * Draw slightly outside of the allocated parcel, @@ -821,7 +803,6 @@ static void TabElementDraw( b.width += 2; break; case TTK_STICK_W: - b.width += 2; b.x -= 2; break; } } diff --git a/win/ttkWinXPTheme.c b/win/ttkWinXPTheme.c index 75866ce..03bbc48 100644 --- a/win/ttkWinXPTheme.c +++ b/win/ttkWinXPTheme.c @@ -767,6 +767,7 @@ static void TabElementDraw( { ElementData *elementData = (ElementData *)clientData; int partId = elementData->info->partId; + int isSelected = (state & TTK_STATE_SELECTED); int stateId = Ttk_StateTableLookup(elementData->info->statemap, state); /* @@ -777,13 +778,13 @@ static void TabElementDraw( case TTK_STICK_S: break; case TTK_STICK_N: - b.y -= 4; + b.y -= isSelected ? 0 : 1; b.height -= isSelected ? 1 : 0; break; case TTK_STICK_E: - b.width += 3; + b.width -= isSelected ? 1 : 0; break; case TTK_STICK_W: - b.x -= 5; b.width += 5; + b.x -= isSelected ? 3 : 4; b.width += isSelected ? 1 : 2; break; } @@ -792,9 +793,11 @@ static void TabElementDraw( if (!InitElementData(elementData, tkwin, d)) return; - if (state & TTK_STATE_USER1) - partId = TABP_TABITEMLEFTEDGE; if (nbTabsStickBit == TTK_STICK_S) { + if (state & TTK_STATE_USER1) { + partId = TABP_TABITEMLEFTEDGE; + } + /* * Draw the border and fill into rc */ @@ -810,37 +813,28 @@ static void TabElementDraw( elementData->hTheme, elementData->hDC, partId, stateId, &rc2, &rc); } - if (state & TTK_STATE_SELECTED) { - /* - * Draw a flat border at 3 edges - */ - switch (nbTabsStickBit) { - default: - case TTK_STICK_S: - break; - case TTK_STICK_N: - elementData->procs->DrawThemeEdge( - elementData->hTheme, elementData->hDC, partId, stateId, &rc, - BDR_RAISEDINNER, BF_FLAT|BF_LEFT|BF_RIGHT|BF_BOTTOM, NULL); - break; - case TTK_STICK_E: - elementData->procs->DrawThemeEdge( - elementData->hTheme, elementData->hDC, partId, stateId, &rc, - BDR_RAISEDINNER, BF_FLAT|BF_LEFT|BF_TOP|BF_BOTTOM, NULL); - break; - case TTK_STICK_W: - elementData->procs->DrawThemeEdge( - elementData->hTheme, elementData->hDC, partId, stateId, &rc, - BDR_RAISEDINNER, BF_FLAT|BF_TOP|BF_RIGHT|BF_BOTTOM, NULL); - break; - } - } else if (nbTabsStickBit != TTK_STICK_S) { - /* - * Draw a flat border at all 4 edges - */ - elementData->procs->DrawThemeEdge( - elementData->hTheme, elementData->hDC, partId, stateId, &rc, - BDR_RAISEDINNER, BF_FLAT|BF_RECT, NULL); + /* + * Draw a flat border at 3 edges + */ + switch (nbTabsStickBit) { + default: + case TTK_STICK_S: + break; + case TTK_STICK_N: + elementData->procs->DrawThemeEdge( + elementData->hTheme, elementData->hDC, partId, stateId, &rc, + BDR_RAISEDINNER, BF_FLAT|BF_LEFT|BF_RIGHT|BF_BOTTOM, NULL); + break; + case TTK_STICK_E: + elementData->procs->DrawThemeEdge( + elementData->hTheme, elementData->hDC, partId, stateId, &rc, + BDR_RAISEDINNER, BF_FLAT|BF_LEFT|BF_TOP|BF_BOTTOM, NULL); + break; + case TTK_STICK_W: + elementData->procs->DrawThemeEdge( + elementData->hTheme, elementData->hDC, partId, stateId, &rc, + BDR_RAISEDINNER, BF_FLAT|BF_TOP|BF_RIGHT|BF_BOTTOM, NULL); + break; } FreeElementData(elementData); -- cgit v0.12