ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/xpm.C
(Generate patch)

Comparing rxvt-unicode/src/xpm.C (file contents):
Revision 1.43 by ayin, Sat Jun 30 23:31:29 2007 UTC vs.
Revision 1.44 by ayin, Sat Jun 30 23:34:57 2007 UTC

26#include "../config.h" /* NECESSARY */ 26#include "../config.h" /* NECESSARY */
27#include "rxvt.h" /* NECESSARY */ 27#include "rxvt.h" /* NECESSARY */
28 28
29#ifdef XPM_BACKGROUND 29#ifdef XPM_BACKGROUND
30 30
31/*
32 * Calculate tiling sizes and increments
33 * At start, p == 0, incr == xpmwidthheight
34 */
35static void
31static void rxvt_pixmap_incr (unsigned int *wh, unsigned int *xy, float *incr, float *p, unsigned int widthheight, unsigned int xpmwidthheight); 36rxvt_pixmap_incr (unsigned int *wh, unsigned int *xy, float *incr, float *p, unsigned int widthheight, unsigned int xpmwidthheight)
37{
38 unsigned int cwh, cxy;
39 float cincr, cp;
40
41 cp = 0;
42 cincr = (float)xpmwidthheight;
43 cxy = *xy;
44 cwh = *wh;
45 if (cwh == 1)
46 { /* display one image, no horizontal/vertical scaling */
47 cincr = (float)widthheight;
48 if (xpmwidthheight <= widthheight)
49 {
50 cwh = xpmwidthheight;
51 cxy = (cxy * (widthheight - cwh)) / 100; /* beware! order */
52 cwh += cxy;
53 }
54 else
55 {
56 cxy = 0;
57 cwh = widthheight;
58 }
59 }
60 else if (cwh < 10)
61 { /* fit WH images across/down screen */
62 cincr *= cwh;
63 cxy = 0;
64 cwh = widthheight;
65 }
66 else
67 {
68 cincr *= 100.0 / cwh;
69 if (cwh < 100)
70 { /* contract */
71 float pos;
72
73 cwh = (cwh * widthheight) / 100;
74 pos = (float)cxy / 100 * widthheight - (cwh / 2);
75
76 cxy = (widthheight - cwh);
77 if (pos <= 0)
78 cxy = 0;
79 else if (pos < cxy)
80 cxy = (int) pos;
81 cwh += cxy;
82 }
83 else
84 { /* expand */
85 if (cxy > 0)
86 { /* position */
87 float pos;
88
89 pos = (float)cxy / 100 * xpmwidthheight - (cincr / 2);
90 cp = xpmwidthheight - cincr;
91 if (pos <= 0)
92 cp = 0;
93 else if (pos < cp)
94 cp = pos;
95 }
96 cxy = 0;
97 cwh = widthheight;
98 }
99 }
100 cincr /= widthheight;
101 *wh = cwh;
102 *xy = cxy;
103 *incr = cincr;
104 *p = cp;
105}
32 106
33/* 107/*
34 * These GEOM strings indicate absolute size/position: 108 * These GEOM strings indicate absolute size/position:
35 * @ `WxH+X+Y' 109 * @ `WxH+X+Y'
36 * @ `WxH+X' -> Y = X 110 * @ `WxH+X' -> Y = X
301 375
302 XFreeGC (dpy, gc); 376 XFreeGC (dpy, gc);
303#ifdef ENABLE_TRANSPARENCY 377#ifdef ENABLE_TRANSPARENCY
304 am_transparent = 0; 378 am_transparent = 0;
305#endif 379#endif
306}
307
308/*
309 * Calculate tiling sizes and increments
310 * At start, p == 0, incr == xpmwidthheight
311 */
312static void
313rxvt_pixmap_incr (unsigned int *wh, unsigned int *xy, float *incr, float *p, unsigned int widthheight, unsigned int xpmwidthheight)
314{
315 unsigned int cwh, cxy;
316 float cincr, cp;
317
318 cp = 0;
319 cincr = (float)xpmwidthheight;
320 cxy = *xy;
321 cwh = *wh;
322 if (cwh == 1)
323 { /* display one image, no horizontal/vertical scaling */
324 cincr = (float)widthheight;
325 if (xpmwidthheight <= widthheight)
326 {
327 cwh = xpmwidthheight;
328 cxy = (cxy * (widthheight - cwh)) / 100; /* beware! order */
329 cwh += cxy;
330 }
331 else
332 {
333 cxy = 0;
334 cwh = widthheight;
335 }
336 }
337 else if (cwh < 10)
338 { /* fit WH images across/down screen */
339 cincr *= cwh;
340 cxy = 0;
341 cwh = widthheight;
342 }
343 else
344 {
345 cincr *= 100.0 / cwh;
346 if (cwh < 100)
347 { /* contract */
348 float pos;
349
350 cwh = (cwh * widthheight) / 100;
351 pos = (float)cxy / 100 * widthheight - (cwh / 2);
352
353 cxy = (widthheight - cwh);
354 if (pos <= 0)
355 cxy = 0;
356 else if (pos < cxy)
357 cxy = (int) pos;
358 cwh += cxy;
359 }
360 else
361 { /* expand */
362 if (cxy > 0)
363 { /* position */
364 float pos;
365
366 pos = (float)cxy / 100 * xpmwidthheight - (cincr / 2);
367 cp = xpmwidthheight - cincr;
368 if (pos <= 0)
369 cp = 0;
370 else if (pos < cp)
371 cp = pos;
372 }
373 cxy = 0;
374 cwh = widthheight;
375 }
376 }
377 cincr /= widthheight;
378 *wh = cwh;
379 *xy = cxy;
380 *incr = cincr;
381 *p = cp;
382} 380}
383 381
384Pixmap 382Pixmap
385rxvt_term::set_bgPixmap (const char *file) 383rxvt_term::set_bgPixmap (const char *file)
386{ 384{

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines