6 WMPixmap
*WMRetainPixmap(WMPixmap
* pixmap
)
14 void WMReleasePixmap(WMPixmap
* pixmap
)
16 wassertr(pixmap
!= NULL
);
20 if (pixmap
->refCount
< 1) {
22 XFreePixmap(pixmap
->screen
->display
, pixmap
->pixmap
);
24 XFreePixmap(pixmap
->screen
->display
, pixmap
->mask
);
29 WMPixmap
*WMCreatePixmap(WMScreen
* scrPtr
, int width
, int height
, int depth
, Bool masked
)
33 pixPtr
= wmalloc(sizeof(WMPixmap
));
34 pixPtr
->screen
= scrPtr
;
35 pixPtr
->width
= width
;
36 pixPtr
->height
= height
;
37 pixPtr
->depth
= depth
;
40 pixPtr
->pixmap
= XCreatePixmap(scrPtr
->display
, W_DRAWABLE(scrPtr
), width
, height
, depth
);
42 pixPtr
->mask
= XCreatePixmap(scrPtr
->display
, W_DRAWABLE(scrPtr
), width
, height
, 1);
50 WMPixmap
*WMCreatePixmapFromXPixmaps(WMScreen
* scrPtr
, Pixmap pixmap
, Pixmap mask
,
51 int width
, int height
, int depth
)
55 pixPtr
= wmalloc(sizeof(WMPixmap
));
56 pixPtr
->screen
= scrPtr
;
57 pixPtr
->pixmap
= pixmap
;
59 pixPtr
->width
= width
;
60 pixPtr
->height
= height
;
61 pixPtr
->depth
= depth
;
67 WMPixmap
*WMCreatePixmapFromFile(WMScreen
* scrPtr
, const char *fileName
)
72 image
= RLoadImage(scrPtr
->rcontext
, fileName
, 0);
76 pixPtr
= WMCreatePixmapFromRImage(scrPtr
, image
, 127);
83 WMPixmap
*WMCreatePixmapFromRImage(WMScreen
* scrPtr
, RImage
* image
, int threshold
)
88 if (!RConvertImageMask(scrPtr
->rcontext
, image
, &pixmap
, &mask
, threshold
)) {
92 pixPtr
= wmalloc(sizeof(WMPixmap
));
93 pixPtr
->screen
= scrPtr
;
94 pixPtr
->pixmap
= pixmap
;
96 pixPtr
->width
= image
->width
;
97 pixPtr
->height
= image
->height
;
98 pixPtr
->depth
= scrPtr
->depth
;
104 WMPixmap
*WMCreateBlendedPixmapFromRImage(WMScreen
* scrPtr
, RImage
* image
, const RColor
* color
)
109 copy
= RCloneImage(image
);
113 RCombineImageWithColor(copy
, color
);
114 pixPtr
= WMCreatePixmapFromRImage(scrPtr
, copy
, 0);
120 WMPixmap
*WMCreateBlendedPixmapFromFile(WMScreen
* scrPtr
, const char *fileName
, const RColor
* color
)
122 return WMCreateScaledBlendedPixmapFromFile(scrPtr
, fileName
, color
, 0, 0);
125 WMPixmap
*WMCreateScaledBlendedPixmapFromFile(WMScreen
*scrPtr
, const char *fileName
, const RColor
*color
,
126 unsigned int width
, unsigned int height
)
131 image
= RLoadImage(scrPtr
->rcontext
, fileName
, 0);
135 /* scale it if needed to fit in the specified box */
136 if ((width
> 0) && (height
> 0) && ((image
->width
> width
) || (image
->height
> height
))) {
137 int new_width
, new_height
;
140 new_width
= image
->width
;
141 new_height
= image
->height
;
142 if (new_width
> width
) {
144 new_height
= width
* image
->height
/ image
->width
;
146 if (new_height
> height
) {
147 new_width
= height
* image
->width
/ image
->height
;
151 new_image
= RScaleImage(image
, new_width
, new_height
);
152 RReleaseImage(image
);
156 RCombineImageWithColor(image
, color
);
157 pixPtr
= WMCreatePixmapFromRImage(scrPtr
, image
, 0);
158 RReleaseImage(image
);
163 WMPixmap
*WMCreatePixmapFromXPMData(WMScreen
* scrPtr
, char **data
)
168 image
= RGetImageFromXPMData(scrPtr
->rcontext
, data
);
172 pixPtr
= WMCreatePixmapFromRImage(scrPtr
, image
, 127);
174 RReleaseImage(image
);
179 Pixmap
WMGetPixmapXID(WMPixmap
* pixmap
)
181 wassertrv(pixmap
!= NULL
, None
);
183 return pixmap
->pixmap
;
186 Pixmap
WMGetPixmapMaskXID(WMPixmap
* pixmap
)
188 wassertrv(pixmap
!= NULL
, None
);
193 WMSize
WMGetPixmapSize(WMPixmap
* pixmap
)
195 WMSize size
= { 0, 0 };
197 wassertrv(pixmap
!= NULL
, size
);
199 size
.width
= pixmap
->width
;
200 size
.height
= pixmap
->height
;
205 WMPixmap
*WMGetSystemPixmap(WMScreen
* scr
, int image
)
209 return WMRetainPixmap(scr
->buttonArrow
);
211 case WSIHighlightedReturnArrow
:
212 return WMRetainPixmap(scr
->pushedButtonArrow
);
214 case WSIScrollerDimple
:
215 return WMRetainPixmap(scr
->scrollerDimple
);
218 return WMRetainPixmap(scr
->leftArrow
);
220 case WSIHighlightedArrowLeft
:
221 return WMRetainPixmap(scr
->hiLeftArrow
);
224 return WMRetainPixmap(scr
->rightArrow
);
226 case WSIHighlightedArrowRight
:
227 return WMRetainPixmap(scr
->hiRightArrow
);
230 return WMRetainPixmap(scr
->upArrow
);
232 case WSIHighlightedArrowUp
:
233 return WMRetainPixmap(scr
->hiUpArrow
);
236 return WMRetainPixmap(scr
->downArrow
);
238 case WSIHighlightedArrowDown
:
239 return WMRetainPixmap(scr
->hiDownArrow
);
242 return WMRetainPixmap(scr
->checkMark
);
249 void WMDrawPixmap(WMPixmap
* pixmap
, Drawable d
, int x
, int y
)
251 WMScreen
*scr
= pixmap
->screen
;
253 XSetClipMask(scr
->display
, scr
->clipGC
, pixmap
->mask
);
254 XSetClipOrigin(scr
->display
, scr
->clipGC
, x
, y
);
256 XCopyArea(scr
->display
, pixmap
->pixmap
, d
, scr
->clipGC
, 0, 0, pixmap
->width
, pixmap
->height
, x
, y
);