Initial version of donated sources by Avertec, 3.4p5.
[tas-yagle.git] / distrib / sources / tas / xal / PixmapLabel.c
1 /****************************************************************************/
2 /* */
3 /* ALLIANCE CAD FRAMEWORK */
4 /* */
5 /* Tool : libXal Version 1.01 */
6 /* File : PixmapLabel.c */
7 /* */
8 /* (c) copyright 1993 MASI Laboratory. CAO & VLSI CAD Team */
9 /* All rights reserved. */
10 /* Support : e-mail cao-vlsi@masi.ibp.fr */
11 /* */
12 /* Author(s) : Nizar ABDALLAH Date : 02/02/1993 */
13 /* */
14 /* Modified by : Date : ../../.... */
15 /* Modified by : Date : ../../.... */
16 /* Modified by : Date : ../../.... */
17 /* */
18 /****************************************************************************/
19 /* */
20 /* This function is to be called by all ALLIANCE tools in order to present */
21 /* the same iconic image. */
22 /* */
23 /****************************************************************************/
24 #include <stdio.h>
25
26 #include <Xm/Xm.h>
27 #include <Xm/Label.h>
28 #include <X11/xpm.h>
29
30 /*-----------------------------*/
31 /* Motif for Alliance includes */
32 /*-----------------------------*/
33 #include MUT_H
34
35 #include XAL_H
36
37 /*---------------------------------------------------------------------------*/
38 /* */
39 /* FUNCTION : XalCreatePixmapLabel */
40 /* */
41 /* IN ARGS : .LabelWidget : set a pixmap on a label widget */
42 /* */
43 /* OUT ARGS : ( void ) */
44 /* */
45 /* OBJECT : Forces the WM to execute the set icon. */
46 /* */
47 /*---------------------------------------------------------------------------*/
48 Widget XalCreatePixmapLabel(LabelWidget, Normal, Insensitive)
49 Widget LabelWidget;
50 char **Normal;
51 char **Insensitive;
52 {
53 Display *Dsp;
54 Screen *Scr;
55 int Depth;
56 int PixmapX, PixmapY;
57 unsigned int PixmapHeight, PixmapWidth, PixmapBorder, PixmapDepth;
58 Window RootWindow;
59 Pixmap NormalPixmap, InsensitivePixmap;
60 XpmAttributes XpmAttr;
61 Boolean RecomputeSize;
62 Pixel Background;
63 GC gc;
64 XGCValues GCValues;
65 Pixmap Stipple;
66 XpmColorSymbol XpmTransparentColor[1] = {{ NULL, "none", 0 }};
67 static char StippleBitmap[8] = { 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA };
68
69 Dsp = XtDisplayOfObject(LabelWidget);
70 Scr = XtScreenOfObject(LabelWidget);
71 XtVaGetValues(XtIsSubclass(LabelWidget, coreWidgetClass) ? LabelWidget : XtParent(LabelWidget),
72 XmNdepth, &Depth,
73 XmNbackground, &Background,
74 NULL);
75
76 XpmTransparentColor[0].pixel = Background;
77 XpmAttr.valuemask = XpmColorSymbols | XpmCloseness | XpmDepth;
78 XpmAttr.colorsymbols = XpmTransparentColor;
79 XpmAttr.numsymbols = 1;
80 XpmAttr.closeness = 65535;
81 XpmAttr.depth = Depth;
82
83 if ((XpmCreatePixmapFromData(Dsp, RootWindowOfScreen(Scr),
84 Normal, &NormalPixmap, NULL, &XpmAttr)) != XpmSuccess){
85 return ( NULL ) ;
86 }
87
88 Stipple = XCreateBitmapFromData(Dsp, RootWindowOfScreen(Scr),
89 StippleBitmap, 8, 8);
90 GCValues.foreground = Background;
91 GCValues.fill_style = FillStippled;
92 GCValues.stipple = Stipple;
93 gc = XtGetGC(LabelWidget,
94 GCForeground | GCFillStyle | GCStipple,
95 &GCValues);
96 XGetGeometry(Dsp, NormalPixmap, &RootWindow, &PixmapX, &PixmapY,
97 &PixmapWidth, &PixmapHeight, &PixmapBorder, &PixmapDepth);
98 InsensitivePixmap = XCreatePixmap(Dsp, RootWindowOfScreen(Scr),
99 PixmapWidth, PixmapHeight, PixmapDepth);
100 XCopyArea(Dsp, NormalPixmap, InsensitivePixmap, gc, 0, 0, PixmapWidth, PixmapHeight, 0, 0);
101 XFillRectangle(Dsp, InsensitivePixmap, gc, 0, 0, PixmapWidth, PixmapHeight);
102
103 XtReleaseGC(LabelWidget, gc);
104 XFreePixmap(Dsp, Stipple);
105
106 XtVaGetValues(LabelWidget, XmNrecomputeSize, &RecomputeSize, NULL);
107 XtVaSetValues(LabelWidget, XmNrecomputeSize, True, NULL);
108 XtVaSetValues(LabelWidget,
109 XmNlabelType, XmPIXMAP,
110 XmNlabelPixmap, NormalPixmap,
111 XmNlabelInsensitivePixmap, InsensitivePixmap,
112 NULL);
113 XtVaSetValues(LabelWidget, XmNrecomputeSize, RecomputeSize, NULL);
114 return ( LabelWidget );
115
116 } /* XalCreatePixmapLabel */