From a5179966d79dc5e42d4da2132e363da240f49319 Mon Sep 17 00:00:00 2001 From: ericm Date: Fri, 28 Jul 2000 16:34:54 +0000 Subject: * mac/tkMacDefault.h: * unix/tkUnixDefault.h: Added default values for listbox disabledforeground and state. * win/tkWinDefault.h: Changed default listbox background color to white and listbox selection borderwidth to 0, in keeping with the "Microsoft Windows User Experience"; added default values for listbox disabledforeground and listbox state. * doc/listbox.n: Added documentation for -state option. * generic/tkListbox.c: Added support for -state to listbox. [RFE: 6052]. * tests/listbox.test: Tests for listbox disabled state. --- ChangeLog | 31 +++++- doc/listbox.n | 20 ++-- generic/tkListbox.c | 276 ++++++++++++++++++++++++++++++++++----------------- mac/tkMacDefault.h | 4 +- tests/listbox.test | 53 +++++++++- unix/tkUnixDefault.h | 4 +- win/tkWinDefault.h | 8 +- 7 files changed, 284 insertions(+), 112 deletions(-) diff --git a/ChangeLog b/ChangeLog index 20c094a..483d046 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,21 @@ +2000-07-28 Eric Melski + + * mac/tkMacDefault.h: + * unix/tkUnixDefault.h: Added default values for listbox + disabledforeground and state. + + * win/tkWinDefault.h: Changed default listbox background color to + white and listbox selection borderwidth to 0, in keeping with the + "Microsoft Windows User Experience"; added default values for + listbox disabledforeground and listbox state. + + * doc/listbox.n: Added documentation for -state option. + + * generic/tkListbox.c: Added support for -state to listbox. [RFE: + 6052]. + + * tests/listbox.test: Tests for listbox disabled state. + 2000-07-27 Mo DeJong * win/configure.in: TCL_STUB_LIB_FLAG and @@ -120,14 +138,17 @@ Remove unused declarations. * win/tkWinColor.c (GetColorByName, GetColorByValue): Remove unused function declarations. - * win/tkWinDialog.c (TrySetDirectory): Remove unused function declaration. + * win/tkWinDialog.c (TrySetDirectory): Remove unused function + declaration. * win/tkWinEmbed.c (TkWinEmbeddedEventProc): Cast to match function prototype. - * win/tkWinMenu.c (winMenuMutex, MenuExitProc): Remove unused declaration. + * win/tkWinMenu.c (winMenuMutex, MenuExitProc): Remove unused + declaration. * win/tkWinWindow.c (StackWindow): Remove unused declaration. * win/tkWinWm.c (ConfigureEvent): Remove unused declaration. * win/tkWinX.c (winXMutex): Remove unused declaration. - * xlib/ximage.c (XCreateBitmapFromData): Cast to match function prototype. + * xlib/ximage.c (XCreateBitmapFromData): Cast to match function + prototype. 2000-07-05 Eric Melski @@ -136,8 +157,8 @@ * generic/tkImgGIF.c: Applied patch from Jan Nijtmans to fix a problem with the GIF writing code [Bug: 5823]. - * generic/tkCursor.c: Added initialization for nextPtr field of TkCursor, - patch from Nijtmans/Howlett. + * generic/tkCursor.c: Added initialization for nextPtr field of + TkCursor, patch from Nijtmans/Howlett. 2000-07-05 Eric Melski diff --git a/doc/listbox.n b/doc/listbox.n index 22f4c09..0db537f 100644 --- a/doc/listbox.n +++ b/doc/listbox.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: listbox.n,v 1.6 2000/05/23 00:31:36 hobbs Exp $ +'\" RCS: @(#) $Id: listbox.n,v 1.7 2000/07/28 16:34:54 ericm Exp $ '\" .so man.macros .TH listbox n 8.0 Tk "Tk Built-In Commands" @@ -16,11 +16,14 @@ listbox \- Create and manipulate listbox widgets .SH SYNOPSIS \fBlistbox\fR \fIpathName \fR?\fIoptions\fR? .SO -\-background \-foreground \-relief \-takefocus -\-borderwidth \-height \-listvar \-selectbackground \-width -\-cursor \-highlightbackground \-selectborderwidth \-xscrollcommand -\-exportselection \-highlightcolor \-selectforeground \-yscrollcommand -\-font \-highlightthickness \-setgrid +\-background \-borderwidth \-cursor +\-disabledforeground \-exportselection \-font +\-foreground \-height \-highlightbackground +\-highlightcolor \-highlightthickness \-listvar +\-relief \-selectbackground \-selectborderwidth +\-selectforeground \-setgrid \-state +\-takefocus \-width \-xscrollcommand +\-yscrollcommand .SE .SH "WIDGET-SPECIFIC OPTIONS" .OP \-height height Height @@ -39,6 +42,11 @@ Specifies one of several styles for manipulating the selection. The value of the option may be arbitrary, but the default bindings expect it to be either \fBsingle\fR, \fBbrowse\fR, \fBmultiple\fR, or \fBextended\fR; the default value is \fBbrowse\fR. +.OP \-state state State +Specifies one of two states for the listbox: \fBnormal\fR or \fBdisabled\fR. +If the listbox is disabled then items may not be inserted or deleted, +items are drawn in the \fB-disabledforeground\fR color, and selection +cannot be modified and is not shown (though selection information is retained). .OP \-width width Width Specifies the desired width for the window in characters. If the font doesn't have a uniform width then the width of the diff --git a/generic/tkListbox.c b/generic/tkListbox.c index 4e9081a..e37ccb8 100644 --- a/generic/tkListbox.c +++ b/generic/tkListbox.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: tkListbox.c,v 1.16 2000/03/02 21:52:41 hobbs Exp $ + * RCS: @(#) $Id: tkListbox.c,v 1.17 2000/07/28 16:34:54 ericm Exp $ */ #include "tkPort.h" @@ -74,6 +74,7 @@ typedef struct { * room for borders. */ Tk_Font tkfont; /* Information about text font, or NULL. */ XColor *fgColorPtr; /* Text color in normal mode. */ + XColor *dfgColorPtr; /* Text color in disabled mode. */ GC textGC; /* For drawing normal text. */ Tk_3DBorder selBorder; /* Borders and backgrounds for selected * elements. */ @@ -155,6 +156,8 @@ typedef struct { char *xScrollCmd; /* Command prefix for communicating with * horizontal scrollbar. NULL means no command * to issue. Malloc'ed. */ + int state; /* Listbox state. */ + Pixmap gray; /* Pixmap for displaying disabled text. */ int flags; /* Various flag bits: see below for * definitions. */ } Listbox; @@ -194,6 +197,20 @@ typedef struct { #define LISTBOX_DELETED 32 /* + * The following enum is used to define a type for the -state option + * of the Entry widget. These values are used as indices into the + * string table below. + */ + +enum state { + STATE_DISABLED, STATE_NORMAL +}; + +static char *stateStrings[] = { + "disabled", "normal", (char *) NULL +}; + +/* * The optionSpecs table defines the valid configuration options for the * listbox widget */ @@ -211,6 +228,10 @@ static Tk_OptionSpec optionSpecs[] = { {TK_OPTION_CURSOR, "-cursor", "cursor", "Cursor", DEF_LISTBOX_CURSOR, -1, Tk_Offset(Listbox, cursor), TK_OPTION_NULL_OK, 0, 0}, + {TK_OPTION_COLOR, "-disabledforeground", "disabledForeground", + "Foreground", + DEF_LISTBOX_DISABLED_FG, -1, Tk_Offset(Listbox, dfgColorPtr), + TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_BOOLEAN, "-exportselection", "exportSelection", "ExportSelection", DEF_LISTBOX_EXPORT_SELECTION, -1, Tk_Offset(Listbox, exportSelection), 0, 0, 0}, @@ -247,6 +268,9 @@ static Tk_OptionSpec optionSpecs[] = { TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_BOOLEAN, "-setgrid", "setGrid", "SetGrid", DEF_LISTBOX_SET_GRID, -1, Tk_Offset(Listbox, setGrid), 0, 0, 0}, + {TK_OPTION_STRING_TABLE, "-state", "state", "State", + DEF_LISTBOX_STATE, -1, Tk_Offset(Listbox, state), + 0, (ClientData) stateStrings, 0}, {TK_OPTION_STRING, "-takefocus", "takeFocus", "TakeFocus", DEF_LISTBOX_TAKE_FOCUS, -1, Tk_Offset(Listbox, takeFocus), TK_OPTION_NULL_OK, 0, 0}, @@ -519,6 +543,7 @@ Tk_ListboxObjCmd(clientData, interp, objc, objv) listPtr->inset = 0; listPtr->tkfont = NULL; listPtr->fgColorPtr = NULL; + listPtr->dfgColorPtr = NULL; listPtr->textGC = None; listPtr->selBorder = NULL; listPtr->selBorderWidth = 0; @@ -547,6 +572,8 @@ Tk_ListboxObjCmd(clientData, interp, objc, objv) listPtr->takeFocus = NULL; listPtr->xScrollCmd = NULL; listPtr->yScrollCmd = NULL; + listPtr->state = STATE_NORMAL; + listPtr->gray = None; listPtr->flags = 0; Tk_SetClass(listPtr->tkwin, "Listbox"); @@ -629,6 +656,11 @@ ListboxWidgetObjCmd(clientData, interp, objc, objv) if (result != TCL_OK) { break; } + + if (!(listPtr->state & STATE_NORMAL)) { + break; + } + if (index >= listPtr->nElements) { index = listPtr->nElements-1; } @@ -733,6 +765,11 @@ ListboxWidgetObjCmd(clientData, interp, objc, objv) if (result != TCL_OK) { break; } + + if (!(listPtr->state & STATE_NORMAL)) { + break; + } + if (first < listPtr->nElements) { /* * if a "last index" was given, get it now; otherwise, use the @@ -838,6 +875,11 @@ ListboxWidgetObjCmd(clientData, interp, objc, objv) if (result != TCL_OK) { break; } + + if (!(listPtr->state & STATE_NORMAL)) { + break; + } + result = ListboxInsertSubCmd(listPtr, index, objc-3, objv+3); break; } @@ -1018,6 +1060,10 @@ ListboxWidgetObjCmd(clientData, interp, objc, objv) } case COMMAND_SELECTION: { + if (!(listPtr->state & STATE_NORMAL)) { + break; + } + result = ListboxSelectionSubCmd(interp, listPtr, objc, objv); break; } @@ -1458,6 +1504,10 @@ DestroyListbox(memPtr) if (listPtr->selTextGC != None) { Tk_FreeGC(listPtr->display, listPtr->selTextGC); } + if (listPtr->gray != None) { + Tk_FreeBitmap(Tk_Display(listPtr->tkwin), listPtr->gray); + } + Tk_FreeConfigOptions((char *)listPtr, listPtr->optionTable, listPtr->tkwin); listPtr->tkwin = NULL; @@ -1698,10 +1748,30 @@ ListboxWorldChanged(instanceData) listPtr = (Listbox *) instanceData; - gcValues.foreground = listPtr->fgColorPtr->pixel; + if (listPtr->state & STATE_NORMAL) { + gcValues.foreground = listPtr->fgColorPtr->pixel; + gcValues.graphics_exposures = False; + mask = GCForeground | GCFont | GCGraphicsExposures; + } else { + if (listPtr->dfgColorPtr != NULL) { + gcValues.foreground = listPtr->dfgColorPtr->pixel; + gcValues.graphics_exposures = False; + mask = GCForeground | GCFont | GCGraphicsExposures; + } else { + gcValues.foreground = listPtr->fgColorPtr->pixel; + mask = GCForeground | GCFont; + if (listPtr->gray == None) { + listPtr->gray = Tk_GetBitmap(NULL, listPtr->tkwin, "gray50"); + } + if (listPtr->gray != None) { + gcValues.fill_style = FillStippled; + gcValues.stipple = listPtr->gray; + mask |= GCFillStyle | GCStipple; + } + } + } + gcValues.font = Tk_FontId(listPtr->tkfont); - gcValues.graphics_exposures = False; - mask = GCForeground | GCFont | GCGraphicsExposures; gc = Tk_GetGC(listPtr->tkwin, mask, &gcValues); if (listPtr->textGC != None) { Tk_FreeGC(listPtr->display, listPtr->textGC); @@ -1823,102 +1893,122 @@ DisplayListbox(clientData) */ entry = Tcl_FindHashEntry(listPtr->itemAttrTable, (char *)i); - /* If the item is selected, it is drawn differently */ - if (Tcl_FindHashEntry(listPtr->selection, (char *)i) != NULL) { - gc = listPtr->selTextGC; - width = Tk_Width(tkwin) - 2*listPtr->inset; - selectedBg = listPtr->selBorder; - - /* If there is attribute information for this item, - * adjust the drawing accordingly */ - if (entry != NULL) { - attrs = (ItemAttr *)Tcl_GetHashValue(entry); - /* The default GC has the settings from the widget at large */ - gcValues.foreground = listPtr->selFgColorPtr->pixel; - gcValues.font = Tk_FontId(listPtr->tkfont); - gcValues.graphics_exposures = False; - mask = GCForeground | GCFont | GCGraphicsExposures; - - if (attrs->selBorder != NULL) { - selectedBg = attrs->selBorder; + /* + * If the listbox is enabled, items may be drawn differently; + * they may be drawn selected, or they may have special foreground + * or background colors. + */ + if (listPtr->state & STATE_NORMAL) { + if (Tcl_FindHashEntry(listPtr->selection, (char *)i) != NULL) { + /* Selected items are drawn differently. */ + gc = listPtr->selTextGC; + width = Tk_Width(tkwin) - 2*listPtr->inset; + selectedBg = listPtr->selBorder; + + /* If there is attribute information for this item, + * adjust the drawing accordingly */ + if (entry != NULL) { + attrs = (ItemAttr *)Tcl_GetHashValue(entry); + /* Default GC has the values from the widget at large */ + gcValues.foreground = listPtr->selFgColorPtr->pixel; + gcValues.font = Tk_FontId(listPtr->tkfont); + gcValues.graphics_exposures = False; + mask = GCForeground | GCFont | GCGraphicsExposures; + + if (attrs->selBorder != NULL) { + selectedBg = attrs->selBorder; + } + + if (attrs->selFgColor != NULL) { + gcValues.foreground = attrs->selFgColor->pixel; + gc = Tk_GetGC(listPtr->tkwin, mask, &gcValues); + } } + + Tk_Fill3DRectangle(tkwin, pixmap, selectedBg, x, y, + width, listPtr->lineHeight, 0, TK_RELIEF_FLAT); - if (attrs->selFgColor != NULL) { - gcValues.foreground = attrs->selFgColor->pixel; - gc = Tk_GetGC(listPtr->tkwin, mask, &gcValues); + /* + * Draw beveled edges around the selection, if there are + * visible edges next to this element. Special considerations: + * 1. The left and right bevels may not be visible if + * horizontal scrolling is enabled (the "left" and "right" + * variables are zero to indicate that the corresponding + * bevel is visible). + * 2. Top and bottom bevels are only drawn if this is the + * first or last seleted item. + * 3. If the left or right bevel isn't visible, then the "left" + * and "right" variables, computed above, have non-zero + * values that extend the top and bottom bevels so that + * the mitered corners are off-screen. + */ + + /* Draw left bevel */ + if (left == 0) { + Tk_3DVerticalBevel(tkwin, pixmap, selectedBg, + x, y, listPtr->selBorderWidth, listPtr->lineHeight, + 1, TK_RELIEF_RAISED); } - } - - Tk_Fill3DRectangle(tkwin, pixmap, selectedBg, x, y, - width, listPtr->lineHeight, 0, TK_RELIEF_FLAT); - - /* - * Draw beveled edges around the selection, if there are visible - * edges next to this element. Special considerations: - * 1. The left and right bevels may not be visible if horizontal - * scrolling is enabled (the "left" and "right" variables - * are zero to indicate that the corresponding bevel is - * visible). - * 2. Top and bottom bevels are only drawn if this is the - * first or last seleted item. - * 3. If the left or right bevel isn't visible, then the "left" - * and "right" variables, computed above, have non-zero values - * that extend the top and bottom bevels so that the mitered - * corners are off-screen. - */ - - /* Draw left bevel */ - if (left == 0) { - Tk_3DVerticalBevel(tkwin, pixmap, selectedBg, - x, y, listPtr->selBorderWidth, listPtr->lineHeight, - 1, TK_RELIEF_RAISED); - } - /* Draw right bevel */ - if (right == 0) { - Tk_3DVerticalBevel(tkwin, pixmap, selectedBg, - x + width - listPtr->selBorderWidth, y, - listPtr->selBorderWidth, listPtr->lineHeight, - 0, TK_RELIEF_RAISED); - } - /* Draw top bevel */ - if (!prevSelected) { - Tk_3DHorizontalBevel(tkwin, pixmap, selectedBg, - x-left, y, width+left+right, listPtr->selBorderWidth, - 1, 1, 1, TK_RELIEF_RAISED); - } - /* Draw bottom bevel */ - if (i + 1 == listPtr->nElements || - Tcl_FindHashEntry(listPtr->selection, - (char *)(i + 1)) == NULL ) { - Tk_3DHorizontalBevel(tkwin, pixmap, selectedBg, x-left, - y + listPtr->lineHeight - listPtr->selBorderWidth, - width+left+right, listPtr->selBorderWidth, 0, 0, 0, - TK_RELIEF_RAISED); - } - prevSelected = 1; - } else { - /* If there is an item attributes record for this item, - * draw the background box and set the foreground color - * accordingly */ - if (entry != NULL) { - attrs = (ItemAttr *)Tcl_GetHashValue(entry); - gcValues.foreground = listPtr->fgColorPtr->pixel; - gcValues.font = Tk_FontId(listPtr->tkfont); - gcValues.graphics_exposures = False; - mask = GCForeground | GCFont | GCGraphicsExposures; - if (attrs->border != NULL) { - width = Tk_Width(tkwin) - 2*listPtr->inset; - Tk_Fill3DRectangle(tkwin, pixmap, attrs->border, x, y, - width, listPtr->lineHeight, 0, TK_RELIEF_FLAT); + /* Draw right bevel */ + if (right == 0) { + Tk_3DVerticalBevel(tkwin, pixmap, selectedBg, + x + width - listPtr->selBorderWidth, y, + listPtr->selBorderWidth, listPtr->lineHeight, + 0, TK_RELIEF_RAISED); + } + /* Draw top bevel */ + if (!prevSelected) { + Tk_3DHorizontalBevel(tkwin, pixmap, selectedBg, + x-left, y, width+left+right, + listPtr->selBorderWidth, + 1, 1, 1, TK_RELIEF_RAISED); } - if (attrs->fgColor != NULL) { - gcValues.foreground = attrs->fgColor->pixel; - gc = Tk_GetGC(listPtr->tkwin, mask, &gcValues); + /* Draw bottom bevel */ + if (i + 1 == listPtr->nElements || + Tcl_FindHashEntry(listPtr->selection, + (char *)(i + 1)) == NULL ) { + Tk_3DHorizontalBevel(tkwin, pixmap, selectedBg, x-left, + y + listPtr->lineHeight - listPtr->selBorderWidth, + width+left+right, listPtr->selBorderWidth, 0, 0, 0, + TK_RELIEF_RAISED); } + prevSelected = 1; + } else { + /* + * If there is an item attributes record for this item, draw + * the background box and set the foreground color accordingly + */ + if (entry != NULL) { + attrs = (ItemAttr *)Tcl_GetHashValue(entry); + gcValues.foreground = listPtr->fgColorPtr->pixel; + gcValues.font = Tk_FontId(listPtr->tkfont); + gcValues.graphics_exposures = False; + mask = GCForeground | GCFont | GCGraphicsExposures; + + /* + * If the item has its own background color, draw it now. + */ + + if (attrs->border != NULL) { + width = Tk_Width(tkwin) - 2*listPtr->inset; + Tk_Fill3DRectangle(tkwin, pixmap, attrs->border, x, y, + width, listPtr->lineHeight, 0, TK_RELIEF_FLAT); + } + + /* + * If the item has its own foreground, use it to override + * the value in the gcValues structure. + */ + + if ((listPtr->state & STATE_NORMAL) + && attrs->fgColor != NULL) { + gcValues.foreground = attrs->fgColor->pixel; + gc = Tk_GetGC(listPtr->tkwin, mask, &gcValues); + } + } + prevSelected = 0; } - prevSelected = 0; } - /* Draw the actual text of this item */ Tk_GetFontMetrics(listPtr->tkfont, &fm); y += fm.ascent + listPtr->selBorderWidth; diff --git a/mac/tkMacDefault.h b/mac/tkMacDefault.h index e1ca127..5358a0f 100644 --- a/mac/tkMacDefault.h +++ b/mac/tkMacDefault.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: tkMacDefault.h,v 1.8 2000/05/17 22:23:26 ericm Exp $ + * RCS: @(#) $Id: tkMacDefault.h,v 1.9 2000/07/28 16:34:55 ericm Exp $ */ #ifndef _TKMACDEFAULT @@ -204,6 +204,7 @@ #define DEF_LISTBOX_BG_MONO WHITE #define DEF_LISTBOX_BORDER_WIDTH "1" #define DEF_LISTBOX_CURSOR "" +#define DEF_LISTBOX_DISABLED_FG DISABLED #define DEF_LISTBOX_EXPORT_SELECTION "1" #define DEF_LISTBOX_FONT "application" #define DEF_LISTBOX_FG BLACK @@ -221,6 +222,7 @@ #define DEF_LISTBOX_SELECT_FG_MONO WHITE #define DEF_LISTBOX_SELECT_MODE "browse" #define DEF_LISTBOX_SET_GRID "0" +#define DEF_LISTBOX_STATE "normal" #define DEF_LISTBOX_TAKE_FOCUS (char *) NULL #define DEF_LISTBOX_WIDTH "20" diff --git a/tests/listbox.test b/tests/listbox.test index f1546d7..45443f6 100644 --- a/tests/listbox.test +++ b/tests/listbox.test @@ -6,7 +6,7 @@ # Copyright (c) 1998-1999 by Scriptics Corporation. # All rights reserved. # -# RCS: @(#) $Id: listbox.test,v 1.12 2000/02/01 11:41:22 hobbs Exp $ +# RCS: @(#) $Id: listbox.test,v 1.13 2000/07/28 16:34:55 ericm Exp $ if {[lsearch [namespace children] ::tcltest] == -1} { source [file join [pwd] [file dirname [info script]] defs.tcl] @@ -79,6 +79,7 @@ foreach test { {-bg #ff0000 #ff0000 non-existent {unknown color name "non-existent"}} {-borderwidth 1.3 1 badValue {bad screen distance "badValue"}} {-cursor arrow arrow badValue {bad cursor spec "badValue"}} + {-disabledforeground #110022 #110022 bogus {unknown color name "bogus"}} {-exportselection yes 1 xyzzy {expected boolean value but got "xyzzy"}} {-fg #110022 #110022 bogus {unknown color name "bogus"}} {-font {Helvetica 12} {Helvetica 12} {} {font "" doesn't exist}} @@ -94,6 +95,7 @@ foreach test { {-selectforeground #654321 #654321 bogus {unknown color name "bogus"}} {-selectmode string string {} {}} {-setgrid false 0 lousy {expected boolean value but got "lousy"}} + {-state disabled disabled foo {bad state "foo": must be disabled or normal}} {-takefocus "any string" "any string" {} {}} {-width 45 45 3p {expected integer but got "3p"}} {-xscrollcommand {Some command} {Some command} {} {}} @@ -239,7 +241,7 @@ test listbox-3.22 {ListboxWidgetCmd procedure, "cget" option} { } {0} test listbox-3.23 {ListboxWidgetCmd procedure, "configure" option} { llength [.l configure] -} {24} +} {26} test listbox-3.24 {ListboxWidgetCmd procedure, "configure" option} { list [catch {.l configure -gorp} msg] $msg } {1 {unknown option "-gorp"}} @@ -2051,7 +2053,52 @@ test listbox-25.2 {listbox item configurations and widget based inserts} { list [.l itemcget 0 -fg] [.l itemcget 4 -fg] } [list {} red] - +# state issues +test listbox-26.1 {listbox disabled state disallows inserts} { + catch {destroy .l} + listbox .l + .l insert end a b c + .l configure -state disabled + .l insert end d e f + .l get 0 end +} [list a b c] +test listbox-26.2 {listbox disabled state disallows deletions} { + catch {destroy .l} + listbox .l + .l insert end a b c + .l configure -state disabled + .l delete 0 end + .l get 0 end +} [list a b c] +test listbox-26.3 {listbox disabled state disallows selection modification} { + catch {destroy .l} + listbox .l + .l insert end a b c + .l selection set 0 + .l selection set 2 + .l configure -state disabled + .l selection clear 0 end + .l selection set 1 + .l curselection +} [list 0 2] +test listbox-26.4 {listbox disabled state disallows anchor modification} { + catch {destroy .l} + listbox .l + .l insert end a b c + .l selection anchor 0 + .l configure -state disabled + .l selection anchor 2 + .l index anchor +} 0 +test listbox-26.5 {listbox disabled state disallows active modification} { + catch {destroy .l} + listbox .l + .l insert end a b c + .l activate 0 + .l configure -state disabled + .l activate 2 + .l index active +} 0 resetGridInfo catch {destroy .l2} diff --git a/unix/tkUnixDefault.h b/unix/tkUnixDefault.h index eb81ff8..4cc48a4 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.8 2000/05/17 22:23:26 ericm Exp $ + * RCS: @(#) $Id: tkUnixDefault.h,v 1.9 2000/07/28 16:34:55 ericm Exp $ */ #ifndef _TKUNIXDEFAULT @@ -199,6 +199,7 @@ #define DEF_LISTBOX_BG_MONO WHITE #define DEF_LISTBOX_BORDER_WIDTH "2" #define DEF_LISTBOX_CURSOR "" +#define DEF_LISTBOX_DISABLED_FG DISABLED #define DEF_LISTBOX_EXPORT_SELECTION "1" #define DEF_LISTBOX_FONT "Helvetica -12 bold" #define DEF_LISTBOX_FG BLACK @@ -216,6 +217,7 @@ #define DEF_LISTBOX_SELECT_FG_MONO WHITE #define DEF_LISTBOX_SELECT_MODE "browse" #define DEF_LISTBOX_SET_GRID "0" +#define DEF_LISTBOX_STATE "normal" #define DEF_LISTBOX_TAKE_FOCUS (char *) NULL #define DEF_LISTBOX_WIDTH "20" diff --git a/win/tkWinDefault.h b/win/tkWinDefault.h index c7cf285..2e6d903 100644 --- a/win/tkWinDefault.h +++ b/win/tkWinDefault.h @@ -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: tkWinDefault.h,v 1.8 2000/05/17 22:23:26 ericm Exp $ + * RCS: @(#) $Id: tkWinDefault.h,v 1.9 2000/07/28 16:34:56 ericm Exp $ */ #ifndef _TKWINDEFAULT @@ -200,10 +200,11 @@ * Defaults for listboxes: */ -#define DEF_LISTBOX_BG_COLOR NORMAL_BG +#define DEF_LISTBOX_BG_COLOR "SystemWindow" #define DEF_LISTBOX_BG_MONO WHITE #define DEF_LISTBOX_BORDER_WIDTH "2" #define DEF_LISTBOX_CURSOR "" +#define DEF_LISTBOX_DISABLED_FG DISABLED #define DEF_LISTBOX_EXPORT_SELECTION "1" #define DEF_LISTBOX_FONT CTL_FONT #define DEF_LISTBOX_FG NORMAL_FG @@ -216,11 +217,12 @@ #define DEF_LISTBOX_LIST_VARIABLE "" #define DEF_LISTBOX_SELECT_COLOR SELECT_BG #define DEF_LISTBOX_SELECT_MONO BLACK -#define DEF_LISTBOX_SELECT_BD "1" +#define DEF_LISTBOX_SELECT_BD "0" #define DEF_LISTBOX_SELECT_FG_COLOR SELECT_FG #define DEF_LISTBOX_SELECT_FG_MONO WHITE #define DEF_LISTBOX_SELECT_MODE "browse" #define DEF_LISTBOX_SET_GRID "0" +#define DEF_LISTBOX_STATE "normal" #define DEF_LISTBOX_TAKE_FOCUS (char *) NULL #define DEF_LISTBOX_WIDTH "20" -- cgit v0.12