summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjenglish <jenglish@flightlab.com>2007-10-28 18:56:49 (GMT)
committerjenglish <jenglish@flightlab.com>2007-10-28 18:56:49 (GMT)
commit5f3a1bfa8de8e91197ca501ca72204d29cd4ba4d (patch)
treef02e743761fb89ddac74788b2a7b6620ac797019
parentd1c6cd2849f86a9aa098925e4de822b4f9dc6637 (diff)
downloadtk-5f3a1bfa8de8e91197ca501ca72204d29cd4ba4d.zip
tk-5f3a1bfa8de8e91197ca501ca72204d29cd4ba4d.tar.gz
tk-5f3a1bfa8de8e91197ca501ca72204d29cd4ba4d.tar.bz2
* library/ttk/combobox.tcl: Make popdown window [wm resizable 0 0]
on OSX, to prevent TkAqua from shrinking the scrollbar to make room for a grow box that isn't there. * macosx/ttkMacOSXTheme.c, library/ttk/aquaTheme.tcl: Reworked combobox layout.
-rw-r--r--ChangeLog8
-rw-r--r--library/ttk/aquaTheme.tcl9
-rw-r--r--library/ttk/combobox.tcl71
-rw-r--r--macosx/ttkMacOSXTheme.c71
4 files changed, 82 insertions, 77 deletions
diff --git a/ChangeLog b/ChangeLog
index eb81f9b..3451c11 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2007-10-28 Joe English <jenglish@users.sourceforge.net>
+
+ * library/ttk/combobox.tcl: Make popdown window [wm resizable 0 0]
+ on OSX, to prevent TkAqua from shrinking the scrollbar to make
+ room for a grow box that isn't there.
+ * macosx/ttkMacOSXTheme.c, library/ttk/aquaTheme.tcl:
+ Reworked combobox layout.
+
2007-10-26 Don Porter <dgp@users.sourceforge.net>
*** 8.5b2 TAGGED FOR RELEASE ***
diff --git a/library/ttk/aquaTheme.tcl b/library/ttk/aquaTheme.tcl
index 834136d..cb99600 100644
--- a/library/ttk/aquaTheme.tcl
+++ b/library/ttk/aquaTheme.tcl
@@ -1,5 +1,5 @@
#
-# $Id: aquaTheme.tcl,v 1.5 2007/10/22 03:35:13 jenglish Exp $
+# $Id: aquaTheme.tcl,v 1.6 2007/10/28 18:56:51 jenglish Exp $
#
# Aqua theme (OSX native look and feel)
#
@@ -35,11 +35,8 @@ namespace eval ttk::theme::aqua {
ttk::style configure TNotebook -tabposition n -padding {20 12}
ttk::style configure TNotebook.Tab -padding {10 2 10 2}
-
- # Adjust combobox post position to ensure the box is
- # directly under 'entry square'
- #
- ttk::style configure TCombobox -postoffset {3 -2 -6 0}
+ # Combobox:
+ ttk::style configure TCombobox -postoffset {5 -2 -10 0}
# Treeview:
ttk::style configure Treeview -rowheight 18
diff --git a/library/ttk/combobox.tcl b/library/ttk/combobox.tcl
index df76c04..76692d8 100644
--- a/library/ttk/combobox.tcl
+++ b/library/ttk/combobox.tcl
@@ -1,5 +1,5 @@
#
-# $Id: combobox.tcl,v 1.7 2007/10/23 23:24:09 hobbs Exp $
+# $Id: combobox.tcl,v 1.8 2007/10/28 18:56:51 jenglish Exp $
#
# Combobox bindings.
#
@@ -8,6 +8,32 @@
# is set to a namespace variable, which is used to synchronize the
# combobox values with the listbox values.
#
+# <<NOTE-WM-TRANSIENT>>:
+#
+# Need to set [wm transient] just before mapping the popdown
+# instead of when it's created, in case a containing frame
+# has been reparented [#1818441].
+#
+# On Windows: setting [wm transient] prevents the parent
+# toplevel from becoming inactive when the popdown is posted
+# (Tk 8.4.8+)
+#
+# On X11: WM_TRANSIENT_FOR on override-redirect windows
+# may be used by compositing managers and by EWMH-aware
+# window managers (even though the older ICCCM spec says
+# it's meaningless).
+#
+# On OSX: [wm transient] does utterly the wrong thing.
+# Instead, we use [MacWindowStyle "help" "noActivates hideOnSuspend"].
+# The "noActivates" attribute prevents the parent toplevel
+# from deactivating when the popdown is posted, and is also
+# necessary for "help" windows to receive mouse events.
+# "hideOnSuspend" makes the popdown disappear (resp. reappear)
+# when the parent toplevel is deactivated (resp. reactivated).
+# (see [#1814778]). Also set [wm resizable 0 0], to prevent
+# TkAqua from shrinking the scrollbar to make room for a grow box
+# that isn't there.
+#
namespace eval ttk::combobox {
variable Values ;# Values($cb) is -listvariable of listbox widget
@@ -234,9 +260,8 @@ namespace eval ::ttk::combobox {
proc ttk::combobox::PopdownWindow {cb} {
variable scrollbar
- set popdown $cb.popdown
- if {![winfo exists $popdown]} {
- PopdownToplevel $popdown
+ if {![winfo exists $cb.popdown]} {
+ set popdown [PopdownToplevel $cb.popdown]
$scrollbar $popdown.sb \
-orient vertical -command [list $popdown.l yview]
@@ -255,40 +280,15 @@ proc ttk::combobox::PopdownWindow {cb} {
grid columnconfigure $popdown 0 -weight 1
grid rowconfigure $popdown 0 -weight 1
}
- # to handle reparented frame/toplevel, recalculate transient each time
- switch -- [tk windowingsystem] {
- x11 {
- wm transient $popdown [winfo toplevel [winfo parent $popdown]]
- }
- win32 {
- wm transient $popdown [winfo toplevel [winfo parent $popdown]]
- }
- }
- return $popdown
+ return $cb.popdown
}
## PopdownToplevel -- Create toplevel window for the combobox popdown
#
-# NOTES:
-# On Windows: setting [wm transient] prevents the parent
-# toplevel from becoming inactive when the popdown is posted
-# (Tk 8.4.8+)
-#
-# On X11: WM_TRANSIENT_FOR on override-redirect windows
-# may be used by compositing managers and by EWMH-aware
-# window managers (even though the older ICCCM spec says
-# it's meaningless).
-#
-# On OSX: for MacWindowStyle "help", "noActivates" prevents
-# the parent toplevel from deactivating when the popdown
-# is posted, and is necessary for the popdown to receive
-# mouse events. "hideOnSuspend" makes the popdown disappear
-# (resp. reappear) when the parent toplevel is deactivated.
-#
+# See also <<NOTE-WM-TRANSIENT>>
+#
proc ttk::combobox::PopdownToplevel {w} {
- if {![winfo exists $w]} {
- toplevel $w -class ComboboxPopdown
- }
+ toplevel $w -class ComboboxPopdown
wm withdraw $w
switch -- [tk windowingsystem] {
default -
@@ -304,6 +304,7 @@ proc ttk::combobox::PopdownToplevel {w} {
$w configure -relief solid -borderwidth 0
tk::unsupported::MacWindowStyle style $w \
help {noActivates hideOnSuspend}
+ wm resizable $w 0 0
}
}
return $w
@@ -379,6 +380,10 @@ proc ttk::combobox::Post {cb} {
ConfigureListbox $cb
update idletasks
PlacePopdown $cb $popdown
+ # See <<NOTE-WM-TRANSIENT>>
+ switch -- [tk windowingsystem] {
+ x11 - win32 { wm transient $popdown [winfo toplevel $cb] }
+ }
# Post the listbox:
#
diff --git a/macosx/ttkMacOSXTheme.c b/macosx/ttkMacOSXTheme.c
index 8096969..7f99776 100644
--- a/macosx/ttkMacOSXTheme.c
+++ b/macosx/ttkMacOSXTheme.c
@@ -19,15 +19,15 @@
* "Active" means different things in Mac and Tk terminology --
* On Aqua, widgets are "Active" if they belong to the foreground window,
* "Inactive" if they are in a background window.
- * Tk/ttk uses the term "active" to mean that the mouse cursor
+ * Tk uses the term "active" to mean that the mouse cursor
* is over a widget; aka "hover", "prelight", or "hot-tracked".
- * (Aqua doesn't use this kind of feedback).
+ * Aqua doesn't use this kind of feedback.
*
* The QuickDraw/Carbon coordinate system is relative to the
* top-level window, not to the Tk_Window. BoxToRect()
* accounts for this.
*
- * RCS: @(#) $Id: ttkMacOSXTheme.c,v 1.11 2007/10/25 07:08:26 jenglish Exp $
+ * RCS: @(#) $Id: ttkMacOSXTheme.c,v 1.12 2007/10/28 18:56:51 jenglish Exp $
*/
#include "tkMacOSXPrivate.h"
@@ -408,56 +408,45 @@ static Ttk_ElementSpec EntryElementSpec = {
};
/*----------------------------------------------------------------------
- * +++ Pop-up arrow (for comboboxes)
- * NOTE: This isn't right at all, but I can't find the correct
- * function in the Appearance Manager reference.
+ * +++ Combobox:
+ *
+ * NOTES:
+ * kThemeMetricComboBoxLargeDisclosureWidth -> 17
+ * Padding and margins guesstimated by trial-and-error.
*/
-static void PopupArrowElementSize(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+static Ttk_Padding ComboboxPadding = { 2, 3, 17, 1 };
+static Ttk_Padding ComboboxMargins = { 3, 3, 4, 4 };
+
+static void ComboboxElementSize(
+ void *clientData, void *elementRecord, Tk_Window tkwin,
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
- *widthPtr = 12; /* wild-assed guess */
- *heightPtr = 12; /* wild-assed guess */
+ *widthPtr = 0;
+ *heightPtr = 0;
+ *paddingPtr = Ttk_AddPadding(ComboboxMargins, ComboboxPadding);
}
-static void PopupArrowElementDraw(
+static void ComboboxElementDraw(
void *clientData, void *elementRecord, Tk_Window tkwin,
Drawable d, Ttk_Box b, Ttk_State state)
{
- Rect bounds = BoxToRect(d, b);
ThemeButtonParms *parms = clientData;
+ Rect bounds = BoxToRect(d, Ttk_PadBox(b, ComboboxMargins));
ThemeButtonDrawInfo info = computeButtonDrawInfo(parms, state);
- bounds.left -= 6;
- bounds.top -= 3;
- bounds.right -= 6;
- bounds.bottom -= 2;
-
BEGIN_DRAWING(d)
- DrawThemeButton(&bounds, kThemeArrowButton, &info,
+ DrawThemeButton(&bounds, kThemeComboBox, &info,
NULL/*prevInfo*/,NULL/*eraseProc*/,NULL/*labelProc*/,0/*userData*/);
-
- bounds = BoxToRect(d, Ttk_PadBox(b, ButtonMargins));
- bounds.top += 2;
- bounds.bottom += 2;
- bounds.left -= 2;
- bounds.right -= 2;
-
- DrawThemePopupArrow(&bounds,
- kThemeArrowDown,
- kThemeArrow9pt, /* ??? */
- Ttk_StateTableLookup(ThemeStateTable, state),
- NULL /*eraseProc*/,0/*eraseData*/);
END_DRAWING
}
-static Ttk_ElementSpec PopupArrowElementSpec = {
+static Ttk_ElementSpec ComboboxElementSpec = {
TK_STYLE_VERSION_2,
sizeof(NullElement),
TtkNullElementOptions,
- PopupArrowElementSize,
- PopupArrowElementDraw
+ ComboboxElementSize,
+ ComboboxElementDraw
};
/*----------------------------------------------------------------------
@@ -957,6 +946,12 @@ TTK_BEGIN_LAYOUT(MenubuttonLayout)
TTK_NODE("Menubutton.label", TTK_PACK_LEFT)))
TTK_END_LAYOUT
+TTK_BEGIN_LAYOUT(ComboboxLayout)
+ TTK_GROUP("Combobox.button", TTK_PACK_TOP|TTK_FILL_X,
+ TTK_GROUP("Combobox.padding", TTK_FILL_BOTH,
+ TTK_NODE("Combobox.textarea", TTK_PACK_LEFT|TTK_FILL_X)))
+TTK_END_LAYOUT
+
/* Notebook tabs -- no focus ring */
TTK_BEGIN_LAYOUT(TabLayout)
TTK_GROUP("Notebook.tab", TTK_FILL_BOTH,
@@ -1004,6 +999,8 @@ static int AquaTheme_Init(Tcl_Interp *interp)
&ButtonElementSpec, &BevelButtonParms);
Ttk_RegisterElementSpec(themePtr, "Menubutton.button",
&ButtonElementSpec, &PopupButtonParms);
+ Ttk_RegisterElementSpec(themePtr, "Combobox.button",
+ &ComboboxElementSpec, 0);
Ttk_RegisterElementSpec(themePtr, "Treeitem.indicator",
&DisclosureElementSpec, &DisclosureParms);
Ttk_RegisterElementSpec(themePtr, "Treeheading.cell",
@@ -1015,10 +1012,6 @@ static int AquaTheme_Init(Tcl_Interp *interp)
Ttk_RegisterElementSpec(themePtr, "Labelframe.border",&GroupElementSpec,0);
Ttk_RegisterElementSpec(themePtr, "Entry.field",&EntryElementSpec,0);
- Ttk_RegisterElementSpec(themePtr, "Combobox.field",&EntryElementSpec,0);
- Ttk_RegisterElementSpec(themePtr, "Combobox.downarrow",
- &PopupArrowElementSpec, 0);
-
Ttk_RegisterElementSpec(themePtr, "separator",&SeparatorElementSpec,0);
Ttk_RegisterElementSpec(themePtr, "hseparator",&SeparatorElementSpec,0);
Ttk_RegisterElementSpec(themePtr, "vseparator",&SeparatorElementSpec,0);
@@ -1042,6 +1035,7 @@ static int AquaTheme_Init(Tcl_Interp *interp)
Ttk_RegisterLayout(themePtr, "TCheckbutton", CheckbuttonLayout);
Ttk_RegisterLayout(themePtr, "TRadiobutton", RadiobuttonLayout);
Ttk_RegisterLayout(themePtr, "TMenubutton", MenubuttonLayout);
+ Ttk_RegisterLayout(themePtr, "TCombobox", ComboboxLayout);
Ttk_RegisterLayout(themePtr, "TProgressbar", ProgressbarLayout);
Ttk_RegisterLayout(themePtr, "TNotebook.Tab", TabLayout);
Ttk_RegisterLayout(themePtr, "Heading", TreeHeadingLayout);
@@ -1050,7 +1044,8 @@ static int AquaTheme_Init(Tcl_Interp *interp)
return TCL_OK;
}
-MODULE_SCOPE int Ttk_MacOSXPlatformInit(Tcl_Interp *interp)
+MODULE_SCOPE
+int Ttk_MacOSXPlatformInit(Tcl_Interp *interp)
{
return AquaTheme_Init(interp);
}