1 /* $Id: test13.c,v 1.8 2001/05/15 14:08:33 amai Exp $ */
2 /*
3 From: "Dr. Peer Griebel" <griebel@rocketmail.com>
4 - shows a sizing problem when the top window is resized
5 - the CascadeButton in the pulldown menu shows it's graphic even though it
6 does not have a sub-menu
7 */
8 /*
9 ** BuildMain.c ( Motifation generated )
10 **
11 ** Motifation@allow-overwrite@
12 ** If you want to protect this file to be overwritten by Motifation
13 ** modify the line above.
14 **
15 */
16 #include <stdlib.h>
17 #include <stdio.h>
18
19 #include <Xm/XmP.h>
20 #include <X11/Shell.h>
21 #include <Xm/BulletinB.h>
22 #include <Xm/CascadeB.h>
23 #include <Xm/PushB.h>
24 #include <Xm/Text.h>
25 #include <Xm/Label.h>
26 #include <Xm/Separator.h>
27 #include <Xm/MainW.h>
28 #include <Xm/RowColumn.h>
29
30 #include "../../common/Test.h"
31
32
33 static Widget appshell = NULL;
34 static Widget pgHelpMainWindow = NULL;
35 static Widget HelpBoard = NULL;
36 static Widget mainbull = NULL;
37
38 static Widget menuFile = NULL;
39 static Widget menuOpen = NULL;
40 static Widget tInfo = NULL;
41
42 static Display *display;
43 static XtAppContext application_context;
44 static int quad_width;
45
Resize(void)46 void Resize(void)
47
48 {
49 Arg args[10];
50 Cardinal argcount;
51 Widget Label;
52
53 if( HelpBoard ) {
54 XtDestroyWidget( HelpBoard );
55 XmUpdateDisplay( mainbull );
56 printf( "Resize! Helpboard destroyed!\n" );
57 }
58
59 argcount = 0;
60 XtSetArg( args[argcount], XmNresizePolicy, XmRESIZE_ANY ); argcount++;
61 XtSetArg( args[argcount], XmNunitType, XmPIXELS ); argcount++;
62
63 HelpBoard = XmCreateBulletinBoard( mainbull, "Board2", args, argcount );
64 XtRealizeWidget( HelpBoard );
65 XtManageChild( HelpBoard );
66
67 printf( "Resize! XtWidth: %d\n", XtWidth( pgHelpMainWindow ) );
68
69 argcount = 0;
70 XtSetArg( args[argcount], XmNx, XtWidth( pgHelpMainWindow ) -50 ); argcount++;
71 XtSetArg( args[argcount], XmNy, 50 ); argcount++;
72 Label = XmCreateLabel( mainbull, "xxx", args, argcount );
73 XtManageChild( Label );
74 }
75
76
77 /**********************************************************************
78 **
79 **
80 */
BuildMainApplication(display)81 void BuildMainApplication( display )
82 Display *display;
83 {
84 Arg args[10];
85 Cardinal argcount;
86
87 Widget menubar = NULL;
88 Widget pulldown = NULL;
89
90 argcount = 0;
91 XtSetArg( args[argcount], XmNallowShellResize, True ); argcount++;
92 XtSetArg( args[argcount], XmNtitle, "XpgHelp" ); argcount++;
93 XtSetArg( args[argcount], XmNiconName, "XpgHelp" ); argcount++;
94 appshell = XtAppCreateShell( NULL, "xpghelp", applicationShellWidgetClass,
95 display, args, argcount );
96
97 /*
98 ** Codegeneration for the Widget pgHelpMainWindow
99 */
100 argcount = 0;
101 XtSetArg( args[argcount], XmNscrollingPolicy, XmAUTOMATIC ); argcount++;
102 XtSetArg( args[argcount], XmNscrollBarDisplayPolicy, XmSTATIC ); argcount++;
103 XtSetArg( args[argcount], XmNvisualPolicy, XmVARIABLE ); argcount++;
104 XtSetArg( args[argcount], XmNspacing, (short) 1 ); argcount++;
105 pgHelpMainWindow = XmCreateMainWindow( appshell, "pgHelpMainWindow", args,
106 argcount );
107 XtAddEventHandler( pgHelpMainWindow, StructureNotifyMask, False,
108 (XtEventHandler)Resize, (XtPointer) NULL ); /* help.c */
109 XtManageChild( pgHelpMainWindow );
110
111 /*
112 ** Codegeneration for the Widget menubar
113 */
114 argcount = 0;
115 menubar = XmCreateMenuBar( pgHelpMainWindow, "menubar", args, argcount );
116 XtManageChild( menubar );
117
118 /*
119 ** Codegeneration for the Widget pulldown
120 */
121 argcount = 0;
122 pulldown = XmCreatePulldownMenu( menubar, "pulldown", args, argcount );
123
124
125 /*
126 ** Codegeneration for the Widget menuOpen
127 */
128 argcount = 0;
129 menuOpen = XmCreateCascadeButton( pulldown, "menuOpen", args, argcount );
130 XtManageChild( menuOpen );
131
132 /*
133 ** Codegeneration for the Widget menuFile
134 */
135 argcount = 0;
136 XtSetArg( args[argcount], XmNsubMenuId, pulldown ); argcount++;
137 menuFile = XmCreateCascadeButton( menubar, "menuFile", args, argcount );
138 XtManageChild( menuFile );
139
140 /*
141 ** Codegeneration for the Widget mainbull
142 */
143 argcount = 0;
144 XtSetArg( args[argcount], XmNmarginHeight, (short) 6 ); argcount++;
145 XtSetArg( args[argcount], XmNmarginWidth, (short) 6 ); argcount++;
146 XtSetArg( args[argcount], XmNheight, 60 ); argcount++;
147 XtSetArg( args[argcount], XmNwidth, 60 ); argcount++;
148 mainbull = XmCreateBulletinBoard( pgHelpMainWindow, "canvas", args, argcount );
149 XtManageChild( mainbull );
150
151 /*
152 ** Codegeneration for the Widget tInfo
153 */
154 argcount = 0;
155 tInfo = XmCreateText( pgHelpMainWindow, "tInfo", args, argcount );
156 XtManageChild( tInfo );
157
158 argcount = 0;
159 XtSetArg( args[argcount], XmNmessageWindow, tInfo ); argcount++;
160 XtSetArg( args[argcount], XmNworkWindow, mainbull ); argcount++;
161 XtSetValues( pgHelpMainWindow, args, argcount );
162
163 XmMainWindowSetAreas( pgHelpMainWindow, menubar, NULL, NULL, NULL, mainbull );
164
165 XtRealizeWidget( appshell );
166
167 XmUpdateDisplay( appshell );
168 }
169
170
171 /**********************************************************************
172 **
173 **
174 */
main(argc,argv)175 int main( argc, argv )
176 int argc;
177 char *argv[];
178 {
179 XrmDatabase database;
180 XFontStruct *font_struct;
181 XrmValue value;
182 char *dummy;
183
184 /*
185 ** initialize Toolkit and set some global variable
186 */
187 XtToolkitInitialize();
188
189 application_context = XtCreateApplicationContext();
190
191 if( ( display = XtOpenDisplay( application_context, NULL, NULL, "Xpghelp", NULL, 0, &argc, argv)) == NULL ) {
192 fprintf( stderr,"\n%s: Can't open display\n", argv[0] );
193 exit( 1 );
194 }
195
196 /*
197 ** Get the QUAD_WIDTH
198 */
199 database = XtDatabase( display );
200 if( XrmGetResource( database, XmNfontList, XmCFontList, &dummy, &value )
201 && (font_struct = XLoadQueryFont( display, value.addr )) ) {
202 quad_width = font_struct->ascent+font_struct->descent;
203 XFreeFont( display, font_struct );
204 } else {
205 if( XrmGetResource( database, XmNfont, XmCFont, &dummy, &value )
206 && (font_struct = XLoadQueryFont( display, value.addr )) ) {
207 quad_width = font_struct->ascent+font_struct->descent;
208 XFreeFont( display, font_struct );
209 } else {
210 if( ( font_struct = XLoadQueryFont( display, "Fixed" ) ) ) {
211 quad_width = font_struct->ascent+font_struct->descent;
212 XFreeFont( display, font_struct );
213 } else {
214 quad_width = 10;
215 }
216 }
217 }
218 XmSetFontUnit( display, quad_width );
219
220 BuildMainApplication( display );
221
222
223 /* Note: the following values are the result of
224 * querying the current geometry.
225 */
226 {
227 static XtWidgetGeometry Expected[] = {
228 CWWidth | CWHeight , 185, 315, 138, 190, 0,0,0, /* pgHelpMainWindow */
229 CWWidth | CWHeight | CWX | CWY, 4, 35, 110, 100, 0,0,0, /* ClipWindow */
230 CWWidth | CWHeight | CWX | CWY, 0, 0, 116, 73, 0,0,0, /* canvas */
231 CWWidth | CWHeight | CWX | CWY, 6, 6, 1, 1, 0,0,0, /* Board2 */
232 CWWidth | CWHeight | CWX | CWY, 88, 50, 22, 17, 0,0,0, /* xxx */
233 CWWidth | CWHeight | CWX | CWY, 0, 159, 138, 31, 0,0,0, /* tInfo */
234 CWWidth | CWHeight | CWX | CWY, 119, 31, 19, 108, 0,0,0, /* VertScrollBar */
235 CWWidth | CWHeight | CWX | CWY, 0, 140, 118, 19, 0,0,0, /* HorScrollBar */
236 CWWidth | CWHeight | CWX | CWY, 0, 0, 138, 31, 0,0,0, /* menubar */
237 CWWidth | CWHeight | CWX | CWY, 5, 5, 64, 21, 0,0,0, /* menuFile */
238 };
239 /* toplevel should be replaced with to correct applicationShell */
240 PrintDetails(appshell, Expected);
241 }
242 LessTifTestMainLoop(appshell);
243 return( 0 );
244 }
245