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
, 105, 0, 24, 24);
431 RCombineImageWithColor(tmp
, &white
);
432 scr
->trashcanIcon
= WMCreatePixmapFromRImage(scr
, tmp
, 128);
434 tmp
= RGetSubImage(image
, 105, 0, 24, 24);
435 RCombineImageWithColor(tmp
, &white
);
436 scr
->altTrashcanIcon
= WMCreatePixmapFromRImage(scr
, tmp
, 128);
440 tmp
= RGetSubImage(image
, 0, 0, 24, 24);
441 RCombineImageWithColor(tmp
, &white
);
442 scr
->altHomeIcon
= WMCreatePixmapFromRImage(scr
, tmp
, 128);
445 /* Magnifying Glass Icon for ColorPanel */
446 tmp
= RGetSubImage(image
, 24, 0, 40, 32);
447 RCombineImageWithColor(tmp
, &gray
);
448 scr
->magnifyIcon
= WMCreatePixmapFromRImage(scr
, tmp
, 128);
451 tmp = RGetSubImage(image, 24, 0, 40, 32);
452 RCombineImageWithColor(tmp, &white);
453 scr->altMagnifyIcon = WMCreatePixmapFromRImage(scr, tmp, 128);
456 /* ColorWheel Icon for ColorPanel */
457 tmp
= RGetSubImage(image
, 0, 25, 24, 24);
458 scr
->wheelIcon
= WMCreatePixmapFromRImage(scr
, tmp
, 128);
460 /* GrayScale Icon for ColorPanel */
461 tmp
= RGetSubImage(image
, 65, 0, 40, 24);
462 scr
->grayIcon
= WMCreatePixmapFromRImage(scr
, tmp
, 128);
464 /* RGB Icon for ColorPanel */
465 tmp
= RGetSubImage(image
, 25, 33, 40, 24);
466 scr
->rgbIcon
= WMCreatePixmapFromRImage(scr
, tmp
, 128);
468 /* CMYK Icon for ColorPanel */
469 tmp
= RGetSubImage(image
, 65, 25, 40, 24);
470 scr
->cmykIcon
= WMCreatePixmapFromRImage(scr
, tmp
, 128);
472 /* HSB Icon for ColorPanel */
473 tmp
= RGetSubImage(image
, 0, 57, 40, 24);
474 scr
->hsbIcon
= WMCreatePixmapFromRImage(scr
, tmp
, 128);
476 /* CustomColorPalette Icon for ColorPanel */
477 tmp
= RGetSubImage(image
, 81, 57, 40, 24);
478 scr
->customPaletteIcon
= WMCreatePixmapFromRImage(scr
, tmp
, 128);
480 /* ColorList Icon for ColorPanel */
481 tmp
= RGetSubImage(image
, 41, 57, 40, 24);
482 scr
->colorListIcon
= WMCreatePixmapFromRImage(scr
, tmp
, 128);
485 RDestroyImage(image
);
488 scr
->defaultObjectIcon
=
489 WMCreatePixmapFromFile(scr
, T_DEFAULT_OBJECT_ICON_FILE
);
490 if (!scr
->defaultObjectIcon
) {
491 scr
->defaultObjectIcon
=
492 WMCreatePixmapFromFile(scr
, X_DEFAULT_OBJECT_ICON_FILE
);
494 if (!scr
->defaultObjectIcon
) {
495 wwarning("WINGs: could not load default icon file");
505 WMCreateSimpleApplicationScreen(Display
*display
)
509 scr
= WMCreateScreen(display
, DefaultScreen(display
));
511 scr
->aflags
.hasAppIcon
= 0;
512 scr
->aflags
.simpleApplication
= 1;
520 WMCreateScreen(Display
*display
, int screen
)
522 return WMCreateScreenWithRContext(display
, screen
,
523 RCreateContext(display
, screen
, NULL
));
528 WMCreateScreenWithRContext(Display
*display
, int screen
, RContext
*context
)
533 static int initialized
= 0;
539 W_ReadConfigurations();
541 assert(W_ApplicationInitialized());
544 scrPtr
= malloc(sizeof(W_Screen
));
547 memset(scrPtr
, 0, sizeof(W_Screen
));
549 scrPtr
->aflags
.hasAppIcon
= 1;
551 scrPtr
->display
= display
;
552 scrPtr
->screen
= screen
;
553 scrPtr
->rcontext
= context
;
555 scrPtr
->depth
= context
->depth
;
557 scrPtr
->visual
= context
->visual
;
558 scrPtr
->lastEventTime
= 0;
560 scrPtr
->colormap
= context
->cmap
;
562 scrPtr
->rootWin
= RootWindow(display
, screen
);
564 scrPtr
->fontCache
= WMCreateHashTable(WMStringPointerHashCallbacks
);
566 /* initially allocate some colors */
567 WMWhiteColor(scrPtr
);
568 WMBlackColor(scrPtr
);
570 WMDarkGrayColor(scrPtr
);
572 gcv
.graphics_exposures
= False
;
574 gcv
.function
= GXxor
;
575 gcv
.foreground
= W_PIXEL(scrPtr
->white
);
576 if (gcv
.foreground
== 0) gcv
.foreground
= 1;
577 scrPtr
->xorGC
= XCreateGC(display
, W_DRAWABLE(scrPtr
), GCFunction
578 |GCGraphicsExposures
|GCForeground
, &gcv
);
580 gcv
.function
= GXxor
;
581 gcv
.foreground
= W_PIXEL(scrPtr
->gray
);
582 gcv
.subwindow_mode
= IncludeInferiors
;
583 scrPtr
->ixorGC
= XCreateGC(display
, W_DRAWABLE(scrPtr
), GCFunction
584 |GCGraphicsExposures
|GCForeground
585 |GCSubwindowMode
, &gcv
);
587 gcv
.function
= GXcopy
;
588 scrPtr
->copyGC
= XCreateGC(display
, W_DRAWABLE(scrPtr
), GCFunction
589 |GCGraphicsExposures
, &gcv
);
591 scrPtr
->clipGC
= XCreateGC(display
, W_DRAWABLE(scrPtr
), GCFunction
592 |GCGraphicsExposures
, &gcv
);
595 stipple
= XCreateBitmapFromData(display
, W_DRAWABLE(scrPtr
),
596 STIPPLE_BITS
, STIPPLE_WIDTH
, STIPPLE_HEIGHT
);
597 gcv
.foreground
= W_PIXEL(scrPtr
->darkGray
);
598 gcv
.background
= W_PIXEL(scrPtr
->gray
);
599 gcv
.fill_style
= FillStippled
;
600 gcv
.stipple
= stipple
;
601 scrPtr
->stippleGC
= XCreateGC(display
, W_DRAWABLE(scrPtr
),
602 GCForeground
|GCBackground
|GCStipple
603 |GCFillStyle
|GCGraphicsExposures
, &gcv
);
605 gcv
.foreground
= W_PIXEL(scrPtr
->black
);
606 gcv
.background
= W_PIXEL(scrPtr
->white
);
607 scrPtr
->textFieldGC
= XCreateGC(display
, W_DRAWABLE(scrPtr
),
608 GCForeground
|GCBackground
, &gcv
);
610 /* we need a 1bpp drawable for the monoGC, so borrow this one */
611 scrPtr
->monoGC
= XCreateGC(display
, stipple
, 0, NULL
);
613 scrPtr
->stipple
= stipple
;
615 scrPtr
->useMultiByte
= WINGsConfiguration
.useMultiByte
;
617 scrPtr
->normalFont
= WMSystemFontOfSize(scrPtr
, 12);
619 scrPtr
->boldFont
= WMBoldSystemFontOfSize(scrPtr
, 12);
621 if (!scrPtr
->boldFont
)
622 scrPtr
->boldFont
= scrPtr
->normalFont
;
624 if (!scrPtr
->normalFont
) {
625 wwarning("could not load any fonts. Make sure your font installation"
626 "and locale settings are correct.");
631 scrPtr
->checkButtonImageOn
= makePixmap(scrPtr
, CHECK_BUTTON_ON
,
632 CHECK_BUTTON_ON_WIDTH
,
633 CHECK_BUTTON_ON_HEIGHT
, False
);
635 scrPtr
->checkButtonImageOff
= makePixmap(scrPtr
, CHECK_BUTTON_OFF
,
636 CHECK_BUTTON_OFF_WIDTH
,
637 CHECK_BUTTON_OFF_HEIGHT
, False
);
639 scrPtr
->radioButtonImageOn
= makePixmap(scrPtr
, RADIO_BUTTON_ON
,
640 RADIO_BUTTON_ON_WIDTH
,
641 RADIO_BUTTON_ON_HEIGHT
, False
);
643 scrPtr
->radioButtonImageOff
= makePixmap(scrPtr
, RADIO_BUTTON_OFF
,
644 RADIO_BUTTON_OFF_WIDTH
,
645 RADIO_BUTTON_OFF_HEIGHT
, False
);
647 scrPtr
->buttonArrow
= makePixmap(scrPtr
, BUTTON_ARROW
,
648 BUTTON_ARROW_WIDTH
, BUTTON_ARROW_HEIGHT
,
651 scrPtr
->pushedButtonArrow
= makePixmap(scrPtr
, BUTTON_ARROW2
,
652 BUTTON_ARROW2_WIDTH
, BUTTON_ARROW2_HEIGHT
,
656 scrPtr
->scrollerDimple
= makePixmap(scrPtr
, SCROLLER_DIMPLE
,
657 SCROLLER_DIMPLE_WIDTH
,
658 SCROLLER_DIMPLE_HEIGHT
, False
);
661 scrPtr
->upArrow
= makePixmap(scrPtr
, SCROLLER_ARROW_UP
,
662 SCROLLER_ARROW_UP_WIDTH
,
663 SCROLLER_ARROW_UP_HEIGHT
, True
);
665 scrPtr
->downArrow
= makePixmap(scrPtr
, SCROLLER_ARROW_DOWN
,
666 SCROLLER_ARROW_DOWN_WIDTH
,
667 SCROLLER_ARROW_DOWN_HEIGHT
, True
);
669 scrPtr
->leftArrow
= makePixmap(scrPtr
, SCROLLER_ARROW_LEFT
,
670 SCROLLER_ARROW_LEFT_WIDTH
,
671 SCROLLER_ARROW_LEFT_HEIGHT
, True
);
673 scrPtr
->rightArrow
= makePixmap(scrPtr
, SCROLLER_ARROW_RIGHT
,
674 SCROLLER_ARROW_RIGHT_WIDTH
,
675 SCROLLER_ARROW_RIGHT_HEIGHT
, True
);
677 scrPtr
->hiUpArrow
= makePixmap(scrPtr
, HI_SCROLLER_ARROW_UP
,
678 SCROLLER_ARROW_UP_WIDTH
,
679 SCROLLER_ARROW_UP_HEIGHT
, True
);
681 scrPtr
->hiDownArrow
= makePixmap(scrPtr
, HI_SCROLLER_ARROW_DOWN
,
682 SCROLLER_ARROW_DOWN_WIDTH
,
683 SCROLLER_ARROW_DOWN_HEIGHT
, True
);
685 scrPtr
->hiLeftArrow
= makePixmap(scrPtr
, HI_SCROLLER_ARROW_LEFT
,
686 SCROLLER_ARROW_LEFT_WIDTH
,
687 SCROLLER_ARROW_LEFT_HEIGHT
, True
);
689 scrPtr
->hiRightArrow
= makePixmap(scrPtr
, HI_SCROLLER_ARROW_RIGHT
,
690 SCROLLER_ARROW_RIGHT_WIDTH
,
691 SCROLLER_ARROW_RIGHT_HEIGHT
, True
);
693 scrPtr
->popUpIndicator
= makePixmap(scrPtr
, POPUP_INDICATOR
,
694 POPUP_INDICATOR_WIDTH
,
695 POPUP_INDICATOR_HEIGHT
, True
);
697 scrPtr
->pullDownIndicator
= makePixmap(scrPtr
, PULLDOWN_INDICATOR
,
698 PULLDOWN_INDICATOR_WIDTH
,
699 PULLDOWN_INDICATOR_HEIGHT
, True
);
701 scrPtr
->checkMark
= makePixmap(scrPtr
, CHECK_MARK
,
703 CHECK_MARK_HEIGHT
, True
);
707 scrPtr
->defaultCursor
= XCreateFontCursor(display
, XC_left_ptr
);
709 scrPtr
->textCursor
= XCreateFontCursor(display
, XC_xterm
);
715 blank
= XCreatePixmap(display
, scrPtr
->stipple
, 1, 1, 1);
716 XSetForeground(display
, scrPtr
->monoGC
, 0);
717 XFillRectangle(display
, blank
, scrPtr
->monoGC
, 0, 0, 1, 1);
719 scrPtr
->invisibleCursor
= XCreatePixmapCursor(display
, blank
, blank
,
721 XFreePixmap(display
, blank
);
724 scrPtr
->internalMessage
= XInternAtom(display
, "_WINGS_MESSAGE", False
);
726 scrPtr
->attribsAtom
= XInternAtom(display
, "_GNUSTEP_WM_ATTR", False
);
728 scrPtr
->deleteWindowAtom
= XInternAtom(display
, "WM_DELETE_WINDOW", False
);
730 scrPtr
->protocolsAtom
= XInternAtom(display
, "WM_PROTOCOLS", False
);
732 scrPtr
->clipboardAtom
= XInternAtom(display
, "CLIPBOARD", False
);
734 scrPtr
->rootView
= W_CreateRootView(scrPtr
);
737 scrPtr
->balloon
= W_CreateBalloon(scrPtr
);
740 W_InitApplication(scrPtr
);
747 WMHangData(WMWidget
*widget
, void *data
)
749 W_VIEW(widget
)->hangedData
= data
;
754 WMGetHangedData(WMWidget
*widget
)
756 return W_VIEW(widget
)->hangedData
;
762 WMDestroyWidget(WMWidget
*widget
)
764 W_DestroyView(W_VIEW(widget
));
769 WMSetFocusToWidget(WMWidget
*widget
)
771 W_SetFocusOfTopLevel(W_TopLevelOfView(W_VIEW(widget
)), W_VIEW(widget
));
777 * Realizes the widget and all it's children.
781 WMRealizeWidget(WMWidget
*w
)
783 W_RealizeView(W_VIEW(w
));
787 WMMapWidget(WMWidget
*w
)
789 W_MapView(W_VIEW(w
));
794 makeChildrenAutomap(W_View
*view
, int flag
)
796 view
= view
->childrenList
;
799 view
->flags
.mapWhenRealized
= flag
;
800 makeChildrenAutomap(view
, flag
);
802 view
= view
->nextSister
;
808 WMMapSubwidgets(WMWidget
*w
)
810 /* make sure that subwidgets created after the parent was realized
812 if (!W_VIEW(w
)->flags
.realized
) {
813 makeChildrenAutomap(W_VIEW(w
), True
);
815 W_MapSubviews(W_VIEW(w
));
821 WMUnmapSubwidgets(WMWidget
*w
)
823 if (!W_VIEW(w
)->flags
.realized
) {
824 makeChildrenAutomap(W_VIEW(w
), False
);
826 W_UnmapSubviews(W_VIEW(w
));
833 WMUnmapWidget(WMWidget
*w
)
835 W_UnmapView(W_VIEW(w
));
840 WMSetWidgetBackgroundColor(WMWidget
*w
, WMColor
*color
)
842 W_SetViewBackgroundColor(W_VIEW(w
), color
);
847 WMMoveWidget(WMWidget
*w
, int x
, int y
)
849 W_MoveView(W_VIEW(w
), x
, y
);
854 WMResizeWidget(WMWidget
*w
, unsigned int width
, unsigned int height
)
856 W_ResizeView(W_VIEW(w
), width
, height
);
862 W_RegisterUserWidget(void)
866 return userWidgetCount
+ WC_UserWidget
- 1;
872 WMScreenRContext(WMScreen
*scr
)
874 return scr
->rcontext
;
880 WMWidgetWidth(WMWidget
*w
)
882 return W_VIEW(w
)->size
.width
;
887 WMWidgetHeight(WMWidget
*w
)
889 return W_VIEW(w
)->size
.height
;
894 WMWidgetXID(WMWidget
*w
)
896 return W_VIEW(w
)->window
;
901 WMWidgetScreen(WMWidget
*w
)
903 return W_VIEW(w
)->screen
;
909 WMScreenMainLoop(WMScreen
*scr
)
914 WMNextEvent(scr
->display
, &event
);
915 WMHandleEvent(&event
);
922 WMScreenDisplay(WMScreen
*scr
)
929 WMScreenDepth(WMScreen
*scr
)
936 WMRedisplayWidget(WMWidget
*w
)
938 W_RedisplayView(W_VIEW(w
));