Tk Source Code

Artifact [3a75228ad8]
Login

Artifact 3a75228ad8eb8163502978e07defb332d2133805:

Attachment "ttkMacOSXTheme.patch" to ticket [2819620fff] added by wordtech 2009-07-10 20:59:28.
--- /Users/kevin/tk-cooca-858/tk/macosx/ttkMacOSXTheme copy.c	2009-05-17 00:48:12.000000000 -0400
+++ /Users/kevin/tk-cooca-858/tk/macosx/ttkMacOSXTheme.c	2009-05-30 19:08:52.000000000 -0400
@@ -7,6 +7,7 @@
  * Copyright (c) 2005 Neil Madden
  * Copyright (c) 2006-2009 Daniel A. Steffen <das@users.sourceforge.net>
  * Copyright 2008-2009, Apple Inc.
+ * Copyright 2009 Kevin Walzer/WordTech Communications LLC. 
  *
  * See the file "license.terms" for information on usage and redistribution
  * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
@@ -220,6 +221,12 @@
  * +++ Notebook elements.
  */
 
+
+//courtesy of Joe English, implements tab position logic for modern-style Mac tabs
+
+#define TTK_STATE_NOTEBOOK_FIRST TTK_STATE_USER1
+#define TTK_STATE_NOTEBOOK_LAST  TTK_STATE_USER2
+
 static Ttk_StateTable TabStyleTable[] = {
     { kThemeTabFrontInactive, TTK_STATE_SELECTED|TTK_STATE_BACKGROUND, 0 },
     { kThemeTabNonFrontInactive, TTK_STATE_BACKGROUND, 0 },
@@ -230,16 +237,37 @@
     { kThemeTabNonFront, 0,0 }
 };
 
+static Ttk_StateTable TabPositionTable[] = {
+    { kHIThemeTabPositionOnly,
+      TTK_STATE_NOTEBOOK_FIRST|TTK_STATE_NOTEBOOK_LAST },
+    { kHIThemeTabPositionFirst, TTK_STATE_NOTEBOOK_FIRST },
+    { kHIThemeTabPositionLast, TTK_STATE_NOTEBOOK_LAST },
+    { kHIThemeTabPositionMiddle, 0 },
+};
+
+static Ttk_StateTable TabAdornmentTable[] = {
+    {kHIThemeTabAdornmentTrailingSeparator, TTK_STATE_NOTEBOOK_FIRST},
+    {kHIThemeTabAdornmentNone, TTK_STATE_NOTEBOOK_LAST },
+    {kHIThemeTabAdornmentTrailingSeparator, 0 },
+};
+
+
 /*
- * Quoth DrawThemeTab() reference manual:
- * "Small tabs have a height of 16 pixels large tabs have a height of
- * 21 pixels. (The widths of tabs are variable.) Additionally, the
- * distance that the tab overlaps the pane must be included in the tab
- * rectangle this overlap distance is always 3 pixels, although the
- * 3-pixel overlap is only drawn for the front tab."
+From the Apple Human Interface Guidelines:
+"Tab View Specifications
+Control sizes: Tab views are available in regular, small, and mini sizes. The tab height is fixed for each size, but you control the size of the pane area. The tab heights for each size are listed below:
+
+Regular size: 20 pixels.
+Small: 17 pixels.
+Mini: 15 pixels."
+
+http://developer.apple.com/documentation/userexperience/Conceptual/AppleHIGuidelines/XHIGControls/XHIGControls.html#//apple_ref/doc/uid/TP30000359-TPXREF116
+
+Tab overlap: set to -1 after trial and error.
  */
-static const int TAB_HEIGHT = 21;
-static const int TAB_OVERLAP = 3;
+
+static const int TAB_HEIGHT = 20;
+static const int TAB_OVERLAP = -1;
 
 static void TabElementSize(
     void *clientData, void *elementRecord, Tk_Window tkwin,
@@ -254,13 +282,13 @@
 {
     CGRect bounds = BoxToRect(d, b);
     HIThemeTabDrawInfo info = {
-	.version = 0,
+	.version = 1,
 	.style = Ttk_StateTableLookup(TabStyleTable, state),
 	.direction = kThemeTabNorth,
 	.size = kHIThemeTabSizeNormal,
-	.adornment = kHIThemeTabAdornmentNone,
+	.adornment = Ttk_StateTableLookup(TabAdornmentTable, state),
 	.kind = kHIThemeTabKindNormal,
-	.position = kHIThemeTabPositionMiddle,
+	.position = Ttk_StateTableLookup(TabPositionTable, state ), 
     };
 
     bounds.size.height += TAB_OVERLAP;
@@ -285,7 +313,7 @@
     int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
 {
     /* Padding determined by trial-and-error */
-    *paddingPtr = Ttk_MakePadding(2, 8, 2, 2);
+     *paddingPtr = Ttk_MakePadding(2, 8, 2, 2);
 }
 
 static void PaneElementDraw(
@@ -294,7 +322,7 @@
 {
     CGRect bounds = BoxToRect(d, b);
     HIThemeTabPaneDrawInfo info = {
-	.version = 0,
+	.version = 1,
 	.state = Ttk_StateTableLookup(ThemeStateTable, state),
 	.direction = kThemeTabNorth,
 	.size = kHIThemeTabSizeNormal,
@@ -846,10 +874,12 @@
 /*----------------------------------------------------------------------
  * +++ Treeview header
  *	Redefine the header to use a kThemeListHeaderButton.
+ *      kThemeAdornmentHeaderButtonNoSortArrow makes header turn Aqua-blue in "selected" state; script can add 
+ *      sort arrow if necessary.
  */
 
 static Ttk_StateTable TreeHeaderAdornmentTable[] = {
-    { kThemeAdornmentHeaderButtonSortUp, TTK_STATE_ALTERNATE, 0 },
+    { kThemeAdornmentHeaderButtonNoSortArrow, TTK_STATE_SELECTED, 0 },
     { kThemeAdornmentFocus, TTK_STATE_FOCUS, 0 },
     { kThemeAdornmentNone, 0, 0 }
 };