diff options
author | hobbs <hobbs> | 2003-04-26 02:53:46 (GMT) |
---|---|---|
committer | hobbs <hobbs> | 2003-04-26 02:53:46 (GMT) |
commit | a012f1e460d3ed37ce6f288481bae260a6f74f78 (patch) | |
tree | 1f1c2de747a6f561c6d8c626dc62f29b10b137e2 /macosx | |
parent | 7241fda68562ff19ba06f66d7c80b5d563fed8d5 (diff) | |
download | tk-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 'macosx')
-rw-r--r-- | macosx/tkMacOSXButton.c | 97 |
1 files changed, 55 insertions, 42 deletions
diff --git a/macosx/tkMacOSXButton.c b/macosx/tkMacOSXButton.c index 6314535..6bd99d9 100644 --- a/macosx/tkMacOSXButton.c +++ b/macosx/tkMacOSXButton.c @@ -10,7 +10,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkMacOSXButton.c,v 1.2 2002/08/31 06:12:29 das Exp $ + * RCS: @(#) $Id: tkMacOSXButton.c,v 1.2.2.1 2003/04/26 02:53:47 hobbs Exp $ */ #include "tkButton.h" @@ -33,10 +33,10 @@ * Some defines used to control what type of control is drawn. */ -#define DRAW_LABEL 0 /* Labels are treated genericly. */ -#define DRAW_CONTROL 1 /* Draw using the Native control. */ -#define DRAW_CUSTOM 2 /* Make our own button drawing. */ -#define DRAW_BEVEL 3 +#define DRAW_LABEL 0 /* Labels are treated genericly. */ +#define DRAW_CONTROL 1 /* Draw using the Native control. */ +#define DRAW_CUSTOM 2 /* Make our own button drawing. */ +#define DRAW_BEVEL 3 /* * Declaration of Mac specific button structure. @@ -47,18 +47,18 @@ typedef struct { SInt16 minValue; SInt16 maxValue; SInt16 procID; - int isBevel; + int isBevel; } MacControlParams; typedef struct { int drawType; Tk_3DBorder border; int relief; - int offset; /* 0 means this is a normal widget. 1 means - * it is an image button, so we offset the - * image to make the button appear to move - * up and down as the relief changes. */ - GC gc; + int offset; /* 0 means this is a normal widget. 1 means + * it is an image button, so we offset the + * image to make the button appear to move + * up and down as the relief changes. */ + GC gc; int hasImageOrBitmap; } DrawParams; @@ -201,12 +201,16 @@ TkpDisplayButton( * compiler warning. */ int y; int width, height, fullWidth, fullHeight; - int imageXOffset, imageYOffset, textXOffset, textYOffset; + int textXOffset, textYOffset; int haveImage = 0, haveText = 0; GWorldPtr destPort; int borderWidth; Pixmap pixmap; int wasUsingControl; + int imageWidth, imageHeight; + int imageXOffset = 0, imageYOffset = 0; /* image information that will + * be used to restrict disabled + * pixmap as well */ DrawParams drawParams, * dpPtr = &drawParams; butPtr->flags &= ~REDRAW_PENDING; @@ -291,10 +295,11 @@ TkpDisplayButton( 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; @@ -366,29 +371,27 @@ TkpDisplayButton( x += dpPtr->offset; y += dpPtr->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, dpPtr->gc, x + imageXOffset, - y + imageYOffset); + XSetClipOrigin(butPtr->display, dpPtr->gc, + imageXOffset, imageYOffset); XCopyPlane(butPtr->display, butPtr->bitmap, pixmap, dpPtr->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, dpPtr->gc, 0, 0); } - - if (macButtonPtr->useTkText ) { + + if (macButtonPtr->useTkText) { Tk_DrawTextLayout(butPtr->display, pixmap, dpPtr->gc, butPtr->textLayout, x + textXOffset, y + textYOffset, 0, -1); @@ -403,7 +406,7 @@ TkpDisplayButton( TkComputeAnchor(butPtr->anchor, tkwin, 0, 0, butPtr->indicatorSpace + width, height, &x, &y); x += butPtr->indicatorSpace; - + x += dpPtr->offset; y += dpPtr->offset; if (dpPtr->relief == TK_RELIEF_RAISED) { @@ -413,17 +416,18 @@ TkpDisplayButton( x += dpPtr->offset; y += dpPtr->offset; } + imageXOffset += x; + imageXOffset += y; if (butPtr->image != NULL) { if ((butPtr->selectImage != NULL) && (butPtr->flags & SELECTED)) { Tk_RedrawImage(butPtr->selectImage, 0, 0, width, - height, pixmap, x, y); + height, pixmap, x, y); } else { Tk_RedrawImage(butPtr->image, 0, 0, width, height, pixmap, x, y); } } else { - XSetClipOrigin(butPtr->display, dpPtr->gc, x, y); XCopyPlane(butPtr->display, butPtr->bitmap, pixmap, dpPtr->gc, @@ -453,28 +457,37 @@ TkpDisplayButton( * 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 (macButtonPtr->useTkText) { 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, - Tk_3DBorderColor(butPtr->selectBorder)->pixel); + && (butPtr->selectBorder != NULL)) { + XSetForeground(butPtr->display, butPtr->stippledGC, + 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, - Tk_3DBorderColor(butPtr->normalBorder)->pixel); - } + && (butPtr->selectBorder != NULL)) { + XSetForeground(butPtr->display, butPtr->stippledGC, + Tk_3DBorderColor(butPtr->normalBorder)->pixel); + } } - + /* * Draw the border and traversal highlight last. This way, if the * button's contents overflow they'll be covered up by the border. |