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).
31 closeAction(WMWidget
*self
, void *data
)
33 WMDestroyWidget(self
);
35 printf("window closed, window count = %d\n", windowCount
);
42 testOpenFilePanel(WMScreen
*scr
)
48 /* get the shared Open File panel */
49 panel
= WMGetOpenPanel(scr
);
51 WMRunModalFilePanelForDirectory(panel
, NULL
, "/usr/local", NULL
, NULL
);
53 /* free the panel to save some memory. Not needed otherwise. */
54 WMFreeFilePanel(WMGetOpenPanel(scr
));
59 testFontPanel(WMScreen
*scr
)
65 panel
= WMGetFontPanel(scr
);
67 WMShowFontPanel(panel
);
69 /*WMFreeFontPanel(panel);*/
75 testFrame(WMScreen
*scr
)
80 static char* titles
[] = {
88 static WMTitlePosition pos
[] = {
99 win
= WMCreateWindow(scr
, "testFrame");
100 WMSetWindowTitle(win
, "Frame");
101 WMSetWindowCloseAction(win
, closeAction
, NULL
);
102 WMResizeWidget(win
, 400, 300);
104 for (i
= 0; i
< 6; i
++) {
105 frame
= WMCreateFrame(win
);
106 WMMoveWidget(frame
, 8+(i
%3)*130, 8+(i
/3)*130);
107 WMResizeWidget(frame
, 120, 120);
108 WMSetFrameTitle(frame
, titles
[i
]);
109 WMSetFrameTitlePosition(frame
, pos
[i
]);
112 WMRealizeWidget(win
);
113 WMMapSubwidgets(win
);
120 resizedWindow(void *self, WMNotification *notif)
122 WMView *view = (WMView*)WMGetNotificationObject(notif);
123 WMSize size = WMGetViewSize(view);
125 WMResizeWidget((WMWidget*)self, size.width, size.height);
129 testBox(WMScreen
*scr
)
139 win
= WMCreateWindow(scr
, "testBox");
140 WMSetWindowTitle(win
, "Box");
141 WMSetWindowCloseAction(win
, closeAction
, NULL
);
142 WMResizeWidget(win
, 400, 300);
144 box
= WMCreateBox(win
);
145 WMSetBoxBorderWidth(box
, 5);
146 WMSetViewExpandsToParent(WMWidgetView(box
), 0, 0, 0, 0);
148 /*WMSetBoxHorizontal(box, True);*/
149 for (i
= 0; i
< 4; i
++) {
150 btn
= WMCreateCommandButton(box
);
151 WMSetButtonText(btn
, "bla");
153 WMAddBoxSubview(box
, WMWidgetView(btn
), i
&1, True
, 20, 0, 5);
156 pop
= WMCreatePopUpButton(box
);
157 WMAddPopUpButtonItem(pop
, "ewqeq");
158 WMAddPopUpButtonItem(pop
, "ewqeqrewrw");
159 WMAddBoxSubview(box
, WMWidgetView(pop
), False
, True
, 20, 0, 5);
162 hbox
= WMCreateBox(box
);
163 WMSetBoxHorizontal(hbox
, True
);
164 WMAddBoxSubview(box
, WMWidgetView(hbox
), False
, True
, 24, 0, 0);
167 for (i
= 0; i
< 4; i
++) {
168 btn
= WMCreateCommandButton(hbox
);
169 WMSetButtonText(btn
, "bla");
171 WMAddBoxSubview(hbox
, WMWidgetView(btn
), 1, True
, 60, 0, i
<3?5:0);
175 WMRealizeWidget(win
);
176 WMMapSubwidgets(win
);
184 singleClick(WMWidget
*self
, void *data
)
190 doubleClick(WMWidget
*self
, void *data
)
192 WMSelectAllListItems((WMList
*)self
);
197 listSelectionObserver(void *observer
, WMNotification
*notification
)
199 WMLabel
*label
= (WMLabel
*)observer
;
200 WMList
*lPtr
= (WMList
*)WMGetNotificationObject(notification
);
203 sprintf(buf
, "Selected items: %d",
204 WMGetArrayItemCount(WMGetListSelectedItems(lPtr
)));
205 WMSetLabelText(label
, buf
);
210 testList(WMScreen
*scr
)
224 win
= WMCreateWindow(scr
, "testList");
225 WMResizeWidget(win
, 370, 250);
226 WMSetWindowTitle(win
, "List");
227 WMSetWindowCloseAction(win
, closeAction
, NULL
);
229 title
= WMCreateLabel(win
);
230 WMResizeWidget(title
, 150, 20);
231 WMMoveWidget(title
, 10, 10);
232 WMSetLabelRelief(title
, WRRidge
);
233 WMSetLabelText(title
, "Single selection list");
235 mtitle
= WMCreateLabel(win
);
236 WMResizeWidget(mtitle
, 150, 20);
237 WMMoveWidget(mtitle
, 210, 10);
238 WMSetLabelRelief(mtitle
, WRRidge
);
239 WMSetLabelText(mtitle
, "Multiple selection list");
241 list
= WMCreateList(win
);
242 /*WMSetListAllowEmptySelection(list, True);*/
243 WMMoveWidget(list
, 10, 40);
244 for (i
=0; i
<105; i
++) {
245 sprintf(text
, "Item %i", i
);
246 WMAddListItem(list
, text
);
248 mlist
= WMCreateList(win
);
249 WMSetListAllowMultipleSelection(mlist
, True
);
250 /*WMSetListAllowEmptySelection(mlist, True);*/
251 WMMoveWidget(mlist
, 210, 40);
252 for (i
=0; i
<135; i
++) {
253 sprintf(text
, "Item %i", i
);
254 WMAddListItem(mlist
, text
);
257 label
= WMCreateLabel(win
);
258 WMResizeWidget(label
, 150, 40);
259 WMMoveWidget(label
, 10, 200);
260 WMSetLabelRelief(label
, WRRidge
);
261 WMSetLabelText(label
, "Selected items: 0");
263 mlabel
= WMCreateLabel(win
);
264 WMResizeWidget(mlabel
, 150, 40);
265 WMMoveWidget(mlabel
, 210, 200);
266 WMSetLabelRelief(mlabel
, WRRidge
);
267 WMSetLabelText(mlabel
, "Selected items: 0");
269 WMSetListAction(list
, singleClick
, label
);
270 WMSetListDoubleAction(list
, doubleClick
, label
);
271 WMSetListAction(mlist
, singleClick
, mlabel
);
272 WMSetListDoubleAction(mlist
, doubleClick
, mlabel
);
274 WMAddNotificationObserver(listSelectionObserver
, label
,
275 WMListSelectionDidChangeNotification
, list
);
276 WMAddNotificationObserver(listSelectionObserver
, mlabel
,
277 WMListSelectionDidChangeNotification
, mlist
);
280 WMRealizeWidget(win
);
281 WMMapSubwidgets(win
);
287 testButton(WMScreen
*scr
)
304 win
= WMCreateWindow(scr
, "testButton");
305 WMResizeWidget(win
, 300, 300);
306 WMSetWindowTitle(win
, "Buttons");
308 WMSetWindowCloseAction(win
, closeAction
, NULL
);
310 for (i
= 1; i
< 9; i
++) {
312 b
= WMCreateButton(win
, i
);
313 WMResizeWidget(b
, 150, 24);
314 WMMoveWidget(b
, 20, i
*30);
315 WMSetButtonText(b
, types
[i
-1]);
318 WMRealizeWidget(win
);
319 WMMapSubwidgets(win
);
325 testGradientButtons(WMScreen
*scr
)
329 WMPixmap
*pix1
, *pix2
;
332 WMColor
*color
, *altColor
;
336 /* creates the top-level window */
337 win
= WMCreateWindow(scr
, "testGradientButtons");
338 WMSetWindowTitle(win
, "Gradiented Button Demo");
339 WMResizeWidget(win
, 300, 200);
341 WMSetWindowCloseAction(win
, closeAction
, NULL
);
351 color
= WMCreateRGBColor(scr
, 0x5900, 0x5100, 0x5900, True
);
352 WMSetWidgetBackgroundColor(win
, color
);
353 WMReleaseColor(color
);
355 back
= RRenderGradient(60, 24, &dark
, &light
, RGRD_DIAGONAL
);
356 RBevelImage(back
, RBEV_RAISED2
);
357 pix1
= WMCreatePixmapFromRImage(scr
, back
, 0);
360 back
= RRenderGradient(60, 24, &dark
, &light
, RGRD_DIAGONAL
);
361 RBevelImage(back
, RBEV_SUNKEN
);
362 pix2
= WMCreatePixmapFromRImage(scr
, back
, 0);
365 color
= WMWhiteColor(scr
);
366 altColor
= WMCreateNamedColor(scr
, "red", True
);
368 btn
= WMCreateButton(win
, WBTMomentaryChange
);
369 WMResizeWidget(btn
, 60, 24);
370 WMMoveWidget(btn
, 20, 100);
371 WMSetButtonBordered(btn
, False
);
372 WMSetButtonImagePosition(btn
, WIPOverlaps
);
373 WMSetButtonImage(btn
, pix1
);
374 WMSetButtonAltImage(btn
, pix2
);
375 WMSetButtonText(btn
, "Cool");
376 WMSetButtonTextColor(btn
, color
);
377 WMSetButtonAltTextColor(btn
, altColor
);
379 WMSetBalloonTextForView("This is a cool button", WMWidgetView(btn
));
381 btn
= WMCreateButton(win
, WBTMomentaryChange
);
382 WMResizeWidget(btn
, 60, 24);
383 WMMoveWidget(btn
, 90, 100);
384 WMSetButtonBordered(btn
, False
);
385 WMSetButtonImagePosition(btn
, WIPOverlaps
);
386 WMSetButtonImage(btn
, pix1
);
387 WMSetButtonAltImage(btn
, pix2
);
388 WMSetButtonText(btn
, "Button");
389 WMSetButtonTextColor(btn
, color
);
391 WMSetBalloonTextForView("Este é outro balão.", WMWidgetView(btn
));
393 WMReleaseColor(color
);
394 color
= WMCreateNamedColor(scr
, "orange", True
);
396 btn
= WMCreateButton(win
, WBTMomentaryChange
);
397 WMResizeWidget(btn
, 60, 24);
398 WMMoveWidget(btn
, 160, 100);
399 WMSetButtonBordered(btn
, False
);
400 WMSetButtonImagePosition(btn
, WIPOverlaps
);
401 WMSetButtonImage(btn
, pix1
);
402 WMSetButtonAltImage(btn
, pix2
);
403 WMSetButtonText(btn
, "Test");
404 WMSetButtonTextColor(btn
, color
);
406 WMSetBalloonTextForView("This is yet another button.\nBut the balloon has 3 lines.\nYay!",
409 WMReleaseColor(color
);
410 WMReleaseColor(altColor
);
412 WMRealizeWidget(win
);
413 WMMapSubwidgets(win
);
419 testScrollView(WMScreen
*scr
)
430 /* creates the top-level window */
431 win
= WMCreateWindow(scr
, "testScroll");
432 WMSetWindowTitle(win
, "Scrollable View");
434 WMSetWindowCloseAction(win
, closeAction
, NULL
);
436 /* set the window size */
437 WMResizeWidget(win
, 300, 300);
439 /* creates a scrollable view inside the top-level window */
440 sview
= WMCreateScrollView(win
);
441 WMResizeWidget(sview
, 200, 200);
442 WMMoveWidget(sview
, 30, 30);
443 WMSetScrollViewRelief(sview
, WRSunken
);
444 WMSetScrollViewHasVerticalScroller(sview
, True
);
445 WMSetScrollViewHasHorizontalScroller(sview
, True
);
447 /* create a frame with a bunch of labels */
448 f
= WMCreateFrame(win
);
449 WMResizeWidget(f
, 400, 400);
450 WMSetFrameRelief(f
, WRFlat
);
452 for (i
=0; i
<20; i
++) {
453 l
= WMCreateLabel(f
);
454 WMResizeWidget(l
, 50, 18);
455 WMMoveWidget(l
, 10, 20*i
);
456 sprintf(buffer
, "Label %i", i
);
457 WMSetLabelText(l
, buffer
);
458 WMSetLabelRelief(l
, WRSimple
);
463 WMSetScrollViewContentView(sview
, WMWidgetView(f
));
465 /* make the windows of the widgets be actually created */
466 WMRealizeWidget(win
);
468 /* Map all child widgets of the top-level be mapped.
469 * You must call this for each container widget (like frames),
470 * even if they are childs of the top-level window.
472 WMMapSubwidgets(win
);
474 /* map the top-level window */
480 testColorWell(WMScreen
*scr
)
483 WMColorWell
*well1
, *well2
;
487 win
= WMCreateWindow(scr
, "testColor");
488 WMResizeWidget(win
, 300, 300);
489 WMSetWindowCloseAction(win
, closeAction
, NULL
);
491 well1
= WMCreateColorWell(win
);
492 WMResizeWidget(well1
, 60, 40);
493 WMMoveWidget(well1
, 100, 100);
494 WMSetColorWellColor(well1
, WMCreateRGBColor(scr
, 0x8888, 0, 0x1111, True
));
495 well2
= WMCreateColorWell(win
);
496 WMResizeWidget(well2
, 60, 40);
497 WMMoveWidget(well2
, 200, 100);
498 WMSetColorWellColor(well2
, WMCreateRGBColor(scr
, 0, 0, 0x8888, True
));
500 WMRealizeWidget(win
);
501 WMMapSubwidgets(win
);
507 testColorPanel(WMScreen
*scr
)
509 WMColorPanel
*panel
= WMGetColorPanel(scr
);
512 startcolor = WMCreateNamedColor(scr, colorname, False);
513 WMSetColorPanelColor(panel, startcolor);
514 WMReleaseColor(startcolor);
517 WMShowColorPanel(panel
);
521 sliderCallback(WMWidget
*w
, void *data
)
523 printf("SLIDER == %i\n", WMGetSliderValue(w
));
528 testSlider(WMScreen
*scr
)
535 win
= WMCreateWindow(scr
, "testSlider");
536 WMResizeWidget(win
, 300, 300);
537 WMSetWindowTitle(win
, "Sliders");
539 WMSetWindowCloseAction(win
, closeAction
, NULL
);
541 s
= WMCreateSlider(win
);
542 WMResizeWidget(s
, 16, 100);
543 WMMoveWidget(s
, 100, 100);
544 WMSetSliderKnobThickness(s
, 8);
545 WMSetSliderContinuous(s
, False
);
546 WMSetSliderAction(s
, sliderCallback
, s
);
548 s
= WMCreateSlider(win
);
549 WMResizeWidget(s
, 100, 16);
550 WMMoveWidget(s
, 100, 10);
551 WMSetSliderKnobThickness(s
, 8);
553 WMRealizeWidget(win
);
554 WMMapSubwidgets(win
);
560 testTextField(WMScreen
*scr
)
563 WMTextField
*field
, *field2
;
567 win
= WMCreateWindow(scr
, "testTextField");
568 WMResizeWidget(win
, 400, 300);
570 WMSetWindowCloseAction(win
, closeAction
, NULL
);
572 field
= WMCreateTextField(win
);
573 WMResizeWidget(field
, 200, 20);
574 WMMoveWidget(field
, 20, 20);
575 WMSetTextFieldText(field
, "the little \xc2\xa9 sign");
577 field2
= WMCreateTextField(win
);
578 WMResizeWidget(field2
, 200, 20);
579 WMMoveWidget(field2
, 20, 50);
580 WMSetTextFieldAlignment(field2
, WARight
);
582 WMRealizeWidget(win
);
583 WMMapSubwidgets(win
);
590 testText(WMScreen
*scr
)
596 FILE *file
= fopen("wm.html", "rb");
600 win
= WMCreateWindow(scr
, "testText");
601 WMResizeWidget(win
, 500, 300);
603 WMSetWindowCloseAction(win
, closeAction
, NULL
);
605 text
= WMCreateText(win
);
606 WMResizeWidget(text
, 480, 280);
607 WMMoveWidget(text
, 10, 10);
608 WMSetTextHasVerticalScroller(text
, True
);
609 WMSetTextEditable(text
, False
);
610 WMSetTextIgnoresNewline(text
, False
);
612 #define FNAME "Verdana,Luxi Sans:pixelsize=12"
614 "Window Maker is the GNU window manager for the " \
615 "X Window System. It was designed to emulate the " \
616 "look and feel of part of the NEXTSTEP(tm) GUI. It's " \
617 "supposed to be relatively fast and small, feature " \
618 "rich, easy to configure and easy to use, with a simple " \
619 "and elegant appearance borrowed from NEXTSTEP(tm)."
621 font
= WMCreateFont(scr
, FNAME
":autohint=false");
622 WMSetTextDefaultFont(text
, font
);
629 while(fgets(buf
, 1023, file
))
630 WMAppendTextStream(text
, buf
);
635 WMAppendTextStream(text
, "First paragraph has autohinting turned off, "
636 "while the second has it turned on:");
637 WMAppendTextStream(text
, "\n\n\n");
638 WMAppendTextStream(text
, MSG
);
639 WMAppendTextStream(text
, "\n\n\n");
640 font
= WMCreateFont(scr
, FNAME
":autohint=true");
641 tb
= WMCreateTextBlockWithText(text
, MSG
, font
, WMBlackColor(scr
),
643 WMAppendTextBlock(text
, tb
);
647 WMRealizeWidget(win
);
648 WMMapSubwidgets(win
);
654 testProgressIndicator(WMScreen
*scr
)
657 WMProgressIndicator
*pPtr
;
661 win
= WMCreateWindow(scr
, "testProgressIndicator");
662 WMResizeWidget(win
, 292, 32);
664 WMSetWindowCloseAction(win
, closeAction
, NULL
);
666 pPtr
= WMCreateProgressIndicator(win
);
667 WMMoveWidget(pPtr
, 8, 8);
668 WMSetProgressIndicatorValue(pPtr
, 75);
670 WMRealizeWidget(win
);
671 WMMapSubwidgets(win
);
678 testPullDown(WMScreen
*scr
)
681 WMPopUpButton
*pop
, *pop2
;
685 win
= WMCreateWindow(scr
, "pullDown");
686 WMResizeWidget(win
, 400, 300);
688 WMSetWindowCloseAction(win
, closeAction
, NULL
);
690 pop
= WMCreatePopUpButton(win
);
691 WMResizeWidget(pop
, 100, 20);
692 WMMoveWidget(pop
, 50, 60);
693 WMSetPopUpButtonPullsDown(pop
, True
);
694 WMSetPopUpButtonText(pop
, "Commands");
695 WMAddPopUpButtonItem(pop
, "Add");
696 WMAddPopUpButtonItem(pop
, "Remove");
697 WMAddPopUpButtonItem(pop
, "Check");
698 WMAddPopUpButtonItem(pop
, "Eat");
700 pop2
= WMCreatePopUpButton(win
);
701 WMResizeWidget(pop2
, 100, 20);
702 WMMoveWidget(pop2
, 200, 60);
703 WMSetPopUpButtonText(pop2
, "Select");
704 WMAddPopUpButtonItem(pop2
, "Apples");
705 WMAddPopUpButtonItem(pop2
, "Bananas");
706 WMAddPopUpButtonItem(pop2
, "Strawberries");
707 WMAddPopUpButtonItem(pop2
, "Blueberries");
709 WMRealizeWidget(win
);
710 WMMapSubwidgets(win
);
717 testTabView(WMScreen
*scr
)
727 win
= WMCreateWindow(scr
, "testTabs");
728 WMResizeWidget(win
, 400, 300);
730 WMSetWindowCloseAction(win
, closeAction
, NULL
);
732 tabv
= WMCreateTabView(win
);
733 WMMoveWidget(tabv
, 50, 50);
734 WMResizeWidget(tabv
, 300, 200);
736 frame
= WMCreateFrame(win
);
737 WMSetFrameRelief(frame
, WRFlat
);
738 label
= WMCreateLabel(frame
);
739 WMResizeWidget(label
, 100, 100);
740 WMSetLabelText(label
, "Label 1");
744 tab
= WMCreateTabViewItemWithIdentifier(0);
745 WMSetTabViewItemView(tab
, WMWidgetView(frame
));
746 WMAddItemInTabView(tabv
, tab
);
747 WMSetTabViewItemLabel(tab
, "Instances");
749 frame
= WMCreateFrame(win
);
750 WMSetFrameRelief(frame
, WRFlat
);
751 label
= WMCreateLabel(frame
);
752 WMResizeWidget(label
, 40, 50);
753 WMSetLabelText(label
, "Label 2");
757 tab
= WMCreateTabViewItemWithIdentifier(0);
758 WMSetTabViewItemView(tab
, WMWidgetView(frame
));
759 WMAddItemInTabView(tabv
, tab
);
760 WMSetTabViewItemLabel(tab
, "Classes");
763 frame
= WMCreateFrame(win
);
764 WMSetFrameRelief(frame
, WRFlat
);
765 label
= WMCreateLabel(frame
);
766 WMResizeWidget(label
, 100, 100);
767 WMMoveWidget(label
, 60, 40);
768 WMSetLabelText(label
, "Label 3");
771 tab
= WMCreateTabViewItemWithIdentifier(0);
772 WMSetTabViewItemView(tab
, WMWidgetView(frame
));
773 WMAddItemInTabView(tabv
, tab
);
774 WMSetTabViewItemLabel(tab
, "Something");
777 frame
= WMCreateFrame(win
);
778 WMSetFrameRelief(frame
, WRFlat
);
779 label
= WMCreateLabel(frame
);
780 WMResizeWidget(label
, 100, 100);
781 WMMoveWidget(label
, 160, 40);
782 WMSetLabelText(label
, "Label 4");
785 tab
= WMCreateTabViewItemWithIdentifier(0);
786 WMSetTabViewItemView(tab
, WMWidgetView(frame
));
787 WMAddItemInTabView(tabv
, tab
);
788 WMSetTabViewItemLabel(tab
, "Bla!");
792 frame
= WMCreateFrame(win
);
793 WMSetFrameRelief(frame
, WRFlat
);
794 label
= WMCreateLabel(frame
);
795 WMResizeWidget(label
, 100, 100);
796 WMMoveWidget(label
, 160, 40);
797 WMSetLabelText(label
, "Label fjweqklrj qwl");
799 tab
= WMCreateTabViewItemWithIdentifier(0);
800 WMSetTabViewItemView(tab
, WMWidgetView(frame
));
801 WMAddItemInTabView(tabv
, tab
);
802 WMSetTabViewItemLabel(tab
, "Weee!");
805 WMRealizeWidget(win
);
806 WMMapSubwidgets(win
);
812 splitViewConstrainProc(WMSplitView
*sPtr
, int indView
,
813 int *minSize
, int *maxSize
)
833 resizeSplitView(XEvent
*event
, void *data
)
835 WMSplitView
*sPtr
= (WMSplitView
*)data
;
837 if (event
->type
== ConfigureNotify
) {
838 int width
= event
->xconfigure
.width
- 10;
840 if (width
< WMGetSplitViewDividerThickness(sPtr
))
841 width
= WMGetSplitViewDividerThickness(sPtr
);
843 if (width
!= WMWidgetWidth(sPtr
) ||
844 event
->xconfigure
.height
!= WMWidgetHeight(sPtr
))
845 WMResizeWidget(sPtr
, width
, event
->xconfigure
.height
- 55);
850 appendSubviewButtonAction(WMWidget
*self
, void *data
)
852 WMSplitView
*sPtr
= (WMSplitView
*)data
;
854 WMLabel
*label
= WMCreateLabel(sPtr
);
856 sprintf(buf
, "Subview %d", WMGetSplitViewSubviewsCount(sPtr
) + 1);
857 WMSetLabelText(label
, buf
);
858 WMSetLabelRelief(label
, WRSunken
);
859 WMAddSplitViewSubview(sPtr
, WMWidgetView(label
));
860 WMRealizeWidget(label
);
865 removeSubviewButtonAction(WMWidget
*self
, void *data
)
867 WMSplitView
*sPtr
= (WMSplitView
*)data
;
868 int count
= WMGetSplitViewSubviewsCount(sPtr
);
871 WMView
*view
= WMGetSplitViewSubviewAt(sPtr
, count
-1);
872 WMDestroyWidget(WMWidgetOfView(view
));
873 WMRemoveSplitViewSubviewAt(sPtr
, count
-1);
878 orientationButtonAction(WMWidget
*self
, void *data
)
880 WMSplitView
*sPtr
= (WMSplitView
*)data
;
881 WMSetSplitViewVertical(sPtr
, !WMGetSplitViewVertical(sPtr
));
885 adjustSubviewsButtonAction(WMWidget
*self
, void *data
)
887 WMAdjustSplitViewSubviews((WMSplitView
*)data
);
891 testSplitView(WMScreen
*scr
)
894 WMSplitView
*splitv1
, *splitv2
;
901 win
= WMCreateWindow(scr
, "testTabs");
902 WMResizeWidget(win
, 300, 400);
903 WMSetWindowCloseAction(win
, closeAction
, NULL
);
905 frame
= WMCreateFrame(win
);
906 WMSetFrameRelief(frame
, WRSunken
);
907 WMMoveWidget(frame
, 5, 5);
908 WMResizeWidget(frame
, 290, 40);
910 splitv1
= WMCreateSplitView(win
);
911 WMMoveWidget(splitv1
, 5, 50);
912 WMResizeWidget(splitv1
, 290, 345);
913 WMSetSplitViewConstrainProc(splitv1
, splitViewConstrainProc
);
914 WMCreateEventHandler(WMWidgetView(win
), StructureNotifyMask
,
915 resizeSplitView
, splitv1
);
917 button
= WMCreateCommandButton(frame
);
918 WMSetButtonText(button
, "+");
919 WMSetButtonAction(button
, appendSubviewButtonAction
, splitv1
);
920 WMMoveWidget(button
, 10, 8);
923 button
= WMCreateCommandButton(frame
);
924 WMSetButtonText(button
, "-");
925 WMSetButtonAction(button
, removeSubviewButtonAction
, splitv1
);
926 WMMoveWidget(button
, 80, 8);
929 button
= WMCreateCommandButton(frame
);
930 WMSetButtonText(button
, "=");
931 WMMoveWidget(button
, 150, 8);
932 WMSetButtonAction(button
, adjustSubviewsButtonAction
, splitv1
);
935 button
= WMCreateCommandButton(frame
);
936 WMSetButtonText(button
, "#");
937 WMMoveWidget(button
, 220, 8);
938 WMSetButtonAction(button
, orientationButtonAction
, splitv1
);
941 label
= WMCreateLabel(splitv1
);
942 WMSetLabelText(label
, "Subview 1");
943 WMSetLabelRelief(label
, WRSunken
);
945 WMAddSplitViewSubview(splitv1
, WMWidgetView(label
));
947 splitv2
= WMCreateSplitView(splitv1
);
948 WMResizeWidget(splitv2
, 150, 150);
949 WMSetSplitViewVertical(splitv2
, True
);
951 label
= WMCreateLabel(splitv2
);
952 WMSetLabelText(label
, "Subview 2.1");
953 WMSetLabelRelief(label
, WRSunken
);
955 WMAddSplitViewSubview(splitv2
, WMWidgetView(label
));
957 label
= WMCreateLabel(splitv2
);
958 WMSetLabelText(label
, "Subview 2.2");
959 WMSetLabelRelief(label
, WRSunken
);
961 WMAddSplitViewSubview(splitv2
, WMWidgetView(label
));
963 label
= WMCreateLabel(splitv2
);
964 WMSetLabelText(label
, "Subview 2.3");
965 WMSetLabelRelief(label
, WRSunken
);
967 WMAddSplitViewSubview(splitv2
, WMWidgetView(label
));
969 WMMapWidget(splitv2
);
970 WMAddSplitViewSubview(splitv1
, WMWidgetView(splitv2
));
972 WMRealizeWidget(win
);
973 WMMapSubwidgets(win
);
981 WMUserDefaults
*defs
;
984 defs
= WMGetStandardUserDefaults();
986 sprintf(str
, "TEST DATA");
988 WMSetUDStringForKey(defs
, str
, "testKey");
994 main(int argc
, char **argv
)
1000 /* Initialize the application */
1001 WMInitializeApplication("Test@eqweq_ewq$eqw", &argc
, argv
);
1006 * Open connection to the X display.
1008 dpy
= XOpenDisplay("");
1011 puts("could not open display");
1015 /* This is used to disable buffering of X protocol requests.
1016 * Do NOT use it unless when debugging. It will cause a major
1017 * slowdown in your application
1020 XSynchronize(dpy
, True
);
1023 * Create screen descriptor.
1025 scr
= WMCreateScreen(dpy
, DefaultScreen(dpy
));
1028 * Loads the logo of the application.
1030 pixmap
= WMCreatePixmapFromFile(scr
, "logo.xpm");
1033 * Makes the logo be used in standard dialog panels.
1036 WMSetApplicationIconPixmap(scr
, pixmap
);
1037 WMReleasePixmap(pixmap
);
1041 * Do some test stuff.
1043 * Put the testSomething() function you want to test here.
1049 testColorPanel(scr
);
1057 testColorPanel(scr
);
1059 testDragAndDrop(scr
);
1061 testGradientButtons(scr
);
1063 testOpenFilePanel(scr
);
1064 testProgressIndicator(scr
);
1066 testScrollView(scr
);
1073 * The main event loop.
1076 WMScreenMainLoop(scr
);