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
)
128 win
= WMCreateWindow(scr
, "testList");
129 WMSetWindowTitle(win
, "List");
130 WMSetWindowCloseAction(win
, closeAction
, NULL
);
132 list
= WMCreateList(win
);
133 for (i
=0; i
<50; i
++) {
134 sprintf(text
, "Item %i", i
);
135 WMAddListItem(list
, text
);
137 WMRealizeWidget(win
);
138 WMMapSubwidgets(win
);
146 testButton(WMScreen
*scr
)
163 win
= WMCreateWindow(scr
, "testButton");
164 WMResizeWidget(win
, 300, 300);
165 WMSetWindowTitle(win
, "Buttons");
167 WMSetWindowCloseAction(win
, closeAction
, NULL
);
169 for (i
= 1; i
< 9; i
++) {
171 b
= WMCreateButton(win
, i
);
172 WMResizeWidget(b
, 150, 24);
173 WMMoveWidget(b
, 20, i
*30);
174 WMSetButtonText(b
, types
[i
-1]);
177 WMRealizeWidget(win
);
178 WMMapSubwidgets(win
);
184 testGradientButtons(WMScreen
*scr
)
188 WMPixmap
*pix1
, *pix2
;
191 WMColor
*color
, *altColor
;
195 /* creates the top-level window */
196 win
= WMCreateWindow(scr
, "testGradientButtons");
197 WMSetWindowTitle(win
, "Gradiented Button Demo");
198 WMResizeWidget(win
, 300, 200);
207 color
= WMCreateRGBColor(scr
, 0x5900, 0x5100, 0x5900, True
);
208 WMSetWidgetBackgroundColor(win
, color
);
209 WMReleaseColor(color
);
211 back
= RRenderGradient(60, 24, &dark
, &light
, RGRD_DIAGONAL
);
212 RBevelImage(back
, RBEV_RAISED2
);
213 pix1
= WMCreatePixmapFromRImage(scr
, back
, 0);
216 back
= RRenderGradient(60, 24, &dark
, &light
, RGRD_DIAGONAL
);
217 RBevelImage(back
, RBEV_SUNKEN
);
218 pix2
= WMCreatePixmapFromRImage(scr
, back
, 0);
221 color
= WMWhiteColor(scr
);
222 altColor
= WMCreateNamedColor(scr
, "red", True
);
224 btn
= WMCreateButton(win
, WBTMomentaryChange
);
225 WMResizeWidget(btn
, 60, 24);
226 WMMoveWidget(btn
, 20, 100);
227 WMSetButtonBordered(btn
, False
);
228 WMSetButtonImagePosition(btn
, WIPOverlaps
);
229 WMSetButtonImage(btn
, pix1
);
230 WMSetButtonAltImage(btn
, pix2
);
231 WMSetButtonText(btn
, "Cool");
232 WMSetButtonTextColor(btn
, color
);
233 WMSetButtonAltTextColor(btn
, altColor
);
235 WMSetBalloonTextForView("This is a cool button", WMWidgetView(btn
));
237 btn
= WMCreateButton(win
, WBTMomentaryChange
);
238 WMResizeWidget(btn
, 60, 24);
239 WMMoveWidget(btn
, 90, 100);
240 WMSetButtonBordered(btn
, False
);
241 WMSetButtonImagePosition(btn
, WIPOverlaps
);
242 WMSetButtonImage(btn
, pix1
);
243 WMSetButtonAltImage(btn
, pix2
);
244 WMSetButtonText(btn
, "Button");
245 WMSetButtonTextColor(btn
, color
);
247 WMSetBalloonTextForView("Este é outro balão.", WMWidgetView(btn
));
249 WMReleaseColor(color
);
250 color
= WMCreateNamedColor(scr
, "orange", True
);
252 btn
= WMCreateButton(win
, WBTMomentaryChange
);
253 WMResizeWidget(btn
, 60, 24);
254 WMMoveWidget(btn
, 160, 100);
255 WMSetButtonBordered(btn
, False
);
256 WMSetButtonImagePosition(btn
, WIPOverlaps
);
257 WMSetButtonImage(btn
, pix1
);
258 WMSetButtonAltImage(btn
, pix2
);
259 WMSetButtonText(btn
, "Test");
260 WMSetButtonTextColor(btn
, color
);
262 WMSetBalloonTextForView("This is yet another button.\nBut the balloon has 3 lines.\nYay!",
265 WMReleaseColor(color
);
266 WMReleaseColor(altColor
);
268 WMRealizeWidget(win
);
269 WMMapSubwidgets(win
);
275 testScrollView(WMScreen
*scr
)
286 /* creates the top-level window */
287 win
= WMCreateWindow(scr
, "testScroll");
288 WMSetWindowTitle(win
, "Scrollable View");
290 WMSetWindowCloseAction(win
, closeAction
, NULL
);
292 /* set the window size */
293 WMResizeWidget(win
, 300, 300);
295 /* creates a scrollable view inside the top-level window */
296 sview
= WMCreateScrollView(win
);
297 WMResizeWidget(sview
, 200, 200);
298 WMMoveWidget(sview
, 30, 30);
299 WMSetScrollViewRelief(sview
, WRSunken
);
300 WMSetScrollViewHasVerticalScroller(sview
, True
);
301 WMSetScrollViewHasHorizontalScroller(sview
, True
);
303 /* create a frame with a bunch of labels */
304 f
= WMCreateFrame(win
);
305 WMResizeWidget(f
, 400, 400);
306 WMSetFrameRelief(f
, WRFlat
);
308 for (i
=0; i
<20; i
++) {
309 l
= WMCreateLabel(f
);
310 WMResizeWidget(l
, 50, 18);
311 WMMoveWidget(l
, 10, 20*i
);
312 sprintf(buffer
, "Label %i", i
);
313 WMSetLabelText(l
, buffer
);
314 WMSetLabelRelief(l
, WRSimple
);
319 WMSetScrollViewContentView(sview
, WMWidgetView(f
));
321 /* make the windows of the widgets be actually created */
322 WMRealizeWidget(win
);
324 /* Map all child widgets of the top-level be mapped.
325 * You must call this for each container widget (like frames),
326 * even if they are childs of the top-level window.
328 WMMapSubwidgets(win
);
330 /* map the top-level window */
336 testColorWell(WMScreen
*scr
)
339 WMColorWell
*well1
, *well2
;
343 win
= WMCreateWindow(scr
, "testColor");
344 WMResizeWidget(win
, 300, 300);
345 WMSetWindowCloseAction(win
, closeAction
, NULL
);
347 well1
= WMCreateColorWell(win
);
348 WMResizeWidget(well1
, 60, 40);
349 WMMoveWidget(well1
, 100, 100);
350 WMSetColorWellColor(well1
, WMCreateRGBColor(scr
, 0x8888, 0, 0x1111, True
));
351 well2
= WMCreateColorWell(win
);
352 WMResizeWidget(well2
, 60, 40);
353 WMMoveWidget(well2
, 200, 100);
354 WMSetColorWellColor(well2
, WMCreateRGBColor(scr
, 0, 0, 0x8888, True
));
356 WMRealizeWidget(win
);
357 WMMapSubwidgets(win
);
362 sliderCallback(WMWidget
*w
, void *data
)
364 printf("SLIDER == %i\n", WMGetSliderValue(w
));
369 testSlider(WMScreen
*scr
)
376 win
= WMCreateWindow(scr
, "testSlider");
377 WMResizeWidget(win
, 300, 300);
378 WMSetWindowTitle(win
, "Sliders");
380 WMSetWindowCloseAction(win
, closeAction
, NULL
);
382 s
= WMCreateSlider(win
);
383 WMResizeWidget(s
, 16, 100);
384 WMMoveWidget(s
, 100, 100);
385 WMSetSliderKnobThickness(s
, 8);
386 WMSetSliderContinuous(s
, False
);
387 WMSetSliderAction(s
, sliderCallback
, s
);
389 s
= WMCreateSlider(win
);
390 WMResizeWidget(s
, 100, 16);
391 WMMoveWidget(s
, 100, 10);
392 WMSetSliderKnobThickness(s
, 8);
394 WMRealizeWidget(win
);
395 WMMapSubwidgets(win
);
400 testTextField(WMScreen
*scr
)
403 WMTextField
*field
, *field2
;
407 win
= WMCreateWindow(scr
, "testTextField");
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
);
428 testText(WMScreen
*scr
)
432 FILE *file
= fopen("../README", "r");
436 win
= WMCreateWindow(scr
, "testText");
437 WMResizeWidget(win
, 500, 300);
439 WMSetWindowCloseAction(win
, closeAction
, NULL
);
441 text
= WMCreateText(win
);
442 WMResizeWidget(text
, 480, 280);
443 WMMoveWidget(text
, 10, 10);
444 WMSetTextHasVerticalScroller(text
, True
);
445 WMSetTextEditable(text
, False
);
451 while(fgets(buf
, 1023, file
))
452 WMAppendTextStream(text
, buf
);
456 WMRefreshText(text
, 0, 0);
458 WMAppendTextStream(text
, "<HTML><i>Where's</i> the <b>README</b>?");
461 WMRealizeWidget(win
);
462 WMMapSubwidgets(win
);
469 testProgressIndicator(WMScreen
*scr
)
472 WMProgressIndicator
*pPtr
;
476 win
= WMCreateWindow(scr
, "testProgressIndicator");
477 WMResizeWidget(win
, 292, 32);
479 WMSetWindowCloseAction(win
, closeAction
, NULL
);
481 pPtr
= WMCreateProgressIndicator(win
);
482 WMMoveWidget(pPtr
, 8, 8);
483 WMSetProgressIndicatorValue(pPtr
, 75);
485 WMRealizeWidget(win
);
486 WMMapSubwidgets(win
);
493 testPullDown(WMScreen
*scr
)
496 WMPopUpButton
*pop
, *pop2
;
500 win
= WMCreateWindow(scr
, "pullDown");
501 WMResizeWidget(win
, 400, 300);
503 WMSetWindowCloseAction(win
, closeAction
, NULL
);
505 pop
= WMCreatePopUpButton(win
);
506 WMResizeWidget(pop
, 100, 20);
507 WMMoveWidget(pop
, 50, 60);
508 WMSetPopUpButtonPullsDown(pop
, True
);
509 WMSetPopUpButtonText(pop
, "Commands");
510 WMAddPopUpButtonItem(pop
, "Add");
511 WMAddPopUpButtonItem(pop
, "Remove");
512 WMAddPopUpButtonItem(pop
, "Check");
513 WMAddPopUpButtonItem(pop
, "Eat");
515 pop2
= WMCreatePopUpButton(win
);
516 WMResizeWidget(pop2
, 100, 20);
517 WMMoveWidget(pop2
, 200, 60);
518 WMSetPopUpButtonText(pop2
, "Select");
519 WMAddPopUpButtonItem(pop2
, "Apples");
520 WMAddPopUpButtonItem(pop2
, "Bananas");
521 WMAddPopUpButtonItem(pop2
, "Strawberries");
522 WMAddPopUpButtonItem(pop2
, "Blueberries");
524 WMRealizeWidget(win
);
525 WMMapSubwidgets(win
);
532 testTabView(WMScreen
*scr
)
542 win
= WMCreateWindow(scr
, "testTabs");
543 WMResizeWidget(win
, 400, 300);
545 WMSetWindowCloseAction(win
, closeAction
, NULL
);
547 tabv
= WMCreateTabView(win
);
548 WMMoveWidget(tabv
, 50, 50);
549 WMResizeWidget(tabv
, 300, 200);
551 frame
= WMCreateFrame(win
);
552 WMSetFrameRelief(frame
, WRFlat
);
553 label
= WMCreateLabel(frame
);
554 WMResizeWidget(label
, 100, 100);
555 WMSetLabelText(label
, "Label 1");
559 tab
= WMCreateTabViewItemWithIdentifier(0);
560 WMSetTabViewItemView(tab
, WMWidgetView(frame
));
561 WMAddItemInTabView(tabv
, tab
);
562 WMSetTabViewItemLabel(tab
, "Instances");
564 frame
= WMCreateFrame(win
);
565 WMSetFrameRelief(frame
, WRFlat
);
566 label
= WMCreateLabel(frame
);
567 WMResizeWidget(label
, 40, 50);
568 WMSetLabelText(label
, "Label 2");
572 tab
= WMCreateTabViewItemWithIdentifier(0);
573 WMSetTabViewItemView(tab
, WMWidgetView(frame
));
574 WMAddItemInTabView(tabv
, tab
);
575 WMSetTabViewItemLabel(tab
, "Classes");
578 frame
= WMCreateFrame(win
);
579 WMSetFrameRelief(frame
, WRFlat
);
580 label
= WMCreateLabel(frame
);
581 WMResizeWidget(label
, 100, 100);
582 WMMoveWidget(label
, 60, 40);
583 WMSetLabelText(label
, "Label 3");
586 tab
= WMCreateTabViewItemWithIdentifier(0);
587 WMSetTabViewItemView(tab
, WMWidgetView(frame
));
588 WMAddItemInTabView(tabv
, tab
);
589 WMSetTabViewItemLabel(tab
, "Something");
592 frame
= WMCreateFrame(win
);
593 WMSetFrameRelief(frame
, WRFlat
);
594 label
= WMCreateLabel(frame
);
595 WMResizeWidget(label
, 100, 100);
596 WMMoveWidget(label
, 160, 40);
597 WMSetLabelText(label
, "Label 4");
600 tab
= WMCreateTabViewItemWithIdentifier(0);
601 WMSetTabViewItemView(tab
, WMWidgetView(frame
));
602 WMAddItemInTabView(tabv
, tab
);
603 WMSetTabViewItemLabel(tab
, "Bla!");
607 frame
= WMCreateFrame(win
);
608 WMSetFrameRelief(frame
, WRFlat
);
609 label
= WMCreateLabel(frame
);
610 WMResizeWidget(label
, 100, 100);
611 WMMoveWidget(label
, 160, 40);
612 WMSetLabelText(label
, "Label fjweqklrj qwl");
614 tab
= WMCreateTabViewItemWithIdentifier(0);
615 WMSetTabViewItemView(tab
, WMWidgetView(frame
));
616 WMAddItemInTabView(tabv
, tab
);
617 WMSetTabViewItemLabel(tab
, "Weee!");
620 WMRealizeWidget(win
);
621 WMMapSubwidgets(win
);
627 splitViewConstrainProc(WMSplitView
*sPtr
, int indView
,
628 int *minSize
, int *maxSize
)
648 resizeSplitView(XEvent
*event
, void *data
)
650 WMSplitView
*sPtr
= (WMSplitView
*)data
;
652 if (event
->type
== ConfigureNotify
) {
653 int width
= event
->xconfigure
.width
- 10;
655 if (width
< WMGetSplitViewDividerThickness(sPtr
))
656 width
= WMGetSplitViewDividerThickness(sPtr
);
658 if (width
!= WMWidgetWidth(sPtr
) ||
659 event
->xconfigure
.height
!= WMWidgetHeight(sPtr
))
660 WMResizeWidget(sPtr
, width
, event
->xconfigure
.height
- 55);
665 appendSubviewButtonAction(WMWidget
*self
, void *data
)
667 WMSplitView
*sPtr
= (WMSplitView
*)data
;
669 WMLabel
*label
= WMCreateLabel(sPtr
);
671 sprintf(buf
, "Subview %d", WMGetSplitViewSubviewsCount(sPtr
) + 1);
672 WMSetLabelText(label
, buf
);
673 WMSetLabelRelief(label
, WRSunken
);
674 WMAddSplitViewSubview(sPtr
, WMWidgetView(label
));
675 WMRealizeWidget(label
);
680 removeSubviewButtonAction(WMWidget
*self
, void *data
)
682 WMSplitView
*sPtr
= (WMSplitView
*)data
;
683 int count
= WMGetSplitViewSubviewsCount(sPtr
);
686 WMView
*view
= WMGetSplitViewSubviewAt(sPtr
, count
-1);
687 WMDestroyWidget(WMWidgetOfView(view
));
688 WMRemoveSplitViewSubviewAt(sPtr
, count
-1);
693 orientationButtonAction(WMWidget
*self
, void *data
)
695 WMSplitView
*sPtr
= (WMSplitView
*)data
;
696 WMSetSplitViewVertical(sPtr
, !WMGetSplitViewVertical(sPtr
));
700 adjustSubviewsButtonAction(WMWidget
*self
, void *data
)
702 WMAdjustSplitViewSubviews((WMSplitView
*)data
);
706 testSplitView(WMScreen
*scr
)
709 WMSplitView
*splitv1
, *splitv2
;
716 win
= WMCreateWindow(scr
, "testTabs");
717 WMResizeWidget(win
, 300, 400);
718 WMSetWindowCloseAction(win
, closeAction
, NULL
);
720 frame
= WMCreateFrame(win
);
721 WMSetFrameRelief(frame
, WRSunken
);
722 WMMoveWidget(frame
, 5, 5);
723 WMResizeWidget(frame
, 290, 40);
725 splitv1
= WMCreateSplitView(win
);
726 WMMoveWidget(splitv1
, 5, 50);
727 WMResizeWidget(splitv1
, 290, 345);
728 WMSetSplitViewConstrainProc(splitv1
, splitViewConstrainProc
);
729 WMCreateEventHandler(WMWidgetView(win
), StructureNotifyMask
,
730 resizeSplitView
, splitv1
);
732 button
= WMCreateCommandButton(frame
);
733 WMSetButtonText(button
, "+");
734 WMSetButtonAction(button
, appendSubviewButtonAction
, splitv1
);
735 WMMoveWidget(button
, 10, 8);
738 button
= WMCreateCommandButton(frame
);
739 WMSetButtonText(button
, "-");
740 WMSetButtonAction(button
, removeSubviewButtonAction
, splitv1
);
741 WMMoveWidget(button
, 80, 8);
744 button
= WMCreateCommandButton(frame
);
745 WMSetButtonText(button
, "=");
746 WMMoveWidget(button
, 150, 8);
747 WMSetButtonAction(button
, adjustSubviewsButtonAction
, splitv1
);
750 button
= WMCreateCommandButton(frame
);
751 WMSetButtonText(button
, "#");
752 WMMoveWidget(button
, 220, 8);
753 WMSetButtonAction(button
, orientationButtonAction
, splitv1
);
756 label
= WMCreateLabel(splitv1
);
757 WMSetLabelText(label
, "Subview 1");
758 WMSetLabelRelief(label
, WRSunken
);
760 WMAddSplitViewSubview(splitv1
, WMWidgetView(label
));
762 splitv2
= WMCreateSplitView(splitv1
);
763 WMResizeWidget(splitv2
, 150, 150);
764 WMSetSplitViewVertical(splitv2
, True
);
766 label
= WMCreateLabel(splitv2
);
767 WMSetLabelText(label
, "Subview 2.1");
768 WMSetLabelRelief(label
, WRSunken
);
770 WMAddSplitViewSubview(splitv2
, WMWidgetView(label
));
772 label
= WMCreateLabel(splitv2
);
773 WMSetLabelText(label
, "Subview 2.2");
774 WMSetLabelRelief(label
, WRSunken
);
776 WMAddSplitViewSubview(splitv2
, WMWidgetView(label
));
778 label
= WMCreateLabel(splitv2
);
779 WMSetLabelText(label
, "Subview 2.3");
780 WMSetLabelRelief(label
, WRSunken
);
782 WMAddSplitViewSubview(splitv2
, WMWidgetView(label
));
784 WMMapWidget(splitv2
);
785 WMAddSplitViewSubview(splitv1
, WMWidgetView(splitv2
));
787 WMRealizeWidget(win
);
788 WMMapSubwidgets(win
);
793 /*******************************************************************/
795 #include <sys/types.h>
807 getImage(WMScreen
*scr
, char *file
)
812 sprintf(buffer
, "../../WindowMaker/Icons/%s", file
);
813 pix
= WMCreatePixmapFromFile(scr
, buffer
);
822 iconMouseStuff(XEvent
*event
, void *cdata
)
824 WMLabel
*label
= (WMLabel
*)cdata
;
825 DNDStuff
*stuff
= WMGetHangedData(label
);
828 switch (event
->type
) {
830 stuff
->x
= event
->xbutton
.x
;
831 stuff
->y
= event
->xbutton
.y
;
832 stuff
->mouseDown
= True
;
835 stuff
->mouseDown
= False
;
838 if (!stuff
->mouseDown
)
841 if (abs(stuff
->x
- event
->xmotion
.x
)>4
842 || abs(stuff
->y
- event
->xmotion
.y
)>4) {
844 where
= WMGetViewScreenPosition(WMWidgetView(label
));
846 WMDragImageFromView(WMWidgetView(label
),
847 WMGetLabelImage(label
),
850 wmksize(stuff
->x
, stuff
->y
),
859 endedDragImage(WMView
*self
, WMPixmap
*image
, WMPoint point
, Bool deposited
)
861 DNDStuff
*stuff
= WMGetHangedData(WMWidgetOfView(self
));
864 WMDestroyWidget(WMWidgetOfView(self
));
867 stuff
->mouseDown
= False
;
872 fetchDragData(WMView
*self
, char *type
)
874 DNDStuff
*stuff
= WMGetHangedData(WMWidgetOfView(self
));
876 return WMCreateDataWithBytes(stuff
->filename
, strlen(stuff
->filename
)+1);
880 WMDragSourceProcs dragSourceProcs
= {
888 /************************/
892 draggingEntered(WMView
*self
, WMDraggingInfo
*info
)
894 return WDOperationCopy
;
899 draggingUpdated(WMView
*self
, WMDraggingInfo
*info
)
901 return WDOperationCopy
;
905 void (*draggingExited)(WMView *self, WMDraggingInfo *info);
908 prepareForDragOperation(WMView
*self
, WMDraggingInfo
*info
)
910 return "application/X-WINGs-Bla";
914 WMLabel
* makeDraggableLabel(WMWidget
*w
, char *file
, int x
, int y
);
917 performDragOperation(WMView
*self
, WMDraggingInfo
*info
, WMData
*data
)
919 char *file
= (char*)WMDataBytes(data
);
922 pos
= WMGetDraggingInfoImageLocation(info
);
926 WMPoint pos2
= WMGetViewScreenPosition(self
);
929 label
= makeDraggableLabel(WMWidgetOfView(self
), file
,
930 pos
.x
-pos2
.x
, pos
.y
-pos2
.y
);
931 WMRealizeWidget(label
);
941 concludeDragOperation(WMView
*self
, WMDraggingInfo
*info
)
948 WMDragDestinationProcs dragDestProcs
= {
952 prepareForDragOperation
,
953 performDragOperation
,
954 concludeDragOperation
961 makeDraggableLabel(WMWidget
*w
, char *file
, int x
, int y
)
965 WMPixmap
*image
= getImage(WMWidgetScreen(w
), file
);
967 stuff
= wmalloc(sizeof(DNDStuff
));
968 stuff
->mouseDown
= False
;
970 stuff
->filename
= wstrdup(file
);
972 label
= WMCreateLabel(w
);
973 WMResizeWidget(label
, 48, 48);
974 WMMoveWidget(label
, x
, y
);
976 WMSetViewDragSourceProcs(WMWidgetView(label
), &dragSourceProcs
);
978 WMHangData(label
, stuff
);
980 WMCreateEventHandler(WMWidgetView(label
),
981 ButtonPressMask
|ButtonReleaseMask
|ButtonMotionMask
,
982 iconMouseStuff
, label
);
986 WMSetLabelImagePosition(label
, WIPImageOnly
);
987 WMSetLabelImage(label
, image
);
988 WMReleasePixmap(image
);
997 testDragAndDrop(WMScreen
*scr
)
1006 "application/X-WINGs-Bla",
1012 win
= WMCreateWindow(scr
, "dragDrop");
1013 WMResizeWidget(win
, 300, 300);
1014 WMSetWindowCloseAction(win
, closeAction
, NULL
);
1015 WMSetWindowTitle(win
, "Drag and Drop");
1018 frame
= WMCreateFrame(win
);
1019 WMSetFrameRelief(frame
, WRSunken
);
1020 WMResizeWidget(frame
, 250, 250);
1021 WMMoveWidget(frame
, 25, 25);
1023 WMRegisterViewForDraggedTypes(WMWidgetView(frame
), types
);
1024 WMSetViewDragDestinationProcs(WMWidgetView(frame
), &dragDestProcs
);
1026 dir
= opendir("../../WindowMaker/Icons");
1028 perror("../../WindowMaker/Icons");
1032 for (i
= 0, j
=0; j
< 8; i
++) {
1037 if (strstr(ent
->d_name
, ".xpm")==NULL
) {
1041 label
= makeDraggableLabel(frame
, ent
->d_name
,4+(j
/4)*64, 4+(j
%4)*64);
1048 WMMapSubwidgets(frame
);
1050 WMMapSubwidgets(win
);
1051 WMRealizeWidget(win
);
1059 /*******************************************************************/
1066 WMUserDefaults
*defs
;
1069 defs
= WMGetStandardUserDefaults();
1071 sprintf(str
, "TEST DATA");
1073 WMSetUDStringForKey(defs
, str
, "testKey");
1079 main(int argc
, char **argv
)
1085 /* Initialize the application */
1086 WMInitializeApplication("Test", &argc
, argv
);
1091 * Open connection to the X display.
1093 dpy
= XOpenDisplay("");
1096 puts("could not open display");
1100 /* This is used to disable buffering of X protocol requests.
1101 * Do NOT use it unless when debugging. It will cause a major
1102 * slowdown in your application
1105 XSynchronize(dpy
, True
);
1108 * Create screen descriptor.
1110 scr
= WMCreateScreen(dpy
, DefaultScreen(dpy
));
1113 * Loads the logo of the application.
1115 pixmap
= WMCreatePixmapFromFile(scr
, "logo.xpm");
1118 * Makes the logo be used in standard dialog panels.
1120 WMSetApplicationIconImage(scr
, pixmap
); WMReleasePixmap(pixmap
);
1123 * Do some test stuff.
1125 * Put the testSomething() function you want to test here.
1135 testDragAndDrop(scr
);
1136 testDragAndDrop(scr
);
1139 testScrollView(scr
);
1152 testGradientButtons(scr
);
1153 testProgressIndicator(scr
);
1156 testOpenFilePanel(scr
);
1162 * The main event loop.
1165 WMScreenMainLoop(scr
);