summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog11
-rw-r--r--generic/ttk/ttkFrame.c93
-rw-r--r--generic/ttk/ttkLabel.c6
-rw-r--r--library/ttk/altTheme.tcl7
-rw-r--r--library/ttk/aquaTheme.tcl12
-rw-r--r--library/ttk/clamTheme.tcl10
-rw-r--r--library/ttk/classicTheme.tcl5
-rw-r--r--library/ttk/defaults.tcl7
-rw-r--r--library/ttk/winTheme.tcl7
-rw-r--r--library/ttk/xpTheme.tcl6
10 files changed, 100 insertions, 64 deletions
diff --git a/ChangeLog b/ChangeLog
index cd5e0c9..f87091b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,16 @@
2007-11-18 Joe English <jenglish@users.sourceforge.net>
+ * generic/ttk/ttkFrame.c: Use sublayout for ttk::labelframe labels
+ instead of single element.
+
+ * generic/ttk/ttkLabel.c: Default -anchor for text and label elements
+ is now "w" instead of "center". Fixes [Bug 1614540].
+
+ * library/ttk/defaults.tcl, library/ttk/*Theme.tcl: Button styles
+ now need explicit "-anchor center".
+
+2007-11-18 Joe English <jenglish@users.sourceforge.net>
+
* generic/ttk/ttkLayout.c(TTKInitPadding): BUGFIX:
Ttk_GetPaddingFromObj() and Ttk_GetBorderFromObj() returned
garbage when passed an empty list.
diff --git a/generic/ttk/ttkFrame.c b/generic/ttk/ttkFrame.c
index b6f8fe8..700288f 100644
--- a/generic/ttk/ttkFrame.c
+++ b/generic/ttk/ttkFrame.c
@@ -1,4 +1,4 @@
-/* $Id: ttkFrame.c,v 1.7 2007/10/25 07:08:26 jenglish Exp $
+/* $Id: ttkFrame.c,v 1.8 2007/11/18 19:20:25 jenglish Exp $
* Copyright (c) 2004, Joe English
*
* ttk::frame and ttk::labelframe widgets.
@@ -14,8 +14,7 @@
* +++ Frame widget:
*/
-typedef struct
-{
+typedef struct {
Tcl_Obj *borderWidthObj;
Tcl_Obj *paddingObj;
Tcl_Obj *reliefObj;
@@ -23,8 +22,7 @@ typedef struct
Tcl_Obj *heightObj;
} FramePart;
-typedef struct
-{
+typedef struct {
WidgetCore core;
FramePart frame;
} Frame;
@@ -241,11 +239,11 @@ typedef struct {
Tk_Window labelWidget;
Ttk_Manager *mgr;
+ Ttk_Layout labelLayout; /* Sublayout for label */
Ttk_Box labelParcel; /* Set in layoutProc */
} LabelframePart;
-typedef struct
-{
+typedef struct {
WidgetCore core;
FramePart frame;
LabelframePart label;
@@ -274,8 +272,7 @@ static Tk_OptionSpec LabelframeOptionSpecs[] =
/*
* Labelframe style parameters:
*/
-typedef struct
-{
+typedef struct {
int borderWidth; /* border width */
Ttk_Padding padding; /* internal padding */
Ttk_PositionSpec labelAnchor; /* corner/side to place label */
@@ -321,17 +318,13 @@ static void LabelframeStyleOptions(Labelframe *lf, LabelframeStyle *style)
static void
LabelframeLabelSize(Labelframe *lframePtr, int *widthPtr, int *heightPtr)
{
- WidgetCore *corePtr = &lframePtr->core;
Tk_Window labelWidget = lframePtr->label.labelWidget;
- Ttk_LayoutNode *textNode = Ttk_LayoutFindNode(corePtr->layout, "text");
if (labelWidget) {
*widthPtr = Tk_ReqWidth(labelWidget);
*heightPtr = Tk_ReqHeight(labelWidget);
- } else if (textNode) {
- Ttk_LayoutNodeReqSize(corePtr->layout, textNode, widthPtr, heightPtr);
} else {
- *widthPtr = *heightPtr = 0;
+ Ttk_LayoutSize(lframePtr->label.labelLayout, 0, widthPtr, heightPtr);
}
}
@@ -379,6 +372,36 @@ static int LabelframeSize(void *recordPtr, int *widthPtr, int *heightPtr)
return 0;
}
+/*
+ * LabelframeGetLayout --
+ * Getlayout widget hook.
+ */
+
+static Ttk_Layout LabelframeGetLayout(
+ Tcl_Interp *interp, Ttk_Theme theme, void *recordPtr)
+{
+ Labelframe *lf = recordPtr;
+ Ttk_Layout frameLayout = TtkWidgetGetLayout(interp, theme, recordPtr);
+ Ttk_Layout labelLayout;
+
+ if (!frameLayout) {
+ return NULL;
+ }
+
+ labelLayout = Ttk_CreateSublayout(
+ interp, theme, frameLayout, ".Label", lf->core.optionTable);
+
+ if (labelLayout) {
+ if (lf->label.labelLayout) {
+ Ttk_FreeLayout(lf->label.labelLayout);
+ }
+ Ttk_RebindSublayout(labelLayout, recordPtr);
+ lf->label.labelLayout = labelLayout;
+ }
+
+ return frameLayout;
+}
+
/*
* LabelframeDoLayout --
* Labelframe layout hook.
@@ -390,20 +413,12 @@ static void LabelframeDoLayout(void *recordPtr)
{
Labelframe *lframePtr = recordPtr;
WidgetCore *corePtr = &lframePtr->core;
- Ttk_Box borderParcel = Ttk_WinBox(corePtr->tkwin);
- Ttk_LayoutNode
- *textNode = Ttk_LayoutFindNode(corePtr->layout, "text"),
- *borderNode = Ttk_LayoutFindNode(corePtr->layout, "border");
int lw, lh; /* Label width and height */
LabelframeStyle style;
+ Ttk_Box borderParcel = Ttk_WinBox(lframePtr->core.tkwin);
Ttk_Box labelParcel;
/*
- * Do base layout:
- */
- Ttk_PlaceLayout(corePtr->layout,corePtr->state,borderParcel);
-
- /*
* Compute label parcel:
*/
LabelframeStyleOptions(lframePtr, &style);
@@ -429,16 +444,22 @@ static void LabelframeDoLayout(void *recordPtr)
/*
* Place border and label:
*/
- if (borderNode) {
- Ttk_PlaceLayoutNode(corePtr->layout, borderNode, borderParcel);
- }
- if (textNode) {
- Ttk_PlaceLayoutNode(corePtr->layout, textNode, labelParcel);
- }
+ Ttk_PlaceLayout(corePtr->layout, corePtr->state, borderParcel);
+ Ttk_PlaceLayout(lframePtr->label.labelLayout, corePtr->state, labelParcel);
/* labelWidget placed in LabelframePlaceSlaves GM hook */
lframePtr->label.labelParcel = labelParcel;
}
+static void LabelframeDisplay(void *recordPtr, Drawable d)
+{
+ Labelframe *lframePtr = recordPtr;
+ Ttk_DrawLayout(lframePtr->core.layout, lframePtr->core.state, d);
+ Ttk_DrawLayout(lframePtr->label.labelLayout, lframePtr->core.state, d);
+}
+
+/* +++ Labelframe geometry manager hooks.
+ */
+
/* LabelframePlaceSlaves --
* Sets the position and size of the labelwidget.
*/
@@ -455,9 +476,6 @@ static void LabelframePlaceSlaves(void *recordPtr)
}
}
-/* Labelframe geometry manager:
- */
-
/* LabelRemoved --
* Unset the -labelwidget option.
*
@@ -489,6 +507,7 @@ static int LabelframeInitialize(Tcl_Interp *interp, void *recordPtr)
lframe->label.mgr = Ttk_CreateManager(
&LabelframeManagerSpec, lframe, lframe->core.tkwin);
lframe->label.labelWidget = 0;
+ lframe->label.labelLayout = 0;
lframe->label.labelParcel = Ttk_MakeBox(-1,-1,-1,-1);
return TCL_OK;
@@ -585,19 +604,22 @@ static WidgetSpec LabelframeWidgetSpec =
LabelframeCleanup, /* cleanupProc */
LabelframeConfigure, /* configureProc */
TtkNullPostConfigure, /* postConfigureProc */
- TtkWidgetGetLayout, /* getLayoutProc */
+ LabelframeGetLayout, /* getLayoutProc */
LabelframeSize, /* sizeProc */
LabelframeDoLayout, /* layoutProc */
- TtkWidgetDisplay /* displayProc */
+ LabelframeDisplay /* displayProc */
};
TTK_BEGIN_LAYOUT(LabelframeLayout)
TTK_NODE("Labelframe.border", TTK_FILL_BOTH)
+TTK_END_LAYOUT
+
+TTK_BEGIN_LAYOUT(LabelSublayout)
TTK_NODE("Labelframe.text", TTK_FILL_BOTH)
TTK_END_LAYOUT
/* ======================================================================
- * +++ Initialization:
+ * +++ Initialization.
*/
MODULE_SCOPE
@@ -607,6 +629,7 @@ void TtkFrame_Init(Tcl_Interp *interp)
Ttk_RegisterLayout(theme, "TFrame", FrameLayout);
Ttk_RegisterLayout(theme, "TLabelframe", LabelframeLayout);
+ Ttk_RegisterLayout(theme, "TLabelframe.Label", LabelSublayout);
RegisterWidget(interp, "ttk::frame", &FrameWidgetSpec);
RegisterWidget(interp, "ttk::labelframe", &LabelframeWidgetSpec);
diff --git a/generic/ttk/ttkLabel.c b/generic/ttk/ttkLabel.c
index 58bdceb..18c4f99 100644
--- a/generic/ttk/ttkLabel.c
+++ b/generic/ttk/ttkLabel.c
@@ -1,4 +1,4 @@
-/* $Id: ttkLabel.c,v 1.8 2007/05/03 22:15:59 dkf Exp $
+/* $Id: ttkLabel.c,v 1.9 2007/11/18 19:20:26 jenglish Exp $
*
* text, image, and label elements.
*
@@ -66,7 +66,7 @@ static Ttk_ElementOptionSpec TextElementOptions[] =
{ "-width", TK_OPTION_INT,
Tk_Offset(TextElement,widthObj), "-1"},
{ "-anchor", TK_OPTION_ANCHOR,
- Tk_Offset(TextElement,anchorObj), "center"},
+ Tk_Offset(TextElement,anchorObj), "w"},
{ "-justify", TK_OPTION_JUSTIFY,
Tk_Offset(TextElement,justifyObj), "left" },
{ "-wraplength", TK_OPTION_PIXELS,
@@ -474,7 +474,7 @@ static Ttk_ElementOptionSpec LabelElementOptions[] =
{ "-width", TK_OPTION_INT,
Tk_Offset(LabelElement,text.widthObj), ""},
{ "-anchor", TK_OPTION_ANCHOR,
- Tk_Offset(LabelElement,text.anchorObj), "center"},
+ Tk_Offset(LabelElement,text.anchorObj), "w"},
{ "-justify", TK_OPTION_JUSTIFY,
Tk_Offset(LabelElement,text.justifyObj), "left" },
{ "-wraplength", TK_OPTION_PIXELS,
diff --git a/library/ttk/altTheme.tcl b/library/ttk/altTheme.tcl
index 62a0607..bee578c 100644
--- a/library/ttk/altTheme.tcl
+++ b/library/ttk/altTheme.tcl
@@ -1,5 +1,5 @@
#
-# $Id: altTheme.tcl,v 1.3 2006/12/18 19:33:14 jenglish Exp $
+# $Id: altTheme.tcl,v 1.4 2007/11/18 19:20:26 jenglish Exp $
#
# Ttk widget set: Alternate theme
#
@@ -35,7 +35,8 @@ namespace eval ttk::theme::alt {
style map "." -embossed [list disabled 1] ;
style configure TButton \
- -width -11 -padding "1 1" -relief raised -shiftrelief 1 \
+ -anchor center -width -11 -padding "1 1" \
+ -relief raised -shiftrelief 1 \
-highlightthickness 1 -highlightcolor $colors(-frame)
style map TButton -relief {
@@ -51,7 +52,7 @@ namespace eval ttk::theme::alt {
[list disabled $colors(-frame) pressed $colors(-frame)]
style configure TMenubutton \
- -width -11 -padding "3 3" -relief raised -anchor w
+ -width -11 -padding "3 3" -relief raised
style configure TEntry -padding 1
style map TEntry -fieldbackground \
diff --git a/library/ttk/aquaTheme.tcl b/library/ttk/aquaTheme.tcl
index e8ece15..bf34746 100644
--- a/library/ttk/aquaTheme.tcl
+++ b/library/ttk/aquaTheme.tcl
@@ -1,5 +1,5 @@
#
-# $Id: aquaTheme.tcl,v 1.8 2007/11/18 17:00:28 jenglish Exp $
+# $Id: aquaTheme.tcl,v 1.9 2007/11/18 19:20:26 jenglish Exp $
#
# Aqua theme (OSX native look and feel)
#
@@ -28,8 +28,7 @@ namespace eval ttk::theme::aqua {
#
ttk::style configure . -stipple {}
- ttk::style configure TButton -width -6
- ttk::style configure TMenubutton -anchor w
+ ttk::style configure TButton -anchor center -width -6
ttk::style configure Toolbutton -padding 4
# See Apple HIG figs 14-63, 14-65
ttk::style configure TNotebook -tabposition n -padding {20 12}
@@ -54,12 +53,9 @@ namespace eval ttk::theme::aqua {
# Modify the the default Labelframe layout to use generic text element
# instead of Labelframe.text; the latter erases the window background
# (@@@ this still isn't right... want to fill with background pattern)
-
- ttk::style layout TLabelframe {
- Labelframe.border
- text
- }
#
+ ttk::style layout TLabelframe.Label { text }
+
# For Aqua, labelframe labels should appear outside the border,
# with a 14 pixel inset and 4 pixels spacing between border and label
# (ref: Apple Human Interface Guidelines / Controls / Grouping Controls)
diff --git a/library/ttk/clamTheme.tcl b/library/ttk/clamTheme.tcl
index 930ec97..c519eab 100644
--- a/library/ttk/clamTheme.tcl
+++ b/library/ttk/clamTheme.tcl
@@ -1,5 +1,5 @@
#
-# $Id: clamTheme.tcl,v 1.4 2006/12/18 19:33:14 jenglish Exp $
+# $Id: clamTheme.tcl,v 1.5 2007/11/18 19:20:26 jenglish Exp $
#
# "Clam" theme.
#
@@ -45,7 +45,8 @@ namespace eval ttk::theme::clam {
;
# -selectbackground [list !focus "#847d73"]
- ttk::style configure TButton -width -11 -padding 5 -relief raised
+ ttk::style configure TButton \
+ -anchor center -width -11 -padding 5 -relief raised
ttk::style map TButton \
-background [list \
disabled $colors(-frame) \
@@ -56,7 +57,8 @@ namespace eval ttk::theme::clam {
-bordercolor [list alternate "#000000"] \
;
- ttk::style configure Toolbutton -padding 2 -relief flat
+ ttk::style configure Toolbutton \
+ -anchor center -padding 2 -relief flat
ttk::style map Toolbutton \
-relief [list \
disabled flat \
@@ -85,7 +87,7 @@ namespace eval ttk::theme::clam {
[list disabled $colors(-frame) pressed $colors(-frame)]
ttk::style configure TMenubutton \
- -width -11 -padding 5 -relief raised -anchor w
+ -width -11 -padding 5 -relief raised
ttk::style configure TEntry -padding 1 -insertwidth 1
ttk::style map TEntry \
diff --git a/library/ttk/classicTheme.tcl b/library/ttk/classicTheme.tcl
index 2061b4e..38dc845 100644
--- a/library/ttk/classicTheme.tcl
+++ b/library/ttk/classicTheme.tcl
@@ -1,5 +1,5 @@
#
-# $Id: classicTheme.tcl,v 1.3 2006/12/18 19:33:14 jenglish Exp $
+# $Id: classicTheme.tcl,v 1.4 2007/11/18 19:20:26 jenglish Exp $
#
# "classic" Tk theme.
#
@@ -45,7 +45,8 @@ namespace eval ttk::theme::classic {
style map "." -highlightcolor [list focus black]
- style configure TButton -padding "3m 1m" -relief raised -shiftrelief 1
+ style configure TButton \
+ -anchor center -padding "3m 1m" -relief raised -shiftrelief 1
style map TButton -relief [list {!disabled pressed} sunken]
style configure TCheckbutton -indicatorrelief raised
diff --git a/library/ttk/defaults.tcl b/library/ttk/defaults.tcl
index d076d8e..be106b1 100644
--- a/library/ttk/defaults.tcl
+++ b/library/ttk/defaults.tcl
@@ -1,5 +1,5 @@
#
-# $Id: defaults.tcl,v 1.4 2006/12/18 19:33:14 jenglish Exp $
+# $Id: defaults.tcl,v 1.5 2007/11/18 19:20:26 jenglish Exp $
#
# Settings for default theme.
#
@@ -38,7 +38,8 @@ namespace eval ttk::theme::default {
[list disabled $colors(-disabledfg)]
ttk::style configure TButton \
- -padding "3 3" -width -9 -relief raised -shiftrelief 1
+ -anchor center -padding "3 3" -width -9 \
+ -relief raised -shiftrelief 1
ttk::style map TButton -relief [list {!disabled pressed} sunken]
ttk::style configure TCheckbutton \
@@ -52,7 +53,7 @@ namespace eval ttk::theme::default {
[list pressed $colors(-activebg) selected $colors(-indicator)]
ttk::style configure TMenubutton \
- -relief raised -padding "10 3" -anchor w
+ -relief raised -padding "10 3"
ttk::style configure TEntry \
-relief sunken -fieldbackground white -padding 1
diff --git a/library/ttk/winTheme.tcl b/library/ttk/winTheme.tcl
index bd9696b..b39ecb5 100644
--- a/library/ttk/winTheme.tcl
+++ b/library/ttk/winTheme.tcl
@@ -1,5 +1,5 @@
#
-# $Id: winTheme.tcl,v 1.4 2007/10/16 21:00:15 jenglish Exp $
+# $Id: winTheme.tcl,v 1.5 2007/11/18 19:20:26 jenglish Exp $
#
# Settings for 'winnative' theme.
#
@@ -19,11 +19,12 @@ namespace eval ttk::theme::winnative {
ttk::style map "." -foreground [list disabled SystemGrayText] ;
ttk::style map "." -embossed [list disabled 1] ;
- ttk::style configure TButton -width -11 -relief raised -shiftrelief 1
+ ttk::style configure TButton \
+ -anchor center -width -11 -relief raised -shiftrelief 1
ttk::style configure TCheckbutton -padding "2 4"
ttk::style configure TRadiobutton -padding "2 4"
ttk::style configure TMenubutton \
- -padding "8 4" -arrowsize 3 -relief raised -anchor w
+ -padding "8 4" -arrowsize 3 -relief raised
ttk::style map TButton -relief {{!disabled pressed} sunken}
diff --git a/library/ttk/xpTheme.tcl b/library/ttk/xpTheme.tcl
index 44a5087..3884f06 100644
--- a/library/ttk/xpTheme.tcl
+++ b/library/ttk/xpTheme.tcl
@@ -1,5 +1,5 @@
#
-# $Id: xpTheme.tcl,v 1.4 2007/10/16 21:00:15 jenglish Exp $
+# $Id: xpTheme.tcl,v 1.5 2007/11/18 19:20:26 jenglish Exp $
#
# Settings for 'xpnative' theme
#
@@ -20,10 +20,10 @@ namespace eval ttk::theme::xpnative {
-foreground [list disabled SystemGrayText] \
;
- ttk::style configure TButton -padding {1 1} -width -11
+ ttk::style configure TButton -anchor center -padding {1 1} -width -11
ttk::style configure TRadiobutton -padding 2
ttk::style configure TCheckbutton -padding 2
- ttk::style configure TMenubutton -padding {8 4} -anchor w
+ ttk::style configure TMenubutton -padding {8 4}
ttk::style configure TNotebook -tabmargins {2 2 2 0}
ttk::style map TNotebook.Tab \