original 1.0.1 release
[xwelltris.git] / src / wellimagefont.cxx
blob5850f3bba0e46cadf230f4d436653d70e8141bb7
1 // docm_prefix(///)
2 /****************************************************************************
3 * Copyright (C) 2002 by Leo Khramov
4 * email: leo@xnc.dubna.su
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 ****************************************************************************/
16 // $Id: wellimagefont.cxx,v 1.1.1.1 2003/01/04 11:37:22 leo Exp $
18 #include "wellimagefont.h"
20 //===========================================================================
21 /// global WellImageFont(Images id, unsigned int ifl, unsigned int ifh, int idx, int idy)
22 /// Constructor of base draw text class
23 /// tags WellImageFont
24 WellImageFont::WellImageFont(Images id, unsigned int ifl, unsigned int ifh,
25 int idx, int idy)
27 font_id=id;
28 font_l=ifl;
29 font_h=ifh;
30 dx=idx;
31 dy=idy;
32 text_l=0;
35 //===========================================================================
36 /// global set_font(...)
37 /// setting font params
38 /// tags WellImageFont
39 void WellImageFont::set_font(unsigned int ifl, unsigned int ifh,
40 int idx, int idy)
42 font_l=ifl;
43 font_h=ifh;
44 dx=idx;
45 dy=idy;
48 //===========================================================================
49 /// global set_text(char*)
50 /// setting text for output
51 /// tags WellImageFont
52 void WellImageFont::set_text(char* itext)
54 strcpy(text,itext);
55 text_l=strlen(text);
59 //===========================================================================
60 /// global set_screen_region(int ix, int iy, int il, int ih)
61 /// setting text for output
62 /// tags WellImageFont
63 void WellImageFont::set_screen_region(int ix, int iy, int il, int ih)
65 screen_x=ix;
66 screen_y=iy;
67 screen_l=il;
68 screen_h=ih;
72 //===========================================================================
73 /// global draw_text(Justify just)
74 /// draw text with given justification
75 /// tags WellImageFont
76 void WellImageFont::draw_text(Justify just)
78 draw_text(text,text_l,just);
81 //===========================================================================
82 /// global draw_text(char *text, int text_l, Justify just)
83 /// draw text with given justification
84 /// tags WellImageFont
85 void WellImageFont::draw_text(char* txt, int txt_l, Justify just)
87 int i,draw_x;
88 unsigned int draw_h;
90 clear_region();
91 if(txt_l<=0)
92 return;
94 switch(just)
96 case LeftJust:
97 draw_x=screen_x;
98 break;
99 case RightJust:
100 draw_x=screen_x+screen_l-txt_l*font_l;
101 break;
102 case CenterJust:
103 draw_x=screen_x+(screen_l-txt_l*font_l)/2;
104 break;
106 draw_h=(screen_h<font_h ? screen_h : font_h);
107 for(i=0;i<txt_l;i++)
108 draw_symbol(draw_x+font_l*i,screen_y,font_l,draw_h,txt[i]);
111 //===========================================================================
112 /// global draw_text(char *text, int text_l, Justify just)
113 /// draw text with given justification
114 /// tags WellImageFont
115 void WellImageFont::draw_text(char* txt, int txt_l, Colors idx, Justify just)
117 int i,draw_x;
118 unsigned int draw_h;
120 clear_region(idx);
121 if(txt_l<=0)
122 return;
124 switch(just)
126 case LeftJust:
127 draw_x=screen_x;
128 break;
129 case RightJust:
130 draw_x=screen_x+screen_l-txt_l*font_l;
131 break;
132 case CenterJust:
133 draw_x=screen_x+(screen_l-txt_l*font_l)/2;
134 break;
136 draw_h=(screen_h<font_h ? screen_h : font_h);
137 for(i=0;i<txt_l;i++)
138 draw_symbol(draw_x+font_l*i,screen_y,font_l,draw_h,txt[i]);