summaryrefslogtreecommitdiffstats
path: root/macosx/ttkMacOSXTheme.c
diff options
context:
space:
mode:
authorhobbs <hobbs>2010-08-26 02:06:08 (GMT)
committerhobbs <hobbs>2010-08-26 02:06:08 (GMT)
commitb29adcfbfc2e03e058536524f1aa3378b948e7ed (patch)
treefa90e1e6d32590addfbb0a1599a40b1f7f99ea3b /macosx/ttkMacOSXTheme.c
parent7dec1714e5d5efd6b7d095657c1434fa68af0f87 (diff)
downloadtk-b29adcfbfc2e03e058536524f1aa3378b948e7ed.zip
tk-b29adcfbfc2e03e058536524f1aa3378b948e7ed.tar.gz
tk-b29adcfbfc2e03e058536524f1aa3378b948e7ed.tar.bz2
Major backport of 8.6 Ttk for 8.5.9. Most changes were only being
committed to head (8.6), although they could apply for 8.5 as well. This re-sync makes future work easier to maintain and adds some useful work for 8.5 users. Notable changes: - Lots of code cleanup - Some bug fixes never backported - Addition of ttk::spinbox - minor color changes - Improved Vista/7 styling - Move to tile version 0.8.6 (pseudo-package) - ABI and API compatible (even $w identify) - minor new features (extended $w identify)
Diffstat (limited to 'macosx/ttkMacOSXTheme.c')
-rw-r--r--macosx/ttkMacOSXTheme.c85
1 files changed, 73 insertions, 12 deletions
diff --git a/macosx/ttkMacOSXTheme.c b/macosx/ttkMacOSXTheme.c
index 843dea7..a6dafaf 100644
--- a/macosx/ttkMacOSXTheme.c
+++ b/macosx/ttkMacOSXTheme.c
@@ -27,7 +27,7 @@
* top-level window, not to the Tk_Window. BoxToRect()
* accounts for this.
*
- * RCS: @(#) $Id: ttkMacOSXTheme.c,v 1.21.2.3 2009/10/24 20:52:06 dkf Exp $
+ * RCS: @(#) $Id: ttkMacOSXTheme.c,v 1.21.2.4 2010/08/26 02:06:10 hobbs Exp $
*/
#include "tkMacOSXPrivate.h"
@@ -479,6 +479,57 @@ static Ttk_ElementSpec ComboboxElementSpec = {
};
/*----------------------------------------------------------------------
+ * +++ Spinbuttons.
+ *
+ * From Apple HIG, part III, section "Controls", "The Stepper Control":
+ * there should be 2 pixels of space between the stepper control
+ * (AKA IncDecButton, AKA "little arrows") and the text field it modifies.
+ */
+
+static Ttk_Padding SpinbuttonMargins = {2,0,2,0};
+static void SpinButtonElementSize(
+ void *clientData, void *elementRecord, Tk_Window tkwin,
+ int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
+{
+ SInt32 s;
+
+ ChkErr(GetThemeMetric, kThemeMetricLittleArrowsWidth, &s);
+ *widthPtr = s + Ttk_PaddingWidth(SpinbuttonMargins);
+ ChkErr(GetThemeMetric, kThemeMetricLittleArrowsHeight, &s);
+ *heightPtr = s + Ttk_PaddingHeight(SpinbuttonMargins);
+}
+
+static void SpinButtonElementDraw(
+ void *clientData, void *elementRecord, Tk_Window tkwin,
+ Drawable d, Ttk_Box b, Ttk_State state)
+{
+ Rect bounds = BoxToRect(d, Ttk_PadBox(b, SpinbuttonMargins));
+ ThemeButtonDrawInfo info;
+
+ /* @@@ can't currently distinguish PressedUp (== Pressed) from PressedDown;
+ * ignore this bit for now [see #2219588]
+ */
+ info.state = Ttk_StateTableLookup(ThemeStateTable,
+ state & ~TTK_STATE_PRESSED);
+ info.value = Ttk_StateTableLookup(ButtonValueTable, state);
+ info.adornment = kThemeAdornmentNone;
+
+ BEGIN_DRAWING(d)
+ ChkErr(DrawThemeButton,
+ &bounds, kThemeIncDecButton, &info, NULL, NULL, NULL, 0);
+ END_DRAWING
+}
+
+static Ttk_ElementSpec SpinButtonElementSpec = {
+ TK_STYLE_VERSION_2,
+ sizeof(NullElement),
+ TtkNullElementOptions,
+ SpinButtonElementSize,
+ SpinButtonElementDraw
+};
+
+
+/*----------------------------------------------------------------------
* +++ DrawThemeTrack-based elements --
* Progress bars and scales. (See also: <<NOTE-TRACKS>>)
*/
@@ -553,15 +604,14 @@ static void TrackElementDraw(
info.enableState = Ttk_StateTableLookup(ThemeTrackEnableTable, state);
switch (data->kind) {
- case kThemeProgressBar:
- info.trackInfo.progress.phase = 0; /* 1-4: animation phase */
- break;
- case kThemeSlider:
- info.trackInfo.slider.pressState = state & TTK_STATE_PRESSED ?
- kThemeThumbPressed : 0;
- info.trackInfo.slider.thumbDir = kThemeThumbPlain;
+ case kThemeProgressBar:
+ info.trackInfo.progress.phase = 0; /* 1-4: animation phase */
+ break;
+ case kThemeSlider:
+ info.trackInfo.slider.pressState = 0; /* @@@ fill this in */
+ info.trackInfo.slider.thumbDir = kThemeThumbPlain;
/* kThemeThumbUpward, kThemeThumbDownward, kThemeThumbPlain */
- break;
+ break;
}
BEGIN_DRAWING(d)
@@ -909,8 +959,11 @@ static void DisclosureElementSize(
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
SInt32 s;
- GetThemeMetric(kThemeMetricDisclosureTriangleWidth, &s); *widthPtr = s;
- GetThemeMetric(kThemeMetricDisclosureTriangleHeight, &s); *heightPtr = s;
+
+ ChkErr(GetThemeMetric, kThemeMetricDisclosureTriangleWidth, &s);
+ *widthPtr = s;
+ ChkErr(GetThemeMetric, kThemeMetricDisclosureTriangleHeight, &s);
+ *heightPtr = s;
}
static void DisclosureElementDraw(
@@ -983,6 +1036,11 @@ TTK_LAYOUT("Tab",
TTK_NODE("Notebook.label", TTK_EXPAND|TTK_FILL_BOTH))))
/* Progress bars -- track only */
+TTK_LAYOUT("TSpinbox",
+ TTK_NODE("Spinbox.spinbutton", TTK_PACK_RIGHT|TTK_STICK_E)
+ TTK_GROUP("Spinbox.field", TTK_EXPAND|TTK_FILL_X,
+ TTK_NODE("Spinbox.textarea", TTK_EXPAND|TTK_FILL_X)))
+
TTK_LAYOUT("TProgressbar",
TTK_NODE("Progressbar.track", TTK_EXPAND|TTK_FILL_BOTH))
@@ -992,7 +1050,7 @@ TTK_LAYOUT("Heading",
TTK_NODE("Treeheading.image", TTK_PACK_RIGHT)
TTK_NODE("Treeheading.text", 0))
-/* Tree items -- omit focus ring */
+/* Tree items -- omit focus ring */
TTK_LAYOUT("Item",
TTK_GROUP("Treeitem.padding", TTK_FILL_BOTH,
TTK_NODE("Treeitem.indicator", TTK_PACK_LEFT)
@@ -1031,6 +1089,8 @@ static int AquaTheme_Init(Tcl_Interp *interp)
&ButtonElementSpec, &BevelButtonParms);
Ttk_RegisterElementSpec(themePtr, "Menubutton.button",
&ButtonElementSpec, &PopupButtonParms);
+ Ttk_RegisterElementSpec(themePtr, "Spinbox.spinbutton",
+ &SpinButtonElementSpec, 0);
Ttk_RegisterElementSpec(themePtr, "Combobox.button",
&ComboboxElementSpec, 0);
Ttk_RegisterElementSpec(themePtr, "Treeitem.indicator",
@@ -1043,6 +1103,7 @@ static int AquaTheme_Init(Tcl_Interp *interp)
Ttk_RegisterElementSpec(themePtr, "Labelframe.border",&GroupElementSpec,0);
Ttk_RegisterElementSpec(themePtr, "Entry.field",&EntryElementSpec,0);
+ Ttk_RegisterElementSpec(themePtr, "Spinbox.field",&EntryElementSpec,0);
Ttk_RegisterElementSpec(themePtr, "separator",&SeparatorElementSpec,0);
Ttk_RegisterElementSpec(themePtr, "hseparator",&SeparatorElementSpec,0);