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 //i = strcspn(text, "\n\r");
124 while (text
[i
]!='\n' && text
[i
]!=0)
132 W_GetTextHeight(WMFont
*font
, char *text
, int width
, int wrap
)
136 int length
= strlen(text
);
138 int fheight
= WMFontHeight(font
);
142 count
= fitText(ptr
, font
, width
, wrap
);
146 if (isspace(ptr
[count
]))
157 W_PaintText(W_View
*view
, Drawable d
, WMFont
*font
, int x
, int y
,
158 int width
, WMAlignment alignment
, WMColor
*color
,
159 int wrap
, char *text
, int length
)
165 int fheight
= WMFontHeight(font
);
168 count
= fitText(ptr
, font
, width
, wrap
);
170 line_width
= WMWidthOfString(font
, ptr
, count
);
171 if (alignment
==WALeft
)
173 else if (alignment
==WARight
)
174 line_x
= x
+ width
- line_width
;
176 line_x
= x
+ (width
- line_width
) / 2;
178 WMDrawString(view
->screen
, d
, color
, font
, line_x
, y
, ptr
, count
);
180 if (wrap
&& ptr
[count
]!='\n')
183 while (ptr
[count
] && ptr
[count
]=='\n') {
195 W_PaintTextAndImage(W_View
*view
, int wrap
, WMColor
*textColor
, W_Font
*font
,
196 WMReliefType relief
, char *text
,
197 WMAlignment alignment
, W_Pixmap
*image
,
198 WMImagePosition position
, WMColor
*backColor
, int ofs
)
200 W_Screen
*screen
= view
->screen
;
203 Drawable d
= view
->window
;
207 d
= XCreatePixmap(screen
->display
, view
->window
,
208 view
->size
.width
, view
->size
.height
, screen
->depth
);
213 XFillRectangle(screen
->display
, d
, WMColorGC(backColor
),
214 0, 0, view
->size
.width
, view
->size
.height
);
216 #ifndef DOUBLE_BUFFER
217 XClearWindow(screen
->display
, d
);
219 XSetForeground(screen
->display
, screen
->copyGC
,
220 view
->attribs
.background_pixel
);
221 XFillRectangle(screen
->display
, d
, screen
->copyGC
, 0, 0,
222 view
->size
.width
, view
->size
.height
);
227 if (relief
== WRFlat
) {
230 w
= view
->size
.width
;
231 h
= view
->size
.height
;
235 w
= view
->size
.width
- 3;
236 h
= view
->size
.height
- 3;
239 /* calc. image alignment */
240 if (position
!=WIPNoImage
&& image
!=NULL
) {
244 ix
= (view
->size
.width
- image
->width
) / 2;
245 iy
= (view
->size
.height
- image
->height
) / 2;
254 iy
= y
+ (h
- image
->height
) / 2;
255 x
= x
+ image
->width
+ 5;
257 w
-= image
->width
+ 5;
261 ix
= view
->size
.width
- image
->width
- x
;
262 iy
= y
+ (h
- image
->height
) / 2;
263 w
-= image
->width
+ 5;
267 ix
= (view
->size
.width
- image
->width
) / 2;
268 iy
= h
- image
->height
;
275 ix
= (view
->size
.width
- image
->width
) / 2;
285 XSetClipOrigin(screen
->display
, screen
->clipGC
, ix
, iy
);
286 XSetClipMask(screen
->display
, screen
->clipGC
, image
->mask
);
289 XCopyPlane(screen
->display
, image
->pixmap
, d
, screen
->clipGC
,
290 0, 0, image
->width
, image
->height
, ix
, iy
, 1);
292 XCopyArea(screen
->display
, image
->pixmap
, d
, screen
->clipGC
,
293 0, 0, image
->width
, image
->height
, ix
, iy
);
297 if (position
!= WIPImageOnly
&& text
!=NULL
) {
300 textHeight
= W_GetTextHeight(font
, text
, w
-8, wrap
);
301 W_PaintText(view
, d
, font
, x
+ofs
+4, y
+ofs
+ (h
-textHeight
)/2, w
-8,
302 alignment
, textColor
, wrap
, text
, strlen(text
));
307 W_DrawRelief(screen
, d
, 0, 0, view
->size
.width
, view
->size
.height
, relief
);
310 XCopyArea(screen
->display
, d
, view
->window
, screen
->copyGC
, 0, 0,
311 view
->size
.width
, view
->size
.height
, 0, 0);
312 XFreePixmap(screen
->display
, d
);
319 wmkpoint(int x
, int y
)
331 wmksize(unsigned int width
, unsigned int height
)
336 size
.height
= height
;
343 wmkrect(int x
, int y
, unsigned int width
, unsigned int height
)
349 rect
.size
.width
= width
;
350 rect
.size
.height
= height
;