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 testFrame(WMScreen
*scr
)
78 static char* titles
[] = {
86 static WMTitlePosition pos
[] = {
97 win
= WMCreateWindow(scr
, "testFrame");
98 WMSetWindowTitle(win
, "Frame");
99 WMSetWindowCloseAction(win
, closeAction
, NULL
);
100 WMResizeWidget(win
, 400, 300);
102 for (i
= 0; i
< 6; i
++) {
103 frame
= WMCreateFrame(win
);
104 WMMoveWidget(frame
, 8+(i
%3)*130, 8+(i
/3)*130);
105 WMResizeWidget(frame
, 120, 120);
106 WMSetFrameTitle(frame
, titles
[i
]);
107 WMSetFrameTitlePosition(frame
, pos
[i
]);
110 WMRealizeWidget(win
);
111 WMMapSubwidgets(win
);
117 testList(WMScreen
*scr
)
126 win
= WMCreateWindow(scr
, "testList");
127 WMSetWindowTitle(win
, "List");
128 WMSetWindowCloseAction(win
, closeAction
, NULL
);
130 list
= WMCreateList(win
);
131 for (i
=0; i
<50; i
++) {
132 sprintf(text
, "Item %i", i
);
133 WMAddListItem(list
, text
);
135 WMRealizeWidget(win
);
136 WMMapSubwidgets(win
);
144 testButton(WMScreen
*scr
)
161 win
= WMCreateWindow(scr
, "testButton");
162 WMResizeWidget(win
, 300, 300);
163 WMSetWindowTitle(win
, "Buttons");
165 WMSetWindowCloseAction(win
, closeAction
, NULL
);
167 for (i
= 1; i
< 9; i
++) {
169 b
= WMCreateButton(win
, i
);
170 WMResizeWidget(b
, 150, 24);
171 WMMoveWidget(b
, 20, i
*30);
172 WMSetButtonText(b
, types
[i
-1]);
175 WMRealizeWidget(win
);
176 WMMapSubwidgets(win
);
182 testGradientButtons(WMScreen
*scr
)
186 WMPixmap
*pix1
, *pix2
;
189 WMColor
*color
, *altColor
;
193 /* creates the top-level window */
194 win
= WMCreateWindow(scr
, "testGradientButtons");
195 WMSetWindowTitle(win
, "Gradiented Button Demo");
196 WMResizeWidget(win
, 300, 200);
205 color
= WMCreateRGBColor(scr
, 0x5900, 0x5100, 0x5900, True
);
206 WMSetWidgetBackgroundColor(win
, color
);
207 WMReleaseColor(color
);
209 back
= RRenderGradient(60, 24, &dark
, &light
, RGRD_DIAGONAL
);
210 RBevelImage(back
, RBEV_RAISED2
);
211 pix1
= WMCreatePixmapFromRImage(scr
, back
, 0);
214 back
= RRenderGradient(60, 24, &dark
, &light
, RGRD_DIAGONAL
);
215 RBevelImage(back
, RBEV_SUNKEN
);
216 pix2
= WMCreatePixmapFromRImage(scr
, back
, 0);
219 color
= WMWhiteColor(scr
);
220 altColor
= WMCreateNamedColor(scr
, "red", True
);
222 btn
= WMCreateButton(win
, WBTMomentaryChange
);
223 WMResizeWidget(btn
, 60, 24);
224 WMMoveWidget(btn
, 20, 100);
225 WMSetButtonBordered(btn
, False
);
226 WMSetButtonImagePosition(btn
, WIPOverlaps
);
227 WMSetButtonImage(btn
, pix1
);
228 WMSetButtonAltImage(btn
, pix2
);
229 WMSetButtonText(btn
, "Cool");
230 WMSetButtonTextColor(btn
, color
);
231 WMSetButtonAltTextColor(btn
, altColor
);
233 WMSetBalloonTextForView("This is a cool button", WMWidgetView(btn
));
235 btn
= WMCreateButton(win
, WBTMomentaryChange
);
236 WMResizeWidget(btn
, 60, 24);
237 WMMoveWidget(btn
, 90, 100);
238 WMSetButtonBordered(btn
, False
);
239 WMSetButtonImagePosition(btn
, WIPOverlaps
);
240 WMSetButtonImage(btn
, pix1
);
241 WMSetButtonAltImage(btn
, pix2
);
242 WMSetButtonText(btn
, "Button");
243 WMSetButtonTextColor(btn
, color
);
245 WMSetBalloonTextForView("Este é outro balão.", WMWidgetView(btn
));
247 WMReleaseColor(color
);
248 color
= WMCreateNamedColor(scr
, "orange", True
);
250 btn
= WMCreateButton(win
, WBTMomentaryChange
);
251 WMResizeWidget(btn
, 60, 24);
252 WMMoveWidget(btn
, 160, 100);
253 WMSetButtonBordered(btn
, False
);
254 WMSetButtonImagePosition(btn
, WIPOverlaps
);
255 WMSetButtonImage(btn
, pix1
);
256 WMSetButtonAltImage(btn
, pix2
);
257 WMSetButtonText(btn
, "Test");
258 WMSetButtonTextColor(btn
, color
);
260 WMSetBalloonTextForView("This is yet another button.\nBut the balloon has 3 lines.\nYay!",
263 WMReleaseColor(color
);
264 WMReleaseColor(altColor
);
266 WMRealizeWidget(win
);
267 WMMapSubwidgets(win
);
273 testScrollView(WMScreen
*scr
)
284 /* creates the top-level window */
285 win
= WMCreateWindow(scr
, "testScroll");
286 WMSetWindowTitle(win
, "Scrollable View");
288 WMSetWindowCloseAction(win
, closeAction
, NULL
);
290 /* set the window size */
291 WMResizeWidget(win
, 300, 300);
293 /* creates a scrollable view inside the top-level window */
294 sview
= WMCreateScrollView(win
);
295 WMResizeWidget(sview
, 200, 200);
296 WMMoveWidget(sview
, 30, 30);
297 WMSetScrollViewRelief(sview
, WRSunken
);
298 WMSetScrollViewHasVerticalScroller(sview
, True
);
299 WMSetScrollViewHasHorizontalScroller(sview
, True
);
301 /* create a frame with a bunch of labels */
302 f
= WMCreateFrame(win
);
303 WMResizeWidget(f
, 400, 400);
304 WMSetFrameRelief(f
, WRFlat
);
306 for (i
=0; i
<20; i
++) {
307 l
= WMCreateLabel(f
);
308 WMResizeWidget(l
, 50, 18);
309 WMMoveWidget(l
, 10, 20*i
);
310 sprintf(buffer
, "Label %i", i
);
311 WMSetLabelText(l
, buffer
);
312 WMSetLabelRelief(l
, WRSimple
);
317 WMSetScrollViewContentView(sview
, WMWidgetView(f
));
319 /* make the windows of the widgets be actually created */
320 WMRealizeWidget(win
);
322 /* Map all child widgets of the top-level be mapped.
323 * You must call this for each container widget (like frames),
324 * even if they are childs of the top-level window.
326 WMMapSubwidgets(win
);
328 /* map the top-level window */
334 testColorWell(WMScreen
*scr
)
337 WMColorWell
*well1
, *well2
;
341 win
= WMCreateWindow(scr
, "testColor");
342 WMResizeWidget(win
, 300, 300);
344 WMSetWindowCloseAction(win
, closeAction
, NULL
);
346 well1
= WMCreateColorWell(win
);
347 WMResizeWidget(well1
, 60, 40);
348 WMMoveWidget(well1
, 100, 100);
349 WMSetColorWellColor(well1
, WMCreateRGBColor(scr
, 0x8888, 0, 0x1111, True
));
350 well2
= WMCreateColorWell(win
);
351 WMResizeWidget(well2
, 60, 40);
352 WMMoveWidget(well2
, 200, 100);
353 WMSetColorWellColor(well2
, WMCreateRGBColor(scr
, 0, 0, 0x8888, True
));
355 WMRealizeWidget(win
);
356 WMMapSubwidgets(win
);
361 sliderCallback(WMWidget
*w
, void *data
)
363 printf("SLIEDER == %i\n", WMGetSliderValue(w
));
368 testSlider(WMScreen
*scr
)
375 win
= WMCreateWindow(scr
, "testSlider");
376 WMResizeWidget(win
, 300, 300);
377 WMSetWindowTitle(win
, "Sliders");
379 WMSetWindowCloseAction(win
, closeAction
, NULL
);
381 s
= WMCreateSlider(win
);
382 WMResizeWidget(s
, 16, 100);
383 WMMoveWidget(s
, 100, 100);
384 WMSetSliderKnobThickness(s
, 8);
385 WMSetSliderContinuous(s
, False
);
386 WMSetSliderAction(s
, sliderCallback
, s
);
388 s
= WMCreateSlider(win
);
389 WMResizeWidget(s
, 100, 16);
390 WMMoveWidget(s
, 100, 10);
391 WMSetSliderKnobThickness(s
, 8);
393 WMRealizeWidget(win
);
394 WMMapSubwidgets(win
);
400 testTextField(WMScreen
*scr
)
403 WMTextField
*field
, *field2
;
407 win
= WMCreateWindow(scr
, "testText");
408 WMResizeWidget(win
, 400, 300);
410 WMSetWindowCloseAction(win
, closeAction
, NULL
);
412 field
= WMCreateTextField(win
);
413 WMResizeWidget(field
, 200, 20);
414 WMMoveWidget(field
, 20, 20);
416 field2
= WMCreateTextField(win
);
417 WMResizeWidget(field2
, 200, 20);
418 WMMoveWidget(field2
, 20, 50);
419 WMSetTextFieldAlignment(field2
, WARight
);
421 WMRealizeWidget(win
);
422 WMMapSubwidgets(win
);
429 testProgressIndicator(WMScreen
*scr
)
432 WMProgressIndicator
*pPtr
;
436 win
= WMCreateWindow(scr
, "testProgressIndicator");
437 WMResizeWidget(win
, 292, 32);
439 WMSetWindowCloseAction(win
, closeAction
, NULL
);
441 pPtr
= WMCreateProgressIndicator(win
);
442 WMMoveWidget(pPtr
, 8, 8);
443 WMSetProgressIndicatorValue(pPtr
, 75);
445 WMRealizeWidget(win
);
446 WMMapSubwidgets(win
);
453 testPullDown(WMScreen
*scr
)
456 WMPopUpButton
*pop
, *pop2
;
460 win
= WMCreateWindow(scr
, "pullDown");
461 WMResizeWidget(win
, 400, 300);
463 WMSetWindowCloseAction(win
, closeAction
, NULL
);
465 pop
= WMCreatePopUpButton(win
);
466 WMResizeWidget(pop
, 100, 20);
467 WMMoveWidget(pop
, 50, 60);
468 WMSetPopUpButtonPullsDown(pop
, True
);
469 WMSetPopUpButtonText(pop
, "Commands");
470 WMAddPopUpButtonItem(pop
, "Add");
471 WMAddPopUpButtonItem(pop
, "Remove");
472 WMAddPopUpButtonItem(pop
, "Check");
473 WMAddPopUpButtonItem(pop
, "Eat");
475 pop2
= WMCreatePopUpButton(win
);
476 WMResizeWidget(pop2
, 100, 20);
477 WMMoveWidget(pop2
, 200, 60);
478 WMSetPopUpButtonText(pop2
, "Select");
479 WMAddPopUpButtonItem(pop2
, "Apples");
480 WMAddPopUpButtonItem(pop2
, "Bananas");
481 WMAddPopUpButtonItem(pop2
, "Strawberries");
482 WMAddPopUpButtonItem(pop2
, "Blueberries");
484 WMRealizeWidget(win
);
485 WMMapSubwidgets(win
);
492 testTabView(WMScreen
*scr
)
502 win
= WMCreateWindow(scr
, "testTabs");
503 WMResizeWidget(win
, 400, 300);
505 WMSetWindowCloseAction(win
, closeAction
, NULL
);
507 tabv
= WMCreateTabView(win
);
508 WMMoveWidget(tabv
, 50, 50);
509 WMResizeWidget(tabv
, 300, 200);
511 frame
= WMCreateFrame(win
);
512 WMSetFrameRelief(frame
, WRFlat
);
513 label
= WMCreateLabel(frame
);
514 WMResizeWidget(label
, 100, 100);
515 WMSetLabelText(label
, "Label 1");
519 tab
= WMCreateTabViewItemWithIdentifier(0);
520 WMSetTabViewItemView(tab
, WMWidgetView(frame
));
521 WMAddItemInTabView(tabv
, tab
);
522 WMSetTabViewItemLabel(tab
, "Instances");
524 frame
= WMCreateFrame(win
);
525 WMSetFrameRelief(frame
, WRFlat
);
526 label
= WMCreateLabel(frame
);
527 WMResizeWidget(label
, 40, 50);
528 WMSetLabelText(label
, "Label 2");
532 tab
= WMCreateTabViewItemWithIdentifier(0);
533 WMSetTabViewItemView(tab
, WMWidgetView(frame
));
534 WMAddItemInTabView(tabv
, tab
);
535 WMSetTabViewItemLabel(tab
, "Classes");
538 frame
= WMCreateFrame(win
);
539 WMSetFrameRelief(frame
, WRFlat
);
540 label
= WMCreateLabel(frame
);
541 WMResizeWidget(label
, 100, 100);
542 WMMoveWidget(label
, 60, 40);
543 WMSetLabelText(label
, "Label 3");
546 tab
= WMCreateTabViewItemWithIdentifier(0);
547 WMSetTabViewItemView(tab
, WMWidgetView(frame
));
548 WMAddItemInTabView(tabv
, tab
);
549 WMSetTabViewItemLabel(tab
, "Something");
552 frame
= WMCreateFrame(win
);
553 WMSetFrameRelief(frame
, WRFlat
);
554 label
= WMCreateLabel(frame
);
555 WMResizeWidget(label
, 100, 100);
556 WMMoveWidget(label
, 160, 40);
557 WMSetLabelText(label
, "Label 4");
560 tab
= WMCreateTabViewItemWithIdentifier(0);
561 WMSetTabViewItemView(tab
, WMWidgetView(frame
));
562 WMAddItemInTabView(tabv
, tab
);
563 WMSetTabViewItemLabel(tab
, "Bla!");
567 frame
= WMCreateFrame(win
);
568 WMSetFrameRelief(frame
, WRFlat
);
569 label
= WMCreateLabel(frame
);
570 WMResizeWidget(label
, 100, 100);
571 WMMoveWidget(label
, 160, 40);
572 WMSetLabelText(label
, "Label fjweqklrj qwl");
574 tab
= WMCreateTabViewItemWithIdentifier(0);
575 WMSetTabViewItemView(tab
, WMWidgetView(frame
));
576 WMAddItemInTabView(tabv
, tab
);
577 WMSetTabViewItemLabel(tab
, "Weee!");
580 WMRealizeWidget(win
);
581 WMMapSubwidgets(win
);
587 splitViewConstrainProc(WMSplitView
*sPtr
, int indView
,
588 int *minSize
, int *maxSize
)
608 resizeSplitView(XEvent
*event
, void *data
)
610 WMSplitView
*sPtr
= (WMSplitView
*)data
;
612 if (event
->type
== ConfigureNotify
) {
613 int width
= event
->xconfigure
.width
- 10;
615 if (width
< WMGetSplitViewDividerThickness(sPtr
))
616 width
= WMGetSplitViewDividerThickness(sPtr
);
618 if (width
!= WMWidgetWidth(sPtr
) ||
619 event
->xconfigure
.height
!= WMWidgetHeight(sPtr
))
620 WMResizeWidget(sPtr
, width
, event
->xconfigure
.height
- 55);
625 appendSubviewButtonAction(WMWidget
*self
, void *data
)
627 WMSplitView
*sPtr
= (WMSplitView
*)data
;
629 WMLabel
*label
= WMCreateLabel(sPtr
);
631 sprintf(buf
, "Subview %d", WMGetSplitViewSubviewsCount(sPtr
) + 1);
632 WMSetLabelText(label
, buf
);
633 WMSetLabelRelief(label
, WRSunken
);
634 WMAddSplitViewSubview(sPtr
, WMWidgetView(label
));
635 WMRealizeWidget(label
);
640 removeSubviewButtonAction(WMWidget
*self
, void *data
)
642 WMSplitView
*sPtr
= (WMSplitView
*)data
;
643 int count
= WMGetSplitViewSubviewsCount(sPtr
);
646 WMView
*view
= WMGetSplitViewSubviewAt(sPtr
, count
-1);
647 WMDestroyWidget(WMWidgetOfView(view
));
648 WMRemoveSplitViewSubviewAt(sPtr
, count
-1);
653 orientationButtonAction(WMWidget
*self
, void *data
)
655 WMSplitView
*sPtr
= (WMSplitView
*)data
;
656 WMSetSplitViewVertical(sPtr
, !WMGetSplitViewVertical(sPtr
));
660 adjustSubviewsButtonAction(WMWidget
*self
, void *data
)
662 WMAdjustSplitViewSubviews((WMSplitView
*)data
);
666 testSplitView(WMScreen
*scr
)
669 WMSplitView
*splitv1
, *splitv2
;
676 win
= WMCreateWindow(scr
, "testTabs");
677 WMResizeWidget(win
, 300, 400);
678 WMSetWindowCloseAction(win
, closeAction
, NULL
);
680 frame
= WMCreateFrame(win
);
681 WMSetFrameRelief(frame
, WRSunken
);
682 WMMoveWidget(frame
, 5, 5);
683 WMResizeWidget(frame
, 290, 40);
685 splitv1
= WMCreateSplitView(win
);
686 WMMoveWidget(splitv1
, 5, 50);
687 WMResizeWidget(splitv1
, 290, 345);
688 WMSetSplitViewConstrainProc(splitv1
, splitViewConstrainProc
);
689 WMCreateEventHandler(WMWidgetView(win
), StructureNotifyMask
,
690 resizeSplitView
, splitv1
);
692 button
= WMCreateCommandButton(frame
);
693 WMSetButtonText(button
, "+");
694 WMSetButtonAction(button
, appendSubviewButtonAction
, splitv1
);
695 WMMoveWidget(button
, 10, 8);
698 button
= WMCreateCommandButton(frame
);
699 WMSetButtonText(button
, "-");
700 WMSetButtonAction(button
, removeSubviewButtonAction
, splitv1
);
701 WMMoveWidget(button
, 80, 8);
704 button
= WMCreateCommandButton(frame
);
705 WMSetButtonText(button
, "=");
706 WMMoveWidget(button
, 150, 8);
707 WMSetButtonAction(button
, adjustSubviewsButtonAction
, splitv1
);
710 button
= WMCreateCommandButton(frame
);
711 WMSetButtonText(button
, "#");
712 WMMoveWidget(button
, 220, 8);
713 WMSetButtonAction(button
, orientationButtonAction
, splitv1
);
716 label
= WMCreateLabel(splitv1
);
717 WMSetLabelText(label
, "Subview 1");
718 WMSetLabelRelief(label
, WRSunken
);
720 WMAddSplitViewSubview(splitv1
, WMWidgetView(label
));
722 splitv2
= WMCreateSplitView(splitv1
);
723 WMResizeWidget(splitv2
, 150, 150);
724 WMSetSplitViewVertical(splitv2
, True
);
726 label
= WMCreateLabel(splitv2
);
727 WMSetLabelText(label
, "Subview 2.1");
728 WMSetLabelRelief(label
, WRSunken
);
730 WMAddSplitViewSubview(splitv2
, WMWidgetView(label
));
732 label
= WMCreateLabel(splitv2
);
733 WMSetLabelText(label
, "Subview 2.2");
734 WMSetLabelRelief(label
, WRSunken
);
736 WMAddSplitViewSubview(splitv2
, WMWidgetView(label
));
738 label
= WMCreateLabel(splitv2
);
739 WMSetLabelText(label
, "Subview 2.3");
740 WMSetLabelRelief(label
, WRSunken
);
742 WMAddSplitViewSubview(splitv2
, WMWidgetView(label
));
744 WMMapWidget(splitv2
);
745 WMAddSplitViewSubview(splitv1
, WMWidgetView(splitv2
));
747 WMRealizeWidget(win
);
748 WMMapSubwidgets(win
);
753 /*******************************************************************/
755 #include <sys/types.h>
767 getImage(WMScreen
*scr
, char *file
)
772 sprintf(buffer
, "../WindowMaker/Icons/%s", file
);
773 pix
= WMCreatePixmapFromFile(scr
, buffer
);
781 static void iconMouseStuff(XEvent
*event
, void *cdata
)
783 WMLabel
*label
= (WMLabel
*)cdata
;
784 DNDStuff
*stuff
= WMGetHangedData(label
);
787 switch (event
->type
) {
789 stuff
->x
= event
->xbutton
.x
;
790 stuff
->y
= event
->xbutton
.y
;
791 stuff
->mouseDown
= True
;
794 stuff
->mouseDown
= False
;
797 if (!stuff
->mouseDown
)
800 if (abs(stuff
->x
- event
->xmotion
.x
)>4
801 || abs(stuff
->y
- event
->xmotion
.y
)>4) {
803 where
= WMGetViewScreenPosition(WMWidgetView(label
));
805 WMDragImageFromView(WMWidgetView(label
),
806 WMGetLabelImage(label
),
809 wmksize(stuff
->x
, stuff
->y
),
817 static void endedDragImage(WMView
*self
, WMPixmap
*image
, WMPoint point
,
820 DNDStuff
*stuff
= WMGetHangedData(WMWidgetOfView(self
));
823 WMDestroyWidget(WMWidgetOfView(self
));
826 stuff
->mouseDown
= False
;
830 static WMData
* fetchDragData(WMView
*self
, char *type
)
832 DNDStuff
*stuff
= WMGetHangedData(WMWidgetOfView(self
));
834 return WMCreateDataWithBytes(stuff
->filename
, strlen(stuff
->filename
)+1);
838 WMDragSourceProcs dragSourceProcs
= {
846 /************************/
849 unsigned draggingEntered(WMView
*self
, WMDraggingInfo
*info
)
851 return WDOperationCopy
;
855 unsigned draggingUpdated(WMView
*self
, WMDraggingInfo
*info
)
857 return WDOperationCopy
;
861 void (*draggingExited)(WMView *self, WMDraggingInfo *info);
863 char *prepareForDragOperation(WMView
*self
, WMDraggingInfo
*info
)
865 return "application/X-WINGs-Bla";
869 WMLabel
*makeDraggableLabel(WMWidget
*w
, char *file
, int x
, int y
);
871 Bool
performDragOperation(WMView
*self
, WMDraggingInfo
*info
,
874 char *file
= (char*)WMDataBytes(data
);
877 pos
= WMGetDraggingInfoImageLocation(info
);
881 WMPoint pos2
= WMGetViewScreenPosition(self
);
884 label
= makeDraggableLabel(WMWidgetOfView(self
), file
,
885 pos
.x
-pos2
.x
, pos
.y
-pos2
.y
);
886 WMRealizeWidget(label
);
895 void concludeDragOperation(WMView
*self
, WMDraggingInfo
*info
)
902 WMDragDestinationProcs dragDestProcs
= {
906 prepareForDragOperation
,
907 performDragOperation
,
908 concludeDragOperation
915 makeDraggableLabel(WMWidget
*w
, char *file
, int x
, int y
)
919 WMPixmap
*image
= getImage(WMWidgetScreen(w
), file
);
921 stuff
= wmalloc(sizeof(DNDStuff
));
922 stuff
->mouseDown
= False
;
924 stuff
->filename
= wstrdup(file
);
926 label
= WMCreateLabel(w
);
927 WMResizeWidget(label
, 48, 48);
928 WMMoveWidget(label
, x
, y
);
930 WMSetViewDragSourceProcs(WMWidgetView(label
), &dragSourceProcs
);
932 WMHangData(label
, stuff
);
934 WMCreateEventHandler(WMWidgetView(label
),
935 ButtonPressMask
|ButtonReleaseMask
|ButtonMotionMask
,
936 iconMouseStuff
, label
);
940 WMSetLabelImagePosition(label
, WIPImageOnly
);
941 WMSetLabelImage(label
, image
);
942 WMReleasePixmap(image
);
950 void testDragAndDrop(WMScreen
*scr
)
959 "application/X-WINGs-Bla",
965 win
= WMCreateWindow(scr
, "dragDrop");
966 WMResizeWidget(win
, 300, 300);
967 WMSetWindowCloseAction(win
, closeAction
, NULL
);
968 WMSetWindowTitle(win
, "Drag and Drop");
971 frame
= WMCreateFrame(win
);
972 WMSetFrameRelief(frame
, WRSunken
);
973 WMResizeWidget(frame
, 250, 250);
974 WMMoveWidget(frame
, 25, 25);
976 WMRegisterViewForDraggedTypes(WMWidgetView(frame
), types
);
977 WMSetViewDragDestinationProcs(WMWidgetView(frame
), &dragDestProcs
);
979 dir
= opendir("../WindowMaker/Icons");
981 perror("../WindowMaker/Icons");
985 for (i
= 0, j
=0; j
< 8; i
++) {
990 if (strstr(ent
->d_name
, ".xpm")==NULL
) {
994 label
= makeDraggableLabel(frame
, ent
->d_name
,4+(j
/4)*64, 4+(j
%4)*64);
1001 WMMapSubwidgets(frame
);
1003 WMMapSubwidgets(win
);
1004 WMRealizeWidget(win
);
1012 /*******************************************************************/
1018 WMUserDefaults
*defs
;
1021 defs
= WMGetStandardUserDefaults();
1023 sprintf(str
, "TEST DATA");
1025 WMSetUDStringForKey(defs
, str
, "testKey");
1030 int main(int argc
, char **argv
)
1036 /* Initialize the application */
1037 WMInitializeApplication("Test", &argc
, argv
);
1042 * Open connection to the X display.
1044 dpy
= XOpenDisplay("");
1047 puts("could not open display");
1051 /* This is used to disable buffering of X protocol requests.
1052 * Do NOT use it unless when debugging. It will cause a major
1053 * slowdown in your application
1056 XSynchronize(dpy
, True
);
1059 * Create screen descriptor.
1061 scr
= WMCreateScreen(dpy
, DefaultScreen(dpy
));
1064 * Loads the logo of the application.
1066 pixmap
= WMCreatePixmapFromFile(scr
, "logo.xpm");
1069 * Makes the logo be used in standard dialog panels.
1071 WMSetApplicationIconImage(scr
, pixmap
); WMReleasePixmap(pixmap
);
1074 * Do some test stuff.
1076 * Put the testSomething() function you want to test here.
1082 testDragAndDrop(scr
);
1083 testDragAndDrop(scr
);
1085 testScrollView(scr
);
1099 testGradientButtons(scr
);
1100 testProgressIndicator(scr
);
1104 testOpenFilePanel(scr
);
1112 * The main event loop.
1115 WMScreenMainLoop(scr
);