summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjenglish <jenglish@flightlab.com>2007-10-30 15:22:51 (GMT)
committerjenglish <jenglish@flightlab.com>2007-10-30 15:22:51 (GMT)
commitbbaec77e7acae48ed03a8b08a5bbd46ee3dd17ec (patch)
tree9b31b537a2c4034a53320d42fa7116e73638c36b
parent06e0381cd6b26bb2a980d4452a3bf9c04f43d11d (diff)
downloadtk-bbaec77e7acae48ed03a8b08a5bbd46ee3dd17ec.zip
tk-bbaec77e7acae48ed03a8b08a5bbd46ee3dd17ec.tar.gz
tk-bbaec77e7acae48ed03a8b08a5bbd46ee3dd17ec.tar.bz2
* generic/ttk/ttkWidget.c: Split up RedisplayWidget()
to factor out double-buffering related code. * macosx/ttkMacOSXAquaTheme.c: Use SetThemeBackGround/ kThemeBrushModelessDialogBackground{Active|Inactive} instead of ApplyThemeBackground/kThemeBackgroundWindowHeader (advice from DAS). * library/ttk/aquaTheme.tcl: Use darker shade for inactive and disabled text, to match typical values of most kThemeXXXTextColorInactive values.
-rw-r--r--ChangeLog14
-rw-r--r--generic/ttk/ttkWidget.c119
-rw-r--r--library/ttk/aquaTheme.tcl4
-rw-r--r--macosx/ttkMacOSXTheme.c32
4 files changed, 82 insertions, 87 deletions
diff --git a/ChangeLog b/ChangeLog
index d20121c..44275a6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2007-10-30 Joe English <jenglish@users.sourceforge.net>
+
+ * generic/ttk/ttkWidget.c: Split up RedisplayWidget()
+ to factor out double-buffering related code.
+
+ * macosx/ttkMacOSXAquaTheme.c: Use SetThemeBackGround/
+ kThemeBrushModelessDialogBackground{Active|Inactive}
+ instead of ApplyThemeBackground/kThemeBackgroundWindowHeader
+ (advice from DAS).
+
+ * library/ttk/aquaTheme.tcl: Use darker shade for inactive
+ and disabled text, to match typical values of most
+ kThemeXXXTextColorInactive values.
+
2007-10-30 Donal K. Fellows <donal.k.fellows@man.ac.uk>
* doc/selection.n: Clarify UTF8_STRING handling. [Bug 1778563]
diff --git a/generic/ttk/ttkWidget.c b/generic/ttk/ttkWidget.c
index 6fbb53b..6418969 100644
--- a/generic/ttk/ttkWidget.c
+++ b/generic/ttk/ttkWidget.c
@@ -1,8 +1,7 @@
-/* $Id: ttkWidget.c,v 1.7 2007/04/23 21:15:19 das Exp $
+/* $Id: ttkWidget.c,v 1.8 2007/10/30 15:22:51 jenglish Exp $
* Copyright (c) 2003, Joe English
*
- * Ttk widget implementation, core widget utilities.
- *
+ * Core widget utilities.
*/
#include <string.h>
@@ -20,13 +19,13 @@
/* UpdateLayout --
* Call the widget's get-layout hook to recompute corePtr->layout.
- * Returns TCL_OK if successful, returns TCL_ERROR and leaves
+ * Returns TCL_OK if successful, returns TCL_ERROR and leaves
* the layout unchanged otherwise.
*/
static int UpdateLayout(Tcl_Interp *interp, WidgetCore *corePtr)
{
Ttk_Theme themePtr = Ttk_GetCurrentTheme(interp);
- Ttk_Layout newLayout =
+ Ttk_Layout newLayout =
corePtr->widgetSpec->getLayoutProc(interp, themePtr,corePtr);
if (newLayout) {
@@ -52,83 +51,78 @@ static void SizeChanged(WidgetCore *corePtr)
}
}
-/*
- * RedisplayWidget --
- * Redraw a widget. Called as an idle handler.
+#ifndef TK_NO_DOUBLE_BUFFERING
+
+/* BeginDrawing --
+ * Returns a Drawable for drawing the widget contents.
+ * This is normally an off-screen Pixmap, copied to
+ * the window by EndDrawing().
*/
+static Drawable BeginDrawing(Tk_Window tkwin)
+{
+ return Tk_GetPixmap(Tk_Display(tkwin), Tk_WindowId(tkwin),
+ Tk_Width(tkwin), Tk_Height(tkwin),
+ DefaultDepthOfScreen(Tk_Screen(tkwin)));
+}
-static void RedisplayWidget(ClientData recordPtr)
+/* EndDrawing --
+ * Copy the drawable contents to the screen and release resources.
+ */
+static void EndDrawing(Tk_Window tkwin, Drawable d)
{
- WidgetCore *corePtr = (WidgetCore *)recordPtr;
- Tk_Window tkwin = corePtr->tkwin;
- Drawable d;
-#ifndef TK_NO_DOUBLE_BUFFERING
XGCValues gcValues;
GC gc;
-#endif /* TK_NO_DOUBLE_BUFFERING */
- corePtr->flags &= ~REDISPLAY_PENDING;
- if (!Tk_IsMapped(tkwin)) {
- return;
- }
-
-#ifndef TK_NO_DOUBLE_BUFFERING
- /*
- * Get a Pixmap for drawing in the background:
- */
- d = Tk_GetPixmap(Tk_Display(tkwin), Tk_WindowId(tkwin),
- Tk_Width(tkwin), Tk_Height(tkwin),
- DefaultDepthOfScreen(Tk_Screen(tkwin)));
-
- /*
- * Get a GC for blitting the pixmap to the display:
- */
gcValues.function = GXcopy;
gcValues.graphics_exposures = False;
- gc = Tk_GetGC(corePtr->tkwin, GCFunction|GCGraphicsExposures, &gcValues);
-#else
- d = Tk_WindowId(tkwin);
-#endif /* TK_NO_DOUBLE_BUFFERING */
-
- /*
- * Recompute layout and draw widget contents:
- */
- corePtr->widgetSpec->layoutProc(recordPtr);
- corePtr->widgetSpec->displayProc(recordPtr, d);
+ gc = Tk_GetGC(tkwin, GCFunction|GCGraphicsExposures, &gcValues);
-#ifndef TK_NO_DOUBLE_BUFFERING
- /*
- * Copy to the screen.
- */
XCopyArea(Tk_Display(tkwin), d, Tk_WindowId(tkwin), gc,
0, 0, (unsigned) Tk_Width(tkwin), (unsigned) Tk_Height(tkwin),
0, 0);
- /*
- * Release resources
- */
Tk_FreePixmap(Tk_Display(tkwin), d);
Tk_FreeGC(Tk_Display(tkwin), gc);
-#endif /* TK_NO_DOUBLE_BUFFERING */
+}
+#else
+/* No double-buffering: draw directly into the window. */
+static Drawable BeginDrawing(Tk_Window tkwin) { return Tk_WindowId(tkwin); }
+static void EndDrawing(Tk_Window tkwin, Drawable d) { }
+#endif
+
+/* DrawWidget --
+ * Redraw a widget. Called as an idle handler.
+ */
+static void DrawWidget(ClientData recordPtr)
+{
+ WidgetCore *corePtr = recordPtr;
+
+ corePtr->flags &= ~REDISPLAY_PENDING;
+ if (Tk_IsMapped(corePtr->tkwin)) {
+ Drawable d = BeginDrawing(corePtr->tkwin);
+ corePtr->widgetSpec->layoutProc(recordPtr);
+ corePtr->widgetSpec->displayProc(recordPtr, d);
+ EndDrawing(corePtr->tkwin, d);
+ }
}
-/* TtkRedisplayWidget --
+/* TtkRedisplayWidget --
* Schedule redisplay as an idle handler.
*/
-void TtkRedisplayWidget(WidgetCore *corePtr)
+void TtkRedisplayWidget(WidgetCore *corePtr)
{
if (corePtr->flags & WIDGET_DESTROYED) {
return;
}
if (!(corePtr->flags & REDISPLAY_PENDING)) {
- Tcl_DoWhenIdle(RedisplayWidget, (ClientData) corePtr);
+ Tcl_DoWhenIdle(DrawWidget, (ClientData) corePtr);
corePtr->flags |= REDISPLAY_PENDING;
}
}
/* TtkResizeWidget --
- * Recompute widget size, schedule geometry propagation and redisplay.
+ * Recompute widget size, schedule geometry propagation and redisplay.
*/
void TtkResizeWidget(WidgetCore *corePtr)
{
@@ -240,7 +234,7 @@ WidgetCleanup(char *memPtr)
*
* For Deactivate/Activate pseudo-events, clear/set the background state flag.
*
- * <<NOTE-REALIZED>> On the first ConfigureNotify event
+ * <<NOTE-REALIZED>> On the first ConfigureNotify event
* (which indicates that the window has just been created),
* update the layout. This is to work around two problems:
* (1) Virtual events aren't delivered to unrealized widgets
@@ -286,7 +280,7 @@ static void CoreEventProc(ClientData clientData, XEvent *eventPtr)
CoreEventMask,CoreEventProc,clientData);
if (corePtr->flags & REDISPLAY_PENDING) {
- Tcl_CancelIdleCall(RedisplayWidget, clientData);
+ Tcl_CancelIdleCall(DrawWidget, clientData);
}
corePtr->widgetSpec->cleanupProc(corePtr);
@@ -484,7 +478,7 @@ Ttk_Layout TtkWidgetGetLayout(
WidgetCore *corePtr = recordPtr;
const char *styleName = 0;
- if (corePtr->styleObj)
+ if (corePtr->styleObj)
styleName = Tcl_GetString(corePtr->styleObj);
if (!styleName || *styleName == '\0')
@@ -496,8 +490,8 @@ Ttk_Layout TtkWidgetGetLayout(
/*
* TtkWidgetGetOrientedLayout --
- * Helper routine. Same as TtkWidgetGetLayout, but prefixes
- * "Horizontal." or "Vertical." to the style name, depending
+ * Helper routine. Same as TtkWidgetGetLayout, but prefixes
+ * "Horizontal." or "Vertical." to the style name, depending
* on the value of the 'orient' option.
*/
Ttk_Layout TtkWidgetGetOrientedLayout(
@@ -511,18 +505,17 @@ Ttk_Layout TtkWidgetGetOrientedLayout(
Tcl_DStringInit(&styleName);
- /* Prefix:
+ /* Prefix:
*/
Ttk_GetOrientFromObj(NULL, orientObj, &orient);
if (orient == TTK_ORIENT_HORIZONTAL)
Tcl_DStringAppend(&styleName, "Horizontal.", -1);
- else
+ else
Tcl_DStringAppend(&styleName, "Vertical.", -1);
-
/* Add base style name:
*/
- if (corePtr->styleObj)
+ if (corePtr->styleObj)
baseStyleName = Tcl_GetString(corePtr->styleObj);
if (!baseStyleName || *baseStyleName == '\0')
baseStyleName = corePtr->widgetSpec->className;
@@ -531,7 +524,7 @@ Ttk_Layout TtkWidgetGetOrientedLayout(
/* Create layout:
*/
- layout= Ttk_CreateLayout(interp, themePtr, Tcl_DStringValue(&styleName),
+ layout= Ttk_CreateLayout(interp, themePtr, Tcl_DStringValue(&styleName),
recordPtr, corePtr->optionTable, corePtr->tkwin);
Tcl_DStringFree(&styleName);
@@ -784,7 +777,7 @@ int TtkWidgetIdentifyCommand(
|| Tcl_GetIntFromObj(interp, objv[3], &y) != TCL_OK)
return TCL_ERROR;
- node = Ttk_LayoutIdentify(corePtr->layout, x, y);
+ node = Ttk_LayoutIdentify(corePtr->layout, x, y);
if (node) {
const char *elementName = Ttk_LayoutNodeName(node);
Tcl_SetObjResult(interp,Tcl_NewStringObj(elementName,-1));
diff --git a/library/ttk/aquaTheme.tcl b/library/ttk/aquaTheme.tcl
index cb99600..1ed45d9 100644
--- a/library/ttk/aquaTheme.tcl
+++ b/library/ttk/aquaTheme.tcl
@@ -1,5 +1,5 @@
#
-# $Id: aquaTheme.tcl,v 1.6 2007/10/28 18:56:51 jenglish Exp $
+# $Id: aquaTheme.tcl,v 1.7 2007/10/30 15:22:52 jenglish Exp $
#
# Aqua theme (OSX native look and feel)
#
@@ -17,7 +17,7 @@ namespace eval ttk::theme::aqua {
-insertwidth 1 \
;
ttk::style map . \
- -foreground [list disabled "#a3a3a3" background "#a3a3a3"] \
+ -foreground [list disabled "#7f7f7f" background "#7f7f7f"] \
-selectbackground [list background "#c3c3c3" !focus "#c3c3c3"] \
-selectforeground [list background "#a3a3a3" !focus "#000000"] \
;
diff --git a/macosx/ttkMacOSXTheme.c b/macosx/ttkMacOSXTheme.c
index 7f99776..616a0aa 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.12 2007/10/28 18:56:51 jenglish Exp $
+ * RCS: @(#) $Id: ttkMacOSXTheme.c,v 1.13 2007/10/30 15:22:52 jenglish Exp $
*/
#include "tkMacOSXPrivate.h"
@@ -742,7 +742,7 @@ static Ttk_ElementSpec SizegripElementSpec = {
};
/*----------------------------------------------------------------------
- * +++ Background element -- an experiment.
+ * +++ Background element.
*
* This isn't quite right: In Aqua, the correct background for
* a control depends on what kind of container it belongs to,
@@ -751,36 +751,24 @@ static Ttk_ElementSpec SizegripElementSpec = {
* Also: patterned backgrounds should be aligned with the coordinate
* system of the top-level window. If we're drawing into an
* off-screen graphics port this leads to alignment glitches.
- *
- * Available kTheme constants:
- * kThemeBackgroundTabPane,
- * kThemeBackgroundPlacard,
- * kThemeBackgroundWindowHeader,
- * kThemeBackgroundListViewWindowHeader,
- * kThemeBackgroundSecondaryGroupBox,
- *
- * SetThemeBackground() offers more kThemeBrush* choices.
- *
*/
static void BackgroundElementDraw(
void *clientData, void *elementRecord, Tk_Window tkwin,
Drawable d, Ttk_Box b, Ttk_State state)
{
- ThemeBackgroundKind kind = kThemeBackgroundWindowHeader;
+ ThemeBrush brush
+ = (state & TTK_STATE_BACKGROUND)
+ ? kThemeBrushModelessDialogBackgroundInactive
+ : kThemeBrushModelessDialogBackgroundActive
+ ;
+
Rect bounds = BoxToRect(d, Ttk_WinBox(tkwin));
- SInt32 depth = 32; /* ??? */
+ SInt32 depth = 32; /* ??? */
Boolean inColor = true;
- /* Avoid kThemeStatePressed, which seems to give bad results
- * for ApplyThemeBackground:
- */
- state &= ~TTK_STATE_PRESSED;
-
BEGIN_DRAWING(d)
- ApplyThemeBackground(kind, &bounds,
- Ttk_StateTableLookup(ThemeStateTable, state),
- depth, inColor);
+ SetThemeBackground(brush, depth, inColor);
QDSetPatternOrigin(PatternOrigin(tkwin, d));
EraseRect(&bounds);
END_DRAWING