summaryrefslogtreecommitdiffstats
path: root/unix/tkUnixMenubu.c
diff options
context:
space:
mode:
authorhobbs <hobbs>2003-11-17 23:29:35 (GMT)
committerhobbs <hobbs>2003-11-17 23:29:35 (GMT)
commitc89c58f9f55f3535385438ef48ab09a78b6a6f36 (patch)
treecac241128933533dd4532102214f9d36d469a0e6 /unix/tkUnixMenubu.c
parent96fcd84d863cd9ed49b2f5f3c492864fb4019e1d (diff)
downloadtk-c89c58f9f55f3535385438ef48ab09a78b6a6f36.zip
tk-c89c58f9f55f3535385438ef48ab09a78b6a6f36.tar.gz
tk-c89c58f9f55f3535385438ef48ab09a78b6a6f36.tar.bz2
* generic/tkMenubutton.h: fixed compound menubutton handling like
* generic/tkMenubutton.c: *button corrections of 2003-04-25. * mac/tkMacMenubutton.c (TkpDisplayMenuButton): * unix/tkUnixMenubu.c (TkpDisplayMenuButton):
Diffstat (limited to 'unix/tkUnixMenubu.c')
-rw-r--r--unix/tkUnixMenubu.c111
1 files changed, 63 insertions, 48 deletions
diff --git a/unix/tkUnixMenubu.c b/unix/tkUnixMenubu.c
index 186bd75..6979069 100644
--- a/unix/tkUnixMenubu.c
+++ b/unix/tkUnixMenubu.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: tkUnixMenubu.c,v 1.6 2001/05/21 14:07:33 tmh Exp $
+ * RCS: @(#) $Id: tkUnixMenubu.c,v 1.6.4.1 2003/11/17 23:29:36 hobbs Exp $
*/
#include "tkMenubutton.h"
@@ -77,7 +77,10 @@ TkpDisplayMenuButton(clientData)
int y = 0;
register Tk_Window tkwin = mbPtr->tkwin;
int width, height, fullWidth, fullHeight;
- int imageXOffset, imageYOffset, textXOffset, textYOffset;
+ int textXOffset, textYOffset;
+ int imageWidth, imageHeight;
+ int imageXOffset, imageYOffset; /* image information that will be used to
+ * restrict disabled pixmap as well */
int haveImage = 0, haveText = 0;
mbPtr->flags &= ~REDRAW_PENDING;
@@ -104,6 +107,9 @@ TkpDisplayMenuButton(clientData)
Tk_SizeOfBitmap(mbPtr->display, mbPtr->bitmap, &width, &height);
haveImage = 1;
}
+ imageWidth = width;
+ imageHeight = height;
+
haveText = (mbPtr->textWidth != 0 && mbPtr->textHeight != 0);
/*
@@ -126,7 +132,6 @@ TkpDisplayMenuButton(clientData)
fullHeight = 0;
if (mbPtr->compound != COMPOUND_NONE && haveImage && haveText) {
-
switch ((enum compound) mbPtr->compound) {
case COMPOUND_TOP:
case COMPOUND_BOTTOM: {
@@ -174,49 +179,49 @@ TkpDisplayMenuButton(clientData)
}
TkComputeAnchor(mbPtr->anchor, tkwin, 0, 0,
- mbPtr->indicatorWidth + fullWidth, fullHeight,
- &x, &y);
+ mbPtr->indicatorWidth + fullWidth, fullHeight, &x, &y);
+
+ imageXOffset += x;
+ imageYOffset += y;
+ if (mbPtr->image != NULL) {
+ Tk_RedrawImage(mbPtr->image, 0, 0, width, height, pixmap,
+ imageXOffset, imageYOffset);
+ } else if (mbPtr->bitmap != None) {
+ XSetClipOrigin(mbPtr->display, gc, imageXOffset, imageYOffset);
+ XCopyPlane(mbPtr->display, mbPtr->bitmap, pixmap,
+ gc, 0, 0, (unsigned) width, (unsigned) height,
+ imageXOffset, imageYOffset, 1);
+ XSetClipOrigin(mbPtr->display, gc, 0, 0);
+ }
- if (mbPtr->image != NULL) {
- Tk_RedrawImage(mbPtr->image, 0, 0, width, height, pixmap,
- x + imageXOffset, y + imageYOffset);
- }
- if (mbPtr->bitmap != None) {
- XCopyPlane(mbPtr->display, mbPtr->bitmap, pixmap,
- gc, 0, 0, (unsigned) width, (unsigned) height,
- x + imageXOffset, y + imageYOffset, 1);
- }
- if (haveText) {
- Tk_DrawTextLayout(mbPtr->display, pixmap, gc, mbPtr->textLayout,
- x + textXOffset, y + textYOffset ,
- 0, -1);
- Tk_UnderlineTextLayout(mbPtr->display, pixmap, gc,
- mbPtr->textLayout, x + textXOffset, y + textYOffset ,
- mbPtr->underline);
- }
+ Tk_DrawTextLayout(mbPtr->display, pixmap, gc, mbPtr->textLayout,
+ x + textXOffset, y + textYOffset, 0, -1);
+ Tk_UnderlineTextLayout(mbPtr->display, pixmap, gc, mbPtr->textLayout,
+ x + textXOffset, y + textYOffset, mbPtr->underline);
+ } else if (haveImage) {
+ TkComputeAnchor(mbPtr->anchor, tkwin, 0, 0,
+ width + mbPtr->indicatorWidth, height, &x, &y);
+ imageXOffset += x;
+ imageYOffset += y;
+ if (mbPtr->image != NULL) {
+ Tk_RedrawImage(mbPtr->image, 0, 0, width, height, pixmap,
+ imageXOffset, imageYOffset);
+ } else if (mbPtr->bitmap != None) {
+ XSetClipOrigin(mbPtr->display, gc, x, y);
+ XCopyPlane(mbPtr->display, mbPtr->bitmap, pixmap,
+ gc, 0, 0, (unsigned) width, (unsigned) height,
+ x, y, 1);
+ XSetClipOrigin(mbPtr->display, gc, 0, 0);
+ }
} else {
- if (mbPtr->image != NULL) {
- TkComputeAnchor(mbPtr->anchor, tkwin, 0, 0,
- width + mbPtr->indicatorWidth, height, &x, &y);
- Tk_RedrawImage(mbPtr->image, 0, 0, width, height, pixmap,
- x + imageXOffset, y + imageYOffset);
- } else if (mbPtr->bitmap != None) {
- TkComputeAnchor(mbPtr->anchor, tkwin, 0, 0,
- width + mbPtr->indicatorWidth, height, &x, &y);
- XCopyPlane(mbPtr->display, mbPtr->bitmap, pixmap,
- gc, 0, 0, (unsigned) width, (unsigned) height,
- x + imageXOffset, y + imageYOffset, 1);
- } else {
- TkComputeAnchor(mbPtr->anchor, tkwin, mbPtr->padX, mbPtr->padY,
- mbPtr->textWidth + mbPtr->indicatorWidth,
- mbPtr->textHeight, &x, &y);
- Tk_DrawTextLayout(mbPtr->display, pixmap, gc, mbPtr->textLayout,
- x + textXOffset, y + textYOffset ,
- 0, -1);
- Tk_UnderlineTextLayout(mbPtr->display, pixmap, gc,
- mbPtr->textLayout, x + textXOffset, y + textYOffset ,
- mbPtr->underline);
- }
+ TkComputeAnchor(mbPtr->anchor, tkwin, mbPtr->padX, mbPtr->padY,
+ mbPtr->textWidth + mbPtr->indicatorWidth,
+ mbPtr->textHeight, &x, &y);
+ Tk_DrawTextLayout(mbPtr->display, pixmap, gc, mbPtr->textLayout,
+ x + textXOffset, y + textYOffset, 0, -1);
+ Tk_UnderlineTextLayout(mbPtr->display, pixmap, gc,
+ mbPtr->textLayout, x + textXOffset, y + textYOffset,
+ mbPtr->underline);
}
/*
@@ -226,10 +231,20 @@ TkpDisplayMenuButton(clientData)
if ((mbPtr->state == STATE_DISABLED)
&& ((mbPtr->disabledFg == NULL) || (mbPtr->image != NULL))) {
- XFillRectangle(mbPtr->display, pixmap, mbPtr->disabledGC,
- mbPtr->inset, mbPtr->inset,
- (unsigned) (Tk_Width(tkwin) - 2*mbPtr->inset),
- (unsigned) (Tk_Height(tkwin) - 2*mbPtr->inset));
+ /*
+ * Stipple the whole button if no disabledFg was specified,
+ * otherwise restrict stippling only to displayed image
+ */
+ if (mbPtr->disabledFg == NULL) {
+ XFillRectangle(mbPtr->display, pixmap, mbPtr->stippleGC,
+ mbPtr->inset, mbPtr->inset,
+ (unsigned) (Tk_Width(tkwin) - 2*mbPtr->inset),
+ (unsigned) (Tk_Height(tkwin) - 2*mbPtr->inset));
+ } else {
+ XFillRectangle(mbPtr->display, pixmap, mbPtr->stippleGC,
+ imageXOffset, imageYOffset,
+ (unsigned) imageWidth, (unsigned) imageHeight);
+ }
}
/*