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
[] = {
33 #define CHECK_BUTTON_OFF_WIDTH 16
34 #define CHECK_BUTTON_OFF_HEIGHT 16
36 static char *CHECK_BUTTON_OFF
[] = {
54 #define RADIO_BUTTON_ON_WIDTH 15
55 #define RADIO_BUTTON_ON_HEIGHT 15
56 static char *RADIO_BUTTON_ON
[] = {
74 #define RADIO_BUTTON_OFF_WIDTH 15
75 #define RADIO_BUTTON_OFF_HEIGHT 15
76 static char *RADIO_BUTTON_OFF
[] = {
95 static char *BUTTON_ARROW
[] = {
100 ".#............ ...",
101 "#............. ...",
102 ".#............ ...",
104 "...#. ............",
108 #define BUTTON_ARROW_WIDTH 18
109 #define BUTTON_ARROW_HEIGHT 10
112 static char *BUTTON_ARROW2
[] = {
125 #define BUTTON_ARROW2_WIDTH 18
126 #define BUTTON_ARROW2_HEIGHT 10
129 static char *SCROLLER_DIMPLE
[] = {
138 #define SCROLLER_DIMPLE_WIDTH 6
139 #define SCROLLER_DIMPLE_HEIGHT 6
142 static char *SCROLLER_ARROW_UP
[] = {
154 static char *HI_SCROLLER_ARROW_UP
[] = {
166 #define SCROLLER_ARROW_UP_WIDTH 9
167 #define SCROLLER_ARROW_UP_HEIGHT 9
170 static char *SCROLLER_ARROW_DOWN
[] = {
182 static char *HI_SCROLLER_ARROW_DOWN
[] = {
194 #define SCROLLER_ARROW_DOWN_WIDTH 9
195 #define SCROLLER_ARROW_DOWN_HEIGHT 9
199 static char *SCROLLER_ARROW_LEFT
[] = {
211 static char *HI_SCROLLER_ARROW_LEFT
[] = {
223 #define SCROLLER_ARROW_LEFT_WIDTH 9
224 #define SCROLLER_ARROW_LEFT_HEIGHT 9
227 static char *SCROLLER_ARROW_RIGHT
[] = {
239 static char *HI_SCROLLER_ARROW_RIGHT
[] = {
251 #define SCROLLER_ARROW_RIGHT_WIDTH 9
252 #define SCROLLER_ARROW_RIGHT_HEIGHT 9
255 static char *POPUP_INDICATOR
[] = {
266 #define POPUP_INDICATOR_WIDTH 11
267 #define POPUP_INDICATOR_HEIGHT 8
271 static char *PULLDOWN_INDICATOR
[] = {
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
[] = {
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 ******/
319 renderPixmap(W_Screen
*screen
, Pixmap d
, Pixmap mask
, char **data
,
320 int width
, int height
)
323 GC whiteGC
= WMColorGC(screen
->white
);
324 GC blackGC
= WMColorGC(screen
->black
);
325 GC lightGC
= WMColorGC(screen
->gray
);
326 GC darkGC
= WMColorGC(screen
->darkGray
);
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
]) {
337 XDrawPoint(screen
->display
, d
, whiteGC
, x
, y
);
342 XDrawPoint(screen
->display
, mask
, screen
->monoGC
, x
, y
);
346 XDrawPoint(screen
->display
, d
, lightGC
, x
, y
);
351 XDrawPoint(screen
->display
, d
, darkGC
, x
, y
);
357 XDrawPoint(screen
->display
, d
, blackGC
, x
, y
);
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
,
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
,
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"
395 loadPixmaps(WMScreen
*scr
)
409 image
= RLoadImage(scr
->rcontext
, T_WINGS_IMAGES_FILE
, 0);
411 image
= RLoadImage(scr
->rcontext
, X_WINGS_IMAGES_FILE
, 0);
413 wwarning("WINGs: could not load widget images file: %s",
414 RMessageForError(RErrorCode
));
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);
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);
430 tmp
= RGetSubImage(image
, 104, 0, 24, 24);
431 RCombineImageWithColor(tmp
, &white
);
432 scr
->trashcanIcon
= WMCreatePixmapFromRImage(scr
, tmp
, 128);
434 tmp
= RGetSubImage(image
, 104, 0, 24, 24);
435 RCombineImageWithColor(tmp
, &white
);
436 scr
->altTrashcanIcon
= WMCreatePixmapFromRImage(scr
, tmp
, 128);
439 tmp
= RGetSubImage(image
, 104, 24, 24, 24);
440 RCombineImageWithColor(tmp
, &white
);
441 scr
->createDirIcon
= WMCreatePixmapFromRImage(scr
, tmp
, 128);
443 tmp
= RGetSubImage(image
, 104, 24, 24, 24);
444 RCombineImageWithColor(tmp
, &white
);
445 scr
->altCreateDirIcon
= WMCreatePixmapFromRImage(scr
, tmp
, 128);
448 tmp
= RGetSubImage(image
, 24, 80, 24, 24);
449 RCombineImageWithColor(tmp
, &white
);
450 scr
->disketteIcon
= WMCreatePixmapFromRImage(scr
, tmp
, 128);
452 tmp
= RGetSubImage(image
, 24, 80, 24, 24);
453 RCombineImageWithColor(tmp
, &white
);
454 scr
->altDisketteIcon
= WMCreatePixmapFromRImage(scr
, tmp
, 128);
457 tmp
= RGetSubImage(image
, 0, 80, 24, 24);
458 RCombineImageWithColor(tmp
, &white
);
459 scr
->unmountIcon
= WMCreatePixmapFromRImage(scr
, tmp
, 128);
461 tmp
= RGetSubImage(image
, 0, 80, 24, 24);
462 RCombineImageWithColor(tmp
, &white
);
463 scr
->altUnmountIcon
= WMCreatePixmapFromRImage(scr
, tmp
, 128);
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);
472 tmp = RGetSubImage(image, 24, 0, 40, 32);
473 RCombineImageWithColor(tmp, &white);
474 scr->altMagnifyIcon = WMCreatePixmapFromRImage(scr, tmp, 128);
477 /* ColorWheel Icon for ColorPanel */
478 tmp
= RGetSubImage(image
, 0, 25, 24, 24);
479 scr
->wheelIcon
= WMCreatePixmapFromRImage(scr
, tmp
, 128);
481 /* GrayScale Icon for ColorPanel */
482 tmp
= RGetSubImage(image
, 65, 0, 40, 24);
483 scr
->grayIcon
= WMCreatePixmapFromRImage(scr
, tmp
, 128);
485 /* RGB Icon for ColorPanel */
486 tmp
= RGetSubImage(image
, 25, 33, 40, 24);
487 scr
->rgbIcon
= WMCreatePixmapFromRImage(scr
, tmp
, 128);
489 /* CMYK Icon for ColorPanel */
490 tmp
= RGetSubImage(image
, 65, 25, 40, 24);
491 scr
->cmykIcon
= WMCreatePixmapFromRImage(scr
, tmp
, 128);
493 /* HSB Icon for ColorPanel */
494 tmp
= RGetSubImage(image
, 0, 57, 40, 24);
495 scr
->hsbIcon
= WMCreatePixmapFromRImage(scr
, tmp
, 128);
497 /* CustomColorPalette Icon for ColorPanel */
498 tmp
= RGetSubImage(image
, 81, 57, 40, 24);
499 scr
->customPaletteIcon
= WMCreatePixmapFromRImage(scr
, tmp
, 128);
501 /* ColorList Icon for ColorPanel */
502 tmp
= RGetSubImage(image
, 41, 57, 40, 24);
503 scr
->colorListIcon
= WMCreatePixmapFromRImage(scr
, tmp
, 128);
506 RDestroyImage(image
);
509 scr
->defaultObjectIcon
=
510 WMCreatePixmapFromFile(scr
, T_DEFAULT_OBJECT_ICON_FILE
);
511 if (!scr
->defaultObjectIcon
) {
512 scr
->defaultObjectIcon
=
513 WMCreatePixmapFromFile(scr
, X_DEFAULT_OBJECT_ICON_FILE
);
515 if (!scr
->defaultObjectIcon
) {
516 wwarning("WINGs: could not load default icon file");
526 WMCreateSimpleApplicationScreen(Display
*display
)
530 scr
= WMCreateScreen(display
, DefaultScreen(display
));
532 scr
->aflags
.hasAppIcon
= 0;
533 scr
->aflags
.simpleApplication
= 1;
541 WMCreateScreen(Display
*display
, int screen
)
543 return WMCreateScreenWithRContext(display
, screen
,
544 RCreateContext(display
, screen
, NULL
));
549 WMCreateScreenWithRContext(Display
*display
, int screen
, RContext
*context
)
554 static int initialized
= 0;
560 W_ReadConfigurations();
562 assert(W_ApplicationInitialized());
565 scrPtr
= malloc(sizeof(W_Screen
));
568 memset(scrPtr
, 0, sizeof(W_Screen
));
570 scrPtr
->aflags
.hasAppIcon
= 1;
572 scrPtr
->display
= display
;
573 scrPtr
->screen
= screen
;
574 scrPtr
->rcontext
= context
;
576 scrPtr
->depth
= context
->depth
;
578 scrPtr
->visual
= context
->visual
;
579 scrPtr
->lastEventTime
= 0;
581 scrPtr
->colormap
= context
->cmap
;
583 scrPtr
->rootWin
= RootWindow(display
, screen
);
585 scrPtr
->fontCache
= WMCreateHashTable(WMStringPointerHashCallbacks
);
587 /* initially allocate some colors */
588 WMWhiteColor(scrPtr
);
589 WMBlackColor(scrPtr
);
591 WMDarkGrayColor(scrPtr
);
593 gcv
.graphics_exposures
= False
;
595 gcv
.function
= GXxor
;
596 gcv
.foreground
= W_PIXEL(scrPtr
->white
);
597 if (gcv
.foreground
== 0) gcv
.foreground
= 1;
598 scrPtr
->xorGC
= XCreateGC(display
, W_DRAWABLE(scrPtr
), GCFunction
599 |GCGraphicsExposures
|GCForeground
, &gcv
);
601 gcv
.function
= GXxor
;
602 gcv
.foreground
= W_PIXEL(scrPtr
->gray
);
603 gcv
.subwindow_mode
= IncludeInferiors
;
604 scrPtr
->ixorGC
= XCreateGC(display
, W_DRAWABLE(scrPtr
), GCFunction
605 |GCGraphicsExposures
|GCForeground
606 |GCSubwindowMode
, &gcv
);
608 gcv
.function
= GXcopy
;
609 scrPtr
->copyGC
= XCreateGC(display
, W_DRAWABLE(scrPtr
), GCFunction
610 |GCGraphicsExposures
, &gcv
);
612 scrPtr
->clipGC
= XCreateGC(display
, W_DRAWABLE(scrPtr
), GCFunction
613 |GCGraphicsExposures
, &gcv
);
616 stipple
= XCreateBitmapFromData(display
, W_DRAWABLE(scrPtr
),
617 STIPPLE_BITS
, STIPPLE_WIDTH
, STIPPLE_HEIGHT
);
618 gcv
.foreground
= W_PIXEL(scrPtr
->darkGray
);
619 gcv
.background
= W_PIXEL(scrPtr
->gray
);
620 gcv
.fill_style
= FillStippled
;
621 gcv
.stipple
= stipple
;
622 scrPtr
->stippleGC
= XCreateGC(display
, W_DRAWABLE(scrPtr
),
623 GCForeground
|GCBackground
|GCStipple
624 |GCFillStyle
|GCGraphicsExposures
, &gcv
);
626 gcv
.foreground
= W_PIXEL(scrPtr
->black
);
627 gcv
.background
= W_PIXEL(scrPtr
->white
);
628 scrPtr
->textFieldGC
= XCreateGC(display
, W_DRAWABLE(scrPtr
),
629 GCForeground
|GCBackground
, &gcv
);
631 /* we need a 1bpp drawable for the monoGC, so borrow this one */
632 scrPtr
->monoGC
= XCreateGC(display
, stipple
, 0, NULL
);
634 scrPtr
->stipple
= stipple
;
636 scrPtr
->useMultiByte
= WINGsConfiguration
.useMultiByte
;
638 scrPtr
->normalFont
= WMSystemFontOfSize(scrPtr
, 12);
640 scrPtr
->boldFont
= WMBoldSystemFontOfSize(scrPtr
, 12);
642 if (!scrPtr
->boldFont
)
643 scrPtr
->boldFont
= scrPtr
->normalFont
;
645 if (!scrPtr
->normalFont
) {
646 wwarning("could not load any fonts. Make sure your font installation"
647 "and locale settings are correct.");
652 scrPtr
->checkButtonImageOn
= makePixmap(scrPtr
, CHECK_BUTTON_ON
,
653 CHECK_BUTTON_ON_WIDTH
,
654 CHECK_BUTTON_ON_HEIGHT
, False
);
656 scrPtr
->checkButtonImageOff
= makePixmap(scrPtr
, CHECK_BUTTON_OFF
,
657 CHECK_BUTTON_OFF_WIDTH
,
658 CHECK_BUTTON_OFF_HEIGHT
, False
);
660 scrPtr
->radioButtonImageOn
= makePixmap(scrPtr
, RADIO_BUTTON_ON
,
661 RADIO_BUTTON_ON_WIDTH
,
662 RADIO_BUTTON_ON_HEIGHT
, False
);
664 scrPtr
->radioButtonImageOff
= makePixmap(scrPtr
, RADIO_BUTTON_OFF
,
665 RADIO_BUTTON_OFF_WIDTH
,
666 RADIO_BUTTON_OFF_HEIGHT
, False
);
668 scrPtr
->buttonArrow
= makePixmap(scrPtr
, BUTTON_ARROW
,
669 BUTTON_ARROW_WIDTH
, BUTTON_ARROW_HEIGHT
,
672 scrPtr
->pushedButtonArrow
= makePixmap(scrPtr
, BUTTON_ARROW2
,
673 BUTTON_ARROW2_WIDTH
, BUTTON_ARROW2_HEIGHT
,
677 scrPtr
->scrollerDimple
= makePixmap(scrPtr
, SCROLLER_DIMPLE
,
678 SCROLLER_DIMPLE_WIDTH
,
679 SCROLLER_DIMPLE_HEIGHT
, False
);
682 scrPtr
->upArrow
= makePixmap(scrPtr
, SCROLLER_ARROW_UP
,
683 SCROLLER_ARROW_UP_WIDTH
,
684 SCROLLER_ARROW_UP_HEIGHT
, True
);
686 scrPtr
->downArrow
= makePixmap(scrPtr
, SCROLLER_ARROW_DOWN
,
687 SCROLLER_ARROW_DOWN_WIDTH
,
688 SCROLLER_ARROW_DOWN_HEIGHT
, True
);
690 scrPtr
->leftArrow
= makePixmap(scrPtr
, SCROLLER_ARROW_LEFT
,
691 SCROLLER_ARROW_LEFT_WIDTH
,
692 SCROLLER_ARROW_LEFT_HEIGHT
, True
);
694 scrPtr
->rightArrow
= makePixmap(scrPtr
, SCROLLER_ARROW_RIGHT
,
695 SCROLLER_ARROW_RIGHT_WIDTH
,
696 SCROLLER_ARROW_RIGHT_HEIGHT
, True
);
698 scrPtr
->hiUpArrow
= makePixmap(scrPtr
, HI_SCROLLER_ARROW_UP
,
699 SCROLLER_ARROW_UP_WIDTH
,
700 SCROLLER_ARROW_UP_HEIGHT
, True
);
702 scrPtr
->hiDownArrow
= makePixmap(scrPtr
, HI_SCROLLER_ARROW_DOWN
,
703 SCROLLER_ARROW_DOWN_WIDTH
,
704 SCROLLER_ARROW_DOWN_HEIGHT
, True
);
706 scrPtr
->hiLeftArrow
= makePixmap(scrPtr
, HI_SCROLLER_ARROW_LEFT
,
707 SCROLLER_ARROW_LEFT_WIDTH
,
708 SCROLLER_ARROW_LEFT_HEIGHT
, True
);
710 scrPtr
->hiRightArrow
= makePixmap(scrPtr
, HI_SCROLLER_ARROW_RIGHT
,
711 SCROLLER_ARROW_RIGHT_WIDTH
,
712 SCROLLER_ARROW_RIGHT_HEIGHT
, True
);
714 scrPtr
->popUpIndicator
= makePixmap(scrPtr
, POPUP_INDICATOR
,
715 POPUP_INDICATOR_WIDTH
,
716 POPUP_INDICATOR_HEIGHT
, True
);
718 scrPtr
->pullDownIndicator
= makePixmap(scrPtr
, PULLDOWN_INDICATOR
,
719 PULLDOWN_INDICATOR_WIDTH
,
720 PULLDOWN_INDICATOR_HEIGHT
, True
);
722 scrPtr
->checkMark
= makePixmap(scrPtr
, CHECK_MARK
,
724 CHECK_MARK_HEIGHT
, True
);
728 scrPtr
->defaultCursor
= XCreateFontCursor(display
, XC_left_ptr
);
730 scrPtr
->textCursor
= XCreateFontCursor(display
, XC_xterm
);
736 blank
= XCreatePixmap(display
, scrPtr
->stipple
, 1, 1, 1);
737 XSetForeground(display
, scrPtr
->monoGC
, 0);
738 XFillRectangle(display
, blank
, scrPtr
->monoGC
, 0, 0, 1, 1);
740 scrPtr
->invisibleCursor
= XCreatePixmapCursor(display
, blank
, blank
,
742 XFreePixmap(display
, blank
);
745 scrPtr
->internalMessage
= XInternAtom(display
, "_WINGS_MESSAGE", False
);
747 scrPtr
->attribsAtom
= XInternAtom(display
, "_GNUSTEP_WM_ATTR", False
);
749 scrPtr
->deleteWindowAtom
= XInternAtom(display
, "WM_DELETE_WINDOW", False
);
751 scrPtr
->protocolsAtom
= XInternAtom(display
, "WM_PROTOCOLS", False
);
753 scrPtr
->clipboardAtom
= XInternAtom(display
, "CLIPBOARD", False
);
755 scrPtr
->rootView
= W_CreateRootView(scrPtr
);
758 scrPtr
->balloon
= W_CreateBalloon(scrPtr
);
761 W_InitApplication(scrPtr
);
768 WMHangData(WMWidget
*widget
, void *data
)
770 W_VIEW(widget
)->hangedData
= data
;
775 WMGetHangedData(WMWidget
*widget
)
777 return W_VIEW(widget
)->hangedData
;
783 WMDestroyWidget(WMWidget
*widget
)
785 W_DestroyView(W_VIEW(widget
));
790 WMSetFocusToWidget(WMWidget
*widget
)
792 W_SetFocusOfTopLevel(W_TopLevelOfView(W_VIEW(widget
)), W_VIEW(widget
));
798 * Realizes the widget and all it's children.
802 WMRealizeWidget(WMWidget
*w
)
804 W_RealizeView(W_VIEW(w
));
808 WMMapWidget(WMWidget
*w
)
810 W_MapView(W_VIEW(w
));
815 makeChildrenAutomap(W_View
*view
, int flag
)
817 view
= view
->childrenList
;
820 view
->flags
.mapWhenRealized
= flag
;
821 makeChildrenAutomap(view
, flag
);
823 view
= view
->nextSister
;
829 WMMapSubwidgets(WMWidget
*w
)
831 /* make sure that subwidgets created after the parent was realized
833 if (!W_VIEW(w
)->flags
.realized
) {
834 makeChildrenAutomap(W_VIEW(w
), True
);
836 W_MapSubviews(W_VIEW(w
));
842 WMUnmapSubwidgets(WMWidget
*w
)
844 if (!W_VIEW(w
)->flags
.realized
) {
845 makeChildrenAutomap(W_VIEW(w
), False
);
847 W_UnmapSubviews(W_VIEW(w
));
854 WMUnmapWidget(WMWidget
*w
)
856 W_UnmapView(W_VIEW(w
));
861 WMSetWidgetBackgroundColor(WMWidget
*w
, WMColor
*color
)
863 W_SetViewBackgroundColor(W_VIEW(w
), color
);
868 WMMoveWidget(WMWidget
*w
, int x
, int y
)
870 W_MoveView(W_VIEW(w
), x
, y
);
875 WMResizeWidget(WMWidget
*w
, unsigned int width
, unsigned int height
)
877 W_ResizeView(W_VIEW(w
), width
, height
);
883 W_RegisterUserWidget(void)
887 return userWidgetCount
+ WC_UserWidget
- 1;
893 WMScreenRContext(WMScreen
*scr
)
895 return scr
->rcontext
;
901 WMWidgetWidth(WMWidget
*w
)
903 return W_VIEW(w
)->size
.width
;
908 WMWidgetHeight(WMWidget
*w
)
910 return W_VIEW(w
)->size
.height
;
915 WMWidgetXID(WMWidget
*w
)
917 return W_VIEW(w
)->window
;
922 WMWidgetScreen(WMWidget
*w
)
924 return W_VIEW(w
)->screen
;
930 WMScreenMainLoop(WMScreen
*scr
)
935 WMNextEvent(scr
->display
, &event
);
936 WMHandleEvent(&event
);
943 WMScreenDisplay(WMScreen
*scr
)
950 WMScreenDepth(WMScreen
*scr
)
957 WMRedisplayWidget(WMWidget
*w
)
959 W_RedisplayView(W_VIEW(w
));