1 /* $Header: /cvsroot/lesstif/lesstif/test/Xm/pushbutton/test16.c,v 1.4 2001/06/18 09:04:00 amai Exp $
2 From:        Eric Howe <mu@clio.trends.ca>
3 To:          Rick Scott <rwscott@omnisig.com>
4 Subject:     Re: cvs commit: hungry/lesstif/test/Xm/pushbg test8.c Makefile.am
5 Date:        Thu, 23 Jul 1998 00:23:22 -0400 (EDT)
6 cc:          lesstif@hungry.com
7 
8 */
9 
10 #include <stdlib.h>
11 #include <stdio.h>
12 #include <string.h>
13 
14 #include <Xm/Xm.h>
15 #include <Xm/Form.h>
16 #include <Xm/PushB.h>
17 #include <Xm/PushBG.h>
18 #include <Xm/RowColumn.h>
19 
20 #include "../../common/Test.h"
21 
22 
23 static void
DumpResources(Widget w)24 DumpResources(Widget w)
25 {
26 Dimension showAsDefault;
27 Dimension defaultButtonShadowThickness;
28 Dimension marginBottom;
29 Dimension marginHeight;
30 Dimension marginLeft;
31 Dimension marginRight;
32 Dimension marginTop;
33 Dimension marginWidth;
34 Dimension highlightThickness;
35 Dimension shadowThickness;
36 Dimension borderWidth;
37 Dimension height;
38 Dimension width;
39 Dimension pheight;
40 Dimension pwidth;
41 
42 	XtVaGetValues(XtParent(w),
43 		XmNheight, &pheight,
44 		XmNwidth, &pwidth,
45 		NULL);
46 	XtVaGetValues(w,
47 		XmNshowAsDefault, &showAsDefault,
48 		XmNdefaultButtonShadowThickness, &defaultButtonShadowThickness,
49 		XmNmarginBottom, &marginBottom,
50 		XmNmarginHeight, &marginHeight,
51 		XmNmarginLeft, &marginLeft,
52 		XmNmarginLeft, &marginRight,
53 		XmNmarginTop, &marginTop,
54 		XmNmarginWidth, &marginWidth,
55 		XmNhighlightThickness, &highlightThickness,
56 		XmNshadowThickness, &shadowThickness,
57 		XmNheight, &height,
58 		XmNwidth, &width,
59 		NULL);
60 	printf("%s: XmNshowAsDefault - %d\n", XtName(w), showAsDefault);
61 	printf("%s: XmNdefaultButtonShadowThickness - %d\n", XtName(w), defaultButtonShadowThickness);
62 	printf("%s: XmNmarginBottom - %d\n", XtName(w), marginBottom);
63 	printf("%s: XmNmarginHeight - %d\n", XtName(w), marginHeight);
64 	printf("%s: XmNmarginLeft - %d\n", XtName(w), marginLeft);
65 	printf("%s: XmNmarginRight - %d\n", XtName(w), marginRight);
66 	printf("%s: XmNmarginTop - %d\n", XtName(w), marginTop);
67 	printf("%s: XmNmarginWidth - %d\n", XtName(w), marginWidth);
68 	printf("%s: XmNhightlightThickness - %d\n", XtName(w), highlightThickness);
69 	printf("%s: XmNshadowThickness - %d\n", XtName(w), shadowThickness);
70 	printf("%s: XmNborderWidth - %d\n", XtName(w), borderWidth);
71 	printf("%s: XmNheight - %d\n", XtName(w), height);
72 	printf("%s: XmNwidth - %d\n", XtName(w), width);
73 	printf("%s: XmNheight - %d\n", XtName(XtParent(w)), pheight);
74 	printf("%s: XmNwidth - %d\n", XtName(XtParent(w)), pwidth);
75 	printf("\n");
76 }
77 
78 static void
dothings(Widget w,XtPointer closure,XtPointer call)79 dothings(Widget w, XtPointer closure, XtPointer call)
80 {
81 static	String    s = NULL;
82 	XmString  x;
83 	Dimension shadow;
84 
85 	XtVaGetValues(w, XmNshowAsDefault, &shadow, NULL);
86 	shadow = (shadow > 0) ? 0 : 1;
87 
88 	if(s == NULL) {
89 		s = XtNewString("haha");
90 	}
91 	else {
92 		s = XtRealloc(s, strlen(s) + 4 + 1);
93 		strcat(s, "haha");
94 	}
95 
96 	x = XmStringCreateLocalized(s);
97 	XtVaSetValues(w,
98 		XmNshowAsDefault, shadow,
99 		XmNlabelString,   x,
100 		NULL);
101 	XmStringFree(x);
102 	DumpResources(w);
103 }
104 
105 
106 int
main(int argc,char ** argv)107 main(int argc, char **argv)
108 {
109 	Widget top, one,two;
110 	XtAppContext app;
111 
112 	XtSetLanguageProc(NULL, NULL, NULL);
113 
114 	top = XtVaAppInitialize(&app, "HaHa", NULL, 0, &argc, argv, NULL,
115 			XmNallowShellResize, True,
116 			NULL);
117 
118 	two = XtVaCreateManagedWidget("Two", xmBulletinBoardWidgetClass,
119 			top, NULL);
120 	one = XtVaCreateManagedWidget("OnePushButton", xmPushButtonWidgetClass,
121 			two, NULL);
122 
123 	XtAddCallback(one, XmNactivateCallback, dothings, NULL);
124 
125 	XtRealizeWidget(top);
126 	DumpResources(one);
127   {
128   static XtWidgetGeometry Expected[] = {
129   	CWWidth | CWHeight,		0,	0,	111,	46,	0,0,0,	/* Form */
130   	CWWidth | CWHeight | CWX | CWY,	10,	10,	90,	25,	0,0,0,	/* two */
131 };
132 
133   PrintDetails(top, Expected);
134   }
135   LessTifTestMainLoop(top);
136   /*
137 	XtAppMainLoop(app);
138 	*/
139 
140 	exit(0);
141 }
142