summaryrefslogtreecommitdiffstats
path: root/win/tkWinButton.c
diff options
context:
space:
mode:
authorhobbs <hobbs>2003-04-26 02:53:46 (GMT)
committerhobbs <hobbs>2003-04-26 02:53:46 (GMT)
commita012f1e460d3ed37ce6f288481bae260a6f74f78 (patch)
tree1f1c2de747a6f561c6d8c626dc62f29b10b137e2 /win/tkWinButton.c
parent7241fda68562ff19ba06f66d7c80b5d563fed8d5 (diff)
downloadtk-a012f1e460d3ed37ce6f288481bae260a6f74f78.zip
tk-a012f1e460d3ed37ce6f288481bae260a6f74f78.tar.gz
tk-a012f1e460d3ed37ce6f288481bae260a6f74f78.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 'win/tkWinButton.c')
-rw-r--r--win/tkWinButton.c73
1 files changed, 42 insertions, 31 deletions
diff --git a/win/tkWinButton.c b/win/tkWinButton.c
index dc8ef12..415a202 100644
--- a/win/tkWinButton.c
+++ b/win/tkWinButton.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: tkWinButton.c,v 1.20.2.1 2003/04/25 20:11:31 hobbs Exp $
+ * RCS: @(#) $Id: tkWinButton.c,v 1.20.2.2 2003/04/26 02:53:47 hobbs Exp $
*/
#define OEMRESOURCE
@@ -355,6 +355,10 @@ TkpDisplayButton(clientData)
* move up and down as the relief changes. */
int textXOffset = 0, textYOffset = 0; /* text offsets for use with
* compound buttons and focus ring */
+ int imageWidth, imageHeight;
+ int imageXOffset = 0, imageYOffset = 0; /* image information that will
+ * be used to restrict disabled
+ * pixmap as well */
DWORD *boxesPalette;
ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
@@ -459,15 +463,13 @@ 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) {
- int imageXOffset, imageYOffset, fullWidth, fullHeight;
- imageXOffset = 0;
- imageYOffset = 0;
- fullWidth = 0;
- fullHeight = 0;
+ int fullWidth = 0, fullHeight = 0;
switch ((enum compound) butPtr->compound) {
case COMPOUND_TOP:
@@ -522,33 +524,27 @@ 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);
+ Tk_RedrawImage(butPtr->image, 0, 0,
+ width, 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);
height = fullHeight;
@@ -563,6 +559,8 @@ TkpDisplayButton(clientData)
x += offset;
y += offset;
}
+ imageXOffset += x;
+ imageXOffset += y;
if (butPtr->image != NULL) {
if ((butPtr->selectImage != NULL) &&
(butPtr->flags & SELECTED)) {
@@ -578,7 +576,6 @@ TkpDisplayButton(clientData)
(unsigned int) width, (unsigned int) height, x, y, 1);
XSetClipOrigin(butPtr->display, gc, 0, 0);
}
-
} else {
TkComputeAnchor(butPtr->anchor, tkwin, butPtr->padX, butPtr->padY,
butPtr->indicatorSpace + butPtr->textWidth,
@@ -656,7 +653,13 @@ TkpDisplayButton(clientData)
* be placed into the palette.
*/
- boxesPalette[PAL_CHECK] = FlipColor(gc->foreground);
+ if ((butPtr->state == STATE_DISABLED)
+ && (butPtr->disabledFg == NULL)) {
+ boxesPalette[PAL_CHECK] = FlipColor(TkWinGetBorderPixels(tkwin,
+ border, TK_3D_DARK_GC));
+ } else {
+ boxesPalette[PAL_CHECK] = FlipColor(gc->foreground);
+ }
boxesPalette[PAL_TOP_OUTER] = FlipColor(TkWinGetBorderPixels(tkwin,
border, TK_3D_DARK_GC));
boxesPalette[PAL_TOP_INNER] = FlipColor(TkWinGetBorderPixels(tkwin,
@@ -689,23 +692,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);
}
}