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 WMRunModalFilePanelForDirectory(panel
, NULL
, "/usr/local", NULL
, NULL
);
51 /* free the panel to save some memory. Not needed otherwise. */
52 WMFreeFilePanel(WMGetOpenPanel(scr
));
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
);
259 sliderCallback(WMWidget
*w
, void *data
)
261 printf("SLIEDER == %i\n", WMGetSliderValue(w
));
266 testSlider(WMScreen
*scr
)
273 win
= WMCreateWindow(scr
, "testSlider");
274 WMResizeWidget(win
, 300, 300);
275 WMSetWindowTitle(win
, "Sliders");
277 WMSetWindowCloseAction(win
, closeAction
, NULL
);
279 s
= WMCreateSlider(win
);
280 WMResizeWidget(s
, 16, 100);
281 WMMoveWidget(s
, 100, 100);
282 WMSetSliderKnobThickness(s
, 8);
283 WMSetSliderContinuous(s
, False
);
284 WMSetSliderAction(s
, sliderCallback
, s
);
286 s
= WMCreateSlider(win
);
287 WMResizeWidget(s
, 100, 16);
288 WMMoveWidget(s
, 100, 10);
289 WMSetSliderKnobThickness(s
, 8);
291 WMRealizeWidget(win
);
292 WMMapSubwidgets(win
);
297 testTextField(WMScreen
*scr
)
300 WMTextField
*field
, *field2
;
304 win
= WMCreateWindow(scr
, "testText");
305 WMResizeWidget(win
, 400, 300);
307 WMSetWindowCloseAction(win
, closeAction
, NULL
);
309 field
= WMCreateTextField(win
);
310 WMResizeWidget(field
, 200, 20);
311 WMMoveWidget(field
, 20, 20);
313 field2
= WMCreateTextField(win
);
314 WMResizeWidget(field2
, 200, 20);
315 WMMoveWidget(field2
, 20, 50);
316 WMSetTextFieldAlignment(field2
, WARight
);
318 WMRealizeWidget(win
);
319 WMMapSubwidgets(win
);
326 testPullDown(WMScreen
*scr
)
329 WMPopUpButton
*pop
, *pop2
;
333 win
= WMCreateWindow(scr
, "pullDown");
334 WMResizeWidget(win
, 400, 300);
336 WMSetWindowCloseAction(win
, closeAction
, NULL
);
338 pop
= WMCreatePopUpButton(win
);
339 WMResizeWidget(pop
, 100, 20);
340 WMMoveWidget(pop
, 50, 60);
341 WMSetPopUpButtonPullsDown(pop
, True
);
342 WMSetPopUpButtonText(pop
, "Commands");
343 WMAddPopUpButtonItem(pop
, "Add");
344 WMAddPopUpButtonItem(pop
, "Remove");
345 WMAddPopUpButtonItem(pop
, "Check");
346 WMAddPopUpButtonItem(pop
, "Eat");
348 pop2
= WMCreatePopUpButton(win
);
349 WMResizeWidget(pop2
, 100, 20);
350 WMMoveWidget(pop2
, 200, 60);
351 WMSetPopUpButtonText(pop2
, "Select");
352 WMAddPopUpButtonItem(pop2
, "Apples");
353 WMAddPopUpButtonItem(pop2
, "Bananas");
354 WMAddPopUpButtonItem(pop2
, "Strawberries");
355 WMAddPopUpButtonItem(pop2
, "Blueberries");
357 WMRealizeWidget(win
);
358 WMMapSubwidgets(win
);
367 int main(int argc
, char **argv
)
372 /* Initialize the application */
373 WMInitializeApplication("Test", &argc
, argv
);
376 * Open connection to the X display.
378 dpy
= XOpenDisplay("");
381 puts("could not open display");
385 /* This is used to disable buffering of X protocol requests.
386 * Do NOT use it unless when debugging. It will cause a major
387 * slowdown in your application
390 XSynchronize(dpy
, True
);
393 * Create screen descriptor.
395 scr
= WMCreateScreen(dpy
, DefaultScreen(dpy
));
398 * Loads the logo of the application.
400 pixmap
= WMCreatePixmapFromFile(scr
, "logo.xpm");
403 * Makes the logo be used in standard dialog panels.
405 WMSetApplicationIconImage(scr
, pixmap
); WMReleasePixmap(pixmap
);
408 * Do some test stuff.
410 * Put the testSomething() function you want to test here.
413 testOpenFilePanel(scr
);
416 testGradientButtons(scr
);
426 * The main event loop.
429 WMScreenMainLoop(scr
);