9 W_DrawRelief(W_Screen
*scr
, Drawable d
, int x
, int y
, unsigned int width
,
10 unsigned int height
, WMReliefType relief
)
12 W_DrawReliefWithGC(scr
, d
, x
, y
, width
, height
, relief
,
13 WMColorGC(scr
->black
), WMColorGC(scr
->darkGray
),
14 WMColorGC(scr
->gray
), WMColorGC(scr
->white
));
19 W_DrawReliefWithGC(W_Screen
*scr
, Drawable d
, int x
, int y
, unsigned int width
,
20 unsigned int height
, WMReliefType relief
,
21 GC black
, GC dark
, GC light
, GC white
)
23 Display
*dpy
= scr
->display
;
31 XDrawRectangle(dpy
, d
, black
, x
, y
, width
-1, height
-1);
67 XDrawLine(dpy
, d
, wgc
, x
, y
, x
+width
-1, y
);
68 if (width
> 2 && relief
!= WRRaised
&& relief
!=WRPushed
) {
69 XDrawLine(dpy
, d
, lgc
, x
+1, y
+1, x
+width
-3, y
+1);
72 XDrawLine(dpy
, d
, wgc
, x
, y
, x
, y
+height
-1);
73 if (height
> 2 && relief
!= WRRaised
&& relief
!=WRPushed
) {
74 XDrawLine(dpy
, d
, lgc
, x
+1, y
+1, x
+1, y
+height
-3);
78 XDrawLine(dpy
, d
, bgc
, x
, y
+height
-1, x
+width
-1, y
+height
-1);
79 if (width
> 2 && relief
!=WRPushed
) {
80 XDrawLine(dpy
, d
, dgc
, x
+1, y
+height
-2, x
+width
-2, y
+height
-2);
83 XDrawLine(dpy
, d
, bgc
, x
+width
-1, y
, x
+width
-1, y
+height
-1);
84 if (height
> 2 && relief
!=WRPushed
) {
85 XDrawLine(dpy
, d
, dgc
, x
+width
-2, y
+1, x
+width
-2, y
+height
-2);
93 fitText(char *text
, WMFont
*font
, int width
, int wrap
)
108 w
= WMWidthOfString(font
, text
, i
);
109 } while (w
< width
&& text
[i
]!='\n' && text
[i
]!=0);
114 /* keep words complete */
115 if (!isspace(text
[i
])) {
117 while (j
>1 && !isspace(text
[j
]) && text
[j
]!=0)
123 while (text
[i
]!='\n' && text
[i
]!=0)
131 W_GetTextHeight(WMFont
*font
, char *text
, int width
, int wrap
)
135 int length
= strlen(text
);
137 int fheight
= WMFontHeight(font
);
141 count
= fitText(ptr
, font
, width
, wrap
);
145 if (isspace(ptr
[count
]))
156 W_PaintText(W_View
*view
, Drawable d
, WMFont
*font
, int x
, int y
,
157 int width
, WMAlignment alignment
, GC gc
,
158 int wrap
, char *text
, int length
)
164 int fheight
= WMFontHeight(font
);
167 count
= fitText(ptr
, font
, width
, wrap
);
169 line_width
= WMWidthOfString(font
, ptr
, count
);
170 if (alignment
==WALeft
)
172 else if (alignment
==WARight
)
173 line_x
= x
+ width
- line_width
;
175 line_x
= x
+ (width
- line_width
) / 2;
177 WMDrawString(view
->screen
, d
, gc
, font
, line_x
, y
, ptr
, count
);
181 if (isspace(ptr
[count
]))
191 W_PaintTextAndImage(W_View
*view
, int wrap
, GC textGC
, W_Font
*font
,
192 WMReliefType relief
, char *text
,
193 WMAlignment alignment
, W_Pixmap
*image
,
194 WMImagePosition position
, GC backGC
, int ofs
)
196 W_Screen
*screen
= view
->screen
;
199 Drawable d
= view
->window
;
203 d
= XCreatePixmap(screen
->display
, view
->window
,
204 view
->size
.width
, view
->size
.height
, screen
->depth
);
208 #ifndef DOUBLE_BUFFER
210 XFillRectangle(screen
->display
, d
, backGC
,
211 0, 0, view
->size
.width
, view
->size
.height
);
213 XClearWindow(screen
->display
, d
);
217 XFillRectangle(screen
->display
, d
, backGC
, 0, 0,
218 view
->size
.width
, view
->size
.height
);
220 XSetForeground(screen
->display
, screen
->copyGC
,
221 view
->attribs
.background_pixel
);
222 XFillRectangle(screen
->display
, d
, screen
->copyGC
, 0, 0,
223 view
->size
.width
, view
->size
.height
);
228 if (relief
== WRFlat
) {
231 w
= view
->size
.width
;
232 h
= view
->size
.height
;
236 w
= view
->size
.width
- 4;
237 h
= view
->size
.height
- 4;
240 /* calc. image alignment */
241 if (position
!=WIPNoImage
&& image
!=NULL
) {
245 ix
= (view
->size
.width
- image
->width
) / 2;
246 iy
= (view
->size
.height
- image
->height
) / 2;
255 iy
= y
+ (h
- image
->height
) / 2;
256 x
= x
+ image
->width
+ 5;
258 w
-= image
->width
+ 5;
262 ix
= view
->size
.width
- image
->width
- x
;
263 iy
= y
+ (h
- image
->height
) / 2;
264 w
-= image
->width
+ 5;
268 ix
= (view
->size
.width
- image
->width
) / 2;
269 iy
= h
- image
->height
;
276 ix
= (view
->size
.width
- image
->width
) / 2;
286 XSetClipOrigin(screen
->display
, screen
->clipGC
, ix
, iy
);
287 XSetClipMask(screen
->display
, screen
->clipGC
, image
->mask
);
290 XCopyPlane(screen
->display
, image
->pixmap
, d
, screen
->clipGC
,
291 0, 0, image
->width
, image
->height
, ix
, iy
, 1);
293 XCopyArea(screen
->display
, image
->pixmap
, d
, screen
->clipGC
,
294 0, 0, image
->width
, image
->height
, ix
, iy
);
298 if (position
!= WIPImageOnly
&& text
!=NULL
) {
301 textHeight
= W_GetTextHeight(font
, text
, w
-8, wrap
);
302 W_PaintText(view
, d
, font
, x
+ofs
+4, y
+ofs
+ (h
-textHeight
)/2, w
-8,
303 alignment
, textGC
, wrap
, text
, strlen(text
));
308 W_DrawRelief(screen
, d
, 0, 0, view
->size
.width
, view
->size
.height
, relief
);
311 XCopyArea(screen
->display
, d
, view
->window
, screen
->copyGC
, 0, 0,
312 view
->size
.width
, view
->size
.height
, 0, 0);
313 XFreePixmap(screen
->display
, d
);
320 wmkrange(int start
, int count
)
324 range
.position
= start
;
332 wmkpoint(int x
, int y
)
344 wmksize(unsigned int width
, unsigned int height
)
349 size
.height
= height
;