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
)
104 w
= WMWidthOfString(font
, text
, i
);
105 } while (w
< width
&& text
[i
]!='\n' && text
[i
]!=0);
107 /* keep words complete */
108 if (!isspace(text
[i
])) {
110 while (j
>1 && !isspace(text
[j
]) && text
[j
]!=0)
116 while (text
[i
]!='\n' && text
[i
]!=0)
125 W_GetTextHeight(WMFont
*font
, char *text
, int width
, int wrap
)
129 int length
= strlen(text
);
131 int fheight
= WMFontHeight(font
);
135 count
= fitText(ptr
, font
, width
, wrap
);
139 if (isspace(ptr
[count
]))
150 W_PaintText(W_View
*view
, Drawable d
, WMFont
*font
, int x
, int y
,
151 int width
, WMAlignment alignment
, GC gc
,
152 int wrap
, char *text
, int length
)
158 int fheight
= WMFontHeight(font
);
161 count
= fitText(ptr
, font
, width
, wrap
);
163 line_width
= WMWidthOfString(font
, ptr
, count
);
164 if (alignment
==WALeft
)
166 else if (alignment
==WARight
)
167 line_x
= x
+ width
- line_width
;
169 line_x
= x
+ (width
- line_width
) / 2;
171 WMDrawString(view
->screen
, d
, gc
, font
, line_x
, y
, ptr
, count
);
175 if (isspace(ptr
[count
]))
185 W_PaintTextAndImage(W_View
*view
, int wrap
, GC textGC
, W_Font
*font
,
186 WMReliefType relief
, char *text
,
187 WMAlignment alignment
, W_Pixmap
*image
,
188 WMImagePosition position
, GC backGC
, int ofs
)
190 W_Screen
*screen
= view
->screen
;
193 Drawable d
= view
->window
;
197 d
= XCreatePixmap(screen
->display
, view
->window
,
198 view
->size
.width
, view
->size
.height
, screen
->depth
);
202 #ifndef DOUBLE_BUFFER
204 XFillRectangle(screen
->display
, d
, backGC
,
205 0, 0, view
->size
.width
, view
->size
.height
);
207 XClearWindow(screen
->display
, d
);
211 XFillRectangle(screen
->display
, d
, backGC
, 0, 0,
212 view
->size
.width
, view
->size
.height
);
214 XSetForeground(screen
->display
, screen
->copyGC
,
215 view
->attribs
.background_pixel
);
216 XFillRectangle(screen
->display
, d
, screen
->copyGC
, 0, 0,
217 view
->size
.width
, view
->size
.height
);
222 if (relief
== WRFlat
) {
225 w
= view
->size
.width
;
226 h
= view
->size
.height
;
230 w
= view
->size
.width
- 4;
231 h
= view
->size
.height
- 4;
234 /* calc. image alignment */
235 if (position
!=WIPNoImage
&& image
!=NULL
) {
239 ix
= (view
->size
.width
- image
->width
) / 2;
240 iy
= (view
->size
.height
- image
->height
) / 2;
249 iy
= y
+ (h
- image
->height
) / 2;
250 x
= x
+ image
->width
+ 5;
252 w
-= image
->width
+ 5;
256 ix
= view
->size
.width
- image
->width
- x
;
257 iy
= y
+ (h
- image
->height
) / 2;
258 w
-= image
->width
+ 5;
262 ix
= (view
->size
.width
- image
->width
) / 2;
263 iy
= h
- image
->height
;
270 ix
= (view
->size
.width
- image
->width
) / 2;
280 XSetClipOrigin(screen
->display
, screen
->clipGC
, ix
, iy
);
281 XSetClipMask(screen
->display
, screen
->clipGC
, image
->mask
);
284 XCopyPlane(screen
->display
, image
->pixmap
, d
, screen
->clipGC
,
285 0, 0, image
->width
, image
->height
, ix
, iy
, 1);
287 XCopyArea(screen
->display
, image
->pixmap
, d
, screen
->clipGC
,
288 0, 0, image
->width
, image
->height
, ix
, iy
);
292 if (position
!= WIPImageOnly
&& text
!=NULL
) {
295 textHeight
= W_GetTextHeight(font
, text
, w
-8, wrap
);
296 W_PaintText(view
, d
, font
, x
+ofs
+4, y
+ofs
+ (h
-textHeight
)/2, w
-8,
297 alignment
, textGC
, wrap
, text
, strlen(text
));
302 W_DrawRelief(screen
, d
, 0, 0, view
->size
.width
, view
->size
.height
, relief
);
305 XCopyArea(screen
->display
, d
, view
->window
, screen
->copyGC
, 0, 0,
306 view
->size
.width
, view
->size
.height
, 0, 0);
307 XFreePixmap(screen
->display
, d
);
314 wmkrange(int start
, int count
)
318 range
.position
= start
;
326 wmkpoint(int x
, int y
)
338 wmksize(unsigned int width
, unsigned int height
)
343 size
.height
= height
;