summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2003-08-14 10:31:13 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2003-08-14 10:31:13 (GMT)
commit5586adc5a179b62eb9f3cd1c260e8fda97f85c2f (patch)
tree6ce0aa41c914ba6f748a3e2b180235c18ba19762
parent2d6759a4618296bfc20e81d7ea42082d81e07000 (diff)
downloadtk-5586adc5a179b62eb9f3cd1c260e8fda97f85c2f.zip
tk-5586adc5a179b62eb9f3cd1c260e8fda97f85c2f.tar.gz
tk-5586adc5a179b62eb9f3cd1c260e8fda97f85c2f.tar.bz2
TIP#109 implementation - checkbuttons and radiobuttons now look better.
-rw-r--r--ChangeLog7
-rw-r--r--unix/tkUnixButton.c358
-rw-r--r--unix/tkUnixDefault.h9
-rw-r--r--unix/tkUnixMenu.c124
4 files changed, 358 insertions, 140 deletions
diff --git a/ChangeLog b/ChangeLog
index 2242501..1a8956d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2003-08-14 Donal K. Fellows <fellowsd@cs.man.ac.uk>
+
+ TIP #109 IMPLEMENTATION FROM Brian Griffin <bgriffin@model.com>
+ * unix/tkUnixButton.c (TkpDrawCheckIndicator, TkpDisplayButton):
+ * unix/tkUnixMenu.c (DrawMenuEntryIndicator, TkpDrawMenuEntry):
+ Much improved display of checkbuttons and radiobuttons on UNIX/X.
+
2003-08-13 Pat Thoyts <patthoyts@users.sourceforge.net>
* library/scale.tcl: Fix for bug #787065 for Button-2 press.
diff --git a/unix/tkUnixButton.c b/unix/tkUnixButton.c
index 35f6adf..4fb3b9e 100644
--- a/unix/tkUnixButton.c
+++ b/unix/tkUnixButton.c
@@ -9,10 +9,11 @@
* 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.13 2003/04/26 02:59:20 hobbs Exp $
+ * RCS: @(#) $Id: tkUnixButton.c,v 1.14 2003/08/14 10:31:14 dkf Exp $
*/
#include "tkButton.h"
+#include "tk3d.h"
/*
* Declaration of Unix specific button structure.
@@ -30,6 +31,261 @@ Tk_ClassProcs tkpButtonProcs = {
sizeof(Tk_ClassProcs), /* size */
TkButtonWorldChanged, /* worldChangedProc */
};
+
+/*
+ * The button image
+ * the header info here is ignored, it's the image that's
+ * important. The colors will be applied as follows:
+ * A = Background
+ * B = Background
+ * C = 3D light
+ * D = selectColor
+ * E = 3D dark
+ * F = Background
+ * G = Indicator Color
+ * H = disabled Indicator Color
+ */
+
+/* XPM */
+static char *button_images[] = {
+ /* width height ncolors chars_per_pixel */
+ "52 26 7 1",
+ /* colors */
+ "A c #808000000000",
+ "B c #000080800000",
+ "C c #808080800000",
+ "D c #000000008080",
+ "E c #808000008080",
+ "F c #000080808080",
+ "G c #000000000000",
+ "H c #000080800000",
+ /* pixels */
+ "AAAAAAAAAAAABAAAAAAAAAAAABAAAAAAAAAAAABAAAAAAAAAAAAB",
+ "AEEEEEEEEEECBAEEEEEEEEEECBAEEEEEEEEEECBAEEEEEEEEEECB",
+ "AEDDDDDDDDDCBAEDDDDDDDDDCBAEFFFFFFFFFCBAEFFFFFFFFFCB",
+ "AEDDDDDDDDDCBAEDDDDDDDGDCBAEFFFFFFFFFCBAEFFFFFFFHFCB",
+ "AEDDDDDDDDDCBAEDDDDDDGGDCBAEFFFFFFFFFCBAEFFFFFFHHFCB",
+ "AEDDDDDDDDDCBAEDGDDDGGGDCBAEFFFFFFFFFCBAEFHFFFHHHFCB",
+ "AEDDDDDDDDDCBAEDGGDGGGDDCBAEFFFFFFFFFCBAEFHHFHHHFFCB",
+ "AEDDDDDDDDDCBAEDGGGGGDDDCBAEFFFFFFFFFCBAEFHHHHHFFFCB",
+ "AEDDDDDDDDDCBAEDDGGGDDDDCBAEFFFFFFFFFCBAEFFHHHFFFFCB",
+ "AEDDDDDDDDDCBAEDDDGDDDDDCBAEFFFFFFFFFCBAEFFFHFFFFFCB",
+ "AEDDDDDDDDDCBAEDDDDDDDDDCBAEFFFFFFFFFCBAEFFFFFFFFFCB",
+ "ACCCCCCCCCCCBACCCCCCCCCCCBACCCCCCCCCCCBACCCCCCCCCCCB",
+ "BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB",
+ "FFFFAAAAFFFFFFFFFAAAAFFFFFFFFFAAAAFFFFFFFFFAAAAFFFFF",
+ "FFAAEEEEAAFFFFFAAEEEEAAFFFFFAAEEEEAAFFFFFAAEEEEAAFFF",
+ "FAEEDDDDEEBFFFAEEDDDDEEBFFFAEEFFFFEEBFFFAEEFFFFEEBFF",
+ "FAEDDDDDDCBFFFAEDDDDDDCBFFFAEFFFFFFCBFFFAEFFFFFFCBFF",
+ "AEDDDDDDDDCBFAEDDDGGDDDCBFAEFFFFFFFFCBFAEFFFHHFFFCBF",
+ "AEDDDDDDDDCBFAEDDGGGGDDCBFAEFFFFFFFFCBFAEFFHHHHFFCBF",
+ "AEDDDDDDDDCBFAEDDGGGGDDCBFAEFFFFFFFFCBFAEFFHHHHFFCBF",
+ "AEDDDDDDDDCBFAEDDDGGDDDCBFAEFFFFFFFFCBFAEFFFHHFFFCBF",
+ "FAEDDDDDDCBFFFAEDDDDDDCBFFFAEFFFFFFCBFFFAEFFFFFFCBFF",
+ "FACCDDDDCCBFFFACCDDDDCCBFFFACCFFFFCCBFFFACCFFFFCCBFF",
+ "FFBBCCCCBBFFFFFBBCCCCBBFFFFFBBCCCCBBFFFFFBBCCCCBBFFF",
+ "FFFFBBBBFFFFFFFFFBBBBFFFFFFFFFBBBBFFFFFFFFFBBBBFFFFF",
+ "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF",
+};
+
+/*
+ * Sizes and offsets into above XPM file.
+ */
+#define CHECK_BUTTON_DIM 13
+#define CHECK_MENU_DIM 9
+#define CHECK_START 9
+#define CHECK_ON_OFFSET 13
+#define CHECK_OFF_OFFSET 0
+#define CHECK_DISON_OFFSET 39
+#define CHECK_DISOFF_OFFSET 26
+#define RADIO_BUTTON_DIM 12
+#define RADIO_MENU_DIM 6
+#define RADIO_WIDTH 13
+#define RADIO_START 22
+#define RADIO_ON_OFFSET 13
+#define RADIO_OFF_OFFSET 0
+#define RADIO_DISON_OFFSET 39
+#define RADIO_DISOFF_OFFSET 26
+
+/*
+ * Indicator Draw Modes
+ */
+#define CHECK_BUTTON 0
+#define CHECK_MENU 1
+#define RADIO_BUTTON 2
+#define RADIO_MENU 3
+
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * TkpDrawCheckIndicator -
+ *
+ * Draws the checkbox image in the drawable at the (x,y)
+ * location, value, and state given. This routine is use by the
+ * button and menu widgets
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * An image is drawn in the drawable at the location given.
+ *
+ *----------------------------------------------------------------------
+ */
+
+void
+TkpDrawCheckIndicator(tkwin, display, d, x, y, bgBorder, indicatorColor,
+ selectColor, disableColor, on, disabled, mode)
+ Tk_Window tkwin; /* handle for resource alloc */
+ Display *display;
+ Drawable d; /* what to draw on */
+ int x, y; /* where to draw */
+ Tk_3DBorder bgBorder; /* colors of the border */
+ XColor *indicatorColor; /* color of the indicator */
+ XColor *selectColor; /* color when selected */
+ XColor *disableColor; /* color when disabled */
+ int on; /* are we on? */
+ int disabled; /* are we disabled? */
+ int mode; /* kind of indicator to draw */
+{
+ int ix, iy;
+ int dim;
+ int imgsel, imgstart;
+ TkBorder *bg_brdr = (TkBorder*)bgBorder;
+ XGCValues gcValues;
+ GC copyGC;
+ unsigned long imgColors[8];
+ XImage *img;
+ Pixmap pixmap;
+ int depth;
+
+ /*
+ * Sanity check.
+ */
+
+ if (tkwin == NULL || display == None || d == None || bgBorder == NULL
+ || indicatorColor == NULL || selectColor == NULL
+ || disableColor == NULL) {
+ return;
+ }
+
+ depth = Tk_Depth(tkwin);
+
+ /*
+ * Compute starting point and dimensions of image inside
+ * button_images to be used.
+ */
+
+ switch (mode) {
+ default:
+ case CHECK_BUTTON:
+ imgsel = on ? CHECK_ON_OFFSET : CHECK_OFF_OFFSET;
+ imgsel += disabled ? 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;
+ 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;
+ 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;
+ imgstart = RADIO_START + 3;
+ imgsel += 3;
+ dim = RADIO_MENU_DIM;
+ break;
+ }
+
+ /*
+ * Allocate the drawing areas to use. Note that we use
+ * double-buffering here because not all code paths leading to
+ * this function do so.
+ */
+
+ pixmap = Tk_GetPixmap(display, d, dim, dim, depth);
+ if (pixmap == None) {
+ return;
+ }
+
+ x -= dim/2;
+ y -= dim/2;
+
+ img = XGetImage(display, pixmap, 0, 0,
+ (unsigned int)dim, (unsigned int)dim, AllPlanes, ZPixmap);
+ if (img == NULL) {
+ return;
+ }
+
+ /*
+ * Set up the color mapping table.
+ */
+
+ TkpGetShadows(bg_brdr, tkwin);
+
+ imgColors[0 /*A*/] =
+ Tk_GetColorByValue(tkwin, bg_brdr->bgColorPtr)->pixel;
+ imgColors[1 /*B*/] =
+ Tk_GetColorByValue(tkwin, bg_brdr->bgColorPtr)->pixel;
+ imgColors[2 /*C*/] =
+ Tk_GetColorByValue(tkwin, bg_brdr->lightColorPtr)->pixel;
+ imgColors[3 /*D*/] =
+ Tk_GetColorByValue(tkwin, selectColor)->pixel;
+ imgColors[4 /*E*/] =
+ Tk_GetColorByValue(tkwin, bg_brdr->darkColorPtr)->pixel;
+ imgColors[5 /*F*/] =
+ Tk_GetColorByValue(tkwin, bg_brdr->bgColorPtr)->pixel;
+ imgColors[6 /*G*/] =
+ Tk_GetColorByValue(tkwin, indicatorColor)->pixel;
+ imgColors[7 /*H*/] =
+ Tk_GetColorByValue(tkwin, disableColor)->pixel;
+
+ /*
+ * Create the image, painting it into an XImage one pixel at a time.
+ */
+
+ for (iy=0 ; iy<dim ; iy++) {
+ for (ix=0 ; ix<dim ; ix++) {
+ XPutPixel(img, ix, iy,
+ imgColors[button_images[imgstart+iy][imgsel+ix] - 'A'] );
+ }
+ }
+
+ /*
+ * Copy onto our target drawable surface.
+ */
+
+ memset(&gcValues, 0, sizeof(gcValues));
+ gcValues.background = bg_brdr->bgColorPtr->pixel;
+ gcValues.graphics_exposures = False;
+ copyGC = Tk_GetGC(tkwin, 0, &gcValues);
+
+ XPutImage(display, pixmap, copyGC, img, 0, 0, 0, 0,
+ (unsigned int)dim, (unsigned int)dim);
+ XCopyArea(display, pixmap, d, copyGC, 0, 0,
+ (unsigned int)dim, (unsigned int)dim, x, y);
+
+ /*
+ * Tidy up.
+ */
+
+ Tk_FreeGC(display, copyGC);
+ XDestroyImage(img);
+ Tk_FreePixmap(display, pixmap);
+}
/*
*----------------------------------------------------------------------
@@ -161,7 +417,7 @@ TkpDisplayButton(clientData)
* In order to avoid screen flashes, this procedure redraws
* the button in a pixmap, then copies the pixmap to the
* screen in a single operation. This means that there's no
- * point in time where the on-sreen image has been cleared.
+ * point in time where the on-screen image has been cleared.
*/
pixmap = Tk_GetPixmap(butPtr->display, Tk_WindowId(tkwin),
@@ -341,89 +597,27 @@ TkpDisplayButton(clientData)
*/
if ((butPtr->type == TYPE_CHECK_BUTTON) && butPtr->indicatorOn) {
- int dim;
-
- dim = butPtr->indicatorDiameter;
- x -= butPtr->indicatorSpace;
- y -= dim/2;
- if (dim > 2*butPtr->borderWidth) {
- Tk_Draw3DRectangle(tkwin, pixmap, border, x, y, dim, dim,
- butPtr->borderWidth,
- (butPtr->flags & SELECTED) ? TK_RELIEF_SUNKEN :
- TK_RELIEF_RAISED);
- x += butPtr->borderWidth;
- y += butPtr->borderWidth;
- dim -= 2*butPtr->borderWidth;
- if (butPtr->flags & SELECTED) {
- GC gc;
- if (butPtr->state != STATE_DISABLED) {
- if (butPtr->selectBorder != NULL) {
- gc = Tk_3DBorderGC(tkwin, butPtr->selectBorder,
- TK_3D_FLAT_GC);
- } else {
- gc = Tk_3DBorderGC(tkwin, butPtr->normalBorder,
- TK_3D_FLAT_GC);
- }
- } else {
- if (butPtr->disabledFg != NULL) {
- gc = butPtr->disabledGC;
- } else {
- gc = butPtr->normalTextGC;
- XSetForeground(butPtr->display, butPtr->disabledGC,
- Tk_3DBorderColor(butPtr->normalBorder)->pixel);
- }
- }
-
- XFillRectangle(butPtr->display, pixmap, gc, x, y,
- (unsigned int) dim, (unsigned int) dim);
- } else {
- Tk_Fill3DRectangle(tkwin, pixmap, butPtr->normalBorder, x, y,
- dim, dim, butPtr->borderWidth, TK_RELIEF_FLAT);
- }
+ if (butPtr->indicatorDiameter > 2*butPtr->borderWidth) {
+ TkBorder *selBorder = (TkBorder *) butPtr->selectBorder;
+
+ x -= butPtr->indicatorSpace/2;
+ y = Tk_Height(tkwin)/2;
+ TkpDrawCheckIndicator(tkwin, butPtr->display, pixmap,
+ x, y, border, butPtr->normalFg, selBorder->bgColorPtr,
+ butPtr->disabledFg, (butPtr->flags & SELECTED),
+ (butPtr->state == STATE_DISABLED), CHECK_BUTTON);
}
} else if ((butPtr->type == TYPE_RADIO_BUTTON) && butPtr->indicatorOn) {
- XPoint points[4];
- int radius;
-
- radius = butPtr->indicatorDiameter/2;
- points[0].x = x - butPtr->indicatorSpace;
- points[0].y = y;
- points[1].x = points[0].x + radius;
- points[1].y = points[0].y + radius;
- points[2].x = points[1].x + radius;
- points[2].y = points[0].y;
- points[3].x = points[1].x;
- points[3].y = points[0].y - radius;
- if (butPtr->flags & SELECTED) {
- GC gc;
-
- if (butPtr->state != STATE_DISABLED) {
- if (butPtr->selectBorder != NULL) {
- gc = Tk_3DBorderGC(tkwin, butPtr->selectBorder,
- TK_3D_FLAT_GC);
- } else {
- gc = Tk_3DBorderGC(tkwin, butPtr->normalBorder,
- TK_3D_FLAT_GC);
- }
- } else {
- if (butPtr->disabledFg != NULL) {
- gc = butPtr->disabledGC;
- } else {
- gc = butPtr->normalTextGC;
- XSetForeground(butPtr->display, butPtr->disabledGC,
- Tk_3DBorderColor(butPtr->normalBorder)->pixel);
- }
- }
-
- XFillPolygon(butPtr->display, pixmap, gc, points, 4, Convex,
- CoordModeOrigin);
- } else {
- Tk_Fill3DPolygon(tkwin, pixmap, butPtr->normalBorder, points,
- 4, butPtr->borderWidth, TK_RELIEF_FLAT);
+ if (butPtr->indicatorDiameter > 2*butPtr->borderWidth) {
+ TkBorder *selBorder = (TkBorder *) butPtr->selectBorder;
+
+ x -= butPtr->indicatorSpace/2;
+ y = Tk_Height(tkwin)/2;
+ TkpDrawCheckIndicator(tkwin, butPtr->display, pixmap,
+ x, y, border, butPtr->normalFg, selBorder->bgColorPtr,
+ butPtr->disabledFg, (butPtr->flags & SELECTED),
+ (butPtr->state == STATE_DISABLED), RADIO_BUTTON);
}
- Tk_Draw3DPolygon(tkwin, pixmap, border, points, 4, butPtr->borderWidth,
- (butPtr->flags & SELECTED) ? TK_RELIEF_SUNKEN :
- TK_RELIEF_RAISED);
}
/*
diff --git a/unix/tkUnixDefault.h b/unix/tkUnixDefault.h
index db8ba93..84f6672 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.17 2003/05/31 18:32:21 jenglish Exp $
+ * RCS: @(#) $Id: tkUnixDefault.h,v 1.18 2003/08/14 10:31:14 dkf Exp $
*/
#ifndef _TKUNIXDEFAULT
@@ -33,7 +33,8 @@
#define ACTIVE_BG "#ececec"
#define SELECT_BG "#c3c3c3"
#define TROUGH "#c3c3c3"
-#define INDICATOR "#b03060"
+#define CHECK_INDICATOR WHITE
+#define MENU_INDICATOR BLACK
#define DISABLED "#a3a3a3"
/*
@@ -96,7 +97,7 @@
#define DEF_LABCHKRAD_RELIEF "flat"
#define DEF_BUTTON_REPEAT_DELAY "0"
#define DEF_BUTTON_REPEAT_INTERVAL "0"
-#define DEF_BUTTON_SELECT_COLOR INDICATOR
+#define DEF_BUTTON_SELECT_COLOR CHECK_INDICATOR
#define DEF_BUTTON_SELECT_MONO BLACK
#define DEF_BUTTON_SELECT_IMAGE (char *) NULL
#define DEF_BUTTON_STATE "normal"
@@ -300,7 +301,7 @@
#define DEF_MENU_FG BLACK
#define DEF_MENU_POST_COMMAND ""
#define DEF_MENU_RELIEF "raised"
-#define DEF_MENU_SELECT_COLOR INDICATOR
+#define DEF_MENU_SELECT_COLOR MENU_INDICATOR
#define DEF_MENU_SELECT_MONO BLACK
#define DEF_MENU_TAKE_FOCUS "0"
#define DEF_MENU_TEAROFF "1"
diff --git a/unix/tkUnixMenu.c b/unix/tkUnixMenu.c
index 930a973..302edaf 100644
--- a/unix/tkUnixMenu.c
+++ b/unix/tkUnixMenu.c
@@ -8,7 +8,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkUnixMenu.c,v 1.7 2002/02/22 13:13:13 dkf Exp $
+ * RCS: @(#) $Id: tkUnixMenu.c,v 1.8 2003/08/14 10:31:14 dkf Exp $
*/
#include "tkPort.h"
@@ -31,6 +31,23 @@
#define ENTRY_HELP_MENU ENTRY_PLATFORM_FLAG1
/*
+ * Shared with button widget.
+ */
+
+extern void TkpDrawCheckIndicator _ANSI_ARGS_((
+ Tk_Window tkwin, Display *display, Drawable d,
+ int x, int y, Tk_3DBorder bgBorder,
+ XColor *indicatorColor, XColor *selectColor,
+ XColor *disColor, int on, int disabled, int mode));
+/*
+ * Indicator Draw Modes
+ */
+#define CHECK_BUTTON 0
+#define CHECK_MENU 1
+#define RADIO_BUTTON 2
+#define RADIO_MENU 3
+
+/*
* Procedures used internally.
*/
@@ -47,9 +64,9 @@ static void DrawMenuEntryBackground _ANSI_ARGS_((
Tk_3DBorder bgBorder, int x, int y,
int width, int heigth));
static void DrawMenuEntryIndicator _ANSI_ARGS_((
- TkMenu *menuPtr, TkMenuEntry *mePtr,
- Drawable d, GC gc, GC indicatorGC,
- Tk_Font tkfont,
+ TkMenu *menuPtr, TkMenuEntry *mePtr, Drawable d,
+ Tk_3DBorder border, XColor *indicatorColor,
+ XColor *disableColor, Tk_Font tkfont,
CONST Tk_FontMetrics *fmPtr, int x, int y,
int width, int height));
static void DrawMenuEntryLabel _ANSI_ARGS_((
@@ -549,13 +566,14 @@ DrawMenuEntryAccelerator(menuPtr, mePtr, d, gc, tkfont, fmPtr, activeBorder,
*/
static void
-DrawMenuEntryIndicator(menuPtr, mePtr, d, gc, indicatorGC, tkfont, fmPtr,
- x, y, width, height)
+DrawMenuEntryIndicator(menuPtr, mePtr, d, border, indicatorColor, disableColor,
+ tkfont, fmPtr, x, y, width, height)
TkMenu *menuPtr; /* The menu we are drawing */
TkMenuEntry *mePtr; /* The entry we are drawing */
Drawable d; /* The drawable to draw into */
- GC gc; /* The gc to draw with */
- GC indicatorGC; /* The gc that indicators draw with */
+ Tk_3DBorder border; /* The background color */
+ XColor *indicatorColor; /* The color to draw indicators with */
+ XColor *disableColor; /* The color use use when disabled */
Tk_Font tkfont; /* The font to draw with */
CONST Tk_FontMetrics *fmPtr; /* The font metrics of the font */
int x; /* The left of the entry rect */
@@ -570,28 +588,20 @@ DrawMenuEntryIndicator(menuPtr, mePtr, d, gc, indicatorGC, tkfont, fmPtr,
if ((mePtr->type == CHECK_BUTTON_ENTRY) && mePtr->indicatorOn) {
int dim, top, left;
int activeBorderWidth;
- Tk_3DBorder border;
-
+ int disabled = (mePtr->state == ENTRY_DISABLED);
+ XColor *bg;
+
dim = (int) mePtr->platformEntryData;
Tk_GetPixelsFromObj(NULL, menuPtr->tkwin,
menuPtr->activeBorderWidthPtr, &activeBorderWidth);
- left = x + activeBorderWidth + (mePtr->indicatorSpace - dim)/2;
- if (menuPtr->menuType == MENUBAR) {
- left += 5;
- }
- top = y + (height - dim)/2;
- border = Tk_Get3DBorderFromObj(menuPtr->tkwin,
- menuPtr->borderPtr);
- Tk_Fill3DRectangle(menuPtr->tkwin, d, border, left, top, dim,
- dim, DECORATION_BORDER_WIDTH, TK_RELIEF_SUNKEN);
- left += DECORATION_BORDER_WIDTH;
- top += DECORATION_BORDER_WIDTH;
- dim -= 2*DECORATION_BORDER_WIDTH;
- if ((dim > 0) && (mePtr->entryFlags
- & ENTRY_SELECTED)) {
- XFillRectangle(menuPtr->display, d, indicatorGC, left, top,
- (unsigned int) dim, (unsigned int) dim);
- }
+ bg = Tk_3DBorderColor(border);
+ top = y + height/2;
+ left = x + activeBorderWidth + DECORATION_BORDER_WIDTH
+ + mePtr->indicatorSpace/2;
+
+ TkpDrawCheckIndicator(menuPtr->tkwin, menuPtr->display, d, left, top,
+ border, indicatorColor, bg, disableColor,
+ (mePtr->entryFlags & ENTRY_SELECTED), disabled, CHECK_MENU);
}
/*
@@ -599,31 +609,22 @@ DrawMenuEntryIndicator(menuPtr, mePtr, d, gc, indicatorGC, tkfont, fmPtr,
*/
if ((mePtr->type == RADIO_BUTTON_ENTRY) && mePtr->indicatorOn) {
- XPoint points[4];
- int radius;
- Tk_3DBorder border;
-
- border = Tk_Get3DBorderFromObj(menuPtr->tkwin,
- menuPtr->borderPtr);
- radius = ((int) mePtr->platformEntryData)/2;
- points[0].x = x + (mePtr->indicatorSpace
- - (int) mePtr->platformEntryData)/2;
- points[0].y = y + (height)/2;
- points[1].x = points[0].x + radius;
- points[1].y = points[0].y + radius;
- points[2].x = points[1].x + radius;
- points[2].y = points[0].y;
- points[3].x = points[1].x;
- points[3].y = points[0].y - radius;
- if (mePtr->entryFlags & ENTRY_SELECTED) {
- XFillPolygon(menuPtr->display, d, indicatorGC, points, 4,
- Convex, CoordModeOrigin);
- } else {
- Tk_Fill3DPolygon(menuPtr->tkwin, d, border, points, 4,
- DECORATION_BORDER_WIDTH, TK_RELIEF_FLAT);
- }
- Tk_Draw3DPolygon(menuPtr->tkwin, d, border, points, 4,
- DECORATION_BORDER_WIDTH, TK_RELIEF_SUNKEN);
+ int dim, top, left;
+ int activeBorderWidth;
+ int disabled = (mePtr->state == ENTRY_DISABLED);
+ XColor *bg;
+
+ dim = (int) mePtr->platformEntryData;
+ Tk_GetPixelsFromObj(NULL, menuPtr->tkwin,
+ menuPtr->activeBorderWidthPtr, &activeBorderWidth);
+ bg = Tk_3DBorderColor(border);
+ top = y + height/2;
+ left = x + activeBorderWidth + DECORATION_BORDER_WIDTH
+ + mePtr->indicatorSpace/2;
+
+ TkpDrawCheckIndicator(menuPtr->tkwin, menuPtr->display, d, left, top,
+ border, indicatorColor, bg, disableColor,
+ (mePtr->entryFlags & ENTRY_SELECTED), disabled, RADIO_MENU);
}
}
@@ -1344,6 +1345,8 @@ TkpDrawMenuEntry(mePtr, d, tkfont, menuMetricsPtr, x, y, width, height,
* to Windows. */
{
GC gc, indicatorGC;
+ XColor *indicatorColor;
+ XColor *disableColor;
TkMenu *menuPtr = mePtr->menuPtr;
Tk_3DBorder bgBorder, activeBorder;
CONST Tk_FontMetrics *fmPtr;
@@ -1398,6 +1401,15 @@ TkpDrawMenuEntry(mePtr, d, tkfont, menuMetricsPtr, x, y, width, height,
if (indicatorGC == NULL) {
indicatorGC = menuPtr->indicatorGC;
}
+ if (mePtr->indicatorFgPtr) {
+ indicatorColor = Tk_GetColorFromObj(menuPtr->tkwin,
+ mePtr->indicatorFgPtr);
+ } else {
+ indicatorColor = Tk_GetColorFromObj(menuPtr->tkwin,
+ menuPtr->indicatorFgPtr);
+ }
+
+ disableColor = Tk_GetColorFromObj(menuPtr->tkwin, menuPtr->disabledFgPtr);
bgBorder = Tk_Get3DBorderFromObj(menuPtr->tkwin,
(mePtr->borderPtr == NULL)
@@ -1439,8 +1451,12 @@ TkpDrawMenuEntry(mePtr, d, tkfont, menuMetricsPtr, x, y, width, height,
DrawMenuEntryAccelerator(menuPtr, mePtr, d, gc, tkfont, fmPtr,
activeBorder, x, adjustedY, width, adjustedHeight, drawArrow);
if (!mePtr->hideMargin) {
- DrawMenuEntryIndicator(menuPtr, mePtr, d, gc, indicatorGC, tkfont,
- fmPtr, x, adjustedY, width, adjustedHeight);
+ if (mePtr->state == ENTRY_ACTIVE) {
+ bgBorder = activeBorder;
+ }
+ DrawMenuEntryIndicator(menuPtr, mePtr, d, bgBorder, indicatorColor,
+ disableColor, tkfont, fmPtr, x, adjustedY, width,
+ adjustedHeight);
}
}
}