diff options
author | hobbs <hobbs> | 2003-11-17 23:12:43 (GMT) |
---|---|---|
committer | hobbs <hobbs> | 2003-11-17 23:12:43 (GMT) |
commit | 69bd0b5addc827fd96263e1adbb4fa03d4795417 (patch) | |
tree | 7008d9995e94e7eab0aabb354357b348f54f0c2e /unix | |
parent | 8d3b4278e41bd5302246e4c3b151e6924a33a9de (diff) | |
download | tk-69bd0b5addc827fd96263e1adbb4fa03d4795417.zip tk-69bd0b5addc827fd96263e1adbb4fa03d4795417.tar.gz tk-69bd0b5addc827fd96263e1adbb4fa03d4795417.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')
-rw-r--r-- | unix/tkUnixMenubu.c | 111 |
1 files changed, 63 insertions, 48 deletions
diff --git a/unix/tkUnixMenubu.c b/unix/tkUnixMenubu.c index 186bd75..cdcc31c 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.7 2003/11/17 23:12:44 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); + } } /* |