9 W_DrawRelief(W_Screen
*scr
, Drawable d
, int x
, int y
, unsigned int width
,
10 unsigned int height
, WMReliefType relief
)
12 Display
*dpy
= scr
->display
;
20 XDrawRectangle(dpy
, d
, WMColorGC(scr
->black
), x
, y
, width
-1, height
-1);
25 bgc
= WMColorGC(scr
->black
);
26 dgc
= WMColorGC(scr
->darkGray
);
27 wgc
= WMColorGC(scr
->white
);
28 lgc
= WMColorGC(scr
->gray
);
32 wgc
= WMColorGC(scr
->darkGray
);
33 lgc
= WMColorGC(scr
->black
);
34 bgc
= WMColorGC(scr
->white
);
35 dgc
= WMColorGC(scr
->gray
);
39 lgc
= wgc
= WMColorGC(scr
->black
);
40 dgc
= bgc
= WMColorGC(scr
->white
);
44 lgc
= bgc
= WMColorGC(scr
->darkGray
);
45 dgc
= wgc
= WMColorGC(scr
->white
);
49 wgc
= dgc
= WMColorGC(scr
->darkGray
);
50 lgc
= bgc
= WMColorGC(scr
->white
);
57 XDrawLine(dpy
, d
, wgc
, x
, y
, x
+width
-1, y
);
58 if (width
> 2 && relief
!= WRRaised
&& relief
!=WRPushed
) {
59 XDrawLine(dpy
, d
, lgc
, x
+1, y
+1, x
+width
-3, y
+1);
62 XDrawLine(dpy
, d
, wgc
, x
, y
, x
, y
+height
-1);
63 if (height
> 2 && relief
!= WRRaised
&& relief
!=WRPushed
) {
64 XDrawLine(dpy
, d
, lgc
, x
+1, y
+1, x
+1, y
+height
-3);
68 XDrawLine(dpy
, d
, bgc
, x
, y
+height
-1, x
+width
-1, y
+height
-1);
69 if (width
> 2 && relief
!=WRPushed
) {
70 XDrawLine(dpy
, d
, dgc
, x
+1, y
+height
-2, x
+width
-2, y
+height
-2);
73 XDrawLine(dpy
, d
, bgc
, x
+width
-1, y
, x
+width
-1, y
+height
-1);
74 if (height
> 2 && relief
!=WRPushed
) {
75 XDrawLine(dpy
, d
, dgc
, x
+width
-2, y
+1, x
+width
-2, y
+height
-2);
81 fitText(char *text
, WMFont
*font
, int width
, int wrap
)
92 w
= WMWidthOfString(font
, text
, i
);
93 } while (w
< width
&& text
[i
]!='\n' && text
[i
]!=0);
95 /* keep words complete */
96 if (!isspace(text
[i
])) {
98 while (j
>1 && !isspace(text
[j
]) && text
[j
]!=0)
104 while (text
[i
]!='\n' && text
[i
]!=0)
113 W_GetTextHeight(WMFont
*font
, char *text
, int width
, int wrap
)
117 int length
= strlen(text
);
119 int fheight
= WMFontHeight(font
);
123 count
= fitText(ptr
, font
, width
, wrap
);
127 if (isspace(ptr
[count
]))
138 W_PaintText(W_View
*view
, Drawable d
, WMFont
*font
, int x
, int y
,
139 int width
, WMAlignment alignment
, GC gc
,
140 int wrap
, char *text
, int length
)
146 int fheight
= WMFontHeight(font
);
149 count
= fitText(ptr
, font
, width
, wrap
);
151 line_width
= WMWidthOfString(font
, ptr
, count
);
152 if (alignment
==WALeft
)
154 else if (alignment
==WARight
)
155 line_x
= x
+ width
- line_width
;
157 line_x
= x
+ (width
- line_width
) / 2;
159 WMDrawString(view
->screen
, d
, gc
, font
, line_x
, y
, ptr
, count
);
163 if (isspace(ptr
[count
]))
173 W_PaintTextAndImage(W_View
*view
, int wrap
, GC textGC
, W_Font
*font
,
174 WMReliefType relief
, char *text
,
175 WMAlignment alignment
, W_Pixmap
*image
,
176 WMImagePosition position
, GC backGC
, int ofs
)
178 W_Screen
*screen
= view
->screen
;
181 Drawable d
= view
->window
;
185 d
= XCreatePixmap(screen
->display
, view
->window
,
186 view
->size
.width
, view
->size
.height
, screen
->depth
);
190 #ifndef DOUBLE_BUFFER
192 XFillRectangle(screen
->display
, d
, backGC
,
193 0, 0, view
->size
.width
, view
->size
.height
);
195 XClearWindow(screen
->display
, d
);
199 XFillRectangle(screen
->display
, d
, backGC
, 0, 0,
200 view
->size
.width
, view
->size
.height
);
202 XSetForeground(screen
->display
, screen
->copyGC
,
203 view
->attribs
.background_pixel
);
204 XFillRectangle(screen
->display
, d
, screen
->copyGC
, 0, 0,
205 view
->size
.width
, view
->size
.height
);
210 if (relief
== WRFlat
) {
213 w
= view
->size
.width
;
214 h
= view
->size
.height
;
218 w
= view
->size
.width
- 4;
219 h
= view
->size
.height
- 4;
222 /* calc. image alignment */
223 if (position
!=WIPNoImage
&& image
!=NULL
) {
227 ix
= (view
->size
.width
- image
->width
) / 2;
228 iy
= (view
->size
.height
- image
->height
) / 2;
237 iy
= y
+ (h
- image
->height
) / 2;
238 x
= x
+ image
->width
+ 5;
240 w
-= image
->width
+ 5;
244 ix
= view
->size
.width
- image
->width
- x
;
245 iy
= y
+ (h
- image
->height
) / 2;
246 w
-= image
->width
+ 5;
250 ix
= (view
->size
.width
- image
->width
) / 2;
251 iy
= h
- image
->height
;
258 ix
= (view
->size
.width
- image
->width
) / 2;
268 XSetClipOrigin(screen
->display
, screen
->clipGC
, ix
, iy
);
269 XSetClipMask(screen
->display
, screen
->clipGC
, image
->mask
);
272 XCopyPlane(screen
->display
, image
->pixmap
, d
, screen
->clipGC
,
273 0, 0, image
->width
, image
->height
, ix
, iy
, 1);
275 XCopyArea(screen
->display
, image
->pixmap
, d
, screen
->clipGC
,
276 0, 0, image
->width
, image
->height
, ix
, iy
);
280 if (position
!= WIPImageOnly
&& text
!=NULL
) {
283 textHeight
= W_GetTextHeight(font
, text
, w
-8, wrap
);
284 W_PaintText(view
, d
, font
, x
+ofs
+4, y
+ofs
+ (h
-textHeight
)/2, w
-8,
285 alignment
, textGC
, wrap
, text
, strlen(text
));
290 W_DrawRelief(screen
, d
, 0, 0, view
->size
.width
, view
->size
.height
, relief
);
293 XCopyArea(screen
->display
, d
, view
->window
, screen
->copyGC
, 0, 0,
294 view
->size
.width
, view
->size
.height
, 0, 0);
295 XFreePixmap(screen
->display
, d
);