summaryrefslogtreecommitdiffstats
path: root/unix
diff options
context:
space:
mode:
authorhobbs <hobbs>2004-02-18 00:40:23 (GMT)
committerhobbs <hobbs>2004-02-18 00:40:23 (GMT)
commitf349a3827b7c3d5876b0531780396c6acda15450 (patch)
tree7f16efd14fa17fc03ce82796e8314678aa3d6e1e /unix
parent4549e3fbc8a24a6ba2228d48dcea4dba5e49c506 (diff)
downloadtk-f349a3827b7c3d5876b0531780396c6acda15450.zip
tk-f349a3827b7c3d5876b0531780396c6acda15450.tar.gz
tk-f349a3827b7c3d5876b0531780396c6acda15450.tar.bz2
* doc/checkbutton.n: TIP#110 implementation
* doc/radiobutton.n: Tristate Checkbutton and Radiobuttons * generic/tkButton.c: * generic/tkButton.h: * library/demos/check.tcl: * library/demos/radio.tcl: * macosx/tkMacOSXButton.c: * macosx/tkMacOSXDefault.h: * tests/button.test: * unix/tkUnixButton.c: * unix/tkUnixDefault.h: * win/tkWinButton.c: * win/tkWinDefault.h:
Diffstat (limited to 'unix')
-rw-r--r--unix/tkUnixButton.c33
-rw-r--r--unix/tkUnixDefault.h3
2 files changed, 24 insertions, 12 deletions
diff --git a/unix/tkUnixButton.c b/unix/tkUnixButton.c
index 9b3c11b..ef6d866 100644
--- a/unix/tkUnixButton.c
+++ b/unix/tkUnixButton.c
@@ -9,7 +9,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkUnixButton.c,v 1.16 2003/10/10 20:19:51 hobbs Exp $
+ * RCS: @(#) $Id: tkUnixButton.c,v 1.17 2004/02/18 00:40:24 hobbs Exp $
*/
#include "tkButton.h"
@@ -180,30 +180,34 @@ TkpDrawCheckIndicator(tkwin, display, d, x, y, bgBorder, indicatorColor,
switch (mode) {
default:
case CHECK_BUTTON:
- imgsel = on ? CHECK_ON_OFFSET : CHECK_OFF_OFFSET;
- imgsel += disabled ? CHECK_DISOFF_OFFSET : 0;
+ imgsel = on == 2 ? CHECK_DISON_OFFSET :
+ on == 1 ? CHECK_ON_OFFSET : CHECK_OFF_OFFSET;
+ imgsel += disabled && on != 2 ? CHECK_DISOFF_OFFSET : 0;
imgstart = CHECK_START;
dim = CHECK_BUTTON_DIM;
break;
case CHECK_MENU:
- imgsel = on ? CHECK_ON_OFFSET : CHECK_OFF_OFFSET;
- imgsel += disabled ? CHECK_DISOFF_OFFSET : 0;
+ imgsel = on == 2 ? CHECK_DISOFF_OFFSET :
+ on == 1 ? CHECK_ON_OFFSET : CHECK_OFF_OFFSET;
+ imgsel += disabled && on != 2 ? CHECK_DISOFF_OFFSET : 0;
imgstart = CHECK_START + 2;
imgsel += 2;
dim = CHECK_MENU_DIM;
break;
case RADIO_BUTTON:
- imgsel = on ? RADIO_ON_OFFSET : RADIO_OFF_OFFSET;
- imgsel += disabled ? RADIO_DISOFF_OFFSET : 0;
+ imgsel = on == 2 ? RADIO_DISON_OFFSET :
+ on==1 ? RADIO_ON_OFFSET : RADIO_OFF_OFFSET;
+ imgsel += disabled && on != 2 ? RADIO_DISOFF_OFFSET : 0;
imgstart = RADIO_START;
dim = RADIO_BUTTON_DIM;
break;
case RADIO_MENU:
- imgsel = on ? RADIO_ON_OFFSET : RADIO_OFF_OFFSET;
- imgsel += disabled ? RADIO_DISOFF_OFFSET : 0;
+ imgsel = on == 2 ? RADIO_DISOFF_OFFSET :
+ on==1 ? RADIO_ON_OFFSET : RADIO_OFF_OFFSET;
+ imgsel += disabled && on != 2 ? RADIO_DISOFF_OFFSET : 0;
imgstart = RADIO_START + 3;
imgsel += 3;
dim = RADIO_MENU_DIM;
@@ -515,6 +519,9 @@ TkpDisplayButton(clientData)
if ((butPtr->selectImage != NULL) && (butPtr->flags & SELECTED)) {
Tk_RedrawImage(butPtr->selectImage, 0, 0,
width, height, pixmap, imageXOffset, imageYOffset);
+ } else if ((butPtr->tristateImage != NULL) && (butPtr->flags & TRISTATED)) {
+ Tk_RedrawImage(butPtr->tristateImage, 0, 0,
+ width, height, pixmap, imageXOffset, imageYOffset);
} else {
Tk_RedrawImage(butPtr->image, 0, 0, width,
height, pixmap, imageXOffset, imageYOffset);
@@ -555,6 +562,10 @@ TkpDisplayButton(clientData)
(butPtr->flags & SELECTED)) {
Tk_RedrawImage(butPtr->selectImage, 0, 0, width,
height, pixmap, imageXOffset, imageYOffset);
+ } else if ((butPtr->tristateImage != NULL) &&
+ (butPtr->flags & TRISTATED)) {
+ Tk_RedrawImage(butPtr->tristateImage, 0, 0, width,
+ height, pixmap, imageXOffset, imageYOffset);
} else {
Tk_RedrawImage(butPtr->image, 0, 0, width, height, pixmap,
imageXOffset, imageYOffset);
@@ -608,7 +619,7 @@ TkpDisplayButton(clientData)
y = Tk_Height(tkwin)/2;
TkpDrawCheckIndicator(tkwin, butPtr->display, pixmap, x, y,
border, butPtr->normalFg, selColor, butPtr->disabledFg,
- (butPtr->flags & SELECTED),
+ ((butPtr->flags & SELECTED)?1:(butPtr->flags & TRISTATED)?2:0),
(butPtr->state == STATE_DISABLED), CHECK_BUTTON);
}
} else if ((butPtr->type == TYPE_RADIO_BUTTON) && butPtr->indicatorOn) {
@@ -623,7 +634,7 @@ TkpDisplayButton(clientData)
y = Tk_Height(tkwin)/2;
TkpDrawCheckIndicator(tkwin, butPtr->display, pixmap, x, y,
border, butPtr->normalFg, selColor, butPtr->disabledFg,
- (butPtr->flags & SELECTED),
+ ((butPtr->flags & SELECTED)?1:(butPtr->flags & TRISTATED)?2:0),
(butPtr->state == STATE_DISABLED), RADIO_BUTTON);
}
}
diff --git a/unix/tkUnixDefault.h b/unix/tkUnixDefault.h
index e8bbea7..f9674d6 100644
--- a/unix/tkUnixDefault.h
+++ b/unix/tkUnixDefault.h
@@ -10,7 +10,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkUnixDefault.h,v 1.19 2003/10/31 09:02:17 vincentdarley Exp $
+ * RCS: @(#) $Id: tkUnixDefault.h,v 1.20 2004/02/18 00:40:24 hobbs Exp $
*/
#ifndef _TKUNIXDEFAULT
@@ -88,6 +88,7 @@
#define DEF_BUTTON_JUSTIFY "center"
#define DEF_BUTTON_OFF_VALUE "0"
#define DEF_BUTTON_ON_VALUE "1"
+#define DEF_BUTTON_TRISTATE_VALUE ""
#define DEF_BUTTON_OVER_RELIEF ""
#define DEF_BUTTON_PADX "3m"
#define DEF_LABCHKRAD_PADX "1"