summaryrefslogtreecommitdiffstats
path: root/mac/tkMacButton.c
diff options
context:
space:
mode:
authorstanton <stanton@noemail.net>1999-04-16 01:51:06 (GMT)
committerstanton <stanton@noemail.net>1999-04-16 01:51:06 (GMT)
commit58364783d6f176ecb8520dade8d1cb1a346c0950 (patch)
tree31378e81bd58f8c726fc552d6b30cbf3ca07497b /mac/tkMacButton.c
parent878ed3a2c9af6e583516ac48fd69ce3b349ac5f8 (diff)
downloadtk-58364783d6f176ecb8520dade8d1cb1a346c0950.zip
tk-58364783d6f176ecb8520dade8d1cb1a346c0950.tar.gz
tk-58364783d6f176ecb8520dade8d1cb1a346c0950.tar.bz2
* Merged 8.1 branch into the main trunk
FossilOrigin-Name: 1120dc4257448ed1955333e682de48e2940cc741
Diffstat (limited to 'mac/tkMacButton.c')
-rw-r--r--mac/tkMacButton.c665
1 files changed, 335 insertions, 330 deletions
diff --git a/mac/tkMacButton.c b/mac/tkMacButton.c
index 237f0b2..cdc609b 100644
--- a/mac/tkMacButton.c
+++ b/mac/tkMacButton.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: tkMacButton.c,v 1.4 1999/04/16 01:25:54 stanton Exp $
+ * RCS: @(#) $Id: tkMacButton.c,v 1.5 1999/04/16 01:51:29 stanton Exp $
*/
#include "tkButton.h"
@@ -28,7 +28,7 @@
#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_BEVEL 3
/*
* The following structures are used to draw our controls. Rather than
@@ -85,17 +85,17 @@ static pascal void UserPaneBackgroundProc(ControlHandle,
*/
static int UpdateControlColors _ANSI_ARGS_((TkButton *butPtr,
- ControlRef controlHandle, CCTabHandle ccTabHandle,
- RGBColor *saveColorPtr));
+ ControlRef controlHandle, CCTabHandle ccTabHandle,
+ RGBColor *saveColorPtr));
static void DrawBufferedControl _ANSI_ARGS_((TkButton *butPtr,
- GWorldPtr destPort, GC gc, Pixmap pixmap));
+ GWorldPtr destPort, GC gc, Pixmap pixmap));
static void InitSampleControls();
static void SetupBevelButton _ANSI_ARGS_((TkButton *butPtr,
- ControlRef controlHandle,
- GWorldPtr destPort, GC gc, Pixmap pixmap));
+ ControlRef controlHandle,
+ GWorldPtr destPort, GC gc, Pixmap pixmap));
static void ChangeBackgroundWindowColor _ANSI_ARGS_((
- WindowRef macintoshWindow, RGBColor rgbColor,
- RGBColor *oldColor));
+ WindowRef macintoshWindow, RGBColor rgbColor,
+ RGBColor *oldColor));
static void ButtonExitProc _ANSI_ARGS_((ClientData clientData));
/*
@@ -193,17 +193,17 @@ TkpDisplayButton(
offset = (butPtr->type == TYPE_BUTTON) && hasImageOrBitmap;
border = butPtr->normalBorder;
- if ((butPtr->state == tkDisabledUid) && (butPtr->disabledFg != NULL)) {
+ if ((butPtr->state == STATE_DISABLED) && (butPtr->disabledFg != NULL)) {
gc = butPtr->disabledGC;
} else if ((butPtr->type == TYPE_BUTTON)
- && (butPtr->state == tkActiveUid)) {
+ && (butPtr->state == STATE_ACTIVE)) {
gc = butPtr->activeTextGC;
border = butPtr->activeBorder;
} else {
gc = butPtr->normalTextGC;
}
- if ((butPtr->flags & SELECTED) && (butPtr->state != tkActiveUid)
+ if ((butPtr->flags & SELECTED) && (butPtr->state != STATE_ACTIVE)
&& (butPtr->selectBorder != NULL) && !butPtr->indicatorOn) {
border = butPtr->selectBorder;
}
@@ -218,10 +218,10 @@ TkpDisplayButton(
relief = butPtr->relief;
if ((butPtr->type >= TYPE_CHECK_BUTTON) && !butPtr->indicatorOn) {
- if (!TkMacHaveAppearance() || !hasImageOrBitmap) {
+ if (!TkMacHaveAppearance() || !hasImageOrBitmap) {
relief = (butPtr->flags & SELECTED) ? TK_RELIEF_SUNKEN
- : TK_RELIEF_RAISED;
- }
+ : TK_RELIEF_RAISED;
+ }
}
/*
@@ -230,11 +230,11 @@ TkpDisplayButton(
*/
if (butPtr->type == TYPE_BUTTON) {
- Tk_Fill3DRectangle(tkwin, pixmap, butPtr->highlightBorder, 0, 0,
- Tk_Width(tkwin), Tk_Height(tkwin), 0, TK_RELIEF_FLAT);
+ Tk_Fill3DRectangle(tkwin, pixmap, butPtr->highlightBorder, 0, 0,
+ Tk_Width(tkwin), Tk_Height(tkwin), 0, TK_RELIEF_FLAT);
} else {
- Tk_Fill3DRectangle(tkwin, pixmap, butPtr->normalBorder, 0, 0,
- Tk_Width(tkwin), Tk_Height(tkwin), 0, TK_RELIEF_FLAT);
+ Tk_Fill3DRectangle(tkwin, pixmap, butPtr->normalBorder, 0, 0,
+ Tk_Width(tkwin), Tk_Height(tkwin), 0, TK_RELIEF_FLAT);
}
if (butPtr->type == TYPE_LABEL) {
@@ -251,21 +251,21 @@ TkpDisplayButton(
* does not record this call, and so we can't use the
* Appearance bevel button here. The only case that would
* exercise this is if you use a bitmap, with
- * -data & -mask specified. We should probably draw the
+ * -data & -mask specified. We should probably draw the
* appearance button and overprint the image in this case.
* This just punts and draws the old-style, ugly, button.
*/
if (gc->clip_mask == 0) {
- drawType = DRAW_BEVEL;
+ drawType = DRAW_BEVEL;
} else {
- TkpClipMask *clipPtr = (TkpClipMask*) gc->clip_mask;
- if ((clipPtr->type == TKP_CLIP_PIXMAP) &&
- (clipPtr->value.pixmap != butPtr->bitmap)) {
- drawType = DRAW_CUSTOM;
- } else {
- drawType = DRAW_BEVEL;
- }
+ TkpClipMask *clipPtr = (TkpClipMask*) gc->clip_mask;
+ if ((clipPtr->type == TKP_CLIP_PIXMAP) &&
+ (clipPtr->value.pixmap != butPtr->bitmap)) {
+ drawType = DRAW_CUSTOM;
+ } else {
+ drawType = DRAW_BEVEL;
+ }
}
}
} else {
@@ -273,15 +273,15 @@ TkpDisplayButton(
drawType = DRAW_CONTROL;
} else if (hasImageOrBitmap) {
if (gc->clip_mask == 0) {
- drawType = DRAW_BEVEL;
+ drawType = DRAW_BEVEL;
} else {
- TkpClipMask *clipPtr = (TkpClipMask*) gc->clip_mask;
- if ((clipPtr->type == TKP_CLIP_PIXMAP) &&
- (clipPtr->value.pixmap != butPtr->bitmap)) {
- drawType = DRAW_CUSTOM;
- } else {
- drawType = DRAW_BEVEL;
- }
+ TkpClipMask *clipPtr = (TkpClipMask*) gc->clip_mask;
+ if ((clipPtr->type == TKP_CLIP_PIXMAP) &&
+ (clipPtr->value.pixmap != butPtr->bitmap)) {
+ drawType = DRAW_CUSTOM;
+ } else {
+ drawType = DRAW_BEVEL;
+ }
}
} else {
drawType = DRAW_CUSTOM;
@@ -289,13 +289,13 @@ TkpDisplayButton(
}
/*
- * Draw the native portion of the buttons. Start by creating the control
+ * Draw the native portion of the buttons. Start by creating the control
* if it doesn't already exist. Then configure the Macintosh control from
* the Tk info. Finally, we call Draw1Control to draw to the screen.
*/
if ((drawType == DRAW_CONTROL) ||
- ((drawType == DRAW_BEVEL) && TkMacHaveAppearance())) {
+ ((drawType == DRAW_BEVEL) && TkMacHaveAppearance())) {
borderWidth = 0;
/*
@@ -319,7 +319,7 @@ TkpDisplayButton(
*/
if ((drawType == DRAW_BEVEL) && TkMacHaveAppearance()) {
- /* Empty Body */
+ /* Empty Body */
} else if (butPtr->image != None) {
Tk_SizeOfImage(butPtr->image, &width, &height);
@@ -369,12 +369,12 @@ TkpDisplayButton(
/*
* If the button is disabled with a stipple rather than a special
- * foreground color, generate the stippled effect. If the widget
+ * 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.
*/
- if ((butPtr->state == tkDisabledUid)
+ if ((butPtr->state == STATE_DISABLED)
&& ((butPtr->disabledFg == NULL) || (butPtr->image != NULL))) {
if ((butPtr->flags & SELECTED) && !butPtr->indicatorOn
&& (butPtr->selectBorder != NULL)) {
@@ -471,7 +471,7 @@ TkpComputeButtonGeometry(
} else {
Tk_FreeTextLayout(butPtr->textLayout);
butPtr->textLayout = Tk_ComputeTextLayout(butPtr->tkfont,
- butPtr->text, -1, butPtr->wrapLength,
+ Tcl_GetString(butPtr->text), -1, butPtr->wrapLength,
butPtr->justify, 0, &butPtr->textWidth, &butPtr->textHeight);
width = butPtr->textWidth;
@@ -504,7 +504,7 @@ TkpComputeButtonGeometry(
/*
* The width and height calculation for Appearance buttons with images &
- * non-Appearance buttons with images is different. In the latter case,
+ * non-Appearance buttons with images is different. In the latter case,
* we add the borderwidth to the inset, since we are going to stamp a
* 3-D border over the image. In the former, we add it to the height,
* directly, since Appearance will draw the border as part of our control.
@@ -516,7 +516,7 @@ TkpComputeButtonGeometry(
*
* The highlight width corresponds to the default ring on the Macintosh.
* As such, the highlight width is only added if the button is the default
- * button. The actual width of the default ring is one less than the
+ * button. The actual width of the default ring is one less than the
* highlight width as there is also one pixel of spacing.
* Appearance buttons with images do not have a highlight ring, because the
* Bevel button type does not support one.
@@ -528,48 +528,48 @@ TkpComputeButtonGeometry(
}
if ((butPtr->type == TYPE_BUTTON)) {
- if ((butPtr->image == None) && (butPtr->bitmap == None)) {
+ if ((butPtr->image == None) && (butPtr->bitmap == None)) {
+ butPtr->inset = 0;
+ if (butPtr->defaultState != STATE_DISABLED) {
+ butPtr->inset += butPtr->highlightWidth;
+ }
+ } else if (TkMacHaveAppearance()) {
butPtr->inset = 0;
- if (butPtr->defaultState != tkDisabledUid) {
- butPtr->inset += butPtr->highlightWidth;
- }
- } else if (TkMacHaveAppearance()) {
- butPtr->inset = 0;
- width += (2 * butPtr->borderWidth + 4);
- height += (2 * butPtr->borderWidth + 4);
+ width += (2 * butPtr->borderWidth + 4);
+ height += (2 * butPtr->borderWidth + 4);
} else {
- butPtr->inset = butPtr->borderWidth;
- width += 2;
- height += 2;
- if (butPtr->defaultState != tkDisabledUid) {
- butPtr->inset += butPtr->highlightWidth;
- }
- }
+ butPtr->inset = butPtr->borderWidth;
+ width += 2;
+ height += 2;
+ if (butPtr->defaultState != STATE_DISABLED) {
+ butPtr->inset += butPtr->highlightWidth;
+ }
+ }
} else if ((butPtr->type != TYPE_LABEL)) {
- if (butPtr->indicatorOn) {
+ if (butPtr->indicatorOn) {
butPtr->inset = 0;
} else {
- /*
- * Under Appearance, the Checkbutton or radiobutton with an image
- * is represented by a BevelButton with the Sticky defProc...
- * So we must set its height in the same way as the Button
- * with an image or bitmap.
- */
- if (((butPtr->image != None) || (butPtr->bitmap != None))
- && TkMacHaveAppearance()) {
- int border;
- butPtr->inset = 0;
- if ( butPtr->borderWidth <= 2 ) {
- border = 6;
- } else {
- border = 2 * butPtr->borderWidth + 2;
- }
- width += border;
- height += border;
- } else {
- butPtr->inset = butPtr->borderWidth;
- }
- }
+ /*
+ * Under Appearance, the Checkbutton or radiobutton with an image
+ * is represented by a BevelButton with the Sticky defProc...
+ * So we must set its height in the same way as the Button
+ * with an image or bitmap.
+ */
+ if (((butPtr->image != None) || (butPtr->bitmap != None))
+ && TkMacHaveAppearance()) {
+ int border;
+ butPtr->inset = 0;
+ if ( butPtr->borderWidth <= 2 ) {
+ border = 6;
+ } else {
+ border = 2 * butPtr->borderWidth + 2;
+ }
+ width += border;
+ height += border;
+ } else {
+ butPtr->inset = butPtr->borderWidth;
+ }
+ }
} else {
butPtr->inset = butPtr->borderWidth;
}
@@ -629,9 +629,9 @@ DrawBufferedControl(
TkButton *butPtr, /* Tk button. */
GWorldPtr destPort, /* Off screen GWorld. */
GC gc, /* The GC we are drawing into - needed for
- * the bevel button */
+ * the bevel button */
Pixmap pixmap /* The pixmap we are drawing into - needed
- for the bevel button */
+ for the bevel button */
)
{
ControlRef controlHandle;
@@ -641,19 +641,19 @@ DrawBufferedControl(
int isBevel = 0;
if (windowRef == NULL) {
- InitSampleControls();
+ InitSampleControls();
}
/*
* Now swap in the passed in GWorld for the portBits of our fake
- * window. We also adjust various fields in the WindowRecord to make
+ * window. We also adjust various fields in the WindowRecord to make
* the system think this is a normal window.
* Note, we can use DrawControlInCurrentPort under Appearance, so we don't
* need to swap pixmaps.
*/
if (!TkMacHaveAppearance()) {
- ((CWindowPeek) windowRef)->port.portPixMap = destPort->portPixMap;
+ ((CWindowPeek) windowRef)->port.portPixMap = destPort->portPixMap;
}
((CWindowPeek) windowRef)->port.portRect = destPort->portRect;
@@ -665,90 +665,90 @@ DrawBufferedControl(
/*
* Set up control in hidden window to match what we need
- * to draw in the buffered window.
+ * to draw in the buffered window.
*/
isBevel = 0;
switch (butPtr->type) {
case TYPE_BUTTON:
- if (TkMacHaveAppearance()) {
- if ((butPtr->image == None) && (butPtr->bitmap == None)) {
- controlHandle = buttonHandle;
- ccTabHandle = buttonTabHandle;
- } else {
- if (butPtr->borderWidth <= 2) {
- controlHandle = smallBevelHandle;
- } else if (butPtr->borderWidth == 3) {
- controlHandle = medBevelHandle;
- } else {
- controlHandle = largeBevelHandle;
- }
- ccTabHandle = buttonTabHandle;
- SetupBevelButton(butPtr, controlHandle, destPort,
- gc, pixmap);
- isBevel = 1;
- }
+ if (TkMacHaveAppearance()) {
+ if ((butPtr->image == None) && (butPtr->bitmap == None)) {
+ controlHandle = buttonHandle;
+ ccTabHandle = buttonTabHandle;
+ } else {
+ if (butPtr->borderWidth <= 2) {
+ controlHandle = smallBevelHandle;
+ } else if (butPtr->borderWidth == 3) {
+ controlHandle = medBevelHandle;
+ } else {
+ controlHandle = largeBevelHandle;
+ }
+ ccTabHandle = buttonTabHandle;
+ SetupBevelButton(butPtr, controlHandle, destPort,
+ gc, pixmap);
+ isBevel = 1;
+ }
} else {
- controlHandle = buttonHandle;
- ccTabHandle = buttonTabHandle;
+ controlHandle = buttonHandle;
+ ccTabHandle = buttonTabHandle;
}
break;
case TYPE_RADIO_BUTTON:
if (TkMacHaveAppearance()) {
- if (((butPtr->image == None) && (butPtr->bitmap == None))
- || (butPtr->indicatorOn)) {
- controlHandle = radioHandle;
- ccTabHandle = radioTabHandle;
- } else {
- if (butPtr->borderWidth <= 2) {
- controlHandle = smallStickyBevelHandle;
- } else if (butPtr->borderWidth == 3) {
- controlHandle = medStickyBevelHandle;
- } else {
- controlHandle = largeStickyBevelHandle;
- }
- ccTabHandle = radioTabHandle;
- SetupBevelButton(butPtr, controlHandle, destPort,
- gc, pixmap);
- isBevel = 1;
- }
+ if (((butPtr->image == None) && (butPtr->bitmap == None))
+ || (butPtr->indicatorOn)) {
+ controlHandle = radioHandle;
+ ccTabHandle = radioTabHandle;
+ } else {
+ if (butPtr->borderWidth <= 2) {
+ controlHandle = smallStickyBevelHandle;
+ } else if (butPtr->borderWidth == 3) {
+ controlHandle = medStickyBevelHandle;
+ } else {
+ controlHandle = largeStickyBevelHandle;
+ }
+ ccTabHandle = radioTabHandle;
+ SetupBevelButton(butPtr, controlHandle, destPort,
+ gc, pixmap);
+ isBevel = 1;
+ }
} else {
- controlHandle = radioHandle;
- ccTabHandle = radioTabHandle;
- }
+ controlHandle = radioHandle;
+ ccTabHandle = radioTabHandle;
+ }
break;
case TYPE_CHECK_BUTTON:
if (TkMacHaveAppearance()) {
- if (((butPtr->image == None) && (butPtr->bitmap == None))
- || (butPtr->indicatorOn)) {
- controlHandle = checkHandle;
- ccTabHandle = checkTabHandle;
- } else {
- if (butPtr->borderWidth <= 2) {
- controlHandle = smallStickyBevelHandle;
- } else if (butPtr->borderWidth == 3) {
- controlHandle = medStickyBevelHandle;
- } else {
- controlHandle = largeStickyBevelHandle;
- }
- ccTabHandle = checkTabHandle;
- SetupBevelButton(butPtr, controlHandle, destPort,
- gc, pixmap);
- isBevel = 1;
- }
+ if (((butPtr->image == None) && (butPtr->bitmap == None))
+ || (butPtr->indicatorOn)) {
+ controlHandle = checkHandle;
+ ccTabHandle = checkTabHandle;
+ } else {
+ if (butPtr->borderWidth <= 2) {
+ controlHandle = smallStickyBevelHandle;
+ } else if (butPtr->borderWidth == 3) {
+ controlHandle = medStickyBevelHandle;
+ } else {
+ controlHandle = largeStickyBevelHandle;
+ }
+ ccTabHandle = checkTabHandle;
+ SetupBevelButton(butPtr, controlHandle, destPort,
+ gc, pixmap);
+ isBevel = 1;
+ }
} else {
- controlHandle = checkHandle;
- ccTabHandle = checkTabHandle;
- }
+ controlHandle = checkHandle;
+ ccTabHandle = checkTabHandle;
+ }
break;
}
(**controlHandle).contrlRect.left = butPtr->inset;
(**controlHandle).contrlRect.top = butPtr->inset;
(**controlHandle).contrlRect.right = Tk_Width(butPtr->tkwin)
- - butPtr->inset;
+ - butPtr->inset;
(**controlHandle).contrlRect.bottom = Tk_Height(butPtr->tkwin)
- - butPtr->inset;
+ - butPtr->inset;
/*
* Setting the control visibility by hand does not
@@ -756,16 +756,16 @@ DrawBufferedControl(
*/
if (TkMacHaveAppearance()) {
- SetControlVisibility(controlHandle, true, false);
- (**userPaneHandle).contrlRect.left = 0;
- (**userPaneHandle).contrlRect.top = 0;
- (**userPaneHandle).contrlRect.right = Tk_Width(butPtr->tkwin);
- (**userPaneHandle).contrlRect.bottom = Tk_Height(butPtr->tkwin);
- } else {
- (**controlHandle).contrlVis = 255;
- }
+ SetControlVisibility(controlHandle, true, false);
+ (**userPaneHandle).contrlRect.left = 0;
+ (**userPaneHandle).contrlRect.top = 0;
+ (**userPaneHandle).contrlRect.right = Tk_Width(butPtr->tkwin);
+ (**userPaneHandle).contrlRect.bottom = Tk_Height(butPtr->tkwin);
+ } else {
+ (**controlHandle).contrlVis = 255;
+ }
-
+
if (butPtr->flags & SELECTED) {
(**controlHandle).contrlValue = 1;
@@ -773,23 +773,23 @@ DrawBufferedControl(
(**controlHandle).contrlValue = 0;
}
- if (butPtr->state == tkActiveUid) {
- if (isBevel) {
- (**controlHandle).contrlHilite = kControlButtonPart;
- } else {
+ if (butPtr->state == STATE_ACTIVE) {
+ if (isBevel) {
+ (**controlHandle).contrlHilite = kControlButtonPart;
+ } else {
switch (butPtr->type) {
- case TYPE_BUTTON:
+ case TYPE_BUTTON:
(**controlHandle).contrlHilite = kControlButtonPart;
break;
- case TYPE_RADIO_BUTTON:
+ case TYPE_RADIO_BUTTON:
(**controlHandle).contrlHilite = kControlRadioButtonPart;
break;
- case TYPE_CHECK_BUTTON:
+ case TYPE_CHECK_BUTTON:
(**controlHandle).contrlHilite = kControlCheckBoxPart;
break;
}
}
- } else if (butPtr->state == tkDisabledUid) {
+ } else if (butPtr->state == STATE_DISABLED) {
(**controlHandle).contrlHilite = kControlInactivePart;
} else {
(**controlHandle).contrlHilite = kControlNoPart;
@@ -815,36 +815,36 @@ DrawBufferedControl(
*/
if (TkMacHaveAppearance()) {
- SetPort((GrafPort *) destPort);
+ SetPort((GrafPort *) destPort);
} else {
- SetPort(windowRef);
+ SetPort(windowRef);
}
windowColorChanged = UpdateControlColors(butPtr, controlHandle,
- ccTabHandle, &saveBackColor);
+ ccTabHandle, &saveBackColor);
if ((butPtr->type == TYPE_BUTTON) && TkMacHaveAppearance()) {
- Boolean isDefault;
-
- if (butPtr->defaultState == tkActiveUid) {
+ Boolean isDefault;
+
+ if (butPtr->defaultState == STATE_ACTIVE) {
isDefault = true;
} else {
isDefault = false;
}
SetControlData(controlHandle, kControlNoPart,
- kControlPushButtonDefaultTag,
- sizeof(isDefault), (Ptr) &isDefault);
+ kControlPushButtonDefaultTag,
+ sizeof(isDefault), (Ptr) &isDefault);
}
if (TkMacHaveAppearance()) {
- DrawControlInCurrentPort(userPaneHandle);
+ DrawControlInCurrentPort(userPaneHandle);
} else {
- Draw1Control(controlHandle);
+ Draw1Control(controlHandle);
}
if (!TkMacHaveAppearance() &&
- (butPtr->type == TYPE_BUTTON) &&
- (butPtr->defaultState == tkActiveUid)) {
+ (butPtr->type == TYPE_BUTTON) &&
+ (butPtr->defaultState == STATE_ACTIVE)) {
Rect box = (**controlHandle).contrlRect;
RGBColor rgbColor;
@@ -866,13 +866,13 @@ DrawBufferedControl(
*/
if (TkMacHaveAppearance()) {
- SetControlVisibility(controlHandle, false, false);
- if (isBevel) {
- KillPicture(bevelButtonContent.u.picture);
- }
- } else {
- (**controlHandle).contrlVis = 0;
- }
+ SetControlVisibility(controlHandle, false, false);
+ if (isBevel) {
+ KillPicture(bevelButtonContent.u.picture);
+ }
+ } else {
+ (**controlHandle).contrlVis = 0;
+ }
LMSetWindowList((WindowRef) ((CWindowPeek) windowRef)->nextWindow);
}
@@ -882,8 +882,8 @@ DrawBufferedControl(
* InitSampleControls --
*
* This function initializes a dummy Macintosh window and
- * sample controls to allow drawing Mac controls to any GWorld
- * (including off-screen bitmaps).
+ * sample controls to allow drawing Mac controls to any GWorld
+ * (including off-screen bitmaps).
*
* Results:
* None.
@@ -907,9 +907,9 @@ InitSampleControls()
* the data structures attached to it are only deallocated
* on exit of the application.
*/
-
+
windowRef = NewCWindow(NULL, &geometry, "\pempty", false,
- zoomDocProc, (WindowRef) -1, true, 0);
+ zoomDocProc, (WindowRef) -1, true, 0);
if (windowRef == NULL) {
panic("Can't allocate buffer window.");
}
@@ -926,15 +926,15 @@ InitSampleControls()
SetPort(windowRef);
if (TkMacHaveAppearance()) {
- OSErr err;
- ControlRef dontCare;
-
- /*
- * Adding UserPaneBackgroundProcs to the root control does
- * not seem to work, so we have to add another UserPane to
- * the root control.
- */
-
+
+ OSErr err;
+ ControlRef dontCare;
+
+ /* Adding UserPaneBackgroundProcs to the root control does
+ * not seem to work, so we have to add another UserPane to
+ * the root control.
+ */
+
err = CreateRootControl(windowRef, &dontCare);
if (err != noErr) {
panic("Can't create root control in DrawBufferedControl");
@@ -942,60 +942,66 @@ InitSampleControls()
userPaneHandle = NewControl(windowRef, &geometry, "\p",
true, kControlSupportsEmbedding|kControlHasSpecialBackground,
- 0, 1, kControlUserPaneProc, (SInt32) 0);
+ 0, 1, kControlUserPaneProc, (SInt32) 0);
SetUserPaneSetUpSpecialBackgroundProc(userPaneHandle,
UserPaneBackgroundProc);
SetUserPaneDrawProc(userPaneHandle, UserPaneDraw);
buttonHandle = NewControl(windowRef, &geometry, "\p",
- false, 1, 0, 1, kControlPushButtonProc, (SInt32) 0);
+ false, 1, 0, 1, kControlPushButtonProc, (SInt32) 0);
EmbedControl(buttonHandle, userPaneHandle);
- checkHandle = NewControl(windowRef, &geometry, "\p",
- false, 1, 0, 1, kControlCheckBoxProc, (SInt32) 0);
+ checkHandle = NewControl(windowRef, &geometry, "\p",
+ false, 1, 0, 1, kControlCheckBoxProc, (SInt32) 0);
EmbedControl(checkHandle, userPaneHandle);
- radioHandle = NewControl(windowRef, &geometry, "\p",
- false, 1, 0, 1, kControlRadioButtonProc, (SInt32) 0);
+ radioHandle = NewControl(windowRef, &geometry, "\p",
+ false, 1, 0, 1, kControlRadioButtonProc, (SInt32) 0);
EmbedControl(radioHandle, userPaneHandle);
- smallBevelHandle = NewControl(windowRef, &geometry, "\p",
- false, 0, 0,
- kControlBehaviorOffsetContents << 16 | kControlContentPictHandle,
- kControlBevelButtonSmallBevelProc, (SInt32) 0);
- EmbedControl(smallBevelHandle, userPaneHandle);
- medBevelHandle = NewControl(windowRef, &geometry, "\p",
- false, 0, 0,
- kControlBehaviorOffsetContents << 16 | kControlContentPictHandle,
- kControlBevelButtonNormalBevelProc, (SInt32) 0);
- EmbedControl(medBevelHandle, userPaneHandle);
- largeBevelHandle = NewControl(windowRef, &geometry, "\p",
- false, 0, 0,
- kControlBehaviorOffsetContents << 16 | kControlContentPictHandle,
- kControlBevelButtonLargeBevelProc, (SInt32) 0);
- EmbedControl(largeBevelHandle, userPaneHandle);
- bevelButtonContent.contentType = kControlContentPictHandle;
- smallStickyBevelHandle = NewControl(windowRef, &geometry, "\p",
- false, 0, 0,
- (kControlBehaviorOffsetContents | kControlBehaviorSticky) << 16
- | kControlContentPictHandle,
- kControlBevelButtonSmallBevelProc, (SInt32) 0);
- EmbedControl(smallStickyBevelHandle, userPaneHandle);
- medStickyBevelHandle = NewControl(windowRef, &geometry, "\p",
- false, 0, 0,
- (kControlBehaviorOffsetContents | kControlBehaviorSticky) << 16
- | kControlContentPictHandle,
- kControlBevelButtonNormalBevelProc, (SInt32) 0);
- EmbedControl(medStickyBevelHandle, userPaneHandle);
- largeStickyBevelHandle = NewControl(windowRef, &geometry, "\p",
- false, 0, 0,
- (kControlBehaviorOffsetContents | kControlBehaviorSticky) << 16
- | kControlContentPictHandle,
- kControlBevelButtonLargeBevelProc, (SInt32) 0);
- EmbedControl(largeStickyBevelHandle, userPaneHandle);
+ smallBevelHandle = NewControl(windowRef, &geometry, "\p",
+ false, 0, 0,
+ kControlBehaviorOffsetContents << 16
+ | kControlContentPictHandle,
+ kControlBevelButtonSmallBevelProc, (SInt32) 0);
+ EmbedControl(smallBevelHandle, userPaneHandle);
+ medBevelHandle = NewControl(windowRef, &geometry, "\p",
+ false, 0, 0,
+ kControlBehaviorOffsetContents << 16
+ | kControlContentPictHandle,
+ kControlBevelButtonNormalBevelProc, (SInt32) 0);
+ EmbedControl(medBevelHandle, userPaneHandle);
+ largeBevelHandle = NewControl(windowRef, &geometry, "\p",
+ false, 0, 0,
+ kControlBehaviorOffsetContents << 16
+ | kControlContentPictHandle,
+ kControlBevelButtonLargeBevelProc, (SInt32) 0);
+ EmbedControl(largeBevelHandle, userPaneHandle);
+ bevelButtonContent.contentType = kControlContentPictHandle;
+ smallStickyBevelHandle = NewControl(windowRef, &geometry, "\p",
+ false, 0, 0,
+ (kControlBehaviorOffsetContents
+ | kControlBehaviorSticky) << 16
+ | kControlContentPictHandle,
+ kControlBevelButtonSmallBevelProc, (SInt32) 0);
+ EmbedControl(smallStickyBevelHandle, userPaneHandle);
+ medStickyBevelHandle = NewControl(windowRef, &geometry, "\p",
+ false, 0, 0,
+ (kControlBehaviorOffsetContents
+ | kControlBehaviorSticky) << 16
+ | kControlContentPictHandle,
+ kControlBevelButtonNormalBevelProc, (SInt32) 0);
+ EmbedControl(medStickyBevelHandle, userPaneHandle);
+ largeStickyBevelHandle = NewControl(windowRef, &geometry, "\p",
+ false, 0, 0,
+ (kControlBehaviorOffsetContents
+ | kControlBehaviorSticky) << 16
+ | kControlContentPictHandle,
+ kControlBevelButtonLargeBevelProc, (SInt32) 0);
+ EmbedControl(largeStickyBevelHandle, userPaneHandle);
- picParams.version = -2;
- picParams.hRes = 0x00480000;
- picParams.vRes = 0x00480000;
- picParams.srcRect.top = 0;
- picParams.srcRect.left = 0;
+ picParams.version = -2;
+ picParams.hRes = 0x00480000;
+ picParams.vRes = 0x00480000;
+ picParams.srcRect.top = 0;
+ picParams.srcRect.left = 0;
((CWindowPeek) windowRef)->visible = true;
} else {
@@ -1013,8 +1019,8 @@ InitSampleControls()
}
/*
- * Remove our window from the window list. This way our
- * applications ad others will not be confused that this
+ * Remove our window from the window list. This way our
+ * applications and others will not be confused that this
* window exists - but no one knows about it.
*/
@@ -1040,9 +1046,9 @@ InitSampleControls()
* TODO: The ButtonExitProc doesn't currently work and the
* code it includes will crash the Mac on exit from Tk.
- oldPixPtr = ((CWindowPeek) windowRef)->port.portPixMap;
- Tcl_CreateExitHandler(ButtonExitProc, (ClientData) NULL);
- */
+ oldPixPtr = ((CWindowPeek) windowRef)->port.portPixMap;
+ Tcl_CreateExitHandler(ButtonExitProc, (ClientData) NULL);
+ */
}
@@ -1065,12 +1071,12 @@ InitSampleControls()
void
SetupBevelButton(
TkButton *butPtr, /* Tk button. */
- ControlRef controlHandle, /* The control to set this picture to */
+ ControlRef controlHandle, /* The control to set this picture to */
GWorldPtr destPort, /* Off screen GWorld. */
GC gc, /* The GC we are drawing into - needed for
- * the bevel button */
+ * the bevel button */
Pixmap pixmap /* The pixmap we are drawing into - needed
- for the bevel button */
+ for the bevel button */
)
{
int height, width;
@@ -1079,13 +1085,13 @@ SetupBevelButton(
SetPort((GrafPtr) destPort);
if (butPtr->image != None) {
- Tk_SizeOfImage(butPtr->image,
- &width, &height);
+ Tk_SizeOfImage(butPtr->image,
+ &width, &height);
} else {
- Tk_SizeOfBitmap(butPtr->display, butPtr->bitmap,
- &width, &height);
+ Tk_SizeOfBitmap(butPtr->display, butPtr->bitmap,
+ &width, &height);
}
-
+
if ((butPtr->width > 0) && (butPtr->width < width)) {
width = butPtr->width;
}
@@ -1105,48 +1111,48 @@ SetupBevelButton(
*/
if ((butPtr->selectImage != NULL) && (butPtr->flags & SELECTED)) {
- Tk_RedrawImage(butPtr->selectImage, 0, 0, width, height,
- pixmap, 0, 0);
+ Tk_RedrawImage(butPtr->selectImage, 0, 0, width, height,
+ pixmap, 0, 0);
} else if (butPtr->image != NULL) {
- Tk_RedrawImage(butPtr->image, 0, 0, width,
- height, pixmap, 0, 0);
- } else {
- XSetClipOrigin(butPtr->display, gc, 0, 0);
- XCopyPlane(butPtr->display, butPtr->bitmap, pixmap, gc, 0, 0,
- (unsigned int) width, (unsigned int) height, 0, 0, 1);
+ Tk_RedrawImage(butPtr->image, 0, 0, width,
+ height, pixmap, 0, 0);
+ } else {
+ XSetClipOrigin(butPtr->display, gc, 0, 0);
+ XCopyPlane(butPtr->display, butPtr->bitmap, pixmap, gc, 0, 0,
+ (unsigned int) width, (unsigned int) height, 0, 0, 1);
}
ClosePicture();
SetControlData(controlHandle, kControlButtonPart,
- kControlBevelButtonContentTag,
- sizeof(ControlButtonContentInfo),
- (char *) &bevelButtonContent);
-
+ kControlBevelButtonContentTag,
+ sizeof(ControlButtonContentInfo),
+ (char *) &bevelButtonContent);
+
if (butPtr->anchor == TK_ANCHOR_N) {
- theAlignment = kControlBevelButtonAlignTop;
- } else if (butPtr->anchor == TK_ANCHOR_NE) {
- theAlignment = kControlBevelButtonAlignTopRight;
- } else if (butPtr->anchor == TK_ANCHOR_E) {
- theAlignment = kControlBevelButtonAlignRight;
- } else if (butPtr->anchor == TK_ANCHOR_SE) {
- theAlignment = kControlBevelButtonAlignBottomRight;
- } else if (butPtr->anchor == TK_ANCHOR_S) {
- theAlignment = kControlBevelButtonAlignBottom;
- } else if (butPtr->anchor == TK_ANCHOR_SW) {
- theAlignment = kControlBevelButtonAlignBottomLeft;
- } else if (butPtr->anchor == TK_ANCHOR_W) {
- theAlignment = kControlBevelButtonAlignLeft;
- } else if (butPtr->anchor == TK_ANCHOR_NW) {
- theAlignment = kControlBevelButtonAlignTopLeft;
- } else if (butPtr->anchor == TK_ANCHOR_CENTER) {
- theAlignment = kControlBevelButtonAlignCenter;
+ theAlignment = kControlBevelButtonAlignTop;
+ } else if (butPtr->anchor == TK_ANCHOR_NE) {
+ theAlignment = kControlBevelButtonAlignTopRight;
+ } else if (butPtr->anchor == TK_ANCHOR_E) {
+ theAlignment = kControlBevelButtonAlignRight;
+ } else if (butPtr->anchor == TK_ANCHOR_SE) {
+ theAlignment = kControlBevelButtonAlignBottomRight;
+ } else if (butPtr->anchor == TK_ANCHOR_S) {
+ theAlignment = kControlBevelButtonAlignBottom;
+ } else if (butPtr->anchor == TK_ANCHOR_SW) {
+ theAlignment = kControlBevelButtonAlignBottomLeft;
+ } else if (butPtr->anchor == TK_ANCHOR_W) {
+ theAlignment = kControlBevelButtonAlignLeft;
+ } else if (butPtr->anchor == TK_ANCHOR_NW) {
+ theAlignment = kControlBevelButtonAlignTopLeft;
+ } else if (butPtr->anchor == TK_ANCHOR_CENTER) {
+ theAlignment = kControlBevelButtonAlignCenter;
}
SetControlData(controlHandle, kControlButtonPart,
- kControlBevelButtonGraphicAlignTag,
- sizeof(ControlButtonGraphicAlignment),
- (char *) &theAlignment);
+ kControlBevelButtonGraphicAlignTag,
+ sizeof(ControlButtonGraphicAlignment),
+ (char *) &theAlignment);
}
@@ -1156,8 +1162,8 @@ SetupBevelButton(
* SetUserPaneDrawProc --
*
* Utility function to add a UserPaneDrawProc
- * to a userPane control. From MoreControls code
- * from Apple DTS.
+ * to a userPane control. From MoreControls code
+ * from Apple DTS.
*
* Results:
* MacOS system error.
@@ -1168,15 +1174,15 @@ SetupBevelButton(
*--------------------------------------------------------------
*/
pascal OSErr SetUserPaneDrawProc (
- ControlRef control,
- ControlUserPaneDrawProcPtr upp)
+ ControlRef control,
+ ControlUserPaneDrawProcPtr upp)
{
ControlUserPaneDrawUPP myControlUserPaneDrawUPP;
myControlUserPaneDrawUPP = NewControlUserPaneDrawProc(upp);
return SetControlData (control,
- kControlNoPart, kControlUserPaneDrawProcTag,
- sizeof(myControlUserPaneDrawUPP),
- (Ptr) &myControlUserPaneDrawUPP);
+ kControlNoPart, kControlUserPaneDrawProcTag,
+ sizeof(myControlUserPaneDrawUPP),
+ (Ptr) &myControlUserPaneDrawUPP);
}
/*
@@ -1185,7 +1191,7 @@ pascal OSErr SetUserPaneDrawProc (
* SetUserPaneSetUpSpecialBackgroundProc --
*
* Utility function to add a UserPaneBackgroundProc
- * to a userPane control
+ * to a userPane control
*
* Results:
* MacOS system error.
@@ -1203,9 +1209,9 @@ SetUserPaneSetUpSpecialBackgroundProc(
ControlUserPaneBackgroundUPP myControlUserPaneBackgroundUPP;
myControlUserPaneBackgroundUPP = NewControlUserPaneBackgroundProc(upp);
return SetControlData (control, kControlNoPart,
- kControlUserPaneBackgroundProcTag,
- sizeof(myControlUserPaneBackgroundUPP),
- (Ptr) &myControlUserPaneBackgroundUPP);
+ kControlUserPaneBackgroundProcTag,
+ sizeof(myControlUserPaneBackgroundUPP),
+ (Ptr) &myControlUserPaneBackgroundUPP);
}
/*
@@ -1214,7 +1220,7 @@ SetUserPaneSetUpSpecialBackgroundProc(
* UserPaneDraw --
*
* This function draws the background of the user pane that will
- * lie under checkboxes and radiobuttons.
+ * lie under checkboxes and radiobuttons.
*
* Results:
* None.
@@ -1229,9 +1235,9 @@ UserPaneDraw(
ControlRef control,
ControlPartCode cpc)
{
- Rect contrlRect = (**control).contrlRect;
- RGBBackColor (&gUserPaneBackground);
- EraseRect (&contrlRect);
+ Rect contrlRect = (**control).contrlRect;
+ RGBBackColor (&gUserPaneBackground);
+ EraseRect (&contrlRect);
}
/*
@@ -1240,7 +1246,7 @@ UserPaneDraw(
* UserPaneBackgroundProc --
*
* This function sets up the background of the user pane that will
- * lie under checkboxes and radiobuttons.
+ * lie under checkboxes and radiobuttons.
*
* Results:
* None.
@@ -1257,7 +1263,7 @@ UserPaneBackgroundProc(
ControlBackgroundPtr info)
{
if (info->colorDevice) {
- RGBBackColor (&gUserPaneBackground);
+ RGBBackColor (&gUserPaneBackground);
}
}
@@ -1271,8 +1277,8 @@ UserPaneBackgroundProc(
* used we create a custom palette for the button, populate
* with the colors for the button and install the palette.
*
- * Under Appearance, we just set the pointer that will be
- * used by the UserPaneDrawProc.
+ * Under Appearance, we just set the pointer that will be
+ * used by the UserPaneDrawProc.
*
* Results:
* None.
@@ -1295,7 +1301,7 @@ UpdateControlColors(
/*
* Under Appearance we cannot change the background of the
* button itself. However, the color we are setting is the color
- * of the containing userPane. This will be the color that peeks
+ * of the containing userPane. This will be the color that peeks
* around the rounded corners of the button.
* We make this the highlightbackground rather than the background,
* because if you color the background of a frame containing a
@@ -1304,38 +1310,37 @@ UpdateControlColors(
*/
if (TkMacHaveAppearance() && (butPtr->type == TYPE_BUTTON)) {
- xcolor = Tk_3DBorderColor(butPtr->highlightBorder);
+ xcolor = Tk_3DBorderColor(butPtr->highlightBorder);
} else {
- xcolor = Tk_3DBorderColor(butPtr->normalBorder);
+ xcolor = Tk_3DBorderColor(butPtr->normalBorder);
}
if (TkMacHaveAppearance()) {
- TkSetMacColor(xcolor->pixel, &gUserPaneBackground);
+ TkSetMacColor(xcolor->pixel, &gUserPaneBackground);
} else {
(**ccTabHandle).ccSeed = 0;
- (**ccTabHandle).ccRider = 0;
- (**ccTabHandle).ctSize = 3;
- (**ccTabHandle).ctTable[0].value = cBodyColor;
- TkSetMacColor(xcolor->pixel,
+ (**ccTabHandle).ccRider = 0;
+ (**ccTabHandle).ctSize = 3;
+ (**ccTabHandle).ctTable[0].value = cBodyColor;
+ TkSetMacColor(xcolor->pixel,
&(**ccTabHandle).ctTable[0].rgb);
- (**ccTabHandle).ctTable[1].value = cTextColor;
- TkSetMacColor(butPtr->normalFg->pixel,
+ (**ccTabHandle).ctTable[1].value = cTextColor;
+ TkSetMacColor(butPtr->normalFg->pixel,
&(**ccTabHandle).ctTable[1].rgb);
- (**ccTabHandle).ctTable[2].value = cFrameColor;
- TkSetMacColor(butPtr->highlightColorPtr->pixel,
+ (**ccTabHandle).ctTable[2].value = cFrameColor;
+ TkSetMacColor(butPtr->highlightColorPtr->pixel,
&(**ccTabHandle).ctTable[2].rgb);
- SetControlColor(controlHandle, ccTabHandle);
-
- if (((xcolor->pixel >> 24) != CONTROL_BODY_PIXEL) &&
- ((butPtr->type == TYPE_CHECK_BUTTON) ||
- (butPtr->type == TYPE_RADIO_BUTTON))) {
+ SetControlColor(controlHandle, ccTabHandle);
+
+ if (((xcolor->pixel >> 24) != CONTROL_BODY_PIXEL) &&
+ ((butPtr->type == TYPE_CHECK_BUTTON) ||
+ (butPtr->type == TYPE_RADIO_BUTTON))) {
RGBColor newColor;
- if (TkSetMacColor(xcolor->pixel, &newColor)) {
- ChangeBackgroundWindowColor((**controlHandle).contrlOwner,
- newColor, saveColorPtr);
- }
+ TkSetMacColor(xcolor->pixel, &newColor);
+ ChangeBackgroundWindowColor((**controlHandle).contrlOwner,
+ newColor, saveColorPtr);
return true;
- }
+ }
}
return false;
@@ -1348,7 +1353,7 @@ UpdateControlColors(
*
* This procedure will change the background color entry
* in the Window's colortable. The system isn't notified
- * of the change. This call should only be used to fool
+ * of the change. This call should only be used to fool
* the drawing routines for checkboxes and radiobuttons.
* Any change should be temporary and be reverted after
* the widget is drawn.
@@ -1422,7 +1427,7 @@ ButtonExitProc(clientData)
/*
* Restore our dummy window to it's origional state by putting it
- * back in the window list and restoring it's bits. The destroy
+ * back in the window list and restoring it's bits. The destroy
* the controls and window.
*/