Buttons in filepanel.
[wmaker-crm.git] / WINGs / widgets.c
blob92b82e4578e18c8d0573ba0b18663d3943078474
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, 104, 0, 24, 24);
431 RCombineImageWithColor(tmp, &white);
432 scr->trashcanIcon = WMCreatePixmapFromRImage(scr, tmp, 128);
433 RDestroyImage(tmp);
434 tmp = RGetSubImage(image, 104, 0, 24, 24);
435 RCombineImageWithColor(tmp, &white);
436 scr->altTrashcanIcon = WMCreatePixmapFromRImage(scr, tmp, 128);
437 RDestroyImage(tmp);
438 /* create dir */
439 tmp = RGetSubImage(image, 104, 24, 24, 24);
440 RCombineImageWithColor(tmp, &white);
441 scr->createDirIcon = WMCreatePixmapFromRImage(scr, tmp, 128);
442 RDestroyImage(tmp);
443 tmp = RGetSubImage(image, 104, 24, 24, 24);
444 RCombineImageWithColor(tmp, &white);
445 scr->altCreateDirIcon = WMCreatePixmapFromRImage(scr, tmp, 128);
446 RDestroyImage(tmp);
447 /* diskettes */
448 tmp = RGetSubImage(image, 24, 80, 24, 24);
449 RCombineImageWithColor(tmp, &white);
450 scr->disketteIcon = WMCreatePixmapFromRImage(scr, tmp, 128);
451 RDestroyImage(tmp);
452 tmp = RGetSubImage(image, 24, 80, 24, 24);
453 RCombineImageWithColor(tmp, &white);
454 scr->altDisketteIcon = WMCreatePixmapFromRImage(scr, tmp, 128);
455 RDestroyImage(tmp);
456 /* unmount */
457 tmp = RGetSubImage(image, 0, 80, 24, 24);
458 RCombineImageWithColor(tmp, &white);
459 scr->unmountIcon = WMCreatePixmapFromRImage(scr, tmp, 128);
460 RDestroyImage(tmp);
461 tmp = RGetSubImage(image, 0, 80, 24, 24);
462 RCombineImageWithColor(tmp, &white);
463 scr->altUnmountIcon = WMCreatePixmapFromRImage(scr, tmp, 128);
464 RDestroyImage(tmp);
466 /* Magnifying Glass Icon for ColorPanel */
467 tmp = RGetSubImage(image, 24, 0, 40, 32);
468 RCombineImageWithColor(tmp, &gray);
469 scr->magnifyIcon = WMCreatePixmapFromRImage(scr, tmp, 128);
470 RDestroyImage(tmp);
472 tmp = RGetSubImage(image, 24, 0, 40, 32);
473 RCombineImageWithColor(tmp, &white);
474 scr->altMagnifyIcon = WMCreatePixmapFromRImage(scr, tmp, 128);
475 RDestroyImage(tmp);
477 /* ColorWheel Icon for ColorPanel */
478 tmp = RGetSubImage(image, 0, 25, 24, 24);
479 scr->wheelIcon = WMCreatePixmapFromRImage(scr, tmp, 128);
480 RDestroyImage(tmp);
481 /* GrayScale Icon for ColorPanel */
482 tmp = RGetSubImage(image, 65, 0, 40, 24);
483 scr->grayIcon = WMCreatePixmapFromRImage(scr, tmp, 128);
484 RDestroyImage(tmp);
485 /* RGB Icon for ColorPanel */
486 tmp = RGetSubImage(image, 25, 33, 40, 24);
487 scr->rgbIcon = WMCreatePixmapFromRImage(scr, tmp, 128);
488 RDestroyImage(tmp);
489 /* CMYK Icon for ColorPanel */
490 tmp = RGetSubImage(image, 65, 25, 40, 24);
491 scr->cmykIcon = WMCreatePixmapFromRImage(scr, tmp, 128);
492 RDestroyImage(tmp);
493 /* HSB Icon for ColorPanel */
494 tmp = RGetSubImage(image, 0, 57, 40, 24);
495 scr->hsbIcon = WMCreatePixmapFromRImage(scr, tmp, 128);
496 RDestroyImage(tmp);
497 /* CustomColorPalette Icon for ColorPanel */
498 tmp = RGetSubImage(image, 81, 57, 40, 24);
499 scr->customPaletteIcon = WMCreatePixmapFromRImage(scr, tmp, 128);
500 RDestroyImage(tmp);
501 /* ColorList Icon for ColorPanel */
502 tmp = RGetSubImage(image, 41, 57, 40, 24);
503 scr->colorListIcon = WMCreatePixmapFromRImage(scr, tmp, 128);
504 RDestroyImage(tmp);
506 RDestroyImage(image);
508 #if 0
509 scr->defaultObjectIcon =
510 WMCreatePixmapFromFile(scr, T_DEFAULT_OBJECT_ICON_FILE);
511 if (!scr->defaultObjectIcon) {
512 scr->defaultObjectIcon =
513 WMCreatePixmapFromFile(scr, X_DEFAULT_OBJECT_ICON_FILE);
515 if (!scr->defaultObjectIcon) {
516 wwarning("WINGs: could not load default icon file");
517 return False;
519 #endif
520 return True;
525 WMScreen*
526 WMCreateSimpleApplicationScreen(Display *display)
528 WMScreen *scr;
530 scr = WMCreateScreen(display, DefaultScreen(display));
532 scr->aflags.hasAppIcon = 0;
533 scr->aflags.simpleApplication = 1;
535 return scr;
540 WMScreen*
541 WMCreateScreen(Display *display, int screen)
543 return WMCreateScreenWithRContext(display, screen,
544 RCreateContext(display, screen, NULL));
548 WMScreen*
549 WMCreateScreenWithRContext(Display *display, int screen, RContext *context)
551 W_Screen *scrPtr;
552 XGCValues gcv;
553 Pixmap stipple;
554 static int initialized = 0;
556 if (!initialized) {
558 initialized = 1;
560 W_ReadConfigurations();
562 assert(W_ApplicationInitialized());
565 scrPtr = malloc(sizeof(W_Screen));
566 if (!scrPtr)
567 return NULL;
568 memset(scrPtr, 0, sizeof(W_Screen));
570 scrPtr->aflags.hasAppIcon = 1;
572 scrPtr->display = display;
573 scrPtr->screen = screen;
574 scrPtr->rcontext = context;
576 scrPtr->depth = context->depth;
578 scrPtr->visual = context->visual;
579 scrPtr->lastEventTime = 0;
581 scrPtr->colormap = context->cmap;
583 scrPtr->rootWin = RootWindow(display, screen);
585 scrPtr->fontCache = WMCreateHashTable(WMStringPointerHashCallbacks);
587 /* initially allocate some colors */
588 WMWhiteColor(scrPtr);
589 WMBlackColor(scrPtr);
590 WMGrayColor(scrPtr);
591 WMDarkGrayColor(scrPtr);
593 gcv.graphics_exposures = False;
595 gcv.function = GXxor;
596 gcv.foreground = W_PIXEL(scrPtr->white);
597 if (gcv.foreground == 0) gcv.foreground = 1;
598 scrPtr->xorGC = XCreateGC(display, W_DRAWABLE(scrPtr), GCFunction
599 |GCGraphicsExposures|GCForeground, &gcv);
601 gcv.function = GXxor;
602 gcv.foreground = W_PIXEL(scrPtr->gray);
603 gcv.subwindow_mode = IncludeInferiors;
604 scrPtr->ixorGC = XCreateGC(display, W_DRAWABLE(scrPtr), GCFunction
605 |GCGraphicsExposures|GCForeground
606 |GCSubwindowMode, &gcv);
608 gcv.function = GXcopy;
609 scrPtr->copyGC = XCreateGC(display, W_DRAWABLE(scrPtr), GCFunction
610 |GCGraphicsExposures, &gcv);
612 scrPtr->clipGC = XCreateGC(display, W_DRAWABLE(scrPtr), GCFunction
613 |GCGraphicsExposures, &gcv);
616 stipple = XCreateBitmapFromData(display, W_DRAWABLE(scrPtr),
617 STIPPLE_BITS, STIPPLE_WIDTH, STIPPLE_HEIGHT);
618 gcv.foreground = W_PIXEL(scrPtr->darkGray);
619 gcv.background = W_PIXEL(scrPtr->gray);
620 gcv.fill_style = FillStippled;
621 gcv.stipple = stipple;
622 scrPtr->stippleGC = XCreateGC(display, W_DRAWABLE(scrPtr),
623 GCForeground|GCBackground|GCStipple
624 |GCFillStyle|GCGraphicsExposures, &gcv);
626 gcv.foreground = W_PIXEL(scrPtr->black);
627 gcv.background = W_PIXEL(scrPtr->white);
628 scrPtr->textFieldGC = XCreateGC(display, W_DRAWABLE(scrPtr),
629 GCForeground|GCBackground, &gcv);
631 /* we need a 1bpp drawable for the monoGC, so borrow this one */
632 scrPtr->monoGC = XCreateGC(display, stipple, 0, NULL);
634 scrPtr->stipple = stipple;
636 scrPtr->useMultiByte = WINGsConfiguration.useMultiByte;
638 scrPtr->normalFont = WMSystemFontOfSize(scrPtr, 12);
640 scrPtr->boldFont = WMBoldSystemFontOfSize(scrPtr, 12);
642 if (!scrPtr->boldFont)
643 scrPtr->boldFont = scrPtr->normalFont;
645 if (!scrPtr->normalFont) {
646 wwarning("could not load any fonts. Make sure your font installation"
647 "and locale settings are correct.");
649 return NULL;
652 scrPtr->checkButtonImageOn = makePixmap(scrPtr, CHECK_BUTTON_ON,
653 CHECK_BUTTON_ON_WIDTH,
654 CHECK_BUTTON_ON_HEIGHT, False);
656 scrPtr->checkButtonImageOff = makePixmap(scrPtr, CHECK_BUTTON_OFF,
657 CHECK_BUTTON_OFF_WIDTH,
658 CHECK_BUTTON_OFF_HEIGHT, False);
660 scrPtr->radioButtonImageOn = makePixmap(scrPtr, RADIO_BUTTON_ON,
661 RADIO_BUTTON_ON_WIDTH,
662 RADIO_BUTTON_ON_HEIGHT, False);
664 scrPtr->radioButtonImageOff = makePixmap(scrPtr, RADIO_BUTTON_OFF,
665 RADIO_BUTTON_OFF_WIDTH,
666 RADIO_BUTTON_OFF_HEIGHT, False);
668 scrPtr->buttonArrow = makePixmap(scrPtr, BUTTON_ARROW,
669 BUTTON_ARROW_WIDTH, BUTTON_ARROW_HEIGHT,
670 False);
672 scrPtr->pushedButtonArrow = makePixmap(scrPtr, BUTTON_ARROW2,
673 BUTTON_ARROW2_WIDTH, BUTTON_ARROW2_HEIGHT,
674 False);
677 scrPtr->scrollerDimple = makePixmap(scrPtr, SCROLLER_DIMPLE,
678 SCROLLER_DIMPLE_WIDTH,
679 SCROLLER_DIMPLE_HEIGHT, False);
682 scrPtr->upArrow = makePixmap(scrPtr, SCROLLER_ARROW_UP,
683 SCROLLER_ARROW_UP_WIDTH,
684 SCROLLER_ARROW_UP_HEIGHT, True);
686 scrPtr->downArrow = makePixmap(scrPtr, SCROLLER_ARROW_DOWN,
687 SCROLLER_ARROW_DOWN_WIDTH,
688 SCROLLER_ARROW_DOWN_HEIGHT, True);
690 scrPtr->leftArrow = makePixmap(scrPtr, SCROLLER_ARROW_LEFT,
691 SCROLLER_ARROW_LEFT_WIDTH,
692 SCROLLER_ARROW_LEFT_HEIGHT, True);
694 scrPtr->rightArrow = makePixmap(scrPtr, SCROLLER_ARROW_RIGHT,
695 SCROLLER_ARROW_RIGHT_WIDTH,
696 SCROLLER_ARROW_RIGHT_HEIGHT, True);
698 scrPtr->hiUpArrow = makePixmap(scrPtr, HI_SCROLLER_ARROW_UP,
699 SCROLLER_ARROW_UP_WIDTH,
700 SCROLLER_ARROW_UP_HEIGHT, True);
702 scrPtr->hiDownArrow = makePixmap(scrPtr, HI_SCROLLER_ARROW_DOWN,
703 SCROLLER_ARROW_DOWN_WIDTH,
704 SCROLLER_ARROW_DOWN_HEIGHT, True);
706 scrPtr->hiLeftArrow = makePixmap(scrPtr, HI_SCROLLER_ARROW_LEFT,
707 SCROLLER_ARROW_LEFT_WIDTH,
708 SCROLLER_ARROW_LEFT_HEIGHT, True);
710 scrPtr->hiRightArrow = makePixmap(scrPtr, HI_SCROLLER_ARROW_RIGHT,
711 SCROLLER_ARROW_RIGHT_WIDTH,
712 SCROLLER_ARROW_RIGHT_HEIGHT, True);
714 scrPtr->popUpIndicator = makePixmap(scrPtr, POPUP_INDICATOR,
715 POPUP_INDICATOR_WIDTH,
716 POPUP_INDICATOR_HEIGHT, True);
718 scrPtr->pullDownIndicator = makePixmap(scrPtr, PULLDOWN_INDICATOR,
719 PULLDOWN_INDICATOR_WIDTH,
720 PULLDOWN_INDICATOR_HEIGHT, True);
722 scrPtr->checkMark = makePixmap(scrPtr, CHECK_MARK,
723 CHECK_MARK_WIDTH,
724 CHECK_MARK_HEIGHT, True);
726 loadPixmaps(scrPtr);
728 scrPtr->defaultCursor = XCreateFontCursor(display, XC_left_ptr);
730 scrPtr->textCursor = XCreateFontCursor(display, XC_xterm);
733 XColor bla;
734 Pixmap blank;
736 blank = XCreatePixmap(display, scrPtr->stipple, 1, 1, 1);
737 XSetForeground(display, scrPtr->monoGC, 0);
738 XFillRectangle(display, blank, scrPtr->monoGC, 0, 0, 1, 1);
740 scrPtr->invisibleCursor = XCreatePixmapCursor(display, blank, blank,
741 &bla, &bla, 0, 0);
742 XFreePixmap(display, blank);
745 scrPtr->internalMessage = XInternAtom(display, "_WINGS_MESSAGE", False);
747 scrPtr->attribsAtom = XInternAtom(display, "_GNUSTEP_WM_ATTR", False);
749 scrPtr->deleteWindowAtom = XInternAtom(display, "WM_DELETE_WINDOW", False);
751 scrPtr->protocolsAtom = XInternAtom(display, "WM_PROTOCOLS", False);
753 scrPtr->clipboardAtom = XInternAtom(display, "CLIPBOARD", False);
755 scrPtr->rootView = W_CreateRootView(scrPtr);
758 scrPtr->balloon = W_CreateBalloon(scrPtr);
761 W_InitApplication(scrPtr);
763 return scrPtr;
767 void
768 WMHangData(WMWidget *widget, void *data)
770 W_VIEW(widget)->hangedData = data;
774 void*
775 WMGetHangedData(WMWidget *widget)
777 return W_VIEW(widget)->hangedData;
782 void
783 WMDestroyWidget(WMWidget *widget)
785 W_DestroyView(W_VIEW(widget));
789 void
790 WMSetFocusToWidget(WMWidget *widget)
792 W_SetFocusOfTopLevel(W_TopLevelOfView(W_VIEW(widget)), W_VIEW(widget));
797 * WMRealizeWidget-
798 * Realizes the widget and all it's children.
801 void
802 WMRealizeWidget(WMWidget *w)
804 W_RealizeView(W_VIEW(w));
807 void
808 WMMapWidget(WMWidget *w)
810 W_MapView(W_VIEW(w));
814 static void
815 makeChildrenAutomap(W_View *view, int flag)
817 view = view->childrenList;
819 while (view) {
820 view->flags.mapWhenRealized = flag;
821 makeChildrenAutomap(view, flag);
823 view = view->nextSister;
828 void
829 WMMapSubwidgets(WMWidget *w)
831 /* make sure that subwidgets created after the parent was realized
832 * are mapped too */
833 if (!W_VIEW(w)->flags.realized) {
834 makeChildrenAutomap(W_VIEW(w), True);
835 } else {
836 W_MapSubviews(W_VIEW(w));
841 void
842 WMUnmapSubwidgets(WMWidget *w)
844 if (!W_VIEW(w)->flags.realized) {
845 makeChildrenAutomap(W_VIEW(w), False);
846 } else {
847 W_UnmapSubviews(W_VIEW(w));
853 void
854 WMUnmapWidget(WMWidget *w)
856 W_UnmapView(W_VIEW(w));
860 void
861 WMSetWidgetBackgroundColor(WMWidget *w, WMColor *color)
863 W_SetViewBackgroundColor(W_VIEW(w), color);
867 void
868 WMMoveWidget(WMWidget *w, int x, int y)
870 W_MoveView(W_VIEW(w), x, y);
874 void
875 WMResizeWidget(WMWidget *w, unsigned int width, unsigned int height)
877 W_ResizeView(W_VIEW(w), width, height);
882 W_Class
883 W_RegisterUserWidget(void)
885 userWidgetCount++;
887 return userWidgetCount + WC_UserWidget - 1;
892 RContext*
893 WMScreenRContext(WMScreen *scr)
895 return scr->rcontext;
900 unsigned int
901 WMWidgetWidth(WMWidget *w)
903 return W_VIEW(w)->size.width;
907 unsigned int
908 WMWidgetHeight(WMWidget *w)
910 return W_VIEW(w)->size.height;
914 Window
915 WMWidgetXID(WMWidget *w)
917 return W_VIEW(w)->window;
921 WMScreen*
922 WMWidgetScreen(WMWidget *w)
924 return W_VIEW(w)->screen;
929 void
930 WMScreenMainLoop(WMScreen *scr)
932 XEvent event;
934 while (1) {
935 WMNextEvent(scr->display, &event);
936 WMHandleEvent(&event);
942 Display*
943 WMScreenDisplay(WMScreen *scr)
945 return scr->display;
949 int
950 WMScreenDepth(WMScreen *scr)
952 return scr->depth;
956 void
957 WMRedisplayWidget(WMWidget *w)
959 W_RedisplayView(W_VIEW(w));