Fixed some problems in 0.60.0
[wmaker-crm.git] / WINGs / widgets.c
blobf04f094d02e95e6b72bdbd33eac506d1605b7834
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);
438 /* diskette */
439 tmp = RGetSubImage(image, 105, 25, 24, 24);
440 RCombineImageWithColor(tmp, &white);
441 scr->disketteIcon = WMCreatePixmapFromRImage(scr, tmp, 128);
442 RDestroyImage(tmp);
443 tmp = RGetSubImage(image, 105, 25, 24, 24);
444 RCombineImageWithColor(tmp, &white);
445 scr->altDisketteIcon = WMCreatePixmapFromRImage(scr, tmp, 128);
446 RDestroyImage(tmp);
449 tmp = RGetSubImage(image, 0, 0, 24, 24);
450 RCombineImageWithColor(tmp, &white);
451 scr->altHomeIcon = WMCreatePixmapFromRImage(scr, tmp, 128);
452 RDestroyImage(tmp);
454 /* Magnifying Glass Icon for ColorPanel */
455 tmp = RGetSubImage(image, 24, 0, 40, 32);
456 RCombineImageWithColor(tmp, &gray);
457 scr->magnifyIcon = WMCreatePixmapFromRImage(scr, tmp, 128);
458 RDestroyImage(tmp);
460 tmp = RGetSubImage(image, 24, 0, 40, 32);
461 RCombineImageWithColor(tmp, &white);
462 scr->altMagnifyIcon = WMCreatePixmapFromRImage(scr, tmp, 128);
463 RDestroyImage(tmp);
465 /* ColorWheel Icon for ColorPanel */
466 tmp = RGetSubImage(image, 0, 25, 24, 24);
467 scr->wheelIcon = WMCreatePixmapFromRImage(scr, tmp, 128);
468 RDestroyImage(tmp);
469 /* GrayScale Icon for ColorPanel */
470 tmp = RGetSubImage(image, 65, 0, 40, 24);
471 scr->grayIcon = WMCreatePixmapFromRImage(scr, tmp, 128);
472 RDestroyImage(tmp);
473 /* RGB Icon for ColorPanel */
474 tmp = RGetSubImage(image, 25, 33, 40, 24);
475 scr->rgbIcon = WMCreatePixmapFromRImage(scr, tmp, 128);
476 RDestroyImage(tmp);
477 /* CMYK Icon for ColorPanel */
478 tmp = RGetSubImage(image, 65, 25, 40, 24);
479 scr->cmykIcon = WMCreatePixmapFromRImage(scr, tmp, 128);
480 RDestroyImage(tmp);
481 /* HSB Icon for ColorPanel */
482 tmp = RGetSubImage(image, 0, 57, 40, 24);
483 scr->hsbIcon = WMCreatePixmapFromRImage(scr, tmp, 128);
484 RDestroyImage(tmp);
485 /* CustomColorPalette Icon for ColorPanel */
486 tmp = RGetSubImage(image, 81, 57, 40, 24);
487 scr->customPaletteIcon = WMCreatePixmapFromRImage(scr, tmp, 128);
488 RDestroyImage(tmp);
489 /* ColorList Icon for ColorPanel */
490 tmp = RGetSubImage(image, 41, 57, 40, 24);
491 scr->colorListIcon = WMCreatePixmapFromRImage(scr, tmp, 128);
492 RDestroyImage(tmp);
494 RDestroyImage(image);
496 #if 0
497 scr->defaultObjectIcon =
498 WMCreatePixmapFromFile(scr, T_DEFAULT_OBJECT_ICON_FILE);
499 if (!scr->defaultObjectIcon) {
500 scr->defaultObjectIcon =
501 WMCreatePixmapFromFile(scr, X_DEFAULT_OBJECT_ICON_FILE);
503 if (!scr->defaultObjectIcon) {
504 wwarning("WINGs: could not load default icon file");
505 return False;
507 #endif
508 return True;
513 WMScreen*
514 WMCreateSimpleApplicationScreen(Display *display)
516 WMScreen *scr;
518 scr = WMCreateScreen(display, DefaultScreen(display));
520 scr->aflags.hasAppIcon = 0;
521 scr->aflags.simpleApplication = 1;
523 return scr;
528 WMScreen*
529 WMCreateScreen(Display *display, int screen)
531 return WMCreateScreenWithRContext(display, screen,
532 RCreateContext(display, screen, NULL));
536 WMScreen*
537 WMCreateScreenWithRContext(Display *display, int screen, RContext *context)
539 W_Screen *scrPtr;
540 XGCValues gcv;
541 Pixmap stipple;
542 static int initialized = 0;
544 if (!initialized) {
546 initialized = 1;
548 W_ReadConfigurations();
550 assert(W_ApplicationInitialized());
553 scrPtr = malloc(sizeof(W_Screen));
554 if (!scrPtr)
555 return NULL;
556 memset(scrPtr, 0, sizeof(W_Screen));
558 scrPtr->aflags.hasAppIcon = 1;
560 scrPtr->display = display;
561 scrPtr->screen = screen;
562 scrPtr->rcontext = context;
564 scrPtr->depth = context->depth;
566 scrPtr->visual = context->visual;
567 scrPtr->lastEventTime = 0;
569 scrPtr->colormap = context->cmap;
571 scrPtr->rootWin = RootWindow(display, screen);
573 scrPtr->fontCache = WMCreateHashTable(WMStringPointerHashCallbacks);
575 /* initially allocate some colors */
576 WMWhiteColor(scrPtr);
577 WMBlackColor(scrPtr);
578 WMGrayColor(scrPtr);
579 WMDarkGrayColor(scrPtr);
581 gcv.graphics_exposures = False;
583 gcv.function = GXxor;
584 gcv.foreground = W_PIXEL(scrPtr->white);
585 if (gcv.foreground == 0) gcv.foreground = 1;
586 scrPtr->xorGC = XCreateGC(display, W_DRAWABLE(scrPtr), GCFunction
587 |GCGraphicsExposures|GCForeground, &gcv);
589 gcv.function = GXxor;
590 gcv.foreground = W_PIXEL(scrPtr->gray);
591 gcv.subwindow_mode = IncludeInferiors;
592 scrPtr->ixorGC = XCreateGC(display, W_DRAWABLE(scrPtr), GCFunction
593 |GCGraphicsExposures|GCForeground
594 |GCSubwindowMode, &gcv);
596 gcv.function = GXcopy;
597 scrPtr->copyGC = XCreateGC(display, W_DRAWABLE(scrPtr), GCFunction
598 |GCGraphicsExposures, &gcv);
600 scrPtr->clipGC = XCreateGC(display, W_DRAWABLE(scrPtr), GCFunction
601 |GCGraphicsExposures, &gcv);
604 stipple = XCreateBitmapFromData(display, W_DRAWABLE(scrPtr),
605 STIPPLE_BITS, STIPPLE_WIDTH, STIPPLE_HEIGHT);
606 gcv.foreground = W_PIXEL(scrPtr->darkGray);
607 gcv.background = W_PIXEL(scrPtr->gray);
608 gcv.fill_style = FillStippled;
609 gcv.stipple = stipple;
610 scrPtr->stippleGC = XCreateGC(display, W_DRAWABLE(scrPtr),
611 GCForeground|GCBackground|GCStipple
612 |GCFillStyle|GCGraphicsExposures, &gcv);
614 gcv.foreground = W_PIXEL(scrPtr->black);
615 gcv.background = W_PIXEL(scrPtr->white);
616 scrPtr->textFieldGC = XCreateGC(display, W_DRAWABLE(scrPtr),
617 GCForeground|GCBackground, &gcv);
619 /* we need a 1bpp drawable for the monoGC, so borrow this one */
620 scrPtr->monoGC = XCreateGC(display, stipple, 0, NULL);
622 scrPtr->stipple = stipple;
624 scrPtr->useMultiByte = WINGsConfiguration.useMultiByte;
626 scrPtr->normalFont = WMSystemFontOfSize(scrPtr, 12);
628 scrPtr->boldFont = WMBoldSystemFontOfSize(scrPtr, 12);
630 if (!scrPtr->boldFont)
631 scrPtr->boldFont = scrPtr->normalFont;
633 if (!scrPtr->normalFont) {
634 wwarning("could not load any fonts. Make sure your font installation"
635 "and locale settings are correct.");
637 return NULL;
640 scrPtr->checkButtonImageOn = makePixmap(scrPtr, CHECK_BUTTON_ON,
641 CHECK_BUTTON_ON_WIDTH,
642 CHECK_BUTTON_ON_HEIGHT, False);
644 scrPtr->checkButtonImageOff = makePixmap(scrPtr, CHECK_BUTTON_OFF,
645 CHECK_BUTTON_OFF_WIDTH,
646 CHECK_BUTTON_OFF_HEIGHT, False);
648 scrPtr->radioButtonImageOn = makePixmap(scrPtr, RADIO_BUTTON_ON,
649 RADIO_BUTTON_ON_WIDTH,
650 RADIO_BUTTON_ON_HEIGHT, False);
652 scrPtr->radioButtonImageOff = makePixmap(scrPtr, RADIO_BUTTON_OFF,
653 RADIO_BUTTON_OFF_WIDTH,
654 RADIO_BUTTON_OFF_HEIGHT, False);
656 scrPtr->buttonArrow = makePixmap(scrPtr, BUTTON_ARROW,
657 BUTTON_ARROW_WIDTH, BUTTON_ARROW_HEIGHT,
658 False);
660 scrPtr->pushedButtonArrow = makePixmap(scrPtr, BUTTON_ARROW2,
661 BUTTON_ARROW2_WIDTH, BUTTON_ARROW2_HEIGHT,
662 False);
665 scrPtr->scrollerDimple = makePixmap(scrPtr, SCROLLER_DIMPLE,
666 SCROLLER_DIMPLE_WIDTH,
667 SCROLLER_DIMPLE_HEIGHT, False);
670 scrPtr->upArrow = makePixmap(scrPtr, SCROLLER_ARROW_UP,
671 SCROLLER_ARROW_UP_WIDTH,
672 SCROLLER_ARROW_UP_HEIGHT, True);
674 scrPtr->downArrow = makePixmap(scrPtr, SCROLLER_ARROW_DOWN,
675 SCROLLER_ARROW_DOWN_WIDTH,
676 SCROLLER_ARROW_DOWN_HEIGHT, True);
678 scrPtr->leftArrow = makePixmap(scrPtr, SCROLLER_ARROW_LEFT,
679 SCROLLER_ARROW_LEFT_WIDTH,
680 SCROLLER_ARROW_LEFT_HEIGHT, True);
682 scrPtr->rightArrow = makePixmap(scrPtr, SCROLLER_ARROW_RIGHT,
683 SCROLLER_ARROW_RIGHT_WIDTH,
684 SCROLLER_ARROW_RIGHT_HEIGHT, True);
686 scrPtr->hiUpArrow = makePixmap(scrPtr, HI_SCROLLER_ARROW_UP,
687 SCROLLER_ARROW_UP_WIDTH,
688 SCROLLER_ARROW_UP_HEIGHT, True);
690 scrPtr->hiDownArrow = makePixmap(scrPtr, HI_SCROLLER_ARROW_DOWN,
691 SCROLLER_ARROW_DOWN_WIDTH,
692 SCROLLER_ARROW_DOWN_HEIGHT, True);
694 scrPtr->hiLeftArrow = makePixmap(scrPtr, HI_SCROLLER_ARROW_LEFT,
695 SCROLLER_ARROW_LEFT_WIDTH,
696 SCROLLER_ARROW_LEFT_HEIGHT, True);
698 scrPtr->hiRightArrow = makePixmap(scrPtr, HI_SCROLLER_ARROW_RIGHT,
699 SCROLLER_ARROW_RIGHT_WIDTH,
700 SCROLLER_ARROW_RIGHT_HEIGHT, True);
702 scrPtr->popUpIndicator = makePixmap(scrPtr, POPUP_INDICATOR,
703 POPUP_INDICATOR_WIDTH,
704 POPUP_INDICATOR_HEIGHT, True);
706 scrPtr->pullDownIndicator = makePixmap(scrPtr, PULLDOWN_INDICATOR,
707 PULLDOWN_INDICATOR_WIDTH,
708 PULLDOWN_INDICATOR_HEIGHT, True);
710 scrPtr->checkMark = makePixmap(scrPtr, CHECK_MARK,
711 CHECK_MARK_WIDTH,
712 CHECK_MARK_HEIGHT, True);
714 loadPixmaps(scrPtr);
716 scrPtr->defaultCursor = XCreateFontCursor(display, XC_left_ptr);
718 scrPtr->textCursor = XCreateFontCursor(display, XC_xterm);
721 XColor bla;
722 Pixmap blank;
724 blank = XCreatePixmap(display, scrPtr->stipple, 1, 1, 1);
725 XSetForeground(display, scrPtr->monoGC, 0);
726 XFillRectangle(display, blank, scrPtr->monoGC, 0, 0, 1, 1);
728 scrPtr->invisibleCursor = XCreatePixmapCursor(display, blank, blank,
729 &bla, &bla, 0, 0);
730 XFreePixmap(display, blank);
733 scrPtr->internalMessage = XInternAtom(display, "_WINGS_MESSAGE", False);
735 scrPtr->attribsAtom = XInternAtom(display, "_GNUSTEP_WM_ATTR", False);
737 scrPtr->deleteWindowAtom = XInternAtom(display, "WM_DELETE_WINDOW", False);
739 scrPtr->protocolsAtom = XInternAtom(display, "WM_PROTOCOLS", False);
741 scrPtr->clipboardAtom = XInternAtom(display, "CLIPBOARD", False);
743 scrPtr->rootView = W_CreateRootView(scrPtr);
746 scrPtr->balloon = W_CreateBalloon(scrPtr);
749 W_InitApplication(scrPtr);
751 return scrPtr;
755 void
756 WMHangData(WMWidget *widget, void *data)
758 W_VIEW(widget)->hangedData = data;
762 void*
763 WMGetHangedData(WMWidget *widget)
765 return W_VIEW(widget)->hangedData;
770 void
771 WMDestroyWidget(WMWidget *widget)
773 W_DestroyView(W_VIEW(widget));
777 void
778 WMSetFocusToWidget(WMWidget *widget)
780 W_SetFocusOfTopLevel(W_TopLevelOfView(W_VIEW(widget)), W_VIEW(widget));
785 * WMRealizeWidget-
786 * Realizes the widget and all it's children.
789 void
790 WMRealizeWidget(WMWidget *w)
792 W_RealizeView(W_VIEW(w));
795 void
796 WMMapWidget(WMWidget *w)
798 W_MapView(W_VIEW(w));
802 static void
803 makeChildrenAutomap(W_View *view, int flag)
805 view = view->childrenList;
807 while (view) {
808 view->flags.mapWhenRealized = flag;
809 makeChildrenAutomap(view, flag);
811 view = view->nextSister;
816 void
817 WMMapSubwidgets(WMWidget *w)
819 /* make sure that subwidgets created after the parent was realized
820 * are mapped too */
821 if (!W_VIEW(w)->flags.realized) {
822 makeChildrenAutomap(W_VIEW(w), True);
823 } else {
824 W_MapSubviews(W_VIEW(w));
829 void
830 WMUnmapSubwidgets(WMWidget *w)
832 if (!W_VIEW(w)->flags.realized) {
833 makeChildrenAutomap(W_VIEW(w), False);
834 } else {
835 W_UnmapSubviews(W_VIEW(w));
841 void
842 WMUnmapWidget(WMWidget *w)
844 W_UnmapView(W_VIEW(w));
848 void
849 WMSetWidgetBackgroundColor(WMWidget *w, WMColor *color)
851 W_SetViewBackgroundColor(W_VIEW(w), color);
855 void
856 WMMoveWidget(WMWidget *w, int x, int y)
858 W_MoveView(W_VIEW(w), x, y);
862 void
863 WMResizeWidget(WMWidget *w, unsigned int width, unsigned int height)
865 W_ResizeView(W_VIEW(w), width, height);
870 W_Class
871 W_RegisterUserWidget(void)
873 userWidgetCount++;
875 return userWidgetCount + WC_UserWidget - 1;
880 RContext*
881 WMScreenRContext(WMScreen *scr)
883 return scr->rcontext;
888 unsigned int
889 WMWidgetWidth(WMWidget *w)
891 return W_VIEW(w)->size.width;
895 unsigned int
896 WMWidgetHeight(WMWidget *w)
898 return W_VIEW(w)->size.height;
902 Window
903 WMWidgetXID(WMWidget *w)
905 return W_VIEW(w)->window;
909 WMScreen*
910 WMWidgetScreen(WMWidget *w)
912 return W_VIEW(w)->screen;
917 void
918 WMScreenMainLoop(WMScreen *scr)
920 XEvent event;
922 while (1) {
923 WMNextEvent(scr->display, &event);
924 WMHandleEvent(&event);
930 Display*
931 WMScreenDisplay(WMScreen *scr)
933 return scr->display;
937 int
938 WMScreenDepth(WMScreen *scr)
940 return scr->depth;
944 void
945 WMRedisplayWidget(WMWidget *w)
947 W_RedisplayView(W_VIEW(w));