From be03330f5858260351f40d4c3dffb0363d358ee5 Mon Sep 17 00:00:00 2001 From: jenglish Date: Wed, 3 Dec 2008 18:44:49 +0000 Subject: Add new "hover" state (patch from Pat Thoyts; needed to support proper visual feedback on Vista). --- ChangeLog | 7 +++++++ doc/ttk_widget.n | 10 +++++++++- generic/ttk/ttkState.c | 9 ++++++++- generic/ttk/ttkTheme.h | 4 ++-- generic/ttk/ttkWidget.c | 12 +++++++++++- library/ttk/combobox.tcl | 4 +--- 6 files changed, 38 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index ba1c26d..a417539 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2008-12-03 Joe English + + * generic/ttk/ttkState.c, generic/ttk/ttkTheme.h, + generic/ttk/ttkWidget.c, doc/ttk_widget.n: + Add new "hover" state (patch from Pat Thoyts; needed + to support proper visual feedback on Vista). + 2008-11-29 Pat Thoyts * library/ttk/altTheme.tcl: Use a styled frame around the popdown diff --git a/doc/ttk_widget.n b/doc/ttk_widget.n index 1f17243..ca6080d 100644 --- a/doc/ttk_widget.n +++ b/doc/ttk_widget.n @@ -4,7 +4,7 @@ '\" See the file "license.terms" for information on usage and redistribution '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. '\" -'\" RCS: @(#) $Id: ttk_widget.n,v 1.16 2008/09/23 13:36:58 dkf Exp $ +'\" RCS: @(#) $Id: ttk_widget.n,v 1.17 2008/12/03 18:44:49 jenglish Exp $ '\" .so man.macros .TH ttk::widget n 8.5 Tk "Tk Themed Widget" @@ -234,6 +234,14 @@ state, and for buttons with \fB\-default active\fR. The widget's value is invalid. (Potential uses: scale widget value out of bounds, entry widget value failed validation.) +.TP +\fBhover\fR +The mouse cursor is within the widget. +This is similar to the \fBactive\fP state; +it is used in some themes for widgets that +provide distinct visual feedback for +the active widget in addition to the active element +within the widget. .PP A \fIstate specification\fR or \fIstateSpec\fR is a list of state names, optionally prefixed with an exclamation point (!) diff --git a/generic/ttk/ttkState.c b/generic/ttk/ttkState.c index 29a526d..693c5d7 100644 --- a/generic/ttk/ttkState.c +++ b/generic/ttk/ttkState.c @@ -1,5 +1,5 @@ /* - * $Id: ttkState.c,v 1.2 2008/11/02 09:54:02 nijtmans Exp $ + * $Id: ttkState.c,v 1.3 2008/12/03 18:44:49 jenglish Exp $ * * Tk widget state utilities. * @@ -27,6 +27,13 @@ static const char *const stateNames[] = "alternate", /* Widget-specific alternate display style */ "invalid", /* Bad value */ "readonly", /* Editing/modification disabled */ + "hover", /* Mouse cursor is over widget */ + "reserved1", /* Reserved for future extension */ + "reserved2", /* Reserved for future extension */ + "reserved3", /* Reserved for future extension */ + "user3", /* User-definable state */ + "user2", /* User-definable state */ + "user1", /* User-definable state */ NULL }; diff --git a/generic/ttk/ttkTheme.h b/generic/ttk/ttkTheme.h index f054181..01a1571 100644 --- a/generic/ttk/ttkTheme.h +++ b/generic/ttk/ttkTheme.h @@ -1,4 +1,4 @@ -/* $Id: ttkTheme.h,v 1.15 2008/11/02 09:54:02 nijtmans Exp $ +/* $Id: ttkTheme.h,v 1.16 2008/12/03 18:44:49 jenglish Exp $ * Copyright (c) 2003 Joe English. Freely redistributable. * * Declarations for Tk theme engine. @@ -48,7 +48,7 @@ typedef unsigned int Ttk_State; #define TTK_STATE_ALTERNATE (1<<6) #define TTK_STATE_INVALID (1<<7) #define TTK_STATE_READONLY (1<<8) -#define TTK_STATE_USER7 (1<<9) +#define TTK_STATE_HOVER (1<<9) #define TTK_STATE_USER6 (1<<10) #define TTK_STATE_USER5 (1<<11) #define TTK_STATE_USER4 (1<<12) diff --git a/generic/ttk/ttkWidget.c b/generic/ttk/ttkWidget.c index 9f8e0a4..820d3d8 100644 --- a/generic/ttk/ttkWidget.c +++ b/generic/ttk/ttkWidget.c @@ -1,4 +1,4 @@ -/* $Id: ttkWidget.c,v 1.19 2008/11/16 17:14:16 jenglish Exp $ +/* $Id: ttkWidget.c,v 1.20 2008/12/03 18:44:50 jenglish Exp $ * Copyright (c) 2003, Joe English * * Core widget utilities. @@ -281,6 +281,8 @@ static const unsigned CoreEventMask | FocusChangeMask | VirtualEventMask | ActivateMask + | EnterWindowMask + | LeaveWindowMask ; static void CoreEventProc(ClientData clientData, XEvent *eventPtr) @@ -324,6 +326,14 @@ static void CoreEventProc(ClientData clientData, XEvent *eventPtr) corePtr->state |= TTK_STATE_BACKGROUND; TtkRedisplayWidget(corePtr); break; + case LeaveNotify: + corePtr->state &= ~TTK_STATE_HOVER; + TtkRedisplayWidget(corePtr); + break; + case EnterNotify: + corePtr->state |= TTK_STATE_HOVER; + TtkRedisplayWidget(corePtr); + break; case VirtualEvent: if (!strcmp("ThemeChanged", ((XVirtualEvent *)(eventPtr))->name)) { (void)UpdateLayout(corePtr->interp, corePtr); diff --git a/library/ttk/combobox.tcl b/library/ttk/combobox.tcl index 581c227..5b93374 100644 --- a/library/ttk/combobox.tcl +++ b/library/ttk/combobox.tcl @@ -1,5 +1,5 @@ # -# $Id: combobox.tcl,v 1.16 2008/11/29 00:43:48 patthoyts Exp $ +# $Id: combobox.tcl,v 1.17 2008/12/03 18:44:50 jenglish Exp $ # # Combobox bindings. # @@ -61,8 +61,6 @@ bind TCombobox { ttk::combobox::Press "2" %W %x %y } bind TCombobox { ttk::combobox::Press "3" %W %x %y } bind TCombobox { ttk::combobox::Drag %W %x } bind TCombobox { ttk::combobox::Motion %W %x %y } -bind TCombobox {%W instate !disabled {%W state active}} -bind TCombobox {%W state !active} bind TCombobox { ttk::combobox::Scroll %W [expr {%D/-120}] } if {[tk windowingsystem] eq "x11"} { -- cgit v0.12