summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorericm <ericm>2000-03-08 03:19:31 (GMT)
committerericm <ericm>2000-03-08 03:19:31 (GMT)
commit0abc21f01163916effa8f0d1fd17fd424f5fcc8f (patch)
tree5403f486f69a9ec059f8cf94b1eebe8dbe2bfc85
parent46c246b94240ad0b0015045bc5fe5bddf4b435bf (diff)
downloadtk-0abc21f01163916effa8f0d1fd17fd424f5fcc8f.zip
tk-0abc21f01163916effa8f0d1fd17fd424f5fcc8f.tar.gz
tk-0abc21f01163916effa8f0d1fd17fd424f5fcc8f.tar.bz2
* tests/button.test:
* generic/tkButton.c: Added -disabledforeground/-state to labels.
-rw-r--r--ChangeLog13
-rw-r--r--generic/tkButton.c51
-rw-r--r--tests/button.test10
3 files changed, 48 insertions, 26 deletions
diff --git a/ChangeLog b/ChangeLog
index 83764b8..72e82fe 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2000-03-07 Eric Melski <ericm@scriptics.com>
+
+ * tests/button.test:
+ * generic/tkButton.c: Added -disabledforeground/-state to labels.
+
2000-03-07 Jeff Hobbs <hobbs@scriptics.com>
* tests/entry.test:
@@ -8,6 +13,14 @@
2000-03-06 Eric Melski <ericm@scriptics.com>
+ * library/menu.tcl: Added a check in tkMenuFirstEntry that changes
+ menu behavior to only auto-post an immediate child cascade if we
+ are currently on a menubar menu. This prevents massive
+ auto-cascading in cases where the first entry of the cascade is
+ itself a cascade, and the first entry of that cascade is a
+ cascade, and the first entry of that cascade is a cascade
+ ... [Bug: 676].
+
* generic/tkOldConfig.c: Added check for NULL tkwin value in
Tk_ConfigureWidget [Bug: 4079]
diff --git a/generic/tkButton.c b/generic/tkButton.c
index dce66f9..1d832c8 100644
--- a/generic/tkButton.c
+++ b/generic/tkButton.c
@@ -11,7 +11,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkButton.c,v 1.3 1999/04/16 01:51:10 stanton Exp $
+ * RCS: @(#) $Id: tkButton.c,v 1.4 2000/03/08 03:19:31 ericm Exp $
*/
#include "tkButton.h"
@@ -66,6 +66,10 @@ static Tk_OptionSpec labelOptionSpecs[] = {
{TK_OPTION_CURSOR, "-cursor", "cursor", "Cursor",
DEF_BUTTON_CURSOR, -1, Tk_Offset(TkButton, cursor),
TK_OPTION_NULL_OK, 0, 0},
+ {TK_OPTION_COLOR, "-disabledforeground", "disabledForeground",
+ "DisabledForeground", DEF_BUTTON_DISABLED_FG_COLOR,
+ -1, Tk_Offset(TkButton, disabledFg), TK_OPTION_NULL_OK,
+ (ClientData) DEF_BUTTON_DISABLED_FG_MONO, 0},
{TK_OPTION_SYNONYM, "-fg", "foreground", (char *) NULL,
(char *) NULL, 0, -1, 0, (ClientData) "-foreground", 0},
{TK_OPTION_FONT, "-font", "font", "Font",
@@ -98,6 +102,9 @@ static Tk_OptionSpec labelOptionSpecs[] = {
Tk_Offset(TkButton, padY), 0, 0, 0},
{TK_OPTION_RELIEF, "-relief", "relief", "Relief",
DEF_LABCHKRAD_RELIEF, -1, Tk_Offset(TkButton, relief), 0, 0, 0},
+ {TK_OPTION_STRING_TABLE, "-state", "state", "State",
+ DEF_BUTTON_STATE, -1, Tk_Offset(TkButton, state),
+ 0, (ClientData) stateStrings, 0},
{TK_OPTION_STRING, "-takefocus", "takeFocus", "TakeFocus",
DEF_LABEL_TAKE_FOCUS, Tk_Offset(TkButton, takeFocusPtr), -1,
TK_OPTION_NULL_OK, 0, 0},
@@ -1271,29 +1278,31 @@ TkButtonWorldChanged(instanceData)
butPtr->activeTextGC = newGC;
}
- if (butPtr->type != TYPE_LABEL) {
- gcValues.background = Tk_3DBorderColor(butPtr->normalBorder)->pixel;
- if ((butPtr->disabledFg != NULL) && (butPtr->imagePtr == NULL)) {
- gcValues.foreground = butPtr->disabledFg->pixel;
- mask = GCForeground | GCBackground | GCFont;
- } else {
- gcValues.foreground = gcValues.background;
- mask = GCForeground;
- if (butPtr->gray == None) {
- butPtr->gray = Tk_GetBitmap(NULL, butPtr->tkwin, "gray50");
- }
- if (butPtr->gray != None) {
- gcValues.fill_style = FillStippled;
- gcValues.stipple = butPtr->gray;
- mask |= GCFillStyle | GCStipple;
- }
+ /*
+ * Allocate the disabled graphics context, for drawing the widget in
+ * its disabled state
+ */
+ gcValues.background = Tk_3DBorderColor(butPtr->normalBorder)->pixel;
+ if ((butPtr->disabledFg != NULL) && (butPtr->imagePtr == NULL)) {
+ gcValues.foreground = butPtr->disabledFg->pixel;
+ mask = GCForeground | GCBackground | GCFont;
+ } else {
+ gcValues.foreground = gcValues.background;
+ mask = GCForeground;
+ if (butPtr->gray == None) {
+ butPtr->gray = Tk_GetBitmap(NULL, butPtr->tkwin, "gray50");
}
- newGC = Tk_GetGC(butPtr->tkwin, mask, &gcValues);
- if (butPtr->disabledGC != None) {
- Tk_FreeGC(butPtr->display, butPtr->disabledGC);
+ if (butPtr->gray != None) {
+ gcValues.fill_style = FillStippled;
+ gcValues.stipple = butPtr->gray;
+ mask |= GCFillStyle | GCStipple;
}
- butPtr->disabledGC = newGC;
}
+ newGC = Tk_GetGC(butPtr->tkwin, mask, &gcValues);
+ if (butPtr->disabledGC != None) {
+ Tk_FreeGC(butPtr->display, butPtr->disabledGC);
+ }
+ butPtr->disabledGC = newGC;
if (butPtr->copyGC == None) {
butPtr->copyGC = Tk_GetGC(butPtr->tkwin, 0, &gcValues);
diff --git a/tests/button.test b/tests/button.test
index 24fc2dc..58932bb 100644
--- a/tests/button.test
+++ b/tests/button.test
@@ -7,7 +7,7 @@
# Copyright (c) 1998-1999 by Scriptics Corporation.
# All rights reserved.
#
-# RCS: @(#) $Id: button.test,v 1.4 2000/03/02 21:52:24 hobbs Exp $
+# RCS: @(#) $Id: button.test,v 1.5 2000/03/08 03:19:31 ericm Exp $
if {[lsearch [namespace children] ::tcltest] == -1} {
source [file join [pwd] [file dirname [info script]] defs.tcl]
@@ -69,7 +69,7 @@ foreach test {
{bad default "huh?": must be active, disabled, or normal}
{0 1 0 0}}
{-disabledforeground #00ff00 #00ff00 xyzzy {unknown color name "xyzzy"}
- {0 1 1 1}}
+ {1 1 1 1}}
{-fg #110022 #110022 bogus {unknown color name "bogus"} {1 1 1 1}}
{-font {Helvetica 12} {Helvetica 12} {} {font "" doesn't exist} {1 1 1 1}}
{-foreground #110022 #110022 bogus {unknown color name "bogus"} {1 1 1 1}}
@@ -91,7 +91,7 @@ foreach test {
{-relief groove groove 1.5 {bad relief "1.5": must be flat, groove, raised, ridge, solid, or sunken} {1 1 1 1}}
{-selectcolor #110022 #110022 bogus {unknown color name "bogus"} {0 0 1 1}}
{-selectimage image1 image1 bogus {image "bogus" doesn't exist} {0 0 1 1}}
- {-state normal normal bogus {bad state "bogus": must be active, disabled, or normal} {0 1 1 1}}
+ {-state normal normal bogus {bad state "bogus": must be active, disabled, or normal} {1 1 1 1}}
{-takefocus "any string" "any string" {} {} {1 1 1 1}}
{-text "Sample text" {Sample text} {} {} {1 1 1 1}}
{-textvariable i i {} {} {1 1 1 1}}
@@ -201,8 +201,8 @@ test button-4.6 {ButtonWidgetCmd procedure, "cget" option} {
.b cget -highlightthickness
} {3}
test button-4.7 {ButtonWidgetCmd procedure, "cget" option} {
- list [catch {.l cget -disabledforeground} msg] $msg
-} {1 {unknown option "-disabledforeground"}}
+ catch {.l cget -disabledforeground}
+} {0}
test button-4.8 {ButtonWidgetCmd procedure, "cget" option} {
catch {.b cget -disabledforeground}
} {0}