Delete button in file panel.
[wmaker-crm.git] / WINGs / widgets.c
bloba230947c4db006d2cf17e9c76aa51e9d849ec839
3 #include "WINGsP.h"
5 #include <X11/Xutil.h>
7 #include <X11/cursorfont.h>
9 /********** data ************/
12 #define CHECK_BUTTON_ON_WIDTH 16
13 #define CHECK_BUTTON_ON_HEIGHT 16
15 static char *CHECK_BUTTON_ON[] = {
16 " %",
17 " .............%#",
18 " ........... .%#",
19 " .......... #.%#",
20 " ......... #%.%#",
21 " ........ #%..%#",
22 " ... #.. #%...%#",
23 " ... #% #%....%#",
24 " ... % #%.....%#",
25 " ... #%......%#",
26 " ... #%.......%#",
27 " ...#%........%#",
28 " .............%#",
29 " .............%#",
30 " %%%%%%%%%%%%%%#",
31 "%###############"};
33 #define CHECK_BUTTON_OFF_WIDTH 16
34 #define CHECK_BUTTON_OFF_HEIGHT 16
36 static char *CHECK_BUTTON_OFF[] = {
37 " %",
38 " .............%#",
39 " .............%#",
40 " .............%#",
41 " .............%#",
42 " .............%#",
43 " .............%#",
44 " .............%#",
45 " .............%#",
46 " .............%#",
47 " .............%#",
48 " .............%#",
49 " .............%#",
50 " .............%#",
51 " %%%%%%%%%%%%%%#",
52 "%###############"};
54 #define RADIO_BUTTON_ON_WIDTH 15
55 #define RADIO_BUTTON_ON_HEIGHT 15
56 static char *RADIO_BUTTON_ON[] = {
57 ".....%%%%%.....",
58 "...%%#####%%...",
59 "..%##.....%.%..",
60 ".%#%.. .....",
61 ".%#. ...",
62 "%#.. .. ",
63 "%#. . ",
64 "%#. . ",
65 "%#. . ",
66 "%#. . ",
67 ".%%. . .",
68 ".%.. . .",
69 "..%... .. ..",
70 ".... ..... ...",
71 "..... .....",
74 #define RADIO_BUTTON_OFF_WIDTH 15
75 #define RADIO_BUTTON_OFF_HEIGHT 15
76 static char *RADIO_BUTTON_OFF[] = {
77 ".....%%%%%.....",
78 "...%%#####%%...",
79 "..%##.......%..",
80 ".%#%...........",
81 ".%#............",
82 "%#............ ",
83 "%#............ ",
84 "%#............ ",
85 "%#............ ",
86 "%#............ ",
87 ".%%.......... .",
88 ".%........... .",
89 "..%......... ..",
90 ".... ..... ...",
91 "..... .....",
95 static char *BUTTON_ARROW[] = {
96 "..................",
97 "....##....#### ...",
98 "...#.%....#... ...",
99 "..#..%#####... ...",
100 ".#............ ...",
101 "#............. ...",
102 ".#............ ...",
103 "..#.. ...",
104 "...#. ............",
105 "....# ............"
108 #define BUTTON_ARROW_WIDTH 18
109 #define BUTTON_ARROW_HEIGHT 10
112 static char *BUTTON_ARROW2[] = {
113 " ",
114 " ## ####. ",
115 " # % # . ",
116 " # %##### . ",
117 " # . ",
118 "# . ",
119 " # . ",
120 " # .......... ",
121 " # . ",
122 " #. "
125 #define BUTTON_ARROW2_WIDTH 18
126 #define BUTTON_ARROW2_HEIGHT 10
129 static char *SCROLLER_DIMPLE[] = {
130 ".%###.",
131 "%#%%%%",
132 "#%%...",
133 "#%.. ",
134 "#%. ",
135 ".%. ."
138 #define SCROLLER_DIMPLE_WIDTH 6
139 #define SCROLLER_DIMPLE_HEIGHT 6
142 static char *SCROLLER_ARROW_UP[] = {
143 "....%....",
144 "....#....",
145 "...%#%...",
146 "...###...",
147 "..%###%..",
148 "..#####..",
149 ".%#####%.",
150 ".#######.",
151 "%#######%"
154 static char *HI_SCROLLER_ARROW_UP[] = {
155 " % ",
156 " % ",
157 " %%% ",
158 " %%% ",
159 " %%%%% ",
160 " %%%%% ",
161 " %%%%%%% ",
162 " %%%%%%% ",
163 "%%%%%%%%%"
166 #define SCROLLER_ARROW_UP_WIDTH 9
167 #define SCROLLER_ARROW_UP_HEIGHT 9
170 static char *SCROLLER_ARROW_DOWN[] = {
171 "%#######%",
172 ".#######.",
173 ".%#####%.",
174 "..#####..",
175 "..%###%..",
176 "...###...",
177 "...%#%...",
178 "....#....",
179 "....%...."
182 static char *HI_SCROLLER_ARROW_DOWN[] = {
183 "%%%%%%%%%",
184 " %%%%%%% ",
185 " %%%%%%% ",
186 " %%%%% ",
187 " %%%%% ",
188 " %%% ",
189 " %%% ",
190 " % ",
191 " % "
194 #define SCROLLER_ARROW_DOWN_WIDTH 9
195 #define SCROLLER_ARROW_DOWN_HEIGHT 9
199 static char *SCROLLER_ARROW_LEFT[] = {
200 "........%",
201 "......%##",
202 "....%####",
203 "..%######",
204 "%########",
205 "..%######",
206 "....%####",
207 "......%##",
208 "........%"
211 static char *HI_SCROLLER_ARROW_LEFT[] = {
212 " %",
213 " %%%",
214 " %%%%%",
215 " %%%%%%%",
216 "%%%%%%%%%",
217 " %%%%%%%",
218 " %%%%%",
219 " %%%",
220 " %"
223 #define SCROLLER_ARROW_LEFT_WIDTH 9
224 #define SCROLLER_ARROW_LEFT_HEIGHT 9
227 static char *SCROLLER_ARROW_RIGHT[] = {
228 "%........",
229 "##%......",
230 "####%....",
231 "######%..",
232 "########%",
233 "######%..",
234 "####%....",
235 "##%......",
236 "%........"
239 static char *HI_SCROLLER_ARROW_RIGHT[] = {
240 "% ",
241 "%%% ",
242 "%%%%% ",
243 "%%%%%%% ",
244 "%%%%%%%%%",
245 "%%%%%%% ",
246 "%%%%% ",
247 "%%% ",
248 "% "
251 #define SCROLLER_ARROW_RIGHT_WIDTH 9
252 #define SCROLLER_ARROW_RIGHT_HEIGHT 9
255 static char *POPUP_INDICATOR[] = {
256 " #==",
257 " ......%#==",
258 " ......%#%%",
259 " ......%#%%",
260 " %%%%%%%#%%",
261 "#########%%",
262 "==%%%%%%%%%",
263 "==%%%%%%%%%"
266 #define POPUP_INDICATOR_WIDTH 11
267 #define POPUP_INDICATOR_HEIGHT 8
271 static char *PULLDOWN_INDICATOR[] = {
272 "=#######=",
273 "=%===== =",
274 "==%=== ==",
275 "==%=== ==",
276 "===%= ===",
277 "===%= ===",
278 "====%===="
280 #define PULLDOWN_INDICATOR_WIDTH 9
281 #define PULLDOWN_INDICATOR_HEIGHT 7
284 #define CHECK_MARK_WIDTH 8
285 #define CHECK_MARK_HEIGHT 10
287 static char *CHECK_MARK[] = {
288 "======== ",
289 "======= #",
290 "====== #%",
291 "===== #%=",
292 " #== #%==",
293 " #% #%===",
294 " % #%====",
295 " #%=====",
296 " #%======",
297 "#%======="};
300 #define STIPPLE_WIDTH 8
301 #define STIPPLE_HEIGHT 8
302 static unsigned char STIPPLE_BITS[] = {
303 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa
309 extern void W_ReadConfigurations(void);
312 static int userWidgetCount=0;
315 /***** end data ******/
318 static void
319 renderPixmap(W_Screen *screen, Pixmap d, Pixmap mask, char **data,
320 int width, int height)
322 int x, y;
323 GC whiteGC = WMColorGC(screen->white);
324 GC blackGC = WMColorGC(screen->black);
325 GC lightGC = WMColorGC(screen->gray);
326 GC darkGC = WMColorGC(screen->darkGray);
329 if (mask)
330 XSetForeground(screen->display, screen->monoGC, 0);
332 for (y = 0; y < height; y++) {
333 for (x = 0; x < width; x++) {
334 switch (data[y][x]) {
335 case ' ':
336 case 'w':
337 XDrawPoint(screen->display, d, whiteGC, x, y);
338 break;
340 case '=':
341 if (mask)
342 XDrawPoint(screen->display, mask, screen->monoGC, x, y);
344 case '.':
345 case 'l':
346 XDrawPoint(screen->display, d, lightGC, x, y);
347 break;
349 case '%':
350 case 'd':
351 XDrawPoint(screen->display, d, darkGC, x, y);
352 break;
354 case '#':
355 case 'b':
356 default:
357 XDrawPoint(screen->display, d, blackGC, x, y);
358 break;
366 static WMPixmap*
367 makePixmap(W_Screen *sPtr, char **data, int width, int height, int masked)
369 Pixmap pixmap, mask = None;
371 pixmap = XCreatePixmap(sPtr->display, W_DRAWABLE(sPtr), width, height,
372 sPtr->depth);
374 if (masked) {
375 mask = XCreatePixmap(sPtr->display, W_DRAWABLE(sPtr), width, height, 1);
376 XSetForeground(sPtr->display, sPtr->monoGC, 1);
377 XFillRectangle(sPtr->display, mask, sPtr->monoGC, 0, 0, width, height);
380 renderPixmap(sPtr, pixmap, mask, data, width, height);
382 return WMCreatePixmapFromXPixmaps(sPtr, pixmap, mask, width, height,
383 sPtr->depth);
387 #define T_WINGS_IMAGES_FILE RESOURCE_PATH"/Images.tiff"
388 #define T_DEFAULT_OBJECT_ICON_FILE RESOURCE_PATH"/defaultIcon.tiff"
390 #define X_WINGS_IMAGES_FILE RESOURCE_PATH"/Images.xpm"
391 #define X_DEFAULT_OBJECT_ICON_FILE RESOURCE_PATH"/defaultIcon.xpm"
394 static Bool
395 loadPixmaps(WMScreen *scr)
397 RImage *image, *tmp;
398 RColor gray;
399 RColor white;
401 gray.red = 0xae;
402 gray.green = 0xaa;
403 gray.blue = 0xae;
405 white.red = 0xff;
406 white.green = 0xff;
407 white.blue = 0xff;
409 image = RLoadImage(scr->rcontext, T_WINGS_IMAGES_FILE, 0);
410 if (!image)
411 image = RLoadImage(scr->rcontext, X_WINGS_IMAGES_FILE, 0);
412 if (!image) {
413 wwarning("WINGs: could not load widget images file: %s",
414 RMessageForError(RErrorCode));
415 return False;
417 /* home icon */
418 /* make it have a gray background */
419 tmp = RGetSubImage(image, 0, 0, 24, 24);
420 RCombineImageWithColor(tmp, &gray);
421 scr->homeIcon = WMCreatePixmapFromRImage(scr, tmp, 128);
422 RDestroyImage(tmp);
423 /* make it have a white background */
424 tmp = RGetSubImage(image, 0, 0, 24, 24);
425 RCombineImageWithColor(tmp, &white);
426 scr->altHomeIcon = WMCreatePixmapFromRImage(scr, tmp, 128);
427 RDestroyImage(tmp);
429 /* trash can */
430 tmp = RGetSubImage(image, 105, 0, 24, 24);
431 RCombineImageWithColor(tmp, &white);
432 scr->trashcanIcon = WMCreatePixmapFromRImage(scr, tmp, 128);
433 RDestroyImage(tmp);
434 tmp = RGetSubImage(image, 105, 0, 24, 24);
435 RCombineImageWithColor(tmp, &white);
436 scr->altTrashcanIcon = WMCreatePixmapFromRImage(scr, tmp, 128);
437 RDestroyImage(tmp);
440 tmp = RGetSubImage(image, 0, 0, 24, 24);
441 RCombineImageWithColor(tmp, &white);
442 scr->altHomeIcon = WMCreatePixmapFromRImage(scr, tmp, 128);
443 RDestroyImage(tmp);
445 /* Magnifying Glass Icon for ColorPanel */
446 tmp = RGetSubImage(image, 24, 0, 40, 32);
447 RCombineImageWithColor(tmp, &gray);
448 scr->magnifyIcon = WMCreatePixmapFromRImage(scr, tmp, 128);
449 RDestroyImage(tmp);
451 tmp = RGetSubImage(image, 24, 0, 40, 32);
452 RCombineImageWithColor(tmp, &white);
453 scr->altMagnifyIcon = WMCreatePixmapFromRImage(scr, tmp, 128);
454 RDestroyImage(tmp);
456 /* ColorWheel Icon for ColorPanel */
457 tmp = RGetSubImage(image, 0, 25, 24, 24);
458 scr->wheelIcon = WMCreatePixmapFromRImage(scr, tmp, 128);
459 RDestroyImage(tmp);
460 /* GrayScale Icon for ColorPanel */
461 tmp = RGetSubImage(image, 65, 0, 40, 24);
462 scr->grayIcon = WMCreatePixmapFromRImage(scr, tmp, 128);
463 RDestroyImage(tmp);
464 /* RGB Icon for ColorPanel */
465 tmp = RGetSubImage(image, 25, 33, 40, 24);
466 scr->rgbIcon = WMCreatePixmapFromRImage(scr, tmp, 128);
467 RDestroyImage(tmp);
468 /* CMYK Icon for ColorPanel */
469 tmp = RGetSubImage(image, 65, 25, 40, 24);
470 scr->cmykIcon = WMCreatePixmapFromRImage(scr, tmp, 128);
471 RDestroyImage(tmp);
472 /* HSB Icon for ColorPanel */
473 tmp = RGetSubImage(image, 0, 57, 40, 24);
474 scr->hsbIcon = WMCreatePixmapFromRImage(scr, tmp, 128);
475 RDestroyImage(tmp);
476 /* CustomColorPalette Icon for ColorPanel */
477 tmp = RGetSubImage(image, 81, 57, 40, 24);
478 scr->customPaletteIcon = WMCreatePixmapFromRImage(scr, tmp, 128);
479 RDestroyImage(tmp);
480 /* ColorList Icon for ColorPanel */
481 tmp = RGetSubImage(image, 41, 57, 40, 24);
482 scr->colorListIcon = WMCreatePixmapFromRImage(scr, tmp, 128);
483 RDestroyImage(tmp);
485 RDestroyImage(image);
487 #if 0
488 scr->defaultObjectIcon =
489 WMCreatePixmapFromFile(scr, T_DEFAULT_OBJECT_ICON_FILE);
490 if (!scr->defaultObjectIcon) {
491 scr->defaultObjectIcon =
492 WMCreatePixmapFromFile(scr, X_DEFAULT_OBJECT_ICON_FILE);
494 if (!scr->defaultObjectIcon) {
495 wwarning("WINGs: could not load default icon file");
496 return False;
498 #endif
499 return True;
504 WMScreen*
505 WMCreateSimpleApplicationScreen(Display *display)
507 WMScreen *scr;
509 scr = WMCreateScreen(display, DefaultScreen(display));
511 scr->aflags.hasAppIcon = 0;
512 scr->aflags.simpleApplication = 1;
514 return scr;
519 WMScreen*
520 WMCreateScreen(Display *display, int screen)
522 return WMCreateScreenWithRContext(display, screen,
523 RCreateContext(display, screen, NULL));
527 WMScreen*
528 WMCreateScreenWithRContext(Display *display, int screen, RContext *context)
530 W_Screen *scrPtr;
531 XGCValues gcv;
532 Pixmap stipple;
533 static int initialized = 0;
535 if (!initialized) {
537 initialized = 1;
539 W_ReadConfigurations();
541 assert(W_ApplicationInitialized());
544 scrPtr = malloc(sizeof(W_Screen));
545 if (!scrPtr)
546 return NULL;
547 memset(scrPtr, 0, sizeof(W_Screen));
549 scrPtr->aflags.hasAppIcon = 1;
551 scrPtr->display = display;
552 scrPtr->screen = screen;
553 scrPtr->rcontext = context;
555 scrPtr->depth = context->depth;
557 scrPtr->visual = context->visual;
558 scrPtr->lastEventTime = 0;
560 scrPtr->colormap = context->cmap;
562 scrPtr->rootWin = RootWindow(display, screen);
564 scrPtr->fontCache = WMCreateHashTable(WMStringPointerHashCallbacks);
566 /* initially allocate some colors */
567 WMWhiteColor(scrPtr);
568 WMBlackColor(scrPtr);
569 WMGrayColor(scrPtr);
570 WMDarkGrayColor(scrPtr);
572 gcv.graphics_exposures = False;
574 gcv.function = GXxor;
575 gcv.foreground = W_PIXEL(scrPtr->white);
576 if (gcv.foreground == 0) gcv.foreground = 1;
577 scrPtr->xorGC = XCreateGC(display, W_DRAWABLE(scrPtr), GCFunction
578 |GCGraphicsExposures|GCForeground, &gcv);
580 gcv.function = GXxor;
581 gcv.foreground = W_PIXEL(scrPtr->gray);
582 gcv.subwindow_mode = IncludeInferiors;
583 scrPtr->ixorGC = XCreateGC(display, W_DRAWABLE(scrPtr), GCFunction
584 |GCGraphicsExposures|GCForeground
585 |GCSubwindowMode, &gcv);
587 gcv.function = GXcopy;
588 scrPtr->copyGC = XCreateGC(display, W_DRAWABLE(scrPtr), GCFunction
589 |GCGraphicsExposures, &gcv);
591 scrPtr->clipGC = XCreateGC(display, W_DRAWABLE(scrPtr), GCFunction
592 |GCGraphicsExposures, &gcv);
595 stipple = XCreateBitmapFromData(display, W_DRAWABLE(scrPtr),
596 STIPPLE_BITS, STIPPLE_WIDTH, STIPPLE_HEIGHT);
597 gcv.foreground = W_PIXEL(scrPtr->darkGray);
598 gcv.background = W_PIXEL(scrPtr->gray);
599 gcv.fill_style = FillStippled;
600 gcv.stipple = stipple;
601 scrPtr->stippleGC = XCreateGC(display, W_DRAWABLE(scrPtr),
602 GCForeground|GCBackground|GCStipple
603 |GCFillStyle|GCGraphicsExposures, &gcv);
605 gcv.foreground = W_PIXEL(scrPtr->black);
606 gcv.background = W_PIXEL(scrPtr->white);
607 scrPtr->textFieldGC = XCreateGC(display, W_DRAWABLE(scrPtr),
608 GCForeground|GCBackground, &gcv);
610 /* we need a 1bpp drawable for the monoGC, so borrow this one */
611 scrPtr->monoGC = XCreateGC(display, stipple, 0, NULL);
613 scrPtr->stipple = stipple;
615 scrPtr->useMultiByte = WINGsConfiguration.useMultiByte;
617 scrPtr->normalFont = WMSystemFontOfSize(scrPtr, 12);
619 scrPtr->boldFont = WMBoldSystemFontOfSize(scrPtr, 12);
621 if (!scrPtr->boldFont)
622 scrPtr->boldFont = scrPtr->normalFont;
624 if (!scrPtr->normalFont) {
625 wwarning("could not load any fonts. Make sure your font installation"
626 "and locale settings are correct.");
628 return NULL;
631 scrPtr->checkButtonImageOn = makePixmap(scrPtr, CHECK_BUTTON_ON,
632 CHECK_BUTTON_ON_WIDTH,
633 CHECK_BUTTON_ON_HEIGHT, False);
635 scrPtr->checkButtonImageOff = makePixmap(scrPtr, CHECK_BUTTON_OFF,
636 CHECK_BUTTON_OFF_WIDTH,
637 CHECK_BUTTON_OFF_HEIGHT, False);
639 scrPtr->radioButtonImageOn = makePixmap(scrPtr, RADIO_BUTTON_ON,
640 RADIO_BUTTON_ON_WIDTH,
641 RADIO_BUTTON_ON_HEIGHT, False);
643 scrPtr->radioButtonImageOff = makePixmap(scrPtr, RADIO_BUTTON_OFF,
644 RADIO_BUTTON_OFF_WIDTH,
645 RADIO_BUTTON_OFF_HEIGHT, False);
647 scrPtr->buttonArrow = makePixmap(scrPtr, BUTTON_ARROW,
648 BUTTON_ARROW_WIDTH, BUTTON_ARROW_HEIGHT,
649 False);
651 scrPtr->pushedButtonArrow = makePixmap(scrPtr, BUTTON_ARROW2,
652 BUTTON_ARROW2_WIDTH, BUTTON_ARROW2_HEIGHT,
653 False);
656 scrPtr->scrollerDimple = makePixmap(scrPtr, SCROLLER_DIMPLE,
657 SCROLLER_DIMPLE_WIDTH,
658 SCROLLER_DIMPLE_HEIGHT, False);
661 scrPtr->upArrow = makePixmap(scrPtr, SCROLLER_ARROW_UP,
662 SCROLLER_ARROW_UP_WIDTH,
663 SCROLLER_ARROW_UP_HEIGHT, True);
665 scrPtr->downArrow = makePixmap(scrPtr, SCROLLER_ARROW_DOWN,
666 SCROLLER_ARROW_DOWN_WIDTH,
667 SCROLLER_ARROW_DOWN_HEIGHT, True);
669 scrPtr->leftArrow = makePixmap(scrPtr, SCROLLER_ARROW_LEFT,
670 SCROLLER_ARROW_LEFT_WIDTH,
671 SCROLLER_ARROW_LEFT_HEIGHT, True);
673 scrPtr->rightArrow = makePixmap(scrPtr, SCROLLER_ARROW_RIGHT,
674 SCROLLER_ARROW_RIGHT_WIDTH,
675 SCROLLER_ARROW_RIGHT_HEIGHT, True);
677 scrPtr->hiUpArrow = makePixmap(scrPtr, HI_SCROLLER_ARROW_UP,
678 SCROLLER_ARROW_UP_WIDTH,
679 SCROLLER_ARROW_UP_HEIGHT, True);
681 scrPtr->hiDownArrow = makePixmap(scrPtr, HI_SCROLLER_ARROW_DOWN,
682 SCROLLER_ARROW_DOWN_WIDTH,
683 SCROLLER_ARROW_DOWN_HEIGHT, True);
685 scrPtr->hiLeftArrow = makePixmap(scrPtr, HI_SCROLLER_ARROW_LEFT,
686 SCROLLER_ARROW_LEFT_WIDTH,
687 SCROLLER_ARROW_LEFT_HEIGHT, True);
689 scrPtr->hiRightArrow = makePixmap(scrPtr, HI_SCROLLER_ARROW_RIGHT,
690 SCROLLER_ARROW_RIGHT_WIDTH,
691 SCROLLER_ARROW_RIGHT_HEIGHT, True);
693 scrPtr->popUpIndicator = makePixmap(scrPtr, POPUP_INDICATOR,
694 POPUP_INDICATOR_WIDTH,
695 POPUP_INDICATOR_HEIGHT, True);
697 scrPtr->pullDownIndicator = makePixmap(scrPtr, PULLDOWN_INDICATOR,
698 PULLDOWN_INDICATOR_WIDTH,
699 PULLDOWN_INDICATOR_HEIGHT, True);
701 scrPtr->checkMark = makePixmap(scrPtr, CHECK_MARK,
702 CHECK_MARK_WIDTH,
703 CHECK_MARK_HEIGHT, True);
705 loadPixmaps(scrPtr);
707 scrPtr->defaultCursor = XCreateFontCursor(display, XC_left_ptr);
709 scrPtr->textCursor = XCreateFontCursor(display, XC_xterm);
712 XColor bla;
713 Pixmap blank;
715 blank = XCreatePixmap(display, scrPtr->stipple, 1, 1, 1);
716 XSetForeground(display, scrPtr->monoGC, 0);
717 XFillRectangle(display, blank, scrPtr->monoGC, 0, 0, 1, 1);
719 scrPtr->invisibleCursor = XCreatePixmapCursor(display, blank, blank,
720 &bla, &bla, 0, 0);
721 XFreePixmap(display, blank);
724 scrPtr->internalMessage = XInternAtom(display, "_WINGS_MESSAGE", False);
726 scrPtr->attribsAtom = XInternAtom(display, "_GNUSTEP_WM_ATTR", False);
728 scrPtr->deleteWindowAtom = XInternAtom(display, "WM_DELETE_WINDOW", False);
730 scrPtr->protocolsAtom = XInternAtom(display, "WM_PROTOCOLS", False);
732 scrPtr->clipboardAtom = XInternAtom(display, "CLIPBOARD", False);
734 scrPtr->rootView = W_CreateRootView(scrPtr);
737 scrPtr->balloon = W_CreateBalloon(scrPtr);
740 W_InitApplication(scrPtr);
742 return scrPtr;
746 void
747 WMHangData(WMWidget *widget, void *data)
749 W_VIEW(widget)->hangedData = data;
753 void*
754 WMGetHangedData(WMWidget *widget)
756 return W_VIEW(widget)->hangedData;
761 void
762 WMDestroyWidget(WMWidget *widget)
764 W_DestroyView(W_VIEW(widget));
768 void
769 WMSetFocusToWidget(WMWidget *widget)
771 W_SetFocusOfTopLevel(W_TopLevelOfView(W_VIEW(widget)), W_VIEW(widget));
776 * WMRealizeWidget-
777 * Realizes the widget and all it's children.
780 void
781 WMRealizeWidget(WMWidget *w)
783 W_RealizeView(W_VIEW(w));
786 void
787 WMMapWidget(WMWidget *w)
789 W_MapView(W_VIEW(w));
793 static void
794 makeChildrenAutomap(W_View *view, int flag)
796 view = view->childrenList;
798 while (view) {
799 view->flags.mapWhenRealized = flag;
800 makeChildrenAutomap(view, flag);
802 view = view->nextSister;
807 void
808 WMMapSubwidgets(WMWidget *w)
810 /* make sure that subwidgets created after the parent was realized
811 * are mapped too */
812 if (!W_VIEW(w)->flags.realized) {
813 makeChildrenAutomap(W_VIEW(w), True);
814 } else {
815 W_MapSubviews(W_VIEW(w));
820 void
821 WMUnmapSubwidgets(WMWidget *w)
823 if (!W_VIEW(w)->flags.realized) {
824 makeChildrenAutomap(W_VIEW(w), False);
825 } else {
826 W_UnmapSubviews(W_VIEW(w));
832 void
833 WMUnmapWidget(WMWidget *w)
835 W_UnmapView(W_VIEW(w));
839 void
840 WMSetWidgetBackgroundColor(WMWidget *w, WMColor *color)
842 W_SetViewBackgroundColor(W_VIEW(w), color);
846 void
847 WMMoveWidget(WMWidget *w, int x, int y)
849 W_MoveView(W_VIEW(w), x, y);
853 void
854 WMResizeWidget(WMWidget *w, unsigned int width, unsigned int height)
856 W_ResizeView(W_VIEW(w), width, height);
861 W_Class
862 W_RegisterUserWidget(void)
864 userWidgetCount++;
866 return userWidgetCount + WC_UserWidget - 1;
871 RContext*
872 WMScreenRContext(WMScreen *scr)
874 return scr->rcontext;
879 unsigned int
880 WMWidgetWidth(WMWidget *w)
882 return W_VIEW(w)->size.width;
886 unsigned int
887 WMWidgetHeight(WMWidget *w)
889 return W_VIEW(w)->size.height;
893 Window
894 WMWidgetXID(WMWidget *w)
896 return W_VIEW(w)->window;
900 WMScreen*
901 WMWidgetScreen(WMWidget *w)
903 return W_VIEW(w)->screen;
908 void
909 WMScreenMainLoop(WMScreen *scr)
911 XEvent event;
913 while (1) {
914 WMNextEvent(scr->display, &event);
915 WMHandleEvent(&event);
921 Display*
922 WMScreenDisplay(WMScreen *scr)
924 return scr->display;
928 int
929 WMScreenDepth(WMScreen *scr)
931 return scr->depth;
935 void
936 WMRedisplayWidget(WMWidget *w)
938 W_RedisplayView(W_VIEW(w));