5 #include <X11/Xft/Xft.h>
9 #include <X11/keysym.h>
10 #include <X11/cursorfont.h>
12 #include <X11/Xlocale.h>
14 /********** data ************/
16 #define CHECK_BUTTON_ON_WIDTH 16
17 #define CHECK_BUTTON_ON_HEIGHT 16
19 static char *CHECK_BUTTON_ON
[] = {
38 #define CHECK_BUTTON_OFF_WIDTH 16
39 #define CHECK_BUTTON_OFF_HEIGHT 16
41 static char *CHECK_BUTTON_OFF
[] = {
60 #define RADIO_BUTTON_ON_WIDTH 15
61 #define RADIO_BUTTON_ON_HEIGHT 15
62 static char *RADIO_BUTTON_ON
[] = {
80 #define RADIO_BUTTON_OFF_WIDTH 15
81 #define RADIO_BUTTON_OFF_HEIGHT 15
82 static char *RADIO_BUTTON_OFF
[] = {
100 static char *BUTTON_ARROW
[] = {
101 "..................",
102 "....##....#### ...",
103 "...#.%....#... ...",
104 "..#..%#####... ...",
105 ".#............ ...",
106 "#............. ...",
107 ".#............ ...",
109 "...#. ............",
113 #define BUTTON_ARROW_WIDTH 18
114 #define BUTTON_ARROW_HEIGHT 10
116 static char *BUTTON_ARROW2
[] = {
129 #define BUTTON_ARROW2_WIDTH 18
130 #define BUTTON_ARROW2_HEIGHT 10
132 static char *SCROLLER_DIMPLE
[] = {
141 #define SCROLLER_DIMPLE_WIDTH 6
142 #define SCROLLER_DIMPLE_HEIGHT 6
144 static char *SCROLLER_ARROW_UP
[] = {
156 static char *HI_SCROLLER_ARROW_UP
[] = {
168 #define SCROLLER_ARROW_UP_WIDTH 9
169 #define SCROLLER_ARROW_UP_HEIGHT 9
171 static char *SCROLLER_ARROW_DOWN
[] = {
183 static char *HI_SCROLLER_ARROW_DOWN
[] = {
195 #define SCROLLER_ARROW_DOWN_WIDTH 9
196 #define SCROLLER_ARROW_DOWN_HEIGHT 9
198 static char *SCROLLER_ARROW_LEFT
[] = {
210 static char *HI_SCROLLER_ARROW_LEFT
[] = {
222 #define SCROLLER_ARROW_LEFT_WIDTH 9
223 #define SCROLLER_ARROW_LEFT_HEIGHT 9
225 static char *SCROLLER_ARROW_RIGHT
[] = {
237 static char *HI_SCROLLER_ARROW_RIGHT
[] = {
249 #define SCROLLER_ARROW_RIGHT_WIDTH 9
250 #define SCROLLER_ARROW_RIGHT_HEIGHT 9
252 static char *POPUP_INDICATOR
[] = {
263 #define POPUP_INDICATOR_WIDTH 11
264 #define POPUP_INDICATOR_HEIGHT 8
266 static char *PULLDOWN_INDICATOR
[] = {
276 #define PULLDOWN_INDICATOR_WIDTH 9
277 #define PULLDOWN_INDICATOR_HEIGHT 7
279 #define CHECK_MARK_WIDTH 8
280 #define CHECK_MARK_HEIGHT 10
282 static char *CHECK_MARK
[] = {
295 #define STIPPLE_WIDTH 8
296 #define STIPPLE_HEIGHT 8
297 static char STIPPLE_BITS
[] = {
298 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55
301 static int userWidgetCount
= 0;
303 /***** end data ******/
305 static void renderPixmap(W_Screen
* screen
, Pixmap d
, Pixmap mask
, char **data
, int width
, int height
)
308 GC whiteGC
= WMColorGC(screen
->white
);
309 GC blackGC
= WMColorGC(screen
->black
);
310 GC lightGC
= WMColorGC(screen
->gray
);
311 GC darkGC
= WMColorGC(screen
->darkGray
);
314 XSetForeground(screen
->display
, screen
->monoGC
, 0);
316 for (y
= 0; y
< height
; y
++) {
317 for (x
= 0; x
< width
; x
++) {
318 switch (data
[y
][x
]) {
321 XDrawPoint(screen
->display
, d
, whiteGC
, x
, y
);
326 XDrawPoint(screen
->display
, mask
, screen
->monoGC
, x
, y
);
330 XDrawPoint(screen
->display
, d
, lightGC
, x
, y
);
335 XDrawPoint(screen
->display
, d
, darkGC
, x
, y
);
341 XDrawPoint(screen
->display
, d
, blackGC
, x
, y
);
348 static WMPixmap
*makePixmap(W_Screen
* sPtr
, char **data
, int width
, int height
, int masked
)
350 Pixmap pixmap
, mask
= None
;
352 pixmap
= XCreatePixmap(sPtr
->display
, W_DRAWABLE(sPtr
), width
, height
, sPtr
->depth
);
355 mask
= XCreatePixmap(sPtr
->display
, W_DRAWABLE(sPtr
), width
, height
, 1);
356 XSetForeground(sPtr
->display
, sPtr
->monoGC
, 1);
357 XFillRectangle(sPtr
->display
, mask
, sPtr
->monoGC
, 0, 0, width
, height
);
360 renderPixmap(sPtr
, pixmap
, mask
, data
, width
, height
);
362 return WMCreatePixmapFromXPixmaps(sPtr
, pixmap
, mask
, width
, height
, sPtr
->depth
);
365 #define T_WINGS_IMAGES_FILE RESOURCE_PATH"/Images.tiff"
366 #define X_WINGS_IMAGES_FILE RESOURCE_PATH"/Images.xpm"
368 static Bool
loadPixmaps(WMScreen
* scr
)
382 image
= RLoadImage(scr
->rcontext
, T_WINGS_IMAGES_FILE
, 0);
384 image
= RLoadImage(scr
->rcontext
, X_WINGS_IMAGES_FILE
, 0);
386 wwarning(_("WINGs: could not load widget images file: %s"), RMessageForError(RErrorCode
));
390 /* make it have a gray background */
391 tmp
= RGetSubImage(image
, 0, 0, 24, 24);
392 RCombineImageWithColor(tmp
, &gray
);
393 scr
->homeIcon
= WMCreatePixmapFromRImage(scr
, tmp
, 128);
395 /* make it have a white background */
396 tmp
= RGetSubImage(image
, 0, 0, 24, 24);
397 RCombineImageWithColor(tmp
, &white
);
398 scr
->altHomeIcon
= WMCreatePixmapFromRImage(scr
, tmp
, 128);
402 tmp
= RGetSubImage(image
, 104, 0, 24, 24);
403 RCombineImageWithColor(tmp
, &white
);
404 scr
->trashcanIcon
= WMCreatePixmapFromRImage(scr
, tmp
, 128);
406 tmp
= RGetSubImage(image
, 104, 0, 24, 24);
407 RCombineImageWithColor(tmp
, &white
);
408 scr
->altTrashcanIcon
= WMCreatePixmapFromRImage(scr
, tmp
, 128);
411 tmp
= RGetSubImage(image
, 104, 24, 24, 24);
412 RCombineImageWithColor(tmp
, &white
);
413 scr
->createDirIcon
= WMCreatePixmapFromRImage(scr
, tmp
, 128);
415 tmp
= RGetSubImage(image
, 104, 24, 24, 24);
416 RCombineImageWithColor(tmp
, &white
);
417 scr
->altCreateDirIcon
= WMCreatePixmapFromRImage(scr
, tmp
, 128);
420 tmp
= RGetSubImage(image
, 24, 80, 24, 24);
421 RCombineImageWithColor(tmp
, &white
);
422 scr
->disketteIcon
= WMCreatePixmapFromRImage(scr
, tmp
, 128);
424 tmp
= RGetSubImage(image
, 24, 80, 24, 24);
425 RCombineImageWithColor(tmp
, &white
);
426 scr
->altDisketteIcon
= WMCreatePixmapFromRImage(scr
, tmp
, 128);
429 tmp
= RGetSubImage(image
, 0, 80, 24, 24);
430 RCombineImageWithColor(tmp
, &white
);
431 scr
->unmountIcon
= WMCreatePixmapFromRImage(scr
, tmp
, 128);
433 tmp
= RGetSubImage(image
, 0, 80, 24, 24);
434 RCombineImageWithColor(tmp
, &white
);
435 scr
->altUnmountIcon
= WMCreatePixmapFromRImage(scr
, tmp
, 128);
438 /* Magnifying Glass Icon for ColorPanel */
439 tmp
= RGetSubImage(image
, 24, 0, 40, 32);
440 RCombineImageWithColor(tmp
, &gray
);
441 scr
->magnifyIcon
= WMCreatePixmapFromRImage(scr
, tmp
, 128);
443 /* ColorWheel Icon for ColorPanel */
444 tmp
= RGetSubImage(image
, 0, 25, 24, 24);
445 scr
->wheelIcon
= WMCreatePixmapFromRImage(scr
, tmp
, 128);
447 /* GrayScale Icon for ColorPanel */
448 tmp
= RGetSubImage(image
, 65, 0, 40, 24);
449 scr
->grayIcon
= WMCreatePixmapFromRImage(scr
, tmp
, 128);
451 /* RGB Icon for ColorPanel */
452 tmp
= RGetSubImage(image
, 25, 33, 40, 24);
453 scr
->rgbIcon
= WMCreatePixmapFromRImage(scr
, tmp
, 128);
455 /* CMYK Icon for ColorPanel */
456 tmp
= RGetSubImage(image
, 65, 25, 40, 24);
457 scr
->cmykIcon
= WMCreatePixmapFromRImage(scr
, tmp
, 128);
459 /* HSB Icon for ColorPanel */
460 tmp
= RGetSubImage(image
, 0, 57, 40, 24);
461 scr
->hsbIcon
= WMCreatePixmapFromRImage(scr
, tmp
, 128);
463 /* CustomColorPalette Icon for ColorPanel */
464 tmp
= RGetSubImage(image
, 81, 57, 40, 24);
465 scr
->customPaletteIcon
= WMCreatePixmapFromRImage(scr
, tmp
, 128);
467 /* ColorList Icon for ColorPanel */
468 tmp
= RGetSubImage(image
, 41, 57, 40, 24);
469 scr
->colorListIcon
= WMCreatePixmapFromRImage(scr
, tmp
, 128);
472 RReleaseImage(image
);
477 WMScreen
*WMOpenScreen(const char *display
)
479 Display
*dpy
= XOpenDisplay(display
);
482 wwarning("WINGs: could not open display %s", XDisplayName(display
));
486 return WMCreateSimpleApplicationScreen(dpy
);
489 WMScreen
*WMCreateSimpleApplicationScreen(Display
* display
)
493 scr
= WMCreateScreen(display
, DefaultScreen(display
));
495 scr
->aflags
.hasAppIcon
= 0;
496 scr
->aflags
.simpleApplication
= 1;
501 WMScreen
*WMCreateScreen(Display
* display
, int screen
)
503 return WMCreateScreenWithRContext(display
, screen
, RCreateContext(display
, screen
, NULL
));
506 WMScreen
*WMCreateScreenWithRContext(Display
* display
, int screen
, RContext
* context
)
511 static int initialized
= 0;
512 static char *atomNames
[] = {
526 "XdndActionDescription",
533 "_WINGS_DND_MOUSE_OFFSET",
540 Atom atoms
[wlengthof(atomNames
)];
547 W_ReadConfigurations();
549 assert(W_ApplicationInitialized());
552 scrPtr
= malloc(sizeof(W_Screen
));
555 memset(scrPtr
, 0, sizeof(W_Screen
));
557 scrPtr
->aflags
.hasAppIcon
= 1;
559 scrPtr
->display
= display
;
560 scrPtr
->screen
= screen
;
561 scrPtr
->rcontext
= context
;
563 scrPtr
->depth
= context
->depth
;
565 scrPtr
->visual
= context
->visual
;
566 scrPtr
->lastEventTime
= 0;
568 scrPtr
->colormap
= context
->cmap
;
570 scrPtr
->rootWin
= RootWindow(display
, screen
);
572 scrPtr
->fontCache
= WMCreateHashTable(WMStringPointerHashCallbacks
);
574 scrPtr
->xftdraw
= XftDrawCreate(scrPtr
->display
, W_DRAWABLE(scrPtr
), scrPtr
->visual
, scrPtr
->colormap
);
576 /* Create missing CUT_BUFFERs */
579 int exists
[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
582 rootWinProps
= XListProperties(display
, scrPtr
->rootWin
, &count
);
583 for (i
= 0; i
< count
; i
++) {
584 switch (rootWinProps
[i
]) {
616 for (i
= 0; i
< 8; i
++) {
618 XStoreBuffer(display
, "", 0, i
);
623 scrPtr
->ignoredModifierMask
= 0;
626 XModifierKeymap
*modmap
;
627 KeyCode nlock
, slock
;
628 static int mask_table
[8] = {
629 ShiftMask
, LockMask
, ControlMask
, Mod1Mask
,
630 Mod2Mask
, Mod3Mask
, Mod4Mask
, Mod5Mask
632 unsigned int numLockMask
= 0, scrollLockMask
= 0;
634 nlock
= XKeysymToKeycode(display
, XK_Num_Lock
);
635 slock
= XKeysymToKeycode(display
, XK_Scroll_Lock
);
638 * Find out the masks for the NumLock and ScrollLock modifiers,
639 * so that we can bind the grabs for when they are enabled too.
641 modmap
= XGetModifierMapping(display
);
643 if (modmap
!= NULL
&& modmap
->max_keypermod
> 0) {
644 for (i
= 0; i
< 8 * modmap
->max_keypermod
; i
++) {
645 if (modmap
->modifiermap
[i
] == nlock
&& nlock
!= 0)
646 numLockMask
= mask_table
[i
/ modmap
->max_keypermod
];
647 else if (modmap
->modifiermap
[i
] == slock
&& slock
!= 0)
648 scrollLockMask
= mask_table
[i
/ modmap
->max_keypermod
];
653 XFreeModifiermap(modmap
);
655 scrPtr
->ignoredModifierMask
= numLockMask
| scrollLockMask
| LockMask
;
658 /* initially allocate some colors */
659 WMWhiteColor(scrPtr
);
660 WMBlackColor(scrPtr
);
662 WMDarkGrayColor(scrPtr
);
664 gcv
.graphics_exposures
= False
;
666 gcv
.function
= GXxor
;
667 gcv
.foreground
= W_PIXEL(scrPtr
->white
);
668 if (gcv
.foreground
== 0)
670 scrPtr
->xorGC
= XCreateGC(display
, W_DRAWABLE(scrPtr
), GCFunction
671 | GCGraphicsExposures
| GCForeground
, &gcv
);
673 gcv
.function
= GXxor
;
674 gcv
.foreground
= W_PIXEL(scrPtr
->gray
);
675 gcv
.subwindow_mode
= IncludeInferiors
;
676 scrPtr
->ixorGC
= XCreateGC(display
, W_DRAWABLE(scrPtr
), GCFunction
677 | GCGraphicsExposures
| GCForeground
| GCSubwindowMode
, &gcv
);
679 gcv
.function
= GXcopy
;
680 scrPtr
->copyGC
= XCreateGC(display
, W_DRAWABLE(scrPtr
), GCFunction
| GCGraphicsExposures
, &gcv
);
682 scrPtr
->clipGC
= XCreateGC(display
, W_DRAWABLE(scrPtr
), GCFunction
| GCGraphicsExposures
, &gcv
);
684 stipple
= XCreateBitmapFromData(display
, W_DRAWABLE(scrPtr
), STIPPLE_BITS
, STIPPLE_WIDTH
, STIPPLE_HEIGHT
);
685 gcv
.foreground
= W_PIXEL(scrPtr
->darkGray
);
686 gcv
.background
= W_PIXEL(scrPtr
->gray
);
687 gcv
.fill_style
= FillStippled
;
688 gcv
.stipple
= stipple
;
689 scrPtr
->stippleGC
= XCreateGC(display
, W_DRAWABLE(scrPtr
),
690 GCForeground
| GCBackground
| GCStipple
691 | GCFillStyle
| GCGraphicsExposures
, &gcv
);
693 scrPtr
->drawStringGC
= XCreateGC(display
, W_DRAWABLE(scrPtr
), GCGraphicsExposures
, &gcv
);
694 scrPtr
->drawImStringGC
= XCreateGC(display
, W_DRAWABLE(scrPtr
), GCGraphicsExposures
, &gcv
);
696 /* we need a 1bpp drawable for the monoGC, so borrow this one */
697 scrPtr
->monoGC
= XCreateGC(display
, stipple
, 0, NULL
);
699 scrPtr
->stipple
= stipple
;
701 scrPtr
->antialiasedText
= WINGsConfiguration
.antialiasedText
;
703 scrPtr
->normalFont
= WMSystemFontOfSize(scrPtr
, 0);
705 scrPtr
->boldFont
= WMBoldSystemFontOfSize(scrPtr
, 0);
707 if (!scrPtr
->boldFont
)
708 scrPtr
->boldFont
= scrPtr
->normalFont
;
710 if (!scrPtr
->normalFont
) {
711 wwarning(_("could not load any fonts. Make sure your font installation"
712 " and locale settings are correct."));
717 /* create input method stuff */
720 scrPtr
->checkButtonImageOn
= makePixmap(scrPtr
, CHECK_BUTTON_ON
,
721 CHECK_BUTTON_ON_WIDTH
, CHECK_BUTTON_ON_HEIGHT
, False
);
723 scrPtr
->checkButtonImageOff
= makePixmap(scrPtr
, CHECK_BUTTON_OFF
,
724 CHECK_BUTTON_OFF_WIDTH
, CHECK_BUTTON_OFF_HEIGHT
, False
);
726 scrPtr
->radioButtonImageOn
= makePixmap(scrPtr
, RADIO_BUTTON_ON
,
727 RADIO_BUTTON_ON_WIDTH
, RADIO_BUTTON_ON_HEIGHT
, False
);
729 scrPtr
->radioButtonImageOff
= makePixmap(scrPtr
, RADIO_BUTTON_OFF
,
730 RADIO_BUTTON_OFF_WIDTH
, RADIO_BUTTON_OFF_HEIGHT
, False
);
732 scrPtr
->buttonArrow
= makePixmap(scrPtr
, BUTTON_ARROW
, BUTTON_ARROW_WIDTH
, BUTTON_ARROW_HEIGHT
, False
);
734 scrPtr
->pushedButtonArrow
= makePixmap(scrPtr
, BUTTON_ARROW2
,
735 BUTTON_ARROW2_WIDTH
, BUTTON_ARROW2_HEIGHT
, False
);
737 scrPtr
->scrollerDimple
= makePixmap(scrPtr
, SCROLLER_DIMPLE
,
738 SCROLLER_DIMPLE_WIDTH
, SCROLLER_DIMPLE_HEIGHT
, False
);
740 scrPtr
->upArrow
= makePixmap(scrPtr
, SCROLLER_ARROW_UP
,
741 SCROLLER_ARROW_UP_WIDTH
, SCROLLER_ARROW_UP_HEIGHT
, True
);
743 scrPtr
->downArrow
= makePixmap(scrPtr
, SCROLLER_ARROW_DOWN
,
744 SCROLLER_ARROW_DOWN_WIDTH
, SCROLLER_ARROW_DOWN_HEIGHT
, True
);
746 scrPtr
->leftArrow
= makePixmap(scrPtr
, SCROLLER_ARROW_LEFT
,
747 SCROLLER_ARROW_LEFT_WIDTH
, SCROLLER_ARROW_LEFT_HEIGHT
, True
);
749 scrPtr
->rightArrow
= makePixmap(scrPtr
, SCROLLER_ARROW_RIGHT
,
750 SCROLLER_ARROW_RIGHT_WIDTH
, SCROLLER_ARROW_RIGHT_HEIGHT
, True
);
752 scrPtr
->hiUpArrow
= makePixmap(scrPtr
, HI_SCROLLER_ARROW_UP
,
753 SCROLLER_ARROW_UP_WIDTH
, SCROLLER_ARROW_UP_HEIGHT
, True
);
755 scrPtr
->hiDownArrow
= makePixmap(scrPtr
, HI_SCROLLER_ARROW_DOWN
,
756 SCROLLER_ARROW_DOWN_WIDTH
, SCROLLER_ARROW_DOWN_HEIGHT
, True
);
758 scrPtr
->hiLeftArrow
= makePixmap(scrPtr
, HI_SCROLLER_ARROW_LEFT
,
759 SCROLLER_ARROW_LEFT_WIDTH
, SCROLLER_ARROW_LEFT_HEIGHT
, True
);
761 scrPtr
->hiRightArrow
= makePixmap(scrPtr
, HI_SCROLLER_ARROW_RIGHT
,
762 SCROLLER_ARROW_RIGHT_WIDTH
, SCROLLER_ARROW_RIGHT_HEIGHT
, True
);
764 scrPtr
->popUpIndicator
= makePixmap(scrPtr
, POPUP_INDICATOR
,
765 POPUP_INDICATOR_WIDTH
, POPUP_INDICATOR_HEIGHT
, True
);
767 scrPtr
->pullDownIndicator
= makePixmap(scrPtr
, PULLDOWN_INDICATOR
,
768 PULLDOWN_INDICATOR_WIDTH
, PULLDOWN_INDICATOR_HEIGHT
, True
);
770 scrPtr
->checkMark
= makePixmap(scrPtr
, CHECK_MARK
, CHECK_MARK_WIDTH
, CHECK_MARK_HEIGHT
, True
);
774 scrPtr
->defaultCursor
= XCreateFontCursor(display
, XC_left_ptr
);
776 scrPtr
->textCursor
= XCreateFontCursor(display
, XC_xterm
);
782 blank
= XCreatePixmap(display
, scrPtr
->stipple
, 1, 1, 1);
783 XSetForeground(display
, scrPtr
->monoGC
, 0);
784 XFillRectangle(display
, blank
, scrPtr
->monoGC
, 0, 0, 1, 1);
786 scrPtr
->invisibleCursor
= XCreatePixmapCursor(display
, blank
, blank
, &bla
, &bla
, 0, 0);
787 XFreePixmap(display
, blank
);
790 #ifdef HAVE_XINTERNATOMS
791 XInternAtoms(display
, atomNames
, wlengthof(atomNames
), False
, atoms
);
793 for (i
= 0; i
< wlengthof(atomNames
); i
++) {
794 atoms
[i
] = XInternAtom(display
, atomNames
[i
], False
);
799 scrPtr
->attribsAtom
= atoms
[i
++];
801 scrPtr
->deleteWindowAtom
= atoms
[i
++];
803 scrPtr
->protocolsAtom
= atoms
[i
++];
805 scrPtr
->clipboardAtom
= atoms
[i
++];
807 scrPtr
->xdndAwareAtom
= atoms
[i
++];
808 scrPtr
->xdndSelectionAtom
= atoms
[i
++];
809 scrPtr
->xdndEnterAtom
= atoms
[i
++];
810 scrPtr
->xdndLeaveAtom
= atoms
[i
++];
811 scrPtr
->xdndPositionAtom
= atoms
[i
++];
812 scrPtr
->xdndDropAtom
= atoms
[i
++];
813 scrPtr
->xdndFinishedAtom
= atoms
[i
++];
814 scrPtr
->xdndTypeListAtom
= atoms
[i
++];
815 scrPtr
->xdndActionListAtom
= atoms
[i
++];
816 scrPtr
->xdndActionDescriptionAtom
= atoms
[i
++];
817 scrPtr
->xdndStatusAtom
= atoms
[i
++];
819 scrPtr
->xdndActionCopy
= atoms
[i
++];
820 scrPtr
->xdndActionMove
= atoms
[i
++];
821 scrPtr
->xdndActionLink
= atoms
[i
++];
822 scrPtr
->xdndActionAsk
= atoms
[i
++];
823 scrPtr
->xdndActionPrivate
= atoms
[i
++];
825 scrPtr
->wmIconDragOffsetAtom
= atoms
[i
++];
827 scrPtr
->wmStateAtom
= atoms
[i
++];
829 scrPtr
->utf8String
= atoms
[i
++];
830 scrPtr
->netwmName
= atoms
[i
++];
831 scrPtr
->netwmIconName
= atoms
[i
++];
832 scrPtr
->netwmIcon
= atoms
[i
++];
834 scrPtr
->rootView
= W_CreateRootView(scrPtr
);
836 scrPtr
->balloon
= W_CreateBalloon(scrPtr
);
838 W_InitApplication(scrPtr
);
843 void WMSetWidgetDefaultFont(WMScreen
* scr
, WMFont
* font
)
845 WMReleaseFont(scr
->normalFont
);
846 scr
->normalFont
= WMRetainFont(font
);
849 void WMSetWidgetDefaultBoldFont(WMScreen
* scr
, WMFont
* font
)
851 WMReleaseFont(scr
->boldFont
);
852 scr
->boldFont
= WMRetainFont(font
);
855 void WMHangData(WMWidget
* widget
, void *data
)
857 W_VIEW(widget
)->hangedData
= data
;
860 void *WMGetHangedData(WMWidget
* widget
)
862 return W_VIEW(widget
)->hangedData
;
865 void WMDestroyWidget(WMWidget
* widget
)
867 W_UnmapView(W_VIEW(widget
));
868 W_DestroyView(W_VIEW(widget
));
871 void WMSetFocusToWidget(WMWidget
* widget
)
873 W_SetFocusOfTopLevel(W_TopLevelOfView(W_VIEW(widget
)), W_VIEW(widget
));
878 * Realizes the widget and all it's children.
881 void WMRealizeWidget(WMWidget
* w
)
883 W_RealizeView(W_VIEW(w
));
886 void WMMapWidget(WMWidget
* w
)
888 W_MapView(W_VIEW(w
));
891 void WMReparentWidget(WMWidget
* w
, WMWidget
* newParent
, int x
, int y
)
893 W_ReparentView(W_VIEW(w
), W_VIEW(newParent
), x
, y
);
896 static void makeChildrenAutomap(W_View
* view
, int flag
)
898 view
= view
->childrenList
;
901 view
->flags
.mapWhenRealized
= flag
;
902 makeChildrenAutomap(view
, flag
);
904 view
= view
->nextSister
;
908 void WMMapSubwidgets(WMWidget
* w
)
910 /* make sure that subwidgets created after the parent was realized
912 if (!W_VIEW(w
)->flags
.realized
) {
913 makeChildrenAutomap(W_VIEW(w
), True
);
915 W_MapSubviews(W_VIEW(w
));
919 void WMUnmapSubwidgets(WMWidget
* w
)
921 if (!W_VIEW(w
)->flags
.realized
) {
922 makeChildrenAutomap(W_VIEW(w
), False
);
924 W_UnmapSubviews(W_VIEW(w
));
928 void WMUnmapWidget(WMWidget
* w
)
930 W_UnmapView(W_VIEW(w
));
933 Bool
WMWidgetIsMapped(WMWidget
* w
)
935 return W_VIEW(w
)->flags
.mapped
;
938 void WMSetWidgetBackgroundColor(WMWidget
* w
, WMColor
* color
)
940 W_SetViewBackgroundColor(W_VIEW(w
), color
);
941 if (W_VIEW(w
)->flags
.mapped
)
942 WMRedisplayWidget(w
);
945 WMColor
*WMGetWidgetBackgroundColor(WMWidget
* w
)
947 return W_VIEW(w
)->backColor
;
950 void WMSetWidgetBackgroundPixmap(WMWidget
*w
, WMPixmap
*pix
)
955 W_SetViewBackgroundPixmap(W_VIEW(w
), pix
);
956 if (W_VIEW(w
)->flags
.mapped
)
957 WMRedisplayWidget(w
);
960 WMPixmap
*WMGetWidgetBackgroundPixmap(WMWidget
*w
)
962 return W_VIEW(w
)->backImage
;
965 void WMRaiseWidget(WMWidget
* w
)
967 W_RaiseView(W_VIEW(w
));
970 void WMLowerWidget(WMWidget
* w
)
972 W_LowerView(W_VIEW(w
));
975 void WMMoveWidget(WMWidget
* w
, int x
, int y
)
977 W_MoveView(W_VIEW(w
), x
, y
);
980 void WMResizeWidget(WMWidget
* w
, unsigned int width
, unsigned int height
)
982 W_ResizeView(W_VIEW(w
), width
, height
);
985 W_Class
W_RegisterUserWidget(void)
989 return userWidgetCount
+ WC_UserWidget
- 1;
992 RContext
*WMScreenRContext(WMScreen
* scr
)
994 return scr
->rcontext
;
997 unsigned int WMWidgetWidth(WMWidget
* w
)
999 return W_VIEW(w
)->size
.width
;
1002 unsigned int WMWidgetHeight(WMWidget
* w
)
1004 return W_VIEW(w
)->size
.height
;
1007 Window
WMWidgetXID(WMWidget
* w
)
1009 return W_VIEW(w
)->window
;
1012 WMScreen
*WMWidgetScreen(WMWidget
* w
)
1014 return W_VIEW(w
)->screen
;
1017 void WMScreenMainLoop(WMScreen
* scr
)
1022 WMNextEvent(scr
->display
, &event
);
1023 WMHandleEvent(&event
);
1027 void WMBreakModalLoop(WMScreen
* scr
)
1032 void WMRunModalLoop(WMScreen
* scr
, WMView
* view
)
1034 /* why is scr passed if is determined from the view? */
1035 /*WMScreen *scr = view->screen; */
1036 int oldModalLoop
= scr
->modalLoop
;
1037 WMView
*oldModalView
= scr
->modalView
;
1039 scr
->modalView
= view
;
1042 while (scr
->modalLoop
) {
1045 WMNextEvent(scr
->display
, &event
);
1046 WMHandleEvent(&event
);
1049 scr
->modalView
= oldModalView
;
1050 scr
->modalLoop
= oldModalLoop
;
1053 Display
*WMScreenDisplay(WMScreen
* scr
)
1055 return scr
->display
;
1058 int WMScreenDepth(WMScreen
* scr
)
1063 unsigned int WMScreenWidth(WMScreen
* scr
)
1065 return scr
->rootView
->size
.width
;
1068 unsigned int WMScreenHeight(WMScreen
* scr
)
1070 return scr
->rootView
->size
.height
;
1073 void WMRedisplayWidget(WMWidget
* w
)
1075 W_RedisplayView(W_VIEW(w
));