drag and drop!
[wmaker-crm.git] / WINGs / widgets.c
blob61b242f08165d1930eef0b96880cdf72430c3a70
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);
471 /* ColorWheel Icon for ColorPanel */
472 tmp = RGetSubImage(image, 0, 25, 24, 24);
473 scr->wheelIcon = WMCreatePixmapFromRImage(scr, tmp, 128);
474 RDestroyImage(tmp);
475 /* GrayScale Icon for ColorPanel */
476 tmp = RGetSubImage(image, 65, 0, 40, 24);
477 scr->grayIcon = WMCreatePixmapFromRImage(scr, tmp, 128);
478 RDestroyImage(tmp);
479 /* RGB Icon for ColorPanel */
480 tmp = RGetSubImage(image, 25, 33, 40, 24);
481 scr->rgbIcon = WMCreatePixmapFromRImage(scr, tmp, 128);
482 RDestroyImage(tmp);
483 /* CMYK Icon for ColorPanel */
484 tmp = RGetSubImage(image, 65, 25, 40, 24);
485 scr->cmykIcon = WMCreatePixmapFromRImage(scr, tmp, 128);
486 RDestroyImage(tmp);
487 /* HSB Icon for ColorPanel */
488 tmp = RGetSubImage(image, 0, 57, 40, 24);
489 scr->hsbIcon = WMCreatePixmapFromRImage(scr, tmp, 128);
490 RDestroyImage(tmp);
491 /* CustomColorPalette Icon for ColorPanel */
492 tmp = RGetSubImage(image, 81, 57, 40, 24);
493 scr->customPaletteIcon = WMCreatePixmapFromRImage(scr, tmp, 128);
494 RDestroyImage(tmp);
495 /* ColorList Icon for ColorPanel */
496 tmp = RGetSubImage(image, 41, 57, 40, 24);
497 scr->colorListIcon = WMCreatePixmapFromRImage(scr, tmp, 128);
498 RDestroyImage(tmp);
500 RDestroyImage(image);
502 #if 0
503 scr->defaultObjectIcon =
504 WMCreatePixmapFromFile(scr, T_DEFAULT_OBJECT_ICON_FILE);
505 if (!scr->defaultObjectIcon) {
506 scr->defaultObjectIcon =
507 WMCreatePixmapFromFile(scr, X_DEFAULT_OBJECT_ICON_FILE);
509 if (!scr->defaultObjectIcon) {
510 wwarning("WINGs: could not load default icon file");
511 return False;
513 #endif
514 return True;
519 WMScreen*
520 WMCreateSimpleApplicationScreen(Display *display)
522 WMScreen *scr;
524 scr = WMCreateScreen(display, DefaultScreen(display));
526 scr->aflags.hasAppIcon = 0;
527 scr->aflags.simpleApplication = 1;
529 return scr;
534 WMScreen*
535 WMCreateScreen(Display *display, int screen)
537 return WMCreateScreenWithRContext(display, screen,
538 RCreateContext(display, screen, NULL));
542 WMScreen*
543 WMCreateScreenWithRContext(Display *display, int screen, RContext *context)
545 W_Screen *scrPtr;
546 XGCValues gcv;
547 Pixmap stipple;
548 static int initialized = 0;
549 static char *atomNames[] = {
550 "_GNUSTEP_WM_ATTR",
551 "WM_DELETE_WINDOW",
552 "WM_PROTOCOLS",
553 "CLIPBOARD",
554 "XdndAware",
555 "XdndSelection",
556 "XdndEnter",
557 "XdndLeave",
558 "XdndPosition",
559 "XdndDrop",
560 "XdndFinished",
561 "XdndTypeList",
562 "XdndActionCopy",
563 "XdndActionMove",
564 "XdndActionLink",
565 "XdndActionAsk",
566 "XdndActionPrivate",
567 "XdndStatus",
568 "WM_STATE"
570 Atom atoms[sizeof(atomNames)/sizeof(char*)];
571 int i = 0;
573 if (!initialized) {
575 initialized = 1;
577 W_ReadConfigurations();
579 assert(W_ApplicationInitialized());
582 scrPtr = malloc(sizeof(W_Screen));
583 if (!scrPtr)
584 return NULL;
585 memset(scrPtr, 0, sizeof(W_Screen));
587 scrPtr->aflags.hasAppIcon = 1;
589 scrPtr->display = display;
590 scrPtr->screen = screen;
591 scrPtr->rcontext = context;
593 scrPtr->depth = context->depth;
595 scrPtr->visual = context->visual;
596 scrPtr->lastEventTime = 0;
598 scrPtr->colormap = context->cmap;
600 scrPtr->rootWin = RootWindow(display, screen);
602 scrPtr->fontCache = WMCreateHashTable(WMStringPointerHashCallbacks);
604 /* initially allocate some colors */
605 WMWhiteColor(scrPtr);
606 WMBlackColor(scrPtr);
607 WMGrayColor(scrPtr);
608 WMDarkGrayColor(scrPtr);
610 gcv.graphics_exposures = False;
612 gcv.function = GXxor;
613 gcv.foreground = W_PIXEL(scrPtr->white);
614 if (gcv.foreground == 0) gcv.foreground = 1;
615 scrPtr->xorGC = XCreateGC(display, W_DRAWABLE(scrPtr), GCFunction
616 |GCGraphicsExposures|GCForeground, &gcv);
618 gcv.function = GXxor;
619 gcv.foreground = W_PIXEL(scrPtr->gray);
620 gcv.subwindow_mode = IncludeInferiors;
621 scrPtr->ixorGC = XCreateGC(display, W_DRAWABLE(scrPtr), GCFunction
622 |GCGraphicsExposures|GCForeground
623 |GCSubwindowMode, &gcv);
625 gcv.function = GXcopy;
626 scrPtr->copyGC = XCreateGC(display, W_DRAWABLE(scrPtr), GCFunction
627 |GCGraphicsExposures, &gcv);
629 scrPtr->clipGC = XCreateGC(display, W_DRAWABLE(scrPtr), GCFunction
630 |GCGraphicsExposures, &gcv);
633 stipple = XCreateBitmapFromData(display, W_DRAWABLE(scrPtr),
634 STIPPLE_BITS, STIPPLE_WIDTH, STIPPLE_HEIGHT);
635 gcv.foreground = W_PIXEL(scrPtr->darkGray);
636 gcv.background = W_PIXEL(scrPtr->gray);
637 gcv.fill_style = FillStippled;
638 gcv.stipple = stipple;
639 scrPtr->stippleGC = XCreateGC(display, W_DRAWABLE(scrPtr),
640 GCForeground|GCBackground|GCStipple
641 |GCFillStyle|GCGraphicsExposures, &gcv);
643 gcv.foreground = W_PIXEL(scrPtr->black);
644 gcv.background = W_PIXEL(scrPtr->white);
645 scrPtr->textFieldGC = XCreateGC(display, W_DRAWABLE(scrPtr),
646 GCForeground|GCBackground, &gcv);
648 /* we need a 1bpp drawable for the monoGC, so borrow this one */
649 scrPtr->monoGC = XCreateGC(display, stipple, 0, NULL);
651 scrPtr->stipple = stipple;
653 scrPtr->useMultiByte = WINGsConfiguration.useMultiByte;
655 scrPtr->normalFont = WMSystemFontOfSize(scrPtr,
656 WINGsConfiguration.defaultFontSize);
658 scrPtr->boldFont = WMBoldSystemFontOfSize(scrPtr,
659 WINGsConfiguration.defaultFontSize);
661 if (!scrPtr->boldFont)
662 scrPtr->boldFont = scrPtr->normalFont;
664 if (!scrPtr->normalFont) {
665 wwarning("could not load any fonts. Make sure your font installation"
666 "and locale settings are correct.");
668 return NULL;
671 scrPtr->checkButtonImageOn = makePixmap(scrPtr, CHECK_BUTTON_ON,
672 CHECK_BUTTON_ON_WIDTH,
673 CHECK_BUTTON_ON_HEIGHT, False);
675 scrPtr->checkButtonImageOff = makePixmap(scrPtr, CHECK_BUTTON_OFF,
676 CHECK_BUTTON_OFF_WIDTH,
677 CHECK_BUTTON_OFF_HEIGHT, False);
679 scrPtr->radioButtonImageOn = makePixmap(scrPtr, RADIO_BUTTON_ON,
680 RADIO_BUTTON_ON_WIDTH,
681 RADIO_BUTTON_ON_HEIGHT, False);
683 scrPtr->radioButtonImageOff = makePixmap(scrPtr, RADIO_BUTTON_OFF,
684 RADIO_BUTTON_OFF_WIDTH,
685 RADIO_BUTTON_OFF_HEIGHT, False);
687 scrPtr->buttonArrow = makePixmap(scrPtr, BUTTON_ARROW,
688 BUTTON_ARROW_WIDTH, BUTTON_ARROW_HEIGHT,
689 False);
691 scrPtr->pushedButtonArrow = makePixmap(scrPtr, BUTTON_ARROW2,
692 BUTTON_ARROW2_WIDTH, BUTTON_ARROW2_HEIGHT,
693 False);
696 scrPtr->scrollerDimple = makePixmap(scrPtr, SCROLLER_DIMPLE,
697 SCROLLER_DIMPLE_WIDTH,
698 SCROLLER_DIMPLE_HEIGHT, False);
701 scrPtr->upArrow = makePixmap(scrPtr, SCROLLER_ARROW_UP,
702 SCROLLER_ARROW_UP_WIDTH,
703 SCROLLER_ARROW_UP_HEIGHT, True);
705 scrPtr->downArrow = makePixmap(scrPtr, SCROLLER_ARROW_DOWN,
706 SCROLLER_ARROW_DOWN_WIDTH,
707 SCROLLER_ARROW_DOWN_HEIGHT, True);
709 scrPtr->leftArrow = makePixmap(scrPtr, SCROLLER_ARROW_LEFT,
710 SCROLLER_ARROW_LEFT_WIDTH,
711 SCROLLER_ARROW_LEFT_HEIGHT, True);
713 scrPtr->rightArrow = makePixmap(scrPtr, SCROLLER_ARROW_RIGHT,
714 SCROLLER_ARROW_RIGHT_WIDTH,
715 SCROLLER_ARROW_RIGHT_HEIGHT, True);
717 scrPtr->hiUpArrow = makePixmap(scrPtr, HI_SCROLLER_ARROW_UP,
718 SCROLLER_ARROW_UP_WIDTH,
719 SCROLLER_ARROW_UP_HEIGHT, True);
721 scrPtr->hiDownArrow = makePixmap(scrPtr, HI_SCROLLER_ARROW_DOWN,
722 SCROLLER_ARROW_DOWN_WIDTH,
723 SCROLLER_ARROW_DOWN_HEIGHT, True);
725 scrPtr->hiLeftArrow = makePixmap(scrPtr, HI_SCROLLER_ARROW_LEFT,
726 SCROLLER_ARROW_LEFT_WIDTH,
727 SCROLLER_ARROW_LEFT_HEIGHT, True);
729 scrPtr->hiRightArrow = makePixmap(scrPtr, HI_SCROLLER_ARROW_RIGHT,
730 SCROLLER_ARROW_RIGHT_WIDTH,
731 SCROLLER_ARROW_RIGHT_HEIGHT, True);
733 scrPtr->popUpIndicator = makePixmap(scrPtr, POPUP_INDICATOR,
734 POPUP_INDICATOR_WIDTH,
735 POPUP_INDICATOR_HEIGHT, True);
737 scrPtr->pullDownIndicator = makePixmap(scrPtr, PULLDOWN_INDICATOR,
738 PULLDOWN_INDICATOR_WIDTH,
739 PULLDOWN_INDICATOR_HEIGHT, True);
741 scrPtr->checkMark = makePixmap(scrPtr, CHECK_MARK,
742 CHECK_MARK_WIDTH,
743 CHECK_MARK_HEIGHT, True);
745 loadPixmaps(scrPtr);
747 scrPtr->defaultCursor = XCreateFontCursor(display, XC_left_ptr);
749 scrPtr->textCursor = XCreateFontCursor(display, XC_xterm);
752 XColor bla;
753 Pixmap blank;
755 blank = XCreatePixmap(display, scrPtr->stipple, 1, 1, 1);
756 XSetForeground(display, scrPtr->monoGC, 0);
757 XFillRectangle(display, blank, scrPtr->monoGC, 0, 0, 1, 1);
759 scrPtr->invisibleCursor = XCreatePixmapCursor(display, blank, blank,
760 &bla, &bla, 0, 0);
761 XFreePixmap(display, blank);
764 #ifdef HAVE_XINTERNATOMS
765 XInternAtoms(display, atomNames, sizeof(atomNames)/sizeof(char*), False,
766 atoms);
767 #else
769 int i;
770 for (i = 0; i < sizeof(atomNames)/sizeof(char*); i++) {
771 atoms[i] = XInternAtom(display, atomNames[i], False);
774 #endif
776 i = 0;
777 scrPtr->attribsAtom = atoms[i++];
779 scrPtr->deleteWindowAtom = atoms[i++];
781 scrPtr->protocolsAtom = atoms[i++];
783 scrPtr->clipboardAtom = atoms[i++];
785 scrPtr->xdndAwareAtom = atoms[i++];
786 scrPtr->xdndSelectionAtom = atoms[i++];
787 scrPtr->xdndEnterAtom = atoms[i++];
788 scrPtr->xdndLeaveAtom = atoms[i++];
789 scrPtr->xdndPositionAtom = atoms[i++];
790 scrPtr->xdndDropAtom = atoms[i++];
791 scrPtr->xdndFinishedAtom = atoms[i++];
792 scrPtr->xdndTypeListAtom = atoms[i++];
793 scrPtr->xdndStatusAtom = atoms[i++];
795 scrPtr->xdndActionCopy = atoms[i++];
796 scrPtr->xdndActionMove = atoms[i++];
797 scrPtr->xdndActionLink = atoms[i++];
798 scrPtr->xdndActionAsk = atoms[i++];
799 scrPtr->xdndActionPrivate = atoms[i++];
801 scrPtr->wmStateAtom = atoms[i++];
803 scrPtr->rootView = W_CreateRootView(scrPtr);
806 scrPtr->balloon = W_CreateBalloon(scrPtr);
809 W_InitApplication(scrPtr);
811 return scrPtr;
815 void
816 WMHangData(WMWidget *widget, void *data)
818 W_VIEW(widget)->hangedData = data;
822 void*
823 WMGetHangedData(WMWidget *widget)
825 return W_VIEW(widget)->hangedData;
830 void
831 WMDestroyWidget(WMWidget *widget)
833 W_DestroyView(W_VIEW(widget));
837 void
838 WMSetFocusToWidget(WMWidget *widget)
840 W_SetFocusOfTopLevel(W_TopLevelOfView(W_VIEW(widget)), W_VIEW(widget));
845 * WMRealizeWidget-
846 * Realizes the widget and all it's children.
849 void
850 WMRealizeWidget(WMWidget *w)
852 W_RealizeView(W_VIEW(w));
855 void
856 WMMapWidget(WMWidget *w)
858 W_MapView(W_VIEW(w));
862 static void
863 makeChildrenAutomap(W_View *view, int flag)
865 view = view->childrenList;
867 while (view) {
868 view->flags.mapWhenRealized = flag;
869 makeChildrenAutomap(view, flag);
871 view = view->nextSister;
876 void
877 WMMapSubwidgets(WMWidget *w)
879 /* make sure that subwidgets created after the parent was realized
880 * are mapped too */
881 if (!W_VIEW(w)->flags.realized) {
882 makeChildrenAutomap(W_VIEW(w), True);
883 } else {
884 W_MapSubviews(W_VIEW(w));
889 void
890 WMUnmapSubwidgets(WMWidget *w)
892 if (!W_VIEW(w)->flags.realized) {
893 makeChildrenAutomap(W_VIEW(w), False);
894 } else {
895 W_UnmapSubviews(W_VIEW(w));
901 void
902 WMUnmapWidget(WMWidget *w)
904 W_UnmapView(W_VIEW(w));
908 void
909 WMSetWidgetBackgroundColor(WMWidget *w, WMColor *color)
911 W_SetViewBackgroundColor(W_VIEW(w), color);
915 void
916 WMMoveWidget(WMWidget *w, int x, int y)
918 W_MoveView(W_VIEW(w), x, y);
922 void
923 WMResizeWidget(WMWidget *w, unsigned int width, unsigned int height)
925 W_ResizeView(W_VIEW(w), width, height);
930 W_Class
931 W_RegisterUserWidget(void)
933 userWidgetCount++;
935 return userWidgetCount + WC_UserWidget - 1;
940 RContext*
941 WMScreenRContext(WMScreen *scr)
943 return scr->rcontext;
948 unsigned int
949 WMWidgetWidth(WMWidget *w)
951 return W_VIEW(w)->size.width;
955 unsigned int
956 WMWidgetHeight(WMWidget *w)
958 return W_VIEW(w)->size.height;
962 Window
963 WMWidgetXID(WMWidget *w)
965 return W_VIEW(w)->window;
969 WMScreen*
970 WMWidgetScreen(WMWidget *w)
972 return W_VIEW(w)->screen;
977 void
978 WMScreenMainLoop(WMScreen *scr)
980 XEvent event;
982 while (1) {
983 WMNextEvent(scr->display, &event);
984 WMHandleEvent(&event);
990 Display*
991 WMScreenDisplay(WMScreen *scr)
993 return scr->display;
997 int
998 WMScreenDepth(WMScreen *scr)
1000 return scr->depth;
1004 unsigned int
1005 WMScreenWidth(WMScreen *scr)
1007 return scr->rootView->size.width;
1011 unsigned int
1012 WMScreenHeight(WMScreen *scr)
1014 return scr->rootView->size.height;
1018 void
1019 WMRedisplayWidget(WMWidget *w)
1021 W_RedisplayView(W_VIEW(w));