annotate gui/skin/font.c @ 29263:0f1b5b68af32

whitespace cosmetics: Remove all trailing whitespace.
author diego
date Wed, 13 May 2009 02:58:57 +0000
parents b0a7b35b78d2
children 5fbb30fa62cc
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
26458
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
1 /*
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
2 * This file is part of MPlayer.
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
3 *
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
4 * MPlayer is free software; you can redistribute it and/or modify
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
5 * it under the terms of the GNU General Public License as published by
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
6 * the Free Software Foundation; either version 2 of the License, or
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
7 * (at your option) any later version.
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
8 *
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
9 * MPlayer is distributed in the hope that it will be useful,
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
12 * GNU General Public License for more details.
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
13 *
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
14 * You should have received a copy of the GNU General Public License along
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
15 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
17 */
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
18
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
19 #include <stdlib.h>
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
20 #include <stdio.h>
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
21 #include <stdarg.h>
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
22 #include <string.h>
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
23 #include <inttypes.h>
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
24
26365
10dfbc523184 Add gui/ prefix to some #include paths so that compilation from the
diego
parents: 23703
diff changeset
25 #include "gui/app.h"
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
26 #include "skin.h"
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
27 #include "font.h"
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
28 #include "cut.h"
26382
b2f4abcf20ed Make include paths consistent; do not use ../ in them.
diego
parents: 26365
diff changeset
29 #include "mp_msg.h"
b2f4abcf20ed Make include paths consistent; do not use ../ in them.
diego
parents: 26365
diff changeset
30 #include "libavutil/avstring.h"
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
31
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
32 int items;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
33
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
34 bmpFont * Fonts[26] = { NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL };
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
35
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
36 int fntAddNewFont( char * name )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
37 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
38 int id;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
39 int i;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
40
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
41 for( id=0;id<26;id++ )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
42 if ( !Fonts[id] ) break;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
43
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
44 if ( id == 25 ) return -2;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
45
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
46 if ( ( Fonts[id]=calloc( 1,sizeof( bmpFont ) ) ) == NULL ) return -1;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
47
23703
9fb716ab06a3 Avoid code duplication and ugly config.h hack by using av_strlcat/av_strlcpy
reimar
parents: 23077
diff changeset
48 av_strlcpy( Fonts[id]->name,name,128 ); // FIXME: as defined in font.h
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 26458
diff changeset
49 for ( i=0;i<256;i++ )
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
50 Fonts[id]->Fnt[i].x=Fonts[id]->Fnt[i].y=Fonts[id]->Fnt[i].sx=Fonts[id]->Fnt[i].sy=-1;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
51
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
52 return id;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
53 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
54
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
55 void fntFreeFont( void )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
56 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
57 int i;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
58 for( i=0;i < 25;i++ )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
59 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
60 if ( Fonts[i] )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
61 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
62 if ( Fonts[i]->Bitmap.Image ) free( Fonts[i]->Bitmap.Image );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
63 free( Fonts[i] );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
64 Fonts[i]=NULL;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
65 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
66 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
67 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
68
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
69 int fntRead( char * path,char * fname )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
70 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
71 FILE * f;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
72 unsigned char tmp[512];
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
73 unsigned char * ptmp;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
74 unsigned char command[32];
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
75 unsigned char param[256];
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
76 int c,linenumber = 0;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
77 int id = fntAddNewFont( fname );
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 26458
diff changeset
78
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
79 if ( id < 0 ) return id;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
80
23703
9fb716ab06a3 Avoid code duplication and ugly config.h hack by using av_strlcat/av_strlcpy
reimar
parents: 23077
diff changeset
81 av_strlcpy( tmp,path,sizeof( tmp ) );
9fb716ab06a3 Avoid code duplication and ugly config.h hack by using av_strlcat/av_strlcpy
reimar
parents: 23077
diff changeset
82 av_strlcat( tmp,fname,sizeof( tmp ) ); av_strlcat( tmp,".fnt",sizeof( tmp ) );
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 26458
diff changeset
83 if ( ( f=fopen( tmp,"rt" ) ) == NULL )
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
84 { free( Fonts[id] ); return -3; }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 26458
diff changeset
85
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
86 while ( !feof( f ) )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
87 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
88 fgets( tmp,255,f ); linenumber++;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
89
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
90 c=tmp[ strlen( tmp ) - 1 ]; if ( ( c == '\n' )||( c == '\r' ) ) tmp[ strlen( tmp ) - 1 ]=0;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
91 c=tmp[ strlen( tmp ) - 1 ]; if ( ( c == '\n' )||( c == '\r' ) ) tmp[ strlen( tmp ) - 1 ]=0;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
92 for ( c=0;c < (int)strlen( tmp );c++ )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
93 if ( tmp[c] == ';' ) { tmp[c]=0; break; }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
94 if ( !tmp[0] ) continue;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
95 ptmp=trimleft( tmp );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
96 if ( !tmp[0] ) continue;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
97 ptmp=strswap( ptmp,'\t',' ' );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
98 ptmp=trim( ptmp );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
99 cutItem( ptmp,command,'=',0 ); cutItem( ptmp,param,'=',1 );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
100 if ( command[0] == '"' )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
101 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
102 int i;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
103 cutItem( command,command,'"',1 );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
104 i=(int)command[0];
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
105 cutItem( param,tmp,',',0 ); Fonts[id]->Fnt[i].x=atoi( tmp );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
106 cutItem( param,tmp,',',1 ); Fonts[id]->Fnt[i].y=atoi( tmp );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
107 cutItem( param,tmp,',',2 ); Fonts[id]->Fnt[i].sx=atoi( tmp );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
108 cutItem( param,tmp,',',3 ); Fonts[id]->Fnt[i].sy=atoi( tmp );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
109 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[font] char: '%s' params: %d,%d %dx%d\n",command,Fonts[id]->Fnt[i].x,Fonts[id]->Fnt[i].y,Fonts[id]->Fnt[i].sx,Fonts[id]->Fnt[i].sy );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
110 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
111 else
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
112 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
113 if ( !strcmp( command,"image" ) )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
114 {
23703
9fb716ab06a3 Avoid code duplication and ugly config.h hack by using av_strlcat/av_strlcpy
reimar
parents: 23077
diff changeset
115 av_strlcpy( tmp,path,sizeof( tmp ) ); av_strlcat( tmp,param,sizeof( tmp ) );
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
116 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[font] font imagefile: %s\n",tmp );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
117 if ( skinBPRead( tmp,&Fonts[id]->Bitmap ) ) return -4;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
118 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
119 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
120 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
121
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
122 return 0;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
123 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
124
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
125 int fntFindID( char * name )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
126 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
127 int i;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
128 for ( i=0;i < 25;i++ )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
129 if ( Fonts[i] )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
130 if ( !strcmp( name,Fonts[i]->name ) ) return i;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
131 return -1;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
132 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
133
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
134 int fntTextWidth( int id,char * str )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
135 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
136 int size = 0;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
137 int i;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
138
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
139 if ( ( !Fonts[id] )||( !str[0] ) ) return 0;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
140
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
141 for ( i=0;i < (int)strlen( str );i++ )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
142 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
143 unsigned char c = (unsigned char)str[i];
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
144 if ( Fonts[id]->Fnt[c].sx == -1 ) c = ' ';
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
145 size+= Fonts[id]->Fnt[ c ].sx;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
146 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
147 return size;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
148 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
149
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
150 int fntTextHeight( int id,char * str )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
151 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
152 int max = 0,i;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
153
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
154 if ( ( !Fonts[id] )||( !str[0] ) ) return 0;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
155
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
156 for ( i=0;i < (int)strlen( str );i++ )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
157 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
158 int h;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
159 unsigned char c = (unsigned char)str[i];
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
160 if ( Fonts[id]->Fnt[c].sx == -1 ) c = ' ';
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
161 h = Fonts[id]->Fnt[c].sy;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
162 if ( h > max ) max=h;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
163 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
164 return max;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
165 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
166
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
167 txSample * fntRender( wItem * item,int px,const char * fmt,... )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
168 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
169 va_list ap;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
170 unsigned char p[512];
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
171 unsigned int c;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
172 int i, dx = 0, tw, fbw, iw, id, ofs;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
173 int x,y,fh,fw,fyc,yc;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
174 uint32_t * ibuf;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
175 uint32_t * obuf;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
176
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
177 va_start( ap,fmt );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
178 vsnprintf( p,512,fmt,ap );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
179 va_end( ap );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
180
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
181 iw=item->width;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
182 id=item->fontid;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
183
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
184 if ( ( !item )||
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
185 ( !Fonts[id] )||
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
186 ( !p[0] )||
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
187 ( !fntTextWidth( id,p ) ) ) return NULL;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
188
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
189 tw=fntTextWidth( id,p );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
190 fbw=Fonts[id]->Bitmap.Width;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
191
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 26458
diff changeset
192 if ( item->Bitmap.Image == NULL )
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
193 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
194 item->Bitmap.Height=item->height=fntTextHeight( id,p );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
195 item->Bitmap.Width=item->width=iw;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
196 item->Bitmap.ImageSize=item->height * iw * 4;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
197 if ( !item->Bitmap.ImageSize ) return NULL;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
198 item->Bitmap.BPP=32;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
199 item->Bitmap.Image=malloc( item->Bitmap.ImageSize );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
200 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
201
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
202 obuf=(uint32_t *)item->Bitmap.Image;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
203 ibuf=(uint32_t *)Fonts[id]->Bitmap.Image;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
204
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
205 for ( i=0;i < item->Bitmap.ImageSize / 4;i++ ) obuf[i]=0xff00ff;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 26458
diff changeset
206
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 26458
diff changeset
207 if ( tw <= iw )
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
208 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
209 switch ( item->align )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
210 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
211 default:
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
212 case fntAlignLeft: dx=0; break;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
213 case fntAlignCenter: dx=( iw - fntTextWidth( id,p ) ) / 2; break;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
214 case fntAlignRight: dx=iw - fntTextWidth( id,p ); break;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
215 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 26458
diff changeset
216
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
217 } else dx+=px;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
218
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
219 ofs=dx;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 26458
diff changeset
220
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
221 for ( i=0;i < (int)strlen( p );i++ )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
222 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
223 c=(unsigned int)p[i];
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
224 fw=Fonts[id]->Fnt[c].sx;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 26458
diff changeset
225
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
226 if ( fw == -1 ) { c=32; fw=Fonts[id]->Fnt[c].sx; }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 26458
diff changeset
227
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
228 fh=Fonts[id]->Fnt[c].sy;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
229 fyc=Fonts[id]->Fnt[c].y * fbw + Fonts[id]->Fnt[c].x;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
230 yc=dx;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 26458
diff changeset
231
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 26458
diff changeset
232 if ( dx >= 0 )
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
233 for ( y=0;y < fh;y++ )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
234 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
235 for ( x=0; x < fw;x++ )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
236 if ( dx + x >= 0 && dx + x < iw ) obuf[yc + x]=ibuf[ fyc + x ];
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
237 fyc+=fbw;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
238 yc+=iw;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
239 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
240 dx+=fw;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
241 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
242
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
243 if ( ofs > 0 && tw > item->width )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
244 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
245 dx=ofs;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
246 for ( i=(int)strlen( p );i > 0;i-- )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
247 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
248 c=(unsigned int)p[i];
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
249 fw=Fonts[id]->Fnt[c].sx;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 26458
diff changeset
250
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
251 if ( fw == -1 ) { c=32; fw=Fonts[id]->Fnt[c].sx; }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
252
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
253 fh=Fonts[id]->Fnt[c].sy;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
254 fyc=Fonts[id]->Fnt[c].y * fbw + Fonts[id]->Fnt[c].x;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
255
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
256 dx-=fw; yc=dx;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 26458
diff changeset
257 if ( dx >= 0 )
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
258 for ( y=0;y < fh;y++ )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
259 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
260 for ( x=fw - 1;x >= 0;x-- )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
261 if ( dx + x >= 0 && dx + x < iw ) obuf[yc + x]=ibuf[fyc + x];
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
262 fyc+=fbw;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
263 yc+=iw;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
264 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
265 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
266 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
267
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
268 return &item->Bitmap;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
269 }