Updating to version 0.20.2
[wmaker-crm.git] / WINGs / widgets.c
blob99649c138a3e7c1b7850e114695b24e30caa42fe
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 STIPPLE_WIDTH 8
285 #define STIPPLE_HEIGHT 8
286 static unsigned char STIPPLE_BITS[] = {
287 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa};
291 extern W_ViewProcedureTable _WindowViewProcedures;
292 extern W_ViewProcedureTable _FrameViewProcedures;
293 extern W_ViewProcedureTable _LabelViewProcedures;
294 extern W_ViewProcedureTable _ButtonViewProcedures;
295 extern W_ViewProcedureTable _TextFieldViewProcedures;
296 extern W_ViewProcedureTable _ScrollerViewProcedures;
297 extern W_ViewProcedureTable _ScrollViewProcedures;
298 extern W_ViewProcedureTable _ListViewProcedures;
299 extern W_ViewProcedureTable _BrowserViewProcedures;
300 extern W_ViewProcedureTable _PopUpButtonViewProcedures;
301 extern W_ViewProcedureTable _ColorWellViewProcedures;
302 extern W_ViewProcedureTable _ScrollViewViewProcedures;
303 extern W_ViewProcedureTable _SliderViewProcedures;
304 extern W_ViewProcedureTable _SplitViewViewProcedures;
307 * All widget classes defined must have an entry here.
309 static W_ViewProcedureTable *procedureTables[16];
311 static W_ViewProcedureTable **userProcedureTable = NULL;
312 static int userWidgetCount=0;
315 /***** end data ******/
319 static void
320 initProcedureTable()
322 procedureTables[WC_Window] = &_WindowViewProcedures;
323 procedureTables[WC_Frame] = &_FrameViewProcedures;
324 procedureTables[WC_Label] = &_LabelViewProcedures;
325 procedureTables[WC_Button] = &_ButtonViewProcedures;
326 procedureTables[WC_TextField] = &_TextFieldViewProcedures;
327 procedureTables[WC_Scroller] = &_ScrollerViewProcedures;
328 procedureTables[WC_List] = &_ListViewProcedures;
329 procedureTables[WC_Browser] = &_BrowserViewProcedures;
330 procedureTables[WC_PopUpButton] = &_PopUpButtonViewProcedures;
331 procedureTables[WC_ColorWell] = &_ColorWellViewProcedures;
332 procedureTables[WC_ScrollView] = &_ScrollViewViewProcedures;
333 procedureTables[WC_Slider] = &_SliderViewProcedures;
334 procedureTables[WC_SplitView] = &_SplitViewViewProcedures;
338 static void
339 renderPixmap(W_Screen *screen, Pixmap d, Pixmap mask, char **data,
340 int width, int height)
342 int x, y;
343 GC whiteGC = W_GC(screen->white);
344 GC blackGC = W_GC(screen->black);
345 GC lightGC = W_GC(screen->gray);
346 GC darkGC = W_GC(screen->darkGray);
349 if (mask)
350 XSetForeground(screen->display, screen->monoGC,
351 W_PIXEL(screen->black));
353 for (y = 0; y < height; y++) {
354 for (x = 0; x < width; x++) {
355 switch (data[y][x]) {
356 case ' ':
357 case 'w':
358 XDrawPoint(screen->display, d, whiteGC, x, y);
359 break;
361 case '=':
362 if (mask)
363 XDrawPoint(screen->display, mask, screen->monoGC, x, y);
365 case '.':
366 case 'l':
367 XDrawPoint(screen->display, d, lightGC, x, y);
368 break;
370 case '%':
371 case 'd':
372 XDrawPoint(screen->display, d, darkGC, x, y);
373 break;
375 case '#':
376 case 'b':
377 default:
378 XDrawPoint(screen->display, d, blackGC, x, y);
379 break;
387 static WMPixmap*
388 makePixmap(W_Screen *sPtr, char **data, int width, int height, int masked)
390 Pixmap pixmap, mask = None;
392 pixmap = XCreatePixmap(sPtr->display, W_DRAWABLE(sPtr), width, height,
393 sPtr->depth);
395 if (masked) {
396 mask = XCreatePixmap(sPtr->display, W_DRAWABLE(sPtr), width, height, 1);
397 XSetForeground(sPtr->display, sPtr->monoGC, W_PIXEL(sPtr->white));
398 XFillRectangle(sPtr->display, mask, sPtr->monoGC, 0, 0, width, height);
401 renderPixmap(sPtr, pixmap, mask, data, width, height);
403 return WMCreatePixmapFromXPixmaps(sPtr, pixmap, mask, width, height,
404 sPtr->depth);
407 #ifdef USE_TIFF
408 #define WINGS_IMAGES_FILE RESOURCE_PATH"/Images.tiff"
409 #define DEFAULT_OBJECT_ICON_FILE RESOURCE_PATH"/defaultIcon.tiff"
410 #else
411 #define WINGS_IMAGES_FILE RESOURCE_PATH"/Images.xpm"
412 #define DEFAULT_OBJECT_ICON_FILE RESOURCE_PATH"/defaultIcon.xpm"
413 #endif
415 static Bool
416 loadPixmaps(WMScreen *scr)
418 RImage *image, *tmp;
419 Pixmap pixmap;
420 RColor gray;
422 image = RLoadImage(scr->rcontext, WINGS_IMAGES_FILE, 0);
423 if (!image) {
424 wwarning("WINGs: could not load widget images file: %s",
425 RMessageForError(RErrorCode));
426 return False;
428 /* make it have a gray background */
429 gray.red = 0xae;
430 gray.green = 0xaa;
431 gray.blue = 0xae;
432 RCombineImageWithColor(image, &gray);
433 tmp = RGetSubImage(image, 0, 0, 24, 24);
434 if (!RConvertImage(scr->rcontext, tmp, &pixmap)) {
435 scr->homeIcon = NULL;
436 } else {
437 scr->homeIcon = WMCreatePixmapFromXPixmaps(scr, pixmap, None, 24, 24,
438 scr->depth);
440 RDestroyImage(tmp);
441 RDestroyImage(image);
443 #if 0
444 scr->defaultObjectIcon =
445 WMCreatePixmapFromFile(scr, DEFAULT_OBJECT_ICON_FILE);
446 if (!scr->defaultObjectIcon) {
447 wwarning("WINGs: could not load default icon file");
448 return False;
450 #endif
451 return True;
456 WMScreen*
457 WMCreateSimpleApplicationScreen(Display *display)
459 WMScreen *scr;
461 scr = WMCreateScreen(display, DefaultScreen(display));
463 scr->aflags.hasAppIcon = 0;
464 scr->aflags.simpleApplication = 1;
466 return scr;
471 WMScreen*
472 WMCreateScreen(Display *display, int screen)
474 return WMCreateScreenWithRContext(display, screen,
475 RCreateContext(display, screen, NULL));
479 WMScreen*
480 WMCreateScreenWithRContext(Display *display, int screen, RContext *context)
482 W_Screen *scrPtr;
483 XGCValues gcv;
484 Pixmap stipple;
485 static int initialized = 0;
487 if (!initialized) {
489 initialized = 1;
491 initProcedureTable();
493 assert(W_ApplicationInitialized());
496 scrPtr = malloc(sizeof(W_Screen));
497 if (!scrPtr)
498 return NULL;
499 memset(scrPtr, 0, sizeof(W_Screen));
501 scrPtr->aflags.hasAppIcon = 1;
503 scrPtr->display = display;
504 scrPtr->screen = screen;
505 scrPtr->rcontext = context;
507 scrPtr->depth = context->depth;
509 scrPtr->visual = context->visual;
510 scrPtr->lastEventTime = 0;
512 scrPtr->colormap = context->cmap;
514 scrPtr->rootWin = RootWindow(display, screen);
517 /* initially allocate some colors */
518 WMWhiteColor(scrPtr);
519 WMBlackColor(scrPtr);
520 WMGrayColor(scrPtr);
521 WMDarkGrayColor(scrPtr);
523 gcv.graphics_exposures = False;
525 gcv.function = GXxor;
526 gcv.foreground = W_PIXEL(scrPtr->white);
527 scrPtr->xorGC = XCreateGC(display, W_DRAWABLE(scrPtr), GCFunction
528 |GCGraphicsExposures|GCForeground, &gcv);
530 gcv.function = GXxor;
531 gcv.foreground = W_PIXEL(scrPtr->gray);
532 gcv.subwindow_mode = IncludeInferiors;
533 scrPtr->ixorGC = XCreateGC(display, W_DRAWABLE(scrPtr), GCFunction
534 |GCGraphicsExposures|GCForeground
535 |GCSubwindowMode, &gcv);
537 gcv.function = GXcopy;
538 scrPtr->copyGC = XCreateGC(display, W_DRAWABLE(scrPtr), GCFunction
539 |GCGraphicsExposures, &gcv);
541 scrPtr->clipGC = XCreateGC(display, W_DRAWABLE(scrPtr), GCFunction
542 |GCGraphicsExposures, &gcv);
545 stipple = XCreateBitmapFromData(display, W_DRAWABLE(scrPtr),
546 STIPPLE_BITS, STIPPLE_WIDTH, STIPPLE_HEIGHT);
547 gcv.foreground = W_PIXEL(scrPtr->darkGray);
548 gcv.background = W_PIXEL(scrPtr->gray);
549 gcv.fill_style = FillStippled;
550 gcv.stipple = stipple;
551 scrPtr->stippleGC = XCreateGC(display, W_DRAWABLE(scrPtr),
552 GCForeground|GCBackground|GCStipple
553 |GCFillStyle|GCGraphicsExposures, &gcv);
555 gcv.foreground = W_PIXEL(scrPtr->black);
556 gcv.background = W_PIXEL(scrPtr->white);
557 scrPtr->textFieldGC = XCreateGC(display, W_DRAWABLE(scrPtr),
558 GCForeground|GCBackground, &gcv);
560 /* we need a 1bpp drawable for the monoGC, so borrow this one */
561 scrPtr->monoGC = XCreateGC(display, stipple, 0, NULL);
563 XFreePixmap(display, stipple);
566 scrPtr->normalFont = WMSystemFontOfSize(scrPtr, 12);
568 scrPtr->boldFont = WMBoldSystemFontOfSize(scrPtr, 12);
570 scrPtr->checkButtonImageOn = makePixmap(scrPtr, CHECK_BUTTON_ON,
571 CHECK_BUTTON_ON_WIDTH,
572 CHECK_BUTTON_ON_HEIGHT, False);
574 scrPtr->checkButtonImageOff = makePixmap(scrPtr, CHECK_BUTTON_OFF,
575 CHECK_BUTTON_OFF_WIDTH,
576 CHECK_BUTTON_OFF_HEIGHT, False);
578 scrPtr->radioButtonImageOn = makePixmap(scrPtr, RADIO_BUTTON_ON,
579 RADIO_BUTTON_ON_WIDTH,
580 RADIO_BUTTON_ON_HEIGHT, False);
582 scrPtr->radioButtonImageOff = makePixmap(scrPtr, RADIO_BUTTON_OFF,
583 RADIO_BUTTON_OFF_WIDTH,
584 RADIO_BUTTON_OFF_HEIGHT, False);
586 scrPtr->buttonArrow = makePixmap(scrPtr, BUTTON_ARROW,
587 BUTTON_ARROW_WIDTH, BUTTON_ARROW_HEIGHT,
588 False);
590 scrPtr->pushedButtonArrow = makePixmap(scrPtr, BUTTON_ARROW2,
591 BUTTON_ARROW2_WIDTH, BUTTON_ARROW2_HEIGHT,
592 False);
595 scrPtr->scrollerDimple = makePixmap(scrPtr, SCROLLER_DIMPLE,
596 SCROLLER_DIMPLE_WIDTH,
597 SCROLLER_DIMPLE_HEIGHT, False);
600 scrPtr->upArrow = makePixmap(scrPtr, SCROLLER_ARROW_UP,
601 SCROLLER_ARROW_UP_WIDTH,
602 SCROLLER_ARROW_UP_HEIGHT, True);
604 scrPtr->downArrow = makePixmap(scrPtr, SCROLLER_ARROW_DOWN,
605 SCROLLER_ARROW_DOWN_WIDTH,
606 SCROLLER_ARROW_DOWN_HEIGHT, True);
608 scrPtr->leftArrow = makePixmap(scrPtr, SCROLLER_ARROW_LEFT,
609 SCROLLER_ARROW_LEFT_WIDTH,
610 SCROLLER_ARROW_LEFT_HEIGHT, True);
612 scrPtr->rightArrow = makePixmap(scrPtr, SCROLLER_ARROW_RIGHT,
613 SCROLLER_ARROW_RIGHT_WIDTH,
614 SCROLLER_ARROW_RIGHT_HEIGHT, True);
616 scrPtr->hiUpArrow = makePixmap(scrPtr, HI_SCROLLER_ARROW_UP,
617 SCROLLER_ARROW_UP_WIDTH,
618 SCROLLER_ARROW_UP_HEIGHT, True);
620 scrPtr->hiDownArrow = makePixmap(scrPtr, HI_SCROLLER_ARROW_DOWN,
621 SCROLLER_ARROW_DOWN_WIDTH,
622 SCROLLER_ARROW_DOWN_HEIGHT, True);
624 scrPtr->hiLeftArrow = makePixmap(scrPtr, HI_SCROLLER_ARROW_LEFT,
625 SCROLLER_ARROW_LEFT_WIDTH,
626 SCROLLER_ARROW_LEFT_HEIGHT, True);
628 scrPtr->hiRightArrow = makePixmap(scrPtr, HI_SCROLLER_ARROW_RIGHT,
629 SCROLLER_ARROW_RIGHT_WIDTH,
630 SCROLLER_ARROW_RIGHT_HEIGHT, True);
632 scrPtr->popUpIndicator = makePixmap(scrPtr, POPUP_INDICATOR,
633 POPUP_INDICATOR_WIDTH,
634 POPUP_INDICATOR_HEIGHT, True);
636 scrPtr->pullDownIndicator = makePixmap(scrPtr, PULLDOWN_INDICATOR,
637 PULLDOWN_INDICATOR_WIDTH,
638 PULLDOWN_INDICATOR_HEIGHT, True);
639 loadPixmaps(scrPtr);
641 scrPtr->defaultCursor = XCreateFontCursor(display, XC_left_ptr);
643 scrPtr->textCursor = XCreateFontCursor(display, XC_xterm);
645 scrPtr->internalMessage = XInternAtom(display, "_WINGS_MESSAGE", False);
647 scrPtr->attribsAtom = XInternAtom(display, "_GNUSTEP_WM_ATTR", False);
649 scrPtr->deleteWindowAtom = XInternAtom(display, "WM_DELETE_WINDOW", False);
651 scrPtr->protocolsAtom = XInternAtom(display, "WM_PROTOCOLS", False);
653 scrPtr->clipboardAtom = XInternAtom(display, "CLIPBOARD", False);
655 scrPtr->rootView = W_CreateRootView(scrPtr);
657 W_InitApplication(scrPtr);
659 return scrPtr;
663 void
664 WMHangData(WMWidget *widget, void *data)
666 W_VIEW(widget)->hangedData = data;
670 void*
671 WMGetHangedData(WMWidget *widget)
673 return W_VIEW(widget)->hangedData;
678 void
679 WMDestroyWidget(WMWidget *widget)
681 W_DestroyView(W_VIEW(widget));
685 void
686 WMSetFocusToWidget(WMWidget *widget)
688 W_SetFocusOfTopLevel(W_TopLevelOfView(W_VIEW(widget)), W_VIEW(widget));
693 * WMRealizeWidget-
694 * Realizes the widget and all it's children.
697 void
698 WMRealizeWidget(WMWidget *w)
700 W_RealizeView(W_VIEW(w));
703 void
704 WMMapWidget(WMWidget *w)
706 W_MapView(W_VIEW(w));
710 static void
711 makeChildrenAutomap(W_View *view, int flag)
713 view = view->childrenList;
715 while (view) {
716 view->flags.mapWhenRealized = flag;
717 makeChildrenAutomap(view, flag);
719 view = view->nextSister;
724 void
725 WMMapSubwidgets(WMWidget *w)
727 /* make sure that subwidgets created after the parent was realized
728 * are mapped too */
729 if (!W_VIEW(w)->flags.realized) {
730 makeChildrenAutomap(W_VIEW(w), True);
731 } else {
732 W_MapSubviews(W_VIEW(w));
737 void
738 WMUnmapSubwidgets(WMWidget *w)
740 if (!W_VIEW(w)->flags.realized) {
741 makeChildrenAutomap(W_VIEW(w), False);
742 } else {
743 W_UnmapSubviews(W_VIEW(w));
749 void
750 WMUnmapWidget(WMWidget *w)
752 W_UnmapView(W_VIEW(w));
756 void
757 WMSetWidgetBackgroundColor(WMWidget *w, WMColor *color)
759 if (W_CLASS(w) < WC_UserWidget
760 && procedureTables[W_CLASS(w)]->setBackgroundColor) {
762 (*procedureTables[W_CLASS(w)]->setBackgroundColor)(w, color);
764 } else if (W_CLASS(w) >= WC_UserWidget
765 && userProcedureTable[W_CLASS(w)-WC_UserWidget]->setBackgroundColor) {
767 (*userProcedureTable[W_CLASS(w)-WC_UserWidget]->setBackgroundColor)(w, color);
769 } else {
770 W_SetViewBackgroundColor(W_VIEW(w), color);
775 void
776 WMMoveWidget(WMWidget *w, int x, int y)
778 if (W_CLASS(w) < WC_UserWidget
779 && procedureTables[W_CLASS(w)]->move) {
781 (*procedureTables[W_CLASS(w)]->move)(w, x, y);
783 } else if (W_CLASS(w) >= WC_UserWidget
784 && userProcedureTable[W_CLASS(w)-WC_UserWidget]->move) {
786 (*userProcedureTable[W_CLASS(w)-WC_UserWidget]->move)(w, x, y);
788 } else {
789 W_MoveView(W_VIEW(w), x, y);
794 void
795 WMResizeWidget(WMWidget *w, unsigned int width, unsigned int height)
797 if (W_CLASS(w) < WC_UserWidget
798 && procedureTables[W_CLASS(w)]->resize) {
800 (*procedureTables[W_CLASS(w)]->resize)(w, width, height);
802 } else if (W_CLASS(w) >= WC_UserWidget
803 && userProcedureTable[W_CLASS(w)-WC_UserWidget]->resize) {
805 (*userProcedureTable[W_CLASS(w)-WC_UserWidget]->resize)(w, width, height);
807 } else {
808 W_ResizeView(W_VIEW(w), width, height);
814 W_Class
815 W_RegisterUserWidget(W_ViewProcedureTable *procTable)
817 W_ViewProcedureTable **newTable;
819 userWidgetCount++;
820 newTable = wmalloc(sizeof(W_ViewProcedureTable*)*userWidgetCount);
821 memcpy(newTable, userProcedureTable,
822 sizeof(W_ViewProcedureTable*)*(userWidgetCount-1));
824 newTable[userWidgetCount-1] = procTable;
826 free(userProcedureTable);
828 userProcedureTable = newTable;
830 return userWidgetCount + WC_UserWidget - 1;
835 RContext*
836 WMScreenRContext(WMScreen *scr)
838 return scr->rcontext;
843 unsigned int
844 WMWidgetWidth(WMWidget *w)
846 return W_VIEW(w)->size.width;
850 unsigned int
851 WMWidgetHeight(WMWidget *w)
853 return W_VIEW(w)->size.height;
857 Window
858 WMWidgetXID(WMWidget *w)
860 return W_VIEW(w)->window;
864 WMScreen*
865 WMWidgetScreen(WMWidget *w)
867 return W_VIEW(w)->screen;
872 void
873 WMScreenMainLoop(WMScreen *scr)
875 XEvent event;
877 while (1) {
878 WMNextEvent(scr->display, &event);
879 WMHandleEvent(&event);
885 Display*
886 WMScreenDisplay(WMScreen *scr)
888 return scr->display;
892 int
893 WMScreenDepth(WMScreen *scr)
895 return scr->depth;
899 void
900 WMRedisplayWidget(WMWidget *w)
902 W_RedisplayView(W_VIEW(w));