updated de.po and fixed a typo
[wmaker-crm.git] / WINGs / widgets.c
blob347df1013421f6e2f4d0d6ff34228ab4d7977b64
3 #include "WINGsP.h"
4 #include "wconfig.h"
6 #include <X11/Xutil.h>
7 #include <X11/Xatom.h>
8 #include <X11/keysym.h>
9 #include <X11/cursorfont.h>
11 /********** data ************/
14 #define CHECK_BUTTON_ON_WIDTH 16
15 #define CHECK_BUTTON_ON_HEIGHT 16
17 static char *CHECK_BUTTON_ON[] = {
18 " %",
19 " .............%#",
20 " ........... .%#",
21 " .......... #.%#",
22 " ......... #%.%#",
23 " ........ #%..%#",
24 " ... #.. #%...%#",
25 " ... #% #%....%#",
26 " ... % #%.....%#",
27 " ... #%......%#",
28 " ... #%.......%#",
29 " ...#%........%#",
30 " .............%#",
31 " .............%#",
32 " %%%%%%%%%%%%%%#",
33 "%###############"};
35 #define CHECK_BUTTON_OFF_WIDTH 16
36 #define CHECK_BUTTON_OFF_HEIGHT 16
38 static char *CHECK_BUTTON_OFF[] = {
39 " %",
40 " .............%#",
41 " .............%#",
42 " .............%#",
43 " .............%#",
44 " .............%#",
45 " .............%#",
46 " .............%#",
47 " .............%#",
48 " .............%#",
49 " .............%#",
50 " .............%#",
51 " .............%#",
52 " .............%#",
53 " %%%%%%%%%%%%%%#",
54 "%###############"};
56 #define RADIO_BUTTON_ON_WIDTH 15
57 #define RADIO_BUTTON_ON_HEIGHT 15
58 static char *RADIO_BUTTON_ON[] = {
59 ".....%%%%%.....",
60 "...%%#####%%...",
61 "..%##.....%.%..",
62 ".%#%.. .....",
63 ".%#. ...",
64 "%#.. .. ",
65 "%#. . ",
66 "%#. . ",
67 "%#. . ",
68 "%#. . ",
69 ".%%. . .",
70 ".%.. . .",
71 "..%... .. ..",
72 ".... ..... ...",
73 "..... .....",
76 #define RADIO_BUTTON_OFF_WIDTH 15
77 #define RADIO_BUTTON_OFF_HEIGHT 15
78 static char *RADIO_BUTTON_OFF[] = {
79 ".....%%%%%.....",
80 "...%%#####%%...",
81 "..%##.......%..",
82 ".%#%...........",
83 ".%#............",
84 "%#............ ",
85 "%#............ ",
86 "%#............ ",
87 "%#............ ",
88 "%#............ ",
89 ".%%.......... .",
90 ".%........... .",
91 "..%......... ..",
92 ".... ..... ...",
93 "..... .....",
97 static char *BUTTON_ARROW[] = {
98 "..................",
99 "....##....#### ...",
100 "...#.%....#... ...",
101 "..#..%#####... ...",
102 ".#............ ...",
103 "#............. ...",
104 ".#............ ...",
105 "..#.. ...",
106 "...#. ............",
107 "....# ............"
110 #define BUTTON_ARROW_WIDTH 18
111 #define BUTTON_ARROW_HEIGHT 10
114 static char *BUTTON_ARROW2[] = {
115 " ",
116 " ## ####. ",
117 " # % # . ",
118 " # %##### . ",
119 " # . ",
120 "# . ",
121 " # . ",
122 " # .......... ",
123 " # . ",
124 " #. "
127 #define BUTTON_ARROW2_WIDTH 18
128 #define BUTTON_ARROW2_HEIGHT 10
131 static char *SCROLLER_DIMPLE[] = {
132 ".%###.",
133 "%#%%%%",
134 "#%%...",
135 "#%.. ",
136 "#%. ",
137 ".%. ."
140 #define SCROLLER_DIMPLE_WIDTH 6
141 #define SCROLLER_DIMPLE_HEIGHT 6
144 static char *SCROLLER_ARROW_UP[] = {
145 "....%....",
146 "....#....",
147 "...%#%...",
148 "...###...",
149 "..%###%..",
150 "..#####..",
151 ".%#####%.",
152 ".#######.",
153 "%#######%"
156 static char *HI_SCROLLER_ARROW_UP[] = {
157 " % ",
158 " % ",
159 " %%% ",
160 " %%% ",
161 " %%%%% ",
162 " %%%%% ",
163 " %%%%%%% ",
164 " %%%%%%% ",
165 "%%%%%%%%%"
168 #define SCROLLER_ARROW_UP_WIDTH 9
169 #define SCROLLER_ARROW_UP_HEIGHT 9
172 static char *SCROLLER_ARROW_DOWN[] = {
173 "%#######%",
174 ".#######.",
175 ".%#####%.",
176 "..#####..",
177 "..%###%..",
178 "...###...",
179 "...%#%...",
180 "....#....",
181 "....%...."
184 static char *HI_SCROLLER_ARROW_DOWN[] = {
185 "%%%%%%%%%",
186 " %%%%%%% ",
187 " %%%%%%% ",
188 " %%%%% ",
189 " %%%%% ",
190 " %%% ",
191 " %%% ",
192 " % ",
193 " % "
196 #define SCROLLER_ARROW_DOWN_WIDTH 9
197 #define SCROLLER_ARROW_DOWN_HEIGHT 9
201 static char *SCROLLER_ARROW_LEFT[] = {
202 "........%",
203 "......%##",
204 "....%####",
205 "..%######",
206 "%########",
207 "..%######",
208 "....%####",
209 "......%##",
210 "........%"
213 static char *HI_SCROLLER_ARROW_LEFT[] = {
214 " %",
215 " %%%",
216 " %%%%%",
217 " %%%%%%%",
218 "%%%%%%%%%",
219 " %%%%%%%",
220 " %%%%%",
221 " %%%",
222 " %"
225 #define SCROLLER_ARROW_LEFT_WIDTH 9
226 #define SCROLLER_ARROW_LEFT_HEIGHT 9
229 static char *SCROLLER_ARROW_RIGHT[] = {
230 "%........",
231 "##%......",
232 "####%....",
233 "######%..",
234 "########%",
235 "######%..",
236 "####%....",
237 "##%......",
238 "%........"
241 static char *HI_SCROLLER_ARROW_RIGHT[] = {
242 "% ",
243 "%%% ",
244 "%%%%% ",
245 "%%%%%%% ",
246 "%%%%%%%%%",
247 "%%%%%%% ",
248 "%%%%% ",
249 "%%% ",
250 "% "
253 #define SCROLLER_ARROW_RIGHT_WIDTH 9
254 #define SCROLLER_ARROW_RIGHT_HEIGHT 9
257 static char *POPUP_INDICATOR[] = {
258 " #==",
259 " ......%#==",
260 " ......%#%%",
261 " ......%#%%",
262 " %%%%%%%#%%",
263 "#########%%",
264 "==%%%%%%%%%",
265 "==%%%%%%%%%"
268 #define POPUP_INDICATOR_WIDTH 11
269 #define POPUP_INDICATOR_HEIGHT 8
273 static char *PULLDOWN_INDICATOR[] = {
274 "=#######=",
275 "=%===== =",
276 "==%=== ==",
277 "==%=== ==",
278 "===%= ===",
279 "===%= ===",
280 "====%===="
282 #define PULLDOWN_INDICATOR_WIDTH 9
283 #define PULLDOWN_INDICATOR_HEIGHT 7
286 #define CHECK_MARK_WIDTH 8
287 #define CHECK_MARK_HEIGHT 10
289 static char *CHECK_MARK[] = {
290 "======== ",
291 "======= #",
292 "====== #%",
293 "===== #%=",
294 " #== #%==",
295 " #% #%===",
296 " % #%====",
297 " #%=====",
298 " #%======",
299 "#%======="};
302 #define STIPPLE_WIDTH 8
303 #define STIPPLE_HEIGHT 8
304 static unsigned char STIPPLE_BITS[] = {
305 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa
311 extern void W_ReadConfigurations(void);
314 static int userWidgetCount=0;
317 /***** end data ******/
320 static void
321 renderPixmap(W_Screen *screen, Pixmap d, Pixmap mask, char **data,
322 int width, int height)
324 int x, y;
325 GC whiteGC = WMColorGC(screen->white);
326 GC blackGC = WMColorGC(screen->black);
327 GC lightGC = WMColorGC(screen->gray);
328 GC darkGC = WMColorGC(screen->darkGray);
331 if (mask)
332 XSetForeground(screen->display, screen->monoGC, 0);
334 for (y = 0; y < height; y++) {
335 for (x = 0; x < width; x++) {
336 switch (data[y][x]) {
337 case ' ':
338 case 'w':
339 XDrawPoint(screen->display, d, whiteGC, x, y);
340 break;
342 case '=':
343 if (mask)
344 XDrawPoint(screen->display, mask, screen->monoGC, x, y);
346 case '.':
347 case 'l':
348 XDrawPoint(screen->display, d, lightGC, x, y);
349 break;
351 case '%':
352 case 'd':
353 XDrawPoint(screen->display, d, darkGC, x, y);
354 break;
356 case '#':
357 case 'b':
358 default:
359 XDrawPoint(screen->display, d, blackGC, x, y);
360 break;
368 static WMPixmap*
369 makePixmap(W_Screen *sPtr, char **data, int width, int height, int masked)
371 Pixmap pixmap, mask = None;
373 pixmap = XCreatePixmap(sPtr->display, W_DRAWABLE(sPtr), width, height,
374 sPtr->depth);
376 if (masked) {
377 mask = XCreatePixmap(sPtr->display, W_DRAWABLE(sPtr), width, height, 1);
378 XSetForeground(sPtr->display, sPtr->monoGC, 1);
379 XFillRectangle(sPtr->display, mask, sPtr->monoGC, 0, 0, width, height);
382 renderPixmap(sPtr, pixmap, mask, data, width, height);
384 return WMCreatePixmapFromXPixmaps(sPtr, pixmap, mask, width, height,
385 sPtr->depth);
389 #define T_WINGS_IMAGES_FILE RESOURCE_PATH"/Images.tiff"
390 #define T_DEFAULT_OBJECT_ICON_FILE RESOURCE_PATH"/defaultIcon.tiff"
392 #define X_WINGS_IMAGES_FILE RESOURCE_PATH"/Images.xpm"
393 #define X_DEFAULT_OBJECT_ICON_FILE RESOURCE_PATH"/defaultIcon.xpm"
396 static Bool
397 loadPixmaps(WMScreen *scr)
399 RImage *image, *tmp;
400 RColor gray;
401 RColor white;
403 gray.red = 0xae;
404 gray.green = 0xaa;
405 gray.blue = 0xae;
407 white.red = 0xff;
408 white.green = 0xff;
409 white.blue = 0xff;
411 image = RLoadImage(scr->rcontext, T_WINGS_IMAGES_FILE, 0);
412 if (!image)
413 image = RLoadImage(scr->rcontext, X_WINGS_IMAGES_FILE, 0);
414 if (!image) {
415 wwarning(_("WINGs: could not load widget images file: %s"),
416 RMessageForError(RErrorCode));
417 return False;
419 /* home icon */
420 /* make it have a gray background */
421 tmp = RGetSubImage(image, 0, 0, 24, 24);
422 RCombineImageWithColor(tmp, &gray);
423 scr->homeIcon = WMCreatePixmapFromRImage(scr, tmp, 128);
424 RReleaseImage(tmp);
425 /* make it have a white background */
426 tmp = RGetSubImage(image, 0, 0, 24, 24);
427 RCombineImageWithColor(tmp, &white);
428 scr->altHomeIcon = WMCreatePixmapFromRImage(scr, tmp, 128);
429 RReleaseImage(tmp);
431 /* trash can */
432 tmp = RGetSubImage(image, 104, 0, 24, 24);
433 RCombineImageWithColor(tmp, &white);
434 scr->trashcanIcon = WMCreatePixmapFromRImage(scr, tmp, 128);
435 RReleaseImage(tmp);
436 tmp = RGetSubImage(image, 104, 0, 24, 24);
437 RCombineImageWithColor(tmp, &white);
438 scr->altTrashcanIcon = WMCreatePixmapFromRImage(scr, tmp, 128);
439 RReleaseImage(tmp);
440 /* create dir */
441 tmp = RGetSubImage(image, 104, 24, 24, 24);
442 RCombineImageWithColor(tmp, &white);
443 scr->createDirIcon = WMCreatePixmapFromRImage(scr, tmp, 128);
444 RReleaseImage(tmp);
445 tmp = RGetSubImage(image, 104, 24, 24, 24);
446 RCombineImageWithColor(tmp, &white);
447 scr->altCreateDirIcon = WMCreatePixmapFromRImage(scr, tmp, 128);
448 RReleaseImage(tmp);
449 /* diskettes */
450 tmp = RGetSubImage(image, 24, 80, 24, 24);
451 RCombineImageWithColor(tmp, &white);
452 scr->disketteIcon = WMCreatePixmapFromRImage(scr, tmp, 128);
453 RReleaseImage(tmp);
454 tmp = RGetSubImage(image, 24, 80, 24, 24);
455 RCombineImageWithColor(tmp, &white);
456 scr->altDisketteIcon = WMCreatePixmapFromRImage(scr, tmp, 128);
457 RReleaseImage(tmp);
458 /* unmount */
459 tmp = RGetSubImage(image, 0, 80, 24, 24);
460 RCombineImageWithColor(tmp, &white);
461 scr->unmountIcon = WMCreatePixmapFromRImage(scr, tmp, 128);
462 RReleaseImage(tmp);
463 tmp = RGetSubImage(image, 0, 80, 24, 24);
464 RCombineImageWithColor(tmp, &white);
465 scr->altUnmountIcon = WMCreatePixmapFromRImage(scr, tmp, 128);
466 RReleaseImage(tmp);
468 /* Magnifying Glass Icon for ColorPanel */
469 tmp = RGetSubImage(image, 24, 0, 40, 32);
470 RCombineImageWithColor(tmp, &gray);
471 scr->magnifyIcon = WMCreatePixmapFromRImage(scr, tmp, 128);
472 RReleaseImage(tmp);
473 /* ColorWheel Icon for ColorPanel */
474 tmp = RGetSubImage(image, 0, 25, 24, 24);
475 scr->wheelIcon = WMCreatePixmapFromRImage(scr, tmp, 128);
476 RReleaseImage(tmp);
477 /* GrayScale Icon for ColorPanel */
478 tmp = RGetSubImage(image, 65, 0, 40, 24);
479 scr->grayIcon = WMCreatePixmapFromRImage(scr, tmp, 128);
480 RReleaseImage(tmp);
481 /* RGB Icon for ColorPanel */
482 tmp = RGetSubImage(image, 25, 33, 40, 24);
483 scr->rgbIcon = WMCreatePixmapFromRImage(scr, tmp, 128);
484 RReleaseImage(tmp);
485 /* CMYK Icon for ColorPanel */
486 tmp = RGetSubImage(image, 65, 25, 40, 24);
487 scr->cmykIcon = WMCreatePixmapFromRImage(scr, tmp, 128);
488 RReleaseImage(tmp);
489 /* HSB Icon for ColorPanel */
490 tmp = RGetSubImage(image, 0, 57, 40, 24);
491 scr->hsbIcon = WMCreatePixmapFromRImage(scr, tmp, 128);
492 RReleaseImage(tmp);
493 /* CustomColorPalette Icon for ColorPanel */
494 tmp = RGetSubImage(image, 81, 57, 40, 24);
495 scr->customPaletteIcon = WMCreatePixmapFromRImage(scr, tmp, 128);
496 RReleaseImage(tmp);
497 /* ColorList Icon for ColorPanel */
498 tmp = RGetSubImage(image, 41, 57, 40, 24);
499 scr->colorListIcon = WMCreatePixmapFromRImage(scr, tmp, 128);
500 RReleaseImage(tmp);
502 RReleaseImage(image);
504 #if 0
505 scr->defaultObjectIcon =
506 WMCreatePixmapFromFile(scr, T_DEFAULT_OBJECT_ICON_FILE);
507 if (!scr->defaultObjectIcon) {
508 scr->defaultObjectIcon =
509 WMCreatePixmapFromFile(scr, X_DEFAULT_OBJECT_ICON_FILE);
511 if (!scr->defaultObjectIcon) {
512 wwarning("WINGs: could not load default icon file");
513 return False;
515 #endif
516 return True;
520 WMScreen*
521 WMOpenScreen(const char *display)
523 Display *dpy = XOpenDisplay(display);
525 if (!dpy) {
526 wwarning("WINGs: could not open display %s",
527 XDisplayName(display));
528 return NULL;
531 return WMCreateSimpleApplicationScreen(dpy);
535 WMScreen*
536 WMCreateSimpleApplicationScreen(Display *display)
538 WMScreen *scr;
540 scr = WMCreateScreen(display, DefaultScreen(display));
542 scr->aflags.hasAppIcon = 0;
543 scr->aflags.simpleApplication = 1;
545 return scr;
550 WMScreen*
551 WMCreateScreen(Display *display, int screen)
553 return WMCreateScreenWithRContext(display, screen,
554 RCreateContext(display, screen, NULL));
558 WMScreen*
559 WMCreateScreenWithRContext(Display *display, int screen, RContext *context)
561 W_Screen *scrPtr;
562 XGCValues gcv;
563 Pixmap stipple;
564 static int initialized = 0;
565 static char *atomNames[] = {
566 "_GNUSTEP_WM_ATTR",
567 "WM_DELETE_WINDOW",
568 "WM_PROTOCOLS",
569 "CLIPBOARD",
570 "XdndAware",
571 "XdndSelection",
572 "XdndEnter",
573 "XdndLeave",
574 "XdndPosition",
575 "XdndDrop",
576 "XdndFinished",
577 "XdndTypeList",
578 "XdndActionCopy",
579 "XdndActionMove",
580 "XdndActionLink",
581 "XdndActionAsk",
582 "XdndActionPrivate",
583 "XdndStatus",
584 "_WINGS_DND_MOUSE_OFFSET",
585 "WM_STATE"
587 Atom atoms[sizeof(atomNames)/sizeof(char*)];
588 int i;
590 if (!initialized) {
592 initialized = 1;
594 W_ReadConfigurations();
596 assert(W_ApplicationInitialized());
599 scrPtr = malloc(sizeof(W_Screen));
600 if (!scrPtr)
601 return NULL;
602 memset(scrPtr, 0, sizeof(W_Screen));
604 scrPtr->aflags.hasAppIcon = 1;
606 scrPtr->display = display;
607 scrPtr->screen = screen;
608 scrPtr->rcontext = context;
610 scrPtr->depth = context->depth;
612 scrPtr->visual = context->visual;
613 scrPtr->lastEventTime = 0;
615 scrPtr->colormap = context->cmap;
617 scrPtr->rootWin = RootWindow(display, screen);
619 scrPtr->fontCache = WMCreateHashTable(WMStringPointerHashCallbacks);
621 scrPtr->fontSetCache = WMCreateHashTable(WMStringPointerHashCallbacks);
624 /* create input method stuff */
625 W_InitIMStuff(scrPtr);
627 /* Create missing CUT_BUFFERs */
629 Atom *rootWinProps;
630 int exists[8] = {0, 0, 0, 0, 0, 0, 0, 0};
631 int count;
633 rootWinProps = XListProperties(display, scrPtr->rootWin, &count);
634 for (i=0; i<count; i++) {
635 switch(rootWinProps[i]) {
636 case XA_CUT_BUFFER0:
637 exists[0] = 1; break;
638 case XA_CUT_BUFFER1:
639 exists[1] = 1; break;
640 case XA_CUT_BUFFER2:
641 exists[2] = 1; break;
642 case XA_CUT_BUFFER3:
643 exists[3] = 1; break;
644 case XA_CUT_BUFFER4:
645 exists[4] = 1; break;
646 case XA_CUT_BUFFER5:
647 exists[5] = 1; break;
648 case XA_CUT_BUFFER6:
649 exists[6] = 1; break;
650 case XA_CUT_BUFFER7:
651 exists[7] = 1; break;
652 default:
653 break;
656 if (rootWinProps) {
657 XFree(rootWinProps);
659 for (i=0; i<8; i++) {
660 if (!exists[i]) {
661 XStoreBuffer(display, "", 0, i);
666 scrPtr->ignoredModifierMask = 0;
668 int i;
669 XModifierKeymap *modmap;
670 KeyCode nlock, slock;
671 static int mask_table[8] = {
672 ShiftMask,LockMask,ControlMask,Mod1Mask,
673 Mod2Mask, Mod3Mask, Mod4Mask, Mod5Mask
675 unsigned int numLockMask, scrollLockMask;
677 nlock = XKeysymToKeycode(display, XK_Num_Lock);
678 slock = XKeysymToKeycode(display, XK_Scroll_Lock);
681 * Find out the masks for the NumLock and ScrollLock modifiers,
682 * so that we can bind the grabs for when they are enabled too.
684 modmap = XGetModifierMapping(display);
686 if (modmap!=NULL && modmap->max_keypermod>0) {
687 for (i=0; i<8*modmap->max_keypermod; i++) {
688 if (modmap->modifiermap[i]==nlock && nlock!=0)
689 numLockMask = mask_table[i/modmap->max_keypermod];
690 else if (modmap->modifiermap[i]==slock && slock!=0)
691 scrollLockMask = mask_table[i/modmap->max_keypermod];
695 if (modmap)
696 XFreeModifiermap(modmap);
699 scrPtr->ignoredModifierMask = numLockMask|scrollLockMask|LockMask;
702 /* initially allocate some colors */
703 WMWhiteColor(scrPtr);
704 WMBlackColor(scrPtr);
705 WMGrayColor(scrPtr);
706 WMDarkGrayColor(scrPtr);
708 gcv.graphics_exposures = False;
710 gcv.function = GXxor;
711 gcv.foreground = W_PIXEL(scrPtr->white);
712 if (gcv.foreground == 0) gcv.foreground = 1;
713 scrPtr->xorGC = XCreateGC(display, W_DRAWABLE(scrPtr), GCFunction
714 |GCGraphicsExposures|GCForeground, &gcv);
716 gcv.function = GXxor;
717 gcv.foreground = W_PIXEL(scrPtr->gray);
718 gcv.subwindow_mode = IncludeInferiors;
719 scrPtr->ixorGC = XCreateGC(display, W_DRAWABLE(scrPtr), GCFunction
720 |GCGraphicsExposures|GCForeground
721 |GCSubwindowMode, &gcv);
723 gcv.function = GXcopy;
724 scrPtr->copyGC = XCreateGC(display, W_DRAWABLE(scrPtr), GCFunction
725 |GCGraphicsExposures, &gcv);
727 scrPtr->clipGC = XCreateGC(display, W_DRAWABLE(scrPtr), GCFunction
728 |GCGraphicsExposures, &gcv);
731 stipple = XCreateBitmapFromData(display, W_DRAWABLE(scrPtr),
732 STIPPLE_BITS, STIPPLE_WIDTH, STIPPLE_HEIGHT);
733 gcv.foreground = W_PIXEL(scrPtr->darkGray);
734 gcv.background = W_PIXEL(scrPtr->gray);
735 gcv.fill_style = FillStippled;
736 gcv.stipple = stipple;
737 scrPtr->stippleGC = XCreateGC(display, W_DRAWABLE(scrPtr),
738 GCForeground|GCBackground|GCStipple
739 |GCFillStyle|GCGraphicsExposures, &gcv);
741 gcv.foreground = W_PIXEL(scrPtr->black);
742 gcv.background = W_PIXEL(scrPtr->white);
743 scrPtr->textFieldGC = XCreateGC(display, W_DRAWABLE(scrPtr),
744 GCForeground|GCBackground, &gcv);
746 /* we need a 1bpp drawable for the monoGC, so borrow this one */
747 scrPtr->monoGC = XCreateGC(display, stipple, 0, NULL);
749 scrPtr->stipple = stipple;
751 scrPtr->useMultiByte = WINGsConfiguration.useMultiByte;
753 scrPtr->normalFont = WMSystemFontOfSize(scrPtr,
754 WINGsConfiguration.defaultFontSize);
756 scrPtr->boldFont = WMBoldSystemFontOfSize(scrPtr,
757 WINGsConfiguration.defaultFontSize);
759 if (!scrPtr->boldFont)
760 scrPtr->boldFont = scrPtr->normalFont;
762 if (!scrPtr->normalFont) {
763 wwarning(_("could not load any fonts. Make sure your font installation"
764 " and locale settings are correct."));
766 return NULL;
769 scrPtr->checkButtonImageOn = makePixmap(scrPtr, CHECK_BUTTON_ON,
770 CHECK_BUTTON_ON_WIDTH,
771 CHECK_BUTTON_ON_HEIGHT, False);
773 scrPtr->checkButtonImageOff = makePixmap(scrPtr, CHECK_BUTTON_OFF,
774 CHECK_BUTTON_OFF_WIDTH,
775 CHECK_BUTTON_OFF_HEIGHT, False);
777 scrPtr->radioButtonImageOn = makePixmap(scrPtr, RADIO_BUTTON_ON,
778 RADIO_BUTTON_ON_WIDTH,
779 RADIO_BUTTON_ON_HEIGHT, False);
781 scrPtr->radioButtonImageOff = makePixmap(scrPtr, RADIO_BUTTON_OFF,
782 RADIO_BUTTON_OFF_WIDTH,
783 RADIO_BUTTON_OFF_HEIGHT, False);
785 scrPtr->buttonArrow = makePixmap(scrPtr, BUTTON_ARROW,
786 BUTTON_ARROW_WIDTH, BUTTON_ARROW_HEIGHT,
787 False);
789 scrPtr->pushedButtonArrow = makePixmap(scrPtr, BUTTON_ARROW2,
790 BUTTON_ARROW2_WIDTH, BUTTON_ARROW2_HEIGHT,
791 False);
794 scrPtr->scrollerDimple = makePixmap(scrPtr, SCROLLER_DIMPLE,
795 SCROLLER_DIMPLE_WIDTH,
796 SCROLLER_DIMPLE_HEIGHT, False);
799 scrPtr->upArrow = makePixmap(scrPtr, SCROLLER_ARROW_UP,
800 SCROLLER_ARROW_UP_WIDTH,
801 SCROLLER_ARROW_UP_HEIGHT, True);
803 scrPtr->downArrow = makePixmap(scrPtr, SCROLLER_ARROW_DOWN,
804 SCROLLER_ARROW_DOWN_WIDTH,
805 SCROLLER_ARROW_DOWN_HEIGHT, True);
807 scrPtr->leftArrow = makePixmap(scrPtr, SCROLLER_ARROW_LEFT,
808 SCROLLER_ARROW_LEFT_WIDTH,
809 SCROLLER_ARROW_LEFT_HEIGHT, True);
811 scrPtr->rightArrow = makePixmap(scrPtr, SCROLLER_ARROW_RIGHT,
812 SCROLLER_ARROW_RIGHT_WIDTH,
813 SCROLLER_ARROW_RIGHT_HEIGHT, True);
815 scrPtr->hiUpArrow = makePixmap(scrPtr, HI_SCROLLER_ARROW_UP,
816 SCROLLER_ARROW_UP_WIDTH,
817 SCROLLER_ARROW_UP_HEIGHT, True);
819 scrPtr->hiDownArrow = makePixmap(scrPtr, HI_SCROLLER_ARROW_DOWN,
820 SCROLLER_ARROW_DOWN_WIDTH,
821 SCROLLER_ARROW_DOWN_HEIGHT, True);
823 scrPtr->hiLeftArrow = makePixmap(scrPtr, HI_SCROLLER_ARROW_LEFT,
824 SCROLLER_ARROW_LEFT_WIDTH,
825 SCROLLER_ARROW_LEFT_HEIGHT, True);
827 scrPtr->hiRightArrow = makePixmap(scrPtr, HI_SCROLLER_ARROW_RIGHT,
828 SCROLLER_ARROW_RIGHT_WIDTH,
829 SCROLLER_ARROW_RIGHT_HEIGHT, True);
831 scrPtr->popUpIndicator = makePixmap(scrPtr, POPUP_INDICATOR,
832 POPUP_INDICATOR_WIDTH,
833 POPUP_INDICATOR_HEIGHT, True);
835 scrPtr->pullDownIndicator = makePixmap(scrPtr, PULLDOWN_INDICATOR,
836 PULLDOWN_INDICATOR_WIDTH,
837 PULLDOWN_INDICATOR_HEIGHT, True);
839 scrPtr->checkMark = makePixmap(scrPtr, CHECK_MARK,
840 CHECK_MARK_WIDTH,
841 CHECK_MARK_HEIGHT, True);
843 loadPixmaps(scrPtr);
845 scrPtr->defaultCursor = XCreateFontCursor(display, XC_left_ptr);
847 scrPtr->textCursor = XCreateFontCursor(display, XC_xterm);
850 XColor bla;
851 Pixmap blank;
853 blank = XCreatePixmap(display, scrPtr->stipple, 1, 1, 1);
854 XSetForeground(display, scrPtr->monoGC, 0);
855 XFillRectangle(display, blank, scrPtr->monoGC, 0, 0, 1, 1);
857 scrPtr->invisibleCursor = XCreatePixmapCursor(display, blank, blank,
858 &bla, &bla, 0, 0);
859 XFreePixmap(display, blank);
862 #ifdef HAVE_XINTERNATOMS
863 XInternAtoms(display, atomNames, sizeof(atomNames)/sizeof(char*), False,
864 atoms);
865 #else
866 for (i = 0; i < sizeof(atomNames)/sizeof(char*); i++) {
867 atoms[i] = XInternAtom(display, atomNames[i], False);
869 #endif
871 i = 0;
872 scrPtr->attribsAtom = atoms[i++];
874 scrPtr->deleteWindowAtom = atoms[i++];
876 scrPtr->protocolsAtom = atoms[i++];
878 scrPtr->clipboardAtom = atoms[i++];
880 scrPtr->xdndAwareAtom = atoms[i++];
881 scrPtr->xdndSelectionAtom = atoms[i++];
882 scrPtr->xdndEnterAtom = atoms[i++];
883 scrPtr->xdndLeaveAtom = atoms[i++];
884 scrPtr->xdndPositionAtom = atoms[i++];
885 scrPtr->xdndDropAtom = atoms[i++];
886 scrPtr->xdndFinishedAtom = atoms[i++];
887 scrPtr->xdndTypeListAtom = atoms[i++];
888 scrPtr->xdndStatusAtom = atoms[i++];
890 scrPtr->xdndActionCopy = atoms[i++];
891 scrPtr->xdndActionMove = atoms[i++];
892 scrPtr->xdndActionLink = atoms[i++];
893 scrPtr->xdndActionAsk = atoms[i++];
894 scrPtr->xdndActionPrivate = atoms[i++];
896 scrPtr->wmIconDragOffsetAtom = atoms[i++];
898 scrPtr->wmStateAtom = atoms[i++];
900 scrPtr->rootView = W_CreateRootView(scrPtr);
902 scrPtr->balloon = W_CreateBalloon(scrPtr);
905 W_InitApplication(scrPtr);
907 return scrPtr;
912 void
913 WMSetWidgetDefaultFont(WMScreen *scr, WMFont *font)
915 WMReleaseFont(scr->normalFont);
916 scr->normalFont = WMRetainFont(font);
920 void
921 WMSetWidgetDefaultBoldFont(WMScreen *scr, WMFont *font)
923 WMReleaseFont(scr->boldFont);
924 scr->boldFont = WMRetainFont(font);
929 void
930 WMHangData(WMWidget *widget, void *data)
932 W_VIEW(widget)->hangedData = data;
936 void*
937 WMGetHangedData(WMWidget *widget)
939 return W_VIEW(widget)->hangedData;
944 void
945 WMDestroyWidget(WMWidget *widget)
947 W_UnmapView(W_VIEW(widget));
948 W_DestroyView(W_VIEW(widget));
952 void
953 WMSetFocusToWidget(WMWidget *widget)
955 W_SetFocusOfTopLevel(W_TopLevelOfView(W_VIEW(widget)), W_VIEW(widget));
960 * WMRealizeWidget-
961 * Realizes the widget and all it's children.
964 void
965 WMRealizeWidget(WMWidget *w)
967 W_RealizeView(W_VIEW(w));
970 void
971 WMMapWidget(WMWidget *w)
973 W_MapView(W_VIEW(w));
977 void
978 WMReparentWidget(WMWidget *w, WMWidget *newParent, int x, int y)
980 W_ReparentView(W_VIEW(w), W_VIEW(newParent), x, y);
984 static void
985 makeChildrenAutomap(W_View *view, int flag)
987 view = view->childrenList;
989 while (view) {
990 view->flags.mapWhenRealized = flag;
991 makeChildrenAutomap(view, flag);
993 view = view->nextSister;
998 void
999 WMMapSubwidgets(WMWidget *w)
1001 /* make sure that subwidgets created after the parent was realized
1002 * are mapped too */
1003 if (!W_VIEW(w)->flags.realized) {
1004 makeChildrenAutomap(W_VIEW(w), True);
1005 } else {
1006 W_MapSubviews(W_VIEW(w));
1011 void
1012 WMUnmapSubwidgets(WMWidget *w)
1014 if (!W_VIEW(w)->flags.realized) {
1015 makeChildrenAutomap(W_VIEW(w), False);
1016 } else {
1017 W_UnmapSubviews(W_VIEW(w));
1023 void
1024 WMUnmapWidget(WMWidget *w)
1026 W_UnmapView(W_VIEW(w));
1030 Bool
1031 WMWidgetIsMapped(WMWidget *w)
1033 return W_VIEW(w)->flags.mapped;
1037 void
1038 WMSetWidgetBackgroundColor(WMWidget *w, WMColor *color)
1040 W_SetViewBackgroundColor(W_VIEW(w), color);
1041 if (W_VIEW(w)->flags.mapped)
1042 WMRedisplayWidget(w);
1046 void
1047 WMRaiseWidget(WMWidget *w)
1049 W_RaiseView(W_VIEW(w));
1053 void
1054 WMLowerWidget(WMWidget *w)
1056 W_LowerView(W_VIEW(w));
1060 void
1061 WMMoveWidget(WMWidget *w, int x, int y)
1063 W_MoveView(W_VIEW(w), x, y);
1067 void
1068 WMResizeWidget(WMWidget *w, unsigned int width, unsigned int height)
1070 W_ResizeView(W_VIEW(w), width, height);
1075 W_Class
1076 W_RegisterUserWidget(void)
1078 userWidgetCount++;
1080 return userWidgetCount + WC_UserWidget - 1;
1085 RContext*
1086 WMScreenRContext(WMScreen *scr)
1088 return scr->rcontext;
1093 unsigned int
1094 WMWidgetWidth(WMWidget *w)
1096 return W_VIEW(w)->size.width;
1100 unsigned int
1101 WMWidgetHeight(WMWidget *w)
1103 return W_VIEW(w)->size.height;
1107 Window
1108 WMWidgetXID(WMWidget *w)
1110 return W_VIEW(w)->window;
1114 WMScreen*
1115 WMWidgetScreen(WMWidget *w)
1117 return W_VIEW(w)->screen;
1122 void
1123 WMScreenMainLoop(WMScreen *scr)
1125 XEvent event;
1127 while (1) {
1128 WMNextEvent(scr->display, &event);
1129 WMHandleEvent(&event);
1134 void
1135 WMBreakModalLoop(WMScreen *scr)
1137 scr->modalLoop = 0;
1141 void
1142 WMRunModalLoop(WMScreen *scr, WMView *view)
1144 /* why is scr passed if is determined from the view? */
1145 /*WMScreen *scr = view->screen;*/
1146 int oldModalLoop = scr->modalLoop;
1147 WMView *oldModalView = scr->modalView;
1149 scr->modalView = view;
1151 scr->modalLoop = 1;
1152 while (scr->modalLoop) {
1153 XEvent event;
1155 WMNextEvent(scr->display, &event);
1156 WMHandleEvent(&event);
1159 scr->modalView = oldModalView;
1160 scr->modalLoop = oldModalLoop;
1164 Display*
1165 WMScreenDisplay(WMScreen *scr)
1167 return scr->display;
1171 int
1172 WMScreenDepth(WMScreen *scr)
1174 return scr->depth;
1178 unsigned int
1179 WMScreenWidth(WMScreen *scr)
1181 return scr->rootView->size.width;
1185 unsigned int
1186 WMScreenHeight(WMScreen *scr)
1188 return scr->rootView->size.height;
1192 void
1193 WMRedisplayWidget(WMWidget *w)
1195 W_RedisplayView(W_VIEW(w));