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
);
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);
276 WMSetSliderKnobThickness(s
, 8);
278 s
= WMCreateSlider(win
);
279 WMResizeWidget(s
, 100, 16);
280 WMMoveWidget(s
, 100, 10);
281 WMSetSliderKnobThickness(s
, 8);
283 WMRealizeWidget(win
);
284 WMMapSubwidgets(win
);
289 testTextField(WMScreen
*scr
)
292 WMTextField
*field
, *field2
;
296 win
= WMCreateWindow(scr
, "testText");
297 WMResizeWidget(win
, 400, 300);
299 WMSetWindowCloseAction(win
, closeAction
, NULL
);
301 field
= WMCreateTextField(win
);
302 WMResizeWidget(field
, 200, 20);
303 WMMoveWidget(field
, 20, 20);
305 field2
= WMCreateTextField(win
);
306 WMResizeWidget(field2
, 200, 20);
307 WMMoveWidget(field2
, 20, 50);
308 WMSetTextFieldAlignment(field2
, WARight
);
310 WMRealizeWidget(win
);
311 WMMapSubwidgets(win
);
318 testPullDown(WMScreen
*scr
)
321 WMPopUpButton
*pop
, *pop2
;
325 win
= WMCreateWindow(scr
, "pullDown");
326 WMResizeWidget(win
, 400, 300);
328 WMSetWindowCloseAction(win
, closeAction
, NULL
);
330 pop
= WMCreatePopUpButton(win
);
331 WMResizeWidget(pop
, 100, 20);
332 WMMoveWidget(pop
, 50, 60);
333 WMSetPopUpButtonPullsDown(pop
, True
);
334 WMSetPopUpButtonText(pop
, "Commands");
335 WMAddPopUpButtonItem(pop
, "Add");
336 WMAddPopUpButtonItem(pop
, "Remove");
337 WMAddPopUpButtonItem(pop
, "Check");
338 WMAddPopUpButtonItem(pop
, "Eat");
340 pop2
= WMCreatePopUpButton(win
);
341 WMResizeWidget(pop2
, 100, 20);
342 WMMoveWidget(pop2
, 200, 60);
343 WMSetPopUpButtonText(pop2
, "Select");
344 WMAddPopUpButtonItem(pop2
, "Apples");
345 WMAddPopUpButtonItem(pop2
, "Bananas");
346 WMAddPopUpButtonItem(pop2
, "Strawberries");
347 WMAddPopUpButtonItem(pop2
, "Blueberries");
349 WMRealizeWidget(win
);
350 WMMapSubwidgets(win
);
359 int main(int argc
, char **argv
)
364 /* Initialize the application */
365 WMInitializeApplication("Test", &argc
, argv
);
368 * Open connection to the X display.
370 dpy
= XOpenDisplay("");
373 puts("could not open display");
377 /* This is used to disable buffering of X protocol requests.
378 * Do NOT use it unless when debugging. It will cause a major
379 * slowdown in your application
382 XSynchronize(dpy
, True
);
385 * Create screen descriptor.
387 scr
= WMCreateScreen(dpy
, DefaultScreen(dpy
));
390 * Loads the logo of the application.
392 pixmap
= WMCreatePixmapFromFile(scr
, "logo.xpm");
395 * Makes the logo be used in standard dialog panels.
397 WMSetApplicationIconImage(scr
, pixmap
); WMReleasePixmap(pixmap
);
400 * Do some test stuff.
402 * Put the testSomething() function you want to test here.
405 testOpenFilePanel(scr
);
408 testGradientButtons(scr
);
418 * The main event loop.
421 WMScreenMainLoop(scr
);