1 /****************************************************************************/
3 /* ALLIANCE CAD FRAMEWORK */
5 /* Tool : libXal Version 1.01 */
8 /* (c) copyright 1993 MASI Laboratory. CAO & VLSI CAD Team */
9 /* All rights reserved. */
10 /* Support : e-mail cao-vlsi@masi.ibp.fr */
12 /* Author(s) : Nizar ABDALLAH Date : 02/02/1993 */
14 /* Modified by : Date : ../../.... */
15 /* Modified by : Date : ../../.... */
16 /* Modified by : Date : ../../.... */
18 /****************************************************************************/
20 /* This function is to be called by all ALLIANCE tools in order to present */
21 /* the same iconic image. */
23 /****************************************************************************/
26 /*--------------------------------------------------------------------------*/
28 /*--------------------------------------------------------------------------*/
36 /*-----------------------------*/
37 /* Motif for Alliance includes */
38 /*-----------------------------*/
46 static Pixmap xal_pixmap
;
49 /*---------------------------------------------------------------------------*/
51 /* FUNCTION : XalForceIcon */
53 /* IN ARGS : .shell_w : The shell widget for whom we want to create the icon*/
55 /* OUT ARGS : ( void ) */
57 /* OBJECT : Forces the WM to execute the set icon. */
59 /*---------------------------------------------------------------------------*/
60 void XalForceIcon( shell_w
, dpy
)
65 unsigned int x
, y
, width
, height
, border_width
, depth
;
67 XtVaGetValues(shell_w
, XmNiconWindow
, &window
, NULL
);
69 /*---------------------------------------------------------------------------*/
70 /* If there is no window associated with the shell, create one. Make it at */
71 /* least as big as the pixmap we're going to use. The icon window only needs */
72 /* to be a simple window. */
73 /*---------------------------------------------------------------------------*/
76 if (!XGetGeometry(dpy
, xal_pixmap
, &root
, &x
, &y
, &width
, &height
, &border_width
, &depth
) ||
77 !(window
= XCreateSimpleWindow(dpy
, root
, 0, 0, width
, height
, (unsigned)0,
78 CopyFromParent
, CopyFromParent
)))
80 XtVaSetValues(shell_w
, XmNiconPixmap
, xal_pixmap
, NULL
);
83 XtVaSetValues(shell_w
, XmNiconWindow
, window
, NULL
);
85 XSetWindowBackgroundPixmap(dpy
, window
, xal_pixmap
);
86 XClearWindow(dpy
, window
);
90 /*---------------------------------------------------------------------------*/
92 /* FUNCTION : XalSetIcon */
94 /* IN ARGS : .shell_w : The shell widget for whom we want to create the icon*/
96 /* OUT ARGS : ( void ) */
98 /* OBJECT : Icon creation function. */
100 /*---------------------------------------------------------------------------*/
101 void XalSetIcon( shell_w
)
104 Display
*dpy
= XtDisplay(shell_w
);
105 Screen
*screen
= XtScreen(shell_w
);
106 XpmAttributes XpmAttr
;
107 XpmColorSymbol XpmTransparentColor
[1] = {{ NULL
, "none", 0 }};
109 XpmTransparentColor
[0].pixel
= WhitePixelOfScreen(screen
) ;
110 XpmAttr
.valuemask
= XpmColorSymbols
| XpmCloseness
| XpmDepth
;
111 XpmAttr
.colorsymbols
= XpmTransparentColor
;
112 XpmAttr
.numsymbols
= 1;
113 XpmAttr
.closeness
= 65535;
114 XpmAttr
.depth
= DefaultDepthOfScreen(screen
);
116 if ((XpmCreatePixmapFromData(dpy
, RootWindowOfScreen(screen
),
117 Icon
, &xal_pixmap
, NULL
, &XpmAttr
)) != XpmSuccess
)
120 xal_pixmap
= XCreatePixmapFromBitmapData( dpy
,
121 RootWindowOfScreen(screen
),
122 Icon_bits
, Icon_width
, Icon_height
,
123 BlackPixelOfScreen(screen
),
124 WhitePixelOfScreen(screen
),
125 DefaultDepthOfScreen(screen
));
129 if ( xal_pixmap
!= XmUNSPECIFIED_PIXMAP
)
130 XalForceIcon( shell_w
, dpy
);
134 /*---------------------------------------------------------------------------*/
136 /* FUNCTION : XalCustomIcon */
138 /* IN ARGS : .shell_w : The shell widget for whom we want to create the icon*/
139 /* .pix_file : Bitmap filename containing Icon pixmap. */
141 /* OUT ARGS : ( void ) */
143 /* OBJECT : Icon creation function. */
145 /*---------------------------------------------------------------------------*/
146 void XalCustomIcon( shell_w
, pix_file
)
150 Display
*dpy
= XtDisplay(shell_w
);
151 Screen
*screen
= XtScreen(shell_w
);
153 if(XalBitmaps
!= NULL
)
155 xal_pixmap
= XalGetPixmap( shell_w
, pix_file
, BlackPixelOfScreen(screen
),
156 WhitePixelOfScreen(screen
));
160 xal_pixmap
= XmUNSPECIFIED_PIXMAP
;
163 if ( xal_pixmap
!= XmUNSPECIFIED_PIXMAP
)
164 XalForceIcon( shell_w
, dpy
);
168 /*---------------------------------------------------------------------------*/
170 /* FUNCTION : XalGetPixmap */
172 /* IN ARGS : .shell_w : The shell widget for whom we want to create the icon*/
173 /* .pix_file : Bitmap filename containing Icon pixmap. */
175 /* OUT ARGS : ( void ) */
177 /* OBJECT : Icon creation function. */
179 /*---------------------------------------------------------------------------*/
180 Pixmap
XalGetPixmap (widget
, imageindex
, foreground
, background
)
188 pixmap
= XmGetPixmap( XtScreen(widget
), XalBitmaps
[imageindex
].name
,
189 foreground
, background
);
191 if ( pixmap
== XmUNSPECIFIED_PIXMAP
)
193 pixmap
= XCreatePixmapFromBitmapData( XtDisplay(widget
),
194 RootWindowOfScreen(XtScreen(widget
)),
195 XalBitmaps
[imageindex
].bitmap
,
196 XalBitmaps
[imageindex
].width
,
197 XalBitmaps
[imageindex
].height
,
198 foreground
, background
,
199 DefaultDepthOfScreen(XtScreen(widget
)));