2 * WINGs test application
5 #include <WINGs/WINGs.h>
12 * You need to define this function to link any program to WINGs.
13 * (this is no longer required as there is a default abort handler in WINGs)
14 * This will be called when the application will be terminated because
15 * of a fatal error (only for memory allocation failures ATM).
17 _Noreturn
void wAbort(void)
26 void closeAction(WMWidget
* self
, void *data
)
29 WMDestroyWidget(self
);
31 printf("window closed, window count = %d\n", windowCount
);
36 void testOpenFilePanel(WMScreen
* scr
)
42 /* get the shared Open File panel */
43 panel
= WMGetOpenPanel(scr
);
45 WMRunModalFilePanelForDirectory(panel
, NULL
, "/usr/local", NULL
, NULL
);
47 /* free the panel to save some memory. Not needed otherwise. */
48 WMFreeFilePanel(WMGetOpenPanel(scr
));
51 void testFontPanel(WMScreen
* scr
)
57 panel
= WMGetFontPanel(scr
);
59 WMShowFontPanel(panel
);
61 /*WMFreeFontPanel(panel); */
64 void testFrame(WMScreen
* scr
)
69 static char *titles
[] = {
77 static WMTitlePosition pos
[] = {
88 win
= WMCreateWindow(scr
, "testFrame");
89 WMSetWindowTitle(win
, "Frame");
90 WMSetWindowCloseAction(win
, closeAction
, NULL
);
91 WMResizeWidget(win
, 400, 300);
93 for (i
= 0; i
< 6; i
++) {
94 frame
= WMCreateFrame(win
);
95 WMMoveWidget(frame
, 8 + (i
% 3) * 130, 8 + (i
/ 3) * 130);
96 WMResizeWidget(frame
, 120, 120);
97 WMSetFrameTitle(frame
, titles
[i
]);
98 WMSetFrameTitlePosition(frame
, pos
[i
]);
101 WMRealizeWidget(win
);
102 WMMapSubwidgets(win
);
108 resizedWindow(void *self, WMNotification *notif)
110 WMView *view = (WMView*)WMGetNotificationObject(notif);
111 WMSize size = WMGetViewSize(view);
113 WMResizeWidget((WMWidget*)self, size.width, size.height);
116 void testBox(WMScreen
* scr
)
126 win
= WMCreateWindow(scr
, "testBox");
127 WMSetWindowTitle(win
, "Box");
128 WMSetWindowCloseAction(win
, closeAction
, NULL
);
129 WMResizeWidget(win
, 400, 300);
131 box
= WMCreateBox(win
);
132 WMSetBoxBorderWidth(box
, 5);
133 WMSetViewExpandsToParent(WMWidgetView(box
), 0, 0, 0, 0);
135 /*WMSetBoxHorizontal(box, True); */
136 for (i
= 0; i
< 4; i
++) {
137 btn
= WMCreateCommandButton(box
);
138 WMSetButtonText(btn
, "bla");
140 WMAddBoxSubview(box
, WMWidgetView(btn
), i
& 1, True
, 20, 0, 5);
143 pop
= WMCreatePopUpButton(box
);
144 WMAddPopUpButtonItem(pop
, "ewqeq");
145 WMAddPopUpButtonItem(pop
, "ewqeqrewrw");
146 WMAddBoxSubview(box
, WMWidgetView(pop
), False
, True
, 20, 0, 5);
149 hbox
= WMCreateBox(box
);
150 WMSetBoxHorizontal(hbox
, True
);
151 WMAddBoxSubview(box
, WMWidgetView(hbox
), False
, True
, 24, 0, 0);
154 for (i
= 0; i
< 4; i
++) {
155 btn
= WMCreateCommandButton(hbox
);
156 WMSetButtonText(btn
, "bla");
158 WMAddBoxSubview(hbox
, WMWidgetView(btn
), 1, True
, 60, 0, i
< 3 ? 5 : 0);
161 WMRealizeWidget(win
);
162 WMMapSubwidgets(win
);
167 static void singleClick(WMWidget
* self
, void *data
)
173 static void doubleClick(WMWidget
* self
, void *data
)
176 WMSelectAllListItems((WMList
*) self
);
179 static void listSelectionObserver(void *observer
, WMNotification
* notification
)
181 WMLabel
*label
= (WMLabel
*) observer
;
182 WMList
*lPtr
= (WMList
*) WMGetNotificationObject(notification
);
185 sprintf(buf
, "Selected items: %d", WMGetArrayItemCount(WMGetListSelectedItems(lPtr
)));
186 WMSetLabelText(label
, buf
);
189 void testList(WMScreen
* scr
)
203 win
= WMCreateWindow(scr
, "testList");
204 WMResizeWidget(win
, 370, 250);
205 WMSetWindowTitle(win
, "List");
206 WMSetWindowCloseAction(win
, closeAction
, NULL
);
208 title
= WMCreateLabel(win
);
209 WMResizeWidget(title
, 150, 20);
210 WMMoveWidget(title
, 10, 10);
211 WMSetLabelRelief(title
, WRRidge
);
212 WMSetLabelText(title
, "Single selection list");
214 mtitle
= WMCreateLabel(win
);
215 WMResizeWidget(mtitle
, 150, 20);
216 WMMoveWidget(mtitle
, 210, 10);
217 WMSetLabelRelief(mtitle
, WRRidge
);
218 WMSetLabelText(mtitle
, "Multiple selection list");
220 list
= WMCreateList(win
);
221 /*WMSetListAllowEmptySelection(list, True); */
222 WMMoveWidget(list
, 10, 40);
223 for (i
= 0; i
< 105; i
++) {
224 sprintf(text
, "Item %i", i
);
225 WMAddListItem(list
, text
);
227 mlist
= WMCreateList(win
);
228 WMSetListAllowMultipleSelection(mlist
, True
);
229 /*WMSetListAllowEmptySelection(mlist, True); */
230 WMMoveWidget(mlist
, 210, 40);
231 for (i
= 0; i
< 135; i
++) {
232 sprintf(text
, "Item %i", i
);
233 WMAddListItem(mlist
, text
);
236 label
= WMCreateLabel(win
);
237 WMResizeWidget(label
, 150, 40);
238 WMMoveWidget(label
, 10, 200);
239 WMSetLabelRelief(label
, WRRidge
);
240 WMSetLabelText(label
, "Selected items: 0");
242 mlabel
= WMCreateLabel(win
);
243 WMResizeWidget(mlabel
, 150, 40);
244 WMMoveWidget(mlabel
, 210, 200);
245 WMSetLabelRelief(mlabel
, WRRidge
);
246 WMSetLabelText(mlabel
, "Selected items: 0");
248 WMSetListAction(list
, singleClick
, label
);
249 WMSetListDoubleAction(list
, doubleClick
, label
);
250 WMSetListAction(mlist
, singleClick
, mlabel
);
251 WMSetListDoubleAction(mlist
, doubleClick
, mlabel
);
253 WMAddNotificationObserver(listSelectionObserver
, label
, WMListSelectionDidChangeNotification
, list
);
254 WMAddNotificationObserver(listSelectionObserver
, mlabel
, WMListSelectionDidChangeNotification
, mlist
);
256 WMRealizeWidget(win
);
257 WMMapSubwidgets(win
);
261 void testButton(WMScreen
* scr
)
278 win
= WMCreateWindow(scr
, "testButton");
279 WMResizeWidget(win
, 300, 300);
280 WMSetWindowTitle(win
, "Buttons");
282 WMSetWindowCloseAction(win
, closeAction
, NULL
);
284 for (i
= 1; i
< 9; i
++) {
286 b
= WMCreateButton(win
, i
);
287 WMResizeWidget(b
, 150, 24);
288 WMMoveWidget(b
, 20, i
* 30);
289 WMSetButtonText(b
, types
[i
- 1]);
292 WMRealizeWidget(win
);
293 WMMapSubwidgets(win
);
297 void testGradientButtons(WMScreen
* scr
)
301 WMPixmap
*pix1
, *pix2
;
304 WMColor
*color
, *altColor
;
308 /* creates the top-level window */
309 win
= WMCreateWindow(scr
, "testGradientButtons");
310 WMSetWindowTitle(win
, "Gradiented Button Demo");
311 WMResizeWidget(win
, 300, 200);
313 WMSetWindowCloseAction(win
, closeAction
, NULL
);
322 color
= WMCreateRGBColor(scr
, 0x5900, 0x5100, 0x5900, True
);
323 WMSetWidgetBackgroundColor(win
, color
);
324 WMReleaseColor(color
);
326 back
= RRenderGradient(60, 24, &dark
, &light
, RGRD_DIAGONAL
);
327 RBevelImage(back
, RBEV_RAISED2
);
328 pix1
= WMCreatePixmapFromRImage(scr
, back
, 0);
331 back
= RRenderGradient(60, 24, &dark
, &light
, RGRD_DIAGONAL
);
332 RBevelImage(back
, RBEV_SUNKEN
);
333 pix2
= WMCreatePixmapFromRImage(scr
, back
, 0);
336 color
= WMWhiteColor(scr
);
337 altColor
= WMCreateNamedColor(scr
, "red", True
);
339 btn
= WMCreateButton(win
, WBTMomentaryChange
);
340 WMResizeWidget(btn
, 60, 24);
341 WMMoveWidget(btn
, 20, 100);
342 WMSetButtonBordered(btn
, False
);
343 WMSetButtonImagePosition(btn
, WIPOverlaps
);
344 WMSetButtonImage(btn
, pix1
);
345 WMSetButtonAltImage(btn
, pix2
);
346 WMSetButtonText(btn
, "Cool");
347 WMSetButtonTextColor(btn
, color
);
348 WMSetButtonAltTextColor(btn
, altColor
);
350 WMSetBalloonTextForView("This is a cool button", WMWidgetView(btn
));
352 btn
= WMCreateButton(win
, WBTMomentaryChange
);
353 WMResizeWidget(btn
, 60, 24);
354 WMMoveWidget(btn
, 90, 100);
355 WMSetButtonBordered(btn
, False
);
356 WMSetButtonImagePosition(btn
, WIPOverlaps
);
357 WMSetButtonImage(btn
, pix1
);
358 WMSetButtonAltImage(btn
, pix2
);
359 WMSetButtonText(btn
, "Button");
360 WMSetButtonTextColor(btn
, color
);
362 WMSetBalloonTextForView("Este é outro balão.", WMWidgetView(btn
));
364 WMReleaseColor(color
);
365 color
= WMCreateNamedColor(scr
, "orange", True
);
367 btn
= WMCreateButton(win
, WBTMomentaryChange
);
368 WMResizeWidget(btn
, 60, 24);
369 WMMoveWidget(btn
, 160, 100);
370 WMSetButtonBordered(btn
, False
);
371 WMSetButtonImagePosition(btn
, WIPOverlaps
);
372 WMSetButtonImage(btn
, pix1
);
373 WMSetButtonAltImage(btn
, pix2
);
374 WMSetButtonText(btn
, "Test");
375 WMSetButtonTextColor(btn
, color
);
377 WMSetBalloonTextForView("This is yet another button.\nBut the balloon has 3 lines.\nYay!",
380 WMReleaseColor(color
);
381 WMReleaseColor(altColor
);
383 WMRealizeWidget(win
);
384 WMMapSubwidgets(win
);
388 void testScrollView(WMScreen
* scr
)
399 /* creates the top-level window */
400 win
= WMCreateWindow(scr
, "testScroll");
401 WMSetWindowTitle(win
, "Scrollable View");
403 WMSetWindowCloseAction(win
, closeAction
, NULL
);
405 /* set the window size */
406 WMResizeWidget(win
, 300, 300);
408 /* creates a scrollable view inside the top-level window */
409 sview
= WMCreateScrollView(win
);
410 WMResizeWidget(sview
, 200, 200);
411 WMMoveWidget(sview
, 30, 30);
412 WMSetScrollViewRelief(sview
, WRSunken
);
413 WMSetScrollViewHasVerticalScroller(sview
, True
);
414 WMSetScrollViewHasHorizontalScroller(sview
, True
);
416 /* create a frame with a bunch of labels */
417 f
= WMCreateFrame(win
);
418 WMResizeWidget(f
, 400, 400);
419 WMSetFrameRelief(f
, WRFlat
);
421 for (i
= 0; i
< 20; i
++) {
422 l
= WMCreateLabel(f
);
423 WMResizeWidget(l
, 50, 18);
424 WMMoveWidget(l
, 10, 20 * i
);
425 sprintf(buffer
, "Label %i", i
);
426 WMSetLabelText(l
, buffer
);
427 WMSetLabelRelief(l
, WRSimple
);
432 WMSetScrollViewContentView(sview
, WMWidgetView(f
));
434 /* make the windows of the widgets be actually created */
435 WMRealizeWidget(win
);
437 /* Map all child widgets of the top-level be mapped.
438 * You must call this for each container widget (like frames),
439 * even if they are childs of the top-level window.
441 WMMapSubwidgets(win
);
443 /* map the top-level window */
447 void testColorWell(WMScreen
* scr
)
450 WMColorWell
*well1
, *well2
;
454 win
= WMCreateWindow(scr
, "testColor");
455 WMResizeWidget(win
, 300, 300);
456 WMSetWindowCloseAction(win
, closeAction
, NULL
);
458 well1
= WMCreateColorWell(win
);
459 WMResizeWidget(well1
, 60, 40);
460 WMMoveWidget(well1
, 100, 100);
461 WMSetColorWellColor(well1
, WMCreateRGBColor(scr
, 0x8888, 0, 0x1111, True
));
462 well2
= WMCreateColorWell(win
);
463 WMResizeWidget(well2
, 60, 40);
464 WMMoveWidget(well2
, 200, 100);
465 WMSetColorWellColor(well2
, WMCreateRGBColor(scr
, 0, 0, 0x8888, True
));
467 WMRealizeWidget(win
);
468 WMMapSubwidgets(win
);
472 void testColorPanel(WMScreen
* scr
)
474 WMColorPanel
*panel
= WMGetColorPanel(scr
);
477 startcolor = WMCreateNamedColor(scr, colorname, False);
478 WMSetColorPanelColor(panel, startcolor);
479 WMReleaseColor(startcolor);
482 WMShowColorPanel(panel
);
485 void sliderCallback(WMWidget
* w
, void *data
)
488 printf("SLIDER == %i\n", WMGetSliderValue(w
));
491 void testSlider(WMScreen
* scr
)
498 win
= WMCreateWindow(scr
, "testSlider");
499 WMResizeWidget(win
, 300, 300);
500 WMSetWindowTitle(win
, "Sliders");
502 WMSetWindowCloseAction(win
, closeAction
, NULL
);
504 s
= WMCreateSlider(win
);
505 WMResizeWidget(s
, 16, 100);
506 WMMoveWidget(s
, 100, 100);
507 WMSetSliderKnobThickness(s
, 8);
508 WMSetSliderContinuous(s
, False
);
509 WMSetSliderAction(s
, sliderCallback
, s
);
511 s
= WMCreateSlider(win
);
512 WMResizeWidget(s
, 100, 16);
513 WMMoveWidget(s
, 100, 10);
514 WMSetSliderKnobThickness(s
, 8);
516 WMRealizeWidget(win
);
517 WMMapSubwidgets(win
);
521 void testTextField(WMScreen
* scr
)
524 WMTextField
*field
, *field2
;
528 win
= WMCreateWindow(scr
, "testTextField");
529 WMResizeWidget(win
, 400, 300);
531 WMSetWindowCloseAction(win
, closeAction
, NULL
);
533 field
= WMCreateTextField(win
);
534 WMResizeWidget(field
, 200, 20);
535 WMMoveWidget(field
, 20, 20);
536 WMSetTextFieldText(field
, "the little \xc2\xa9 sign");
538 field2
= WMCreateTextField(win
);
539 WMResizeWidget(field2
, 200, 20);
540 WMMoveWidget(field2
, 20, 50);
541 WMSetTextFieldAlignment(field2
, WARight
);
543 WMRealizeWidget(win
);
544 WMMapSubwidgets(win
);
549 void testText(WMScreen
* scr
)
555 FILE *file
= fopen("wm.html", "rb");
559 win
= WMCreateWindow(scr
, "testText");
560 WMResizeWidget(win
, 500, 300);
562 WMSetWindowCloseAction(win
, closeAction
, NULL
);
564 text
= WMCreateText(win
);
565 WMResizeWidget(text
, 480, 280);
566 WMMoveWidget(text
, 10, 10);
567 WMSetTextHasVerticalScroller(text
, True
);
568 WMSetTextEditable(text
, False
);
569 WMSetTextIgnoresNewline(text
, False
);
571 #define FNAME "Verdana,sans serif:pixelsize=12"
573 "Window Maker is the GNU window manager for the " \
574 "X Window System. It was designed to emulate the " \
575 "look and feel of part of the NEXTSTEP(tm) GUI. It's " \
576 "supposed to be relatively fast and small, feature " \
577 "rich, easy to configure and easy to use, with a simple " \
578 "and elegant appearance borrowed from NEXTSTEP(tm)."
580 font
= WMCreateFont(scr
, FNAME
":autohint=false");
581 WMSetTextDefaultFont(text
, font
);
588 while (fgets(buf
, 1023, file
))
589 WMAppendTextStream(text
, buf
);
594 WMAppendTextStream(text
, "First paragraph has autohinting turned off, "
595 "while the second has it turned on:");
596 WMAppendTextStream(text
, "\n\n\n");
597 WMAppendTextStream(text
, MSG
);
598 WMAppendTextStream(text
, "\n\n\n");
599 font
= WMCreateFont(scr
, FNAME
":autohint=true");
600 tb
= WMCreateTextBlockWithText(text
, MSG
, font
, WMBlackColor(scr
), 0, strlen(MSG
));
601 WMAppendTextBlock(text
, tb
);
605 WMRealizeWidget(win
);
606 WMMapSubwidgets(win
);
610 void testProgressIndicator(WMScreen
* scr
)
613 WMProgressIndicator
*pPtr
;
617 win
= WMCreateWindow(scr
, "testProgressIndicator");
618 WMResizeWidget(win
, 292, 32);
620 WMSetWindowCloseAction(win
, closeAction
, NULL
);
622 pPtr
= WMCreateProgressIndicator(win
);
623 WMMoveWidget(pPtr
, 8, 8);
624 WMSetProgressIndicatorValue(pPtr
, 75);
626 WMRealizeWidget(win
);
627 WMMapSubwidgets(win
);
632 void testPullDown(WMScreen
* scr
)
635 WMPopUpButton
*pop
, *pop2
;
639 win
= WMCreateWindow(scr
, "pullDown");
640 WMResizeWidget(win
, 400, 300);
642 WMSetWindowCloseAction(win
, closeAction
, NULL
);
644 pop
= WMCreatePopUpButton(win
);
645 WMResizeWidget(pop
, 100, 20);
646 WMMoveWidget(pop
, 50, 60);
647 WMSetPopUpButtonPullsDown(pop
, True
);
648 WMSetPopUpButtonText(pop
, "Commands");
649 WMAddPopUpButtonItem(pop
, "Add");
650 WMAddPopUpButtonItem(pop
, "Remove");
651 WMAddPopUpButtonItem(pop
, "Check");
652 WMAddPopUpButtonItem(pop
, "Eat");
654 pop2
= WMCreatePopUpButton(win
);
655 WMResizeWidget(pop2
, 100, 20);
656 WMMoveWidget(pop2
, 200, 60);
657 WMSetPopUpButtonText(pop2
, "Select");
658 WMAddPopUpButtonItem(pop2
, "Apples");
659 WMAddPopUpButtonItem(pop2
, "Bananas");
660 WMAddPopUpButtonItem(pop2
, "Strawberries");
661 WMAddPopUpButtonItem(pop2
, "Blueberries");
663 WMRealizeWidget(win
);
664 WMMapSubwidgets(win
);
669 void testTabView(WMScreen
* scr
)
679 win
= WMCreateWindow(scr
, "testTabs");
680 WMResizeWidget(win
, 400, 300);
682 WMSetWindowCloseAction(win
, closeAction
, NULL
);
684 tabv
= WMCreateTabView(win
);
685 WMMoveWidget(tabv
, 50, 50);
686 WMResizeWidget(tabv
, 300, 200);
688 frame
= WMCreateFrame(win
);
689 WMSetFrameRelief(frame
, WRFlat
);
690 label
= WMCreateLabel(frame
);
691 WMResizeWidget(label
, 100, 100);
692 WMSetLabelText(label
, "Label 1");
695 tab
= WMCreateTabViewItemWithIdentifier(0);
696 WMSetTabViewItemView(tab
, WMWidgetView(frame
));
697 WMAddItemInTabView(tabv
, tab
);
698 WMSetTabViewItemLabel(tab
, "Instances");
700 frame
= WMCreateFrame(win
);
701 WMSetFrameRelief(frame
, WRFlat
);
702 label
= WMCreateLabel(frame
);
703 WMResizeWidget(label
, 40, 50);
704 WMSetLabelText(label
, "Label 2");
707 tab
= WMCreateTabViewItemWithIdentifier(0);
708 WMSetTabViewItemView(tab
, WMWidgetView(frame
));
709 WMAddItemInTabView(tabv
, tab
);
710 WMSetTabViewItemLabel(tab
, "Classes");
712 frame
= WMCreateFrame(win
);
713 WMSetFrameRelief(frame
, WRFlat
);
714 label
= WMCreateLabel(frame
);
715 WMResizeWidget(label
, 100, 100);
716 WMMoveWidget(label
, 60, 40);
717 WMSetLabelText(label
, "Label 3");
720 tab
= WMCreateTabViewItemWithIdentifier(0);
721 WMSetTabViewItemView(tab
, WMWidgetView(frame
));
722 WMAddItemInTabView(tabv
, tab
);
723 WMSetTabViewItemLabel(tab
, "Something");
725 frame
= WMCreateFrame(win
);
726 WMSetFrameRelief(frame
, WRFlat
);
727 label
= WMCreateLabel(frame
);
728 WMResizeWidget(label
, 100, 100);
729 WMMoveWidget(label
, 160, 40);
730 WMSetLabelText(label
, "Label 4");
733 tab
= WMCreateTabViewItemWithIdentifier(0);
734 WMSetTabViewItemView(tab
, WMWidgetView(frame
));
735 WMAddItemInTabView(tabv
, tab
);
736 WMSetTabViewItemLabel(tab
, "Bla!");
738 frame
= WMCreateFrame(win
);
739 WMSetFrameRelief(frame
, WRFlat
);
740 label
= WMCreateLabel(frame
);
741 WMResizeWidget(label
, 100, 100);
742 WMMoveWidget(label
, 160, 40);
743 WMSetLabelText(label
, "Label fjweqklrj qwl");
745 tab
= WMCreateTabViewItemWithIdentifier(0);
746 WMSetTabViewItemView(tab
, WMWidgetView(frame
));
747 WMAddItemInTabView(tabv
, tab
);
748 WMSetTabViewItemLabel(tab
, "Weee!");
750 WMRealizeWidget(win
);
751 WMMapSubwidgets(win
);
755 void splitViewConstrainProc(WMSplitView
* sPtr
, int indView
, int *minSize
, int *maxSize
)
775 static void resizeSplitView(XEvent
* event
, void *data
)
777 WMSplitView
*sPtr
= (WMSplitView
*) data
;
779 if (event
->type
== ConfigureNotify
) {
780 int width
= event
->xconfigure
.width
- 10;
782 if (width
< WMGetSplitViewDividerThickness(sPtr
))
783 width
= WMGetSplitViewDividerThickness(sPtr
);
785 if (width
!= WMWidgetWidth(sPtr
) || event
->xconfigure
.height
!= WMWidgetHeight(sPtr
))
786 WMResizeWidget(sPtr
, width
, event
->xconfigure
.height
- 55);
790 void appendSubviewButtonAction(WMWidget
* self
, void *data
)
793 WMSplitView
*sPtr
= (WMSplitView
*) data
;
795 WMLabel
*label
= WMCreateLabel(sPtr
);
797 sprintf(buf
, "Subview %d", WMGetSplitViewSubviewsCount(sPtr
) + 1);
798 WMSetLabelText(label
, buf
);
799 WMSetLabelRelief(label
, WRSunken
);
800 WMAddSplitViewSubview(sPtr
, WMWidgetView(label
));
801 WMRealizeWidget(label
);
805 void removeSubviewButtonAction(WMWidget
* self
, void *data
)
808 WMSplitView
*sPtr
= (WMSplitView
*) data
;
809 int count
= WMGetSplitViewSubviewsCount(sPtr
);
812 WMView
*view
= WMGetSplitViewSubviewAt(sPtr
, count
- 1);
813 WMDestroyWidget(WMWidgetOfView(view
));
814 WMRemoveSplitViewSubviewAt(sPtr
, count
- 1);
818 void orientationButtonAction(WMWidget
* self
, void *data
)
821 WMSplitView
*sPtr
= (WMSplitView
*) data
;
822 WMSetSplitViewVertical(sPtr
, !WMGetSplitViewVertical(sPtr
));
825 void adjustSubviewsButtonAction(WMWidget
* self
, void *data
)
828 WMAdjustSplitViewSubviews((WMSplitView
*) data
);
831 void testSplitView(WMScreen
* scr
)
834 WMSplitView
*splitv1
, *splitv2
;
841 win
= WMCreateWindow(scr
, "testTabs");
842 WMResizeWidget(win
, 300, 400);
843 WMSetWindowCloseAction(win
, closeAction
, NULL
);
845 frame
= WMCreateFrame(win
);
846 WMSetFrameRelief(frame
, WRSunken
);
847 WMMoveWidget(frame
, 5, 5);
848 WMResizeWidget(frame
, 290, 40);
850 splitv1
= WMCreateSplitView(win
);
851 WMMoveWidget(splitv1
, 5, 50);
852 WMResizeWidget(splitv1
, 290, 345);
853 WMSetSplitViewConstrainProc(splitv1
, splitViewConstrainProc
);
854 WMCreateEventHandler(WMWidgetView(win
), StructureNotifyMask
, resizeSplitView
, splitv1
);
856 button
= WMCreateCommandButton(frame
);
857 WMSetButtonText(button
, "+");
858 WMSetButtonAction(button
, appendSubviewButtonAction
, splitv1
);
859 WMMoveWidget(button
, 10, 8);
862 button
= WMCreateCommandButton(frame
);
863 WMSetButtonText(button
, "-");
864 WMSetButtonAction(button
, removeSubviewButtonAction
, splitv1
);
865 WMMoveWidget(button
, 80, 8);
868 button
= WMCreateCommandButton(frame
);
869 WMSetButtonText(button
, "=");
870 WMMoveWidget(button
, 150, 8);
871 WMSetButtonAction(button
, adjustSubviewsButtonAction
, splitv1
);
874 button
= WMCreateCommandButton(frame
);
875 WMSetButtonText(button
, "#");
876 WMMoveWidget(button
, 220, 8);
877 WMSetButtonAction(button
, orientationButtonAction
, splitv1
);
880 label
= WMCreateLabel(splitv1
);
881 WMSetLabelText(label
, "Subview 1");
882 WMSetLabelRelief(label
, WRSunken
);
884 WMAddSplitViewSubview(splitv1
, WMWidgetView(label
));
886 splitv2
= WMCreateSplitView(splitv1
);
887 WMResizeWidget(splitv2
, 150, 150);
888 WMSetSplitViewVertical(splitv2
, True
);
890 label
= WMCreateLabel(splitv2
);
891 WMSetLabelText(label
, "Subview 2.1");
892 WMSetLabelRelief(label
, WRSunken
);
894 WMAddSplitViewSubview(splitv2
, WMWidgetView(label
));
896 label
= WMCreateLabel(splitv2
);
897 WMSetLabelText(label
, "Subview 2.2");
898 WMSetLabelRelief(label
, WRSunken
);
900 WMAddSplitViewSubview(splitv2
, WMWidgetView(label
));
902 label
= WMCreateLabel(splitv2
);
903 WMSetLabelText(label
, "Subview 2.3");
904 WMSetLabelRelief(label
, WRSunken
);
906 WMAddSplitViewSubview(splitv2
, WMWidgetView(label
));
908 WMMapWidget(splitv2
);
909 WMAddSplitViewSubview(splitv1
, WMWidgetView(splitv2
));
911 WMRealizeWidget(win
);
912 WMMapSubwidgets(win
);
918 WMUserDefaults
*defs
;
921 defs
= WMGetStandardUserDefaults();
923 sprintf(str
, "TEST DATA");
925 WMSetUDStringForKey(defs
, str
, "testKey");
929 int main(int argc
, char **argv
)
934 /* Initialize the application */
935 WMInitializeApplication("Test@eqweq_ewq$eqw", &argc
, argv
);
940 * Open connection to the X display.
942 dpy
= XOpenDisplay("");
945 puts("could not open display");
949 /* This is used to disable buffering of X protocol requests.
950 * Do NOT use it unless when debugging. It will cause a major
951 * slowdown in your application
954 XSynchronize(dpy
, True
);
957 * Create screen descriptor.
959 scr
= WMCreateScreen(dpy
, DefaultScreen(dpy
));
962 * Loads the logo of the application.
964 pixmap
= WMCreatePixmapFromFile(scr
, "logo.xpm");
967 * Makes the logo be used in standard dialog panels.
970 WMSetApplicationIconPixmap(scr
, pixmap
);
971 WMReleasePixmap(pixmap
);
975 * Do some test stuff.
977 * Put the testSomething() function you want to test here.
993 testDragAndDrop(scr
);
995 testGradientButtons(scr
);
997 testOpenFilePanel(scr
);
998 testProgressIndicator(scr
);
1000 testScrollView(scr
);
1007 * The main event loop.
1010 WMScreenMainLoop(scr
);