summaryrefslogtreecommitdiffstats
path: root/unix
diff options
context:
space:
mode:
authorhobbs <hobbs>2003-04-26 02:59:19 (GMT)
committerhobbs <hobbs>2003-04-26 02:59:19 (GMT)
commit089226ed8985189d0e14343101b8a1c62187e6bd (patch)
tree566771aaa15411ffcc5ed06c7d1055c573128211 /unix
parentf9848e525a926932e78279575535447bd92b9b2f (diff)
downloadtk-089226ed8985189d0e14343101b8a1c62187e6bd.zip
tk-089226ed8985189d0e14343101b8a1c62187e6bd.tar.gz
tk-089226ed8985189d0e14343101b8a1c62187e6bd.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.
Diffstat (limited to 'unix')
-rw-r--r--unix/tkUnixButton.c63
1 files changed, 37 insertions, 26 deletions
diff --git a/unix/tkUnixButton.c b/unix/tkUnixButton.c
index ae2feae..35f6adf 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.12 2003/04/25 20:03:43 hobbs Exp $
+ * RCS: @(#) $Id: tkUnixButton.c,v 1.13 2003/04/26 02:59:20 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,33 +251,29 @@ 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);
}
- /*
- * 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 +292,8 @@ TkpDisplayButton(clientData)
x += offset;
y += offset;
}
+ imageXOffset += x;
+ imageXOffset += y;
if (butPtr->image != NULL) {
if ((butPtr->selectImage != NULL) &&
(butPtr->flags & SELECTED)) {
@@ -427,23 +430,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);
}
}