|
Packit |
b099d7 |
/*
|
|
Packit |
b099d7 |
* Motif
|
|
Packit |
b099d7 |
*
|
|
Packit |
b099d7 |
* Copyright (c) 1987-2012, The Open Group. All rights reserved.
|
|
Packit |
b099d7 |
*
|
|
Packit |
b099d7 |
* These libraries and programs are free software; you can
|
|
Packit |
b099d7 |
* redistribute them and/or modify them under the terms of the GNU
|
|
Packit |
b099d7 |
* Lesser General Public License as published by the Free Software
|
|
Packit |
b099d7 |
* Foundation; either version 2 of the License, or (at your option)
|
|
Packit |
b099d7 |
* any later version.
|
|
Packit |
b099d7 |
*
|
|
Packit |
b099d7 |
* These libraries and programs are distributed in the hope that
|
|
Packit |
b099d7 |
* they will be useful, but WITHOUT ANY WARRANTY; without even the
|
|
Packit |
b099d7 |
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
Packit |
b099d7 |
* PURPOSE. See the GNU Lesser General Public License for more
|
|
Packit |
b099d7 |
* details.
|
|
Packit |
b099d7 |
*
|
|
Packit |
b099d7 |
* You should have received a copy of the GNU Lesser General Public
|
|
Packit |
b099d7 |
* License along with these librararies and programs; if not, write
|
|
Packit |
b099d7 |
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
|
|
Packit |
b099d7 |
* Floor, Boston, MA 02110-1301 USA
|
|
Packit |
b099d7 |
*/
|
|
Packit |
b099d7 |
/*
|
|
Packit |
b099d7 |
* HISTORY
|
|
Packit |
b099d7 |
*/
|
|
Packit |
b099d7 |
|
|
Packit |
b099d7 |
#ifdef REV_INFO
|
|
Packit |
b099d7 |
#ifndef lint
|
|
Packit |
b099d7 |
static char rcsid[] = "$XConsortium: ToggleBGad5.c /main/4 1995/07/13 17:32:09 drk $"
|
|
Packit |
b099d7 |
#endif
|
|
Packit |
b099d7 |
#endif
|
|
Packit |
b099d7 |
|
|
Packit |
b099d7 |
/****************************************************************************
|
|
Packit |
b099d7 |
*
|
|
Packit |
b099d7 |
* This program tests the indicator dimensions - Changing pixmap sizes,
|
|
Packit |
b099d7 |
* setting the indicator dimension for pixmaps, and changing the label in
|
|
Packit |
b099d7 |
* a pulldown menu of toggle buttons.
|
|
Packit |
b099d7 |
*
|
|
Packit |
b099d7 |
****************************************************************************/
|
|
Packit |
b099d7 |
#include <testlib.h>
|
|
Packit |
b099d7 |
#include <X11/Xlib.h>
|
|
Packit |
b099d7 |
#include <X11/StringDefs.h>
|
|
Packit |
b099d7 |
#include <X11/Xatom.h>
|
|
Packit |
b099d7 |
|
|
Packit |
b099d7 |
#define xlogo32_width 32
|
|
Packit |
b099d7 |
#define xlogo32_height 32
|
|
Packit |
b099d7 |
static char xlogo32_bits[] = {
|
|
Packit |
b099d7 |
0xff, 0x00, 0x00, 0xc0, 0xfe, 0x01, 0x00, 0xc0, 0xfc, 0x03, 0x00, 0x60,
|
|
Packit |
b099d7 |
0xf8, 0x07, 0x00, 0x30, 0xf8, 0x07, 0x00, 0x18, 0xf0, 0x0f, 0x00, 0x0c,
|
|
Packit |
b099d7 |
0xe0, 0x1f, 0x00, 0x06, 0xc0, 0x3f, 0x00, 0x06, 0xc0, 0x3f, 0x00, 0x03,
|
|
Packit |
b099d7 |
0x80, 0x7f, 0x80, 0x01, 0x00, 0xff, 0xc0, 0x00, 0x00, 0xfe, 0x61, 0x00,
|
|
Packit |
b099d7 |
0x00, 0xfe, 0x31, 0x00, 0x00, 0xfc, 0x33, 0x00, 0x00, 0xf8, 0x1b, 0x00,
|
|
Packit |
b099d7 |
0x00, 0xf0, 0x0d, 0x00, 0x00, 0xf0, 0x0e, 0x00, 0x00, 0x60, 0x1f, 0x00,
|
|
Packit |
b099d7 |
0x00, 0xb0, 0x3f, 0x00, 0x00, 0x98, 0x7f, 0x00, 0x00, 0x98, 0x7f, 0x00,
|
|
Packit |
b099d7 |
0x00, 0x0c, 0xff, 0x00, 0x00, 0x06, 0xfe, 0x01, 0x00, 0x03, 0xfc, 0x03,
|
|
Packit |
b099d7 |
0x80, 0x01, 0xfc, 0x03, 0xc0, 0x00, 0xf8, 0x07, 0xc0, 0x00, 0xf0, 0x0f,
|
|
Packit |
b099d7 |
0x60, 0x00, 0xe0, 0x1f, 0x30, 0x00, 0xe0, 0x1f, 0x18, 0x00, 0xc0, 0x3f,
|
|
Packit |
b099d7 |
0x0c, 0x00, 0x80, 0x7f, 0x06, 0x00, 0x00, 0xff};
|
|
Packit |
b099d7 |
|
|
Packit |
b099d7 |
#define LARGE_width 16
|
|
Packit |
b099d7 |
#define LARGE_height 16
|
|
Packit |
b099d7 |
static char LARGE_bits[] = {
|
|
Packit |
b099d7 |
0x03, 0xc0, 0x07, 0xe0, 0x0e, 0x70, 0x1c, 0x38, 0x38, 0x1c, 0x70, 0x0e,
|
|
Packit |
b099d7 |
0Xe0, 0x07, 0x40, 0x02, 0x40, 0x02, 0xe0, 0x07, 0x70, 0x0e, 0x38, 0x1c,
|
|
Packit |
b099d7 |
0x1c, 0x38, 0x0e, 0x70, 0x07, 0xe0, 0x03, 0xc0};
|
|
Packit |
b099d7 |
|
|
Packit |
b099d7 |
#define grid8_width 8
|
|
Packit |
b099d7 |
#define grid8_height 8
|
|
Packit |
b099d7 |
static char grid8_bits[] = {
|
|
Packit |
b099d7 |
0x55, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00};
|
|
Packit |
b099d7 |
|
|
Packit |
b099d7 |
Pixmap pix[3];
|
|
Packit |
b099d7 |
|
|
Packit |
b099d7 |
void pbCB (widget, togglebutton, callData)
|
|
Packit |
b099d7 |
Widget widget;
|
|
Packit |
b099d7 |
XtPointer togglebutton;
|
|
Packit |
b099d7 |
XtPointer callData;
|
|
Packit |
b099d7 |
{
|
|
Packit |
b099d7 |
Cardinal n;
|
|
Packit |
b099d7 |
Arg args[MAX_ARGS];
|
|
Packit |
b099d7 |
Widget tb = (Widget)togglebutton;
|
|
Packit |
b099d7 |
static int pix_num = 0;
|
|
Packit |
b099d7 |
|
|
Packit |
b099d7 |
pix_num = (pix_num + 1) % 3;
|
|
Packit |
b099d7 |
n = 0;
|
|
Packit |
b099d7 |
XtSetArg(args[n], XmNlabelPixmap, pix[pix_num]); n++;
|
|
Packit |
b099d7 |
XtSetValues(tb, args, n);
|
|
Packit |
b099d7 |
}
|
|
Packit |
b099d7 |
|
|
Packit |
b099d7 |
void tbCB (widget, moreinfo, callData)
|
|
Packit |
b099d7 |
Widget widget;
|
|
Packit |
b099d7 |
XtPointer moreinfo;
|
|
Packit |
b099d7 |
XtPointer callData;
|
|
Packit |
b099d7 |
{
|
|
Packit |
b099d7 |
Cardinal n;
|
|
Packit |
b099d7 |
Arg args[MAX_ARGS];
|
|
Packit |
b099d7 |
XmString original = XmStringCreateLocalized("Button_A");
|
|
Packit |
b099d7 |
XmString new = XmStringCreateLocalized("A New Label");
|
|
Packit |
b099d7 |
XmString from_tb;
|
|
Packit |
b099d7 |
|
|
Packit |
b099d7 |
n = 0;
|
|
Packit |
b099d7 |
XtSetArg(args[n], XmNlabelString, &from_tb); n++;
|
|
Packit |
b099d7 |
XtGetValues(widget, args, n);
|
|
Packit |
b099d7 |
|
|
Packit |
b099d7 |
n = 0;
|
|
Packit |
b099d7 |
XtSetArg(args[n], XmNset, True); n++;
|
|
Packit |
b099d7 |
if (XmStringCompare(original, from_tb))
|
|
Packit |
b099d7 |
{
|
|
Packit |
b099d7 |
XtSetArg(args[n], XmNlabelString, new); n++;
|
|
Packit |
b099d7 |
}
|
|
Packit |
b099d7 |
else if (XmStringCompare(new, from_tb))
|
|
Packit |
b099d7 |
{
|
|
Packit |
b099d7 |
XtSetArg(args[n], XmNlabelString, original); n++;
|
|
Packit |
b099d7 |
}
|
|
Packit |
b099d7 |
else
|
|
Packit |
b099d7 |
{
|
|
Packit |
b099d7 |
printf("A horrible error occurred. AAACCCCKKKK!!!\n\n");
|
|
Packit |
b099d7 |
exit(0);
|
|
Packit |
b099d7 |
}
|
|
Packit |
b099d7 |
XtSetValues(widget, args, n);
|
|
Packit |
b099d7 |
}
|
|
Packit |
b099d7 |
|
|
Packit |
b099d7 |
void main (argc, argv)
|
|
Packit |
b099d7 |
unsigned int argc;
|
|
Packit |
b099d7 |
char **argv;
|
|
Packit |
b099d7 |
{
|
|
Packit |
b099d7 |
Cardinal n;
|
|
Packit |
b099d7 |
Arg args[MAX_ARGS];
|
|
Packit |
b099d7 |
Widget rc, tb1, pb1;
|
|
Packit |
b099d7 |
Widget menubar, pulldown, tb[4], cb1;
|
|
Packit |
b099d7 |
static char labelstring[9] = "Button_A";
|
|
Packit |
b099d7 |
XmString tcs;
|
|
Packit |
b099d7 |
|
|
Packit |
b099d7 |
CommonTestInit(argc, argv);
|
|
Packit |
b099d7 |
|
|
Packit |
b099d7 |
/* Begin test for 4998 - Change the pixmaps to verify that the indicator
|
|
Packit |
b099d7 |
* size changes to match the size of the new pixmap.
|
|
Packit |
b099d7 |
*/
|
|
Packit |
b099d7 |
|
|
Packit |
b099d7 |
rc = XmCreateRowColumn(Shell1, "rc", NULL, 0);
|
|
Packit |
b099d7 |
XtManageChild(rc);
|
|
Packit |
b099d7 |
|
|
Packit |
b099d7 |
pix[0] = XCreatePixmapFromBitmapData(display, DefaultRootWindow(display),
|
|
Packit |
b099d7 |
grid8_bits, grid8_width, grid8_height,
|
|
Packit |
b099d7 |
WhitePixel(display, DefaultScreen(display)),
|
|
Packit |
b099d7 |
BlackPixel(display, DefaultScreen(display)),
|
|
Packit |
b099d7 |
DefaultDepth(display,DefaultScreen(display)));
|
|
Packit |
b099d7 |
|
|
Packit |
b099d7 |
pix[1] = XCreatePixmapFromBitmapData(display, DefaultRootWindow(display),
|
|
Packit |
b099d7 |
LARGE_bits, LARGE_width, LARGE_height,
|
|
Packit |
b099d7 |
WhitePixel(display, DefaultScreen(display)),
|
|
Packit |
b099d7 |
BlackPixel(display, DefaultScreen(display)),
|
|
Packit |
b099d7 |
DefaultDepth(display,DefaultScreen(display)));
|
|
Packit |
b099d7 |
|
|
Packit |
b099d7 |
pix[2] = XCreatePixmapFromBitmapData(display, DefaultRootWindow(display),
|
|
Packit |
b099d7 |
xlogo32_bits, xlogo32_width, xlogo32_height,
|
|
Packit |
b099d7 |
WhitePixel(display, DefaultScreen(display)),
|
|
Packit |
b099d7 |
BlackPixel(display, DefaultScreen(display)),
|
|
Packit |
b099d7 |
DefaultDepth(display,DefaultScreen(display)));
|
|
Packit |
b099d7 |
|
|
Packit |
b099d7 |
n = 0;
|
|
Packit |
b099d7 |
XtSetArg(args[n], XmNlabelType, XmPIXMAP); n++;
|
|
Packit |
b099d7 |
XtSetArg(args[n], XmNlabelPixmap, pix[0]); n++;
|
|
Packit |
b099d7 |
tb1 = XmCreateToggleButtonGadget(rc, "tb1", args, n);
|
|
Packit |
b099d7 |
XtManageChild(tb1);
|
|
Packit |
b099d7 |
|
|
Packit |
b099d7 |
n = 0;
|
|
Packit |
b099d7 |
tcs = XmStringCreateSimple("Cycle Pixmaps");
|
|
Packit |
b099d7 |
XtSetArg(args[n], XmNlabelString, tcs); n++;
|
|
Packit |
b099d7 |
pb1 = XmCreatePushButton(rc, "pb1", args, n);
|
|
Packit |
b099d7 |
XtManageChild(pb1);
|
|
Packit |
b099d7 |
XtAddCallback(pb1, XmNactivateCallback, pbCB, (XtPointer)tb1);
|
|
Packit |
b099d7 |
XmStringFree(tcs);
|
|
Packit |
b099d7 |
|
|
Packit |
b099d7 |
XtRealizeWidget(Shell1);
|
|
Packit |
b099d7 |
|
|
Packit |
b099d7 |
CommonPause();
|
|
Packit |
b099d7 |
|
|
Packit |
b099d7 |
XtDestroyWidget(rc);
|
|
Packit |
b099d7 |
|
|
Packit |
b099d7 |
/* End Test for 4998 */
|
|
Packit |
b099d7 |
|
|
Packit |
b099d7 |
/*
|
|
Packit |
b099d7 |
* Begin test for 5203: Create a pulldown menu of toggle buttons.
|
|
Packit |
b099d7 |
* Add a callback to the first toggle button which will cause a change
|
|
Packit |
b099d7 |
* in its label. Verify that the indicator size stays the same after
|
|
Packit |
b099d7 |
* the change.
|
|
Packit |
b099d7 |
*/
|
|
Packit |
b099d7 |
|
|
Packit |
b099d7 |
n = 0;
|
|
Packit |
b099d7 |
menubar = XmCreateMenuBar(Shell1, "menubar", args, n);
|
|
Packit |
b099d7 |
|
|
Packit |
b099d7 |
n = 0;
|
|
Packit |
b099d7 |
pulldown = XmCreatePulldownMenu(menubar, "pulldown", args, n);
|
|
Packit |
b099d7 |
|
|
Packit |
b099d7 |
for (n = 0; n < 4; n++)
|
|
Packit |
b099d7 |
{
|
|
Packit |
b099d7 |
labelstring[strlen(labelstring) - 1] = 'A' + n;
|
|
Packit |
b099d7 |
tcs = XmStringCreateLocalized(labelstring);
|
|
Packit |
b099d7 |
XtSetArg(args[0], XmNlabelString, tcs);
|
|
Packit |
b099d7 |
XtSetArg(args[1], XmNset, True);
|
|
Packit |
b099d7 |
tb[n] = XmCreateToggleButtonGadget(pulldown, labelstring, args, 2);
|
|
Packit |
b099d7 |
XmStringFree(tcs);
|
|
Packit |
b099d7 |
}
|
|
Packit |
b099d7 |
XtManageChildren(tb, 4);
|
|
Packit |
b099d7 |
XtAddCallback(tb[0], XmNvalueChangedCallback, tbCB, NULL);
|
|
Packit |
b099d7 |
|
|
Packit |
b099d7 |
n = 0;
|
|
Packit |
b099d7 |
XtSetArg(args[n], XmNsubMenuId, pulldown); n++;
|
|
Packit |
b099d7 |
cb1 = XmCreateCascadeButton(menubar, "MENU", args, n);
|
|
Packit |
b099d7 |
XtManageChild(cb1);
|
|
Packit |
b099d7 |
XtManageChild(menubar);
|
|
Packit |
b099d7 |
CommonPause();
|
|
Packit |
b099d7 |
|
|
Packit |
b099d7 |
CommonPause(); /* exit */
|
|
Packit |
b099d7 |
XtAppMainLoop(app_context);
|
|
Packit |
b099d7 |
}
|
|
Packit |
b099d7 |
|
|
Packit |
b099d7 |
|