Initial revision
[wmaker-crm.git] / WINGs / widgets.c
blob69ec62e151dcc1c3104c0783e1f17be45d2b30e5
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", RErrorString);
425 return False;
427 /* make it have a gray background */
428 gray.red = 0xae;
429 gray.green = 0xaa;
430 gray.blue = 0xae;
431 RCombineImageWithColor(image, &gray);
432 tmp = RGetSubImage(image, 0, 0, 24, 24);
433 if (!RConvertImage(scr->rcontext, tmp, &pixmap)) {
434 scr->homeIcon = NULL;
435 } else {
436 scr->homeIcon = WMCreatePixmapFromXPixmaps(scr, pixmap, None, 24, 24,
437 scr->depth);
439 RDestroyImage(tmp);
440 RDestroyImage(image);
442 #if 0
443 scr->defaultObjectIcon =
444 WMCreatePixmapFromFile(scr, DEFAULT_OBJECT_ICON_FILE);
445 if (!scr->defaultObjectIcon) {
446 wwarning("WINGs: could not load default icon file");
447 return False;
449 #endif
450 return True;
455 WMScreen*
456 WMCreateSimpleApplicationScreen(Display *display)
458 WMScreen *scr;
460 scr = WMCreateScreen(display, DefaultScreen(display));
462 scr->aflags.hasAppIcon = 0;
463 scr->aflags.simpleApplication = 1;
465 return scr;
470 WMScreen*
471 WMCreateScreen(Display *display, int screen)
473 return WMCreateScreenWithRContext(display, screen,
474 RCreateContext(display, screen, NULL));
478 WMScreen*
479 WMCreateScreenWithRContext(Display *display, int screen, RContext *context)
481 W_Screen *scrPtr;
482 XGCValues gcv;
483 Pixmap stipple;
484 static int initialized = 0;
486 if (!initialized) {
488 initialized = 1;
490 initProcedureTable();
492 assert(W_ApplicationInitialized());
495 scrPtr = malloc(sizeof(W_Screen));
496 if (!scrPtr)
497 return NULL;
498 memset(scrPtr, 0, sizeof(W_Screen));
500 scrPtr->aflags.hasAppIcon = 1;
502 scrPtr->display = display;
503 scrPtr->screen = screen;
504 scrPtr->rcontext = context;
506 scrPtr->depth = context->depth;
508 scrPtr->visual = context->visual;
509 scrPtr->lastEventTime = 0;
511 scrPtr->colormap = context->cmap;
513 scrPtr->rootWin = RootWindow(display, screen);
516 /* initially allocate some colors */
517 WMWhiteColor(scrPtr);
518 WMBlackColor(scrPtr);
519 WMGrayColor(scrPtr);
520 WMDarkGrayColor(scrPtr);
522 gcv.graphics_exposures = False;
524 gcv.function = GXxor;
525 gcv.foreground = W_PIXEL(scrPtr->white);
526 scrPtr->xorGC = XCreateGC(display, W_DRAWABLE(scrPtr), GCFunction
527 |GCGraphicsExposures|GCForeground, &gcv);
529 gcv.function = GXxor;
530 gcv.foreground = W_PIXEL(scrPtr->gray);
531 gcv.subwindow_mode = IncludeInferiors;
532 scrPtr->ixorGC = XCreateGC(display, W_DRAWABLE(scrPtr), GCFunction
533 |GCGraphicsExposures|GCForeground
534 |GCSubwindowMode, &gcv);
536 gcv.function = GXcopy;
537 scrPtr->copyGC = XCreateGC(display, W_DRAWABLE(scrPtr), GCFunction
538 |GCGraphicsExposures, &gcv);
540 scrPtr->clipGC = XCreateGC(display, W_DRAWABLE(scrPtr), GCFunction
541 |GCGraphicsExposures, &gcv);
544 stipple = XCreateBitmapFromData(display, W_DRAWABLE(scrPtr),
545 STIPPLE_BITS, STIPPLE_WIDTH, STIPPLE_HEIGHT);
546 gcv.foreground = W_PIXEL(scrPtr->darkGray);
547 gcv.background = W_PIXEL(scrPtr->gray);
548 gcv.fill_style = FillStippled;
549 gcv.stipple = stipple;
550 scrPtr->stippleGC = XCreateGC(display, W_DRAWABLE(scrPtr),
551 GCForeground|GCBackground|GCStipple
552 |GCFillStyle|GCGraphicsExposures, &gcv);
554 gcv.foreground = W_PIXEL(scrPtr->black);
555 gcv.background = W_PIXEL(scrPtr->white);
556 scrPtr->textFieldGC = XCreateGC(display, W_DRAWABLE(scrPtr),
557 GCForeground|GCBackground, &gcv);
559 /* we need a 1bpp drawable for the monoGC, so borrow this one */
560 scrPtr->monoGC = XCreateGC(display, stipple, 0, NULL);
562 XFreePixmap(display, stipple);
565 scrPtr->normalFont = WMSystemFontOfSize(scrPtr, 12);
567 scrPtr->boldFont = WMBoldSystemFontOfSize(scrPtr, 12);
569 scrPtr->checkButtonImageOn = makePixmap(scrPtr, CHECK_BUTTON_ON,
570 CHECK_BUTTON_ON_WIDTH,
571 CHECK_BUTTON_ON_HEIGHT, False);
573 scrPtr->checkButtonImageOff = makePixmap(scrPtr, CHECK_BUTTON_OFF,
574 CHECK_BUTTON_OFF_WIDTH,
575 CHECK_BUTTON_OFF_HEIGHT, False);
577 scrPtr->radioButtonImageOn = makePixmap(scrPtr, RADIO_BUTTON_ON,
578 RADIO_BUTTON_ON_WIDTH,
579 RADIO_BUTTON_ON_HEIGHT, False);
581 scrPtr->radioButtonImageOff = makePixmap(scrPtr, RADIO_BUTTON_OFF,
582 RADIO_BUTTON_OFF_WIDTH,
583 RADIO_BUTTON_OFF_HEIGHT, False);
585 scrPtr->buttonArrow = makePixmap(scrPtr, BUTTON_ARROW,
586 BUTTON_ARROW_WIDTH, BUTTON_ARROW_HEIGHT,
587 False);
589 scrPtr->pushedButtonArrow = makePixmap(scrPtr, BUTTON_ARROW2,
590 BUTTON_ARROW2_WIDTH, BUTTON_ARROW2_HEIGHT,
591 False);
594 scrPtr->scrollerDimple = makePixmap(scrPtr, SCROLLER_DIMPLE,
595 SCROLLER_DIMPLE_WIDTH,
596 SCROLLER_DIMPLE_HEIGHT, False);
599 scrPtr->upArrow = makePixmap(scrPtr, SCROLLER_ARROW_UP,
600 SCROLLER_ARROW_UP_WIDTH,
601 SCROLLER_ARROW_UP_HEIGHT, True);
603 scrPtr->downArrow = makePixmap(scrPtr, SCROLLER_ARROW_DOWN,
604 SCROLLER_ARROW_DOWN_WIDTH,
605 SCROLLER_ARROW_DOWN_HEIGHT, True);
607 scrPtr->leftArrow = makePixmap(scrPtr, SCROLLER_ARROW_LEFT,
608 SCROLLER_ARROW_LEFT_WIDTH,
609 SCROLLER_ARROW_LEFT_HEIGHT, True);
611 scrPtr->rightArrow = makePixmap(scrPtr, SCROLLER_ARROW_RIGHT,
612 SCROLLER_ARROW_RIGHT_WIDTH,
613 SCROLLER_ARROW_RIGHT_HEIGHT, True);
615 scrPtr->hiUpArrow = makePixmap(scrPtr, HI_SCROLLER_ARROW_UP,
616 SCROLLER_ARROW_UP_WIDTH,
617 SCROLLER_ARROW_UP_HEIGHT, True);
619 scrPtr->hiDownArrow = makePixmap(scrPtr, HI_SCROLLER_ARROW_DOWN,
620 SCROLLER_ARROW_DOWN_WIDTH,
621 SCROLLER_ARROW_DOWN_HEIGHT, True);
623 scrPtr->hiLeftArrow = makePixmap(scrPtr, HI_SCROLLER_ARROW_LEFT,
624 SCROLLER_ARROW_LEFT_WIDTH,
625 SCROLLER_ARROW_LEFT_HEIGHT, True);
627 scrPtr->hiRightArrow = makePixmap(scrPtr, HI_SCROLLER_ARROW_RIGHT,
628 SCROLLER_ARROW_RIGHT_WIDTH,
629 SCROLLER_ARROW_RIGHT_HEIGHT, True);
631 scrPtr->popUpIndicator = makePixmap(scrPtr, POPUP_INDICATOR,
632 POPUP_INDICATOR_WIDTH,
633 POPUP_INDICATOR_HEIGHT, True);
635 scrPtr->pullDownIndicator = makePixmap(scrPtr, PULLDOWN_INDICATOR,
636 PULLDOWN_INDICATOR_WIDTH,
637 PULLDOWN_INDICATOR_HEIGHT, True);
638 loadPixmaps(scrPtr);
640 scrPtr->defaultCursor = XCreateFontCursor(display, XC_left_ptr);
642 scrPtr->textCursor = XCreateFontCursor(display, XC_xterm);
644 scrPtr->internalMessage = XInternAtom(display, "_WINGS_MESSAGE", False);
646 scrPtr->attribsAtom = XInternAtom(display, "_GNUSTEP_WM_ATTR", False);
648 scrPtr->deleteWindowAtom = XInternAtom(display, "WM_DELETE_WINDOW", False);
650 scrPtr->protocolsAtom = XInternAtom(display, "WM_PROTOCOLS", False);
652 scrPtr->clipboardAtom = XInternAtom(display, "CLIPBOARD", False);
654 scrPtr->rootView = W_CreateRootView(scrPtr);
656 return scrPtr;
660 void
661 WMHangData(WMWidget *widget, void *data)
663 W_VIEW(widget)->hangedData = data;
667 void*
668 WMGetHangedData(WMWidget *widget)
670 return W_VIEW(widget)->hangedData;
675 void
676 WMDestroyWidget(WMWidget *widget)
678 W_DestroyView(W_VIEW(widget));
682 void
683 WMSetFocusToWidget(WMWidget *widget)
685 W_SetFocusOfTopLevel(W_TopLevelOfView(W_VIEW(widget)), W_VIEW(widget));
690 * WMRealizeWidget-
691 * Realizes the widget and all it's children.
694 void
695 WMRealizeWidget(WMWidget *w)
697 W_RealizeView(W_VIEW(w));
700 void
701 WMMapWidget(WMWidget *w)
703 W_MapView(W_VIEW(w));
707 static void
708 makeChildrenAutomap(W_View *view, int flag)
710 view = view->childrenList;
712 while (view) {
713 view->flags.mapWhenRealized = flag;
714 makeChildrenAutomap(view, flag);
716 view = view->nextSister;
721 void
722 WMMapSubwidgets(WMWidget *w)
724 /* make sure that subwidgets created after the parent was realized
725 * are mapped too */
726 if (!W_VIEW(w)->flags.realized) {
727 makeChildrenAutomap(W_VIEW(w), True);
728 } else {
729 W_MapSubviews(W_VIEW(w));
734 void
735 WMUnmapSubwidgets(WMWidget *w)
737 if (!W_VIEW(w)->flags.realized) {
738 makeChildrenAutomap(W_VIEW(w), False);
739 } else {
740 W_UnmapSubviews(W_VIEW(w));
746 void
747 WMUnmapWidget(WMWidget *w)
749 W_UnmapView(W_VIEW(w));
753 void
754 WMSetWidgetBackgroundColor(WMWidget *w, WMColor *color)
756 if (W_CLASS(w) < WC_UserWidget
757 && procedureTables[W_CLASS(w)]->setBackgroundColor) {
759 (*procedureTables[W_CLASS(w)]->setBackgroundColor)(w, color);
761 } else if (W_CLASS(w) >= WC_UserWidget
762 && userProcedureTable[W_CLASS(w)-WC_UserWidget]->setBackgroundColor) {
764 (*userProcedureTable[W_CLASS(w)-WC_UserWidget]->setBackgroundColor)(w, color);
766 } else {
767 W_SetViewBackgroundColor(W_VIEW(w), color);
772 void
773 WMMoveWidget(WMWidget *w, int x, int y)
775 if (W_CLASS(w) < WC_UserWidget
776 && procedureTables[W_CLASS(w)]->move) {
778 (*procedureTables[W_CLASS(w)]->move)(w, x, y);
780 } else if (W_CLASS(w) >= WC_UserWidget
781 && userProcedureTable[W_CLASS(w)-WC_UserWidget]->move) {
783 (*userProcedureTable[W_CLASS(w)-WC_UserWidget]->move)(w, x, y);
785 } else {
786 W_MoveView(W_VIEW(w), x, y);
791 void
792 WMResizeWidget(WMWidget *w, unsigned int width, unsigned int height)
794 if (W_CLASS(w) < WC_UserWidget
795 && procedureTables[W_CLASS(w)]->resize) {
797 (*procedureTables[W_CLASS(w)]->resize)(w, width, height);
799 } else if (W_CLASS(w) >= WC_UserWidget
800 && userProcedureTable[W_CLASS(w)-WC_UserWidget]->resize) {
802 (*userProcedureTable[W_CLASS(w)-WC_UserWidget]->resize)(w, width, height);
804 } else {
805 W_ResizeView(W_VIEW(w), width, height);
811 W_Class
812 W_RegisterUserWidget(W_ViewProcedureTable *procTable)
814 W_ViewProcedureTable **newTable;
816 userWidgetCount++;
817 newTable = wmalloc(sizeof(W_ViewProcedureTable*)*userWidgetCount);
818 memcpy(newTable, userProcedureTable,
819 sizeof(W_ViewProcedureTable*)*(userWidgetCount-1));
821 newTable[userWidgetCount-1] = procTable;
823 free(userProcedureTable);
825 userProcedureTable = newTable;
827 return userWidgetCount + WC_UserWidget - 1;
832 RContext*
833 WMScreenRContext(WMScreen *scr)
835 return scr->rcontext;
840 unsigned int
841 WMWidgetWidth(WMWidget *w)
843 return W_VIEW(w)->size.width;
847 unsigned int
848 WMWidgetHeight(WMWidget *w)
850 return W_VIEW(w)->size.height;
854 Window
855 WMWidgetXID(WMWidget *w)
857 return W_VIEW(w)->window;
861 WMScreen*
862 WMWidgetScreen(WMWidget *w)
864 return W_VIEW(w)->screen;
869 void
870 WMScreenMainLoop(WMScreen *scr)
872 XEvent event;
874 while (1) {
875 WMNextEvent(scr->display, &event);
876 WMHandleEvent(&event);
882 Display*
883 WMScreenDisplay(WMScreen *scr)
885 return scr->display;
889 void
890 WMRedisplayWidget(WMWidget *w)
892 W_RedisplayView(W_VIEW(w));