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);
439 tmp
= RGetSubImage(image
, 105, 25, 24, 24);
440 RCombineImageWithColor(tmp
, &white
);
441 scr
->disketteIcon
= WMCreatePixmapFromRImage(scr
, tmp
, 128);
443 tmp
= RGetSubImage(image
, 105, 25, 24, 24);
444 RCombineImageWithColor(tmp
, &white
);
445 scr
->altDisketteIcon
= WMCreatePixmapFromRImage(scr
, tmp
, 128);
449 tmp
= RGetSubImage(image
, 0, 0, 24, 24);
450 RCombineImageWithColor(tmp
, &white
);
451 scr
->altHomeIcon
= WMCreatePixmapFromRImage(scr
, tmp
, 128);
454 /* Magnifying Glass Icon for ColorPanel */
455 tmp
= RGetSubImage(image
, 24, 0, 40, 32);
456 RCombineImageWithColor(tmp
, &gray
);
457 scr
->magnifyIcon
= WMCreatePixmapFromRImage(scr
, tmp
, 128);
460 tmp = RGetSubImage(image, 24, 0, 40, 32);
461 RCombineImageWithColor(tmp, &white);
462 scr->altMagnifyIcon = WMCreatePixmapFromRImage(scr, tmp, 128);
465 /* ColorWheel Icon for ColorPanel */
466 tmp
= RGetSubImage(image
, 0, 25, 24, 24);
467 scr
->wheelIcon
= WMCreatePixmapFromRImage(scr
, tmp
, 128);
469 /* GrayScale Icon for ColorPanel */
470 tmp
= RGetSubImage(image
, 65, 0, 40, 24);
471 scr
->grayIcon
= WMCreatePixmapFromRImage(scr
, tmp
, 128);
473 /* RGB Icon for ColorPanel */
474 tmp
= RGetSubImage(image
, 25, 33, 40, 24);
475 scr
->rgbIcon
= WMCreatePixmapFromRImage(scr
, tmp
, 128);
477 /* CMYK Icon for ColorPanel */
478 tmp
= RGetSubImage(image
, 65, 25, 40, 24);
479 scr
->cmykIcon
= WMCreatePixmapFromRImage(scr
, tmp
, 128);
481 /* HSB Icon for ColorPanel */
482 tmp
= RGetSubImage(image
, 0, 57, 40, 24);
483 scr
->hsbIcon
= WMCreatePixmapFromRImage(scr
, tmp
, 128);
485 /* CustomColorPalette Icon for ColorPanel */
486 tmp
= RGetSubImage(image
, 81, 57, 40, 24);
487 scr
->customPaletteIcon
= WMCreatePixmapFromRImage(scr
, tmp
, 128);
489 /* ColorList Icon for ColorPanel */
490 tmp
= RGetSubImage(image
, 41, 57, 40, 24);
491 scr
->colorListIcon
= WMCreatePixmapFromRImage(scr
, tmp
, 128);
494 RDestroyImage(image
);
497 scr
->defaultObjectIcon
=
498 WMCreatePixmapFromFile(scr
, T_DEFAULT_OBJECT_ICON_FILE
);
499 if (!scr
->defaultObjectIcon
) {
500 scr
->defaultObjectIcon
=
501 WMCreatePixmapFromFile(scr
, X_DEFAULT_OBJECT_ICON_FILE
);
503 if (!scr
->defaultObjectIcon
) {
504 wwarning("WINGs: could not load default icon file");
514 WMCreateSimpleApplicationScreen(Display
*display
)
518 scr
= WMCreateScreen(display
, DefaultScreen(display
));
520 scr
->aflags
.hasAppIcon
= 0;
521 scr
->aflags
.simpleApplication
= 1;
529 WMCreateScreen(Display
*display
, int screen
)
531 return WMCreateScreenWithRContext(display
, screen
,
532 RCreateContext(display
, screen
, NULL
));
537 WMCreateScreenWithRContext(Display
*display
, int screen
, RContext
*context
)
542 static int initialized
= 0;
548 W_ReadConfigurations();
550 assert(W_ApplicationInitialized());
553 scrPtr
= malloc(sizeof(W_Screen
));
556 memset(scrPtr
, 0, sizeof(W_Screen
));
558 scrPtr
->aflags
.hasAppIcon
= 1;
560 scrPtr
->display
= display
;
561 scrPtr
->screen
= screen
;
562 scrPtr
->rcontext
= context
;
564 scrPtr
->depth
= context
->depth
;
566 scrPtr
->visual
= context
->visual
;
567 scrPtr
->lastEventTime
= 0;
569 scrPtr
->colormap
= context
->cmap
;
571 scrPtr
->rootWin
= RootWindow(display
, screen
);
573 scrPtr
->fontCache
= WMCreateHashTable(WMStringPointerHashCallbacks
);
575 /* initially allocate some colors */
576 WMWhiteColor(scrPtr
);
577 WMBlackColor(scrPtr
);
579 WMDarkGrayColor(scrPtr
);
581 gcv
.graphics_exposures
= False
;
583 gcv
.function
= GXxor
;
584 gcv
.foreground
= W_PIXEL(scrPtr
->white
);
585 if (gcv
.foreground
== 0) gcv
.foreground
= 1;
586 scrPtr
->xorGC
= XCreateGC(display
, W_DRAWABLE(scrPtr
), GCFunction
587 |GCGraphicsExposures
|GCForeground
, &gcv
);
589 gcv
.function
= GXxor
;
590 gcv
.foreground
= W_PIXEL(scrPtr
->gray
);
591 gcv
.subwindow_mode
= IncludeInferiors
;
592 scrPtr
->ixorGC
= XCreateGC(display
, W_DRAWABLE(scrPtr
), GCFunction
593 |GCGraphicsExposures
|GCForeground
594 |GCSubwindowMode
, &gcv
);
596 gcv
.function
= GXcopy
;
597 scrPtr
->copyGC
= XCreateGC(display
, W_DRAWABLE(scrPtr
), GCFunction
598 |GCGraphicsExposures
, &gcv
);
600 scrPtr
->clipGC
= XCreateGC(display
, W_DRAWABLE(scrPtr
), GCFunction
601 |GCGraphicsExposures
, &gcv
);
604 stipple
= XCreateBitmapFromData(display
, W_DRAWABLE(scrPtr
),
605 STIPPLE_BITS
, STIPPLE_WIDTH
, STIPPLE_HEIGHT
);
606 gcv
.foreground
= W_PIXEL(scrPtr
->darkGray
);
607 gcv
.background
= W_PIXEL(scrPtr
->gray
);
608 gcv
.fill_style
= FillStippled
;
609 gcv
.stipple
= stipple
;
610 scrPtr
->stippleGC
= XCreateGC(display
, W_DRAWABLE(scrPtr
),
611 GCForeground
|GCBackground
|GCStipple
612 |GCFillStyle
|GCGraphicsExposures
, &gcv
);
614 gcv
.foreground
= W_PIXEL(scrPtr
->black
);
615 gcv
.background
= W_PIXEL(scrPtr
->white
);
616 scrPtr
->textFieldGC
= XCreateGC(display
, W_DRAWABLE(scrPtr
),
617 GCForeground
|GCBackground
, &gcv
);
619 /* we need a 1bpp drawable for the monoGC, so borrow this one */
620 scrPtr
->monoGC
= XCreateGC(display
, stipple
, 0, NULL
);
622 scrPtr
->stipple
= stipple
;
624 scrPtr
->useMultiByte
= WINGsConfiguration
.useMultiByte
;
626 scrPtr
->normalFont
= WMSystemFontOfSize(scrPtr
, 12);
628 scrPtr
->boldFont
= WMBoldSystemFontOfSize(scrPtr
, 12);
630 if (!scrPtr
->boldFont
)
631 scrPtr
->boldFont
= scrPtr
->normalFont
;
633 if (!scrPtr
->normalFont
) {
634 wwarning("could not load any fonts. Make sure your font installation"
635 "and locale settings are correct.");
640 scrPtr
->checkButtonImageOn
= makePixmap(scrPtr
, CHECK_BUTTON_ON
,
641 CHECK_BUTTON_ON_WIDTH
,
642 CHECK_BUTTON_ON_HEIGHT
, False
);
644 scrPtr
->checkButtonImageOff
= makePixmap(scrPtr
, CHECK_BUTTON_OFF
,
645 CHECK_BUTTON_OFF_WIDTH
,
646 CHECK_BUTTON_OFF_HEIGHT
, False
);
648 scrPtr
->radioButtonImageOn
= makePixmap(scrPtr
, RADIO_BUTTON_ON
,
649 RADIO_BUTTON_ON_WIDTH
,
650 RADIO_BUTTON_ON_HEIGHT
, False
);
652 scrPtr
->radioButtonImageOff
= makePixmap(scrPtr
, RADIO_BUTTON_OFF
,
653 RADIO_BUTTON_OFF_WIDTH
,
654 RADIO_BUTTON_OFF_HEIGHT
, False
);
656 scrPtr
->buttonArrow
= makePixmap(scrPtr
, BUTTON_ARROW
,
657 BUTTON_ARROW_WIDTH
, BUTTON_ARROW_HEIGHT
,
660 scrPtr
->pushedButtonArrow
= makePixmap(scrPtr
, BUTTON_ARROW2
,
661 BUTTON_ARROW2_WIDTH
, BUTTON_ARROW2_HEIGHT
,
665 scrPtr
->scrollerDimple
= makePixmap(scrPtr
, SCROLLER_DIMPLE
,
666 SCROLLER_DIMPLE_WIDTH
,
667 SCROLLER_DIMPLE_HEIGHT
, False
);
670 scrPtr
->upArrow
= makePixmap(scrPtr
, SCROLLER_ARROW_UP
,
671 SCROLLER_ARROW_UP_WIDTH
,
672 SCROLLER_ARROW_UP_HEIGHT
, True
);
674 scrPtr
->downArrow
= makePixmap(scrPtr
, SCROLLER_ARROW_DOWN
,
675 SCROLLER_ARROW_DOWN_WIDTH
,
676 SCROLLER_ARROW_DOWN_HEIGHT
, True
);
678 scrPtr
->leftArrow
= makePixmap(scrPtr
, SCROLLER_ARROW_LEFT
,
679 SCROLLER_ARROW_LEFT_WIDTH
,
680 SCROLLER_ARROW_LEFT_HEIGHT
, True
);
682 scrPtr
->rightArrow
= makePixmap(scrPtr
, SCROLLER_ARROW_RIGHT
,
683 SCROLLER_ARROW_RIGHT_WIDTH
,
684 SCROLLER_ARROW_RIGHT_HEIGHT
, True
);
686 scrPtr
->hiUpArrow
= makePixmap(scrPtr
, HI_SCROLLER_ARROW_UP
,
687 SCROLLER_ARROW_UP_WIDTH
,
688 SCROLLER_ARROW_UP_HEIGHT
, True
);
690 scrPtr
->hiDownArrow
= makePixmap(scrPtr
, HI_SCROLLER_ARROW_DOWN
,
691 SCROLLER_ARROW_DOWN_WIDTH
,
692 SCROLLER_ARROW_DOWN_HEIGHT
, True
);
694 scrPtr
->hiLeftArrow
= makePixmap(scrPtr
, HI_SCROLLER_ARROW_LEFT
,
695 SCROLLER_ARROW_LEFT_WIDTH
,
696 SCROLLER_ARROW_LEFT_HEIGHT
, True
);
698 scrPtr
->hiRightArrow
= makePixmap(scrPtr
, HI_SCROLLER_ARROW_RIGHT
,
699 SCROLLER_ARROW_RIGHT_WIDTH
,
700 SCROLLER_ARROW_RIGHT_HEIGHT
, True
);
702 scrPtr
->popUpIndicator
= makePixmap(scrPtr
, POPUP_INDICATOR
,
703 POPUP_INDICATOR_WIDTH
,
704 POPUP_INDICATOR_HEIGHT
, True
);
706 scrPtr
->pullDownIndicator
= makePixmap(scrPtr
, PULLDOWN_INDICATOR
,
707 PULLDOWN_INDICATOR_WIDTH
,
708 PULLDOWN_INDICATOR_HEIGHT
, True
);
710 scrPtr
->checkMark
= makePixmap(scrPtr
, CHECK_MARK
,
712 CHECK_MARK_HEIGHT
, True
);
716 scrPtr
->defaultCursor
= XCreateFontCursor(display
, XC_left_ptr
);
718 scrPtr
->textCursor
= XCreateFontCursor(display
, XC_xterm
);
724 blank
= XCreatePixmap(display
, scrPtr
->stipple
, 1, 1, 1);
725 XSetForeground(display
, scrPtr
->monoGC
, 0);
726 XFillRectangle(display
, blank
, scrPtr
->monoGC
, 0, 0, 1, 1);
728 scrPtr
->invisibleCursor
= XCreatePixmapCursor(display
, blank
, blank
,
730 XFreePixmap(display
, blank
);
733 scrPtr
->internalMessage
= XInternAtom(display
, "_WINGS_MESSAGE", False
);
735 scrPtr
->attribsAtom
= XInternAtom(display
, "_GNUSTEP_WM_ATTR", False
);
737 scrPtr
->deleteWindowAtom
= XInternAtom(display
, "WM_DELETE_WINDOW", False
);
739 scrPtr
->protocolsAtom
= XInternAtom(display
, "WM_PROTOCOLS", False
);
741 scrPtr
->clipboardAtom
= XInternAtom(display
, "CLIPBOARD", False
);
743 scrPtr
->rootView
= W_CreateRootView(scrPtr
);
746 scrPtr
->balloon
= W_CreateBalloon(scrPtr
);
749 W_InitApplication(scrPtr
);
756 WMHangData(WMWidget
*widget
, void *data
)
758 W_VIEW(widget
)->hangedData
= data
;
763 WMGetHangedData(WMWidget
*widget
)
765 return W_VIEW(widget
)->hangedData
;
771 WMDestroyWidget(WMWidget
*widget
)
773 W_DestroyView(W_VIEW(widget
));
778 WMSetFocusToWidget(WMWidget
*widget
)
780 W_SetFocusOfTopLevel(W_TopLevelOfView(W_VIEW(widget
)), W_VIEW(widget
));
786 * Realizes the widget and all it's children.
790 WMRealizeWidget(WMWidget
*w
)
792 W_RealizeView(W_VIEW(w
));
796 WMMapWidget(WMWidget
*w
)
798 W_MapView(W_VIEW(w
));
803 makeChildrenAutomap(W_View
*view
, int flag
)
805 view
= view
->childrenList
;
808 view
->flags
.mapWhenRealized
= flag
;
809 makeChildrenAutomap(view
, flag
);
811 view
= view
->nextSister
;
817 WMMapSubwidgets(WMWidget
*w
)
819 /* make sure that subwidgets created after the parent was realized
821 if (!W_VIEW(w
)->flags
.realized
) {
822 makeChildrenAutomap(W_VIEW(w
), True
);
824 W_MapSubviews(W_VIEW(w
));
830 WMUnmapSubwidgets(WMWidget
*w
)
832 if (!W_VIEW(w
)->flags
.realized
) {
833 makeChildrenAutomap(W_VIEW(w
), False
);
835 W_UnmapSubviews(W_VIEW(w
));
842 WMUnmapWidget(WMWidget
*w
)
844 W_UnmapView(W_VIEW(w
));
849 WMSetWidgetBackgroundColor(WMWidget
*w
, WMColor
*color
)
851 W_SetViewBackgroundColor(W_VIEW(w
), color
);
856 WMMoveWidget(WMWidget
*w
, int x
, int y
)
858 W_MoveView(W_VIEW(w
), x
, y
);
863 WMResizeWidget(WMWidget
*w
, unsigned int width
, unsigned int height
)
865 W_ResizeView(W_VIEW(w
), width
, height
);
871 W_RegisterUserWidget(void)
875 return userWidgetCount
+ WC_UserWidget
- 1;
881 WMScreenRContext(WMScreen
*scr
)
883 return scr
->rcontext
;
889 WMWidgetWidth(WMWidget
*w
)
891 return W_VIEW(w
)->size
.width
;
896 WMWidgetHeight(WMWidget
*w
)
898 return W_VIEW(w
)->size
.height
;
903 WMWidgetXID(WMWidget
*w
)
905 return W_VIEW(w
)->window
;
910 WMWidgetScreen(WMWidget
*w
)
912 return W_VIEW(w
)->screen
;
918 WMScreenMainLoop(WMScreen
*scr
)
923 WMNextEvent(scr
->display
, &event
);
924 WMHandleEvent(&event
);
931 WMScreenDisplay(WMScreen
*scr
)
938 WMScreenDepth(WMScreen
*scr
)
945 WMRedisplayWidget(WMWidget
*w
)
947 W_RedisplayView(W_VIEW(w
));