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
);
35 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
);
257 void testButton(WMScreen
* scr
)
274 win
= WMCreateWindow(scr
, "testButton");
275 WMResizeWidget(win
, 300, 300);
276 WMSetWindowTitle(win
, "Buttons");
278 WMSetWindowCloseAction(win
, closeAction
, NULL
);
280 for (i
= 1; i
< 9; i
++) {
282 b
= WMCreateButton(win
, i
);
283 WMResizeWidget(b
, 150, 24);
284 WMMoveWidget(b
, 20, i
* 30);
285 WMSetButtonText(b
, types
[i
- 1]);
288 WMRealizeWidget(win
);
289 WMMapSubwidgets(win
);
293 void testGradientButtons(WMScreen
* scr
)
297 WMPixmap
*pix1
, *pix2
;
300 WMColor
*color
, *altColor
;
304 /* creates the top-level window */
305 win
= WMCreateWindow(scr
, "testGradientButtons");
306 WMSetWindowTitle(win
, "Gradiented Button Demo");
307 WMResizeWidget(win
, 300, 200);
309 WMSetWindowCloseAction(win
, closeAction
, NULL
);
318 color
= WMCreateRGBColor(scr
, 0x5900, 0x5100, 0x5900, True
);
319 WMSetWidgetBackgroundColor(win
, color
);
320 WMReleaseColor(color
);
322 back
= RRenderGradient(60, 24, &dark
, &light
, RGRD_DIAGONAL
);
323 RBevelImage(back
, RBEV_RAISED2
);
324 pix1
= WMCreatePixmapFromRImage(scr
, back
, 0);
327 back
= RRenderGradient(60, 24, &dark
, &light
, RGRD_DIAGONAL
);
328 RBevelImage(back
, RBEV_SUNKEN
);
329 pix2
= WMCreatePixmapFromRImage(scr
, back
, 0);
332 color
= WMWhiteColor(scr
);
333 altColor
= WMCreateNamedColor(scr
, "red", True
);
335 btn
= WMCreateButton(win
, WBTMomentaryChange
);
336 WMResizeWidget(btn
, 60, 24);
337 WMMoveWidget(btn
, 20, 100);
338 WMSetButtonBordered(btn
, False
);
339 WMSetButtonImagePosition(btn
, WIPOverlaps
);
340 WMSetButtonImage(btn
, pix1
);
341 WMSetButtonAltImage(btn
, pix2
);
342 WMSetButtonText(btn
, "Cool");
343 WMSetButtonTextColor(btn
, color
);
344 WMSetButtonAltTextColor(btn
, altColor
);
346 WMSetBalloonTextForView("This is a cool button", WMWidgetView(btn
));
348 btn
= WMCreateButton(win
, WBTMomentaryChange
);
349 WMResizeWidget(btn
, 60, 24);
350 WMMoveWidget(btn
, 90, 100);
351 WMSetButtonBordered(btn
, False
);
352 WMSetButtonImagePosition(btn
, WIPOverlaps
);
353 WMSetButtonImage(btn
, pix1
);
354 WMSetButtonAltImage(btn
, pix2
);
355 WMSetButtonText(btn
, "Button");
356 WMSetButtonTextColor(btn
, color
);
358 WMSetBalloonTextForView("Este é outro balão.", WMWidgetView(btn
));
360 WMReleaseColor(color
);
361 color
= WMCreateNamedColor(scr
, "orange", True
);
363 btn
= WMCreateButton(win
, WBTMomentaryChange
);
364 WMResizeWidget(btn
, 60, 24);
365 WMMoveWidget(btn
, 160, 100);
366 WMSetButtonBordered(btn
, False
);
367 WMSetButtonImagePosition(btn
, WIPOverlaps
);
368 WMSetButtonImage(btn
, pix1
);
369 WMSetButtonAltImage(btn
, pix2
);
370 WMSetButtonText(btn
, "Test");
371 WMSetButtonTextColor(btn
, color
);
373 WMSetBalloonTextForView("This is yet another button.\nBut the balloon has 3 lines.\nYay!",
376 WMReleaseColor(color
);
377 WMReleaseColor(altColor
);
379 WMRealizeWidget(win
);
380 WMMapSubwidgets(win
);
384 void testScrollView(WMScreen
* scr
)
395 /* creates the top-level window */
396 win
= WMCreateWindow(scr
, "testScroll");
397 WMSetWindowTitle(win
, "Scrollable View");
399 WMSetWindowCloseAction(win
, closeAction
, NULL
);
401 /* set the window size */
402 WMResizeWidget(win
, 300, 300);
404 /* creates a scrollable view inside the top-level window */
405 sview
= WMCreateScrollView(win
);
406 WMResizeWidget(sview
, 200, 200);
407 WMMoveWidget(sview
, 30, 30);
408 WMSetScrollViewRelief(sview
, WRSunken
);
409 WMSetScrollViewHasVerticalScroller(sview
, True
);
410 WMSetScrollViewHasHorizontalScroller(sview
, True
);
412 /* create a frame with a bunch of labels */
413 f
= WMCreateFrame(win
);
414 WMResizeWidget(f
, 400, 400);
415 WMSetFrameRelief(f
, WRFlat
);
417 for (i
= 0; i
< 20; i
++) {
418 l
= WMCreateLabel(f
);
419 WMResizeWidget(l
, 50, 18);
420 WMMoveWidget(l
, 10, 20 * i
);
421 sprintf(buffer
, "Label %i", i
);
422 WMSetLabelText(l
, buffer
);
423 WMSetLabelRelief(l
, WRSimple
);
428 WMSetScrollViewContentView(sview
, WMWidgetView(f
));
430 /* make the windows of the widgets be actually created */
431 WMRealizeWidget(win
);
433 /* Map all child widgets of the top-level be mapped.
434 * You must call this for each container widget (like frames),
435 * even if they are childs of the top-level window.
437 WMMapSubwidgets(win
);
439 /* map the top-level window */
443 void testColorWell(WMScreen
* scr
)
446 WMColorWell
*well1
, *well2
;
450 win
= WMCreateWindow(scr
, "testColor");
451 WMResizeWidget(win
, 300, 300);
452 WMSetWindowCloseAction(win
, closeAction
, NULL
);
454 well1
= WMCreateColorWell(win
);
455 WMResizeWidget(well1
, 60, 40);
456 WMMoveWidget(well1
, 100, 100);
457 WMSetColorWellColor(well1
, WMCreateRGBColor(scr
, 0x8888, 0, 0x1111, True
));
458 well2
= WMCreateColorWell(win
);
459 WMResizeWidget(well2
, 60, 40);
460 WMMoveWidget(well2
, 200, 100);
461 WMSetColorWellColor(well2
, WMCreateRGBColor(scr
, 0, 0, 0x8888, True
));
463 WMRealizeWidget(win
);
464 WMMapSubwidgets(win
);
468 void testColorPanel(WMScreen
* scr
)
470 WMColorPanel
*panel
= WMGetColorPanel(scr
);
473 startcolor = WMCreateNamedColor(scr, colorname, False);
474 WMSetColorPanelColor(panel, startcolor);
475 WMReleaseColor(startcolor);
478 WMShowColorPanel(panel
);
481 void sliderCallback(WMWidget
* w
, void *data
)
483 printf("SLIDER == %i\n", WMGetSliderValue(w
));
486 void testSlider(WMScreen
* scr
)
493 win
= WMCreateWindow(scr
, "testSlider");
494 WMResizeWidget(win
, 300, 300);
495 WMSetWindowTitle(win
, "Sliders");
497 WMSetWindowCloseAction(win
, closeAction
, NULL
);
499 s
= WMCreateSlider(win
);
500 WMResizeWidget(s
, 16, 100);
501 WMMoveWidget(s
, 100, 100);
502 WMSetSliderKnobThickness(s
, 8);
503 WMSetSliderContinuous(s
, False
);
504 WMSetSliderAction(s
, sliderCallback
, s
);
506 s
= WMCreateSlider(win
);
507 WMResizeWidget(s
, 100, 16);
508 WMMoveWidget(s
, 100, 10);
509 WMSetSliderKnobThickness(s
, 8);
511 WMRealizeWidget(win
);
512 WMMapSubwidgets(win
);
516 void testTextField(WMScreen
* scr
)
519 WMTextField
*field
, *field2
;
523 win
= WMCreateWindow(scr
, "testTextField");
524 WMResizeWidget(win
, 400, 300);
526 WMSetWindowCloseAction(win
, closeAction
, NULL
);
528 field
= WMCreateTextField(win
);
529 WMResizeWidget(field
, 200, 20);
530 WMMoveWidget(field
, 20, 20);
531 WMSetTextFieldText(field
, "the little \xc2\xa9 sign");
533 field2
= WMCreateTextField(win
);
534 WMResizeWidget(field2
, 200, 20);
535 WMMoveWidget(field2
, 20, 50);
536 WMSetTextFieldAlignment(field2
, WARight
);
538 WMRealizeWidget(win
);
539 WMMapSubwidgets(win
);
544 void testText(WMScreen
* scr
)
550 FILE *file
= fopen("wm.html", "rb");
554 win
= WMCreateWindow(scr
, "testText");
555 WMResizeWidget(win
, 500, 300);
557 WMSetWindowCloseAction(win
, closeAction
, NULL
);
559 text
= WMCreateText(win
);
560 WMResizeWidget(text
, 480, 280);
561 WMMoveWidget(text
, 10, 10);
562 WMSetTextHasVerticalScroller(text
, True
);
563 WMSetTextEditable(text
, False
);
564 WMSetTextIgnoresNewline(text
, False
);
566 #define FNAME "Verdana,sans serif:pixelsize=12"
568 "Window Maker is the GNU window manager for the " \
569 "X Window System. It was designed to emulate the " \
570 "look and feel of part of the NEXTSTEP(tm) GUI. It's " \
571 "supposed to be relatively fast and small, feature " \
572 "rich, easy to configure and easy to use, with a simple " \
573 "and elegant appearance borrowed from NEXTSTEP(tm)."
575 font
= WMCreateFont(scr
, FNAME
":autohint=false");
576 WMSetTextDefaultFont(text
, font
);
583 while (fgets(buf
, 1023, file
))
584 WMAppendTextStream(text
, buf
);
589 WMAppendTextStream(text
, "First paragraph has autohinting turned off, "
590 "while the second has it turned on:");
591 WMAppendTextStream(text
, "\n\n\n");
592 WMAppendTextStream(text
, MSG
);
593 WMAppendTextStream(text
, "\n\n\n");
594 font
= WMCreateFont(scr
, FNAME
":autohint=true");
595 tb
= WMCreateTextBlockWithText(text
, MSG
, font
, WMBlackColor(scr
), 0, strlen(MSG
));
596 WMAppendTextBlock(text
, tb
);
600 WMRealizeWidget(win
);
601 WMMapSubwidgets(win
);
605 void testProgressIndicator(WMScreen
* scr
)
608 WMProgressIndicator
*pPtr
;
612 win
= WMCreateWindow(scr
, "testProgressIndicator");
613 WMResizeWidget(win
, 292, 32);
615 WMSetWindowCloseAction(win
, closeAction
, NULL
);
617 pPtr
= WMCreateProgressIndicator(win
);
618 WMMoveWidget(pPtr
, 8, 8);
619 WMSetProgressIndicatorValue(pPtr
, 75);
621 WMRealizeWidget(win
);
622 WMMapSubwidgets(win
);
627 void testPullDown(WMScreen
* scr
)
630 WMPopUpButton
*pop
, *pop2
;
634 win
= WMCreateWindow(scr
, "pullDown");
635 WMResizeWidget(win
, 400, 300);
637 WMSetWindowCloseAction(win
, closeAction
, NULL
);
639 pop
= WMCreatePopUpButton(win
);
640 WMResizeWidget(pop
, 100, 20);
641 WMMoveWidget(pop
, 50, 60);
642 WMSetPopUpButtonPullsDown(pop
, True
);
643 WMSetPopUpButtonText(pop
, "Commands");
644 WMAddPopUpButtonItem(pop
, "Add");
645 WMAddPopUpButtonItem(pop
, "Remove");
646 WMAddPopUpButtonItem(pop
, "Check");
647 WMAddPopUpButtonItem(pop
, "Eat");
649 pop2
= WMCreatePopUpButton(win
);
650 WMResizeWidget(pop2
, 100, 20);
651 WMMoveWidget(pop2
, 200, 60);
652 WMSetPopUpButtonText(pop2
, "Select");
653 WMAddPopUpButtonItem(pop2
, "Apples");
654 WMAddPopUpButtonItem(pop2
, "Bananas");
655 WMAddPopUpButtonItem(pop2
, "Strawberries");
656 WMAddPopUpButtonItem(pop2
, "Blueberries");
658 WMRealizeWidget(win
);
659 WMMapSubwidgets(win
);
664 void testTabView(WMScreen
* scr
)
674 win
= WMCreateWindow(scr
, "testTabs");
675 WMResizeWidget(win
, 400, 300);
677 WMSetWindowCloseAction(win
, closeAction
, NULL
);
679 tabv
= WMCreateTabView(win
);
680 WMMoveWidget(tabv
, 50, 50);
681 WMResizeWidget(tabv
, 300, 200);
683 frame
= WMCreateFrame(win
);
684 WMSetFrameRelief(frame
, WRFlat
);
685 label
= WMCreateLabel(frame
);
686 WMResizeWidget(label
, 100, 100);
687 WMSetLabelText(label
, "Label 1");
690 tab
= WMCreateTabViewItemWithIdentifier(0);
691 WMSetTabViewItemView(tab
, WMWidgetView(frame
));
692 WMAddItemInTabView(tabv
, tab
);
693 WMSetTabViewItemLabel(tab
, "Instances");
695 frame
= WMCreateFrame(win
);
696 WMSetFrameRelief(frame
, WRFlat
);
697 label
= WMCreateLabel(frame
);
698 WMResizeWidget(label
, 40, 50);
699 WMSetLabelText(label
, "Label 2");
702 tab
= WMCreateTabViewItemWithIdentifier(0);
703 WMSetTabViewItemView(tab
, WMWidgetView(frame
));
704 WMAddItemInTabView(tabv
, tab
);
705 WMSetTabViewItemLabel(tab
, "Classes");
707 frame
= WMCreateFrame(win
);
708 WMSetFrameRelief(frame
, WRFlat
);
709 label
= WMCreateLabel(frame
);
710 WMResizeWidget(label
, 100, 100);
711 WMMoveWidget(label
, 60, 40);
712 WMSetLabelText(label
, "Label 3");
715 tab
= WMCreateTabViewItemWithIdentifier(0);
716 WMSetTabViewItemView(tab
, WMWidgetView(frame
));
717 WMAddItemInTabView(tabv
, tab
);
718 WMSetTabViewItemLabel(tab
, "Something");
720 frame
= WMCreateFrame(win
);
721 WMSetFrameRelief(frame
, WRFlat
);
722 label
= WMCreateLabel(frame
);
723 WMResizeWidget(label
, 100, 100);
724 WMMoveWidget(label
, 160, 40);
725 WMSetLabelText(label
, "Label 4");
728 tab
= WMCreateTabViewItemWithIdentifier(0);
729 WMSetTabViewItemView(tab
, WMWidgetView(frame
));
730 WMAddItemInTabView(tabv
, tab
);
731 WMSetTabViewItemLabel(tab
, "Bla!");
733 frame
= WMCreateFrame(win
);
734 WMSetFrameRelief(frame
, WRFlat
);
735 label
= WMCreateLabel(frame
);
736 WMResizeWidget(label
, 100, 100);
737 WMMoveWidget(label
, 160, 40);
738 WMSetLabelText(label
, "Label fjweqklrj qwl");
740 tab
= WMCreateTabViewItemWithIdentifier(0);
741 WMSetTabViewItemView(tab
, WMWidgetView(frame
));
742 WMAddItemInTabView(tabv
, tab
);
743 WMSetTabViewItemLabel(tab
, "Weee!");
745 WMRealizeWidget(win
);
746 WMMapSubwidgets(win
);
750 void splitViewConstrainProc(WMSplitView
* sPtr
, int indView
, int *minSize
, int *maxSize
)
768 static void resizeSplitView(XEvent
* event
, void *data
)
770 WMSplitView
*sPtr
= (WMSplitView
*) data
;
772 if (event
->type
== ConfigureNotify
) {
773 int width
= event
->xconfigure
.width
- 10;
775 if (width
< WMGetSplitViewDividerThickness(sPtr
))
776 width
= WMGetSplitViewDividerThickness(sPtr
);
778 if (width
!= WMWidgetWidth(sPtr
) || event
->xconfigure
.height
!= WMWidgetHeight(sPtr
))
779 WMResizeWidget(sPtr
, width
, event
->xconfigure
.height
- 55);
783 void appendSubviewButtonAction(WMWidget
* self
, void *data
)
785 WMSplitView
*sPtr
= (WMSplitView
*) data
;
787 WMLabel
*label
= WMCreateLabel(sPtr
);
789 sprintf(buf
, "Subview %d", WMGetSplitViewSubviewsCount(sPtr
) + 1);
790 WMSetLabelText(label
, buf
);
791 WMSetLabelRelief(label
, WRSunken
);
792 WMAddSplitViewSubview(sPtr
, WMWidgetView(label
));
793 WMRealizeWidget(label
);
797 void removeSubviewButtonAction(WMWidget
* self
, void *data
)
799 WMSplitView
*sPtr
= (WMSplitView
*) data
;
800 int count
= WMGetSplitViewSubviewsCount(sPtr
);
803 WMView
*view
= WMGetSplitViewSubviewAt(sPtr
, count
- 1);
804 WMDestroyWidget(WMWidgetOfView(view
));
805 WMRemoveSplitViewSubviewAt(sPtr
, count
- 1);
809 void orientationButtonAction(WMWidget
* self
, void *data
)
811 WMSplitView
*sPtr
= (WMSplitView
*) data
;
812 WMSetSplitViewVertical(sPtr
, !WMGetSplitViewVertical(sPtr
));
815 void adjustSubviewsButtonAction(WMWidget
* self
, void *data
)
817 WMAdjustSplitViewSubviews((WMSplitView
*) data
);
820 void testSplitView(WMScreen
* scr
)
823 WMSplitView
*splitv1
, *splitv2
;
830 win
= WMCreateWindow(scr
, "testTabs");
831 WMResizeWidget(win
, 300, 400);
832 WMSetWindowCloseAction(win
, closeAction
, NULL
);
834 frame
= WMCreateFrame(win
);
835 WMSetFrameRelief(frame
, WRSunken
);
836 WMMoveWidget(frame
, 5, 5);
837 WMResizeWidget(frame
, 290, 40);
839 splitv1
= WMCreateSplitView(win
);
840 WMMoveWidget(splitv1
, 5, 50);
841 WMResizeWidget(splitv1
, 290, 345);
842 WMSetSplitViewConstrainProc(splitv1
, splitViewConstrainProc
);
843 WMCreateEventHandler(WMWidgetView(win
), StructureNotifyMask
, resizeSplitView
, splitv1
);
845 button
= WMCreateCommandButton(frame
);
846 WMSetButtonText(button
, "+");
847 WMSetButtonAction(button
, appendSubviewButtonAction
, splitv1
);
848 WMMoveWidget(button
, 10, 8);
851 button
= WMCreateCommandButton(frame
);
852 WMSetButtonText(button
, "-");
853 WMSetButtonAction(button
, removeSubviewButtonAction
, splitv1
);
854 WMMoveWidget(button
, 80, 8);
857 button
= WMCreateCommandButton(frame
);
858 WMSetButtonText(button
, "=");
859 WMMoveWidget(button
, 150, 8);
860 WMSetButtonAction(button
, adjustSubviewsButtonAction
, splitv1
);
863 button
= WMCreateCommandButton(frame
);
864 WMSetButtonText(button
, "#");
865 WMMoveWidget(button
, 220, 8);
866 WMSetButtonAction(button
, orientationButtonAction
, splitv1
);
869 label
= WMCreateLabel(splitv1
);
870 WMSetLabelText(label
, "Subview 1");
871 WMSetLabelRelief(label
, WRSunken
);
873 WMAddSplitViewSubview(splitv1
, WMWidgetView(label
));
875 splitv2
= WMCreateSplitView(splitv1
);
876 WMResizeWidget(splitv2
, 150, 150);
877 WMSetSplitViewVertical(splitv2
, True
);
879 label
= WMCreateLabel(splitv2
);
880 WMSetLabelText(label
, "Subview 2.1");
881 WMSetLabelRelief(label
, WRSunken
);
883 WMAddSplitViewSubview(splitv2
, WMWidgetView(label
));
885 label
= WMCreateLabel(splitv2
);
886 WMSetLabelText(label
, "Subview 2.2");
887 WMSetLabelRelief(label
, WRSunken
);
889 WMAddSplitViewSubview(splitv2
, WMWidgetView(label
));
891 label
= WMCreateLabel(splitv2
);
892 WMSetLabelText(label
, "Subview 2.3");
893 WMSetLabelRelief(label
, WRSunken
);
895 WMAddSplitViewSubview(splitv2
, WMWidgetView(label
));
897 WMMapWidget(splitv2
);
898 WMAddSplitViewSubview(splitv1
, WMWidgetView(splitv2
));
900 WMRealizeWidget(win
);
901 WMMapSubwidgets(win
);
907 WMUserDefaults
*defs
;
910 defs
= WMGetStandardUserDefaults();
912 sprintf(str
, "TEST DATA");
914 WMSetUDStringForKey(defs
, str
, "testKey");
918 int main(int argc
, char **argv
)
923 /* Initialize the application */
924 WMInitializeApplication("Test@eqweq_ewq$eqw", &argc
, argv
);
929 * Open connection to the X display.
931 dpy
= XOpenDisplay("");
934 puts("could not open display");
938 /* This is used to disable buffering of X protocol requests.
939 * Do NOT use it unless when debugging. It will cause a major
940 * slowdown in your application
943 XSynchronize(dpy
, True
);
946 * Create screen descriptor.
948 scr
= WMCreateScreen(dpy
, DefaultScreen(dpy
));
951 * Loads the logo of the application.
953 pixmap
= WMCreatePixmapFromFile(scr
, "logo.xpm");
956 * Makes the logo be used in standard dialog panels.
959 WMSetApplicationIconPixmap(scr
, pixmap
);
960 WMReleasePixmap(pixmap
);
964 * Do some test stuff.
966 * Put the testSomething() function you want to test here.
982 testDragAndDrop(scr
);
984 testGradientButtons(scr
);
986 testOpenFilePanel(scr
);
987 testProgressIndicator(scr
);
996 * The main event loop.
999 WMScreenMainLoop(scr
);