2 * WINGs test application
12 * You need to define this function to link any program to WINGs.
13 * This will be called when the application will be terminated because
30 closeAction(WMWidget
*self
, void *data
)
32 WMDestroyWidget(self
);
40 testOpenFilePanel(WMScreen
*scr
)
46 /* get the shared Open File panel */
47 panel
= WMGetOpenPanel(scr
);
49 WMRunModalOpenPanelForDirectory(panel
, NULL
, "/usr/local", NULL
, NULL
);
51 /* free the panel to save some memory. Not needed otherwise. */
52 WMFreeFilePanel(panel
);
57 testFontPanel(WMScreen
*scr
)
63 panel
= WMGetFontPanel(scr
);
65 WMShowFontPanel(panel
);
67 /* WMFreeFontPanel(panel);*/
73 testList(WMScreen
*scr
)
82 win
= WMCreateWindow(scr
, "testList");
83 WMSetWindowTitle(win
, "List");
84 WMSetWindowCloseAction(win
, closeAction
, NULL
);
86 list
= WMCreateList(win
);
87 for (i
=0; i
<50; i
++) {
88 sprintf(text
, "Item %i", i
);
89 WMAddListItem(list
, text
);
100 testGradientButtons(WMScreen
*scr
)
104 WMPixmap
*pix1
, *pix2
;
111 /* creates the top-level window */
112 win
= WMCreateWindow(scr
, "testGradientButtons");
113 WMSetWindowTitle(win
, "Gradiented Button Demo");
114 WMResizeWidget(win
, 300, 200);
123 color
= WMCreateRGBColor(scr
, 0x5900, 0x5100, 0x5900, True
);
124 WMSetWidgetBackgroundColor(win
, color
);
125 WMReleaseColor(color
);
127 back
= RRenderGradient(60, 24, &dark
, &light
, RGRD_DIAGONAL
);
128 RBevelImage(back
, RBEV_RAISED2
);
129 pix1
= WMCreatePixmapFromRImage(scr
, back
, 0);
132 back
= RRenderGradient(60, 24, &dark
, &light
, RGRD_DIAGONAL
);
133 RBevelImage(back
, RBEV_SUNKEN
);
134 pix2
= WMCreatePixmapFromRImage(scr
, back
, 0);
137 btn
= WMCreateButton(win
, WBTMomentaryChange
);
138 WMResizeWidget(btn
, 60, 24);
139 WMMoveWidget(btn
, 20, 100);
140 WMSetButtonBordered(btn
, False
);
141 WMSetButtonImagePosition(btn
, WIPOverlaps
);
142 WMSetButtonImage(btn
, pix1
);
143 WMSetButtonAltImage(btn
, pix2
);
144 WMSetButtonText(btn
, "Cool");
146 btn
= WMCreateButton(win
, WBTMomentaryChange
);
147 WMResizeWidget(btn
, 60, 24);
148 WMMoveWidget(btn
, 90, 100);
149 WMSetButtonBordered(btn
, False
);
150 WMSetButtonImagePosition(btn
, WIPOverlaps
);
151 WMSetButtonImage(btn
, pix1
);
152 WMSetButtonAltImage(btn
, pix2
);
153 WMSetButtonText(btn
, "Button");
155 btn
= WMCreateButton(win
, WBTMomentaryChange
);
156 WMResizeWidget(btn
, 60, 24);
157 WMMoveWidget(btn
, 160, 100);
158 WMSetButtonBordered(btn
, False
);
159 WMSetButtonImagePosition(btn
, WIPOverlaps
);
160 WMSetButtonImage(btn
, pix1
);
161 WMSetButtonAltImage(btn
, pix2
);
162 WMSetButtonText(btn
, "Test");
164 WMRealizeWidget(win
);
165 WMMapSubwidgets(win
);
171 testScrollView(WMScreen
*scr
)
182 /* creates the top-level window */
183 win
= WMCreateWindow(scr
, "testScroll");
184 WMSetWindowTitle(win
, "Scrollable View");
186 WMSetWindowCloseAction(win
, closeAction
, NULL
);
188 /* set the window size */
189 WMResizeWidget(win
, 300, 300);
191 /* creates a scrollable view inside the top-level window */
192 sview
= WMCreateScrollView(win
);
193 WMResizeWidget(sview
, 200, 200);
194 WMMoveWidget(sview
, 30, 30);
195 WMSetScrollViewRelief(sview
, WRSunken
);
196 WMSetScrollViewHasVerticalScroller(sview
, True
);
197 WMSetScrollViewHasHorizontalScroller(sview
, True
);
199 /* create a frame with a bunch of labels */
200 f
= WMCreateFrame(win
);
201 WMResizeWidget(f
, 400, 400);
202 WMSetFrameRelief(f
, WRFlat
);
204 for (i
=0; i
<20; i
++) {
205 l
= WMCreateLabel(f
);
206 WMResizeWidget(l
, 50, 18);
207 WMMoveWidget(l
, 10, 20*i
);
208 sprintf(buffer
, "Label %i", i
);
209 WMSetLabelText(l
, buffer
);
210 WMSetLabelRelief(l
, WRSimple
);
215 WMSetScrollViewContentView(sview
, WMWidgetView(f
));
217 /* make the windows of the widgets be actually created */
218 WMRealizeWidget(win
);
220 /* Map all child widgets of the top-level be mapped.
221 * You must call this for each container widget (like frames),
222 * even if they are childs of the top-level window.
224 WMMapSubwidgets(win
);
226 /* map the top-level window */
232 testColorWell(WMScreen
*scr
)
235 WMColorWell
*well1
, *well2
;
239 win
= WMCreateWindow(scr
, "testColor");
240 WMResizeWidget(win
, 300, 300);
242 WMSetWindowCloseAction(win
, closeAction
, NULL
);
244 well1
= WMCreateColorWell(win
);
245 WMResizeWidget(well1
, 60, 40);
246 WMMoveWidget(well1
, 100, 100);
247 WMSetColorWellColor(well1
, WMCreateRGBColor(scr
, 0x8888, 0, 0x1111, True
));
248 well2
= WMCreateColorWell(win
);
249 WMResizeWidget(well2
, 60, 40);
250 WMMoveWidget(well2
, 200, 100);
251 WMSetColorWellColor(well2
, WMCreateRGBColor(scr
, 0, 0, 0x8888, True
));
253 WMRealizeWidget(win
);
254 WMMapSubwidgets(win
);
260 testSlider(WMScreen
*scr
)
267 win
= WMCreateWindow(scr
, "testSlider");
268 WMResizeWidget(win
, 300, 300);
269 WMSetWindowTitle(win
, "Sliders");
271 WMSetWindowCloseAction(win
, closeAction
, NULL
);
273 s
= WMCreateSlider(win
);
274 WMResizeWidget(s
, 16, 100);
275 WMMoveWidget(s
, 100, 100);
277 s
= WMCreateSlider(win
);
278 WMResizeWidget(s
, 100, 16);
279 WMMoveWidget(s
, 100, 10);
281 WMRealizeWidget(win
);
282 WMMapSubwidgets(win
);
288 testText(WMScreen
*scr
)
295 win
= WMCreateWindow(scr
, "testText");
296 WMResizeWidget(win
, 300, 300);
297 WMSetWindowTitle(win
, "Text");
299 WMSetWindowCloseAction(win
, closeAction
, NULL
);
301 text
= WMCreateSimpleText(win
);
302 WMResizeWidget(text
, 280, 280);
303 WMMoveWidget(text
, 10, 10);
305 WMRealizeWidget(win
);
306 WMMapSubwidgets(win
);
312 testTextField(WMScreen
*scr
)
315 WMTextField
*field
, *field2
;
319 win
= WMCreateWindow(scr
, "testText");
320 WMResizeWidget(win
, 400, 300);
322 WMSetWindowCloseAction(win
, closeAction
, NULL
);
324 field
= WMCreateTextField(win
);
325 WMResizeWidget(field
, 200, 20);
326 WMMoveWidget(field
, 20, 20);
328 field2
= WMCreateTextField(win
);
329 WMResizeWidget(field2
, 200, 20);
330 WMMoveWidget(field2
, 20, 50);
331 WMSetTextFieldAlignment(field2
, WARight
);
333 WMRealizeWidget(win
);
334 WMMapSubwidgets(win
);
341 testPullDown(WMScreen
*scr
)
344 WMPopUpButton
*pop
, *pop2
;
348 win
= WMCreateWindow(scr
, "pullDown");
349 WMResizeWidget(win
, 400, 300);
351 WMSetWindowCloseAction(win
, closeAction
, NULL
);
353 pop
= WMCreatePopUpButton(win
);
354 WMResizeWidget(pop
, 100, 20);
355 WMMoveWidget(pop
, 50, 60);
356 WMSetPopUpButtonPullsDown(pop
, True
);
357 WMSetPopUpButtonText(pop
, "Commands");
358 WMAddPopUpButtonItem(pop
, "Add");
359 WMAddPopUpButtonItem(pop
, "Remove");
360 WMAddPopUpButtonItem(pop
, "Check");
361 WMAddPopUpButtonItem(pop
, "Eat");
363 pop2
= WMCreatePopUpButton(win
);
364 WMResizeWidget(pop2
, 100, 20);
365 WMMoveWidget(pop2
, 200, 60);
366 WMSetPopUpButtonText(pop2
, "Select");
367 WMAddPopUpButtonItem(pop2
, "Apples");
368 WMAddPopUpButtonItem(pop2
, "Bananas");
369 WMAddPopUpButtonItem(pop2
, "Strawberries");
370 WMAddPopUpButtonItem(pop2
, "Blueberries");
372 WMRealizeWidget(win
);
373 WMMapSubwidgets(win
);
382 int main(int argc
, char **argv
)
387 /* Initialize the application */
388 WMInitializeApplication("Test", &argc
, argv
);
391 * Open connection to the X display.
393 dpy
= XOpenDisplay("");
396 puts("could not open display");
400 /* This is used to disable buffering of X protocol requests.
401 * Do NOT use it unless when debugging. It will cause a major
402 * slowdown in your application
405 XSynchronize(dpy
, True
);
408 * Create screen descriptor.
410 scr
= WMCreateScreen(dpy
, DefaultScreen(dpy
));
413 * Loads the logo of the application.
415 pixmap
= WMCreatePixmapFromFile(scr
, "logo.xpm");
418 * Makes the logo be used in standard dialog panels.
420 WMSetApplicationIconImage(scr
, pixmap
); WMReleasePixmap(pixmap
);
423 * Do some test stuff.
425 * Put the testSomething() function you want to test here.
428 testOpenFilePanel(scr
);
431 testGradientButtons(scr
);
439 * The main event loop.
442 WMScreenMainLoop(scr
);