diff options
author | hobbs <hobbs@noemail.net> | 2003-04-26 02:53:46 (GMT) |
---|---|---|
committer | hobbs <hobbs@noemail.net> | 2003-04-26 02:53:46 (GMT) |
commit | 48f1938775fe828f720439b69c82c9813194ab6e (patch) | |
tree | 1f1c2de747a6f561c6d8c626dc62f29b10b137e2 /unix/tkUnixButton.c | |
parent | a7171bfb4bc223701d9776f8ada0dbf7dde30ad0 (diff) | |
download | tk-48f1938775fe828f720439b69c82c9813194ab6e.zip tk-48f1938775fe828f720439b69c82c9813194ab6e.tar.gz tk-48f1938775fe828f720439b69c82c9813194ab6e.tar.bz2 |
* generic/tkButton.h: Rewrote the handling
* generic/tkButton.c (TkButtonWorldChanged): of compound *buttons
* mac/tkMacButton.c (TkpDisplayButton): to correctly display
* macosx/tkMacOSXButton.c (TkpDisplayButton): mixture of disabledfg,
* unix/tkUnixButton.c (TkpDisplayButton): selectcolor, indicator,
* win/tkWinButton.c (TkpDisplayButton): etc. *buttons will
now only stipple the image, unless no disabledfg is given, in which
case it will stipple the whole button.
FossilOrigin-Name: 6e8bda65b8ba2dd0a752ecffcd03955feadd3093
Diffstat (limited to 'unix/tkUnixButton.c')
-rw-r--r-- | unix/tkUnixButton.c | 59 |
1 files changed, 37 insertions, 22 deletions
diff --git a/unix/tkUnixButton.c b/unix/tkUnixButton.c index 24aef95..dd4eca9 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.11.2.1 2003/04/25 20:11:30 hobbs Exp $ + * RCS: @(#) $Id: tkUnixButton.c,v 1.11.2.2 2003/04/26 02:53:47 hobbs Exp $ */ #include "tkButton.h" @@ -86,12 +86,16 @@ TkpDisplayButton(clientData) int y, relief; Tk_Window tkwin = butPtr->tkwin; int width, height, fullWidth, fullHeight; - int imageXOffset, imageYOffset, textXOffset, textYOffset; + int textXOffset, textYOffset; int haveImage = 0, haveText = 0; int offset; /* 1 means this is a button widget, so we * offset the text to make the button appear * to move up and down as the relief changes. */ + int imageWidth, imageHeight; + int imageXOffset = 0, imageYOffset = 0; /* image information that will + * be used to restrict disabled + * pixmap as well */ butPtr->flags &= ~REDRAW_PENDING; if ((butPtr->tkwin == NULL) || !Tk_IsMapped(tkwin)) { @@ -176,11 +180,12 @@ TkpDisplayButton(clientData) Tk_SizeOfBitmap(butPtr->display, butPtr->bitmap, &width, &height); haveImage = 1; } + imageWidth = width; + imageHeight = height; + haveText = (butPtr->textWidth != 0 && butPtr->textHeight != 0); if (butPtr->compound != COMPOUND_NONE && haveImage && haveText) { - imageXOffset = 0; - imageYOffset = 0; textXOffset = 0; textYOffset = 0; fullWidth = 0; @@ -246,23 +251,23 @@ TkpDisplayButton(clientData) x += offset; y += offset; } - + + imageXOffset += x; + imageYOffset += y; + if (butPtr->image != NULL) { if ((butPtr->selectImage != NULL) && (butPtr->flags & SELECTED)) { Tk_RedrawImage(butPtr->selectImage, 0, 0, - width, height, pixmap, x + imageXOffset, - y + imageYOffset); + width, height, pixmap, imageXOffset, imageYOffset); } else { Tk_RedrawImage(butPtr->image, 0, 0, width, - height, pixmap, x + imageXOffset, y + imageYOffset); + height, pixmap, imageXOffset, imageYOffset); } } else { - XSetClipOrigin(butPtr->display, gc, x + imageXOffset, - y + imageYOffset); + XSetClipOrigin(butPtr->display, gc, imageXOffset, imageYOffset); XCopyPlane(butPtr->display, butPtr->bitmap, pixmap, gc, - 0, 0, (unsigned int) width, - (unsigned int) height, x + imageXOffset, - y + imageYOffset, 1); + 0, 0, (unsigned int) width, (unsigned int) height, + imageXOffset, imageYOffset, 1); XSetClipOrigin(butPtr->display, gc, 0, 0); } @@ -270,9 +275,9 @@ TkpDisplayButton(clientData) * Use normalTextGC in this case since we have both text and image, * the whole button will later be stippled 50% grey. */ - Tk_DrawTextLayout(butPtr->display, pixmap, butPtr->normalTextGC, + Tk_DrawTextLayout(butPtr->display, pixmap, gc, butPtr->textLayout, x + textXOffset, y + textYOffset, 0, -1); - Tk_UnderlineTextLayout(butPtr->display, pixmap, butPtr->normalTextGC, + Tk_UnderlineTextLayout(butPtr->display, pixmap, gc, butPtr->textLayout, x + textXOffset, y + textYOffset, butPtr->underline); y += fullHeight/2; @@ -291,6 +296,8 @@ TkpDisplayButton(clientData) x += offset; y += offset; } + imageXOffset += x; + imageXOffset += y; if (butPtr->image != NULL) { if ((butPtr->selectImage != NULL) && (butPtr->flags & SELECTED)) { @@ -427,23 +434,31 @@ TkpDisplayButton(clientData) * If the button is disabled with a stipple rather than a special * foreground color, generate the stippled effect. If the widget * is selected and we use a different background color when selected, - * must temporarily modify the GC. + * must temporarily modify the GC so the stippling is the right color. */ if ((butPtr->state == STATE_DISABLED) && ((butPtr->disabledFg == NULL) || (butPtr->image != NULL))) { if ((butPtr->flags & SELECTED) && !butPtr->indicatorOn && (butPtr->selectBorder != NULL)) { - XSetForeground(butPtr->display, butPtr->disabledGC, + XSetForeground(butPtr->display, butPtr->stippleGC, Tk_3DBorderColor(butPtr->selectBorder)->pixel); } - XFillRectangle(butPtr->display, pixmap, butPtr->disabledGC, - butPtr->inset, butPtr->inset, - (unsigned) (Tk_Width(tkwin) - 2*butPtr->inset), - (unsigned) (Tk_Height(tkwin) - 2*butPtr->inset)); + /* + * Stipple the whole button if no disabledFg was specified, + * otherwise restrict stippling only to displayed image + */ + if (butPtr->disabledFg == NULL) { + XFillRectangle(butPtr->display, pixmap, butPtr->stippleGC, 0, 0, + (unsigned) Tk_Width(tkwin), (unsigned) Tk_Height(tkwin)); + } else { + XFillRectangle(butPtr->display, pixmap, butPtr->stippleGC, + imageXOffset, imageYOffset, + (unsigned) imageWidth, (unsigned) imageHeight); + } if ((butPtr->flags & SELECTED) && !butPtr->indicatorOn && (butPtr->selectBorder != NULL)) { - XSetForeground(butPtr->display, butPtr->disabledGC, + XSetForeground(butPtr->display, butPtr->stippleGC, Tk_3DBorderColor(butPtr->normalBorder)->pixel); } } |