summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorericm <ericm>2000-05-10 00:09:38 (GMT)
committerericm <ericm>2000-05-10 00:09:38 (GMT)
commit7ff73db610e3d2efd82c272471c0dfe16d5745b8 (patch)
tree36475aa7b20157ca2cd0fba5339eb61b1484aead
parent5766ce10779959eb0437e49fc4bdb3045982a63d (diff)
downloadtk-7ff73db610e3d2efd82c272471c0dfe16d5745b8.zip
tk-7ff73db610e3d2efd82c272471c0dfe16d5745b8.tar.gz
tk-7ff73db610e3d2efd82c272471c0dfe16d5745b8.tar.bz2
* doc/button.n: Added documentation for link relief.
* tests/button.test: Added tests for link relief for buttons. * generic/tk.h (TK_CONFIG_LINK_OK): Added definition of TK_RELIEF_LINK, TK_OPTION_LINK_OK and TK_CONFIG_LINK_OK. [RFE: 4348] * generic/tk3d.c: Added support for link relief. [RFE: 4348] * mac/tkMacButton.c (TkpDisplayButton): * unix/tkUnixButton.c (TkpDisplayButton): Added support for link relief. [RFE: 4348] * generic/tkOldConfig.c (Tk_ConfigureWidget): * generic/tkConfig.c (DoObjConfig): Added understanding of link relief, which is allowed only for widgets that have TK_OPTION_LINK_OK or TK_CONFIG_LINK_OK set for the "-relief" option. [RFE: 4348] * generic/tkButton.c: Added TK_OPTION_LINK_OK to "-relief" option for buttons. [RFE: 4348] * win/tkWinWm.c (EX_TRANSIENT_STYLE): Removed WS_EX_TOOLWINDOW style bit, so that transient windows have full-size titlebars (like the tk_getOpenFile dialog). * win/tkWinMenu.c (GetMenuSeparatorGeometry): Tweaked height requested for separator bars to be (linespace - (2*descent)) instead of just (linespace); this makes the separator occupy a more correct amount of vertical space. [Bug: 5303].
-rw-r--r--ChangeLog33
-rw-r--r--doc/button.n10
-rw-r--r--generic/tk.h8
-rw-r--r--generic/tk3d.c13
-rw-r--r--generic/tkButton.c5
-rw-r--r--generic/tkConfig.c30
-rw-r--r--generic/tkOldConfig.c17
-rw-r--r--mac/tkMacButton.c15
-rw-r--r--tests/button.test19
-rw-r--r--unix/tkUnixButton.c16
-rw-r--r--win/tkWinMenu.c4
-rw-r--r--win/tkWinWm.c5
12 files changed, 153 insertions, 22 deletions
diff --git a/ChangeLog b/ChangeLog
index 1eded23..38e7af5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,36 @@
+2000-05-09 Eric Melski <ericm@scriptics.com>
+
+ * doc/button.n: Added documentation for link relief.
+
+ * tests/button.test: Added tests for link relief for buttons.
+
+ * generic/tk.h (TK_CONFIG_LINK_OK): Added definition of
+ TK_RELIEF_LINK, TK_OPTION_LINK_OK and TK_CONFIG_LINK_OK. [RFE: 4348]
+
+ * generic/tk3d.c: Added support for link relief. [RFE: 4348]
+
+ * mac/tkMacButton.c (TkpDisplayButton):
+ * unix/tkUnixButton.c (TkpDisplayButton): Added support for link
+ relief. [RFE: 4348]
+
+ * generic/tkOldConfig.c (Tk_ConfigureWidget):
+ * generic/tkConfig.c (DoObjConfig): Added understanding of link
+ relief, which is allowed only for widgets that have
+ TK_OPTION_LINK_OK or TK_CONFIG_LINK_OK set for the "-relief"
+ option. [RFE: 4348]
+
+ * generic/tkButton.c: Added TK_OPTION_LINK_OK to "-relief" option
+ for buttons. [RFE: 4348]
+
+ * win/tkWinWm.c (EX_TRANSIENT_STYLE): Removed WS_EX_TOOLWINDOW
+ style bit, so that transient windows have full-size titlebars
+ (like the tk_getOpenFile dialog).
+
+ * win/tkWinMenu.c (GetMenuSeparatorGeometry): Tweaked height
+ requested for separator bars to be (linespace - (2*descent))
+ instead of just (linespace); this makes the separator occupy a
+ more correct amount of vertical space. [Bug: 5303].
+
2000-05-09 Jeff Hobbs <hobbs@scriptics.com>
* library/focus.tcl: fixed calling of takeFocus proc [Bug: 5372]
diff --git a/doc/button.n b/doc/button.n
index aecb556..28b29ff 100644
--- a/doc/button.n
+++ b/doc/button.n
@@ -5,7 +5,7 @@
'\" See the file "license.terms" for information on usage and redistribution
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
'\"
-'\" RCS: @(#) $Id: button.n,v 1.2 1998/09/14 18:22:55 stanton Exp $
+'\" RCS: @(#) $Id: button.n,v 1.3 2000/05/10 00:09:38 ericm Exp $
'\"
.so man.macros
.TH button n 4.4 Tk "Tk Built-In Commands"
@@ -49,6 +49,14 @@ screen units (i.e. any of the forms acceptable to \fBTk_GetPixels\fR);
for text it is in lines of text.
If this option isn't specified, the button's desired height is computed
from the size of the image or bitmap or text being displayed in it.
+.VS 8.4
+.OP \-relief relief Relief
+Specifies a relief for the button. In addition to the standard relief
+styles available to most widgets, buttons support the \fBlink\fR
+relief style. When using this relief style, buttons will have a
+raised relief when they are active (when the mouse cursor is over the
+button), and a flat relief otherwise.
+.VE 8.4
.OP \-state state State
Specifies one of three states for the button: \fBnormal\fR, \fBactive\fR,
or \fBdisabled\fR. In normal state the button is displayed using the
diff --git a/generic/tk.h b/generic/tk.h
index a08c3fd..cd31a16 100644
--- a/generic/tk.h
+++ b/generic/tk.h
@@ -12,7 +12,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tk.h,v 1.40 2000/05/03 00:18:35 hobbs Exp $
+ * RCS: @(#) $Id: tk.h,v 1.41 2000/05/10 00:09:38 ericm Exp $
*/
#ifndef _TK
@@ -204,6 +204,9 @@ typedef struct Tk_OptionSpec {
#define TK_OPTION_NULL_OK 1
#define TK_OPTION_DONT_SET_DEFAULT 8
+/* This widget allows the link relief */
+#define TK_OPTION_LINK_OK (1 << 9)
+
/*
* Macro to use to fill in "offset" fields of the Tk_OptionSpec.
* struct. Computes number of bytes from beginning of structure
@@ -366,6 +369,8 @@ typedef enum {
#define TK_CONFIG_DONT_SET_DEFAULT 8
#define TK_CONFIG_OPTION_SPECIFIED 0x10
#define TK_CONFIG_USER_BIT 0x100
+/* This widget allows the link relief */
+#define TK_CONFIG_LINK_OK (1 << 9)
#endif /* __NO_OLD_CONFIG */
/*
@@ -440,6 +445,7 @@ typedef enum {
#define TK_RELIEF_RIDGE 3
#define TK_RELIEF_SOLID 4
#define TK_RELIEF_SUNKEN 5
+#define TK_RELIEF_LINK 6
/*
* "Which" argument values for Tk_3DBorderGC:
diff --git a/generic/tk3d.c b/generic/tk3d.c
index 8cbe0ee..805c6bc 100644
--- a/generic/tk3d.c
+++ b/generic/tk3d.c
@@ -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: tk3d.c,v 1.6 1999/12/21 23:55:10 hobbs Exp $
+ * RCS: @(#) $Id: tk3d.c,v 1.7 2000/05/10 00:09:38 ericm Exp $
*/
#include "tk3d.h"
@@ -20,8 +20,9 @@
* used by Tk_GetReliefFromObj.
*/
-static char *reliefStrings[] = {"flat", "groove", "raised", "ridge", "solid",
- "sunken", (char *) NULL};
+static char *reliefStrings[] = {"flat", "groove", "raised",
+ "ridge", "solid", "sunken",
+ (char *) NULL};
/*
* Forward declarations for procedures defined in this file:
@@ -663,6 +664,8 @@ Tk_GetRelief(interp, name, reliefPtr)
} else if ((c == 'g') && (strncmp(name, "groove", length) == 0)
&& (length >= 2)) {
*reliefPtr = TK_RELIEF_GROOVE;
+ } else if ((c == 'l') && (strncmp(name, "link", length) == 0)) {
+ *reliefPtr = TK_RELIEF_LINK;
} else if ((c == 'r') && (strncmp(name, "raised", length) == 0)
&& (length >= 2)) {
*reliefPtr = TK_RELIEF_RAISED;
@@ -676,7 +679,7 @@ Tk_GetRelief(interp, name, reliefPtr)
char buf[200];
sprintf(buf, "bad relief type \"%.50s\": must be %s",
- name, "flat, groove, raised, ridge, solid, or sunken");
+ name, "flat, groove, link, raised, ridge, solid, or sunken");
Tcl_SetResult(interp, buf, TCL_VOLATILE);
return TCL_ERROR;
}
@@ -718,6 +721,8 @@ Tk_NameOfRelief(relief)
return "ridge";
} else if (relief == TK_RELIEF_SOLID) {
return "solid";
+ } else if (relief == TK_RELIEF_LINK) {
+ return "link";
} else {
return "unknown relief";
}
diff --git a/generic/tkButton.c b/generic/tkButton.c
index 1d832c8..51d928d 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.4 2000/03/08 03:19:31 ericm Exp $
+ * RCS: @(#) $Id: tkButton.c,v 1.5 2000/05/10 00:09:39 ericm Exp $
*/
#include "tkButton.h"
@@ -190,7 +190,8 @@ static Tk_OptionSpec buttonOptionSpecs[] = {
DEF_BUTTON_PADY, Tk_Offset(TkButton, padYPtr),
Tk_Offset(TkButton, padY), 0, 0, 0},
{TK_OPTION_RELIEF, "-relief", "relief", "Relief",
- DEF_BUTTON_RELIEF, -1, Tk_Offset(TkButton, relief), 0, 0, 0},
+ DEF_BUTTON_RELIEF, -1, Tk_Offset(TkButton, relief),
+ TK_OPTION_LINK_OK, 0, 0},
{TK_OPTION_STRING_TABLE, "-state", "state", "State",
DEF_BUTTON_STATE, -1, Tk_Offset(TkButton, state),
0, (ClientData) stateStrings, 0},
diff --git a/generic/tkConfig.c b/generic/tkConfig.c
index 471af9d..5739a7e 100644
--- a/generic/tkConfig.c
+++ b/generic/tkConfig.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: tkConfig.c,v 1.7 2000/04/25 01:02:30 hobbs Exp $
+ * RCS: @(#) $Id: tkConfig.c,v 1.8 2000/05/10 00:09:39 ericm Exp $
*/
/*
@@ -804,10 +804,34 @@ DoObjConfig(interp, recordPtr, optionPtr, valuePtr, tkwin, savedOptionPtr)
}
case TK_OPTION_RELIEF: {
int new;
-
+ char *valueStr;
+
if (Tk_GetReliefFromObj(interp, valuePtr, &new) != TCL_OK) {
- return TCL_ERROR;
+ /*
+ * In order that error messages be handled properly, we let
+ * GetReliefFromObj do the first pass check on the relief
+ * string. If it fails there, and the option spec doesn't
+ * allow for LINK relief, return an error. If the option spec
+ * does allow LINK relief, see if the string matches "link".
+ */
+ if ((specPtr->flags & TK_OPTION_LINK_OK) == 0) {
+ return TCL_ERROR;
+ } else {
+ valueStr = Tcl_GetString(valuePtr);
+ if (valueStr[0] == 'l' && strcmp(valueStr, "link") == 0) {
+ new = TK_RELIEF_LINK;
+ Tcl_ResetResult(interp);
+ } else {
+ Tcl_ResetResult(interp);
+ Tcl_AppendResult(interp, "bad relief \"",
+ valueStr, "\": must be flat, groove, link, "
+ "raised, ridge, solid, or sunken",
+ (char *)NULL);
+ return TCL_ERROR;
+ }
+ }
}
+
if (internalPtr != NULL) {
*((int *) oldInternalPtr) = *((int *) internalPtr);
*((int *) internalPtr) = new;
diff --git a/generic/tkOldConfig.c b/generic/tkOldConfig.c
index 9ee2a14..135e83c 100644
--- a/generic/tkOldConfig.c
+++ b/generic/tkOldConfig.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: tkOldConfig.c,v 1.6 2000/03/07 00:09:08 ericm Exp $
+ * RCS: @(#) $Id: tkOldConfig.c,v 1.7 2000/05/10 00:09:39 ericm Exp $
*/
#include "tkPort.h"
@@ -486,6 +486,21 @@ DoConfig(interp, tkwin, specPtr, value, valueIsUid, widgRec)
if (Tk_GetRelief(interp, uid, (int *) ptr) != TCL_OK) {
return TCL_ERROR;
}
+
+ /*
+ * Not all widgets allow the link relief. If the given
+ * relief is "link" and this widget does not support it,
+ * display the "invalid relief" error message and return
+ * TCL_ERROR.
+ */
+
+ if ((*ptr == TK_RELIEF_LINK) && \
+ ((specPtr->specFlags & TK_CONFIG_LINK_OK) == 0)) {
+ Tcl_SetResult(interp, "invalid relief \"link\": must be "
+ "flat, groove, raised, ridge, solid, or sunken",
+ TCL_STATIC);
+ return TCL_ERROR;
+ }
break;
case TK_CONFIG_CURSOR:
case TK_CONFIG_ACTIVE_CURSOR: {
diff --git a/mac/tkMacButton.c b/mac/tkMacButton.c
index ce298ed..dc4ecc1 100644
--- a/mac/tkMacButton.c
+++ b/mac/tkMacButton.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: tkMacButton.c,v 1.10 2000/04/17 02:16:36 jingham Exp $
+ * RCS: @(#) $Id: tkMacButton.c,v 1.11 2000/05/10 00:09:39 ericm Exp $
*/
#include "tkButton.h"
@@ -231,6 +231,19 @@ TkpDisplayButton(
}
/*
+ * LINK relief means that the button has a raised relief when it is
+ * active, and a flat relief otherwise (like toolbar buttons). It
+ * is supported for true buttons only.
+ */
+
+ if ((butPtr->type == TYPE_BUTTON) && butPtr->relief == TK_RELIEF_LINK) {
+ if (butPtr->state == STATE_ACTIVE) {
+ relief = TK_RELIEF_RAISED;
+ } else {
+ relief = TK_RELIEF_FLAT;
+ }
+ }
+ /*
* See the comment in UpdateControlColors as to why we use the
* highlightbackground for the border of Macintosh buttons.
*/
diff --git a/tests/button.test b/tests/button.test
index 58932bb..145dddb 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.5 2000/03/08 03:19:31 ericm Exp $
+# RCS: @(#) $Id: button.test,v 1.6 2000/05/10 00:09:40 ericm Exp $
if {[lsearch [namespace children] ::tcltest] == -1} {
source [file join [pwd] [file dirname [info script]] defs.tcl]
@@ -88,7 +88,6 @@ foreach test {
{-offvalue fantastic fantastic {} {} {0 0 1 0}}
{-padx 12m 12m 420x {bad screen distance "420x"} {1 1 1 1}}
{-pady 12m 12m 420x {bad screen distance "420x"} {1 1 1 1}}
- {-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} {1 1 1 1}}
@@ -126,7 +125,21 @@ foreach test {
test button-1.$i {configuration options} {
.c configure -selectcolor {}
} {}
-incr i
+test button-1.[incr i] {configuration options} {
+ list [catch {.l configure -relief 1.5} msg] $msg
+} [list 1 {bad relief "1.5": must be flat, groove, raised, ridge, solid, or sunken}]
+test button-1.[incr i] {configuration options} {
+ list [catch {.c configure -relief 1.5} msg] $msg
+} [list 1 {bad relief "1.5": must be flat, groove, raised, ridge, solid, or sunken}]
+test button-1.[incr i] {configuration options} {
+ list [catch {.r configure -relief 1.5} msg] $msg
+} [list 1 {bad relief "1.5": must be flat, groove, raised, ridge, solid, or sunken}]
+test button-1.[incr i] {configuration options} {
+ list [catch {.b configure -relief 1.5} msg] $msg
+} [list 1 {bad relief "1.5": must be flat, groove, link, raised, ridge, solid, or sunken}]
+test button-1.[incr i] {configuration options} {
+ list [catch {.b configure -relief link} msg] $msg [.b cget -relief]
+} [list 0 {} link]
test button-3.1 {ButtonCreate - not enough cd ../unix
} {
diff --git a/unix/tkUnixButton.c b/unix/tkUnixButton.c
index 2d4cb25..5cce667 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.3 1999/04/16 01:51:45 stanton Exp $
+ * RCS: @(#) $Id: tkUnixButton.c,v 1.4 2000/05/10 00:09:40 ericm Exp $
*/
#include "tkButton.h"
@@ -122,6 +122,20 @@ TkpDisplayButton(clientData)
: TK_RELIEF_RAISED;
}
+ /*
+ * LINK relief means that the button has a raised relief when it is
+ * active, and a flat relief otherwise (like toolbar buttons). It
+ * is supported for true buttons only.
+ */
+
+ if ((butPtr->type == TYPE_BUTTON) && butPtr->relief == TK_RELIEF_LINK) {
+ if (butPtr->state == STATE_ACTIVE) {
+ relief = TK_RELIEF_RAISED;
+ } else {
+ relief = TK_RELIEF_FLAT;
+ }
+ }
+
offset = (butPtr->type == TYPE_BUTTON) && !Tk_StrictMotif(butPtr->tkwin);
/*
diff --git a/win/tkWinMenu.c b/win/tkWinMenu.c
index e379faa..61784c6 100644
--- a/win/tkWinMenu.c
+++ b/win/tkWinMenu.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: tkWinMenu.c,v 1.8 2000/04/13 20:51:55 ericm Exp $
+ * RCS: @(#) $Id: tkWinMenu.c,v 1.9 2000/05/10 00:09:40 ericm Exp $
*/
#define OEMRESOURCE
@@ -1384,7 +1384,7 @@ GetMenuSeparatorGeometry (
int *heightPtr) /* The resulting height */
{
*widthPtr = 0;
- *heightPtr = fmPtr->linespace;
+ *heightPtr = fmPtr->linespace - (2 * fmPtr->descent);
}
/*
diff --git a/win/tkWinWm.c b/win/tkWinWm.c
index 7be7598..ff29259 100644
--- a/win/tkWinWm.c
+++ b/win/tkWinWm.c
@@ -12,7 +12,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkWinWm.c,v 1.22 2000/04/15 17:38:13 hobbs Exp $
+ * RCS: @(#) $Id: tkWinWm.c,v 1.23 2000/05/10 00:09:41 ericm Exp $
*/
#include "tkWinInt.h"
@@ -224,8 +224,7 @@ typedef struct TkWmInfo {
#define WM_TRANSIENT_STYLE \
(WS_POPUP|WS_CAPTION|WS_SYSMENU|WS_CLIPSIBLINGS|CS_DBLCLKS)
-#define EX_TRANSIENT_STYLE \
- (WS_EX_TOOLWINDOW|WS_EX_DLGMODALFRAME)
+#define EX_TRANSIENT_STYLE (WS_EX_DLGMODALFRAME)
/*
* The following structure is the official type record for geometry