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).
26 void closeAction(WMWidget
* self
, void *data
)
28 WMDestroyWidget(self
);
30 printf("window closed, window count = %d\n", windowCount
);
36 void testOpenFilePanel(WMScreen
* scr
)
41 /* get the shared Open File panel */
42 panel
= WMGetOpenPanel(scr
);
44 WMRunModalFilePanelForDirectory(panel
, NULL
, "/usr/local", NULL
, NULL
);
46 /* free the panel to save some memory. Not needed otherwise. */
47 WMFreeFilePanel(WMGetOpenPanel(scr
));
50 void testFontPanel(WMScreen
* scr
)
56 panel
= WMGetFontPanel(scr
);
58 WMShowFontPanel(panel
);
60 /*WMFreeFontPanel(panel); */
63 void testFrame(WMScreen
* scr
)
68 static char *titles
[] = {
76 static WMTitlePosition pos
[] = {
87 win
= WMCreateWindow(scr
, "testFrame");
88 WMSetWindowTitle(win
, "Frame");
89 WMSetWindowCloseAction(win
, closeAction
, NULL
);
90 WMResizeWidget(win
, 400, 300);
92 for (i
= 0; i
< 6; i
++) {
93 frame
= WMCreateFrame(win
);
94 WMMoveWidget(frame
, 8 + (i
% 3) * 130, 8 + (i
/ 3) * 130);
95 WMResizeWidget(frame
, 120, 120);
96 WMSetFrameTitle(frame
, titles
[i
]);
97 WMSetFrameTitlePosition(frame
, pos
[i
]);
100 WMRealizeWidget(win
);
101 WMMapSubwidgets(win
);
107 resizedWindow(void *self, WMNotification *notif)
109 WMView *view = (WMView*)WMGetNotificationObject(notif);
110 WMSize size = WMGetViewSize(view);
112 WMResizeWidget((WMWidget*)self, size.width, size.height);
115 void testBox(WMScreen
* scr
)
125 win
= WMCreateWindow(scr
, "testBox");
126 WMSetWindowTitle(win
, "Box");
127 WMSetWindowCloseAction(win
, closeAction
, NULL
);
128 WMResizeWidget(win
, 400, 300);
130 box
= WMCreateBox(win
);
131 WMSetBoxBorderWidth(box
, 5);
132 WMSetViewExpandsToParent(WMWidgetView(box
), 0, 0, 0, 0);
134 /*WMSetBoxHorizontal(box, True); */
135 for (i
= 0; i
< 4; i
++) {
136 btn
= WMCreateCommandButton(box
);
137 WMSetButtonText(btn
, "bla");
139 WMAddBoxSubview(box
, WMWidgetView(btn
), i
& 1, True
, 20, 0, 5);
142 pop
= WMCreatePopUpButton(box
);
143 WMAddPopUpButtonItem(pop
, "ewqeq");
144 WMAddPopUpButtonItem(pop
, "ewqeqrewrw");
145 WMAddBoxSubview(box
, WMWidgetView(pop
), False
, True
, 20, 0, 5);
148 hbox
= WMCreateBox(box
);
149 WMSetBoxHorizontal(hbox
, True
);
150 WMAddBoxSubview(box
, WMWidgetView(hbox
), False
, True
, 24, 0, 0);
153 for (i
= 0; i
< 4; i
++) {
154 btn
= WMCreateCommandButton(hbox
);
155 WMSetButtonText(btn
, "bla");
157 WMAddBoxSubview(hbox
, WMWidgetView(btn
), 1, True
, 60, 0, i
< 3 ? 5 : 0);
160 WMRealizeWidget(win
);
161 WMMapSubwidgets(win
);
166 static void singleClick(WMWidget
* self
, void *data
)
170 static void doubleClick(WMWidget
* self
, void *data
)
172 WMSelectAllListItems((WMList
*) self
);
175 static void listSelectionObserver(void *observer
, WMNotification
* notification
)
177 WMLabel
*label
= (WMLabel
*) observer
;
178 WMList
*lPtr
= (WMList
*) WMGetNotificationObject(notification
);
181 sprintf(buf
, "Selected items: %d", WMGetArrayItemCount(WMGetListSelectedItems(lPtr
)));
182 WMSetLabelText(label
, buf
);
185 void testList(WMScreen
* scr
)
199 win
= WMCreateWindow(scr
, "testList");
200 WMResizeWidget(win
, 370, 250);
201 WMSetWindowTitle(win
, "List");
202 WMSetWindowCloseAction(win
, closeAction
, NULL
);
204 title
= WMCreateLabel(win
);
205 WMResizeWidget(title
, 150, 20);
206 WMMoveWidget(title
, 10, 10);
207 WMSetLabelRelief(title
, WRRidge
);
208 WMSetLabelText(title
, "Single selection list");
210 mtitle
= WMCreateLabel(win
);
211 WMResizeWidget(mtitle
, 150, 20);
212 WMMoveWidget(mtitle
, 210, 10);
213 WMSetLabelRelief(mtitle
, WRRidge
);
214 WMSetLabelText(mtitle
, "Multiple selection list");
216 list
= WMCreateList(win
);
217 /*WMSetListAllowEmptySelection(list, True); */
218 WMMoveWidget(list
, 10, 40);
219 for (i
= 0; i
< 105; i
++) {
220 sprintf(text
, "Item %i", i
);
221 WMAddListItem(list
, text
);
223 mlist
= WMCreateList(win
);
224 WMSetListAllowMultipleSelection(mlist
, True
);
225 /*WMSetListAllowEmptySelection(mlist, True); */
226 WMMoveWidget(mlist
, 210, 40);
227 for (i
= 0; i
< 135; i
++) {
228 sprintf(text
, "Item %i", i
);
229 WMAddListItem(mlist
, text
);
232 label
= WMCreateLabel(win
);
233 WMResizeWidget(label
, 150, 40);
234 WMMoveWidget(label
, 10, 200);
235 WMSetLabelRelief(label
, WRRidge
);
236 WMSetLabelText(label
, "Selected items: 0");
238 mlabel
= WMCreateLabel(win
);
239 WMResizeWidget(mlabel
, 150, 40);
240 WMMoveWidget(mlabel
, 210, 200);
241 WMSetLabelRelief(mlabel
, WRRidge
);
242 WMSetLabelText(mlabel
, "Selected items: 0");
244 WMSetListAction(list
, singleClick
, label
);
245 WMSetListDoubleAction(list
, doubleClick
, label
);
246 WMSetListAction(mlist
, singleClick
, mlabel
);
247 WMSetListDoubleAction(mlist
, doubleClick
, mlabel
);
249 WMAddNotificationObserver(listSelectionObserver
, label
, WMListSelectionDidChangeNotification
, list
);
250 WMAddNotificationObserver(listSelectionObserver
, mlabel
, WMListSelectionDidChangeNotification
, mlist
);
252 WMRealizeWidget(win
);
253 WMMapSubwidgets(win
);
258 void testButton(WMScreen
* scr
)
275 win
= WMCreateWindow(scr
, "testButton");
276 WMResizeWidget(win
, 300, 300);
277 WMSetWindowTitle(win
, "Buttons");
279 WMSetWindowCloseAction(win
, closeAction
, NULL
);
281 for (i
= 1; i
< 9; i
++) {
283 b
= WMCreateButton(win
, i
);
284 WMResizeWidget(b
, 150, 24);
285 WMMoveWidget(b
, 20, i
* 30);
286 WMSetButtonText(b
, types
[i
- 1]);
289 WMRealizeWidget(win
);
290 WMMapSubwidgets(win
);
295 void testGradientButtons(WMScreen
* scr
)
299 WMPixmap
*pix1
, *pix2
;
302 WMColor
*color
, *altColor
;
306 /* creates the top-level window */
307 win
= WMCreateWindow(scr
, "testGradientButtons");
308 WMSetWindowTitle(win
, "Gradiented Button Demo");
309 WMResizeWidget(win
, 300, 200);
311 WMSetWindowCloseAction(win
, closeAction
, NULL
);
320 color
= WMCreateRGBColor(scr
, 0x5900, 0x5100, 0x5900, True
);
321 WMSetWidgetBackgroundColor(win
, color
);
322 WMReleaseColor(color
);
324 back
= RRenderGradient(60, 24, &dark
, &light
, RGRD_DIAGONAL
);
325 RBevelImage(back
, RBEV_RAISED2
);
326 pix1
= WMCreatePixmapFromRImage(scr
, back
, 0);
329 back
= RRenderGradient(60, 24, &dark
, &light
, RGRD_DIAGONAL
);
330 RBevelImage(back
, RBEV_SUNKEN
);
331 pix2
= WMCreatePixmapFromRImage(scr
, back
, 0);
334 color
= WMWhiteColor(scr
);
335 altColor
= WMCreateNamedColor(scr
, "red", True
);
337 btn
= WMCreateButton(win
, WBTMomentaryChange
);
338 WMResizeWidget(btn
, 60, 24);
339 WMMoveWidget(btn
, 20, 100);
340 WMSetButtonBordered(btn
, False
);
341 WMSetButtonImagePosition(btn
, WIPOverlaps
);
342 WMSetButtonImage(btn
, pix1
);
343 WMSetButtonAltImage(btn
, pix2
);
344 WMSetButtonText(btn
, "Cool");
345 WMSetButtonTextColor(btn
, color
);
346 WMSetButtonAltTextColor(btn
, altColor
);
348 WMSetBalloonTextForView("This is a cool button", WMWidgetView(btn
));
350 btn
= WMCreateButton(win
, WBTMomentaryChange
);
351 WMResizeWidget(btn
, 60, 24);
352 WMMoveWidget(btn
, 90, 100);
353 WMSetButtonBordered(btn
, False
);
354 WMSetButtonImagePosition(btn
, WIPOverlaps
);
355 WMSetButtonImage(btn
, pix1
);
356 WMSetButtonAltImage(btn
, pix2
);
357 WMSetButtonText(btn
, "Button");
358 WMSetButtonTextColor(btn
, color
);
360 WMSetBalloonTextForView("Este é outro balão.", WMWidgetView(btn
));
362 WMReleaseColor(color
);
363 color
= WMCreateNamedColor(scr
, "orange", True
);
365 btn
= WMCreateButton(win
, WBTMomentaryChange
);
366 WMResizeWidget(btn
, 60, 24);
367 WMMoveWidget(btn
, 160, 100);
368 WMSetButtonBordered(btn
, False
);
369 WMSetButtonImagePosition(btn
, WIPOverlaps
);
370 WMSetButtonImage(btn
, pix1
);
371 WMSetButtonAltImage(btn
, pix2
);
372 WMSetButtonText(btn
, "Test");
373 WMSetButtonTextColor(btn
, color
);
375 WMSetBalloonTextForView("This is yet another button.\nBut the balloon has 3 lines.\nYay!",
378 WMReleaseColor(color
);
379 WMReleaseColor(altColor
);
381 WMRealizeWidget(win
);
382 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
)
487 printf("SLIDER == %i\n", WMGetSliderValue(w
));
490 void testSlider(WMScreen
* scr
)
497 win
= WMCreateWindow(scr
, "testSlider");
498 WMResizeWidget(win
, 300, 300);
499 WMSetWindowTitle(win
, "Sliders");
501 WMSetWindowCloseAction(win
, closeAction
, NULL
);
503 s
= WMCreateSlider(win
);
504 WMResizeWidget(s
, 16, 100);
505 WMMoveWidget(s
, 100, 100);
506 WMSetSliderKnobThickness(s
, 8);
507 WMSetSliderContinuous(s
, False
);
508 WMSetSliderAction(s
, sliderCallback
, s
);
510 s
= WMCreateSlider(win
);
511 WMResizeWidget(s
, 100, 16);
512 WMMoveWidget(s
, 100, 10);
513 WMSetSliderKnobThickness(s
, 8);
515 WMRealizeWidget(win
);
516 WMMapSubwidgets(win
);
521 void testStuff(WMScreen
*scr
)
529 win
= WMCreateWindow(scr
, "testTextField");
530 WMResizeWidget(win
, 400, 300);
532 WMSetWindowCloseAction(win
, closeAction
, NULL
);
535 label
= WMCreateLabel(win
);
536 WMSetLabelText(label
, "HELLO");
537 WMResizeWidget(label
, 100, 20);
538 WMMoveWidget(label
, 10, 100);
540 button
= WMCreateCommandButton(win
);
541 WMSetButtonText(button
, "OK");
542 WMResizeWidget(button
, 80, 24);
543 WMMoveWidget(button
, 400-80-12, 200-24-12);
545 button
= WMCreateCommandButton(win
);
546 WMSetButtonText(button
, "Cancel");
547 WMResizeWidget(button
, 80, 24);
548 WMMoveWidget(button
, 400-80-12-80-12, 300-24-12);
551 WMRealizeWidget(win
);
552 WMMapSubwidgets(win
);
557 void testTextField(WMScreen
* scr
)
560 WMTextField
*field
, *field2
;
564 win
= WMCreateWindow(scr
, "testTextField");
565 WMResizeWidget(win
, 400, 300);
567 WMSetWindowCloseAction(win
, closeAction
, NULL
);
569 field
= WMCreateTextField(win
);
570 WMResizeWidget(field
, 200, 20);
571 WMMoveWidget(field
, 20, 20);
572 WMSetTextFieldText(field
, "the little \xc2\xa9 sign");
574 field2
= WMCreateTextField(win
);
575 WMResizeWidget(field2
, 200, 20);
576 WMMoveWidget(field2
, 20, 50);
577 WMSetTextFieldAlignment(field2
, WARight
);
579 WMRealizeWidget(win
);
580 WMMapSubwidgets(win
);
585 void testText(WMScreen
* scr
)
591 FILE *file
= fopen("wm.html", "rb");
595 win
= WMCreateWindow(scr
, "testText");
596 WMResizeWidget(win
, 500, 300);
598 WMSetWindowCloseAction(win
, closeAction
, NULL
);
600 text
= WMCreateText(win
);
601 WMResizeWidget(text
, 480, 280);
602 WMMoveWidget(text
, 10, 10);
603 WMSetTextHasVerticalScroller(text
, True
);
604 WMSetTextEditable(text
, False
);
605 WMSetTextIgnoresNewline(text
, False
);
607 #define FNAME "Verdana,Luxi Sans:pixelsize=12"
609 "Window Maker is the GNU window manager for the " \
610 "X Window System. It was designed to emulate the " \
611 "look and feel of part of the NEXTSTEP(tm) GUI. It's " \
612 "supposed to be relatively fast and small, feature " \
613 "rich, easy to configure and easy to use, with a simple " \
614 "and elegant appearance borrowed from NEXTSTEP(tm)."
616 font
= WMCreateFont(scr
, FNAME
":autohint=false");
617 WMSetTextDefaultFont(text
, font
);
624 while (fgets(buf
, 1023, file
))
625 WMAppendTextStream(text
, buf
);
630 WMAppendTextStream(text
, "First paragraph has autohinting turned off, "
631 "while the second has it turned on:");
632 WMAppendTextStream(text
, "\n\n\n");
633 WMAppendTextStream(text
, MSG
);
634 WMAppendTextStream(text
, "\n\n\n");
635 font
= WMCreateFont(scr
, FNAME
":autohint=true");
636 tb
= WMCreateTextBlockWithText(text
, MSG
, font
, WMBlackColor(scr
), 0, strlen(MSG
));
637 WMAppendTextBlock(text
, tb
);
641 WMRealizeWidget(win
);
642 WMMapSubwidgets(win
);
646 void testProgressIndicator(WMScreen
* scr
)
649 WMProgressIndicator
*pPtr
;
653 win
= WMCreateWindow(scr
, "testProgressIndicator");
654 WMResizeWidget(win
, 292, 32);
656 WMSetWindowCloseAction(win
, closeAction
, NULL
);
658 pPtr
= WMCreateProgressIndicator(win
);
659 WMMoveWidget(pPtr
, 8, 8);
660 WMSetProgressIndicatorValue(pPtr
, 75);
662 WMRealizeWidget(win
);
663 WMMapSubwidgets(win
);
668 void testPullDown(WMScreen
* scr
)
671 WMPopUpButton
*pop
, *pop2
;
675 win
= WMCreateWindow(scr
, "pullDown");
676 WMResizeWidget(win
, 400, 300);
678 WMSetWindowCloseAction(win
, closeAction
, NULL
);
680 pop
= WMCreatePopUpButton(win
);
681 WMResizeWidget(pop
, 100, 20);
682 WMMoveWidget(pop
, 50, 60);
683 WMSetPopUpButtonPullsDown(pop
, True
);
684 WMSetPopUpButtonText(pop
, "Commands");
685 WMAddPopUpButtonItem(pop
, "Add");
686 WMAddPopUpButtonItem(pop
, "Remove");
687 WMAddPopUpButtonItem(pop
, "Check");
688 WMAddPopUpButtonItem(pop
, "Eat");
690 pop2
= WMCreatePopUpButton(win
);
691 WMResizeWidget(pop2
, 100, 20);
692 WMMoveWidget(pop2
, 200, 60);
693 WMSetPopUpButtonText(pop2
, "Select");
694 WMAddPopUpButtonItem(pop2
, "Apples");
695 WMAddPopUpButtonItem(pop2
, "Bananas");
696 WMAddPopUpButtonItem(pop2
, "Strawberries");
697 WMAddPopUpButtonItem(pop2
, "Blueberries");
699 WMRealizeWidget(win
);
700 WMMapSubwidgets(win
);
705 void testTabView(WMScreen
* scr
)
715 win
= WMCreateWindow(scr
, "testTabs");
716 WMResizeWidget(win
, 400, 300);
718 WMSetWindowCloseAction(win
, closeAction
, NULL
);
720 tabv
= WMCreateTabView(win
);
721 WMMoveWidget(tabv
, 50, 50);
722 WMResizeWidget(tabv
, 300, 200);
724 frame
= WMCreateFrame(win
);
725 WMSetFrameRelief(frame
, WRFlat
);
726 label
= WMCreateLabel(frame
);
727 WMResizeWidget(label
, 100, 100);
728 WMSetLabelText(label
, "Label 1");
731 tab
= WMCreateTabViewItemWithIdentifier(0);
732 WMSetTabViewItemView(tab
, WMWidgetView(frame
));
733 WMAddItemInTabView(tabv
, tab
);
734 WMSetTabViewItemLabel(tab
, "Instances");
736 frame
= WMCreateFrame(win
);
737 WMSetFrameRelief(frame
, WRFlat
);
738 label
= WMCreateLabel(frame
);
739 WMResizeWidget(label
, 40, 50);
740 WMSetLabelText(label
, "Label 2");
743 tab
= WMCreateTabViewItemWithIdentifier(0);
744 WMSetTabViewItemView(tab
, WMWidgetView(frame
));
745 WMAddItemInTabView(tabv
, tab
);
746 WMSetTabViewItemLabel(tab
, "Classes");
748 frame
= WMCreateFrame(win
);
749 WMSetFrameRelief(frame
, WRFlat
);
750 label
= WMCreateLabel(frame
);
751 WMResizeWidget(label
, 100, 100);
752 WMMoveWidget(label
, 60, 40);
753 WMSetLabelText(label
, "Label 3");
756 tab
= WMCreateTabViewItemWithIdentifier(0);
757 WMSetTabViewItemView(tab
, WMWidgetView(frame
));
758 WMAddItemInTabView(tabv
, tab
);
759 WMSetTabViewItemLabel(tab
, "Something");
761 frame
= WMCreateFrame(win
);
762 WMSetFrameRelief(frame
, WRFlat
);
763 label
= WMCreateLabel(frame
);
764 WMResizeWidget(label
, 100, 100);
765 WMMoveWidget(label
, 160, 40);
766 WMSetLabelText(label
, "Label 4");
769 tab
= WMCreateTabViewItemWithIdentifier(0);
770 WMSetTabViewItemView(tab
, WMWidgetView(frame
));
771 WMAddItemInTabView(tabv
, tab
);
772 WMSetTabViewItemLabel(tab
, "Bla!");
774 frame
= WMCreateFrame(win
);
775 WMSetFrameRelief(frame
, WRFlat
);
776 label
= WMCreateLabel(frame
);
777 WMResizeWidget(label
, 100, 100);
778 WMMoveWidget(label
, 160, 40);
779 WMSetLabelText(label
, "Label fjweqklrj qwl");
781 tab
= WMCreateTabViewItemWithIdentifier(0);
782 WMSetTabViewItemView(tab
, WMWidgetView(frame
));
783 WMAddItemInTabView(tabv
, tab
);
784 WMSetTabViewItemLabel(tab
, "Weee!");
786 WMRealizeWidget(win
);
787 WMMapSubwidgets(win
);
791 void splitViewConstrainProc(WMSplitView
* sPtr
, int indView
, int *minSize
, int *maxSize
)
809 static void resizeSplitView(XEvent
* event
, void *data
)
811 WMSplitView
*sPtr
= (WMSplitView
*) data
;
813 if (event
->type
== ConfigureNotify
) {
814 int width
= event
->xconfigure
.width
- 10;
816 if (width
< WMGetSplitViewDividerThickness(sPtr
))
817 width
= WMGetSplitViewDividerThickness(sPtr
);
819 if (width
!= WMWidgetWidth(sPtr
) || event
->xconfigure
.height
!= WMWidgetHeight(sPtr
))
820 WMResizeWidget(sPtr
, width
, event
->xconfigure
.height
- 55);
824 void appendSubviewButtonAction(WMWidget
* self
, void *data
)
826 WMSplitView
*sPtr
= (WMSplitView
*) data
;
828 WMLabel
*label
= WMCreateLabel(sPtr
);
830 sprintf(buf
, "Subview %d", WMGetSplitViewSubviewsCount(sPtr
) + 1);
831 WMSetLabelText(label
, buf
);
832 WMSetLabelRelief(label
, WRSunken
);
833 WMAddSplitViewSubview(sPtr
, WMWidgetView(label
));
834 WMRealizeWidget(label
);
838 void removeSubviewButtonAction(WMWidget
* self
, void *data
)
840 WMSplitView
*sPtr
= (WMSplitView
*) data
;
841 int count
= WMGetSplitViewSubviewsCount(sPtr
);
844 WMView
*view
= WMGetSplitViewSubviewAt(sPtr
, count
- 1);
845 WMDestroyWidget(WMWidgetOfView(view
));
846 WMRemoveSplitViewSubviewAt(sPtr
, count
- 1);
850 void orientationButtonAction(WMWidget
* self
, void *data
)
852 WMSplitView
*sPtr
= (WMSplitView
*) data
;
853 WMSetSplitViewVertical(sPtr
, !WMGetSplitViewVertical(sPtr
));
856 void adjustSubviewsButtonAction(WMWidget
* self
, void *data
)
858 WMAdjustSplitViewSubviews((WMSplitView
*) data
);
861 void testSplitView(WMScreen
* scr
)
864 WMSplitView
*splitv1
, *splitv2
;
871 win
= WMCreateWindow(scr
, "testTabs");
872 WMResizeWidget(win
, 300, 400);
873 WMSetWindowCloseAction(win
, closeAction
, NULL
);
875 frame
= WMCreateFrame(win
);
876 WMSetFrameRelief(frame
, WRSunken
);
877 WMMoveWidget(frame
, 5, 5);
878 WMResizeWidget(frame
, 290, 40);
880 splitv1
= WMCreateSplitView(win
);
881 WMMoveWidget(splitv1
, 5, 50);
882 WMResizeWidget(splitv1
, 290, 345);
883 WMSetSplitViewConstrainProc(splitv1
, splitViewConstrainProc
);
884 WMCreateEventHandler(WMWidgetView(win
), StructureNotifyMask
, resizeSplitView
, splitv1
);
886 button
= WMCreateCommandButton(frame
);
887 WMSetButtonText(button
, "+");
888 WMSetButtonAction(button
, appendSubviewButtonAction
, splitv1
);
889 WMMoveWidget(button
, 10, 8);
892 button
= WMCreateCommandButton(frame
);
893 WMSetButtonText(button
, "-");
894 WMSetButtonAction(button
, removeSubviewButtonAction
, splitv1
);
895 WMMoveWidget(button
, 80, 8);
898 button
= WMCreateCommandButton(frame
);
899 WMSetButtonText(button
, "=");
900 WMMoveWidget(button
, 150, 8);
901 WMSetButtonAction(button
, adjustSubviewsButtonAction
, splitv1
);
904 button
= WMCreateCommandButton(frame
);
905 WMSetButtonText(button
, "#");
906 WMMoveWidget(button
, 220, 8);
907 WMSetButtonAction(button
, orientationButtonAction
, splitv1
);
910 label
= WMCreateLabel(splitv1
);
911 WMSetLabelText(label
, "Subview 1");
912 WMSetLabelRelief(label
, WRSunken
);
914 WMAddSplitViewSubview(splitv1
, WMWidgetView(label
));
916 splitv2
= WMCreateSplitView(splitv1
);
917 WMResizeWidget(splitv2
, 150, 150);
918 WMSetSplitViewVertical(splitv2
, True
);
920 label
= WMCreateLabel(splitv2
);
921 WMSetLabelText(label
, "Subview 2.1");
922 WMSetLabelRelief(label
, WRSunken
);
924 WMAddSplitViewSubview(splitv2
, WMWidgetView(label
));
926 label
= WMCreateLabel(splitv2
);
927 WMSetLabelText(label
, "Subview 2.2");
928 WMSetLabelRelief(label
, WRSunken
);
930 WMAddSplitViewSubview(splitv2
, WMWidgetView(label
));
932 label
= WMCreateLabel(splitv2
);
933 WMSetLabelText(label
, "Subview 2.3");
934 WMSetLabelRelief(label
, WRSunken
);
936 WMAddSplitViewSubview(splitv2
, WMWidgetView(label
));
938 WMMapWidget(splitv2
);
939 WMAddSplitViewSubview(splitv1
, WMWidgetView(splitv2
));
941 WMRealizeWidget(win
);
942 WMMapSubwidgets(win
);
948 WMUserDefaults
*defs
;
951 defs
= WMGetStandardUserDefaults();
953 sprintf(str
, "TEST DATA");
955 WMSetUDStringForKey(defs
, str
, "testKey");
960 int main(int argc
, char **argv
)
965 /* Initialize the application */
966 WMInitializeApplication("Test@eqweq_ewq$eqw", &argc
, argv
);
971 * Open connection to the X display.
973 dpy
= XOpenDisplay("");
976 puts("could not open display");
980 /* This is used to disable buffering of X protocol requests.
981 * Do NOT use it unless when debugging. It will cause a major
982 * slowdown in your application
985 XSynchronize(dpy
, True
);
988 * Create screen descriptor.
990 scr
= WMCreateScreen(dpy
, DefaultScreen(dpy
));
993 * Loads the logo of the application.
995 pixmap
= WMCreatePixmapFromFile(scr
, "logo.xpm");
998 * Makes the logo be used in standard dialog panels.
1001 //XXXWMSetApplicationIconPixmap(scr, pixmap);
1002 //XXXWMReleasePixmap(pixmap);
1006 * Do some test stuff.
1008 * Put the testSomething() function you want to test here.
1017 testColorPanel(scr
);
1023 testColorPanel(scr
);
1025 testDragAndDrop(scr
);
1027 testGradientButtons(scr
);
1029 testOpenFilePanel(scr
);
1030 testProgressIndicator(scr
);
1032 testScrollView(scr
);
1039 * The main event loop.
1042 WMScreenMainLoop(scr
);