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
)
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
);
119 testList(WMScreen
*scr
)
131 win
= WMCreateWindow(scr
, "testList");
132 WMSetWindowTitle(win
, "List");
133 WMSetWindowCloseAction(win
, closeAction
, NULL
);
135 list
= WMCreateList(win
);
136 for (i
=0; i
<50; i
++) {
137 sprintf(text
, "Item %i", i
);
138 WMAddListItem(list
, text
);
140 mlist
= WMCreateList(win
);
141 WMSetListAllowMultipleSelection(mlist
, True
);
142 WMMoveWidget(mlist
, 220, 0);
143 for (i
=0; i
<50; i
++) {
144 sprintf(text
, "Item %i", i
);
145 WMAddListItem(mlist
, text
);
147 WMRealizeWidget(win
);
148 WMMapSubwidgets(win
);
154 testButton(WMScreen
*scr
)
171 win
= WMCreateWindow(scr
, "testButton");
172 WMResizeWidget(win
, 300, 300);
173 WMSetWindowTitle(win
, "Buttons");
175 WMSetWindowCloseAction(win
, closeAction
, NULL
);
177 for (i
= 1; i
< 9; i
++) {
179 b
= WMCreateButton(win
, i
);
180 WMResizeWidget(b
, 150, 24);
181 WMMoveWidget(b
, 20, i
*30);
182 WMSetButtonText(b
, types
[i
-1]);
185 WMRealizeWidget(win
);
186 WMMapSubwidgets(win
);
192 testGradientButtons(WMScreen
*scr
)
196 WMPixmap
*pix1
, *pix2
;
199 WMColor
*color
, *altColor
;
203 /* creates the top-level window */
204 win
= WMCreateWindow(scr
, "testGradientButtons");
205 WMSetWindowTitle(win
, "Gradiented Button Demo");
206 WMResizeWidget(win
, 300, 200);
215 color
= WMCreateRGBColor(scr
, 0x5900, 0x5100, 0x5900, True
);
216 WMSetWidgetBackgroundColor(win
, color
);
217 WMReleaseColor(color
);
219 back
= RRenderGradient(60, 24, &dark
, &light
, RGRD_DIAGONAL
);
220 RBevelImage(back
, RBEV_RAISED2
);
221 pix1
= WMCreatePixmapFromRImage(scr
, back
, 0);
224 back
= RRenderGradient(60, 24, &dark
, &light
, RGRD_DIAGONAL
);
225 RBevelImage(back
, RBEV_SUNKEN
);
226 pix2
= WMCreatePixmapFromRImage(scr
, back
, 0);
229 color
= WMWhiteColor(scr
);
230 altColor
= WMCreateNamedColor(scr
, "red", True
);
232 btn
= WMCreateButton(win
, WBTMomentaryChange
);
233 WMResizeWidget(btn
, 60, 24);
234 WMMoveWidget(btn
, 20, 100);
235 WMSetButtonBordered(btn
, False
);
236 WMSetButtonImagePosition(btn
, WIPOverlaps
);
237 WMSetButtonImage(btn
, pix1
);
238 WMSetButtonAltImage(btn
, pix2
);
239 WMSetButtonText(btn
, "Cool");
240 WMSetButtonTextColor(btn
, color
);
241 WMSetButtonAltTextColor(btn
, altColor
);
243 WMSetBalloonTextForView("This is a cool button", WMWidgetView(btn
));
245 btn
= WMCreateButton(win
, WBTMomentaryChange
);
246 WMResizeWidget(btn
, 60, 24);
247 WMMoveWidget(btn
, 90, 100);
248 WMSetButtonBordered(btn
, False
);
249 WMSetButtonImagePosition(btn
, WIPOverlaps
);
250 WMSetButtonImage(btn
, pix1
);
251 WMSetButtonAltImage(btn
, pix2
);
252 WMSetButtonText(btn
, "Button");
253 WMSetButtonTextColor(btn
, color
);
255 WMSetBalloonTextForView("Este é outro balão.", WMWidgetView(btn
));
257 WMReleaseColor(color
);
258 color
= WMCreateNamedColor(scr
, "orange", True
);
260 btn
= WMCreateButton(win
, WBTMomentaryChange
);
261 WMResizeWidget(btn
, 60, 24);
262 WMMoveWidget(btn
, 160, 100);
263 WMSetButtonBordered(btn
, False
);
264 WMSetButtonImagePosition(btn
, WIPOverlaps
);
265 WMSetButtonImage(btn
, pix1
);
266 WMSetButtonAltImage(btn
, pix2
);
267 WMSetButtonText(btn
, "Test");
268 WMSetButtonTextColor(btn
, color
);
270 WMSetBalloonTextForView("This is yet another button.\nBut the balloon has 3 lines.\nYay!",
273 WMReleaseColor(color
);
274 WMReleaseColor(altColor
);
276 WMRealizeWidget(win
);
277 WMMapSubwidgets(win
);
283 testScrollView(WMScreen
*scr
)
294 /* creates the top-level window */
295 win
= WMCreateWindow(scr
, "testScroll");
296 WMSetWindowTitle(win
, "Scrollable View");
298 WMSetWindowCloseAction(win
, closeAction
, NULL
);
300 /* set the window size */
301 WMResizeWidget(win
, 300, 300);
303 /* creates a scrollable view inside the top-level window */
304 sview
= WMCreateScrollView(win
);
305 WMResizeWidget(sview
, 200, 200);
306 WMMoveWidget(sview
, 30, 30);
307 WMSetScrollViewRelief(sview
, WRSunken
);
308 WMSetScrollViewHasVerticalScroller(sview
, True
);
309 WMSetScrollViewHasHorizontalScroller(sview
, True
);
311 /* create a frame with a bunch of labels */
312 f
= WMCreateFrame(win
);
313 WMResizeWidget(f
, 400, 400);
314 WMSetFrameRelief(f
, WRFlat
);
316 for (i
=0; i
<20; i
++) {
317 l
= WMCreateLabel(f
);
318 WMResizeWidget(l
, 50, 18);
319 WMMoveWidget(l
, 10, 20*i
);
320 sprintf(buffer
, "Label %i", i
);
321 WMSetLabelText(l
, buffer
);
322 WMSetLabelRelief(l
, WRSimple
);
327 WMSetScrollViewContentView(sview
, WMWidgetView(f
));
329 /* make the windows of the widgets be actually created */
330 WMRealizeWidget(win
);
332 /* Map all child widgets of the top-level be mapped.
333 * You must call this for each container widget (like frames),
334 * even if they are childs of the top-level window.
336 WMMapSubwidgets(win
);
338 /* map the top-level window */
344 testColorWell(WMScreen
*scr
)
347 WMColorWell
*well1
, *well2
;
351 win
= WMCreateWindow(scr
, "testColor");
352 WMResizeWidget(win
, 300, 300);
353 WMSetWindowCloseAction(win
, closeAction
, NULL
);
355 well1
= WMCreateColorWell(win
);
356 WMResizeWidget(well1
, 60, 40);
357 WMMoveWidget(well1
, 100, 100);
358 WMSetColorWellColor(well1
, WMCreateRGBColor(scr
, 0x8888, 0, 0x1111, True
));
359 well2
= WMCreateColorWell(win
);
360 WMResizeWidget(well2
, 60, 40);
361 WMMoveWidget(well2
, 200, 100);
362 WMSetColorWellColor(well2
, WMCreateRGBColor(scr
, 0, 0, 0x8888, True
));
364 WMRealizeWidget(win
);
365 WMMapSubwidgets(win
);
370 sliderCallback(WMWidget
*w
, void *data
)
372 printf("SLIDER == %i\n", WMGetSliderValue(w
));
377 testSlider(WMScreen
*scr
)
384 win
= WMCreateWindow(scr
, "testSlider");
385 WMResizeWidget(win
, 300, 300);
386 WMSetWindowTitle(win
, "Sliders");
388 WMSetWindowCloseAction(win
, closeAction
, NULL
);
390 s
= WMCreateSlider(win
);
391 WMResizeWidget(s
, 16, 100);
392 WMMoveWidget(s
, 100, 100);
393 WMSetSliderKnobThickness(s
, 8);
394 WMSetSliderContinuous(s
, False
);
395 WMSetSliderAction(s
, sliderCallback
, s
);
397 s
= WMCreateSlider(win
);
398 WMResizeWidget(s
, 100, 16);
399 WMMoveWidget(s
, 100, 10);
400 WMSetSliderKnobThickness(s
, 8);
402 WMRealizeWidget(win
);
403 WMMapSubwidgets(win
);
408 testTextField(WMScreen
*scr
)
411 WMTextField
*field
, *field2
;
415 win
= WMCreateWindow(scr
, "testTextField");
416 WMResizeWidget(win
, 400, 300);
418 WMSetWindowCloseAction(win
, closeAction
, NULL
);
420 field
= WMCreateTextField(win
);
421 WMResizeWidget(field
, 200, 20);
422 WMMoveWidget(field
, 20, 20);
424 field2
= WMCreateTextField(win
);
425 WMResizeWidget(field2
, 200, 20);
426 WMMoveWidget(field2
, 20, 50);
427 WMSetTextFieldAlignment(field2
, WARight
);
429 WMRealizeWidget(win
);
430 WMMapSubwidgets(win
);
436 testText(WMScreen
*scr
)
440 FILE *file
= fopen("../README", "r");
444 win
= WMCreateWindow(scr
, "testText");
445 WMResizeWidget(win
, 500, 300);
447 WMSetWindowCloseAction(win
, closeAction
, NULL
);
449 text
= WMCreateText(win
);
450 WMResizeWidget(text
, 480, 280);
451 WMMoveWidget(text
, 10, 10);
452 WMSetTextHasVerticalScroller(text
, True
);
453 WMSetTextEditable(text
, False
);
459 while(fgets(buf
, 1023, file
))
460 WMAppendTextStream(text
, buf
);
464 WMRefreshText(text
, 0, 0);
466 WMAppendTextStream(text
, "<HTML><i>Where's</i> the <b>README</b>?");
469 WMRealizeWidget(win
);
470 WMMapSubwidgets(win
);
477 testProgressIndicator(WMScreen
*scr
)
480 WMProgressIndicator
*pPtr
;
484 win
= WMCreateWindow(scr
, "testProgressIndicator");
485 WMResizeWidget(win
, 292, 32);
487 WMSetWindowCloseAction(win
, closeAction
, NULL
);
489 pPtr
= WMCreateProgressIndicator(win
);
490 WMMoveWidget(pPtr
, 8, 8);
491 WMSetProgressIndicatorValue(pPtr
, 75);
493 WMRealizeWidget(win
);
494 WMMapSubwidgets(win
);
501 testPullDown(WMScreen
*scr
)
504 WMPopUpButton
*pop
, *pop2
;
508 win
= WMCreateWindow(scr
, "pullDown");
509 WMResizeWidget(win
, 400, 300);
511 WMSetWindowCloseAction(win
, closeAction
, NULL
);
513 pop
= WMCreatePopUpButton(win
);
514 WMResizeWidget(pop
, 100, 20);
515 WMMoveWidget(pop
, 50, 60);
516 WMSetPopUpButtonPullsDown(pop
, True
);
517 WMSetPopUpButtonText(pop
, "Commands");
518 WMAddPopUpButtonItem(pop
, "Add");
519 WMAddPopUpButtonItem(pop
, "Remove");
520 WMAddPopUpButtonItem(pop
, "Check");
521 WMAddPopUpButtonItem(pop
, "Eat");
523 pop2
= WMCreatePopUpButton(win
);
524 WMResizeWidget(pop2
, 100, 20);
525 WMMoveWidget(pop2
, 200, 60);
526 WMSetPopUpButtonText(pop2
, "Select");
527 WMAddPopUpButtonItem(pop2
, "Apples");
528 WMAddPopUpButtonItem(pop2
, "Bananas");
529 WMAddPopUpButtonItem(pop2
, "Strawberries");
530 WMAddPopUpButtonItem(pop2
, "Blueberries");
532 WMRealizeWidget(win
);
533 WMMapSubwidgets(win
);
540 testTabView(WMScreen
*scr
)
550 win
= WMCreateWindow(scr
, "testTabs");
551 WMResizeWidget(win
, 400, 300);
553 WMSetWindowCloseAction(win
, closeAction
, NULL
);
555 tabv
= WMCreateTabView(win
);
556 WMMoveWidget(tabv
, 50, 50);
557 WMResizeWidget(tabv
, 300, 200);
559 frame
= WMCreateFrame(win
);
560 WMSetFrameRelief(frame
, WRFlat
);
561 label
= WMCreateLabel(frame
);
562 WMResizeWidget(label
, 100, 100);
563 WMSetLabelText(label
, "Label 1");
567 tab
= WMCreateTabViewItemWithIdentifier(0);
568 WMSetTabViewItemView(tab
, WMWidgetView(frame
));
569 WMAddItemInTabView(tabv
, tab
);
570 WMSetTabViewItemLabel(tab
, "Instances");
572 frame
= WMCreateFrame(win
);
573 WMSetFrameRelief(frame
, WRFlat
);
574 label
= WMCreateLabel(frame
);
575 WMResizeWidget(label
, 40, 50);
576 WMSetLabelText(label
, "Label 2");
580 tab
= WMCreateTabViewItemWithIdentifier(0);
581 WMSetTabViewItemView(tab
, WMWidgetView(frame
));
582 WMAddItemInTabView(tabv
, tab
);
583 WMSetTabViewItemLabel(tab
, "Classes");
586 frame
= WMCreateFrame(win
);
587 WMSetFrameRelief(frame
, WRFlat
);
588 label
= WMCreateLabel(frame
);
589 WMResizeWidget(label
, 100, 100);
590 WMMoveWidget(label
, 60, 40);
591 WMSetLabelText(label
, "Label 3");
594 tab
= WMCreateTabViewItemWithIdentifier(0);
595 WMSetTabViewItemView(tab
, WMWidgetView(frame
));
596 WMAddItemInTabView(tabv
, tab
);
597 WMSetTabViewItemLabel(tab
, "Something");
600 frame
= WMCreateFrame(win
);
601 WMSetFrameRelief(frame
, WRFlat
);
602 label
= WMCreateLabel(frame
);
603 WMResizeWidget(label
, 100, 100);
604 WMMoveWidget(label
, 160, 40);
605 WMSetLabelText(label
, "Label 4");
608 tab
= WMCreateTabViewItemWithIdentifier(0);
609 WMSetTabViewItemView(tab
, WMWidgetView(frame
));
610 WMAddItemInTabView(tabv
, tab
);
611 WMSetTabViewItemLabel(tab
, "Bla!");
615 frame
= WMCreateFrame(win
);
616 WMSetFrameRelief(frame
, WRFlat
);
617 label
= WMCreateLabel(frame
);
618 WMResizeWidget(label
, 100, 100);
619 WMMoveWidget(label
, 160, 40);
620 WMSetLabelText(label
, "Label fjweqklrj qwl");
622 tab
= WMCreateTabViewItemWithIdentifier(0);
623 WMSetTabViewItemView(tab
, WMWidgetView(frame
));
624 WMAddItemInTabView(tabv
, tab
);
625 WMSetTabViewItemLabel(tab
, "Weee!");
628 WMRealizeWidget(win
);
629 WMMapSubwidgets(win
);
635 splitViewConstrainProc(WMSplitView
*sPtr
, int indView
,
636 int *minSize
, int *maxSize
)
656 resizeSplitView(XEvent
*event
, void *data
)
658 WMSplitView
*sPtr
= (WMSplitView
*)data
;
660 if (event
->type
== ConfigureNotify
) {
661 int width
= event
->xconfigure
.width
- 10;
663 if (width
< WMGetSplitViewDividerThickness(sPtr
))
664 width
= WMGetSplitViewDividerThickness(sPtr
);
666 if (width
!= WMWidgetWidth(sPtr
) ||
667 event
->xconfigure
.height
!= WMWidgetHeight(sPtr
))
668 WMResizeWidget(sPtr
, width
, event
->xconfigure
.height
- 55);
673 appendSubviewButtonAction(WMWidget
*self
, void *data
)
675 WMSplitView
*sPtr
= (WMSplitView
*)data
;
677 WMLabel
*label
= WMCreateLabel(sPtr
);
679 sprintf(buf
, "Subview %d", WMGetSplitViewSubviewsCount(sPtr
) + 1);
680 WMSetLabelText(label
, buf
);
681 WMSetLabelRelief(label
, WRSunken
);
682 WMAddSplitViewSubview(sPtr
, WMWidgetView(label
));
683 WMRealizeWidget(label
);
688 removeSubviewButtonAction(WMWidget
*self
, void *data
)
690 WMSplitView
*sPtr
= (WMSplitView
*)data
;
691 int count
= WMGetSplitViewSubviewsCount(sPtr
);
694 WMView
*view
= WMGetSplitViewSubviewAt(sPtr
, count
-1);
695 WMDestroyWidget(WMWidgetOfView(view
));
696 WMRemoveSplitViewSubviewAt(sPtr
, count
-1);
701 orientationButtonAction(WMWidget
*self
, void *data
)
703 WMSplitView
*sPtr
= (WMSplitView
*)data
;
704 WMSetSplitViewVertical(sPtr
, !WMGetSplitViewVertical(sPtr
));
708 adjustSubviewsButtonAction(WMWidget
*self
, void *data
)
710 WMAdjustSplitViewSubviews((WMSplitView
*)data
);
714 testSplitView(WMScreen
*scr
)
717 WMSplitView
*splitv1
, *splitv2
;
724 win
= WMCreateWindow(scr
, "testTabs");
725 WMResizeWidget(win
, 300, 400);
726 WMSetWindowCloseAction(win
, closeAction
, NULL
);
728 frame
= WMCreateFrame(win
);
729 WMSetFrameRelief(frame
, WRSunken
);
730 WMMoveWidget(frame
, 5, 5);
731 WMResizeWidget(frame
, 290, 40);
733 splitv1
= WMCreateSplitView(win
);
734 WMMoveWidget(splitv1
, 5, 50);
735 WMResizeWidget(splitv1
, 290, 345);
736 WMSetSplitViewConstrainProc(splitv1
, splitViewConstrainProc
);
737 WMCreateEventHandler(WMWidgetView(win
), StructureNotifyMask
,
738 resizeSplitView
, splitv1
);
740 button
= WMCreateCommandButton(frame
);
741 WMSetButtonText(button
, "+");
742 WMSetButtonAction(button
, appendSubviewButtonAction
, splitv1
);
743 WMMoveWidget(button
, 10, 8);
746 button
= WMCreateCommandButton(frame
);
747 WMSetButtonText(button
, "-");
748 WMSetButtonAction(button
, removeSubviewButtonAction
, splitv1
);
749 WMMoveWidget(button
, 80, 8);
752 button
= WMCreateCommandButton(frame
);
753 WMSetButtonText(button
, "=");
754 WMMoveWidget(button
, 150, 8);
755 WMSetButtonAction(button
, adjustSubviewsButtonAction
, splitv1
);
758 button
= WMCreateCommandButton(frame
);
759 WMSetButtonText(button
, "#");
760 WMMoveWidget(button
, 220, 8);
761 WMSetButtonAction(button
, orientationButtonAction
, splitv1
);
764 label
= WMCreateLabel(splitv1
);
765 WMSetLabelText(label
, "Subview 1");
766 WMSetLabelRelief(label
, WRSunken
);
768 WMAddSplitViewSubview(splitv1
, WMWidgetView(label
));
770 splitv2
= WMCreateSplitView(splitv1
);
771 WMResizeWidget(splitv2
, 150, 150);
772 WMSetSplitViewVertical(splitv2
, True
);
774 label
= WMCreateLabel(splitv2
);
775 WMSetLabelText(label
, "Subview 2.1");
776 WMSetLabelRelief(label
, WRSunken
);
778 WMAddSplitViewSubview(splitv2
, WMWidgetView(label
));
780 label
= WMCreateLabel(splitv2
);
781 WMSetLabelText(label
, "Subview 2.2");
782 WMSetLabelRelief(label
, WRSunken
);
784 WMAddSplitViewSubview(splitv2
, WMWidgetView(label
));
786 label
= WMCreateLabel(splitv2
);
787 WMSetLabelText(label
, "Subview 2.3");
788 WMSetLabelRelief(label
, WRSunken
);
790 WMAddSplitViewSubview(splitv2
, WMWidgetView(label
));
792 WMMapWidget(splitv2
);
793 WMAddSplitViewSubview(splitv1
, WMWidgetView(splitv2
));
795 WMRealizeWidget(win
);
796 WMMapSubwidgets(win
);
801 /*******************************************************************/
803 #include <sys/types.h>
815 getImage(WMScreen
*scr
, char *file
)
820 sprintf(buffer
, "../../WindowMaker/Icons/%s", file
);
821 pix
= WMCreatePixmapFromFile(scr
, buffer
);
830 iconMouseStuff(XEvent
*event
, void *cdata
)
832 WMLabel
*label
= (WMLabel
*)cdata
;
833 DNDStuff
*stuff
= WMGetHangedData(label
);
836 switch (event
->type
) {
838 stuff
->x
= event
->xbutton
.x
;
839 stuff
->y
= event
->xbutton
.y
;
840 stuff
->mouseDown
= True
;
843 stuff
->mouseDown
= False
;
846 if (!stuff
->mouseDown
)
849 if (abs(stuff
->x
- event
->xmotion
.x
)>4
850 || abs(stuff
->y
- event
->xmotion
.y
)>4) {
852 where
= WMGetViewScreenPosition(WMWidgetView(label
));
854 WMDragImageFromView(WMWidgetView(label
),
855 WMGetLabelImage(label
),
858 wmksize(stuff
->x
, stuff
->y
),
867 endedDragImage(WMView
*self
, WMPixmap
*image
, WMPoint point
, Bool deposited
)
869 DNDStuff
*stuff
= WMGetHangedData(WMWidgetOfView(self
));
872 WMDestroyWidget(WMWidgetOfView(self
));
875 stuff
->mouseDown
= False
;
880 fetchDragData(WMView
*self
, char *type
)
882 DNDStuff
*stuff
= WMGetHangedData(WMWidgetOfView(self
));
884 return WMCreateDataWithBytes(stuff
->filename
, strlen(stuff
->filename
)+1);
888 WMDragSourceProcs dragSourceProcs
= {
896 /************************/
900 draggingEntered(WMView
*self
, WMDraggingInfo
*info
)
902 return WDOperationCopy
;
907 draggingUpdated(WMView
*self
, WMDraggingInfo
*info
)
909 return WDOperationCopy
;
913 void (*draggingExited)(WMView *self, WMDraggingInfo *info);
916 prepareForDragOperation(WMView
*self
, WMDraggingInfo
*info
)
918 return "application/X-WINGs-Bla";
922 WMLabel
* makeDraggableLabel(WMWidget
*w
, char *file
, int x
, int y
);
925 performDragOperation(WMView
*self
, WMDraggingInfo
*info
, WMData
*data
)
927 char *file
= (char*)WMDataBytes(data
);
930 pos
= WMGetDraggingInfoImageLocation(info
);
934 WMPoint pos2
= WMGetViewScreenPosition(self
);
937 label
= makeDraggableLabel(WMWidgetOfView(self
), file
,
938 pos
.x
-pos2
.x
, pos
.y
-pos2
.y
);
939 WMRealizeWidget(label
);
949 concludeDragOperation(WMView
*self
, WMDraggingInfo
*info
)
956 WMDragDestinationProcs dragDestProcs
= {
960 prepareForDragOperation
,
961 performDragOperation
,
962 concludeDragOperation
969 makeDraggableLabel(WMWidget
*w
, char *file
, int x
, int y
)
973 WMPixmap
*image
= getImage(WMWidgetScreen(w
), file
);
975 stuff
= wmalloc(sizeof(DNDStuff
));
976 stuff
->mouseDown
= False
;
978 stuff
->filename
= wstrdup(file
);
980 label
= WMCreateLabel(w
);
981 WMResizeWidget(label
, 48, 48);
982 WMMoveWidget(label
, x
, y
);
984 WMSetViewDragSourceProcs(WMWidgetView(label
), &dragSourceProcs
);
986 WMHangData(label
, stuff
);
988 WMCreateEventHandler(WMWidgetView(label
),
989 ButtonPressMask
|ButtonReleaseMask
|ButtonMotionMask
,
990 iconMouseStuff
, label
);
994 WMSetLabelImagePosition(label
, WIPImageOnly
);
995 WMSetLabelImage(label
, image
);
996 WMReleasePixmap(image
);
1005 testDragAndDrop(WMScreen
*scr
)
1014 "application/X-WINGs-Bla",
1020 win
= WMCreateWindow(scr
, "dragDrop");
1021 WMResizeWidget(win
, 300, 300);
1022 WMSetWindowCloseAction(win
, closeAction
, NULL
);
1023 WMSetWindowTitle(win
, "Drag and Drop");
1026 frame
= WMCreateFrame(win
);
1027 WMSetFrameRelief(frame
, WRSunken
);
1028 WMResizeWidget(frame
, 250, 250);
1029 WMMoveWidget(frame
, 25, 25);
1031 WMRegisterViewForDraggedTypes(WMWidgetView(frame
), types
);
1032 WMSetViewDragDestinationProcs(WMWidgetView(frame
), &dragDestProcs
);
1034 dir
= opendir("../../WindowMaker/Icons");
1036 perror("../../WindowMaker/Icons");
1040 for (i
= 0, j
=0; j
< 8; i
++) {
1045 if (strstr(ent
->d_name
, ".xpm")==NULL
) {
1049 label
= makeDraggableLabel(frame
, ent
->d_name
,4+(j
/4)*64, 4+(j
%4)*64);
1056 WMMapSubwidgets(frame
);
1058 WMMapSubwidgets(win
);
1059 WMRealizeWidget(win
);
1067 /*******************************************************************/
1074 WMUserDefaults
*defs
;
1077 defs
= WMGetStandardUserDefaults();
1079 sprintf(str
, "TEST DATA");
1081 WMSetUDStringForKey(defs
, str
, "testKey");
1087 main(int argc
, char **argv
)
1093 /* Initialize the application */
1094 WMInitializeApplication("Test", &argc
, argv
);
1099 * Open connection to the X display.
1101 dpy
= XOpenDisplay("");
1104 puts("could not open display");
1108 /* This is used to disable buffering of X protocol requests.
1109 * Do NOT use it unless when debugging. It will cause a major
1110 * slowdown in your application
1113 XSynchronize(dpy
, True
);
1116 * Create screen descriptor.
1118 scr
= WMCreateScreen(dpy
, DefaultScreen(dpy
));
1121 * Loads the logo of the application.
1123 pixmap
= WMCreatePixmapFromFile(scr
, "logo.xpm");
1126 * Makes the logo be used in standard dialog panels.
1128 WMSetApplicationIconImage(scr
, pixmap
); WMReleasePixmap(pixmap
);
1131 * Do some test stuff.
1133 * Put the testSomething() function you want to test here.
1144 testDragAndDrop(scr
);
1145 testDragAndDrop(scr
);
1148 testScrollView(scr
);
1161 testGradientButtons(scr
);
1162 testProgressIndicator(scr
);
1165 testOpenFilePanel(scr
);
1171 * The main event loop.
1174 WMScreenMainLoop(scr
);