summaryrefslogtreecommitdiffstats
path: root/macosx/ttkMacOSXTheme.c
diff options
context:
space:
mode:
authorjenglish <jenglish@flightlab.com>2006-12-18 19:33:10 (GMT)
committerjenglish <jenglish@flightlab.com>2006-12-18 19:33:10 (GMT)
commitfb835826dd21c44784539b40e590866ffb89bd93 (patch)
treeb0a6aa116ab0a8f8f7eefc79d7816eb5eb6e5c58 /macosx/ttkMacOSXTheme.c
parent16cde6f4aaf0d168843b71218b3b76cad1f1da4c (diff)
downloadtk-fb835826dd21c44784539b40e590866ffb89bd93.zip
tk-fb835826dd21c44784539b40e590866ffb89bd93.tar.gz
tk-fb835826dd21c44784539b40e590866ffb89bd93.tar.bz2
Big batch of ttk::treeview improvements:
Added column '-stretch' and '-minwidth' options. Improved column drag and resize behavior. Added horizontal scrolling [#1518650]. Row height and child indent specifiable on Treeview style. Decreased default row height, no default -padding. Use correct heading height [#1163349]. Apply tag settings to tree item as well as to data columns [NOTE: 'tag configure' still buggy]. Fix off-by-one condition when moving nodes forward [#1618142] Prevent overscroll ([#1173434]) Treeview style settings specified separately in each theme. Added disclosure triangle element in aqua theme.
Diffstat (limited to 'macosx/ttkMacOSXTheme.c')
-rw-r--r--macosx/ttkMacOSXTheme.c59
1 files changed, 58 insertions, 1 deletions
diff --git a/macosx/ttkMacOSXTheme.c b/macosx/ttkMacOSXTheme.c
index 7cd46ae..47dca7b 100644
--- a/macosx/ttkMacOSXTheme.c
+++ b/macosx/ttkMacOSXTheme.c
@@ -1,5 +1,5 @@
/*
- * $Id: ttkMacOSXTheme.c,v 1.3 2006/11/03 03:06:22 das Exp $
+ * $Id: ttkMacOSXTheme.c,v 1.4 2006/12/18 19:33:14 jenglish Exp $
*
* Tk theme engine for Mac OSX, using the Appearance Manager API.
*
@@ -46,6 +46,13 @@ Rect BoxToRect(Ttk_Box b)
return rect;
}
+/* DontErase --
+ * No-op ThemeEraseProc, can be passed to DrawThemeButton &c.
+ */
+static void DontErase(
+ const Rect *bounds, UInt32 eraseData, SInt16 depth, Boolean isColorDev)
+{ }
+
#define BEGIN_DRAWING(d) { \
CGrafPtr saveWorld; GDHandle saveDevice; \
GetGWorld(&saveWorld, &saveDevice); \
@@ -94,6 +101,7 @@ static ThemeButtonParms
RadioButtonParms = { kThemeRadioButton, kThemeMetricRadioButtonHeight },
BevelButtonParms = { kThemeBevelButton, NoThemeMetric },
PopupButtonParms = { kThemePopupButton, NoThemeMetric },
+ DisclosureParms = { kThemeDisclosureButton, kThemeMetricDisclosureTriangleHeight },
ListHeaderParms = { kThemeListHeaderButton, kThemeMetricListHeaderHeight };
static Ttk_StateTable ButtonValueTable[] = {
@@ -866,6 +874,53 @@ static Ttk_ElementSpec TreeHeaderElementSpec =
TreeHeaderElementDraw
};
+/* Disclosure triangle:
+ */
+#define TTK_TREEVIEW_STATE_OPEN TTK_STATE_USER1
+#define TTK_TREEVIEW_STATE_LEAF TTK_STATE_USER2
+static Ttk_StateTable DisclosureValueTable[] = {
+ { kThemeDisclosureDown, TTK_TREEVIEW_STATE_OPEN, 0 },
+ { kThemeDisclosureRight, 0, 0 },
+};
+
+static void DisclosureElementSize(
+ void *clientData, void *elementRecord, Tk_Window tkwin,
+ int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
+{
+ SInt32 s;
+ GetThemeMetric(kThemeMetricDisclosureTriangleWidth, &s); *widthPtr = s;
+ GetThemeMetric(kThemeMetricDisclosureTriangleHeight, &s); *heightPtr = s;
+}
+
+static void DisclosureElementDraw(
+ void *clientData, void *elementRecord, Tk_Window tkwin,
+ Drawable d, Ttk_Box b, Ttk_State state)
+{
+ Rect bounds = BoxToRect(b);
+ ThemeButtonDrawInfo info;
+
+ if (state & TTK_TREEVIEW_STATE_LEAF)
+ return;
+
+ info.state = Ttk_StateTableLookup(ThemeStateTable, state);
+ info.value = Ttk_StateTableLookup(DisclosureValueTable, state);
+ info.adornment = kThemeAdornmentDrawIndicatorOnly;
+
+ BEGIN_DRAWING(d)
+ DrawThemeButton(&bounds, kThemeDisclosureTriangle, &info,
+ NULL/*prevInfo*/,DontErase,NULL/*labelProc*/,0/*userData*/);
+ END_DRAWING
+}
+
+static Ttk_ElementSpec DisclosureElementSpec =
+{
+ TK_STYLE_VERSION_2,
+ sizeof(NullElement),
+ TtkNullElementOptions,
+ DisclosureElementSize,
+ DisclosureElementDraw
+};
+
/*----------------------------------------------------------------------
* +++ Widget layouts.
*/
@@ -944,6 +999,8 @@ static int AquaTheme_Init(Tcl_Interp *interp)
&ButtonElementSpec, &BevelButtonParms);
Ttk_RegisterElementSpec(themePtr, "Menubutton.button",
&ButtonElementSpec, &PopupButtonParms);
+ Ttk_RegisterElementSpec(themePtr, "Treeitem.indicator",
+ &DisclosureElementSpec, &DisclosureParms);
Ttk_RegisterElementSpec(themePtr, "Treeheading.cell",
&TreeHeaderElementSpec, &ListHeaderParms);