2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these librararies and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
24 * (c) Copyright 1989, 1990, 1991, 1992 OPEN SOFTWARE FOUNDATION, INC.
32 static char rcsid[] = "$XConsortium: WmGraphics.c /main/4 1995/11/01 11:38:53 rswiston $"
36 * (c) Copyright 1987, 1988, 1989, 1990 HEWLETT-PACKARD COMPANY */
46 #include <X11/StringDefs.h>
47 #include <X11/Xutil.h>
48 #include <X11/Intrinsic.h>
53 #define RLIST_EXTENSION_SIZE 10
56 #define MAX(x,y) ((x)>(y)?(x):(y))
60 * include extern functions
62 #include "WmGraphics.h"
76 /* test if > 0 and return 1 if true, 0 if false. */
77 #define GE1(x) ((x)>0?1:0)
81 /*************************************<->*************************************
83 * Procedure: BevelRectangle (prTop, prBot, x, y,
84 * width, height, top_wid, right_wid, bot_wid, left_wid)
88 * Generate data for top- and bottom-shadow bevels on a box.
92 * prTop - ptr to top shadow RList
93 * prBot - ptr to bottom shadow RList
94 * x,y - position of rectangle to bevel
95 * width - (outside) width of rectangle
96 * height - (outside) height of rectangle
97 * top_wid - width of beveling on top side of rectangle
98 * right_wid - width of beveling on right side of rectangle
99 * bot_wid - width of beveling on bottom side of rectangle
100 * left_wid - width of beveling on left side of rectangle
104 * prTop - top shadows for this rectangle added to list
105 * prBot - bottom shadows for this rectangle added to list
111 *************************************<->***********************************/
113 void BevelRectangle (RList *prTop, RList *prBot, int x, int y, unsigned int width, unsigned int height, unsigned int top_wid, unsigned int right_wid, unsigned int bot_wid, unsigned int left_wid)
115 XRectangle *prect; /* pointer to "current" rectangle */
116 register int count; /* counter used for beveling operation */
117 int join1, join2; /* used to compute "good" bevel joints */
118 int x1, y1, len; /* used to compute bevel parameters */
122 /* build the rectangles to implement the beveling on each side */
126 if (((prTop->used + (top_wid + left_wid)) > prTop->allocated) &&
127 (!ExtendRList (prTop, MAX (top_wid+left_wid, RLIST_EXTENSION_SIZE))))
129 return; /* not enough memory */
132 piTop = &(prTop->used);
133 prect = &(prTop->prect[*piTop]);
140 for (count=top_wid; count>0; count--, prect++, (*piTop)++)
148 len -= GE1(join1) + GE1(--join2);
157 len = height-GE1(join1);
158 for (count=left_wid; count >0; count--, prect++, (*piTop)++)
166 len -= GE1(join1) + GE1(--join2);
172 if (((prBot->used + (bot_wid + right_wid)) > prBot->allocated) &&
173 (!ExtendRList(prBot, MAX (bot_wid+right_wid, RLIST_EXTENSION_SIZE))))
178 piBot = &(prBot->used);
179 prect = &(prBot->prect[*piBot]);
185 len = width-GE1(join1);
186 /* fudge fat bottom shadow to overwrite corner of skinny left shadow */
187 if (GE1(join1) && (bot_wid > left_wid)) {
192 for (count=bot_wid; count >0; count--, prect++, (*piBot)++)
200 len -= GE1(join1) + GE1(--join2);
209 len = height - GE1(join1) - GE1(join2);
210 /* fudge fat right shadow to overwrite corner of skinny top shadow */
211 if (GE1(join1) && (right_wid > top_wid)) {
216 for (count=right_wid; count >0; count--, prect++, (*piBot)++)
224 len -= GE1(join1) + GE1(--join2);
227 } /* END OF FUNCTION BevelRectangle */
232 /*************************************<->*************************************
234 * Procedure: BevelDepressedRectangle (prTop, prBot, x, y,
235 * width, height, top_wid, right_wid, bot_wid, left_wid
240 * Generate data for top- and bottom-shadow bevels on a rectangle with
241 * the center part depressed.
245 * prTop - ptr to top shadow RList
246 * prBot - ptr to bottom shadow RList
247 * x,y - position of rectangle to bevel
248 * width - (outside) width of rectangle
249 * height - (outside) height of rectangle
250 * top_wid - width of beveling on top side of rectangle
251 * right_wid - width of beveling on right side of rectangle
252 * bot_wid - width of beveling on bottom side of rectangle
253 * left_wid - width of beveling on left side of rectangle
254 * in_wid - width of depressed beveling inside of rectangle
258 * prTop - top shadows for this rectangle added to list
259 * prBot - bottom shadows for this rectangle added to list
265 *************************************<->***********************************/
267 void BevelDepressedRectangle (RList *prTop, RList *prBot, int x, int y, unsigned int width, unsigned int height, unsigned int top_wid, unsigned int right_wid, unsigned int bot_wid, unsigned int left_wid, unsigned int in_wid)
269 XRectangle *prect; /* pointer to "current" rectangle */
270 register int count; /* counter used for beveling operation */
271 int join1, join2; /* used to compute "good" bevel joints */
272 int x1, y1, len; /* used to compute bevel parameters */
277 * Build the rectangles to implement the beveling on each side
278 * First, guarantee that there is enough memory.
282 if (((prTop->used + (top_wid + left_wid)) > prTop->allocated) &&
283 (!ExtendRList (prTop, MAX (top_wid+left_wid, RLIST_EXTENSION_SIZE))))
285 return; /* not enough memory */
288 if (((prBot->used + (bot_wid + right_wid)) > prBot->allocated) &&
289 (!ExtendRList(prBot, MAX (bot_wid+right_wid, RLIST_EXTENSION_SIZE))))
291 return; /* not enought memory */
296 /* top side (normal beveling) */
298 piTop = &(prTop->used);
299 prect = &(prTop->prect[*piTop]);
306 for (count=top_wid - in_wid; count>0; count--, prect++, (*piTop)++)
314 len -= GE1(join1) + GE1(--join2);
317 /* top side (inverted beveling) */
319 piBot = &(prBot->used);
320 prect = &(prBot->prect[*piBot]);
322 for (count=in_wid; count>0; count--, prect++, (*piBot)++)
330 len -= GE1(join1) + GE1(--join2);
335 /* left side (normal beveling) */
337 piTop = &(prTop->used);
338 prect = &(prTop->prect[*piTop]);
344 len = height-GE1(join1);
345 for (count=left_wid-in_wid; count >0; count--, prect++, (*piTop)++)
353 len -= GE1(join1) + GE1(--join2);
356 /* left side (inverted beveling) */
358 piBot = &(prBot->used);
359 prect = &(prBot->prect[*piBot]);
361 for (count=in_wid; count >0; count--, prect++, (*piBot)++)
369 len -= GE1(join1) + GE1(--join2);
374 /* bottom side (normal beveling) */
376 piBot = &(prBot->used);
377 prect = &(prBot->prect[*piBot]);
383 len = width-GE1(join1);
384 /* fudge fat bottom shadow to overwrite corner of skinny left shadow */
385 if (GE1(join1) && (bot_wid > left_wid)) {
390 for (count=bot_wid-in_wid; count >0; count--, prect++, (*piBot)++)
398 len -= GE1(join1) + GE1(--join2);
401 /* bottom side (inverted beveling) */
403 piTop = &(prTop->used);
404 prect = &(prTop->prect[*piTop]);
406 for (count=in_wid; count >0; count--, prect++, (*piTop)++)
414 len -= GE1(join1) + GE1(--join2);
419 /* right side (normal beveling) */
421 piBot = &(prBot->used);
422 prect = &(prBot->prect[*piBot]);
428 len = height - GE1(join1) - GE1(join2);
429 /* fudge fat right shadow to overwrite corner of skinny top shadow */
430 if (GE1(join1) && (right_wid > top_wid)) {
435 for (count=right_wid-in_wid; count >0; count--, prect++, (*piBot)++)
443 len -= GE1(join1) + GE1(--join2);
446 /* right side (inverted beveling) */
448 piTop = &(prTop->used);
449 prect = &(prTop->prect[*piTop]);
451 for (count=in_wid; count >0; count--, prect++, (*piTop)++)
459 len -= GE1(join1) + GE1(--join2);
462 } /* END OF FUNCTION BevelDepressedRectangle */
467 /*************************************<->*************************************
469 * Procedure: StretcherCorner (prTop, prBot, x, y, cnum,
470 * swidth, cwidth, cheight);
474 * Generate data to draw a corner of the stretcher border.
478 * prTop - ptr to top shadow RList
479 * prBot - ptr to bottom shadow RList
480 * x,y - position of rectangle enclosing the cornern
481 * cnum - corner number; which corner to draw
482 * ASSUMES only NW, NE, SE, SW for mwm ()
483 * swidth - width (thickness) of border (includes bevels)
484 * cwidth - corner width from corner to end of horizontal run
485 * cheight - corner height from corner to end of vertical run
489 * prTop - array filled in for top shadows
490 * prBot - array filledin for bottom shadows
494 * o Uses only 1 pixel bevels. Beveling is hard coded.
495 * o XFillRectangles assumed as an optimization to take
496 * advantage of the block mover hardware.
498 *************************************<->***********************************/
500 void StretcherCorner (RList *prTop, RList *prBot, int x, int y, int cnum, unsigned int swidth, unsigned int cwidth, unsigned int cheight)
502 XRectangle *prect; /* pointer to "current" rectangle */
507 case STRETCH_NORTH_WEST:
508 if (((prTop->used + 4) > prTop->allocated) &&
509 (!ExtendRList (prTop, (unsigned int) RLIST_EXTENSION_SIZE)))
514 piTop = &(prTop->used);
515 prect = &(prTop->prect[*piTop]);
517 prect->x = x; /* top (row 1) */
519 prect->width = cwidth;
524 prect->x = x+1; /* top (row 2) */
526 prect->width = cwidth-2;
531 prect->x = x; /* left (col 1) */
534 prect->height = cheight-1;
538 prect->x = x+1; /* left (col 2) */
541 prect->height = cheight-3;
544 if (((prBot->used + 4) > prBot->allocated) &&
545 (!ExtendRList (prBot, (unsigned int) RLIST_EXTENSION_SIZE)))
550 piBot = &(prBot->used);
551 prect = &(prBot->prect[*piBot]); /* bottom shadow parts */
554 prect->x = x+1; /* bottom end */
555 prect->y = y+cheight-1;
556 prect->width = swidth-1;
561 if (wmGD.frameStyle == WmRECESSED)
563 prect->x = x+swidth-1; /* right inside */
564 prect->y = y+swidth-1;
566 prect->height = cheight-swidth;
570 prect->x = x+swidth; /* bottom inside */
571 prect->y = y+swidth-1;
572 prect->width = cwidth-swidth;
578 prect->x = x+cwidth-1; /* right end */
581 prect->height = swidth-1-((wmGD.frameStyle == WmSLAB)? 0 : 1);
586 case STRETCH_NORTH_EAST:
587 if (((prTop->used + 4) > prTop->allocated) &&
588 (!ExtendRList (prTop, (unsigned int) RLIST_EXTENSION_SIZE)))
593 piTop = &(prTop->used);
594 prect = &(prTop->prect[*piTop]);
596 prect->x = x; /* top (row 1) */
598 prect->width = cwidth;
603 prect->x = x+1; /* top (row 2) */
605 prect->width = cwidth-2;
610 prect->x = x; /* left end */
613 prect->height = swidth-1;
617 if (wmGD.frameStyle == WmRECESSED)
619 prect->x = x+cwidth-swidth; /* left inside (col 1) */
622 prect->height = cheight-swidth;
626 if (((prBot->used + 4) > prBot->allocated) &&
627 (!ExtendRList (prBot, (unsigned int) RLIST_EXTENSION_SIZE)))
632 piBot = &(prBot->used);
633 prect = &(prBot->prect[*piBot]); /* bottom shadow parts */
637 prect->x = x+cwidth-swidth+((wmGD.frameStyle == WmSLAB)? 0 : 1);
638 prect->y = y+cheight-1;
639 prect->width = swidth-((wmGD.frameStyle == WmSLAB)? 0 : 1);
644 prect->x = x+cwidth-1; /* right (col 2) */
647 prect->height = cheight-2;
651 prect->x = x+cwidth-2; /* right (col 1) */
654 prect->height = cheight-3;
658 if (wmGD.frameStyle == WmRECESSED)
660 prect->x = x+1; /* bottom inside (row 2) */
661 prect->y = y+swidth-1;
662 prect->width = cwidth-swidth;
669 case STRETCH_SOUTH_EAST:
670 if (((prTop->used + 4) > prTop->allocated) &&
671 (!ExtendRList (prTop, (unsigned int) RLIST_EXTENSION_SIZE)))
676 piTop = &(prTop->used);
677 prect = &(prTop->prect[*piTop]);
679 if (wmGD.frameStyle == WmRECESSED)
681 prect->x = x; /* top inside */
682 prect->y = y+cheight-swidth;
683 prect->width = cwidth-swidth+1;
688 prect->x = x+cwidth-swidth; /* left inside */
691 prect->height = cheight-swidth;
697 prect->x = x+cwidth-swidth+
698 ((wmGD.frameStyle == WmSLAB)? 0 : 1);
700 prect->width = swidth-2+((wmGD.frameStyle == WmSLAB)? 1 : 0);;
705 prect->x = x; /* left end */
706 prect->y = y+cheight-swidth+
707 ((wmGD.frameStyle == WmSLAB)? 0 : 1);
709 prect->height = swidth-2+((wmGD.frameStyle == WmSLAB)? 1 : 0);
712 if (((prBot->used + 4) > prBot->allocated) &&
713 (!ExtendRList (prBot, (unsigned int) RLIST_EXTENSION_SIZE)))
718 piBot = &(prBot->used);
719 prect = &(prBot->prect[*piBot]); /* bottom shadow parts */
722 prect->x = x+1; /* bottom - row 1 */
723 prect->y = y+cheight-2;
724 prect->width = cwidth-1;
729 prect->x = x; /* bottom - row 2 */
730 prect->y = y+cheight-1;
731 prect->width = cwidth;
736 prect->x = x+cwidth-2; /* right - column 1 */
739 prect->height = cheight-3;
743 prect->x = x+cwidth-1; /* right - column 2 */
746 prect->height = cheight-2;
751 case STRETCH_SOUTH_WEST:
752 if (((prTop->used + 4) > prTop->allocated) &&
753 (!ExtendRList (prTop, (unsigned int) RLIST_EXTENSION_SIZE)))
758 piTop = &(prTop->used);
759 prect = &(prTop->prect[*piTop]);
761 prect->x = x; /* top end */
763 prect->width = swidth;
768 prect->x = x; /* left (col 1) */
771 prect->height = cheight-1;
775 prect->x = x+1; /* left (col 2) */
778 prect->height = cheight-2;
782 if (wmGD.frameStyle == WmRECESSED)
784 prect->x = x+swidth; /* top inside (row 2) */
785 prect->y = y+cheight-swidth;
786 prect->width = cwidth-swidth;
791 if (((prBot->used + 4) > prBot->allocated) &&
792 (!ExtendRList (prBot, (unsigned int) RLIST_EXTENSION_SIZE)))
797 piBot = &(prBot->used);
798 prect = &(prBot->prect[*piBot]); /* bottom shadow parts */
801 if (wmGD.frameStyle == WmRECESSED)
803 prect->x = x+swidth-1; /* right inside (col 2) */
806 prect->height = cheight-swidth;
811 prect->x = x+cwidth-1; /* right end */
812 prect->y = y+cheight-swidth+
813 ((wmGD.frameStyle == WmSLAB)? 0 : 1);
815 prect->height = swidth-((wmGD.frameStyle == WmSLAB)? 0 : 1);
819 prect->x = x+2; /* bottom (row 1) */
820 prect->y = y+cheight-2;
821 prect->width = cwidth-3;
826 prect->x = x+1; /* bottom (row 2) */
827 prect->y = y+cheight-1;
828 prect->width = cwidth-2;
834 } /* END OF FUNCTION StretcherCorner */
838 /*************************************<->*************************************
840 * DrawStringInBox (dpy, win, gc, pbox, str)
845 * Draws a null-terminated string inside the specified box (rectangle)
850 * dpy - ptr to Display
852 * gc - graphics context to use
853 * pfs - pointer to XFontStruct for the font in "gc"
854 * pbox - ptr to XRectangle that encloses text
855 * str - String to write
863 * o Assumes 8-bit text for now.
865 * get length of String
866 * if String is short than box width then
867 * draw string centered in box
869 * draw string left justified and clipped to box
870 * o The clip_x_origin, clip_y_origin, and clip_mask are reset to None
872 * o Due to bugs and / or misunderstanding, I gave up on trying to
873 * extract the XFontStruct from the GC. I just made it a separate
876 *************************************<->***********************************/
877 void DrawStringInBox (Display *dpy, Window win, GC gc, XFontStruct *pfs, XRectangle *pbox, String str)
884 /* compute text position */
885 textWidth = XTextWidth(pfs, str, strlen(str));
887 if (textWidth < (int) pbox->width) { /* center text if there's room */
888 xCenter = (int) pbox->x + ((int) pbox->width - textWidth) / 2 ;
889 WmDrawString(dpy, win, gc, xCenter, (pbox->y + pfs->ascent),
892 else { /* left justify & clip text */
893 clipBox.x = 0; /* set up clip rectangle */
895 clipBox.width = pbox->width;
896 clipBox.height = pbox->height;
898 XSetClipRectangles (dpy, gc, pbox->x, pbox->y, /* put into gc */
899 &clipBox, 1, Unsorted);
901 WmDrawString(dpy, win, gc, pbox->x, (pbox->y + pfs->ascent),
904 gcv.clip_x_origin = 0; /* erase clip_mask from gc */
905 gcv.clip_y_origin = 0;
906 gcv.clip_mask = None;
908 GCClipXOrigin | GCClipYOrigin | GCClipMask, &gcv);
910 } /* END OF FUNCTION DrawStringInBox */
915 /*************************************<->*************************************
917 * ExtendRList (prl, amt)
922 * Extends the size of the RList
927 * prl - ptr to Display
928 * amt - how much to extend it by
932 * Returns True if succeeded, false otherwise.
937 *************************************<->***********************************/
938 Boolean ExtendRList (RList *prl, unsigned int amt)
940 unsigned int total, count;
941 XRectangle *pNewRect;
945 total = prl->allocated + amt;
946 if ( (pNewRect = (XRectangle *) XtMalloc (total * sizeof(XRectangle)))
949 Warning (((char *)GETMESSAGE(28, 1, "Insufficient memory for graphics data")));
954 prl->allocated = total;
957 if (prl->used != 0) { /* copy from old structure */
958 count = prl->used * sizeof(XRectangle);
959 (void) memcpy ((void *)pNewRect, (void *)prl->prect, count);
960 if (prl->prect != NULL)
961 XtFree ((char *)prl->prect);
962 prl->prect = pNewRect;
966 } /* END OF FUNCTION ExtendRList */
970 /*************************************<->*************************************
972 * AllocateRList (amt)
977 * Allocates an RList of size "amt"
982 * amt - number of XRectangles to allocate in list
986 * Returns ptr to new RList structure if success, returns NULL ptr otherwise
991 *************************************<->***********************************/
992 RList *AllocateRList (amt)
999 if ((prl = (RList *) XtMalloc (sizeof (RList))) != NULL)
1001 if ( (prl->prect = (XRectangle *) XtMalloc (amt * sizeof(XRectangle)))
1004 XtFree ((char *)prl);
1009 prl->allocated = amt;
1016 } /* END OF FUNCTION AllocateRList */
1020 /*************************************<->*************************************
1032 * prl - ptr to RList to free
1040 *************************************<->***********************************/
1041 void FreeRList (RList *prl)
1046 XtFree ((char *)prl->prect);
1048 XtFree ((char *)prl);
1050 }/* END OF FUNCTION FreeRList */
1053 /*************************************<->*************************************
1065 * (same parameters used by XDrawString and XDrawImageString)
1072 * o If wmGD.cleanText is True, then the text is drawn using
1073 * XDrawImageString. This provides some clean space around the text
1074 * if the background area is stippled -- especially useful on
1077 *************************************<->***********************************/
1078 void WmDrawString (Display *dpy, Drawable d, GC gc, int x, int y, char *string, unsigned int length)
1080 if (ACTIVE_PSD->cleanText)
1082 XDrawImageString(dpy, d, gc, x, y, string, length);
1086 XDrawString(dpy, d, gc, x, y, string, length);
1089 }/* END OF FUNCTION WmDrawString */
1093 /*************************************<->*************************************
1105 * (subset of parameters used by XmStringDraw and XmStringDrawImage)
1112 * o If wmGD.cleanText is True, then the text is drawn using
1113 * XmStringDrawImage. This provides some clean space around the text
1114 * if the background area is stippled -- especially useful on
1117 *************************************<->***********************************/
1119 void WmDrawXmString (Display *dpy, Window w, XmFontList xmfontlist,
1120 XmString xmstring, GC gc, Position x, Position y,
1121 Dimension width, XRectangle *pbox, Boolean bCenter)
1123 void WmDrawXmString (Display *dpy, Window w, XmFontList xmfontlist,
1124 XmString xmstring, GC gc, Position x, Position y,
1125 Dimension width, XRectangle *pbox)
1128 Dimension textWidth;
1132 int alignment = XmALIGNMENT_BEGINNING;
1136 textWidth = XmStringWidth(xmfontlist, xmstring);
1139 alignment = bCenter ? XmALIGNMENT_CENTER : XmALIGNMENT_BEGINNING;
1141 if (textWidth >= pbox->width) /* can't center text if no room */
1142 { /* left justify & clip text */
1143 alignment = XmALIGNMENT_BEGINNING;
1146 if (textWidth < pbox->width) { /* center text if there's room */
1147 alignment = XmALIGNMENT_CENTER;
1150 { /* left justify & clip text */
1151 alignment = XmALIGNMENT_BEGINNING;
1155 if (ACTIVE_PSD->cleanText)
1157 XmStringDrawImage(dpy, w, xmfontlist, xmstring, gc, x, y, width,
1158 alignment, XmSTRING_DIRECTION_L_TO_R,
1163 XmStringDraw (dpy, w, xmfontlist, xmstring, gc, x, y, width,
1164 alignment, XmSTRING_DIRECTION_L_TO_R, pbox);
1166 } /* END OF FUNCTION WmDrawXmString */
1170 /*************************************<->*************************************
1172 * WmInstallBitmapIntoXmCache (pchName, bitmap, width, height)
1177 * Installs all or part of a pixmap into the Xm cache. This pixmap
1178 * may be retrieved later by a call to XmGetPixmap.
1182 * pchName = pointer to name of bitmap
1183 * bitmap = depth-1 pixmap
1184 * width = width of portion to install
1185 * height = height of portion to install
1193 * This always installs the Northwest corner of the passed in bitmap.
1194 * If the width and height match the size of the bitmap, then the
1195 * whole thing is installed in the cache.
1197 *************************************<->***********************************/
1198 void WmInstallBitmapIntoXmCache (unsigned char *pchName,
1199 Pixmap bitmap, unsigned int width, unsigned int height)
1203 pImage = XGetImage (DISPLAY, bitmap, 0, 0, width, height, 1L, XYBitmap);
1205 XmInstallImage (pImage, (char *)pchName);
1206 } /* END OF FUNCTION WmInstallBitmapIntoXmCache */
1210 /*************************************<->*************************************
1212 * WmInstallBitmapDataIntoXmCache (pSD, pchName, pData)
1217 * Installs built-in bitmap data into the Xm Pixmap cache. The image
1218 * may be retrieved later by a call to XmGetPixmap.
1222 * pSD = pointer to screen data
1223 * pchName = pointer to name of bitmap
1224 * pData = pointer to the bitmap data
1232 * This is principally for putting built-in pixmap data into the Xm
1233 * cache to allow for uniform access to pixmap creation.
1236 * Do NOT call XmDestroyPixmap on images cached via this routine unless
1237 * pData passed in points to malloc'ed memory. XmDestroyPixmap could
1238 * try to free this data.
1240 *************************************<->***********************************/
1241 void WmInstallBitmapDataIntoXmCache (WmScreenData *pSD,
1242 unsigned char *pchName, char *pData, unsigned int width,
1243 unsigned int height)
1247 if ((pImage = (XImage *) XtMalloc (sizeof (XImage))))
1249 pImage->width = width;
1250 pImage->height = height;
1251 pImage->xoffset = 0;
1252 pImage->data = pData;
1253 pImage->format = XYBitmap;
1254 pImage->byte_order = MSBFirst;
1255 pImage->bitmap_pad = 8;
1256 pImage->bitmap_bit_order = LSBFirst;
1257 pImage->bitmap_unit = 8;
1259 pImage->bytes_per_line = (width/8) + ((width%8) != 0 ? 1 : 0);
1260 pImage->obdata = NULL;
1262 XmInstallImage(pImage, (char *)pchName);
1265 } /* END OF FUNCTION WmInstallBitmapDataIntoXmCache */