wmclockmon: update change-log
[dockapps.git] / wmframepic / src / draw_text.c
blobd09bcfc8296d0f1903fe5aec65951c276ea95182
1 #include "draw_text.h"
3 static Display *display;
4 static GC gc;
5 static Pixmap draw_area_pixmap, font_pixmap, display_text_pixmap;
6 static Window icon_window;
8 static void dockapp_copyarea(Pixmap src, Pixmap dist, int x_src, int y_src, int w,
9 int h, int x_dist, int y_dist);
10 static int offset_w, offset_h;
11 void init_variables(Display *g_display, GC g_gc, Window g_icon_window, int g_offset_w, int g_offset_h, Pixmap **background) {
12 display = g_display;
13 gc = g_gc;
14 icon_window = g_icon_window;
15 offset_h = g_offset_h;
16 offset_w = g_offset_w;
18 XpmCreatePixmapFromData(display, icon_window, display_text_xpm, &display_text_pixmap, NULL, NULL);
19 XpmCreatePixmapFromData(display, icon_window, font_xpm, &font_pixmap, NULL, NULL);
21 *background = &display_text_pixmap;
24 void restore_background() {
25 XpmCreatePixmapFromData(display, icon_window, display_text_xpm, &display_text_pixmap, NULL, NULL);
28 void flush_background() {
29 XCopyArea(display, display_text_pixmap, icon_window, gc, 0, 0, 64, 64, offset_w, offset_h);
30 XFlush(display);
34 void dockapp_copyarea(Pixmap src, Pixmap dist, int x_src, int y_src, int w,
35 int h, int x_dist, int y_dist) {
36 XCopyArea(display, src, dist, gc, x_src, y_src, w, h, x_dist, y_dist);
37 //XCopyArea(display, src, text_window, gc, x_src, y_src, w, h, x_dist, y_dist);
40 void draw_text(char *text, int dx, int dy, Bool digit) {
41 int ax, ay = 1, bx, len, i;
42 char tmptext[255] = "";
43 len = strlen(text);
44 bx = 4;
47 for (i = 0; i < len; i++) {
48 digit = (!isalpha(text[i])) ? True : False;
52 if (digit) {
53 if (len == 4)
54 dx -= 6;
55 strcat(tmptext, text);
56 if (len == 3)
57 strcat(tmptext, text);
58 if (len == 2) {
59 tmptext[0] = 0x20;
60 tmptext[1] = text[0];
61 tmptext[2] = text[1];
62 len++;
64 if (len == 1) {
65 tmptext[0] = ' ';
66 tmptext[1] = ' ';
67 tmptext[2] = text[0];
68 len += 2;
70 } else {
71 strcpy(tmptext, text);
74 for (i = 0; i < len; i++) {
75 if (isalpha(tmptext[i])) {
76 ax = ((tolower(tmptext[i]) - 97) * 6) + 1;
77 ay = 1;
78 } else {
79 ax = ((tmptext[i] - 33) * 6) + 1;
80 ay = 10;
82 /* Space */
83 if (tmptext[i] == 0x20)
84 ax = 79;
85 /* Draw Text */
86 dockapp_copyarea(font_pixmap, display_text_pixmap, ax, ay, 6, 8, dx, dy);
87 dx += 6;