head	1.29;
access;
symbols
	core-8-5-9:1.25.2.1
	core-8-5-8:1.25.2.1
	macosx-cocoa-merge:1.26
	macosx-cocoa-premerge:1.26
	macosx-carbon-freeze:1.26
	core-8-5-7:1.25
	core-8-5-6:1.25
	core-8-6-b1:1.26
	core-8-6-a3:1.25
	core-8-5-5:1.25
	core-8-6-a2:1.25
	core-8-5-4:1.25
	core-8-5-3:1.25
	core-8-6-a1:1.25
	core-8-4-19:1.11.2.5
	core-8-5-branch:1.25.0.2
	core-8-5-2:1.25
	core-8-4-18:1.11.2.5
	core-8-5-1:1.25
	core-8-4-17:1.11.2.5
	core-8-5-0:1.25
	core-8-5-b3:1.24
	core-8-5-b2:1.24
	core-8-4-16:1.11.2.5
	core-8-5-b1:1.24
	core-stablilizer-merge:1.23
	core-stabilizer-branch:1.23.0.2
	core-stabilizer-merge:1.25
	core-8-4-15:1.11.2.5
	core-8-5-a6:1.23
	core-8-5-a5:1.22
	core-8-4-14:1.11.2.5
	core-8-5-a4:1.22
	core-8-4-13:1.11.2.5
	core-8-4-12:1.11.2.5
	core-8-4-11:1.11.2.5
	core-8-5-a3:1.20
	core-8-4-10:1.11.2.5
	core-8-4-9-branch:1.11.2.5.0.2
	core-8-5-a2:1.20
	core-8-4-9:1.11.2.5
	core-8-4-8:1.11.2.4
	core-8-4-7:1.11.2.4
	core-8-5-a1:1.17
	core-8-4-6:1.11.2.4
	core-8-4-5:1.11.2.4
	mistachkin-dev-branch:1.15.0.2
	core-8-4-4:1.11.2.3
	core-8-4-3:1.11.2.3
	core-8-4-branch:1.11.0.2
	core-8-4-2:1.11
	core-8-4-1:1.10
	core-8-3-5:1.3
	core-8-4-0:1.10
	macosx-8-4-merge-2002-08-31-trunk:1.10
	macosx-8-4-premerge-2002-08-31-branch:1.8.4.2
	macosx-8-4-premerge-2002-08-31-trunk:1.10
	macosx-8-4-merge-2002-08-30-branch:1.8.4.2
	macosx-8-4-merge-2002-08-30-trunk:1.10
	macosx-8-4-merge-2002-08-20-branch:1.8.4.1
	macosx-8-4-merge-2002-08-20-trunk:1.9
	core-8-4-b2:1.9
	core-8-4-b1:1.9
	macosx-premerge-6-9-02:1.8
	core-8-4-a4:1.8
	core-8-3-4:1.3
	macosx-8-4-branch:1.8.0.4
	macosx-8-4-branchpoint:1.8
	core-8-4-a3:1.8
	core-8-3-3:1.3
	dgp-privates-into-namespace:1.8.0.2
	tclpro-1-5-0:1.3
	core-8-4-win-speedup:1.7.0.2
	core-8-4-a2:1.7
	tclpro-1-4-1:1.3
	tclpro-1-4-0:1.3
	core-8-3-2:1.3
	ajuba-ajuba2-2-1-base:1.3
	ajuba-ajuba2-2-0:1.3
	core-8-4-a1:1.6
	core-8-3-1-branch:1.3.0.12
	core-8-3-1:1.3
	scriptics-sc-2-0-b5:1.3
	scriptics-sc-2-0-fixed:1.3
	scriptics-sc-2-0-b2:1.3
	scriptics-sc-2-0-b1:1.3
	core-8-3-0:1.3
	core-8-3-b2:1.3
	core-8-3-b1:1.3
	scriptics-sc-1-1:1.3
	scriptics-sc-1-1-b1:1.3
	core-8-2-3:1.3
	scriptics-sc-1-1-branch:1.3.0.10
	scriptics-sc-1-1-base:1.3
	scriptics-sc-1-0:1.3
	scriptics-sc-1-0-branch:1.3.0.8
	scriptics-sc-1-0-base:1.3
	core-8-2-2:1.3
	core-8-2-1:1.3
	scriptics-bc-1-0-b1:1.3
	core-8-2-1-branch:1.3.0.6
	scriptics-tclpro-1-3-0:1.3
	core-8-2-0:1.3
	core-8-2-b3-branch:1.3.0.4
	core-8-2-b3-base:1.3
	scriptics-tclpro-1-3-b4:1.3
	core-8-2-b2:1.3
	scriptics-tclpro-1-3-b3:1.3
	core-8-2-b1:1.3
	scriptics-tclpro-1-3-b2:1.3
	merge-to-mainline-5/21/99:1.3
	scriptics-tclpro-1-3-b2-branch:1.3.0.2
	core-8-1-1:1.3
	scriptics-tclpro-1-3-b1:1.3
	core-8-1-1-base:1.3
	core-8-1-0:1.3
	merge-to-mainline-4-29-99:1.3
	merge-to-mainline-4-23-99:1.3
	core-8-1-branch-old:1.1.0.4
	core-8-0-6-branch:1.2.0.6
	core-8-0-6-base:1.2
	core-8-0-5:1.2
	core-8-1-b3:1.1.4.3
	core-8-1-b2:1.1.4.2
	dev-8-1-stubs-branch:1.1.4.2.0.2
	dev-stubs-branch:1.2.0.4
	scriptics-tclpro-1-2:1.2
	scriptics-tclpro-1-2-b2:1.2
	core-8-1-merge-2/10/99:1.2
	core-8-0-5-branch:1.2.0.2
	core-8-0-5-base:1.2
	scriptics-tclpro-1-2-b1:1.2
	scriptics-tclpro-1-2-a1:1.2
	core-8-1-b1:1.1.4.2
	core-8-0-4:1.2
	core-8-1-a2:1.1.4.1
	core-8-0-2:1.1
	core-8-0-3:1.2;
locks; strict;
comment	@ * @;


1.29
date	2010.02.05.22.45.03;	author nijtmans;	state Exp;
branches;
next	1.28;

1.28
date	2010.01.13.23.08.11;	author nijtmans;	state Exp;
branches;
next	1.27;

1.27
date	2009.10.24.00.01.48;	author dkf;	state Exp;
branches;
next	1.26;

1.26
date	2008.11.05.22.20.59;	author nijtmans;	state Exp;
branches;
next	1.25;

1.25
date	2007.12.13.15.28.50;	author dgp;	state Exp;
branches
	1.25.2.1;
next	1.24;

1.24
date	2007.09.07.00.34.57;	author dgp;	state Exp;
branches;
next	1.23;

1.23
date	2007.02.27.14.52.56;	author dkf;	state Exp;
branches
	1.23.2.1;
next	1.22;

1.22
date	2005.11.27.02.36.16;	author das;	state Exp;
branches;
next	1.21;

1.21
date	2005.11.14.11.54.21;	author dkf;	state Exp;
branches;
next	1.20;

1.20
date	2004.12.02.02.10.38;	author hobbs;	state Exp;
branches;
next	1.19;

1.19
date	2004.05.04.00.39.51;	author hobbs;	state Exp;
branches;
next	1.18;

1.18
date	2004.03.16.19.55.12;	author hobbs;	state Exp;
branches;
next	1.17;

1.17
date	2004.02.18.00.40.24;	author hobbs;	state Exp;
branches;
next	1.16;

1.16
date	2003.10.10.20.19.51;	author hobbs;	state Exp;
branches;
next	1.15;

1.15
date	2003.08.14.12.30.11;	author dkf;	state Exp;
branches;
next	1.14;

1.14
date	2003.08.14.10.31.14;	author dkf;	state Exp;
branches;
next	1.13;

1.13
date	2003.04.26.02.59.20;	author hobbs;	state Exp;
branches;
next	1.12;

1.12
date	2003.04.25.20.03.43;	author hobbs;	state Exp;
branches;
next	1.11;

1.11
date	2003.02.25.01.39.57;	author hobbs;	state Exp;
branches
	1.11.2.1;
next	1.10;

1.10
date	2002.08.28.01.08.06;	author drh;	state Exp;
branches;
next	1.9;

1.9
date	2002.06.17.10.54.29;	author drh;	state Exp;
branches;
next	1.8;

1.8
date	2000.11.22.01.49.38;	author ericm;	state Exp;
branches
	1.8.4.1;
next	1.7;

1.7
date	2000.07.29.01.08.54;	author ericm;	state Exp;
branches
	1.7.2.1;
next	1.6;

1.6
date	2000.05.17.21.17.22;	author ericm;	state Exp;
branches;
next	1.5;

1.5
date	2000.05.13.00.39.09;	author ericm;	state Exp;
branches;
next	1.4;

1.4
date	2000.05.10.00.09.40;	author ericm;	state Exp;
branches;
next	1.3;

1.3
date	99.04.16.01.51.45;	author stanton;	state Exp;
branches;
next	1.2;

1.2
date	98.09.14.18.23.55;	author stanton;	state Exp;
branches;
next	1.1;

1.1
date	98.04.01.09.59.33;	author rjohnson;	state Exp;
branches
	1.1.4.1;
next	;

1.1.4.1
date	98.09.29.00.25.59;	author stanton;	state Exp;
branches;
next	1.1.4.2;

1.1.4.2
date	98.09.30.02.19.14;	author stanton;	state Exp;
branches;
next	1.1.4.3;

1.1.4.3
date	99.03.30.04.12.59;	author stanton;	state Exp;
branches;
next	;

1.7.2.1
date	2002.04.02.20.58.01;	author hobbs;	state Exp;
branches;
next	;

1.8.4.1
date	2002.08.20.20.27.18;	author das;	state Exp;
branches;
next	1.8.4.2;

1.8.4.2
date	2002.08.30.15.36.13;	author das;	state Exp;
branches;
next	;

1.11.2.1
date	2003.04.25.20.11.30;	author hobbs;	state Exp;
branches;
next	1.11.2.2;

1.11.2.2
date	2003.04.26.02.53.47;	author hobbs;	state Exp;
branches;
next	1.11.2.3;

1.11.2.3
date	2003.04.26.02.58.17;	author hobbs;	state Exp;
branches;
next	1.11.2.4;

1.11.2.4
date	2003.10.10.20.20.47;	author hobbs;	state Exp;
branches;
next	1.11.2.5;

1.11.2.5
date	2004.12.02.02.07.43;	author hobbs;	state Exp;
branches;
next	;

1.23.2.1
date	2007.09.07.01.25.37;	author dgp;	state Exp;
branches;
next	;

1.25.2.1
date	2009.10.24.00.12.03;	author dkf;	state Exp;
branches;
next	;


desc
@@


1.29
log
@Make more internal tables "const"
tk*Decls.h (regenerated with new genStubs.tcl from Tcl)
@
text
@/*
 * tkUnixButton.c --
 *
 *	This file implements the Unix specific portion of the button widgets.
 *
 * Copyright (c) 1996-1997 by Sun Microsystems, Inc.
 *
 * See the file "license.terms" for information on usage and redistribution of
 * this file, and for a DISCLAIMER OF ALL WARRANTIES.
 *
 * RCS: @@(#) $Id: tkUnixButton.c,v 1.28 2010/01/13 23:08:11 nijtmans Exp $
 */

#include "tkInt.h"
#include "tkButton.h"
#include "tk3d.h"

/*
 * Shared with menu widget.
 */

MODULE_SCOPE void	TkpDrawCheckIndicator(Tk_Window tkwin,
			    Display *display, Drawable d, int x, int y,
			    Tk_3DBorder bgBorder, XColor *indicatorColor,
			    XColor *selectColor, XColor *disColor, int on,
			    int disabled, int mode);

/*
 * Declaration of Unix specific button structure.
 */

typedef struct UnixButton {
    TkButton info;		/* Generic button info. */
} UnixButton;

/*
 * The class function table for the button widgets.
 */

const Tk_ClassProcs tkpButtonProcs = {
    sizeof(Tk_ClassProcs),	/* size */
    TkButtonWorldChanged,	/* worldChangedProc */
    NULL,					/* createProc */
    NULL					/* modalProc */
};

/*
 * The button image.
 * The header info here is ignored, it's the image that's important. The
 * colors will be applied as follows:
 *   A = Background
 *   B = Background
 *   C = 3D light
 *   D = selectColor
 *   E = 3D dark
 *   F = Background
 *   G = Indicator Color
 *   H = disabled Indicator Color
 */

/* XPM */
static const char *const button_images[] = {
    /* width height ncolors chars_per_pixel */
    "52 26 7 1",
    /* colors */
    "A c #808000000000",
    "B c #000080800000",
    "C c #808080800000",
    "D c #000000008080",
    "E c #808000008080",
    "F c #000080808080",
    "G c #000000000000",
    "H c #000080800000",
    /* pixels */
    "AAAAAAAAAAAABAAAAAAAAAAAABAAAAAAAAAAAABAAAAAAAAAAAAB",
    "AEEEEEEEEEECBAEEEEEEEEEECBAEEEEEEEEEECBAEEEEEEEEEECB",
    "AEDDDDDDDDDCBAEDDDDDDDDDCBAEFFFFFFFFFCBAEFFFFFFFFFCB",
    "AEDDDDDDDDDCBAEDDDDDDDGDCBAEFFFFFFFFFCBAEFFFFFFFHFCB",
    "AEDDDDDDDDDCBAEDDDDDDGGDCBAEFFFFFFFFFCBAEFFFFFFHHFCB",
    "AEDDDDDDDDDCBAEDGDDDGGGDCBAEFFFFFFFFFCBAEFHFFFHHHFCB",
    "AEDDDDDDDDDCBAEDGGDGGGDDCBAEFFFFFFFFFCBAEFHHFHHHFFCB",
    "AEDDDDDDDDDCBAEDGGGGGDDDCBAEFFFFFFFFFCBAEFHHHHHFFFCB",
    "AEDDDDDDDDDCBAEDDGGGDDDDCBAEFFFFFFFFFCBAEFFHHHFFFFCB",
    "AEDDDDDDDDDCBAEDDDGDDDDDCBAEFFFFFFFFFCBAEFFFHFFFFFCB",
    "AEDDDDDDDDDCBAEDDDDDDDDDCBAEFFFFFFFFFCBAEFFFFFFFFFCB",
    "ACCCCCCCCCCCBACCCCCCCCCCCBACCCCCCCCCCCBACCCCCCCCCCCB",
    "BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB",
    "FFFFAAAAFFFFFFFFFAAAAFFFFFFFFFAAAAFFFFFFFFFAAAAFFFFF",
    "FFAAEEEEAAFFFFFAAEEEEAAFFFFFAAEEEEAAFFFFFAAEEEEAAFFF",
    "FAEEDDDDEEBFFFAEEDDDDEEBFFFAEEFFFFEEBFFFAEEFFFFEEBFF",
    "FAEDDDDDDCBFFFAEDDDDDDCBFFFAEFFFFFFCBFFFAEFFFFFFCBFF",
    "AEDDDDDDDDCBFAEDDDGGDDDCBFAEFFFFFFFFCBFAEFFFHHFFFCBF",
    "AEDDDDDDDDCBFAEDDGGGGDDCBFAEFFFFFFFFCBFAEFFHHHHFFCBF",
    "AEDDDDDDDDCBFAEDDGGGGDDCBFAEFFFFFFFFCBFAEFFHHHHFFCBF",
    "AEDDDDDDDDCBFAEDDDGGDDDCBFAEFFFFFFFFCBFAEFFFHHFFFCBF",
    "FAEDDDDDDCBFFFAEDDDDDDCBFFFAEFFFFFFCBFFFAEFFFFFFCBFF",
    "FACCDDDDCCBFFFACCDDDDCCBFFFACCFFFFCCBFFFACCFFFFCCBFF",
    "FFBBCCCCBBFFFFFBBCCCCBBFFFFFBBCCCCBBFFFFFBBCCCCBBFFF",
    "FFFFBBBBFFFFFFFFFBBBBFFFFFFFFFBBBBFFFFFFFFFBBBBFFFFF",
    "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF",
};

/*
 * Sizes and offsets into above XPM file.
 */

#define CHECK_BUTTON_DIM    13
#define CHECK_MENU_DIM       9
#define CHECK_START          9
#define CHECK_ON_OFFSET     13
#define CHECK_OFF_OFFSET     0
#define CHECK_DISON_OFFSET  39
#define CHECK_DISOFF_OFFSET 26
#define RADIO_BUTTON_DIM    12
#define RADIO_MENU_DIM       6
#define RADIO_WIDTH         13
#define RADIO_START         22
#define RADIO_ON_OFFSET     13
#define RADIO_OFF_OFFSET     0
#define RADIO_DISON_OFFSET  39
#define RADIO_DISOFF_OFFSET 26

/*
 * Indicator Draw Modes
 */

#define CHECK_BUTTON 0
#define CHECK_MENU   1
#define RADIO_BUTTON 2
#define RADIO_MENU   3

/*
 *----------------------------------------------------------------------
 *
 * TkpDrawCheckIndicator -
 *
 *	Draws the checkbox image in the drawable at the (x,y) location, value,
 *	and state given. This routine is use by the button and menu widgets
 *
 * Results:
 *	None.
 *
 * Side effects:
 *	An image is drawn in the drawable at the location given.
 *
 *----------------------------------------------------------------------
 */

void
TkpDrawCheckIndicator(
    Tk_Window tkwin,		/* handle for resource alloc */
    Display *display,
    Drawable d,			/* what to draw on */
    int x, int y,		/* where to draw */
    Tk_3DBorder bgBorder,	/* colors of the border */
    XColor *indicatorColor,	/* color of the indicator */
    XColor *selectColor,	/* color when selected */
    XColor *disableColor,	/* color when disabled */
    int on,			/* are we on? */
    int disabled,		/* are we disabled? */
    int mode)			/* kind of indicator to draw */
{
    int ix, iy;
    int dim;
    int imgsel, imgstart;
    TkBorder *bg_brdr = (TkBorder*)bgBorder;
    XGCValues gcValues;
    GC copyGC;
    unsigned long imgColors[8];
    XImage *img;
    Pixmap pixmap;
    int depth;

    /*
     * Sanity check.
     */

    if (tkwin == NULL || display == None || d == None || bgBorder == NULL
	    || indicatorColor == NULL) {
	return;
    }

    if (disableColor == NULL) {
	disableColor = bg_brdr->bgColorPtr;
    }

    if (selectColor == NULL) {
	selectColor = bg_brdr->bgColorPtr;
    }

    depth = Tk_Depth(tkwin);

    /*
     * Compute starting point and dimensions of image inside button_images to
     * be used.
     */

    switch (mode) {
    default:
    case CHECK_BUTTON:
	imgsel = on == 2 ? CHECK_DISON_OFFSET :
		on == 1 ? CHECK_ON_OFFSET : CHECK_OFF_OFFSET;
	imgsel += disabled && on != 2 ? CHECK_DISOFF_OFFSET : 0;
	imgstart = CHECK_START;
	dim = CHECK_BUTTON_DIM;
	break;

    case CHECK_MENU:
	imgsel = on == 2 ? CHECK_DISOFF_OFFSET :
		on == 1 ? CHECK_ON_OFFSET : CHECK_OFF_OFFSET;
	imgsel += disabled && on != 2 ? CHECK_DISOFF_OFFSET : 0;
	imgstart = CHECK_START + 2;
	imgsel += 2;
	dim = CHECK_MENU_DIM;
	break;

    case RADIO_BUTTON:
	imgsel = on == 2 ? RADIO_DISON_OFFSET :
		on==1 ? RADIO_ON_OFFSET : RADIO_OFF_OFFSET;
	imgsel += disabled && on != 2 ? RADIO_DISOFF_OFFSET : 0;
	imgstart = RADIO_START;
	dim = RADIO_BUTTON_DIM;
	break;

    case RADIO_MENU:
	imgsel = on == 2 ? RADIO_DISOFF_OFFSET :
		on==1 ? RADIO_ON_OFFSET : RADIO_OFF_OFFSET;
	imgsel += disabled && on != 2 ? RADIO_DISOFF_OFFSET : 0;
	imgstart = RADIO_START + 3;
	imgsel += 3;
	dim = RADIO_MENU_DIM;
	break;
    }

    /*
     * Allocate the drawing areas to use. Note that we use double-buffering
     * here because not all code paths leading to this function do so.
     */

    pixmap = Tk_GetPixmap(display, d, dim, dim, depth);
    if (pixmap == None) {
	return;
    }

    x -= dim/2;
    y -= dim/2;

    img = XGetImage(display, pixmap, 0, 0,
	    (unsigned int)dim, (unsigned int)dim, AllPlanes, ZPixmap);
    if (img == NULL) {
	return;
    }

    /*
     * Set up the color mapping table.
     */

    TkpGetShadows(bg_brdr, tkwin);

    imgColors[0 /*A*/] =
	    Tk_GetColorByValue(tkwin, bg_brdr->bgColorPtr)->pixel;
    imgColors[1 /*B*/] =
	    Tk_GetColorByValue(tkwin, bg_brdr->bgColorPtr)->pixel;
    imgColors[2 /*C*/] = (bg_brdr->lightColorPtr != NULL) ?
	    Tk_GetColorByValue(tkwin, bg_brdr->lightColorPtr)->pixel :
	    WhitePixelOfScreen(bg_brdr->screen);
    imgColors[3 /*D*/] =
	    Tk_GetColorByValue(tkwin, selectColor)->pixel;
    imgColors[4 /*E*/] = (bg_brdr->darkColorPtr != NULL) ?
	    Tk_GetColorByValue(tkwin, bg_brdr->darkColorPtr)->pixel :
	    BlackPixelOfScreen(bg_brdr->screen);
    imgColors[5 /*F*/] =
	    Tk_GetColorByValue(tkwin, bg_brdr->bgColorPtr)->pixel;
    imgColors[6 /*G*/] =
	    Tk_GetColorByValue(tkwin, indicatorColor)->pixel;
    imgColors[7 /*H*/] =
	    Tk_GetColorByValue(tkwin, disableColor)->pixel;

    /*
     * Create the image, painting it into an XImage one pixel at a time.
     */

    for (iy=0 ; iy<dim ; iy++) {
	for (ix=0 ; ix<dim ; ix++) {
	    XPutPixel(img, ix, iy,
		    imgColors[button_images[imgstart+iy][imgsel+ix] - 'A']);
	}
    }

    /*
     * Copy onto our target drawable surface.
     */

    memset(&gcValues, 0, sizeof(gcValues));
    gcValues.background = bg_brdr->bgColorPtr->pixel;
    gcValues.graphics_exposures = False;
    copyGC = Tk_GetGC(tkwin, 0, &gcValues);

    XPutImage(display, pixmap, copyGC, img, 0, 0, 0, 0,
	    (unsigned)dim, (unsigned)dim);
    XCopyArea(display, pixmap, d, copyGC, 0, 0,
	    (unsigned)dim, (unsigned)dim, x, y);

    /*
     * Tidy up.
     */

    Tk_FreeGC(display, copyGC);
    XDestroyImage(img);
    Tk_FreePixmap(display, pixmap);
}

/*
 *----------------------------------------------------------------------
 *
 * TkpCreateButton --
 *
 *	Allocate a new TkButton structure.
 *
 * Results:
 *	Returns a newly allocated TkButton structure.
 *
 * Side effects:
 *	Registers an event handler for the widget.
 *
 *----------------------------------------------------------------------
 */

TkButton *
TkpCreateButton(
    Tk_Window tkwin)
{
    UnixButton *butPtr = (UnixButton *) ckalloc(sizeof(UnixButton));
    return (TkButton *) butPtr;
}

/*
 *----------------------------------------------------------------------
 *
 * TkpDisplayButton --
 *
 *	This function is invoked to display a button widget. It is normally
 *	invoked as an idle handler.
 *
 * Results:
 *	None.
 *
 * Side effects:
 *	Commands are output to X to display the button in its current mode.
 *	The REDRAW_PENDING flag is cleared.
 *
 *----------------------------------------------------------------------
 */

void
TkpDisplayButton(
    ClientData clientData)	/* Information about widget. */
{
    register TkButton *butPtr = (TkButton *) clientData;
    GC gc;
    Tk_3DBorder border;
    Pixmap pixmap;
    int x = 0;			/* Initialization only needed to stop compiler
				 * warning. */
    int y, relief;
    Tk_Window tkwin = butPtr->tkwin;
    int width, height, fullWidth, fullHeight;
    int textXOffset, textYOffset;
    int haveImage = 0, haveText = 0;
    int offset;			/* 1 means this is a button widget, so we
				 * offset the text to make the button appear
				 * to move up and down as the relief
				 * changes. */
    int imageWidth, imageHeight;
    int imageXOffset = 0, imageYOffset = 0;
				/* image information that will be used to
				 * restrict disabled pixmap as well */

    butPtr->flags &= ~REDRAW_PENDING;
    if ((butPtr->tkwin == NULL) || !Tk_IsMapped(tkwin)) {
	return;
    }

    border = butPtr->normalBorder;
    if ((butPtr->state == STATE_DISABLED) && (butPtr->disabledFg != NULL)) {
	gc = butPtr->disabledGC;
    } else if ((butPtr->state == STATE_ACTIVE)
	    && !Tk_StrictMotif(butPtr->tkwin)) {
	gc = butPtr->activeTextGC;
	border = butPtr->activeBorder;
    } else {
	gc = butPtr->normalTextGC;
    }
    if ((butPtr->flags & SELECTED) && (butPtr->selectBorder != NULL)
	    && !butPtr->indicatorOn) {
	border = butPtr->selectBorder;
    }

    /*
     * Override the relief specified for the button if this is a checkbutton
     * or radiobutton and there's no indicator. The new relief is as follows:
     *      If the button is select  --> "sunken"
     *      If relief==overrelief    --> relief
     *      Otherwise                --> overrelief
     *
     * The effect we are trying to achieve is as follows:
     *
     *      value    mouse-over?   -->   relief
     *     -------  ------------        --------
     *       off        no               flat
     *       off        yes              raised
     *       on         no               sunken
     *       on         yes              sunken
     *
     * This is accomplished by configuring the checkbutton or radiobutton like
     * this:
     *
     *     -indicatoron 0 -overrelief raised -offrelief flat
     *
     * Bindings (see library/button.tcl) will copy the -overrelief into
     * -relief on mouseover. Hence, we can tell if we are in mouse-over by
     * comparing relief against overRelief. This is an aweful kludge, but it
     * gives use the desired behavior while keeping the code backwards
     * compatible.
     */

    relief = butPtr->relief;
    if ((butPtr->type >= TYPE_CHECK_BUTTON) && !butPtr->indicatorOn) {
	if (butPtr->flags & SELECTED) {
	    relief = TK_RELIEF_SUNKEN;
	} else if (butPtr->overRelief != relief) {
	    relief = butPtr->offRelief;
	}
    }

    offset = (butPtr->type == TYPE_BUTTON) && !Tk_StrictMotif(butPtr->tkwin);

    /*
     * In order to avoid screen flashes, this function redraws the button in a
     * pixmap, then copies the pixmap to the screen in a single operation.
     * This means that there's no point in time where the on-screen image has
     * been cleared.
     */

    pixmap = Tk_GetPixmap(butPtr->display, Tk_WindowId(tkwin),
	    Tk_Width(tkwin), Tk_Height(tkwin), Tk_Depth(tkwin));
    Tk_Fill3DRectangle(tkwin, pixmap, border, 0, 0, Tk_Width(tkwin),
	    Tk_Height(tkwin), 0, TK_RELIEF_FLAT);

    /*
     * Display image or bitmap or text for button.
     */

    if (butPtr->image != NULL) {
	Tk_SizeOfImage(butPtr->image, &width, &height);
	haveImage = 1;
    } else if (butPtr->bitmap != None) {
	Tk_SizeOfBitmap(butPtr->display, butPtr->bitmap, &width, &height);
	haveImage = 1;
    }
    imageWidth = width;
    imageHeight = height;

    haveText = (butPtr->textWidth != 0 && butPtr->textHeight != 0);

    if (butPtr->compound != COMPOUND_NONE && haveImage && haveText) {
	textXOffset = 0;
	textYOffset = 0;
	fullWidth = 0;
	fullHeight = 0;

	switch ((enum compound) butPtr->compound) {
	case COMPOUND_TOP:
	case COMPOUND_BOTTOM:
	    /*
	     * Image is above or below text.
	     */

	    if (butPtr->compound == COMPOUND_TOP) {
		textYOffset = height + butPtr->padY;
	    } else {
		imageYOffset = butPtr->textHeight + butPtr->padY;
	    }
	    fullHeight = height + butPtr->textHeight + butPtr->padY;
	    fullWidth = (width > butPtr->textWidth ? width :
		    butPtr->textWidth);
	    textXOffset = (fullWidth - butPtr->textWidth)/2;
	    imageXOffset = (fullWidth - width)/2;
	    break;
	case COMPOUND_LEFT:
	case COMPOUND_RIGHT:
	    /*
	     * Image is left or right of text.
	     */

	    if (butPtr->compound == COMPOUND_LEFT) {
		textXOffset = width + butPtr->padX;
	    } else {
		imageXOffset = butPtr->textWidth + butPtr->padX;
	    }
	    fullWidth = butPtr->textWidth + butPtr->padX + width;
	    fullHeight = (height > butPtr->textHeight ? height :
		    butPtr->textHeight);
	    textYOffset = (fullHeight - butPtr->textHeight)/2;
	    imageYOffset = (fullHeight - height)/2;
	    break;
	case COMPOUND_CENTER:
	    /*
	     * Image and text are superimposed.
	     */

	    fullWidth = (width > butPtr->textWidth ? width :
		    butPtr->textWidth);
	    fullHeight = (height > butPtr->textHeight ? height :
		    butPtr->textHeight);
	    textXOffset = (fullWidth - butPtr->textWidth)/2;
	    imageXOffset = (fullWidth - width)/2;
	    textYOffset = (fullHeight - butPtr->textHeight)/2;
	    imageYOffset = (fullHeight - height)/2;
	    break;
	case COMPOUND_NONE:
	    break;
	}

	TkComputeAnchor(butPtr->anchor, tkwin, butPtr->padX, butPtr->padY,
		butPtr->indicatorSpace + fullWidth, fullHeight, &x, &y);

	x += butPtr->indicatorSpace;

	x += offset;
	y += offset;
	if (relief == TK_RELIEF_RAISED) {
	    x -= offset;
	    y -= offset;
	} else if (relief == TK_RELIEF_SUNKEN) {
	    x += offset;
	    y += offset;
	}

	imageXOffset += x;
	imageYOffset += y;

	if (butPtr->image != NULL) {
	    /*
	     * Do boundary clipping, so that Tk_RedrawImage is passed valid
	     * coordinates. [Bug 979239]
	     */

	    if (imageXOffset < 0) {
		imageXOffset = 0;
	    }
	    if (imageYOffset < 0) {
		imageYOffset = 0;
	    }
	    if (width > Tk_Width(tkwin)) {
		width = Tk_Width(tkwin);
	    }
	    if (height > Tk_Height(tkwin)) {
		height = Tk_Height(tkwin);
	    }
	    if ((width + imageXOffset) > Tk_Width(tkwin)) {
		imageXOffset = Tk_Width(tkwin) - width;
	    }
	    if ((height + imageYOffset) > Tk_Height(tkwin)) {
		imageYOffset = Tk_Height(tkwin) - height;
	    }

	    if ((butPtr->selectImage != NULL) && (butPtr->flags & SELECTED)) {
		Tk_RedrawImage(butPtr->selectImage, 0, 0,
			width, height, pixmap, imageXOffset, imageYOffset);
	    } else if ((butPtr->tristateImage != NULL) && (butPtr->flags & TRISTATED)) {
		Tk_RedrawImage(butPtr->tristateImage, 0, 0,
			width, height, pixmap, imageXOffset, imageYOffset);
	    } else {
		Tk_RedrawImage(butPtr->image, 0, 0, width,
			height, pixmap, imageXOffset, imageYOffset);
	    }
	} else {
	    XSetClipOrigin(butPtr->display, gc, imageXOffset, imageYOffset);
	    XCopyPlane(butPtr->display, butPtr->bitmap, pixmap, gc,
		    0, 0, (unsigned int) width, (unsigned int) height,
		    imageXOffset, imageYOffset, 1);
	    XSetClipOrigin(butPtr->display, gc, 0, 0);
	}

	Tk_DrawTextLayout(butPtr->display, pixmap, gc,
		butPtr->textLayout, x + textXOffset, y + textYOffset, 0, -1);
	Tk_UnderlineTextLayout(butPtr->display, pixmap, gc,
		butPtr->textLayout, x + textXOffset, y + textYOffset,
		butPtr->underline);
	y += fullHeight/2;
    } else {
	if (haveImage) {
	    TkComputeAnchor(butPtr->anchor, tkwin, 0, 0,
		    butPtr->indicatorSpace + width, height, &x, &y);
	    x += butPtr->indicatorSpace;

	    x += offset;
	    y += offset;
	    if (relief == TK_RELIEF_RAISED) {
		x -= offset;
		y -= offset;
	    } else if (relief == TK_RELIEF_SUNKEN) {
		x += offset;
		y += offset;
	    }
	    imageXOffset += x;
	    imageYOffset += y;
	    if (butPtr->image != NULL) {
		/*
		 * Do boundary clipping, so that Tk_RedrawImage is passed
		 * valid coordinates. [Bug 979239]
		 */

		if (imageXOffset < 0) {
		    imageXOffset = 0;
		}
		if (imageYOffset < 0) {
		    imageYOffset = 0;
		}
		if (width > Tk_Width(tkwin)) {
		    width = Tk_Width(tkwin);
		}
		if (height > Tk_Height(tkwin)) {
		    height = Tk_Height(tkwin);
		}
		if ((width + imageXOffset) > Tk_Width(tkwin)) {
		    imageXOffset = Tk_Width(tkwin) - width;
		}
		if ((height + imageYOffset) > Tk_Height(tkwin)) {
		    imageYOffset = Tk_Height(tkwin) - height;
		}

		if ((butPtr->selectImage != NULL) &&
			(butPtr->flags & SELECTED)) {
		    Tk_RedrawImage(butPtr->selectImage, 0, 0, width,
			    height, pixmap, imageXOffset, imageYOffset);
		} else if ((butPtr->tristateImage != NULL) &&
			(butPtr->flags & TRISTATED)) {
		    Tk_RedrawImage(butPtr->tristateImage, 0, 0, width,
			    height, pixmap, imageXOffset, imageYOffset);
		} else {
		    Tk_RedrawImage(butPtr->image, 0, 0, width, height, pixmap,
			    imageXOffset, imageYOffset);
		}
	    } else {
		XSetClipOrigin(butPtr->display, gc, x, y);
		XCopyPlane(butPtr->display, butPtr->bitmap, pixmap, gc, 0, 0,
			(unsigned int) width, (unsigned int) height, x, y, 1);
		XSetClipOrigin(butPtr->display, gc, 0, 0);
	    }
	    y += height/2;
	} else {
 	    TkComputeAnchor(butPtr->anchor, tkwin, butPtr->padX, butPtr->padY,
		    butPtr->indicatorSpace + butPtr->textWidth,
		    butPtr->textHeight, &x, &y);

	    x += butPtr->indicatorSpace;

	    x += offset;
	    y += offset;
	    if (relief == TK_RELIEF_RAISED) {
		x -= offset;
		y -= offset;
	    } else if (relief == TK_RELIEF_SUNKEN) {
		x += offset;
		y += offset;
	    }
	    Tk_DrawTextLayout(butPtr->display, pixmap, gc, butPtr->textLayout,
		    x, y, 0, -1);
	    Tk_UnderlineTextLayout(butPtr->display, pixmap, gc,
		    butPtr->textLayout, x, y, butPtr->underline);
	    y += butPtr->textHeight/2;
	}
    }

    /*
     * Draw the indicator for check buttons and radio buttons. At this point,
     * x and y refer to the top-left corner of the text or image or bitmap.
     */

    if ((butPtr->type == TYPE_CHECK_BUTTON) && butPtr->indicatorOn) {
	if (butPtr->indicatorDiameter > 2*butPtr->borderWidth) {
	    TkBorder *selBorder = (TkBorder *) butPtr->selectBorder;
	    XColor *selColor = NULL;

	    if (selBorder != NULL) {
		selColor = selBorder->bgColorPtr;
	    }
	    x -= butPtr->indicatorSpace/2;
	    y = Tk_Height(tkwin)/2;
	    TkpDrawCheckIndicator(tkwin, butPtr->display, pixmap, x, y,
		    border, butPtr->normalFg, selColor, butPtr->disabledFg,
		    ((butPtr->flags & SELECTED) ? 1 :
			    (butPtr->flags & TRISTATED) ? 2 : 0),
		    (butPtr->state == STATE_DISABLED), CHECK_BUTTON);
	}
    } else if ((butPtr->type == TYPE_RADIO_BUTTON) && butPtr->indicatorOn) {
	if (butPtr->indicatorDiameter > 2*butPtr->borderWidth) {
	    TkBorder *selBorder = (TkBorder *) butPtr->selectBorder;
	    XColor *selColor = NULL;

	    if (selBorder != NULL) {
		selColor = selBorder->bgColorPtr;
	    }
	    x -= butPtr->indicatorSpace/2;
	    y = Tk_Height(tkwin)/2;
	    TkpDrawCheckIndicator(tkwin, butPtr->display, pixmap, x, y,
		    border, butPtr->normalFg, selColor, butPtr->disabledFg,
		    ((butPtr->flags & SELECTED) ? 1 :
			    (butPtr->flags & TRISTATED) ? 2 : 0),
		    (butPtr->state == STATE_DISABLED), RADIO_BUTTON);
	}
    }

    /*
     * If the button is disabled with a stipple rather than a special
     * foreground color, generate the stippled effect. If the widget is
     * selected and we use a different background color when selected, must
     * temporarily modify the GC so the stippling is the right color.
     */

    if ((butPtr->state == STATE_DISABLED)
	    && ((butPtr->disabledFg == NULL) || (butPtr->image != NULL))) {
	if ((butPtr->flags & SELECTED) && !butPtr->indicatorOn
		&& (butPtr->selectBorder != NULL)) {
	    XSetForeground(butPtr->display, butPtr->stippleGC,
		    Tk_3DBorderColor(butPtr->selectBorder)->pixel);
	}

	/*
	 * Stipple the whole button if no disabledFg was specified, otherwise
	 * restrict stippling only to displayed image
	 */

	if (butPtr->disabledFg == NULL) {
	    XFillRectangle(butPtr->display, pixmap, butPtr->stippleGC, 0, 0,
		    (unsigned) Tk_Width(tkwin), (unsigned) Tk_Height(tkwin));
	} else {
	    XFillRectangle(butPtr->display, pixmap, butPtr->stippleGC,
		    imageXOffset, imageYOffset,
		    (unsigned) imageWidth, (unsigned) imageHeight);
	}
	if ((butPtr->flags & SELECTED) && !butPtr->indicatorOn
		&& (butPtr->selectBorder != NULL)) {
	    XSetForeground(butPtr->display, butPtr->stippleGC,
		    Tk_3DBorderColor(butPtr->normalBorder)->pixel);
	}
    }

    /*
     * Draw the border and traversal highlight last. This way, if the button's
     * contents overflow they'll be covered up by the border. This code is
     * complicated by the possible combinations of focus highlight and default
     * rings. We draw the focus and highlight rings using the highlight border
     * and highlight foreground color.
     */

    if (relief != TK_RELIEF_FLAT) {
	int inset = butPtr->highlightWidth;

	if (butPtr->defaultState == DEFAULT_ACTIVE) {
	    /*
	     * Draw the default ring with 2 pixels of space between the
	     * default ring and the button and the default ring and the focus
	     * ring. Note that we need to explicitly draw the space in the
	     * highlightBorder color to ensure that we overwrite any overflow
	     * text and/or a different button background color.
	     */

	    Tk_Draw3DRectangle(tkwin, pixmap, butPtr->highlightBorder, inset,
		    inset, Tk_Width(tkwin) - 2*inset,
		    Tk_Height(tkwin) - 2*inset, 2, TK_RELIEF_FLAT);
	    inset += 2;
	    Tk_Draw3DRectangle(tkwin, pixmap, butPtr->highlightBorder, inset,
		    inset, Tk_Width(tkwin) - 2*inset,
		    Tk_Height(tkwin) - 2*inset, 1, TK_RELIEF_SUNKEN);
	    inset++;
	    Tk_Draw3DRectangle(tkwin, pixmap, butPtr->highlightBorder, inset,
		    inset, Tk_Width(tkwin) - 2*inset,
		    Tk_Height(tkwin) - 2*inset, 2, TK_RELIEF_FLAT);

	    inset += 2;
	} else if (butPtr->defaultState == DEFAULT_NORMAL) {
	    /*
	     * Leave room for the default ring and write over any text or
	     * background color.
	     */

	    Tk_Draw3DRectangle(tkwin, pixmap, butPtr->highlightBorder, 0,
		    0, Tk_Width(tkwin), Tk_Height(tkwin), 5, TK_RELIEF_FLAT);
	    inset += 5;
	}

	/*
	 * Draw the button border.
	 */

	Tk_Draw3DRectangle(tkwin, pixmap, border, inset, inset,
		Tk_Width(tkwin) - 2*inset, Tk_Height(tkwin) - 2*inset,
		butPtr->borderWidth, relief);
    }
    if (butPtr->highlightWidth > 0) {
	GC gc;

	if (butPtr->flags & GOT_FOCUS) {
	    gc = Tk_GCForColor(butPtr->highlightColorPtr, pixmap);
	} else {
	    gc = Tk_GCForColor(Tk_3DBorderColor(butPtr->highlightBorder),
		    pixmap);
	}

	/*
	 * Make sure the focus ring shrink-wraps the actual button, not the
	 * padding space left for a default ring.
	 */

	if (butPtr->defaultState == DEFAULT_NORMAL) {
	    TkDrawInsetFocusHighlight(tkwin, gc, butPtr->highlightWidth,
		    pixmap, 5);
	} else {
	    Tk_DrawFocusHighlight(tkwin, gc, butPtr->highlightWidth, pixmap);
	}
    }

    /*
     * Copy the information from the off-screen pixmap onto the screen, then
     * delete the pixmap.
     */

    XCopyArea(butPtr->display, pixmap, Tk_WindowId(tkwin),
	    butPtr->copyGC, 0, 0, (unsigned) Tk_Width(tkwin),
	    (unsigned) Tk_Height(tkwin), 0, 0);
    Tk_FreePixmap(butPtr->display, pixmap);
}

/*
 *----------------------------------------------------------------------
 *
 * TkpComputeButtonGeometry --
 *
 *	After changes in a button's text or bitmap, this function recomputes
 *	the button's geometry and passes this information along to the
 *	geometry manager for the window.
 *
 * Results:
 *	None.
 *
 * Side effects:
 *	The button's window may change size.
 *
 *----------------------------------------------------------------------
 */

void
TkpComputeButtonGeometry(
    register TkButton *butPtr)	/* Button whose geometry may have changed. */
{
    int width, height, avgWidth, txtWidth, txtHeight;
    int haveImage = 0, haveText = 0;
    Tk_FontMetrics fm;

    butPtr->inset = butPtr->highlightWidth + butPtr->borderWidth;

    /*
     * Leave room for the default ring if needed.
     */

    if (butPtr->defaultState != DEFAULT_DISABLED) {
	butPtr->inset += 5;
    }
    butPtr->indicatorSpace = 0;

    width = 0;
    height = 0;
    txtWidth = 0;
    txtHeight = 0;
    avgWidth = 0;

    if (butPtr->image != NULL) {
	Tk_SizeOfImage(butPtr->image, &width, &height);
	haveImage = 1;
    } else if (butPtr->bitmap != None) {
	Tk_SizeOfBitmap(butPtr->display, butPtr->bitmap, &width, &height);
	haveImage = 1;
    }

    if (haveImage == 0 || butPtr->compound != COMPOUND_NONE) {
	Tk_FreeTextLayout(butPtr->textLayout);

	butPtr->textLayout = Tk_ComputeTextLayout(butPtr->tkfont,
		Tcl_GetString(butPtr->textPtr), -1, butPtr->wrapLength,
		butPtr->justify, 0, &butPtr->textWidth, &butPtr->textHeight);

	txtWidth = butPtr->textWidth;
	txtHeight = butPtr->textHeight;
	avgWidth = Tk_TextWidth(butPtr->tkfont, "0", 1);
	Tk_GetFontMetrics(butPtr->tkfont, &fm);
	haveText = (txtWidth != 0 && txtHeight != 0);
    }

    /*
     * If the button is compound (i.e., it shows both an image and text), the
     * new geometry is a combination of the image and text geometry. We only
     * honor the compound bit if the button has both text and an image,
     * because otherwise it is not really a compound button.
     */

    if (butPtr->compound != COMPOUND_NONE && haveImage && haveText) {
	switch ((enum compound) butPtr->compound) {
	case COMPOUND_TOP:
	case COMPOUND_BOTTOM:
	    /*
	     * Image is above or below text.
	     */

	    height += txtHeight + butPtr->padY;
	    width = (width > txtWidth ? width : txtWidth);
	    break;
	case COMPOUND_LEFT:
	case COMPOUND_RIGHT:
	    /*
	     * Image is left or right of text.
	     */

	    width += txtWidth + butPtr->padX;
	    height = (height > txtHeight ? height : txtHeight);
	    break;
	case COMPOUND_CENTER:
	    /*
	     * Image and text are superimposed.
	     */

	    width = (width > txtWidth ? width : txtWidth);
	    height = (height > txtHeight ? height : txtHeight);
	    break;
	case COMPOUND_NONE:
	    break;
	}
	if (butPtr->width > 0) {
	    width = butPtr->width;
	}
	if (butPtr->height > 0) {
	    height = butPtr->height;
	}

	if ((butPtr->type >= TYPE_CHECK_BUTTON) && butPtr->indicatorOn) {
	    butPtr->indicatorSpace = height;
	    if (butPtr->type == TYPE_CHECK_BUTTON) {
		butPtr->indicatorDiameter = (65*height)/100;
	    } else {
		butPtr->indicatorDiameter = (75*height)/100;
	    }
	}

	width += 2*butPtr->padX;
	height += 2*butPtr->padY;
    } else {
	if (haveImage) {
	    if (butPtr->width > 0) {
		width = butPtr->width;
	    }
	    if (butPtr->height > 0) {
		height = butPtr->height;
	    }

	    if ((butPtr->type >= TYPE_CHECK_BUTTON) && butPtr->indicatorOn) {
		butPtr->indicatorSpace = height;
		if (butPtr->type == TYPE_CHECK_BUTTON) {
		    butPtr->indicatorDiameter = (65*height)/100;
		} else {
		    butPtr->indicatorDiameter = (75*height)/100;
		}
	    }
	} else {
	    width = txtWidth;
	    height = txtHeight;

	    if (butPtr->width > 0) {
		width = butPtr->width * avgWidth;
	    }
	    if (butPtr->height > 0) {
		height = butPtr->height * fm.linespace;
	    }
	    if ((butPtr->type >= TYPE_CHECK_BUTTON) && butPtr->indicatorOn) {
		butPtr->indicatorDiameter = fm.linespace;
		if (butPtr->type == TYPE_CHECK_BUTTON) {
		    butPtr->indicatorDiameter =
			(80*butPtr->indicatorDiameter)/100;
		}
		butPtr->indicatorSpace = butPtr->indicatorDiameter + avgWidth;
	    }
	}
    }

    /*
     * When issuing the geometry request, add extra space for the indicator,
     * if any, and for the border and padding, plus two extra pixels so the
     * display can be offset by 1 pixel in either direction for the raised or
     * lowered effect.
     */

    if ((butPtr->image == NULL) && (butPtr->bitmap == None)) {
	width += 2*butPtr->padX;
	height += 2*butPtr->padY;
    }
    if ((butPtr->type == TYPE_BUTTON) && !Tk_StrictMotif(butPtr->tkwin)) {
	width += 2;
	height += 2;
    }
    Tk_GeometryRequest(butPtr->tkwin, (int) (width + butPtr->indicatorSpace
	    + 2*butPtr->inset), (int) (height + 2*butPtr->inset));
    Tk_SetInternalBorder(butPtr->tkwin, butPtr->inset);
}

/*
 * Local Variables:
 * mode: c
 * c-basic-offset: 4
 * fill-column: 78
 * End:
 */
@


1.28
log
@Eliminate tkpMenubuttonClass
make tkpButtonProcs CONST
fix gcc warnings: missing initializer
@
text
@d11 1
a11 1
 * RCS: @@(#) $Id: tkUnixButton.c,v 1.27 2009/10/24 00:01:48 dkf Exp $
d62 1
a62 1
static const char *button_images[] = {
@


1.27
log
@[Patch 1530276]: Improve no-indicator check/radio buttons on Unix.
@
text
@d11 1
a11 1
 * RCS: @@(#) $Id: tkUnixButton.c,v 1.26 2008/11/05 22:20:59 nijtmans Exp $
d40 1
a40 1
Tk_ClassProcs tkpButtonProcs = {
d43 2
@


1.26
log
@fix [Bug 2226093] const changes not all correct
more internal -Wwrite-string warning fixes
@
text
@d11 1
a11 1
 * RCS: @@(#) $Id: tkUnixButton.c,v 1.25 2007/12/13 15:28:50 dgp Exp $
d284 1
a284 1
		    imgColors[button_images[imgstart+iy][imgsel+ix] - 'A'] );
d298 1
a298 1
	    (unsigned int)dim, (unsigned int)dim);
d300 1
a300 1
	    (unsigned int)dim, (unsigned int)dim, x, y);
d392 2
a393 2
    if ((butPtr->flags & SELECTED) && (butPtr->state != STATE_ACTIVE)
	    && (butPtr->selectBorder != NULL) && !butPtr->indicatorOn) {
@


1.25
log
@merge stable branch onto HEAD
@
text
@d11 1
a11 1
 * RCS: @@(#) $Id: tkUnixButton.c,v 1.23.2.1 2007/09/07 01:25:37 dgp Exp $
d60 1
a60 1
static char *button_images[] = {
@


1.25.2.1
log
@[Patch 1530276]: Improve no-indicator check/radio buttons on Unix.
@
text
@d11 1
a11 1
 * RCS: @@(#) $Id: tkUnixButton.c,v 1.25 2007/12/13 15:28:50 dgp Exp $
d392 2
a393 2
    if ((butPtr->flags & SELECTED) && (butPtr->selectBorder != NULL)
	    && !butPtr->indicatorOn) {
@


1.24
log
@header cleanup
@
text
@d11 1
a11 1
 * RCS: @@(#) $Id: tkUnixButton.c,v 1.23 2007/02/27 14:52:56 dkf Exp $
@


1.23
log
@Minor syntactic stuff
@
text
@d11 1
a11 1
 * RCS: @@(#) $Id: tkUnixButton.c,v 1.22 2005/11/27 02:36:16 das Exp $
d14 1
@


1.23.2.1
log
@merge updates from HEAD
@
text
@d11 1
a11 1
 * RCS: @@(#) $Id: tkUnixButton.c,v 1.23 2007/02/27 14:52:56 dkf Exp $
a13 1
#include "tkInt.h"
@


1.22
log
@	* unix/tcl.m4 (Darwin): add 64bit support, check for Tiger copyfile(),
	add CFLAGS to SHLIB_LD to support passing -isysroot in env(CFLAGS) to
	configure (flag can't be present twice, so can't be in both CFLAGS and
	LDFLAGS during configure), don't use -prebind when deploying on 10.4,
	define TCL_IO_TRACK_OS_FOR_DRIVER_WITH_BAD_BLOCKING (rdar://3171542).
	(SC_ENABLE_LANGINFO, SC_TIME_HANDLER): add/fix caching, fix obsolete
	autoconf macros. Sync with tcl/unix/tcl.m4.

	* unix/configure.in: fix obsolete autoconf macros, sync gratuitous
	formatting/ordering differences with tcl/unix/configure.in.

	* unix/Makefile.in: add CFLAGS to wish/tktest link to make executable
	linking the same as during configure (needed to avoid loosing any linker
	relevant flags in CFLAGS, in particular flags that can't be in LDFLAGS).
	Avoid concurrent linking of wish and compiling of tkTestInit.o during
	parallel make, fix dependencies and flags for building tkMacOSXInit.o
	(checkstubs, checkexports): dependency and Darwin fixes
	(dist): add new macosx files.

	* macosx/tkMacOSXEvent.c (TkMacOSXProcessEvent):
	* macosx/tkMacOSXEvent.h:
	* macosx/tkMacOSXMouseEvent.c (TkMacOSXProcessMouseEvent):
	* macosx/tkMacOSXCarbonEvents.c: install standard application event
	handler, add & call functions to start and stop carbon even timer that
	runs the tcl event loop periodically during a nested carbon event loop
	in the toolbox (e.g. during menutracking) to ensure tcl timers etc
	continue to fire, register app event handler for menu tracking and HI
	command carbon events, move menu event handling to new handlers for
	those carbon events, no longer register for/handle appleevent carbon
	event (now dealt with by standard application event handler), event
	debugging code dynamically acquires carbon event debugging functions to
	allow use on Tiger where they are no longer exported from HIToolbox.

	* macosx/tkMacOSXFont.c (TkMacOSXUseAntialiasedText):
	* macosx/tkMacOSXKeyEvent.c (GetKeyboardLayout):
	* macosx/tkMacOSXCarbonEvents.c (TkMacOSXInitCarbonEvents):
	* macosx/tkMacOSXInit.c:
	* macosx/tkMacOSXInt.h: abstract common code to dynamically acquire
	address of a named symbol (from a loaded dynamic library) into new
	function TkMacOSXGetNamedSymbol() and macro TkMacOSXInitNamedSymbol.

	* macosx/tkMacOSXMenu.c (TkpNewMenu):
	* macosx/tkMacOSXMenubutton.c (MenuButtonInitControl):
	* macosx/tkMacOSXMenus.c (TkMacOSXHandleMenuSelect): switch to  modern
	utf8 aware menu manager API, remove obsolete code, add error handling.

	* macosx/tkMacOSXMouseEvent.c: define OSX 10.3 or later only constants
	if necessary to allow compilation on OSX 10.2

	* macosx/tkMacOSXWm.c (UpdateSizeHints): remove code that is never
	executed.

	* xlib/xgc.c (XCreateGC): sync with core-8-4-branch change.

	* generic/tk.h: add/correct location of version numbers in macosx files.

	* generic/tkInt.h: clarify fat compile comment.

	* macosx/Wish.pbproj/default.pbxuser (new file):
	* macosx/Wish.pbproj/jingham.pbxuser:
	* macosx/Wish.pbproj/project.pbxproj:
	* macosx/Wish.xcode/default.pbxuser:
	* macosx/Wish.xcode/project.pbxproj:
	* macosx/Wish.xcodeproj/default.pbxuser (new file):
	* macosx/Wish.xcodeproj/project.pbxproj (new file): new/updated projects
	for Xcode 2.2 on 10.4, Xcode 1.5 on 10.3 & ProjectBuilder on 10.2, with
	native tktest targets and support for universal (fat) compiles.

	* macosx/Tk-Info.plist (removed):
	* macosx/Wish-Info.plist (removed):
	* macosx/buildTkConfig.tcl (removed): remove obsolete build files.

	* macosx/README: clarification/cleanup, document new Xcode projects and
	universal (fat) builds via CFLAGS (i.e. ppc and i386 at the same time).

	* unix/Makefile.in:
	* unix/aclocal.m4:
	* unix/configure.in:
	* macosx/configure.ac (new file): add support for inclusion of
	unix/configure.in by macosx/configure.ac, allows generation of a config
	headers enabled configure script in macosx (required by Xcode projects).

	* macosx/GNUmakefile: rename from Makefile to avoid overwriting by
	configure run in tk/macosx, add support for reusing configure cache,
	build target fixes.

	* generic/tk3d.h:
	* generic/tkButton.h:
	* generic/tkCanvas.c:
	* generic/tkCanvas.h:
	* generic/tkColor.h:
	* generic/tkEntry.h:
	* generic/tkFileFilter.h:
	* generic/tkFont.c:
	* generic/tkFont.h:
	* generic/tkImage.c:
	* generic/tkImgPhoto.c:
	* generic/tkInt.h:
	* generic/tkMenu.c:
	* generic/tkMenu.h:
	* generic/tkMenubutton.h:
	* generic/tkScale.h:
	* generic/tkScrollbar.h:
	* generic/tkSelect.h:
	* generic/tkStubInit.c:
	* generic/tkStubLib.c:
	* generic/tkText.h:
	* generic/tkUndo.h:
	* macosx/tkMacOSXButton.c:
	* macosx/tkMacOSXDebug.c:
	* macosx/tkMacOSXDebug.h:
	* macosx/tkMacOSXDialog.c:
	* macosx/tkMacOSXDraw.c:
	* macosx/tkMacOSXEntry.c:
	* macosx/tkMacOSXFont.c:
	* macosx/tkMacOSXInt.h:
	* macosx/tkMacOSXMenu.c:
	* macosx/tkMacOSXMenubutton.c:
	* macosx/tkMacOSXMouseEvent.c:
	* macosx/tkMacOSXSend.c:
	* macosx/tkMacOSXSubwindows.c:
	* macosx/tkMacOSXWindowEvent.c:
	* macosx/tkMacOSXWm.c:
	* macosx/tkMacOSXXStubs.c:
	* unix/tkUnixButton.c:
	* unix/tkUnixMenu.c:
	* xlib/xgc.c: ensure externally visible symbols not contained in stubs
	table are declared as MODULE_SCOPE (or as static if not used outside of
	own source file), #ifdef out a few Xlib and aqua functions that are
	never called. These changes allow 'make checkstubs' to complete without
	error on Darwin with gcc 4.

	* macosx/tkMacOSXTest.c:
	* macosx/tkMacOSXPort.h:
	* win/tkWinTest.c:
	* generic/tkInt.decls: add functions needed by tktest to internal stubs
	table, correct signature of TkMacOSXHandleMenuSelect, add XSync to aqua
	Xlib stubs.

	* unix/tkUnixSend.c:
	* generic/tkText.c:
	* generic/tkTest.c: #ifdef unix only declarations.
	(TestmetricsCmd): unify win and mac implementation.
	(TestsendCmd): move to tkUnixSend.c to avoid access to global var.
	(TesttextCmd): move to tkText.c to avoid having to put all the internal
	text functions it uses into the stubs table.

	* generic/tkTextDisp.c:
	* macosx/tkMacOSXInit.c:
	* macosx/tkMacOSXKeyEvent.c:
	* macosx/tkMacOSXWindowEvent.c:
	* macosx/tkMacOSXXStubs.c: fix gcc 4 warnings.

	* macosx/tkMacOSXNotify.c:
	* macosx/tkMacOSXScrlbr.c: sync with core-8-4-branch.

	* generic/tkIntDecls.h:
	* generic/tkIntPlatDecls.h:
	* generic/tkIntXlibDecls.h:
	* generic/tkStubInit.c:
	* unix/configure:
	* unix/tkConfig.h.in: regen.
@
text
@d11 1
a11 1
 * RCS: @@(#) $Id: tkUnixButton.c,v 1.21 2005/11/14 11:54:21 dkf Exp $
d200 1
a200 1
	imgsel += disabled  && on != 2 ? CHECK_DISOFF_OFFSET : 0;
d208 1
a208 1
	imgsel += disabled  && on != 2 ? CHECK_DISOFF_OFFSET : 0;
d458 1
a458 1
    imageWidth  = width;
d705 1
a705 1
	    TkpDrawCheckIndicator(tkwin, butPtr->display, pixmap,  x, y,
@


1.21
log
@ANSIfy
@
text
@d11 1
a11 1
 * RCS: @@(#) $Id: tkUnixButton.c,v 1.20 2004/12/02 02:10:38 hobbs Exp $
d18 10
@


1.20
log
@	* unix/tkUnixButton.c (TkpDisplayButton): constrain coords to
	Tk_RedrawImage to display only portion that is valid.
	* generic/tkImgPhoto.c (ImgPhotoDisplay): add X error suppression
	around XGetImage to prevent app abort. [Bug 979239]
@
text
@d1 1
a1 1
/* 
d4 1
a4 2
 *	This file implements the Unix specific portion of the button
 *	widgets.
d8 2
a9 2
 * See the file "license.terms" for information on usage and redistribution
 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
d11 1
a11 1
 * RCS: @@(#) $Id: tkUnixButton.c,v 1.19 2004/05/04 00:39:51 hobbs Exp $
d26 1
a26 1
 * The class procedure table for the button widgets.
d35 3
a37 3
 * The button image
 * the header info here is ignored, it's the image that's
 * important.  The colors will be applied as follows:
d93 1
d113 1
a117 1

d124 2
a125 3
 *	Draws the checkbox image in the drawable at the (x,y)
 *	location, value, and state given.  This routine is use by the
 *	button and menu widgets
d136 13
a148 14
void 
TkpDrawCheckIndicator(tkwin, display, d, x, y, bgBorder, indicatorColor,
	selectColor, disableColor, on, disabled, mode)
    Tk_Window tkwin;				/* handle for resource alloc */
    Display *display;
    Drawable d;					/* what to draw on */
    int x, y;					/* where to draw */
    Tk_3DBorder bgBorder;			/* colors of the border */
    XColor *indicatorColor;			/* color of the indicator */
    XColor *selectColor;			/* color when selected */
    XColor *disableColor;			/* color when disabled */
    int on;					/* are we on? */
    int disabled;				/* are we disabled? */
    int mode;					/* kind of indicator to draw */
d181 2
a182 2
     * Compute starting point and dimensions of image inside
     * button_images to be used.
d188 2
a189 2
	imgsel = on == 2 ? CHECK_DISON_OFFSET : 
	    on == 1 ? CHECK_ON_OFFSET : CHECK_OFF_OFFSET;
d196 2
a197 2
	imgsel = on == 2 ? CHECK_DISOFF_OFFSET : 
	    on == 1 ? CHECK_ON_OFFSET : CHECK_OFF_OFFSET;
d206 1
a206 1
	    on==1 ? RADIO_ON_OFFSET : RADIO_OFF_OFFSET;
d212 1
a212 1
    case RADIO_MENU:    
d214 1
a214 1
	    on==1 ? RADIO_ON_OFFSET : RADIO_OFF_OFFSET;
d223 2
a224 3
     * Allocate the drawing areas to use.  Note that we use
     * double-buffering here because not all code paths leading to
     * this function do so.
d252 2
a253 2
	Tk_GetColorByValue(tkwin, bg_brdr->lightColorPtr)->pixel :
	WhitePixelOfScreen(bg_brdr->screen);
d256 3
a258 3
    imgColors[4 /*E*/] = (bg_brdr->darkColorPtr != NULL) ? 
	Tk_GetColorByValue(tkwin, bg_brdr->darkColorPtr)->pixel :
	BlackPixelOfScreen(bg_brdr->screen);
d317 2
a318 2
TkpCreateButton(tkwin)
    Tk_Window tkwin;
d320 1
a320 1
    UnixButton *butPtr = (UnixButton *)ckalloc(sizeof(UnixButton));
d329 2
a330 2
 *	This procedure is invoked to display a button widget.  It is
 *	normally invoked as an idle handler.
d336 2
a337 2
 *	Commands are output to X to display the button in its
 *	current mode.  The REDRAW_PENDING flag is cleared.
d343 2
a344 2
TkpDisplayButton(clientData)
    ClientData clientData;	/* Information about widget. */
d350 2
a351 2
    int x = 0;			/* Initialization only needed to stop
				 * compiler warning. */
d359 2
a360 2
				 * to move up and down as the relief changes.
				 */
d362 3
a364 3
    int imageXOffset = 0, imageYOffset = 0; /* image information that will
					     * be used to restrict disabled
					     * pixmap as well */
d387 2
a388 3
     * Override the relief specified for the button if this is a
     * checkbutton or radiobutton and there's no indicator.  The new
     * relief is as follows:
d402 2
a403 2
     * This is accomplished by configuring the checkbutton or radiobutton
     * like this:
d408 3
a410 3
     * -relief on mouseover.  Hence, we can tell if we are in mouse-over by
     * comparing relief against overRelief.  This is an aweful kludge, but
     * it gives use the desired behavior while keeping the code backwards
d426 4
a429 4
     * In order to avoid screen flashes, this procedure redraws
     * the button in a pixmap, then copies the pixmap to the
     * screen in a single operation.  This means that there's no
     * point in time where the on-screen image has been cleared.
d452 1
a452 1
    
d460 27
a486 41
	    case COMPOUND_TOP: 
	    case COMPOUND_BOTTOM: {
		/* Image is above or below text */
		if (butPtr->compound == COMPOUND_TOP) {
		    textYOffset = height + butPtr->padY;
		} else {
		    imageYOffset = butPtr->textHeight + butPtr->padY;
		}
		fullHeight = height + butPtr->textHeight + butPtr->padY;
		fullWidth = (width > butPtr->textWidth ? width :
			butPtr->textWidth);
		textXOffset = (fullWidth - butPtr->textWidth)/2;
		imageXOffset = (fullWidth - width)/2;
		break;
	    }
	    case COMPOUND_LEFT:
	    case COMPOUND_RIGHT: {
		/* Image is left or right of text */
		if (butPtr->compound == COMPOUND_LEFT) {
		    textXOffset = width + butPtr->padX;
		} else {
		    imageXOffset = butPtr->textWidth + butPtr->padX;
		}
		fullWidth = butPtr->textWidth + butPtr->padX + width;
		fullHeight = (height > butPtr->textHeight ? height :
			butPtr->textHeight);
		textYOffset = (fullHeight - butPtr->textHeight)/2;
		imageYOffset = (fullHeight - height)/2;
		break;
	    }
	    case COMPOUND_CENTER: {
		/* Image and text are superimposed */
		fullWidth = (width > butPtr->textWidth ? width :
			butPtr->textWidth);
		fullHeight = (height > butPtr->textHeight ? height :
			butPtr->textHeight);
		textXOffset = (fullWidth - butPtr->textWidth)/2;
		imageXOffset = (fullWidth - width)/2;
		textYOffset = (fullHeight - butPtr->textHeight)/2;
		imageYOffset = (fullHeight - height)/2;
		break;
d488 22
a509 1
	    case COMPOUND_NONE: {break;}
d532 2
a533 2
	     * Do boundary clipping, so that Tk_RedrawImage is passed
	     * valid coordinates. [Bug 979239]
d584 1
a584 1
	    
d644 1
a644 1
	    
d646 1
a646 1
	    
d663 1
a663 1
    
d665 2
a666 3
     * Draw the indicator for check buttons and radio buttons.  At this
     * point x and y refer to the top-left corner of the text or image
     * or bitmap.
d681 2
a682 1
		    ((butPtr->flags & SELECTED)?1:(butPtr->flags & TRISTATED)?2:0), 
d697 2
a698 1
		    ((butPtr->flags & SELECTED)?1:(butPtr->flags & TRISTATED)?2:0),
d705 3
a707 3
     * foreground color, generate the stippled effect.  If the widget
     * is selected and we use a different background color when selected,
     * must temporarily modify the GC so the stippling is the right color.
d717 1
d719 2
a720 2
	 * Stipple the whole button if no disabledFg was specified,
	 * otherwise restrict stippling only to displayed image
d722 1
d739 5
a743 5
     * Draw the border and traversal highlight last.  This way, if the
     * button's contents overflow they'll be covered up by the border.
     * This code is complicated by the possible combinations of focus
     * highlight and default rings.  We draw the focus and highlight rings
     * using the highlight border and highlight foreground color.
d752 4
a755 4
	     * default ring and the button and the default ring and the
	     * focus ring.  Note that we need to explicitly draw the space
	     * in the highlightBorder color to ensure that we overwrite any
	     * overflow text and/or a different button background color.
d814 2
a815 2
     * Copy the information from the off-screen pixmap onto the screen,
     * then delete the pixmap.
d829 3
a831 3
 *	After changes in a button's text or bitmap, this procedure
 *	recomputes the button's geometry and passes this information
 *	along to the geometry manager for the window.
d843 2
a844 2
TkpComputeButtonGeometry(butPtr)
    register TkButton *butPtr;	/* Button whose geometry may have changed. */
d866 1
a866 1
    
d874 1
a874 1
    
d877 1
a877 1
	    
d881 1
a881 1
	
d888 1
a888 1
    
d890 4
a893 4
     * If the button is compound (ie, it shows both an image and text),
     * the new geometry is a combination of the image and text geometry.
     * We only honor the compound bit if the button has both text and an
     * image, because otherwise it is not really a compound button.
d898 28
a925 21
	    case COMPOUND_TOP:
	    case COMPOUND_BOTTOM: {
		/* Image is above or below text */
		height += txtHeight + butPtr->padY;
		width = (width > txtWidth ? width : txtWidth);
		break;
	    }
	    case COMPOUND_LEFT:
	    case COMPOUND_RIGHT: {
		/* Image is left or right of text */
		width += txtWidth + butPtr->padX;
		height = (height > txtHeight ? height : txtHeight);
		break;
	    }
	    case COMPOUND_CENTER: {
		/* Image and text are superimposed */
		width = (width > txtWidth ? width : txtWidth);
		height = (height > txtHeight ? height : txtHeight);
		break;
	    }
	    case COMPOUND_NONE: {break;}
a944 1

d953 1
a953 1
	    
d965 1
a965 1
	    
d986 2
a987 2
     * display can be offset by 1 pixel in either direction for the raised
     * or lowered effect.
d1002 8
@


1.19
log
@	* unix/tkUnixButton.c (TkpDrawCheckIndicator): allow radiobuttons
	to be drawn when disabledforeground and/or selectcolor are NULL.
	[Bug #826850] (griffin)
@
text
@d12 1
a12 1
 * RCS: @@(#) $Id: tkUnixButton.c,v 1.18 2004/03/16 19:55:12 hobbs Exp $
d508 1
a508 1
	
d513 1
a513 1
	
d528 24
d594 24
@


1.18
log
@	* unix/tkUnixButton.c (TkpDrawCheckIndicator): correct crash
	condition for new radio/checkbuttons when colors are exhausted.
	[Bug 915330] (griffin)
@
text
@d12 1
a12 1
 * RCS: @@(#) $Id: tkUnixButton.c,v 1.17 2004/02/18 00:40:24 hobbs Exp $
d168 1
a168 2
	    || indicatorColor == NULL || selectColor == NULL
	    || disableColor == NULL) {
d172 8
a258 2
    imgColors[4 /*E*/] =
	    Tk_GetColorByValue(tkwin, bg_brdr->darkColorPtr)->pixel;
@


1.17
log
@	* doc/checkbutton.n: TIP#110 implementation
	* doc/radiobutton.n: Tristate Checkbutton and Radiobuttons
	* generic/tkButton.c:
	* generic/tkButton.h:
	* library/demos/check.tcl:
	* library/demos/radio.tcl:
	* macosx/tkMacOSXButton.c:
	* macosx/tkMacOSXDefault.h:
	* tests/button.test:
	* unix/tkUnixButton.c:
	* unix/tkUnixDefault.h:
	* win/tkWinButton.c:
	* win/tkWinDefault.h:
@
text
@d12 1
a12 1
 * RCS: @@(#) $Id: tkUnixButton.c,v 1.16 2003/10/10 20:19:51 hobbs Exp $
d247 3
a249 2
    imgColors[2 /*C*/] =
	    Tk_GetColorByValue(tkwin, bg_brdr->lightColorPtr)->pixel;
d254 3
@


1.16
log
@	* mac/tkMacButton.c (TkpDisplayButton):
	* macosx/tkMacOSXButton.c (TkpDisplayButton):
	* unix/tkUnixButton.c (TkpDisplayButton): correct imageYOffset for
	buttons with just images.
@
text
@d12 1
a12 1
 * RCS: @@(#) $Id: tkUnixButton.c,v 1.15 2003/08/14 12:30:11 dkf Exp $
d183 3
a185 2
	imgsel = on ? CHECK_ON_OFFSET : CHECK_OFF_OFFSET;
	imgsel += disabled ? CHECK_DISOFF_OFFSET : 0;
d191 3
a193 2
	imgsel = on ? CHECK_ON_OFFSET : CHECK_OFF_OFFSET;
	imgsel += disabled ? CHECK_DISOFF_OFFSET : 0;
d200 3
a202 2
	imgsel = on ? RADIO_ON_OFFSET : RADIO_OFF_OFFSET;
	imgsel += disabled ? RADIO_DISOFF_OFFSET : 0;
d208 3
a210 2
	imgsel = on ? RADIO_ON_OFFSET : RADIO_OFF_OFFSET;
	imgsel += disabled ? RADIO_DISOFF_OFFSET : 0;
d522 3
d565 4
d622 1
a622 1
		    (butPtr->flags & SELECTED), 
d637 1
a637 1
		    (butPtr->flags & SELECTED), 
@


1.15
log
@Make test suite pass without crashes from TIP#109 changes...
@
text
@d12 1
a12 1
 * RCS: @@(#) $Id: tkUnixButton.c,v 1.14 2003/08/14 10:31:14 dkf Exp $
d552 1
a552 1
	    imageXOffset += y;
d557 1
a557 1
			    height, pixmap, x, y);
d560 1
a560 1
			    x, y);
@


1.14
log
@TIP#109 implementation - checkbuttons and radiobuttons now look better.
@
text
@d12 1
a12 1
 * RCS: @@(#) $Id: tkUnixButton.c,v 1.13 2003/04/26 02:59:20 hobbs Exp $
d602 1
d604 3
d609 3
a611 3
	    TkpDrawCheckIndicator(tkwin, butPtr->display, pixmap, 
		    x, y, border, butPtr->normalFg, selBorder->bgColorPtr,
		    butPtr->disabledFg, (butPtr->flags & SELECTED), 
d617 1
d619 3
d624 3
a626 3
	    TkpDrawCheckIndicator(tkwin, butPtr->display, pixmap, 
		    x, y, border, butPtr->normalFg, selBorder->bgColorPtr,
		    butPtr->disabledFg, (butPtr->flags & SELECTED), 
@


1.13
log
@	* generic/tkButton.h:                         Rewrote the handling
	* generic/tkButton.c (TkButtonWorldChanged):  of compound *buttons
	* mac/tkMacButton.c (TkpDisplayButton):       to correctly display
	* macosx/tkMacOSXButton.c (TkpDisplayButton): mixture of disabledfg,
	* unix/tkUnixButton.c (TkpDisplayButton):     selectcolor, indicator,
	* win/tkWinButton.c (TkpDisplayButton):       etc.  *buttons will
	now only stipple the image, unless no disabledfg is given, in which
	case it will stipple the whole button.
@
text
@d12 1
a12 1
 * RCS: @@(#) $Id: tkUnixButton.c,v 1.12 2003/04/25 20:03:43 hobbs Exp $
d16 1
d34 255
d420 1
a420 1
     * point in time where the on-sreen image has been cleared.
d600 2
a601 1
	int dim;
d603 6
a608 37
	dim = butPtr->indicatorDiameter;
	x -= butPtr->indicatorSpace;
	y -= dim/2;
	if (dim > 2*butPtr->borderWidth) {
	    Tk_Draw3DRectangle(tkwin, pixmap, border, x, y, dim, dim,
		    butPtr->borderWidth,
		    (butPtr->flags & SELECTED) ? TK_RELIEF_SUNKEN :
		    TK_RELIEF_RAISED);
	    x += butPtr->borderWidth;
	    y += butPtr->borderWidth;
	    dim -= 2*butPtr->borderWidth;
	    if (butPtr->flags & SELECTED) {
		GC gc;
		if (butPtr->state != STATE_DISABLED) {
		    if (butPtr->selectBorder != NULL) {
			gc = Tk_3DBorderGC(tkwin, butPtr->selectBorder,
				TK_3D_FLAT_GC);
		    } else {
			gc = Tk_3DBorderGC(tkwin, butPtr->normalBorder,
				TK_3D_FLAT_GC);
		    }
		} else {
		    if (butPtr->disabledFg != NULL) {
			gc = butPtr->disabledGC;
		    } else {
			gc = butPtr->normalTextGC; 
			XSetForeground(butPtr->display, butPtr->disabledGC,
				Tk_3DBorderColor(butPtr->normalBorder)->pixel);
		    }
		}

		XFillRectangle(butPtr->display, pixmap, gc, x, y,
			(unsigned int) dim, (unsigned int) dim);
	    } else {
		Tk_Fill3DRectangle(tkwin, pixmap, butPtr->normalBorder, x, y,
			dim, dim, butPtr->borderWidth, TK_RELIEF_FLAT);
	    }
d611 2
a612 2
	XPoint points[4];
	int radius;
d614 6
a619 35
	radius = butPtr->indicatorDiameter/2;
	points[0].x = x - butPtr->indicatorSpace;
	points[0].y = y;
	points[1].x = points[0].x + radius;
	points[1].y = points[0].y + radius;
	points[2].x = points[1].x + radius;
	points[2].y = points[0].y;
	points[3].x = points[1].x;
	points[3].y = points[0].y - radius;
	if (butPtr->flags & SELECTED) {
	    GC gc;

	    if (butPtr->state != STATE_DISABLED) {
		if (butPtr->selectBorder != NULL) {
		    gc = Tk_3DBorderGC(tkwin, butPtr->selectBorder,
			    TK_3D_FLAT_GC);
		} else {
		    gc = Tk_3DBorderGC(tkwin, butPtr->normalBorder,
			    TK_3D_FLAT_GC);
		}
	    } else {
		if (butPtr->disabledFg != NULL) {
		    gc = butPtr->disabledGC;
		} else {
		    gc = butPtr->normalTextGC; 
		    XSetForeground(butPtr->display, butPtr->disabledGC,
			    Tk_3DBorderColor(butPtr->normalBorder)->pixel);
		}
	    }

	    XFillPolygon(butPtr->display, pixmap, gc, points, 4, Convex,
		    CoordModeOrigin);
	} else {
	    Tk_Fill3DPolygon(tkwin, pixmap, butPtr->normalBorder, points,
		    4, butPtr->borderWidth, TK_RELIEF_FLAT);
a620 3
	Tk_Draw3DPolygon(tkwin, pixmap, border, points, 4, butPtr->borderWidth,
		(butPtr->flags & SELECTED) ? TK_RELIEF_SUNKEN :
		TK_RELIEF_RAISED);
@


1.12
log
@	* unix/tkUnixButton.c (TkpDisplayButton): Use the normalTextGc when
	* win/tkWinButton.c (TkpDisplayButton):   displaying disabled text
	that have images, as they get a gray50 stipple as well and the
	disabledGc is not set up correctly for font drawing. [Bug #477740]
@
text
@d12 1
a12 1
 * RCS: @@(#) $Id: tkUnixButton.c,v 1.11 2003/02/25 01:39:57 hobbs Exp $
d89 1
a89 1
    int imageXOffset, imageYOffset, textXOffset, textYOffset;
d95 4
d183 3
a188 2
	imageXOffset = 0;
	imageYOffset = 0;
d254 4
a257 1
	
d261 1
a261 2
			width, height, pixmap, x + imageXOffset,
			y + imageYOffset);
d264 1
a264 1
			height, pixmap, x + imageXOffset, y + imageYOffset);
d267 1
a267 2
	    XSetClipOrigin(butPtr->display, gc, x + imageXOffset,
		    y + imageYOffset);
d269 2
a270 3
		    0, 0, (unsigned int) width,
		    (unsigned int) height, x + imageXOffset,
		    y + imageYOffset, 1);
d274 1
a274 5
	/*
	 * Use normalTextGC in this case since we have both text and image,
	 * the whole button will later be stippled 50% grey.
	 */
	Tk_DrawTextLayout(butPtr->display, pixmap, butPtr->normalTextGC,
d276 1
a276 1
	Tk_UnderlineTextLayout(butPtr->display, pixmap, butPtr->normalTextGC,
d295 2
d433 1
a433 1
     * must temporarily modify the GC.
d440 1
a440 1
	    XSetForeground(butPtr->display, butPtr->disabledGC,
d443 12
a454 4
	XFillRectangle(butPtr->display, pixmap, butPtr->disabledGC,
		butPtr->inset, butPtr->inset,
		(unsigned) (Tk_Width(tkwin) - 2*butPtr->inset),
		(unsigned) (Tk_Height(tkwin) - 2*butPtr->inset));
d457 1
a457 1
	    XSetForeground(butPtr->display, butPtr->disabledGC,
@


1.11
log
@	* unix/tkUnixButton.c (TkpDisplayButton): Correct visual display
	of disabled check/radiobutton to be more distinctive on unix.
	* tests/unixButton.test: [Bug #669595] (hintermayer)
@
text
@d12 1
a12 1
 * RCS: @@(#) $Id: tkUnixButton.c,v 1.10 2002/08/28 01:08:06 drh Exp $
d269 7
a275 3
	Tk_DrawTextLayout(butPtr->display, pixmap, gc, butPtr->textLayout,
		x + textXOffset, y + textYOffset, 0, -1);
	Tk_UnderlineTextLayout(butPtr->display, pixmap, gc,
@


1.11.2.1
log
@	* unix/tkUnixButton.c (TkpDisplayButton): Use the normalTextGc when
	* win/tkWinButton.c (TkpDisplayButton):   displaying disabled text
	that have images, as they get a gray50 stipple as well and the
	disabledGc is not set up correctly for font drawing. [Bug #477740]
@
text
@d12 1
a12 1
 * RCS: @@(#) $Id: tkUnixButton.c,v 1.12 2003/04/25 20:03:43 hobbs Exp $
d269 3
a271 7
	/*
	 * Use normalTextGC in this case since we have both text and image,
	 * the whole button will later be stippled 50% grey.
	 */
	Tk_DrawTextLayout(butPtr->display, pixmap, butPtr->normalTextGC,
		butPtr->textLayout, x + textXOffset, y + textYOffset, 0, -1);
	Tk_UnderlineTextLayout(butPtr->display, pixmap, butPtr->normalTextGC,
@


1.11.2.2
log
@	* generic/tkButton.h:                         Rewrote the handling
	* generic/tkButton.c (TkButtonWorldChanged):  of compound *buttons
	* mac/tkMacButton.c (TkpDisplayButton):       to correctly display
	* macosx/tkMacOSXButton.c (TkpDisplayButton): mixture of disabledfg,
	* unix/tkUnixButton.c (TkpDisplayButton):     selectcolor, indicator,
	* win/tkWinButton.c (TkpDisplayButton):       etc.  *buttons will
	now only stipple the image, unless no disabledfg is given, in which
	case it will stipple the whole button.
@
text
@d12 1
a12 1
 * RCS: @@(#) $Id: tkUnixButton.c,v 1.11.2.1 2003/04/25 20:11:30 hobbs Exp $
d89 1
a89 1
    int textXOffset, textYOffset;
a94 4
    int imageWidth, imageHeight;
    int imageXOffset = 0, imageYOffset = 0; /* image information that will
					     * be used to restrict disabled
					     * pixmap as well */
a178 3
    imageWidth  = width;
    imageHeight = height;

d182 2
d249 1
a249 4

	imageXOffset += x;
	imageYOffset += y;

d253 2
a254 1
			width, height, pixmap, imageXOffset, imageYOffset);
d257 1
a257 1
			height, pixmap, imageXOffset, imageYOffset);
d260 2
a261 1
	    XSetClipOrigin(butPtr->display, gc, imageXOffset, imageYOffset);
d263 3
a265 2
		    0, 0, (unsigned int) width, (unsigned int) height,
		    imageXOffset, imageYOffset, 1);
d273 1
a273 1
	Tk_DrawTextLayout(butPtr->display, pixmap, gc,
d275 1
a275 1
	Tk_UnderlineTextLayout(butPtr->display, pixmap, gc,
a293 2
	    imageXOffset += x;
	    imageXOffset += y;
d430 1
a430 1
     * must temporarily modify the GC so the stippling is the right color.
d437 1
a437 1
	    XSetForeground(butPtr->display, butPtr->stippleGC,
d440 4
a443 12
	/*
	 * Stipple the whole button if no disabledFg was specified,
	 * otherwise restrict stippling only to displayed image
	 */
	if (butPtr->disabledFg == NULL) {
	    XFillRectangle(butPtr->display, pixmap, butPtr->stippleGC, 0, 0,
		    (unsigned) Tk_Width(tkwin), (unsigned) Tk_Height(tkwin));
	} else {
	    XFillRectangle(butPtr->display, pixmap, butPtr->stippleGC,
		    imageXOffset, imageYOffset,
		    (unsigned) imageWidth, (unsigned) imageHeight);
	}
d446 1
a446 1
	    XSetForeground(butPtr->display, butPtr->stippleGC,
@


1.11.2.3
log
@remove outdated comments
@
text
@d12 1
a12 1
 * RCS: @@(#) $Id: tkUnixButton.c,v 1.11.2.2 2003/04/26 02:53:47 hobbs Exp $
d274 4
@


1.11.2.4
log
@	* mac/tkMacButton.c (TkpDisplayButton):
	* macosx/tkMacOSXButton.c (TkpDisplayButton):
	* unix/tkUnixButton.c (TkpDisplayButton): correct imageYOffset for
	buttons with just images.
@
text
@d12 1
a12 1
 * RCS: @@(#) $Id: tkUnixButton.c,v 1.11.2.3 2003/04/26 02:58:17 hobbs Exp $
d296 1
a296 1
	    imageYOffset += y;
d301 1
a301 1
			    height, pixmap, imageXOffset, imageYOffset);
d304 1
a304 1
			    imageXOffset, imageYOffset);
@


1.11.2.5
log
@	* unix/tkUnixButton.c (TkpDisplayButton): constrain coords to
	Tk_RedrawImage to display only portion that is valid.
	* generic/tkImgPhoto.c (ImgPhotoDisplay): add X error suppression
	around XGetImage to prevent app abort. [Bug 979239]
@
text
@d12 1
a12 1
 * RCS: @@(#) $Id: tkUnixButton.c,v 1.11.2.4 2003/10/10 20:20:47 hobbs Exp $
d239 1
a239 1

d244 1
a244 1

a258 24
	    /*
	     * Do boundary clipping, so that Tk_RedrawImage is passed
	     * valid coordinates. [Bug 979239]
	     */

	    if (imageXOffset < 0) {
		imageXOffset = 0;
	    }
	    if (imageYOffset < 0) {
		imageYOffset = 0;
	    }
	    if (width > Tk_Width(tkwin)) {
		width = Tk_Width(tkwin);
	    }
	    if (height > Tk_Height(tkwin)) {
		height = Tk_Height(tkwin);
	    }
	    if ((width + imageXOffset) > Tk_Width(tkwin)) {
		imageXOffset = Tk_Width(tkwin) - width;
	    }
	    if ((height + imageYOffset) > Tk_Height(tkwin)) {
		imageYOffset = Tk_Height(tkwin) - height;
	    }

a297 24
		/*
		 * Do boundary clipping, so that Tk_RedrawImage is passed
		 * valid coordinates. [Bug 979239]
		 */

		if (imageXOffset < 0) {
		    imageXOffset = 0;
		}
		if (imageYOffset < 0) {
		    imageYOffset = 0;
		}
		if (width > Tk_Width(tkwin)) {
		    width = Tk_Width(tkwin);
		}
		if (height > Tk_Height(tkwin)) {
		    height = Tk_Height(tkwin);
		}
		if ((width + imageXOffset) > Tk_Width(tkwin)) {
		    imageXOffset = Tk_Width(tkwin) - width;
		}
		if ((height + imageYOffset) > Tk_Height(tkwin)) {
		    imageYOffset = Tk_Height(tkwin) - height;
		}

@


1.10
log
@Fix for bug #582457: make radio and checkbuttons work like Windows when
-relief is sunken, -offrelief is flat, and -overrelief is raised.
@
text
@d12 1
a12 1
 * RCS: @@(#) $Id: tkUnixButton.c,v 1.9 2002/06/17 10:54:29 drh Exp $
d352 8
a359 4
		if (butPtr->state != STATE_DISABLED &&
			butPtr->selectBorder != NULL) {
		    gc = Tk_3DBorderGC(tkwin, butPtr->selectBorder,
			    TK_3D_FLAT_GC);
d361 7
a367 2
		    gc = Tk_3DBorderGC(tkwin, butPtr->normalBorder,
			    TK_3D_FLAT_GC);
d369 1
a369 1
		
d393 8
a400 3
	    if (butPtr->state != STATE_DISABLED &&
		    butPtr->selectBorder != NULL) {
		gc = Tk_3DBorderGC(tkwin, butPtr->selectBorder,	TK_3D_FLAT_GC);
d402 7
a408 1
		gc = Tk_3DBorderGC(tkwin, butPtr->normalBorder,	TK_3D_FLAT_GC);
d410 1
a410 1
	    
@


1.9
log
@Initial implementation of TIP #82: added the -offrelief option to
checkbutton and radiobutton to allow those widgets to have a
MS-Office look and feel.
@
text
@d12 1
a12 1
 * RCS: @@(#) $Id: tkUnixButton.c,v 1.8 2000/11/22 01:49:38 ericm Exp $
d118 25
a142 1
     * checkbutton or radiobutton and there's no indicator.
d147 5
a151 2
	relief = (butPtr->flags & SELECTED) ? TK_RELIEF_SUNKEN
		: butPtr->offRelief;
@


1.8
log
@	Overall change:  Implemented TIP 5, which exports
	TkClassProcs/TkSetClassProcs as Tk_ClassProcs/Tk_SetClassProcs,
	adding a size field to Tk_ClassProcs to allow for future
	expansion, and renaming the geometryProc to worldChangedProc,
	which is more in keeping with the actual use of the callback.

	See ChangeLog for details.
@
text
@d12 1
a12 1
 * RCS: @@(#) $Id: tkUnixButton.c,v 1.7 2000/07/29 01:08:54 ericm Exp $
d124 1
a124 1
		: TK_RELIEF_RAISED;
@


1.8.4.1
log
@merged with trunk at tag macosx-8-4-merge-2002-08-20-trunk
@
text
@d12 1
a12 1
 * RCS: @@(#) $Id$
d124 1
a124 1
		: butPtr->offRelief;
@


1.8.4.2
log
@merged with trunk at tag macosx-8-4-merge-2002-08-30-trunk
@
text
@d12 1
a12 1
 * RCS: @@(#) $Id: tkUnixButton.c,v 1.8.4.1 2002/08/20 20:27:18 das Exp $
d118 1
a118 25
     * checkbutton or radiobutton and there's no indicator.  The new
     * relief is as follows:
     *      If the button is select  --> "sunken"
     *      If relief==overrelief    --> relief
     *      Otherwise                --> overrelief
     *
     * The effect we are trying to achieve is as follows:
     *
     *      value    mouse-over?   -->   relief
     *     -------  ------------        --------
     *       off        no               flat
     *       off        yes              raised
     *       on         no               sunken
     *       on         yes              sunken
     *
     * This is accomplished by configuring the checkbutton or radiobutton
     * like this:
     *
     *     -indicatoron 0 -overrelief raised -offrelief flat
     *
     * Bindings (see library/button.tcl) will copy the -overrelief into
     * -relief on mouseover.  Hence, we can tell if we are in mouse-over by
     * comparing relief against overRelief.  This is an aweful kludge, but
     * it gives use the desired behavior while keeping the code backwards
     * compatible.
d123 2
a124 5
	if (butPtr->flags & SELECTED) {
	    relief = TK_RELIEF_SUNKEN;
	} else if (butPtr->overRelief != relief) {
	    relief = butPtr->offRelief;
	}
@


1.7
log
@* unix/tkUnixButton.c (TkpDisplayButton): Added bits to change
the indicator color when radio-/check-buttons are disabled.  This
reduces the visual incongruity when a group of these controls are
disabled together.
@
text
@d12 1
a12 1
 * RCS: @@(#) $Id: tkUnixButton.c,v 1.6 2000/05/17 21:17:22 ericm Exp $
d29 3
a31 4
TkClassProcs tkpButtonProcs = { 
    NULL,			/* createProc. */
    TkButtonWorldChanged,	/* geometryProc. */
    NULL			/* modalProc. */
@


1.7.2.1
log
@sync with head
@
text
@d12 1
a12 1
 * RCS: @@(#) $Id: tkUnixButton.c,v 1.8 2000/11/22 01:49:38 ericm Exp $
d29 4
a32 3
Tk_ClassProcs tkpButtonProcs = {
    sizeof(Tk_ClassProcs),	/* size */
    TkButtonWorldChanged,	/* worldChangedProc */
@


1.6
log
@* doc/SetOptions.3: Added information about TK_OPTION_NULL_OK with
TK_OPTION_RELIEF.

* win/tkWinButton.c: Removed bits about TK_RELIEF_LINK.

* tests/button.test: Added tests for -overrelief; removed tests
for -relief link.

* mac/tkMacButton.c: Removed bits about TK_RELIEF_LINK.

* generic/tkOldConfig.c: Removed bits about TK_RELIEF_LINK.

* generic/tkConfig.c: Removed bits about TK_RELIEF_LINK; added
support for TK_OPTION_NULL_OK for TK_OPTION_RELIEF.

* library/button.tcl: Added binding support for -overrelief.

* generic/tk3d.c (Tk_GetRelief): Added branch for TK_RELIEF_NULL.

* generic/tkButton.c: Added -overrelief option; removed
Enter/Leave EventProc masks and handlers.

* generic/tk.h: Added TK_RELIEF_NULL definition, removed
TK_RELIEF_LINK.

* mac/tkMacDefault.h (DEF_BUTTON_OVER_RELIEF):
* win/tkWinDefault.h (DEF_BUTTON_OVER_RELIEF):
* unix/tkUnixDefault.h (DEF_BUTTON_OVER_RELIEF): Added default
value for the -overrelief option.
@
text
@d12 1
a12 1
 * RCS: @@(#) $Id: tkUnixButton.c,v 1.5 2000/05/13 00:39:09 ericm Exp $
d326 9
a334 4

		gc = Tk_3DBorderGC(tkwin, (butPtr->selectBorder != NULL)
			? butPtr->selectBorder : butPtr->normalBorder,
			TK_3D_FLAT_GC);
d358 7
a364 3
	    gc = Tk_3DBorderGC(tkwin, (butPtr->selectBorder != NULL)
		    ? butPtr->selectBorder : butPtr->normalBorder,
		    TK_3D_FLAT_GC);
@


1.5
log
@* unix/tkUnixButton.c (TkpDisplayButton, TkpComputeButtonGeometry):
* mac/tkMacButton.c (TkpDisplayButton, TkpComputeButtonGeometry):
* win/tkWinButton.c (TkpDisplayButton, TkpComputeButtonGeometry):
Added code for drawing compound buttons.

* tests/button.test: Added configuration tests for -repeatdelay,
-repeatinterval, -compound.

* library/button.tcl: Added support for -repeatedelay,
-repeatinterval options.

* generic/tkOldConfig.c: Changed handling of link relief so that
proper error messages are used.

* generic/tkButton.h: Added -compound, -repeatdelay,
-repeatinterval options.

* generic/tkButton.c: Added event watchers for enter/leave events,
for link relief support.

* generic/tk3d.c: Changed handling of link relief so that proper
error messages are used.

* generic/tk.h: Changed values of
TK_OPTION_LINK_OK/TK_CONFIG_LINK_OK for link relief support.
@
text
@d12 1
a12 1
 * RCS: @@(#) $Id: tkUnixButton.c,v 1.4 2000/05/10 00:09:40 ericm Exp $
a127 14
    /*
     * LINK relief means that the button has a raised relief when it is
     * active, and a flat relief otherwise (like toolbar buttons).  It
     * is supported for true buttons only.
     */

    if ((butPtr->type == TYPE_BUTTON) && butPtr->relief == TK_RELIEF_LINK) {
	if ((butPtr->flags & MOUSE_IN_BUTTON) == MOUSE_IN_BUTTON) {
	    relief = TK_RELIEF_RAISED;
	} else {
	    relief = TK_RELIEF_FLAT;
	}
    }
    
@


1.4
log
@	* doc/button.n: Added documentation for link relief.

	* tests/button.test: Added tests for link relief for buttons.

	* generic/tk.h (TK_CONFIG_LINK_OK): Added definition of
	TK_RELIEF_LINK, TK_OPTION_LINK_OK and TK_CONFIG_LINK_OK. [RFE: 4348]

	* generic/tk3d.c: Added support for link relief. [RFE: 4348]

	* mac/tkMacButton.c (TkpDisplayButton):
	* unix/tkUnixButton.c (TkpDisplayButton): Added support for link
	relief. [RFE: 4348]

	* generic/tkOldConfig.c (Tk_ConfigureWidget):
	* generic/tkConfig.c (DoObjConfig): Added understanding of link
	relief, which is allowed only for widgets that have
	TK_OPTION_LINK_OK or TK_CONFIG_LINK_OK set for the "-relief"
	option. [RFE: 4348]

	* generic/tkButton.c: Added TK_OPTION_LINK_OK to "-relief" option
	for buttons. [RFE: 4348]

	* win/tkWinWm.c (EX_TRANSIENT_STYLE): Removed WS_EX_TOOLWINDOW
	style bit, so that transient windows have full-size titlebars
	(like the tk_getOpenFile dialog).

	* win/tkWinMenu.c (GetMenuSeparatorGeometry): Tweaked height
	requested for separator bars to be (linespace - (2*descent))
	instead of just (linespace); this makes the separator occupy a
	more correct amount of vertical space. [Bug: 5303].
@
text
@d12 1
a12 1
 * RCS: @@(#) $Id: tkUnixButton.c,v 1.3 1999/04/16 01:51:45 stanton Exp $
d89 3
a91 1
    int width, height;
d94 2
a95 1
				 * to move up and down as the relief changes. */
d135 1
a135 1
	if (butPtr->state == STATE_ACTIVE) {
d162 63
a225 3
	imageOrBitmap:
	TkComputeAnchor(butPtr->anchor, tkwin, 0, 0,
		butPtr->indicatorSpace + width, height, &x, &y);
d227 1
a227 1

d237 1
d240 3
a242 2
		Tk_RedrawImage(butPtr->selectImage, 0, 0, width, height, pixmap,
			x, y);
d244 2
a245 2
		Tk_RedrawImage(butPtr->image, 0, 0, width, height, pixmap,
			x, y);
d248 6
a253 3
	    XSetClipOrigin(butPtr->display, gc, x, y);
	    XCopyPlane(butPtr->display, butPtr->bitmap, pixmap, gc, 0, 0,
		    (unsigned int) width, (unsigned int) height, x, y, 1);
d256 7
a262 4
	y += height/2;
    } else if (butPtr->bitmap != None) {
	Tk_SizeOfBitmap(butPtr->display, butPtr->bitmap, &width, &height);
	goto imageOrBitmap;
d264 37
a300 12
	TkComputeAnchor(butPtr->anchor, tkwin, butPtr->padX, butPtr->padY,
		butPtr->indicatorSpace + butPtr->textWidth, butPtr->textHeight,
		&x, &y);

	x += butPtr->indicatorSpace;

	x += offset;
	y += offset;
	if (relief == TK_RELIEF_RAISED) {
	    x -= offset;
	    y -= offset;
	} else if (relief == TK_RELIEF_SUNKEN) {
d303 12
a315 5
	Tk_DrawTextLayout(butPtr->display, pixmap, gc, butPtr->textLayout,
		x, y, 0, -1);
	Tk_UnderlineTextLayout(butPtr->display, pixmap, gc,
		butPtr->textLayout, x, y, butPtr->underline);
	y += butPtr->textHeight/2;
d317 1
a317 1

d514 2
a515 1
    int width, height, avgWidth;
d528 7
d537 51
a587 1
	imageOrBitmap:
d594 1
a602 5
    } else if (butPtr->bitmap != None) {
	Tk_SizeOfBitmap(butPtr->display, butPtr->bitmap, &width, &height);
	goto imageOrBitmap;
    } else {
	Tk_FreeTextLayout(butPtr->textLayout);
d604 2
a605 3
	butPtr->textLayout = Tk_ComputeTextLayout(butPtr->tkfont,
		Tcl_GetString(butPtr->textPtr), -1, butPtr->wrapLength,
		butPtr->justify, 0, &butPtr->textWidth, &butPtr->textHeight);
d607 34
a640 15
	width = butPtr->textWidth;
	height = butPtr->textHeight;
	avgWidth = Tk_TextWidth(butPtr->tkfont, "0", 1);
	Tk_GetFontMetrics(butPtr->tkfont, &fm);

	if (butPtr->width > 0) {
	    width = butPtr->width * avgWidth;
	}
	if (butPtr->height > 0) {
	    height = butPtr->height * fm.linespace;
	}
	if ((butPtr->type >= TYPE_CHECK_BUTTON) && butPtr->indicatorOn) {
	    butPtr->indicatorDiameter = fm.linespace;
	    if (butPtr->type == TYPE_CHECK_BUTTON) {
		butPtr->indicatorDiameter = (80*butPtr->indicatorDiameter)/100;
a641 1
	    butPtr->indicatorSpace = butPtr->indicatorDiameter + avgWidth;
@


1.3
log
@* Merged 8.1 branch into the main trunk
@
text
@d12 1
a12 1
 * RCS: @@(#) $Id$
d125 14
@


1.2
log
@Replaced SCCS strings, fixed binary files
@
text
@d7 1
a7 1
 * Copyright (c) 1996 by Sun Microsystems, Inc.
d88 1
a88 1
    register Tk_Window tkwin = butPtr->tkwin;
d90 3
a92 4
    int offset;			/* 0 means this is a label widget.  1 means
				 * it is a flavor of button, so we offset
				 * the text to make the button appear to
				 * move up and down as the relief changes. */
d100 1
a100 1
    if ((butPtr->state == tkDisabledUid) && (butPtr->disabledFg != NULL)) {
d102 1
a102 1
    } else if ((butPtr->state == tkActiveUid)
d109 1
a109 1
    if ((butPtr->flags & SELECTED) && (butPtr->state != tkActiveUid)
d143 1
a143 1
    if (butPtr->image != None) {
d215 1
a215 1
		    butPtr->borderWidth, 
d224 1
a224 1
		gc = Tk_3DBorderGC(tkwin,(butPtr->selectBorder != NULL)
d271 1
a271 1
    if ((butPtr->state == tkDisabledUid)
d299 2
a300 1
	if (butPtr->defaultState == tkActiveUid) {
d322 1
a322 1
	} else if (butPtr->defaultState == tkNormalUid) {
d329 1
a329 2
		    0, Tk_Width(tkwin),
		    Tk_Height(tkwin), 5, TK_RELIEF_FLAT);
d341 1
a341 1
    if (butPtr->highlightWidth != 0) {
d356 1
a356 1
	if (butPtr->defaultState == tkNormalUid) {
a399 3
    if (butPtr->highlightWidth < 0) {
	butPtr->highlightWidth = 0;
    }
d406 1
a406 1
    if (butPtr->defaultState != tkDisabledUid) {
d432 1
d434 2
a435 2
		butPtr->text, -1, butPtr->wrapLength, butPtr->justify, 0,
		&butPtr->textWidth, &butPtr->textHeight);
@


1.1
log
@Initial revision
@
text
@d12 1
a12 1
 * SCCS: @@(#) tkUnixButton.c 1.4 97/06/06 11:21:40
@


1.1.4.1
log
@initial tk8.1a2 version
@
text
@d7 1
a7 1
 * Copyright (c) 1996-1997 by Sun Microsystems, Inc.
d12 1
a12 1
 * SCCS: @@(#) tkUnixButton.c 1.6 97/12/22 10:44:42
d88 1
a88 1
    Tk_Window tkwin = butPtr->tkwin;
d90 4
a93 3
    int offset;			/* 1 means this is a button widget, so we
				 * offset the text to make the button appear
				 * to move up and down as the relief changes. */
d101 1
a101 1
    if ((butPtr->state == STATE_DISABLED) && (butPtr->disabledFg != NULL)) {
d103 1
a103 1
    } else if ((butPtr->state == STATE_ACTIVE)
d110 1
a110 1
    if ((butPtr->flags & SELECTED) && (butPtr->state != STATE_ACTIVE)
d144 1
a144 1
    if (butPtr->image != NULL) {
d216 1
a216 1
		    butPtr->borderWidth,
d225 1
a225 1
		gc = Tk_3DBorderGC(tkwin, (butPtr->selectBorder != NULL)
d272 1
a272 1
    if ((butPtr->state == STATE_DISABLED)
d300 1
a300 2

	if (butPtr->defaultState == DEFAULT_ACTIVE) {
d322 1
a322 1
	} else if (butPtr->defaultState == DEFAULT_NORMAL) {
d329 2
a330 1
		    0, Tk_Width(tkwin), Tk_Height(tkwin), 5, TK_RELIEF_FLAT);
d342 1
a342 1
    if (butPtr->highlightWidth > 0) {
d357 1
a357 1
	if (butPtr->defaultState == DEFAULT_NORMAL) {
a398 2
    int length;
    char *text;
d401 3
a403 2
    text = Tcl_GetStringFromObj(butPtr->textPtr, &length);

d410 1
a410 1
    if (butPtr->defaultState != DEFAULT_DISABLED) {
d437 1
a437 1
		 text, length, butPtr->wrapLength, butPtr->justify, 0,
@


1.1.4.2
log
@Merged 8.0.3 changes into 8.1
@
text
@d12 1
a12 1
 * RCS: @@(#) $Id: tkUnixButton.c,v 1.2 1998/09/14 18:23:55 stanton Exp $
@


1.1.4.3
log
@* doc/MeasureChar.3:
* doc/TextLayout.3:
* generic/tk.decls:
* generic/tkCanvText.c:
* generic/tkEntry.c:
* generic/tkFont.c:
* generic/tkListbox.c:
* generic/tkMessage.c:
* mac/tkMacFont.c:
* unix/tkUnixButton.c:
* unix/tkUnixFont.c:
* unix/tkUnixMenu.c:
* win/tkWinFont.c:
* win/tkWinMenu.c: Standardized text layout and font interfaces
so they are consistent with respect to byte versus character
oriented indices.  The layout functions all manipulate character
oriented values while the lower level measurement functions all
operate on byte oriented values.  This distinction was not clear
and so the functions were being used improperly in a number of
places.  [Bug: 1053, 747, 749, 1646]

* generic/tk.decls: Eliminated uses of C++ STL types string and
list from declarations.

* generic/tkFont.c: Changes to named fonts were not being
propagated in some cases. [Bug: 1144]
@
text
@d12 1
a12 1
 * RCS: @@(#) $Id$
d398 2
d402 2
a435 1

d437 2
a438 2
		Tcl_GetString(butPtr->textPtr), -1, butPtr->wrapLength,
		butPtr->justify, 0, &butPtr->textWidth, &butPtr->textHeight);
@


