OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [tags/] [start/] [insight/] [tk/] [mac/] [tkMacButton.c] - Diff between revs 579 and 1765

Go to most recent revision | Only display areas with differences | Details | Blame | View Log

Rev 579 Rev 1765
/*
/*
 * tkMacButton.c --
 * tkMacButton.c --
 *
 *
 *      This file implements the Macintosh specific portion of the
 *      This file implements the Macintosh specific portion of the
 *      button widgets.
 *      button widgets.
 *
 *
 * Copyright (c) 1996-1997 by Sun Microsystems, Inc.
 * Copyright (c) 1996-1997 by Sun Microsystems, Inc.
 *
 *
 * See the file "license.terms" for information on usage and redistribution
 * See the file "license.terms" for information on usage and redistribution
 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
 *
 *
 * RCS: @(#) $Id: tkMacButton.c,v 1.1.1.1 2002-01-16 10:25:55 markom Exp $
 * RCS: @(#) $Id: tkMacButton.c,v 1.1.1.1 2002-01-16 10:25:55 markom Exp $
 */
 */
 
 
#include "tkButton.h"
#include "tkButton.h"
#include "tkMacInt.h"
#include "tkMacInt.h"
#include <Controls.h>
#include <Controls.h>
#include <LowMem.h>
#include <LowMem.h>
#include <Appearance.h>
#include <Appearance.h>
 
 
 
 
#include <ToolUtils.h>
#include <ToolUtils.h>
 
 
/*
/*
 * Some defines used to control what type of control is drawn.
 * Some defines used to control what type of control is drawn.
 */
 */
 
 
#define DRAW_LABEL      0                /* Labels are treated genericly. */
#define DRAW_LABEL      0                /* Labels are treated genericly. */
#define DRAW_CONTROL    1               /* Draw using the Native control. */
#define DRAW_CONTROL    1               /* Draw using the Native control. */
#define DRAW_CUSTOM     2               /* Make our own button drawing. */
#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
 * The following structures are used to draw our controls.  Rather than
 * having many Mac controls we just use one control of each type and
 * having many Mac controls we just use one control of each type and
 * reuse them for all Tk widgets.  When the windowRef variable is NULL
 * reuse them for all Tk widgets.  When the windowRef variable is NULL
 * it means none of the data structures have been allocated.
 * it means none of the data structures have been allocated.
 */
 */
 
 
static WindowRef windowRef = NULL;
static WindowRef windowRef = NULL;
static CWindowRecord windowRecord;
static CWindowRecord windowRecord;
static ControlRef buttonHandle;
static ControlRef buttonHandle;
static ControlRef checkHandle;
static ControlRef checkHandle;
static ControlRef radioHandle;
static ControlRef radioHandle;
static ControlRef smallBevelHandle;
static ControlRef smallBevelHandle;
static ControlRef smallStickyBevelHandle;
static ControlRef smallStickyBevelHandle;
static ControlRef medBevelHandle;
static ControlRef medBevelHandle;
static ControlRef medStickyBevelHandle;
static ControlRef medStickyBevelHandle;
static ControlRef largeBevelHandle;
static ControlRef largeBevelHandle;
static ControlRef largeStickyBevelHandle;
static ControlRef largeStickyBevelHandle;
 
 
/*
/*
 * These are used to store the image content for
 * These are used to store the image content for
 * beveled buttons - i.e. buttons with images.
 * beveled buttons - i.e. buttons with images.
 */
 */
 
 
static ControlButtonContentInfo bevelButtonContent;
static ControlButtonContentInfo bevelButtonContent;
static OpenCPicParams picParams;
static OpenCPicParams picParams;
 
 
static CCTabHandle buttonTabHandle;
static CCTabHandle buttonTabHandle;
static CCTabHandle checkTabHandle;
static CCTabHandle checkTabHandle;
static CCTabHandle radioTabHandle;
static CCTabHandle radioTabHandle;
static PixMapHandle oldPixPtr;
static PixMapHandle oldPixPtr;
 
 
/*
/*
 * These functions are used when Appearance is present.
 * These functions are used when Appearance is present.
 * By embedding all our controls in a userPane control,
 * By embedding all our controls in a userPane control,
 * we can color the background of the text in radiobuttons
 * we can color the background of the text in radiobuttons
 * and checkbuttons.  Thanks to Peter Gontier of Apple DTS
 * and checkbuttons.  Thanks to Peter Gontier of Apple DTS
 * for help on this one.
 * for help on this one.
 */
 */
 
 
static ControlRef userPaneHandle;
static ControlRef userPaneHandle;
static RGBColor gUserPaneBackground = { ~0, ~0, ~0};
static RGBColor gUserPaneBackground = { ~0, ~0, ~0};
static pascal OSErr SetUserPaneDrawProc(ControlRef control,
static pascal OSErr SetUserPaneDrawProc(ControlRef control,
        ControlUserPaneDrawProcPtr upp);
        ControlUserPaneDrawProcPtr upp);
static pascal OSErr SetUserPaneSetUpSpecialBackgroundProc(ControlRef control,
static pascal OSErr SetUserPaneSetUpSpecialBackgroundProc(ControlRef control,
        ControlUserPaneBackgroundProcPtr upp);
        ControlUserPaneBackgroundProcPtr upp);
static pascal void UserPaneDraw(ControlRef control, ControlPartCode cpc);
static pascal void UserPaneDraw(ControlRef control, ControlPartCode cpc);
static pascal void UserPaneBackgroundProc(ControlHandle,
static pascal void UserPaneBackgroundProc(ControlHandle,
        ControlBackgroundPtr info);
        ControlBackgroundPtr info);
 
 
/*
/*
 * Forward declarations for procedures defined later in this file:
 * Forward declarations for procedures defined later in this file:
 */
 */
 
 
static int      UpdateControlColors _ANSI_ARGS_((TkButton *butPtr,
static int      UpdateControlColors _ANSI_ARGS_((TkButton *butPtr,
                            ControlRef controlHandle, CCTabHandle ccTabHandle,
                            ControlRef controlHandle, CCTabHandle ccTabHandle,
                            RGBColor *saveColorPtr));
                            RGBColor *saveColorPtr));
static void     DrawBufferedControl _ANSI_ARGS_((TkButton *butPtr,
static void     DrawBufferedControl _ANSI_ARGS_((TkButton *butPtr,
                    GWorldPtr destPort, GC gc, Pixmap pixmap));
                    GWorldPtr destPort, GC gc, Pixmap pixmap));
static void     InitSampleControls();
static void     InitSampleControls();
static void     SetupBevelButton _ANSI_ARGS_((TkButton *butPtr,
static void     SetupBevelButton _ANSI_ARGS_((TkButton *butPtr,
                    ControlRef controlHandle,
                    ControlRef controlHandle,
                    GWorldPtr destPort, GC gc, Pixmap pixmap));
                    GWorldPtr destPort, GC gc, Pixmap pixmap));
static void     ChangeBackgroundWindowColor _ANSI_ARGS_((
static void     ChangeBackgroundWindowColor _ANSI_ARGS_((
                            WindowRef macintoshWindow, RGBColor rgbColor,
                            WindowRef macintoshWindow, RGBColor rgbColor,
                            RGBColor *oldColor));
                            RGBColor *oldColor));
static void     ButtonExitProc _ANSI_ARGS_((ClientData clientData));
static void     ButtonExitProc _ANSI_ARGS_((ClientData clientData));
 
 
/*
/*
 * The class procedure table for the button widgets.
 * The class procedure table for the button widgets.
 */
 */
 
 
TkClassProcs tkpButtonProcs = {
TkClassProcs tkpButtonProcs = {
    NULL,                       /* createProc. */
    NULL,                       /* createProc. */
    TkButtonWorldChanged,       /* geometryProc. */
    TkButtonWorldChanged,       /* geometryProc. */
    NULL                        /* modalProc. */
    NULL                        /* modalProc. */
};
};


/*
/*
 *----------------------------------------------------------------------
 *----------------------------------------------------------------------
 *
 *
 * TkpCreateButton --
 * TkpCreateButton --
 *
 *
 *      Allocate a new TkButton structure.
 *      Allocate a new TkButton structure.
 *
 *
 * Results:
 * Results:
 *      Returns a newly allocated TkButton structure.
 *      Returns a newly allocated TkButton structure.
 *
 *
 * Side effects:
 * Side effects:
 *      Registers an event handler for the widget.
 *      Registers an event handler for the widget.
 *
 *
 *----------------------------------------------------------------------
 *----------------------------------------------------------------------
 */
 */
 
 
TkButton *
TkButton *
TkpCreateButton(
TkpCreateButton(
    Tk_Window tkwin)
    Tk_Window tkwin)
{
{
    return (TkButton *) ckalloc(sizeof(TkButton));
    return (TkButton *) ckalloc(sizeof(TkButton));
}
}


/*
/*
 *----------------------------------------------------------------------
 *----------------------------------------------------------------------
 *
 *
 * TkpDisplayButton --
 * TkpDisplayButton --
 *
 *
 *      This procedure is invoked to display a button widget.  It is
 *      This procedure is invoked to display a button widget.  It is
 *      normally invoked as an idle handler.
 *      normally invoked as an idle handler.
 *
 *
 * Results:
 * Results:
 *      None.
 *      None.
 *
 *
 * Side effects:
 * Side effects:
 *      Commands are output to X to display the button in its
 *      Commands are output to X to display the button in its
 *      current mode.  The REDRAW_PENDING flag is cleared.
 *      current mode.  The REDRAW_PENDING flag is cleared.
 *
 *
 *----------------------------------------------------------------------
 *----------------------------------------------------------------------
 */
 */
 
 
void
void
TkpDisplayButton(
TkpDisplayButton(
    ClientData clientData)      /* Information about widget. */
    ClientData clientData)      /* Information about widget. */
{
{
    TkButton *butPtr = (TkButton *) clientData;
    TkButton *butPtr = (TkButton *) clientData;
    Pixmap pixmap;
    Pixmap pixmap;
    GC gc;
    GC gc;
    Tk_3DBorder border;
    Tk_3DBorder border;
    int x = 0;                   /* Initialization only needed to stop
    int x = 0;                   /* Initialization only needed to stop
                                 * compiler warning. */
                                 * compiler warning. */
    int y, relief;
    int y, relief;
    register Tk_Window tkwin = butPtr->tkwin;
    register Tk_Window tkwin = butPtr->tkwin;
    int width, height;
    int width, height;
    int offset;                 /* 0 means this is a normal widget.  1 means
    int offset;                 /* 0 means this is a normal widget.  1 means
                                 * it is an image button, so we offset the
                                 * it is an image button, so we offset the
                                 * image to make the button appear to move
                                 * image to make the button appear to move
                                 * up and down as the relief changes. */
                                 * up and down as the relief changes. */
    int hasImageOrBitmap;
    int hasImageOrBitmap;
    CGrafPtr saveWorld;
    CGrafPtr saveWorld;
    GDHandle saveDevice;
    GDHandle saveDevice;
    GWorldPtr destPort;
    GWorldPtr destPort;
    int drawType, borderWidth;
    int drawType, borderWidth;
 
 
    GetGWorld(&saveWorld, &saveDevice);
    GetGWorld(&saveWorld, &saveDevice);
 
 
    butPtr->flags &= ~REDRAW_PENDING;
    butPtr->flags &= ~REDRAW_PENDING;
    if ((butPtr->tkwin == NULL) || !Tk_IsMapped(tkwin)) {
    if ((butPtr->tkwin == NULL) || !Tk_IsMapped(tkwin)) {
        return;
        return;
    }
    }
 
 
    /*
    /*
     * In order to avoid screen flashes, this procedure redraws
     * In order to avoid screen flashes, this procedure redraws
     * the button in a pixmap, then copies the pixmap to the
     * the button in a pixmap, then copies the pixmap to the
     * screen in a single operation.  This means that there's no
     * screen in a single operation.  This means that there's no
     * point in time where the on-sreen image has been cleared.
     * point in time where the on-sreen image has been cleared.
     */
     */
 
 
    pixmap = Tk_GetPixmap(butPtr->display, Tk_WindowId(tkwin),
    pixmap = Tk_GetPixmap(butPtr->display, Tk_WindowId(tkwin),
            Tk_Width(tkwin), Tk_Height(tkwin), Tk_Depth(tkwin));
            Tk_Width(tkwin), Tk_Height(tkwin), Tk_Depth(tkwin));
 
 
    hasImageOrBitmap = ((butPtr->image != NULL) || (butPtr->bitmap != None));
    hasImageOrBitmap = ((butPtr->image != NULL) || (butPtr->bitmap != None));
    offset = (butPtr->type == TYPE_BUTTON) && hasImageOrBitmap;
    offset = (butPtr->type == TYPE_BUTTON) && hasImageOrBitmap;
 
 
    border = butPtr->normalBorder;
    border = butPtr->normalBorder;
    if ((butPtr->state == tkDisabledUid) && (butPtr->disabledFg != NULL)) {
    if ((butPtr->state == tkDisabledUid) && (butPtr->disabledFg != NULL)) {
        gc = butPtr->disabledGC;
        gc = butPtr->disabledGC;
    } else if ((butPtr->type == TYPE_BUTTON)
    } else if ((butPtr->type == TYPE_BUTTON)
            && (butPtr->state == tkActiveUid)) {
            && (butPtr->state == tkActiveUid)) {
        gc = butPtr->activeTextGC;
        gc = butPtr->activeTextGC;
        border = butPtr->activeBorder;
        border = butPtr->activeBorder;
    } else {
    } else {
        gc = butPtr->normalTextGC;
        gc = butPtr->normalTextGC;
    }
    }
 
 
    if ((butPtr->flags & SELECTED) && (butPtr->state != tkActiveUid)
    if ((butPtr->flags & SELECTED) && (butPtr->state != tkActiveUid)
            && (butPtr->selectBorder != NULL) && !butPtr->indicatorOn) {
            && (butPtr->selectBorder != NULL) && !butPtr->indicatorOn) {
        border = butPtr->selectBorder;
        border = butPtr->selectBorder;
    }
    }
 
 
    /*
    /*
     * Override the relief specified for the button if this is a
     * Override the relief specified for the button if this is a
     * checkbutton or radiobutton and there's no indicator.
     * checkbutton or radiobutton and there's no indicator.
     * However, don't do this in the presence of Appearance, since
     * However, don't do this in the presence of Appearance, since
     * then the bevel button will take care of the relief.
     * then the bevel button will take care of the relief.
     */
     */
 
 
    relief = butPtr->relief;
    relief = butPtr->relief;
 
 
    if ((butPtr->type >= TYPE_CHECK_BUTTON) && !butPtr->indicatorOn) {
    if ((butPtr->type >= TYPE_CHECK_BUTTON) && !butPtr->indicatorOn) {
        if (!TkMacHaveAppearance() || !hasImageOrBitmap) {
        if (!TkMacHaveAppearance() || !hasImageOrBitmap) {
            relief = (butPtr->flags & SELECTED) ? TK_RELIEF_SUNKEN
            relief = (butPtr->flags & SELECTED) ? TK_RELIEF_SUNKEN
                    : TK_RELIEF_RAISED;
                    : TK_RELIEF_RAISED;
        }
        }
    }
    }
 
 
    /*
    /*
     * See the comment in UpdateControlColors as to why we use the
     * See the comment in UpdateControlColors as to why we use the
     * highlightbackground for the border of Macintosh buttons.
     * highlightbackground for the border of Macintosh buttons.
     */
     */
 
 
    if (butPtr->type == TYPE_BUTTON) {
    if (butPtr->type == TYPE_BUTTON) {
        Tk_Fill3DRectangle(tkwin, pixmap, butPtr->highlightBorder, 0, 0,
        Tk_Fill3DRectangle(tkwin, pixmap, butPtr->highlightBorder, 0, 0,
                Tk_Width(tkwin), Tk_Height(tkwin), 0, TK_RELIEF_FLAT);
                Tk_Width(tkwin), Tk_Height(tkwin), 0, TK_RELIEF_FLAT);
    } else {
    } else {
    Tk_Fill3DRectangle(tkwin, pixmap, butPtr->normalBorder, 0, 0,
    Tk_Fill3DRectangle(tkwin, pixmap, butPtr->normalBorder, 0, 0,
            Tk_Width(tkwin), Tk_Height(tkwin), 0, TK_RELIEF_FLAT);
            Tk_Width(tkwin), Tk_Height(tkwin), 0, TK_RELIEF_FLAT);
    }
    }
 
 
    if (butPtr->type == TYPE_LABEL) {
    if (butPtr->type == TYPE_LABEL) {
        drawType = DRAW_LABEL;
        drawType = DRAW_LABEL;
    } else if (butPtr->type == TYPE_BUTTON) {
    } else if (butPtr->type == TYPE_BUTTON) {
        if (!hasImageOrBitmap) {
        if (!hasImageOrBitmap) {
            drawType = DRAW_CONTROL;
            drawType = DRAW_CONTROL;
        } else if (butPtr->image != None) {
        } else if (butPtr->image != None) {
            drawType = DRAW_BEVEL;
            drawType = DRAW_BEVEL;
        } else {
        } else {
            /*
            /*
             * TO DO - The current way the we draw bitmaps (XCopyPlane)
             * TO DO - The current way the we draw bitmaps (XCopyPlane)
             * uses CopyDeepMask in this one case.  The Picture recording
             * uses CopyDeepMask in this one case.  The Picture recording
             * does not record this call, and so we can't use the
             * does not record this call, and so we can't use the
             * Appearance bevel button here.  The only case that would
             * Appearance bevel button here.  The only case that would
             * exercise this is if you use a bitmap, with
             * 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.
             * appearance button and overprint the image in this case.
             * This just punts and draws the old-style, ugly, button.
             * This just punts and draws the old-style, ugly, button.
             */
             */
 
 
            if (gc->clip_mask == 0) {
            if (gc->clip_mask == 0) {
                drawType = DRAW_BEVEL;
                drawType = DRAW_BEVEL;
            } else {
            } else {
                TkpClipMask *clipPtr = (TkpClipMask*) gc->clip_mask;
                TkpClipMask *clipPtr = (TkpClipMask*) gc->clip_mask;
                if ((clipPtr->type == TKP_CLIP_PIXMAP) &&
                if ((clipPtr->type == TKP_CLIP_PIXMAP) &&
                    (clipPtr->value.pixmap != butPtr->bitmap)) {
                    (clipPtr->value.pixmap != butPtr->bitmap)) {
                    drawType = DRAW_CUSTOM;
                    drawType = DRAW_CUSTOM;
                } else {
                } else {
                    drawType = DRAW_BEVEL;
                    drawType = DRAW_BEVEL;
                }
                }
            }
            }
        }
        }
    } else {
    } else {
        if (butPtr->indicatorOn) {
        if (butPtr->indicatorOn) {
            drawType = DRAW_CONTROL;
            drawType = DRAW_CONTROL;
        } else if (hasImageOrBitmap) {
        } else if (hasImageOrBitmap) {
            if (gc->clip_mask == 0) {
            if (gc->clip_mask == 0) {
                drawType = DRAW_BEVEL;
                drawType = DRAW_BEVEL;
            } else {
            } else {
                TkpClipMask *clipPtr = (TkpClipMask*) gc->clip_mask;
                TkpClipMask *clipPtr = (TkpClipMask*) gc->clip_mask;
                if ((clipPtr->type == TKP_CLIP_PIXMAP) &&
                if ((clipPtr->type == TKP_CLIP_PIXMAP) &&
                    (clipPtr->value.pixmap != butPtr->bitmap)) {
                    (clipPtr->value.pixmap != butPtr->bitmap)) {
                    drawType = DRAW_CUSTOM;
                    drawType = DRAW_CUSTOM;
                } else {
                } else {
                    drawType = DRAW_BEVEL;
                    drawType = DRAW_BEVEL;
                }
                }
            }
            }
        } else {
        } else {
            drawType = DRAW_CUSTOM;
            drawType = DRAW_CUSTOM;
        }
        }
    }
    }
 
 
    /*
    /*
     * 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
     * if it doesn't already exist.  Then configure the Macintosh control from
     * the Tk info.  Finally, we call Draw1Control to draw to the screen.
     * the Tk info.  Finally, we call Draw1Control to draw to the screen.
     */
     */
 
 
    if ((drawType == DRAW_CONTROL) ||
    if ((drawType == DRAW_CONTROL) ||
            ((drawType == DRAW_BEVEL) && TkMacHaveAppearance())) {
            ((drawType == DRAW_BEVEL) && TkMacHaveAppearance())) {
        borderWidth = 0;
        borderWidth = 0;
 
 
        /*
        /*
         * This part uses Macintosh rather than Tk calls to draw
         * This part uses Macintosh rather than Tk calls to draw
         * to the screen.  Make sure the ports etc. are set correctly.
         * to the screen.  Make sure the ports etc. are set correctly.
         */
         */
 
 
        destPort = TkMacGetDrawablePort(pixmap);
        destPort = TkMacGetDrawablePort(pixmap);
        SetGWorld(destPort, NULL);
        SetGWorld(destPort, NULL);
        DrawBufferedControl(butPtr, destPort, gc, pixmap);
        DrawBufferedControl(butPtr, destPort, gc, pixmap);
    }
    }
 
 
    if ((drawType == DRAW_CUSTOM) || (drawType == DRAW_LABEL)) {
    if ((drawType == DRAW_CUSTOM) || (drawType == DRAW_LABEL)) {
        borderWidth = butPtr->borderWidth;
        borderWidth = butPtr->borderWidth;
    }
    }
 
 
    /*
    /*
     * Display image or bitmap or text for button.  This has
     * Display image or bitmap or text for button.  This has
     * already been done under Appearance with the Bevel
     * already been done under Appearance with the Bevel
     * button types.
     * button types.
     */
     */
 
 
    if ((drawType == DRAW_BEVEL) && TkMacHaveAppearance()) {
    if ((drawType == DRAW_BEVEL) && TkMacHaveAppearance()) {
        /* Empty Body */
        /* Empty Body */
    } else if (butPtr->image != None) {
    } else if (butPtr->image != None) {
        Tk_SizeOfImage(butPtr->image, &width, &height);
        Tk_SizeOfImage(butPtr->image, &width, &height);
 
 
        imageOrBitmap:
        imageOrBitmap:
        TkComputeAnchor(butPtr->anchor, tkwin, 0, 0,
        TkComputeAnchor(butPtr->anchor, tkwin, 0, 0,
                butPtr->indicatorSpace + width, height, &x, &y);
                butPtr->indicatorSpace + width, height, &x, &y);
        x += butPtr->indicatorSpace;
        x += butPtr->indicatorSpace;
 
 
        x += offset;
        x += offset;
        y += offset;
        y += offset;
        if (relief == TK_RELIEF_RAISED) {
        if (relief == TK_RELIEF_RAISED) {
            x -= offset;
            x -= offset;
            y -= offset;
            y -= offset;
        } else if (relief == TK_RELIEF_SUNKEN) {
        } else if (relief == TK_RELIEF_SUNKEN) {
            x += offset;
            x += offset;
            y += offset;
            y += offset;
        }
        }
        if (butPtr->image != NULL) {
        if (butPtr->image != NULL) {
            if ((butPtr->selectImage != NULL) && (butPtr->flags & SELECTED)) {
            if ((butPtr->selectImage != NULL) && (butPtr->flags & SELECTED)) {
                Tk_RedrawImage(butPtr->selectImage, 0, 0, width, height,
                Tk_RedrawImage(butPtr->selectImage, 0, 0, width, height,
                        pixmap, x, y);
                        pixmap, x, y);
            } else {
            } else {
                Tk_RedrawImage(butPtr->image, 0, 0, width, height, pixmap,
                Tk_RedrawImage(butPtr->image, 0, 0, width, height, pixmap,
                        x, y);
                        x, y);
            }
            }
        } else {
        } else {
            XSetClipOrigin(butPtr->display, gc, x, y);
            XSetClipOrigin(butPtr->display, gc, x, y);
            XCopyPlane(butPtr->display, butPtr->bitmap, pixmap, gc, 0, 0,
            XCopyPlane(butPtr->display, butPtr->bitmap, pixmap, gc, 0, 0,
                    (unsigned int) width, (unsigned int) height, x, y, 1);
                    (unsigned int) width, (unsigned int) height, x, y, 1);
            XSetClipOrigin(butPtr->display, gc, 0, 0);
            XSetClipOrigin(butPtr->display, gc, 0, 0);
        }
        }
        y += height/2;
        y += height/2;
    } else if (butPtr->bitmap != None) {
    } else if (butPtr->bitmap != None) {
        Tk_SizeOfBitmap(butPtr->display, butPtr->bitmap, &width, &height);
        Tk_SizeOfBitmap(butPtr->display, butPtr->bitmap, &width, &height);
        goto imageOrBitmap;
        goto imageOrBitmap;
    } else {
    } else {
        TkComputeAnchor(butPtr->anchor, tkwin, butPtr->padX, butPtr->padY,
        TkComputeAnchor(butPtr->anchor, tkwin, butPtr->padX, butPtr->padY,
                butPtr->indicatorSpace + butPtr->textWidth, butPtr->textHeight,
                butPtr->indicatorSpace + butPtr->textWidth, butPtr->textHeight,
                &x, &y);
                &x, &y);
 
 
        x += butPtr->indicatorSpace;
        x += butPtr->indicatorSpace;
 
 
        Tk_DrawTextLayout(butPtr->display, pixmap, gc, butPtr->textLayout,
        Tk_DrawTextLayout(butPtr->display, pixmap, gc, butPtr->textLayout,
                x, y, 0, -1);
                x, y, 0, -1);
        y += butPtr->textHeight/2;
        y += butPtr->textHeight/2;
    }
    }
 
 
    /*
    /*
     * If the button is disabled with a stipple rather than a special
     * 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,
     * is selected and we use a different background color when selected,
     * must temporarily modify the GC.
     * must temporarily modify the GC.
     */
     */
 
 
    if ((butPtr->state == tkDisabledUid)
    if ((butPtr->state == tkDisabledUid)
            && ((butPtr->disabledFg == NULL) || (butPtr->image != NULL))) {
            && ((butPtr->disabledFg == NULL) || (butPtr->image != NULL))) {
        if ((butPtr->flags & SELECTED) && !butPtr->indicatorOn
        if ((butPtr->flags & SELECTED) && !butPtr->indicatorOn
                && (butPtr->selectBorder != NULL)) {
                && (butPtr->selectBorder != NULL)) {
            XSetForeground(butPtr->display, butPtr->disabledGC,
            XSetForeground(butPtr->display, butPtr->disabledGC,
                    Tk_3DBorderColor(butPtr->selectBorder)->pixel);
                    Tk_3DBorderColor(butPtr->selectBorder)->pixel);
        }
        }
        XFillRectangle(butPtr->display, pixmap, butPtr->disabledGC,
        XFillRectangle(butPtr->display, pixmap, butPtr->disabledGC,
                butPtr->inset, butPtr->inset,
                butPtr->inset, butPtr->inset,
                (unsigned) (Tk_Width(tkwin) - 2*butPtr->inset),
                (unsigned) (Tk_Width(tkwin) - 2*butPtr->inset),
                (unsigned) (Tk_Height(tkwin) - 2*butPtr->inset));
                (unsigned) (Tk_Height(tkwin) - 2*butPtr->inset));
        if ((butPtr->flags & SELECTED) && !butPtr->indicatorOn
        if ((butPtr->flags & SELECTED) && !butPtr->indicatorOn
                && (butPtr->selectBorder != NULL)) {
                && (butPtr->selectBorder != NULL)) {
            XSetForeground(butPtr->display, butPtr->disabledGC,
            XSetForeground(butPtr->display, butPtr->disabledGC,
                    Tk_3DBorderColor(butPtr->normalBorder)->pixel);
                    Tk_3DBorderColor(butPtr->normalBorder)->pixel);
        }
        }
    }
    }
 
 
    /*
    /*
     * Draw the border and traversal highlight last.  This way, if the
     * Draw the border and traversal highlight last.  This way, if the
     * button's contents overflow they'll be covered up by the border.
     * button's contents overflow they'll be covered up by the border.
     */
     */
 
 
    if (relief != TK_RELIEF_FLAT) {
    if (relief != TK_RELIEF_FLAT) {
        int inset = butPtr->highlightWidth;
        int inset = butPtr->highlightWidth;
        Tk_Draw3DRectangle(tkwin, pixmap, border, inset, inset,
        Tk_Draw3DRectangle(tkwin, pixmap, border, inset, inset,
                Tk_Width(tkwin) - 2*inset, Tk_Height(tkwin) - 2*inset,
                Tk_Width(tkwin) - 2*inset, Tk_Height(tkwin) - 2*inset,
                butPtr->borderWidth, relief);
                butPtr->borderWidth, relief);
    }
    }
 
 
    /*
    /*
     * Copy the information from the off-screen pixmap onto the screen,
     * Copy the information from the off-screen pixmap onto the screen,
     * then delete the pixmap.
     * then delete the pixmap.
     */
     */
 
 
    XCopyArea(butPtr->display, pixmap, Tk_WindowId(tkwin),
    XCopyArea(butPtr->display, pixmap, Tk_WindowId(tkwin),
            butPtr->copyGC, 0, 0, (unsigned) Tk_Width(tkwin),
            butPtr->copyGC, 0, 0, (unsigned) Tk_Width(tkwin),
            (unsigned) Tk_Height(tkwin), 0, 0);
            (unsigned) Tk_Height(tkwin), 0, 0);
    Tk_FreePixmap(butPtr->display, pixmap);
    Tk_FreePixmap(butPtr->display, pixmap);
 
 
    SetGWorld(saveWorld, saveDevice);
    SetGWorld(saveWorld, saveDevice);
}
}


/*
/*
 *----------------------------------------------------------------------
 *----------------------------------------------------------------------
 *
 *
 * TkpComputeButtonGeometry --
 * TkpComputeButtonGeometry --
 *
 *
 *      After changes in a button's text or bitmap, this procedure
 *      After changes in a button's text or bitmap, this procedure
 *      recomputes the button's geometry and passes this information
 *      recomputes the button's geometry and passes this information
 *      along to the geometry manager for the window.
 *      along to the geometry manager for the window.
 *
 *
 * Results:
 * Results:
 *      None.
 *      None.
 *
 *
 * Side effects:
 * Side effects:
 *      The button's window may change size.
 *      The button's window may change size.
 *
 *
 *----------------------------------------------------------------------
 *----------------------------------------------------------------------
 */
 */
 
 
void
void
TkpComputeButtonGeometry(
TkpComputeButtonGeometry(
    TkButton *butPtr)   /* Button whose geometry may have changed. */
    TkButton *butPtr)   /* Button whose geometry may have changed. */
{
{
    int width, height, avgWidth;
    int width, height, avgWidth;
    Tk_FontMetrics fm;
    Tk_FontMetrics fm;
 
 
 
 
    /*
    /*
     * First figure out the size of the contents of the button.
     * First figure out the size of the contents of the button.
     */
     */
 
 
    butPtr->indicatorSpace = 0;
    butPtr->indicatorSpace = 0;
    if (butPtr->image != NULL) {
    if (butPtr->image != NULL) {
        Tk_SizeOfImage(butPtr->image, &width, &height);
        Tk_SizeOfImage(butPtr->image, &width, &height);
        imageOrBitmap:
        imageOrBitmap:
        if (butPtr->width > 0) {
        if (butPtr->width > 0) {
            width = butPtr->width;
            width = butPtr->width;
        }
        }
        if (butPtr->height > 0) {
        if (butPtr->height > 0) {
            height = butPtr->height;
            height = butPtr->height;
        }
        }
        if ((butPtr->type >= TYPE_CHECK_BUTTON) && butPtr->indicatorOn) {
        if ((butPtr->type >= TYPE_CHECK_BUTTON) && butPtr->indicatorOn) {
            butPtr->indicatorSpace = height;
            butPtr->indicatorSpace = height;
            if (butPtr->type == TYPE_CHECK_BUTTON) {
            if (butPtr->type == TYPE_CHECK_BUTTON) {
                butPtr->indicatorDiameter = (65*height)/100;
                butPtr->indicatorDiameter = (65*height)/100;
            } else {
            } else {
                butPtr->indicatorDiameter = (75*height)/100;
                butPtr->indicatorDiameter = (75*height)/100;
            }
            }
        }
        }
    } else if (butPtr->bitmap != None) {
    } else if (butPtr->bitmap != None) {
        Tk_SizeOfBitmap(butPtr->display, butPtr->bitmap, &width, &height);
        Tk_SizeOfBitmap(butPtr->display, butPtr->bitmap, &width, &height);
        goto imageOrBitmap;
        goto imageOrBitmap;
    } else {
    } else {
        Tk_FreeTextLayout(butPtr->textLayout);
        Tk_FreeTextLayout(butPtr->textLayout);
        butPtr->textLayout = Tk_ComputeTextLayout(butPtr->tkfont,
        butPtr->textLayout = Tk_ComputeTextLayout(butPtr->tkfont,
                butPtr->text, -1, butPtr->wrapLength,
                butPtr->text, -1, butPtr->wrapLength,
                butPtr->justify, 0, &butPtr->textWidth, &butPtr->textHeight);
                butPtr->justify, 0, &butPtr->textWidth, &butPtr->textHeight);
 
 
        width = butPtr->textWidth;
        width = butPtr->textWidth;
        height = butPtr->textHeight;
        height = butPtr->textHeight;
        avgWidth = Tk_TextWidth(butPtr->tkfont, "0", 1);
        avgWidth = Tk_TextWidth(butPtr->tkfont, "0", 1);
        Tk_GetFontMetrics(butPtr->tkfont, &fm);
        Tk_GetFontMetrics(butPtr->tkfont, &fm);
 
 
        if (butPtr->width > 0) {
        if (butPtr->width > 0) {
            width = butPtr->width * avgWidth;
            width = butPtr->width * avgWidth;
        }
        }
        if (butPtr->height > 0) {
        if (butPtr->height > 0) {
            height = butPtr->height * fm.linespace;
            height = butPtr->height * fm.linespace;
        }
        }
        if ((butPtr->type >= TYPE_CHECK_BUTTON) && butPtr->indicatorOn) {
        if ((butPtr->type >= TYPE_CHECK_BUTTON) && butPtr->indicatorOn) {
            butPtr->indicatorDiameter = fm.linespace;
            butPtr->indicatorDiameter = fm.linespace;
            if (butPtr->type == TYPE_CHECK_BUTTON) {
            if (butPtr->type == TYPE_CHECK_BUTTON) {
                butPtr->indicatorDiameter = (80*butPtr->indicatorDiameter)/100;
                butPtr->indicatorDiameter = (80*butPtr->indicatorDiameter)/100;
            }
            }
            butPtr->indicatorSpace = butPtr->indicatorDiameter + avgWidth;
            butPtr->indicatorSpace = butPtr->indicatorDiameter + avgWidth;
        }
        }
    }
    }
 
 
    /*
    /*
     * Now figure out the size of the border decorations for the button.
     * Now figure out the size of the border decorations for the button.
     */
     */
 
 
    if (butPtr->highlightWidth < 0) {
    if (butPtr->highlightWidth < 0) {
        butPtr->highlightWidth = 0;
        butPtr->highlightWidth = 0;
    }
    }
 
 
    /*
    /*
     * The width and height calculation for Appearance buttons with images &
     * 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
     * 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,
     * 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.
     * directly, since Appearance will draw the border as part of our control.
     *
     *
     * When issuing the geometry request, add extra space for the indicator,
     * When issuing the geometry request, add extra space for the indicator,
     * if any, and for the border and padding, plus if this is an image two
     * if any, and for the border and padding, plus if this is an image two
     * extra pixels so the display can be offset by 1 pixel in either
     * extra pixels so the display can be offset by 1 pixel in either
     * direction for the raised or lowered effect.
     * direction for the raised or lowered effect.
     *
     *
     * The highlight width corresponds to the default ring on the Macintosh.
     * 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
     * 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.
     * highlight width as there is also one pixel of spacing.
     * Appearance buttons with images do not have a highlight ring, because the
     * Appearance buttons with images do not have a highlight ring, because the
     * Bevel button type does not support one.
     * Bevel button type does not support one.
     */
     */
 
 
    if ((butPtr->image == None) && (butPtr->bitmap == None)) {
    if ((butPtr->image == None) && (butPtr->bitmap == None)) {
        width += 2*butPtr->padX;
        width += 2*butPtr->padX;
        height += 2*butPtr->padY;
        height += 2*butPtr->padY;
    }
    }
 
 
    if ((butPtr->type == TYPE_BUTTON)) {
    if ((butPtr->type == TYPE_BUTTON)) {
        if ((butPtr->image == None) && (butPtr->bitmap == None)) {
        if ((butPtr->image == None) && (butPtr->bitmap == None)) {
            butPtr->inset = 0;
            butPtr->inset = 0;
            if (butPtr->defaultState != tkDisabledUid) {
            if (butPtr->defaultState != tkDisabledUid) {
                butPtr->inset += butPtr->highlightWidth;
                butPtr->inset += butPtr->highlightWidth;
            }
            }
        } else if (TkMacHaveAppearance()) {
        } else if (TkMacHaveAppearance()) {
                butPtr->inset = 0;
                butPtr->inset = 0;
                width += (2 * butPtr->borderWidth + 4);
                width += (2 * butPtr->borderWidth + 4);
                height += (2 * butPtr->borderWidth + 4);
                height += (2 * butPtr->borderWidth + 4);
        } else {
        } else {
            butPtr->inset = butPtr->borderWidth;
            butPtr->inset = butPtr->borderWidth;
        width += 2;
        width += 2;
        height += 2;
        height += 2;
            if (butPtr->defaultState != tkDisabledUid) {
            if (butPtr->defaultState != tkDisabledUid) {
                butPtr->inset += butPtr->highlightWidth;
                butPtr->inset += butPtr->highlightWidth;
            }
            }
        }
        }
    } else if ((butPtr->type != TYPE_LABEL)) {
    } else if ((butPtr->type != TYPE_LABEL)) {
        if (butPtr->indicatorOn) {
        if (butPtr->indicatorOn) {
            butPtr->inset = 0;
            butPtr->inset = 0;
        } else {
        } else {
        /*
        /*
         * Under Appearance, the Checkbutton or radiobutton with an image
         * Under Appearance, the Checkbutton or radiobutton with an image
         * is represented by a BevelButton with the Sticky defProc...
         * is represented by a BevelButton with the Sticky defProc...
         * So we must set its height in the same way as the Button
         * So we must set its height in the same way as the Button
         * with an image or bitmap.
         * with an image or bitmap.
         */
         */
            if (((butPtr->image != None) || (butPtr->bitmap != None))
            if (((butPtr->image != None) || (butPtr->bitmap != None))
                    && TkMacHaveAppearance()) {
                    && TkMacHaveAppearance()) {
                int border;
                int border;
                butPtr->inset = 0;
                butPtr->inset = 0;
                if ( butPtr->borderWidth <= 2 ) {
                if ( butPtr->borderWidth <= 2 ) {
                    border = 6;
                    border = 6;
                }  else {
                }  else {
                    border = 2 * butPtr->borderWidth + 2;
                    border = 2 * butPtr->borderWidth + 2;
                }
                }
                width += border;
                width += border;
                height += border;
                height += border;
            } else {
            } else {
                butPtr->inset = butPtr->borderWidth;
                butPtr->inset = butPtr->borderWidth;
            }
            }
        }
        }
    } else {
    } else {
        butPtr->inset = butPtr->borderWidth;
        butPtr->inset = butPtr->borderWidth;
    }
    }
 
 
 
 
 
 
    Tk_GeometryRequest(butPtr->tkwin, (int) (width + butPtr->indicatorSpace
    Tk_GeometryRequest(butPtr->tkwin, (int) (width + butPtr->indicatorSpace
            + 2*butPtr->inset), (int) (height + 2*butPtr->inset));
            + 2*butPtr->inset), (int) (height + 2*butPtr->inset));
    Tk_SetInternalBorder(butPtr->tkwin, butPtr->inset);
    Tk_SetInternalBorder(butPtr->tkwin, butPtr->inset);
}
}


/*
/*
 *----------------------------------------------------------------------
 *----------------------------------------------------------------------
 *
 *
 * TkpDestroyButton --
 * TkpDestroyButton --
 *
 *
 *      Free data structures associated with the button control.
 *      Free data structures associated with the button control.
 *
 *
 * Results:
 * Results:
 *      None.
 *      None.
 *
 *
 * Side effects:
 * Side effects:
 *      Restores the default control state.
 *      Restores the default control state.
 *
 *
 *----------------------------------------------------------------------
 *----------------------------------------------------------------------
 */
 */
 
 
void
void
TkpDestroyButton(
TkpDestroyButton(
    TkButton *butPtr)
    TkButton *butPtr)
{
{
    /* Do nothing. */
    /* Do nothing. */
}
}


/*
/*
 *--------------------------------------------------------------
 *--------------------------------------------------------------
 *
 *
 * DrawBufferedControl --
 * DrawBufferedControl --
 *
 *
 *      This function uses a dummy Macintosh window to allow
 *      This function uses a dummy Macintosh window to allow
 *      drawing Mac controls to any GWorld (including off-screen
 *      drawing Mac controls to any GWorld (including off-screen
 *      bitmaps).  In addition, this code may apply custom
 *      bitmaps).  In addition, this code may apply custom
 *      colors passed in the TkButton.
 *      colors passed in the TkButton.
 *
 *
 * Results:
 * Results:
 *      None.
 *      None.
 *
 *
 * Side effects:
 * Side effects:
 *      Control is to the GWorld.  Static state created on
 *      Control is to the GWorld.  Static state created on
 *      first invocation of this routine.
 *      first invocation of this routine.
 *
 *
 *--------------------------------------------------------------
 *--------------------------------------------------------------
 */
 */
 
 
static void
static void
DrawBufferedControl(
DrawBufferedControl(
    TkButton *butPtr,           /* Tk button. */
    TkButton *butPtr,           /* Tk button. */
    GWorldPtr destPort,         /* Off screen GWorld. */
    GWorldPtr destPort,         /* Off screen GWorld. */
    GC gc,                      /* The GC we are drawing into - needed for
    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
    Pixmap pixmap               /* The pixmap we are drawing into - needed
                                   for the bevel button */
                                   for the bevel button */
    )
    )
{
{
    ControlRef controlHandle;
    ControlRef controlHandle;
    CCTabHandle ccTabHandle;
    CCTabHandle ccTabHandle;
    int windowColorChanged = false;
    int windowColorChanged = false;
    RGBColor saveBackColor;
    RGBColor saveBackColor;
    int isBevel = 0;
    int isBevel = 0;
 
 
    if (windowRef == NULL) {
    if (windowRef == NULL) {
        InitSampleControls();
        InitSampleControls();
    }
    }
 
 
    /*
    /*
     * Now swap in the passed in GWorld for the portBits of our fake
     * 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.
     * the system think this is a normal window.
     * Note, we can use DrawControlInCurrentPort under Appearance, so we don't
     * Note, we can use DrawControlInCurrentPort under Appearance, so we don't
     * need to swap pixmaps.
     * need to swap pixmaps.
     */
     */
 
 
    if (!TkMacHaveAppearance()) {
    if (!TkMacHaveAppearance()) {
        ((CWindowPeek) windowRef)->port.portPixMap = destPort->portPixMap;
        ((CWindowPeek) windowRef)->port.portPixMap = destPort->portPixMap;
    }
    }
 
 
    ((CWindowPeek) windowRef)->port.portRect = destPort->portRect;
    ((CWindowPeek) windowRef)->port.portRect = destPort->portRect;
    RectRgn(((CWindowPeek) windowRef)->port.visRgn, &destPort->portRect);
    RectRgn(((CWindowPeek) windowRef)->port.visRgn, &destPort->portRect);
    RectRgn(((CWindowPeek) windowRef)->strucRgn, &destPort->portRect);
    RectRgn(((CWindowPeek) windowRef)->strucRgn, &destPort->portRect);
    RectRgn(((CWindowPeek) windowRef)->updateRgn, &destPort->portRect);
    RectRgn(((CWindowPeek) windowRef)->updateRgn, &destPort->portRect);
    RectRgn(((CWindowPeek) windowRef)->contRgn, &destPort->portRect);
    RectRgn(((CWindowPeek) windowRef)->contRgn, &destPort->portRect);
    PortChanged(windowRef);
    PortChanged(windowRef);
 
 
    /*
    /*
     * Set up control in hidden window to match what we need
     * 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;
    isBevel = 0;
    switch (butPtr->type) {
    switch (butPtr->type) {
        case TYPE_BUTTON:
        case TYPE_BUTTON:
            if (TkMacHaveAppearance()) {
            if (TkMacHaveAppearance()) {
                if ((butPtr->image == None) && (butPtr->bitmap == None)) {
                if ((butPtr->image == None) && (butPtr->bitmap == None)) {
                    controlHandle = buttonHandle;
                    controlHandle = buttonHandle;
                    ccTabHandle = buttonTabHandle;
                    ccTabHandle = buttonTabHandle;
                } else {
                } else {
                    if (butPtr->borderWidth <= 2) {
                    if (butPtr->borderWidth <= 2) {
                        controlHandle = smallBevelHandle;
                        controlHandle = smallBevelHandle;
                    } else if (butPtr->borderWidth == 3) {
                    } else if (butPtr->borderWidth == 3) {
                        controlHandle = medBevelHandle;
                        controlHandle = medBevelHandle;
                    } else {
                    } else {
                        controlHandle = largeBevelHandle;
                        controlHandle = largeBevelHandle;
                    }
                    }
                    ccTabHandle = buttonTabHandle;
                    ccTabHandle = buttonTabHandle;
                    SetupBevelButton(butPtr, controlHandle, destPort,
                    SetupBevelButton(butPtr, controlHandle, destPort,
                            gc, pixmap);
                            gc, pixmap);
                    isBevel = 1;
                    isBevel = 1;
                }
                }
            } else {
            } else {
                controlHandle = buttonHandle;
                controlHandle = buttonHandle;
                ccTabHandle = buttonTabHandle;
                ccTabHandle = buttonTabHandle;
            }
            }
            break;
            break;
        case TYPE_RADIO_BUTTON:
        case TYPE_RADIO_BUTTON:
            if (TkMacHaveAppearance()) {
            if (TkMacHaveAppearance()) {
                if (((butPtr->image == None) && (butPtr->bitmap == None))
                if (((butPtr->image == None) && (butPtr->bitmap == None))
                        || (butPtr->indicatorOn)) {
                        || (butPtr->indicatorOn)) {
                    controlHandle = radioHandle;
                    controlHandle = radioHandle;
                    ccTabHandle = radioTabHandle;
                    ccTabHandle = radioTabHandle;
                } else {
                } else {
                    if (butPtr->borderWidth <= 2) {
                    if (butPtr->borderWidth <= 2) {
                        controlHandle = smallStickyBevelHandle;
                        controlHandle = smallStickyBevelHandle;
                    } else if (butPtr->borderWidth == 3) {
                    } else if (butPtr->borderWidth == 3) {
                        controlHandle = medStickyBevelHandle;
                        controlHandle = medStickyBevelHandle;
                    } else {
                    } else {
                        controlHandle = largeStickyBevelHandle;
                        controlHandle = largeStickyBevelHandle;
                    }
                    }
                    ccTabHandle = radioTabHandle;
                    ccTabHandle = radioTabHandle;
                    SetupBevelButton(butPtr, controlHandle, destPort,
                    SetupBevelButton(butPtr, controlHandle, destPort,
                            gc, pixmap);
                            gc, pixmap);
                    isBevel = 1;
                    isBevel = 1;
                }
                }
            } else {
            } else {
                controlHandle = radioHandle;
                controlHandle = radioHandle;
                ccTabHandle = radioTabHandle;
                ccTabHandle = radioTabHandle;
            }
            }
            break;
            break;
        case TYPE_CHECK_BUTTON:
        case TYPE_CHECK_BUTTON:
            if (TkMacHaveAppearance()) {
            if (TkMacHaveAppearance()) {
                if (((butPtr->image == None) && (butPtr->bitmap == None))
                if (((butPtr->image == None) && (butPtr->bitmap == None))
                        || (butPtr->indicatorOn)) {
                        || (butPtr->indicatorOn)) {
                    controlHandle = checkHandle;
                    controlHandle = checkHandle;
                    ccTabHandle = checkTabHandle;
                    ccTabHandle = checkTabHandle;
                } else {
                } else {
                    if (butPtr->borderWidth <= 2) {
                    if (butPtr->borderWidth <= 2) {
                        controlHandle = smallStickyBevelHandle;
                        controlHandle = smallStickyBevelHandle;
                    } else if (butPtr->borderWidth == 3) {
                    } else if (butPtr->borderWidth == 3) {
                        controlHandle = medStickyBevelHandle;
                        controlHandle = medStickyBevelHandle;
                    } else {
                    } else {
                        controlHandle = largeStickyBevelHandle;
                        controlHandle = largeStickyBevelHandle;
                    }
                    }
                    ccTabHandle = checkTabHandle;
                    ccTabHandle = checkTabHandle;
                    SetupBevelButton(butPtr, controlHandle, destPort,
                    SetupBevelButton(butPtr, controlHandle, destPort,
                            gc, pixmap);
                            gc, pixmap);
                    isBevel = 1;
                    isBevel = 1;
                }
                }
            } else {
            } else {
                controlHandle = checkHandle;
                controlHandle = checkHandle;
                ccTabHandle = checkTabHandle;
                ccTabHandle = checkTabHandle;
            }
            }
            break;
            break;
    }
    }
 
 
    (**controlHandle).contrlRect.left = butPtr->inset;
    (**controlHandle).contrlRect.left = butPtr->inset;
    (**controlHandle).contrlRect.top = butPtr->inset;
    (**controlHandle).contrlRect.top = butPtr->inset;
    (**controlHandle).contrlRect.right = Tk_Width(butPtr->tkwin)
    (**controlHandle).contrlRect.right = Tk_Width(butPtr->tkwin)
            - butPtr->inset;
            - butPtr->inset;
    (**controlHandle).contrlRect.bottom = Tk_Height(butPtr->tkwin)
    (**controlHandle).contrlRect.bottom = Tk_Height(butPtr->tkwin)
            - butPtr->inset;
            - butPtr->inset;
 
 
    /*
    /*
     * Setting the control visibility by hand does not
     * Setting the control visibility by hand does not
     * seem to work under Appearance.
     * seem to work under Appearance.
     */
     */
 
 
    if (TkMacHaveAppearance()) {
    if (TkMacHaveAppearance()) {
        SetControlVisibility(controlHandle, true, false);
        SetControlVisibility(controlHandle, true, false);
        (**userPaneHandle).contrlRect.left = 0;
        (**userPaneHandle).contrlRect.left = 0;
        (**userPaneHandle).contrlRect.top = 0;
        (**userPaneHandle).contrlRect.top = 0;
        (**userPaneHandle).contrlRect.right = Tk_Width(butPtr->tkwin);
        (**userPaneHandle).contrlRect.right = Tk_Width(butPtr->tkwin);
        (**userPaneHandle).contrlRect.bottom = Tk_Height(butPtr->tkwin);
        (**userPaneHandle).contrlRect.bottom = Tk_Height(butPtr->tkwin);
    } else {
    } else {
        (**controlHandle).contrlVis = 255;
        (**controlHandle).contrlVis = 255;
    }
    }
 
 
 
 
 
 
    if (butPtr->flags & SELECTED) {
    if (butPtr->flags & SELECTED) {
        (**controlHandle).contrlValue = 1;
        (**controlHandle).contrlValue = 1;
    } else {
    } else {
        (**controlHandle).contrlValue = 0;
        (**controlHandle).contrlValue = 0;
    }
    }
 
 
    if (butPtr->state == tkActiveUid) {
    if (butPtr->state == tkActiveUid) {
        if (isBevel) {
        if (isBevel) {
            (**controlHandle).contrlHilite = kControlButtonPart;
            (**controlHandle).contrlHilite = kControlButtonPart;
        } else {
        } else {
            switch (butPtr->type) {
            switch (butPtr->type) {
                case TYPE_BUTTON:
                case TYPE_BUTTON:
                    (**controlHandle).contrlHilite = kControlButtonPart;
                    (**controlHandle).contrlHilite = kControlButtonPart;
                    break;
                    break;
                case TYPE_RADIO_BUTTON:
                case TYPE_RADIO_BUTTON:
                    (**controlHandle).contrlHilite = kControlRadioButtonPart;
                    (**controlHandle).contrlHilite = kControlRadioButtonPart;
                    break;
                    break;
                case TYPE_CHECK_BUTTON:
                case TYPE_CHECK_BUTTON:
                    (**controlHandle).contrlHilite = kControlCheckBoxPart;
                    (**controlHandle).contrlHilite = kControlCheckBoxPart;
                    break;
                    break;
            }
            }
        }
        }
    } else if (butPtr->state == tkDisabledUid) {
    } else if (butPtr->state == tkDisabledUid) {
        (**controlHandle).contrlHilite = kControlInactivePart;
        (**controlHandle).contrlHilite = kControlInactivePart;
    } else {
    } else {
        (**controlHandle).contrlHilite = kControlNoPart;
        (**controlHandle).contrlHilite = kControlNoPart;
    }
    }
 
 
    /*
    /*
     * Before we draw the control we must add the hidden window back to the
     * Before we draw the control we must add the hidden window back to the
     * main window list.  Otherwise, radiobuttons and checkbuttons will draw
     * main window list.  Otherwise, radiobuttons and checkbuttons will draw
     * incorrectly.  I don't really know why - but clearly the control draw
     * incorrectly.  I don't really know why - but clearly the control draw
     * proc needs to have the controls window in the window list.
     * proc needs to have the controls window in the window list.
     */
     */
 
 
    ((CWindowPeek) windowRef)->nextWindow = (CWindowPeek) LMGetWindowList();
    ((CWindowPeek) windowRef)->nextWindow = (CWindowPeek) LMGetWindowList();
    LMSetWindowList(windowRef);
    LMSetWindowList(windowRef);
 
 
    /*
    /*
     * Now we can set the port to our doctered up window.  We next need
     * Now we can set the port to our doctered up window.  We next need
     * to muck with the colors for the port & window to draw the control
     * to muck with the colors for the port & window to draw the control
     * with the proper Tk colors.  If we need to we also draw a default
     * with the proper Tk colors.  If we need to we also draw a default
     * ring for buttons.
     * ring for buttons.
     * Under Appearance, we draw the control directly into destPort, and
     * Under Appearance, we draw the control directly into destPort, and
     * just set the default control data.
     * just set the default control data.
     */
     */
 
 
    if (TkMacHaveAppearance()) {
    if (TkMacHaveAppearance()) {
        SetPort((GrafPort *) destPort);
        SetPort((GrafPort *) destPort);
    } else {
    } else {
        SetPort(windowRef);
        SetPort(windowRef);
    }
    }
 
 
    windowColorChanged = UpdateControlColors(butPtr, controlHandle,
    windowColorChanged = UpdateControlColors(butPtr, controlHandle,
        ccTabHandle, &saveBackColor);
        ccTabHandle, &saveBackColor);
 
 
    if ((butPtr->type == TYPE_BUTTON) && TkMacHaveAppearance()) {
    if ((butPtr->type == TYPE_BUTTON) && TkMacHaveAppearance()) {
        Boolean isDefault;
        Boolean isDefault;
 
 
        if (butPtr->defaultState == tkActiveUid) {
        if (butPtr->defaultState == tkActiveUid) {
            isDefault = true;
            isDefault = true;
        } else {
        } else {
            isDefault = false;
            isDefault = false;
        }
        }
        SetControlData(controlHandle, kControlNoPart,
        SetControlData(controlHandle, kControlNoPart,
                kControlPushButtonDefaultTag,
                kControlPushButtonDefaultTag,
                sizeof(isDefault), (Ptr) &isDefault);
                sizeof(isDefault), (Ptr) &isDefault);
    }
    }
 
 
    if (TkMacHaveAppearance()) {
    if (TkMacHaveAppearance()) {
        DrawControlInCurrentPort(userPaneHandle);
        DrawControlInCurrentPort(userPaneHandle);
    } else {
    } else {
        Draw1Control(controlHandle);
        Draw1Control(controlHandle);
    }
    }
 
 
    if (!TkMacHaveAppearance() &&
    if (!TkMacHaveAppearance() &&
            (butPtr->type == TYPE_BUTTON) &&
            (butPtr->type == TYPE_BUTTON) &&
            (butPtr->defaultState == tkActiveUid)) {
            (butPtr->defaultState == tkActiveUid)) {
        Rect box = (**controlHandle).contrlRect;
        Rect box = (**controlHandle).contrlRect;
        RGBColor rgbColor;
        RGBColor rgbColor;
 
 
        TkSetMacColor(butPtr->highlightColorPtr->pixel, &rgbColor);
        TkSetMacColor(butPtr->highlightColorPtr->pixel, &rgbColor);
        RGBForeColor(&rgbColor);
        RGBForeColor(&rgbColor);
        PenSize(butPtr->highlightWidth - 1, butPtr->highlightWidth - 1);
        PenSize(butPtr->highlightWidth - 1, butPtr->highlightWidth - 1);
        InsetRect(&box, -butPtr->highlightWidth, -butPtr->highlightWidth);
        InsetRect(&box, -butPtr->highlightWidth, -butPtr->highlightWidth);
        FrameRoundRect(&box, 16, 16);
        FrameRoundRect(&box, 16, 16);
    }
    }
 
 
    if (windowColorChanged) {
    if (windowColorChanged) {
        RGBColor dummyColor;
        RGBColor dummyColor;
        ChangeBackgroundWindowColor(windowRef, saveBackColor, &dummyColor);
        ChangeBackgroundWindowColor(windowRef, saveBackColor, &dummyColor);
    }
    }
 
 
    /*
    /*
     * Clean up: remove the hidden window from the main window list, and
     * Clean up: remove the hidden window from the main window list, and
     * hide the control we drew.
     * hide the control we drew.
     */
     */
 
 
    if (TkMacHaveAppearance()) {
    if (TkMacHaveAppearance()) {
        SetControlVisibility(controlHandle, false, false);
        SetControlVisibility(controlHandle, false, false);
        if (isBevel) {
        if (isBevel) {
            KillPicture(bevelButtonContent.u.picture);
            KillPicture(bevelButtonContent.u.picture);
        }
        }
    } else {
    } else {
        (**controlHandle).contrlVis = 0;
        (**controlHandle).contrlVis = 0;
    }
    }
    LMSetWindowList((WindowRef) ((CWindowPeek) windowRef)->nextWindow);
    LMSetWindowList((WindowRef) ((CWindowPeek) windowRef)->nextWindow);
}
}


/*
/*
 *--------------------------------------------------------------
 *--------------------------------------------------------------
 *
 *
 * InitSampleControls --
 * InitSampleControls --
 *
 *
 *      This function initializes a dummy Macintosh window and
 *      This function initializes a dummy Macintosh window and
 *      sample controls to allow drawing Mac controls to any GWorld
 *      sample controls to allow drawing Mac controls to any GWorld
 *      (including off-screen bitmaps).
 *      (including off-screen bitmaps).
 *
 *
 * Results:
 * Results:
 *      None.
 *      None.
 *
 *
 * Side effects:
 * Side effects:
 *      Controls & a window are created.
 *      Controls & a window are created.
 *
 *
 *--------------------------------------------------------------
 *--------------------------------------------------------------
 */
 */
 
 
static void
static void
InitSampleControls()
InitSampleControls()
{
{
        Rect geometry = {0, 0, 10, 10};
        Rect geometry = {0, 0, 10, 10};
        CWindowPeek windowList;
        CWindowPeek windowList;
 
 
        /*
        /*
         * Create a dummy window that we can draw to.  We will
         * Create a dummy window that we can draw to.  We will
         * actually replace this window's bitmap with the one
         * actually replace this window's bitmap with the one
         * we want to draw to at a later time.  This window and
         * we want to draw to at a later time.  This window and
         * the data structures attached to it are only deallocated
         * the data structures attached to it are only deallocated
         * on exit of the application.
         * on exit of the application.
         */
         */
 
 
        windowRef = NewCWindow(NULL, &geometry, "\pempty", false,
        windowRef = NewCWindow(NULL, &geometry, "\pempty", false,
            zoomDocProc, (WindowRef) -1, true, 0);
            zoomDocProc, (WindowRef) -1, true, 0);
        if (windowRef == NULL) {
        if (windowRef == NULL) {
            panic("Can't allocate buffer window.");
            panic("Can't allocate buffer window.");
        }
        }
 
 
        /*
        /*
         * Now add the three standard controls to hidden window.  We
         * Now add the three standard controls to hidden window.  We
         * only create one of each and reuse them for every widget in
         * only create one of each and reuse them for every widget in
         * Tk.
         * Tk.
         * Under Appearance, we have to embed the controls in a UserPane
         * Under Appearance, we have to embed the controls in a UserPane
         * control, so that we can color the background text in
         * control, so that we can color the background text in
         * radiobuttons and checkbuttons.
         * radiobuttons and checkbuttons.
         */
         */
 
 
        SetPort(windowRef);
        SetPort(windowRef);
 
 
        if (TkMacHaveAppearance()) {
        if (TkMacHaveAppearance()) {
 
 
            OSErr err;
            OSErr err;
            ControlRef dontCare;
            ControlRef dontCare;
 
 
            /* Adding UserPaneBackgroundProcs to the root control does
            /* Adding UserPaneBackgroundProcs to the root control does
             * not seem to work, so we have to add another UserPane to
             * not seem to work, so we have to add another UserPane to
             * the root control.
             * the root control.
             */
             */
 
 
            err = CreateRootControl(windowRef, &dontCare);
            err = CreateRootControl(windowRef, &dontCare);
            if (err != noErr) {
            if (err != noErr) {
                panic("Can't create root control in DrawBufferedControl");
                panic("Can't create root control in DrawBufferedControl");
            }
            }
 
 
            userPaneHandle = NewControl(windowRef, &geometry, "\p",
            userPaneHandle = NewControl(windowRef, &geometry, "\p",
                true, kControlSupportsEmbedding|kControlHasSpecialBackground,
                true, kControlSupportsEmbedding|kControlHasSpecialBackground,
                0, 1, kControlUserPaneProc, (SInt32) 0);
                0, 1, kControlUserPaneProc, (SInt32) 0);
            SetUserPaneSetUpSpecialBackgroundProc(userPaneHandle,
            SetUserPaneSetUpSpecialBackgroundProc(userPaneHandle,
                    UserPaneBackgroundProc);
                    UserPaneBackgroundProc);
            SetUserPaneDrawProc(userPaneHandle, UserPaneDraw);
            SetUserPaneDrawProc(userPaneHandle, UserPaneDraw);
 
 
            buttonHandle = NewControl(windowRef, &geometry, "\p",
            buttonHandle = NewControl(windowRef, &geometry, "\p",
                false, 1, 0, 1, kControlPushButtonProc, (SInt32) 0);
                false, 1, 0, 1, kControlPushButtonProc, (SInt32) 0);
            EmbedControl(buttonHandle, userPaneHandle);
            EmbedControl(buttonHandle, userPaneHandle);
            checkHandle = NewControl(windowRef, &geometry, "\p",
            checkHandle = NewControl(windowRef, &geometry, "\p",
            false, 1, 0, 1, kControlCheckBoxProc, (SInt32) 0);
            false, 1, 0, 1, kControlCheckBoxProc, (SInt32) 0);
            EmbedControl(checkHandle, userPaneHandle);
            EmbedControl(checkHandle, userPaneHandle);
            radioHandle = NewControl(windowRef, &geometry, "\p",
            radioHandle = NewControl(windowRef, &geometry, "\p",
                false, 1, 0, 1, kControlRadioButtonProc, (SInt32) 0);
                false, 1, 0, 1, kControlRadioButtonProc, (SInt32) 0);
            EmbedControl(radioHandle, userPaneHandle);
            EmbedControl(radioHandle, userPaneHandle);
        smallBevelHandle = NewControl(windowRef, &geometry, "\p",
        smallBevelHandle = NewControl(windowRef, &geometry, "\p",
                false, 0, 0,
                false, 0, 0,
                kControlBehaviorOffsetContents << 16 | kControlContentPictHandle,
                kControlBehaviorOffsetContents << 16 | kControlContentPictHandle,
                kControlBevelButtonSmallBevelProc, (SInt32) 0);
                kControlBevelButtonSmallBevelProc, (SInt32) 0);
        EmbedControl(smallBevelHandle, userPaneHandle);
        EmbedControl(smallBevelHandle, userPaneHandle);
        medBevelHandle = NewControl(windowRef, &geometry, "\p",
        medBevelHandle = NewControl(windowRef, &geometry, "\p",
                false, 0, 0,
                false, 0, 0,
                kControlBehaviorOffsetContents << 16 | kControlContentPictHandle,
                kControlBehaviorOffsetContents << 16 | kControlContentPictHandle,
                kControlBevelButtonNormalBevelProc, (SInt32) 0);
                kControlBevelButtonNormalBevelProc, (SInt32) 0);
        EmbedControl(medBevelHandle, userPaneHandle);
        EmbedControl(medBevelHandle, userPaneHandle);
        largeBevelHandle = NewControl(windowRef, &geometry, "\p",
        largeBevelHandle = NewControl(windowRef, &geometry, "\p",
                false, 0, 0,
                false, 0, 0,
                kControlBehaviorOffsetContents << 16 | kControlContentPictHandle,
                kControlBehaviorOffsetContents << 16 | kControlContentPictHandle,
                kControlBevelButtonLargeBevelProc, (SInt32) 0);
                kControlBevelButtonLargeBevelProc, (SInt32) 0);
        EmbedControl(largeBevelHandle, userPaneHandle);
        EmbedControl(largeBevelHandle, userPaneHandle);
        bevelButtonContent.contentType = kControlContentPictHandle;
        bevelButtonContent.contentType = kControlContentPictHandle;
        smallStickyBevelHandle = NewControl(windowRef, &geometry, "\p",
        smallStickyBevelHandle = NewControl(windowRef, &geometry, "\p",
                false, 0, 0,
                false, 0, 0,
                (kControlBehaviorOffsetContents | kControlBehaviorSticky) << 16
                (kControlBehaviorOffsetContents | kControlBehaviorSticky) << 16
                | kControlContentPictHandle,
                | kControlContentPictHandle,
                kControlBevelButtonSmallBevelProc, (SInt32) 0);
                kControlBevelButtonSmallBevelProc, (SInt32) 0);
        EmbedControl(smallStickyBevelHandle, userPaneHandle);
        EmbedControl(smallStickyBevelHandle, userPaneHandle);
        medStickyBevelHandle = NewControl(windowRef, &geometry, "\p",
        medStickyBevelHandle = NewControl(windowRef, &geometry, "\p",
                false, 0, 0,
                false, 0, 0,
                (kControlBehaviorOffsetContents | kControlBehaviorSticky) << 16
                (kControlBehaviorOffsetContents | kControlBehaviorSticky) << 16
                | kControlContentPictHandle,
                | kControlContentPictHandle,
                kControlBevelButtonNormalBevelProc, (SInt32) 0);
                kControlBevelButtonNormalBevelProc, (SInt32) 0);
        EmbedControl(medStickyBevelHandle, userPaneHandle);
        EmbedControl(medStickyBevelHandle, userPaneHandle);
        largeStickyBevelHandle = NewControl(windowRef, &geometry, "\p",
        largeStickyBevelHandle = NewControl(windowRef, &geometry, "\p",
                false, 0, 0,
                false, 0, 0,
                (kControlBehaviorOffsetContents | kControlBehaviorSticky) << 16
                (kControlBehaviorOffsetContents | kControlBehaviorSticky) << 16
                | kControlContentPictHandle,
                | kControlContentPictHandle,
                kControlBevelButtonLargeBevelProc, (SInt32) 0);
                kControlBevelButtonLargeBevelProc, (SInt32) 0);
        EmbedControl(largeStickyBevelHandle, userPaneHandle);
        EmbedControl(largeStickyBevelHandle, userPaneHandle);
 
 
        picParams.version = -2;
        picParams.version = -2;
        picParams.hRes = 0x00480000;
        picParams.hRes = 0x00480000;
        picParams.vRes = 0x00480000;
        picParams.vRes = 0x00480000;
        picParams.srcRect.top = 0;
        picParams.srcRect.top = 0;
        picParams.srcRect.left = 0;
        picParams.srcRect.left = 0;
 
 
            ((CWindowPeek) windowRef)->visible = true;
            ((CWindowPeek) windowRef)->visible = true;
        } else {
        } else {
        buttonHandle = NewControl(windowRef, &geometry, "\p",
        buttonHandle = NewControl(windowRef, &geometry, "\p",
                false, 1, 0, 1, pushButProc, (SInt32) 0);
                false, 1, 0, 1, pushButProc, (SInt32) 0);
        checkHandle = NewControl(windowRef, &geometry, "\p",
        checkHandle = NewControl(windowRef, &geometry, "\p",
                false, 1, 0, 1, checkBoxProc, (SInt32) 0);
                false, 1, 0, 1, checkBoxProc, (SInt32) 0);
        radioHandle = NewControl(windowRef, &geometry, "\p",
        radioHandle = NewControl(windowRef, &geometry, "\p",
                false, 1, 0, 1, radioButProc, (SInt32) 0);
                false, 1, 0, 1, radioButProc, (SInt32) 0);
        ((CWindowPeek) windowRef)->visible = true;
        ((CWindowPeek) windowRef)->visible = true;
 
 
        buttonTabHandle = (CCTabHandle) NewHandle(sizeof(CtlCTab));
        buttonTabHandle = (CCTabHandle) NewHandle(sizeof(CtlCTab));
        checkTabHandle = (CCTabHandle) NewHandle(sizeof(CtlCTab));
        checkTabHandle = (CCTabHandle) NewHandle(sizeof(CtlCTab));
        radioTabHandle = (CCTabHandle) NewHandle(sizeof(CtlCTab));
        radioTabHandle = (CCTabHandle) NewHandle(sizeof(CtlCTab));
        }
        }
 
 
        /*
        /*
         * Remove our window from the window list.  This way our
         * Remove our window from the window list.  This way our
         * applications and others will not be confused that this
         * applications and others will not be confused that this
         * window exists - but no one knows about it.
         * window exists - but no one knows about it.
         */
         */
 
 
        windowList = (CWindowPeek) LMGetWindowList();
        windowList = (CWindowPeek) LMGetWindowList();
        if (windowList == (CWindowPeek) windowRef) {
        if (windowList == (CWindowPeek) windowRef) {
            LMSetWindowList((WindowRef) windowList->nextWindow);
            LMSetWindowList((WindowRef) windowList->nextWindow);
        } else {
        } else {
            while ((windowList != NULL)
            while ((windowList != NULL)
                    && (windowList->nextWindow != (CWindowPeek) windowRef)) {
                    && (windowList->nextWindow != (CWindowPeek) windowRef)) {
                windowList = windowList->nextWindow;
                windowList = windowList->nextWindow;
            }
            }
            if (windowList != NULL) {
            if (windowList != NULL) {
                windowList->nextWindow = windowList->nextWindow->nextWindow;
                windowList->nextWindow = windowList->nextWindow->nextWindow;
            }
            }
        }
        }
        ((CWindowPeek) windowRef)->nextWindow = NULL;
        ((CWindowPeek) windowRef)->nextWindow = NULL;
 
 
        /*
        /*
         * Create an exit handler to clean up this mess if we our
         * Create an exit handler to clean up this mess if we our
         * unloaded etc.  We need to remember the windows portPixMap
         * unloaded etc.  We need to remember the windows portPixMap
         * so it isn't leaked.
         * so it isn't leaked.
         *
         *
         * TODO: The ButtonExitProc doesn't currently work and the
         * TODO: The ButtonExitProc doesn't currently work and the
         * code it includes will crash the Mac on exit from Tk.
         * code it includes will crash the Mac on exit from Tk.
 
 
         oldPixPtr = ((CWindowPeek) windowRef)->port.portPixMap;
         oldPixPtr = ((CWindowPeek) windowRef)->port.portPixMap;
         Tcl_CreateExitHandler(ButtonExitProc, (ClientData) NULL);
         Tcl_CreateExitHandler(ButtonExitProc, (ClientData) NULL);
         */
         */
 
 
}
}


/*
/*
 *--------------------------------------------------------------
 *--------------------------------------------------------------
 *
 *
 * SetupBevelButton --
 * SetupBevelButton --
 *
 *
 *      Sets up the Bevel Button with image by copying the
 *      Sets up the Bevel Button with image by copying the
 *      source image onto the PicHandle for the button.
 *      source image onto the PicHandle for the button.
 *
 *
 * Results:
 * Results:
 *      None
 *      None
 *
 *
 * Side effects:
 * Side effects:
 *      The image or bitmap for the button is copied over to a picture.
 *      The image or bitmap for the button is copied over to a picture.
 *
 *
 *--------------------------------------------------------------
 *--------------------------------------------------------------
 */
 */
void
void
SetupBevelButton(
SetupBevelButton(
    TkButton *butPtr,           /* Tk button. */
    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. */
    GWorldPtr destPort,         /* Off screen GWorld. */
    GC gc,                      /* The GC we are drawing into - needed for
    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
    Pixmap pixmap               /* The pixmap we are drawing into - needed
                                   for the bevel button */
                                   for the bevel button */
    )
    )
{
{
    int height, width;
    int height, width;
    ControlButtonGraphicAlignment theAlignment;
    ControlButtonGraphicAlignment theAlignment;
 
 
    SetPort((GrafPtr) destPort);
    SetPort((GrafPtr) destPort);
 
 
    if (butPtr->image != None) {
    if (butPtr->image != None) {
        Tk_SizeOfImage(butPtr->image,
        Tk_SizeOfImage(butPtr->image,
                &width, &height);
                &width, &height);
    } else {
    } else {
        Tk_SizeOfBitmap(butPtr->display, butPtr->bitmap,
        Tk_SizeOfBitmap(butPtr->display, butPtr->bitmap,
                &width, &height);
                &width, &height);
    }
    }
 
 
    if ((butPtr->width > 0) && (butPtr->width < width)) {
    if ((butPtr->width > 0) && (butPtr->width < width)) {
        width = butPtr->width;
        width = butPtr->width;
    }
    }
    if ((butPtr->height > 0) && (butPtr->height < height)) {
    if ((butPtr->height > 0) && (butPtr->height < height)) {
        height = butPtr->height;
        height = butPtr->height;
    }
    }
 
 
    picParams.srcRect.right = width;
    picParams.srcRect.right = width;
    picParams.srcRect.bottom = height;
    picParams.srcRect.bottom = height;
 
 
    bevelButtonContent.u.picture = OpenCPicture(&picParams);
    bevelButtonContent.u.picture = OpenCPicture(&picParams);
 
 
    /*
    /*
     * TO DO - There is one case where XCopyPlane calls CopyDeepMask,
     * TO DO - There is one case where XCopyPlane calls CopyDeepMask,
     * which does not get recorded in the picture.  So the bitmap code
     * which does not get recorded in the picture.  So the bitmap code
     * will fail in that case.
     * will fail in that case.
     */
     */
 
 
    if ((butPtr->selectImage != NULL) && (butPtr->flags & SELECTED)) {
    if ((butPtr->selectImage != NULL) && (butPtr->flags & SELECTED)) {
        Tk_RedrawImage(butPtr->selectImage, 0, 0, width, height,
        Tk_RedrawImage(butPtr->selectImage, 0, 0, width, height,
                pixmap, 0, 0);
                pixmap, 0, 0);
    } else if (butPtr->image != NULL) {
    } else if (butPtr->image != NULL) {
        Tk_RedrawImage(butPtr->image, 0, 0, width,
        Tk_RedrawImage(butPtr->image, 0, 0, width,
            height, pixmap, 0, 0);
            height, pixmap, 0, 0);
    } else {
    } else {
        XSetClipOrigin(butPtr->display, gc, 0, 0);
        XSetClipOrigin(butPtr->display, gc, 0, 0);
        XCopyPlane(butPtr->display, butPtr->bitmap, pixmap, gc, 0, 0,
        XCopyPlane(butPtr->display, butPtr->bitmap, pixmap, gc, 0, 0,
                (unsigned int) width, (unsigned int) height, 0, 0, 1);
                (unsigned int) width, (unsigned int) height, 0, 0, 1);
    }
    }
 
 
    ClosePicture();
    ClosePicture();
 
 
    SetControlData(controlHandle, kControlButtonPart,
    SetControlData(controlHandle, kControlButtonPart,
            kControlBevelButtonContentTag,
            kControlBevelButtonContentTag,
            sizeof(ControlButtonContentInfo),
            sizeof(ControlButtonContentInfo),
            (char *) &bevelButtonContent);
            (char *) &bevelButtonContent);
 
 
    if (butPtr->anchor == TK_ANCHOR_N) {
    if (butPtr->anchor == TK_ANCHOR_N) {
            theAlignment = kControlBevelButtonAlignTop;
            theAlignment = kControlBevelButtonAlignTop;
     } else if (butPtr->anchor == TK_ANCHOR_NE) {
     } else if (butPtr->anchor == TK_ANCHOR_NE) {
            theAlignment = kControlBevelButtonAlignTopRight;
            theAlignment = kControlBevelButtonAlignTopRight;
     } else if (butPtr->anchor == TK_ANCHOR_E) {
     } else if (butPtr->anchor == TK_ANCHOR_E) {
            theAlignment = kControlBevelButtonAlignRight;
            theAlignment = kControlBevelButtonAlignRight;
     } else if (butPtr->anchor == TK_ANCHOR_SE) {
     } else if (butPtr->anchor == TK_ANCHOR_SE) {
            theAlignment = kControlBevelButtonAlignBottomRight;
            theAlignment = kControlBevelButtonAlignBottomRight;
     } else if (butPtr->anchor == TK_ANCHOR_S) {
     } else if (butPtr->anchor == TK_ANCHOR_S) {
            theAlignment = kControlBevelButtonAlignBottom;
            theAlignment = kControlBevelButtonAlignBottom;
     } else if (butPtr->anchor == TK_ANCHOR_SW) {
     } else if (butPtr->anchor == TK_ANCHOR_SW) {
            theAlignment = kControlBevelButtonAlignBottomLeft;
            theAlignment = kControlBevelButtonAlignBottomLeft;
     } else if (butPtr->anchor == TK_ANCHOR_W) {
     } else if (butPtr->anchor == TK_ANCHOR_W) {
            theAlignment = kControlBevelButtonAlignLeft;
            theAlignment = kControlBevelButtonAlignLeft;
     } else if (butPtr->anchor == TK_ANCHOR_NW) {
     } else if (butPtr->anchor == TK_ANCHOR_NW) {
            theAlignment = kControlBevelButtonAlignTopLeft;
            theAlignment = kControlBevelButtonAlignTopLeft;
     } else if (butPtr->anchor == TK_ANCHOR_CENTER) {
     } else if (butPtr->anchor == TK_ANCHOR_CENTER) {
            theAlignment = kControlBevelButtonAlignCenter;
            theAlignment = kControlBevelButtonAlignCenter;
    }
    }
 
 
    SetControlData(controlHandle, kControlButtonPart,
    SetControlData(controlHandle, kControlButtonPart,
            kControlBevelButtonGraphicAlignTag,
            kControlBevelButtonGraphicAlignTag,
            sizeof(ControlButtonGraphicAlignment),
            sizeof(ControlButtonGraphicAlignment),
            (char *) &theAlignment);
            (char *) &theAlignment);
 
 
}
}


/*
/*
 *--------------------------------------------------------------
 *--------------------------------------------------------------
 *
 *
 * SetUserPaneDrawProc --
 * SetUserPaneDrawProc --
 *
 *
 *      Utility function to add a UserPaneDrawProc
 *      Utility function to add a UserPaneDrawProc
 *      to a userPane control.  From MoreControls code
 *      to a userPane control.  From MoreControls code
 *      from Apple DTS.
 *      from Apple DTS.
 *
 *
 * Results:
 * Results:
 *      MacOS system error.
 *      MacOS system error.
 *
 *
 * Side effects:
 * Side effects:
 *      The user pane gets a new UserPaneDrawProc.
 *      The user pane gets a new UserPaneDrawProc.
 *
 *
 *--------------------------------------------------------------
 *--------------------------------------------------------------
 */
 */
pascal OSErr SetUserPaneDrawProc (
pascal OSErr SetUserPaneDrawProc (
        ControlRef control,
        ControlRef control,
        ControlUserPaneDrawProcPtr upp)
        ControlUserPaneDrawProcPtr upp)
{
{
    ControlUserPaneDrawUPP myControlUserPaneDrawUPP;
    ControlUserPaneDrawUPP myControlUserPaneDrawUPP;
    myControlUserPaneDrawUPP = NewControlUserPaneDrawProc(upp);
    myControlUserPaneDrawUPP = NewControlUserPaneDrawProc(upp);
    return SetControlData (control,
    return SetControlData (control,
                kControlNoPart, kControlUserPaneDrawProcTag,
                kControlNoPart, kControlUserPaneDrawProcTag,
                sizeof(myControlUserPaneDrawUPP),
                sizeof(myControlUserPaneDrawUPP),
                (Ptr) &myControlUserPaneDrawUPP);
                (Ptr) &myControlUserPaneDrawUPP);
}
}


/*
/*
 *--------------------------------------------------------------
 *--------------------------------------------------------------
 *
 *
 * SetUserPaneSetUpSpecialBackgroundProc --
 * SetUserPaneSetUpSpecialBackgroundProc --
 *
 *
 *      Utility function to add a UserPaneBackgroundProc
 *      Utility function to add a UserPaneBackgroundProc
 *      to a userPane control
 *      to a userPane control
 *
 *
 * Results:
 * Results:
 *      MacOS system error.
 *      MacOS system error.
 *
 *
 * Side effects:
 * Side effects:
 *      The user pane gets a new UserPaneBackgroundProc.
 *      The user pane gets a new UserPaneBackgroundProc.
 *
 *
 *--------------------------------------------------------------
 *--------------------------------------------------------------
 */
 */
pascal OSErr
pascal OSErr
SetUserPaneSetUpSpecialBackgroundProc(
SetUserPaneSetUpSpecialBackgroundProc(
    ControlRef control,
    ControlRef control,
    ControlUserPaneBackgroundProcPtr upp)
    ControlUserPaneBackgroundProcPtr upp)
{
{
    ControlUserPaneBackgroundUPP myControlUserPaneBackgroundUPP;
    ControlUserPaneBackgroundUPP myControlUserPaneBackgroundUPP;
    myControlUserPaneBackgroundUPP = NewControlUserPaneBackgroundProc(upp);
    myControlUserPaneBackgroundUPP = NewControlUserPaneBackgroundProc(upp);
    return SetControlData (control, kControlNoPart,
    return SetControlData (control, kControlNoPart,
                kControlUserPaneBackgroundProcTag,
                kControlUserPaneBackgroundProcTag,
                sizeof(myControlUserPaneBackgroundUPP),
                sizeof(myControlUserPaneBackgroundUPP),
                (Ptr) &myControlUserPaneBackgroundUPP);
                (Ptr) &myControlUserPaneBackgroundUPP);
}
}


/*
/*
 *--------------------------------------------------------------
 *--------------------------------------------------------------
 *
 *
 * UserPaneDraw --
 * UserPaneDraw --
 *
 *
 *      This function draws the background of the user pane that will
 *      This function draws the background of the user pane that will
 *      lie under checkboxes and radiobuttons.
 *      lie under checkboxes and radiobuttons.
 *
 *
 * Results:
 * Results:
 *      None.
 *      None.
 *
 *
 * Side effects:
 * Side effects:
 *      The user pane gets updated to the current color.
 *      The user pane gets updated to the current color.
 *
 *
 *--------------------------------------------------------------
 *--------------------------------------------------------------
 */
 */
pascal void
pascal void
UserPaneDraw(
UserPaneDraw(
    ControlRef control,
    ControlRef control,
    ControlPartCode cpc)
    ControlPartCode cpc)
{
{
        Rect contrlRect = (**control).contrlRect;
        Rect contrlRect = (**control).contrlRect;
        RGBBackColor (&gUserPaneBackground);
        RGBBackColor (&gUserPaneBackground);
        EraseRect (&contrlRect);
        EraseRect (&contrlRect);
}
}


/*
/*
 *--------------------------------------------------------------
 *--------------------------------------------------------------
 *
 *
 * UserPaneBackgroundProc --
 * UserPaneBackgroundProc --
 *
 *
 *      This function sets up the background of the user pane that will
 *      This function sets up the background of the user pane that will
 *      lie under checkboxes and radiobuttons.
 *      lie under checkboxes and radiobuttons.
 *
 *
 * Results:
 * Results:
 *      None.
 *      None.
 *
 *
 * Side effects:
 * Side effects:
 *      The user pane background gets set to the current color.
 *      The user pane background gets set to the current color.
 *
 *
 *--------------------------------------------------------------
 *--------------------------------------------------------------
 */
 */
 
 
pascal void
pascal void
UserPaneBackgroundProc(
UserPaneBackgroundProc(
    ControlHandle,
    ControlHandle,
    ControlBackgroundPtr info)
    ControlBackgroundPtr info)
{
{
    if (info->colorDevice) {
    if (info->colorDevice) {
        RGBBackColor (&gUserPaneBackground);
        RGBBackColor (&gUserPaneBackground);
    }
    }
}
}


/*
/*
 *--------------------------------------------------------------
 *--------------------------------------------------------------
 *
 *
 * UpdateControlColors --
 * UpdateControlColors --
 *
 *
 *      This function will review the colors used to display
 *      This function will review the colors used to display
 *      a Macintosh button.  If any non-standard colors are
 *      a Macintosh button.  If any non-standard colors are
 *      used we create a custom palette for the button, populate
 *      used we create a custom palette for the button, populate
 *      with the colors for the button and install the palette.
 *      with the colors for the button and install the palette.
 *
 *
 *      Under Appearance, we just set the pointer that will be
 *      Under Appearance, we just set the pointer that will be
 *      used by the UserPaneDrawProc.
 *      used by the UserPaneDrawProc.
 *
 *
 * Results:
 * Results:
 *      None.
 *      None.
 *
 *
 * Side effects:
 * Side effects:
 *      The Macintosh control may get a custom palette installed.
 *      The Macintosh control may get a custom palette installed.
 *
 *
 *--------------------------------------------------------------
 *--------------------------------------------------------------
 */
 */
 
 
static int
static int
UpdateControlColors(
UpdateControlColors(
    TkButton *butPtr,
    TkButton *butPtr,
    ControlRef controlHandle,
    ControlRef controlHandle,
    CCTabHandle ccTabHandle,
    CCTabHandle ccTabHandle,
    RGBColor *saveColorPtr)
    RGBColor *saveColorPtr)
{
{
    XColor *xcolor;
    XColor *xcolor;
 
 
    /*
    /*
     * Under Appearance we cannot change the background of the
     * Under Appearance we cannot change the background of the
     * button itself.  However, the color we are setting is the color
     * 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.
     * around the rounded corners of the button.
     * We make this the highlightbackground rather than the background,
     * We make this the highlightbackground rather than the background,
     * because if you color the background of a frame containing a
     * because if you color the background of a frame containing a
     * button, you usually also color the highlightbackground as well,
     * button, you usually also color the highlightbackground as well,
     * or you will get a thin grey ring around the button.
     * or you will get a thin grey ring around the button.
     */
     */
 
 
    if (TkMacHaveAppearance() && (butPtr->type == TYPE_BUTTON)) {
    if (TkMacHaveAppearance() && (butPtr->type == TYPE_BUTTON)) {
        xcolor = Tk_3DBorderColor(butPtr->highlightBorder);
        xcolor = Tk_3DBorderColor(butPtr->highlightBorder);
    } else {
    } else {
    xcolor = Tk_3DBorderColor(butPtr->normalBorder);
    xcolor = Tk_3DBorderColor(butPtr->normalBorder);
    }
    }
    if (TkMacHaveAppearance()) {
    if (TkMacHaveAppearance()) {
         TkSetMacColor(xcolor->pixel, &gUserPaneBackground);
         TkSetMacColor(xcolor->pixel, &gUserPaneBackground);
     } else {
     } else {
    (**ccTabHandle).ccSeed = 0;
    (**ccTabHandle).ccSeed = 0;
    (**ccTabHandle).ccRider = 0;
    (**ccTabHandle).ccRider = 0;
    (**ccTabHandle).ctSize = 3;
    (**ccTabHandle).ctSize = 3;
    (**ccTabHandle).ctTable[0].value = cBodyColor;
    (**ccTabHandle).ctTable[0].value = cBodyColor;
    TkSetMacColor(xcolor->pixel,
    TkSetMacColor(xcolor->pixel,
        &(**ccTabHandle).ctTable[0].rgb);
        &(**ccTabHandle).ctTable[0].rgb);
    (**ccTabHandle).ctTable[1].value = cTextColor;
    (**ccTabHandle).ctTable[1].value = cTextColor;
    TkSetMacColor(butPtr->normalFg->pixel,
    TkSetMacColor(butPtr->normalFg->pixel,
        &(**ccTabHandle).ctTable[1].rgb);
        &(**ccTabHandle).ctTable[1].rgb);
    (**ccTabHandle).ctTable[2].value = cFrameColor;
    (**ccTabHandle).ctTable[2].value = cFrameColor;
    TkSetMacColor(butPtr->highlightColorPtr->pixel,
    TkSetMacColor(butPtr->highlightColorPtr->pixel,
        &(**ccTabHandle).ctTable[2].rgb);
        &(**ccTabHandle).ctTable[2].rgb);
    SetControlColor(controlHandle, ccTabHandle);
    SetControlColor(controlHandle, ccTabHandle);
 
 
    if (((xcolor->pixel >> 24) != CONTROL_BODY_PIXEL) &&
    if (((xcolor->pixel >> 24) != CONTROL_BODY_PIXEL) &&
            ((butPtr->type == TYPE_CHECK_BUTTON) ||
            ((butPtr->type == TYPE_CHECK_BUTTON) ||
                    (butPtr->type == TYPE_RADIO_BUTTON))) {
                    (butPtr->type == TYPE_RADIO_BUTTON))) {
        RGBColor newColor;
        RGBColor newColor;
 
 
        TkSetMacColor(xcolor->pixel, &newColor);
        TkSetMacColor(xcolor->pixel, &newColor);
        ChangeBackgroundWindowColor((**controlHandle).contrlOwner,
        ChangeBackgroundWindowColor((**controlHandle).contrlOwner,
                newColor, saveColorPtr);
                newColor, saveColorPtr);
        return true;
        return true;
    }
    }
    }
    }
 
 
    return false;
    return false;
}
}


/*
/*
 *--------------------------------------------------------------
 *--------------------------------------------------------------
 *
 *
 * ChangeBackgroundWindowColor --
 * ChangeBackgroundWindowColor --
 *
 *
 *      This procedure will change the background color entry
 *      This procedure will change the background color entry
 *      in the Window's colortable.  The system isn't notified
 *      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.
 *      the drawing routines for checkboxes and radiobuttons.
 *      Any change should be temporary and be reverted after
 *      Any change should be temporary and be reverted after
 *      the widget is drawn.
 *      the widget is drawn.
 *
 *
 * Results:
 * Results:
 *      None.
 *      None.
 *
 *
 * Side effects:
 * Side effects:
 *      The Window's color table will be adjusted.
 *      The Window's color table will be adjusted.
 *
 *
 *--------------------------------------------------------------
 *--------------------------------------------------------------
 */
 */
 
 
static void
static void
ChangeBackgroundWindowColor(
ChangeBackgroundWindowColor(
    WindowRef macintoshWindow,  /* A Mac window whose color to change. */
    WindowRef macintoshWindow,  /* A Mac window whose color to change. */
    RGBColor rgbColor,          /* The new RGB Color for the background. */
    RGBColor rgbColor,          /* The new RGB Color for the background. */
    RGBColor *oldColor)         /* The old color of the background. */
    RGBColor *oldColor)         /* The old color of the background. */
{
{
    AuxWinHandle auxWinHandle;
    AuxWinHandle auxWinHandle;
    WCTabHandle winCTabHandle;
    WCTabHandle winCTabHandle;
    short ctIndex;
    short ctIndex;
    ColorSpecPtr rgbScan;
    ColorSpecPtr rgbScan;
 
 
    GetAuxWin(macintoshWindow, &auxWinHandle);
    GetAuxWin(macintoshWindow, &auxWinHandle);
    winCTabHandle = (WCTabHandle) ((**auxWinHandle).awCTable);
    winCTabHandle = (WCTabHandle) ((**auxWinHandle).awCTable);
 
 
    /*
    /*
     * Scan through the color table until we find the content
     * Scan through the color table until we find the content
     * (background) color for the window.  Don't tell the system
     * (background) color for the window.  Don't tell the system
     * about the change - it will generate damage and we will get
     * about the change - it will generate damage and we will get
     * into an infinite loop.
     * into an infinite loop.
     */
     */
 
 
    ctIndex = (**winCTabHandle).ctSize;
    ctIndex = (**winCTabHandle).ctSize;
    while (ctIndex > -1) {
    while (ctIndex > -1) {
        rgbScan = ctIndex + (**winCTabHandle).ctTable;
        rgbScan = ctIndex + (**winCTabHandle).ctTable;
 
 
        if (rgbScan->value == wContentColor) {
        if (rgbScan->value == wContentColor) {
            *oldColor = rgbScan->rgb;
            *oldColor = rgbScan->rgb;
            rgbScan->rgb = rgbColor;
            rgbScan->rgb = rgbColor;
            break;
            break;
        }
        }
        ctIndex--;
        ctIndex--;
    }
    }
}
}


/*
/*
 *----------------------------------------------------------------------
 *----------------------------------------------------------------------
 *
 *
 * ButtonExitProc --
 * ButtonExitProc --
 *
 *
 *      This procedure is invoked just before the application exits.
 *      This procedure is invoked just before the application exits.
 *      It frees all of the control handles, our dummy window, etc.
 *      It frees all of the control handles, our dummy window, etc.
 *
 *
 * Results:
 * Results:
 *      None.
 *      None.
 *
 *
 * Side effects:
 * Side effects:
 *      Memory is freed.
 *      Memory is freed.
 *
 *
 *----------------------------------------------------------------------
 *----------------------------------------------------------------------
 */
 */
 
 
static void
static void
ButtonExitProc(clientData)
ButtonExitProc(clientData)
    ClientData clientData;              /* Not used. */
    ClientData clientData;              /* Not used. */
{
{
    Rect pixRect = {0, 0, 10, 10};
    Rect pixRect = {0, 0, 10, 10};
    Rect rgnRect = {0, 0, 0, 0};
    Rect rgnRect = {0, 0, 0, 0};
 
 
    /*
    /*
     * Restore our dummy window to it's origional state by putting it
     * 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.
     * the controls and window.
     */
     */
 
 
    ((CWindowPeek) windowRef)->nextWindow = (CWindowPeek) LMGetWindowList();
    ((CWindowPeek) windowRef)->nextWindow = (CWindowPeek) LMGetWindowList();
    LMSetWindowList(windowRef);
    LMSetWindowList(windowRef);
    ((CWindowPeek) windowRef)->port.portPixMap = oldPixPtr;
    ((CWindowPeek) windowRef)->port.portPixMap = oldPixPtr;
    ((CWindowPeek) windowRef)->port.portRect = pixRect;
    ((CWindowPeek) windowRef)->port.portRect = pixRect;
    RectRgn(((CWindowPeek) windowRef)->port.visRgn, &rgnRect);
    RectRgn(((CWindowPeek) windowRef)->port.visRgn, &rgnRect);
    RectRgn(((CWindowPeek) windowRef)->strucRgn, &rgnRect);
    RectRgn(((CWindowPeek) windowRef)->strucRgn, &rgnRect);
    RectRgn(((CWindowPeek) windowRef)->updateRgn, &rgnRect);
    RectRgn(((CWindowPeek) windowRef)->updateRgn, &rgnRect);
    RectRgn(((CWindowPeek) windowRef)->contRgn, &rgnRect);
    RectRgn(((CWindowPeek) windowRef)->contRgn, &rgnRect);
    PortChanged(windowRef);
    PortChanged(windowRef);
 
 
    DisposeControl(buttonHandle);
    DisposeControl(buttonHandle);
    DisposeControl(checkHandle);
    DisposeControl(checkHandle);
    DisposeControl(radioHandle);
    DisposeControl(radioHandle);
    DisposeWindow(windowRef);
    DisposeWindow(windowRef);
    windowRef = NULL;
    windowRef = NULL;
}
}
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.