3 /* Copyright (C) 2002 Brad Jorsch <anomie@users.sourceforge.net>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
28 #include "wmgeneral/wmgeneral-x11.h"
33 #include "characters.xpm"
35 static Pixmap fonts
[3]={ None
, None
, None
};
36 static char *colors
[3][4]={
37 { "#000000", "#0C4E66", "#127599", "#1EC3FF" },
38 { "#000000", "#664D0B", "#997411", "#FFC21D" },
39 { "#000000", "#662B31", "#99414A", "#FF6D7B" }
42 void init_font(int i
){
44 XpmColorSymbol cols
[4]={
45 {"Background", NULL
, 0},
52 if(fonts
[i
]!=None
) return;
54 cols
[j
].pixel
=GetColor(colors
[i
][j
]);
56 x
.attributes
.numsymbols
=5;
57 x
.attributes
.colorsymbols
=cols
;
58 x
.attributes
.exactColors
=False
;
59 x
.attributes
.closeness
=40000;
60 x
.attributes
.valuemask
=(XpmColorSymbols
| XpmExactColors
| XpmCloseness
);
61 GetXPM(&x
, characters_xpm
);
63 XFreePixmap(display
, x
.mask
);
66 int DrawString(int x
, int y
, char *str
, int font
){
71 for(c
=str
; *c
!='\0'; c
++){
72 w
+=DrawChar(x
+w
, y
, *c
, font
);
79 int GetStringWidth(char *str
){
84 for(c
=str
; *c
!='\0'; c
++){
85 w
+=DrawChar(-1, -1, *c
, -1);
92 int DrawNumber(int x
, int y
, int n
, int font
){
106 DrawChar(x
-w
, y
, c
, font
);
112 DrawChar(x
-w
, y
, '-', font
);
119 int DrawChar(int x
, int y
, char c
, int font
){
124 if(c
>='A' && c
<='Z'){
126 if(c
=='M'){ w
=4; sx
=149; }
127 if(c
=='N'){ w
=4; sx
=154; }
128 if(c
=='W'){ w
=4; sx
=159; }
129 } else if(c
>='0' && c
<='9') sx
=(c
-'0')*4+105;
130 else if(c
==':'){ w
=1; sx
=164; }
131 else if(c
=='('){ w
=2; sx
=171; }
132 else if(c
==')'){ w
=2; sx
=174; }
133 else if(c
=='%') sx
=89;
134 else if(c
=='-'){ w
=2; sx
=168; }
135 else if(c
=='.'){ w
=1; sx
=166; }
136 else if(c
=='<') sx
=49;
137 else if(c
=='>') sx
=53;
138 else if(c
=='/') sx
=145;
139 else if(c
=='\''){ w
=1; sx
=177; }
142 if(x
>=0 && y
>=0 && x
+w
<192 && y
<174 && font
>=0 && font
<3){
144 XCopyArea(display
, fonts
[font
], wmgen
.pixmap
, NormalGC
, sx
, 1, w
, 5, x
, y
);