FreeCalypso > hg > fc-magnetite
comparison src/aci2/atb/ATBDisplay.c @ 3:93999a60b835
src/aci2, src/condat2: import of g23m/condat source pieces from TCS211
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Mon, 26 Sep 2016 00:29:36 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
2:c41a534f33c6 | 3:93999a60b835 |
---|---|
1 /******************************************************************************* | |
2 | |
3 CONDAT (UK) | |
4 | |
5 ******************************************************************************** | |
6 | |
7 This software product is the property of Condat (UK) Ltd and may not be | |
8 disclosed to any third party without the express permission of the owner. | |
9 | |
10 ******************************************************************************** | |
11 | |
12 $Project name: Basic MMI | |
13 $Project code: BMI (6349) | |
14 $Module: ATB | |
15 $File: ATBDisplay.c | |
16 $Revision: 1.0 | |
17 | |
18 $Author: SH - Condat(UK) | |
19 $Date: 11/11/02 | |
20 | |
21 ******************************************************************************** | |
22 | |
23 Description: ATB/Display interface. | |
24 | |
25 | |
26 | |
27 ******************************************************************************** | |
28 | |
29 $History: ATBDisplay.c | |
30 | |
31 15/03/02 Original Condat(UK) BMI version. | |
32 $End | |
33 | |
34 *******************************************************************************/ | |
35 | |
36 #ifndef ATB_DISPLAY_C | |
37 #define ATB_DISPLAY_C | |
38 | |
39 #if defined (NEW_FRAME) | |
40 | |
41 #include "typedefs.h" | |
42 #include "vsi.h" | |
43 #include "pei.h" | |
44 #include "custom.h" | |
45 #include "gsm.h" | |
46 | |
47 #else | |
48 | |
49 #include "STDDEFS.H" | |
50 #include "custom.h" | |
51 #include "gsm.h" | |
52 #include "vsi.h" | |
53 | |
54 #endif | |
55 | |
56 #include <stdio.h> | |
57 #include <string.h> | |
58 | |
59 #include "mfw_mfw.h" | |
60 #include "mfw_sys.h" | |
61 #include "gdi.h" | |
62 #include "font_bitmaps.h" | |
63 #include "dspl.h" | |
64 #include "ATBCommon.h" | |
65 #include "ATBDisplay.h" | |
66 | |
67 /* | |
68 +--------------------------------------------------------------------+ | |
69 | LOCAL FUNCTION PROTOTYPES | | |
70 +--------------------------------------------------------------------+ | |
71 */ | |
72 | |
73 extern t_font_bitmap* get_bitmap(USHORT selected_code); | |
74 t_font_bitmap *ATB_display_GetBitmap(USHORT character); | |
75 void ATB_display_ShowBitmap(int x,int y,t_font_bitmap* current_bitmap,T_DS_TEXTFORMAT *format, | |
76 int xstart, int ystart, int width, int height); | |
77 | |
78 /* | |
79 +--------------------------------------------------------------------+ | |
80 | PROJECT : MMI-Framework (8417) MODULE : ATBDisplay | | |
81 | STATE : code ROUTINE : ATB_display_Cursor | | |
82 +--------------------------------------------------------------------+ | |
83 | |
84 PURPOSE : set cursor at specified position | |
85 | |
86 */ | |
87 | |
88 void ATB_display_Cursor (T_ATB_TEXT *text, USHORT textIndex, UBYTE type, SHORT x, SHORT y, USHORT width, USHORT height) | |
89 { | |
90 T_ATB_TEXT charTxt; | |
91 UBYTE charData[4]; | |
92 USHORT character; | |
93 T_DS_TEXTFORMAT format; | |
94 | |
95 switch(type) | |
96 { | |
97 // bar cursor | |
98 case DS_CURSOR_BAR: | |
99 dspl_DrawLine(x,y,x,y+height-1); | |
100 break; | |
101 | |
102 // underscore cursor | |
103 case DS_CURSOR_UNDERLINE: | |
104 dspl_DrawLine(x,y+height-1, x+width-1, y+height-1); | |
105 break; | |
106 | |
107 // block cursor | |
108 case DS_CURSOR_BLOCK: | |
109 charTxt.data = charData; | |
110 charTxt.dcs = text->dcs; | |
111 charTxt.len = 1; | |
112 | |
113 character = ATB_string_GetChar(text, textIndex); | |
114 if (!ATB_char_IsVisible(character)) | |
115 character = UNICODE_SPACE; | |
116 | |
117 ATB_string_SetChar(&charTxt, 0, character); | |
118 ATB_string_SetChar(&charTxt, 1, UNICODE_EOLN); | |
119 | |
120 ATB_display_SetFormatAttr(&format, 0, TRUE); | |
121 ATB_display_Text(x,y, &format, &charTxt); | |
122 break; | |
123 } | |
124 return; | |
125 } | |
126 | |
127 | |
128 /* | |
129 +--------------------------------------------------------------------+ | |
130 | PROJECT : MMI-Framework (8417) MODULE : ATBDisplay.c | | |
131 | STATE : code ROUTINE : ATB_display_Text | | |
132 +--------------------------------------------------------------------+ | |
133 | |
134 PURPOSE : draw 'length' characters of string 'text' at x,y in format 'format'. | |
135 | |
136 */ | |
137 | |
138 void ATB_display_Text(SHORT x, SHORT y, T_DS_TEXTFORMAT *format, T_ATB_TEXT *text) | |
139 { | |
140 | |
141 USHORT charStore; | |
142 UBYTE attr; | |
143 | |
144 attr = 0; | |
145 | |
146 if (text->dcs==ATB_DCS_UNICODE) | |
147 attr |= DSPL_TXTATTR_UNICODE; | |
148 if (format->highlight) | |
149 attr |= DSPL_TXTATTR_INVERS; | |
150 | |
151 charStore = ATB_string_GetChar(text, text->len); | |
152 ATB_string_SetChar(text, text->len, UNICODE_EOLN); | |
153 dspl_TextOut((USHORT)x, (USHORT)y, attr, (char *)text->data); | |
154 ATB_string_SetChar(text, text->len, charStore); | |
155 | |
156 return; | |
157 } | |
158 | |
159 | |
160 /* | |
161 +--------------------------------------------------------------------+ | |
162 | PROJECT : MMI-Framework (8417) MODULE : ATBDisplay.c | | |
163 | STATE : code ROUTINE : ATB_display_GetCharWidth | | |
164 +--------------------------------------------------------------------+ | |
165 | |
166 PURPOSE : get height of character in current font | |
167 | |
168 */ | |
169 | |
170 int ATB_display_GetCharWidth (USHORT character, T_DS_TEXTFORMAT *format) | |
171 { | |
172 t_font_bitmap *current_bitmap; | |
173 int width; | |
174 | |
175 if (character==UNICODE_WIDEST_CHAR) | |
176 { | |
177 width = ATB_display_GetMaxCharWidth(format); | |
178 } | |
179 else | |
180 { | |
181 current_bitmap = ATB_display_GetBitmap(character); | |
182 if (!current_bitmap) | |
183 { | |
184 current_bitmap = ATB_display_GetBitmap(UNICODE_SPACE); | |
185 } | |
186 width = (int)current_bitmap->width; | |
187 } | |
188 | |
189 | |
190 //TRACE_EVENT_P2("Width of char %d is %d", character, width); | |
191 | |
192 return width; | |
193 } | |
194 | |
195 | |
196 /* | |
197 +--------------------------------------------------------------------+ | |
198 | PROJECT : MMI-Framework (8417) MODULE : ATBDisplay.c | | |
199 | STATE : code ROUTINE : ATB_display_GetMaxCharWidth | | |
200 +--------------------------------------------------------------------+ | |
201 | |
202 PURPOSE : Get maximum width of a character in the current font and style | |
203 | |
204 */ | |
205 | |
206 int ATB_display_GetMaxCharWidth (T_DS_TEXTFORMAT *format) | |
207 { | |
208 int width; | |
209 | |
210 width = 16; | |
211 | |
212 return width; | |
213 } | |
214 | |
215 /* | |
216 +--------------------------------------------------------------------+ | |
217 | PROJECT : MMI-Framework (8417) MODULE : ATBDisplay | | |
218 | STATE : code ROUTINE : ATB_display_GetCharHeight | | |
219 +--------------------------------------------------------------------+ | |
220 | |
221 PURPOSE : get height of character in current font | |
222 | |
223 */ | |
224 | |
225 int ATB_display_GetCharHeight (USHORT character, T_DS_TEXTFORMAT *format) | |
226 { | |
227 | |
228 /*t_font_bitmap *current_bitmap; | |
229 int height; | |
230 | |
231 current_bitmap = ATB_display_GetBitmap(character); | |
232 if (!current_bitmap) | |
233 { | |
234 current_bitmap = ATB_display_GetBitmap(UNICODE_SPACE); | |
235 } | |
236 height = (int)current_bitmap->height; | |
237 | |
238 return height;*/ | |
239 | |
240 return (int)dspl_GetFontHeight(); | |
241 } | |
242 | |
243 | |
244 /* | |
245 +--------------------------------------------------------------------+ | |
246 | PROJECT : MMI-Framework (8417) MODULE : ATB Display | | |
247 | STATE : code ROUTINE : | | |
248 +--------------------------------------------------------------------+ | |
249 | |
250 PURPOSE : Return width of string in pixels. NOTE: End of line characters | |
251 will be included in the width - same width as a space - if the "length" | |
252 parameter includes them. | |
253 | |
254 text - the text whose width is to be calculated | |
255 length - the length of text to be considered | |
256 format - pointer to the format attributes at the start of the string | |
257 */ | |
258 | |
259 USHORT ATB_display_StringWidth(T_ATB_TEXT *text, T_DS_TEXTFORMAT *format) | |
260 { | |
261 USHORT width; | |
262 USHORT textIndex; | |
263 USHORT character; | |
264 T_DS_TEXTFORMAT tempFormat; // Temporary storage for format attributes | |
265 BOOL endFound; | |
266 | |
267 #ifdef TRACE_ATBEDITOR | |
268 TRACE_FUNCTION("ATB Editor: ATB_display_StringWidth()"); | |
269 #endif | |
270 | |
271 width = 0; | |
272 textIndex = 0; | |
273 endFound = FALSE; | |
274 ATB_display_CopyFormat(&tempFormat, format); // Make a copy of the original format | |
275 | |
276 while (!endFound) | |
277 { | |
278 character = ATB_string_GetChar(text, textIndex); // Get the next character | |
279 width += ATB_display_GetCharWidth(character, &tempFormat); | |
280 textIndex++; | |
281 | |
282 if(!(textIndex<text->len)) | |
283 endFound = TRUE; | |
284 } | |
285 | |
286 return (width); | |
287 } | |
288 | |
289 | |
290 /* | |
291 +--------------------------------------------------------------------+ | |
292 | PROJECT : MMI-Framework (8417) MODULE : ATB Display | | |
293 | STATE : code ROUTINE : | | |
294 +--------------------------------------------------------------------+ | |
295 | |
296 PURPOSE : Return height of tallest character in next 'length' characters of string | |
297 */ | |
298 | |
299 USHORT ATB_display_StringHeight(T_ATB_TEXT *text, T_DS_TEXTFORMAT *format) | |
300 { | |
301 USHORT height; | |
302 USHORT currentHeight; | |
303 USHORT textIndex; | |
304 USHORT character; | |
305 BOOL endFound; | |
306 T_DS_TEXTFORMAT tempFormat; // Temporary storage for format attributes | |
307 | |
308 TRACE_FUNCTION("ATB_display_StringHeight()"); | |
309 | |
310 height = 0; | |
311 textIndex = 0; | |
312 endFound = FALSE; | |
313 ATB_display_CopyFormat(&tempFormat, format); // Store the original format | |
314 | |
315 while (!endFound) | |
316 { | |
317 character = ATB_string_GetChar(text, textIndex); // Get the next character | |
318 currentHeight = ATB_display_GetCharHeight(character, &tempFormat); | |
319 if (currentHeight>height) | |
320 height = currentHeight; | |
321 textIndex++; | |
322 | |
323 if(!(textIndex<text->len)) | |
324 endFound = TRUE; | |
325 } | |
326 | |
327 return (height); | |
328 } | |
329 | |
330 | |
331 | |
332 /* | |
333 +--------------------------------------------------------------------+ | |
334 | PROJECT : MMI-Framework (8417) MODULE : ATBDisplay.c | | |
335 | STATE : code ROUTINE : ATB_display_SetFormatAttr | | |
336 +--------------------------------------------------------------------+ | |
337 | |
338 PURPOSE : Sets format attributes and highlighting | |
339 attr - the rich text formatting | |
340 highlight - TRUE if highlighting is to be switched on for the whole string | |
341 */ | |
342 | |
343 void ATB_display_SetFormatAttr(T_DS_TEXTFORMAT *format, USHORT attr, BOOL highlight) | |
344 { | |
345 format->attr = attr; | |
346 format->highlight = highlight; | |
347 | |
348 return; | |
349 } | |
350 | |
351 | |
352 /* | |
353 +--------------------------------------------------------------------+ | |
354 | PROJECT : MMI-Framework (8417) MODULE : ATBDisplay.c | | |
355 | STATE : code ROUTINE : ATB_display_ClearFormat | | |
356 +--------------------------------------------------------------------+ | |
357 | |
358 PURPOSE : Clears the formatting attributes | |
359 format - pointer to the current formatting attributes | |
360 */ | |
361 | |
362 void ATB_display_ClearFormat(T_DS_TEXTFORMAT *format) | |
363 { | |
364 format->attr = 0; | |
365 format->highlight = FALSE; | |
366 return; | |
367 } | |
368 | |
369 /* | |
370 +--------------------------------------------------------------------+ | |
371 | PROJECT : MMI-Framework (8417) MODULE : ATBDisplay.c | | |
372 | STATE : code ROUTINE : ATB_display_ClearFormat | | |
373 +--------------------------------------------------------------------+ | |
374 | |
375 PURPOSE : Duplicates format attributes | |
376 dest - pointer to the destination format structure (caller allocated) | |
377 src - pointer to the source format structure (caller allocated) | |
378 */ | |
379 | |
380 void ATB_display_CopyFormat(T_DS_TEXTFORMAT *dest, T_DS_TEXTFORMAT *src) | |
381 { | |
382 memcpy((void *)dest, (void *)src, sizeof(T_DS_TEXTFORMAT)); | |
383 return; | |
384 } | |
385 | |
386 | |
387 /* | |
388 +------------------------------------------------------------------------+ | |
389 | PROJECT : MMI-Framework (8417) MODULE : ATBDisplay.c | | |
390 | STATE : code ROUTINE : ATB_display_GetBitmap | | |
391 +------------------------------------------------------------------------+ | |
392 | |
393 PURPOSE : Returns address of bitmap based on unicode number (our coding scheme) | |
394 */ | |
395 | |
396 t_font_bitmap *ATB_display_GetBitmap(USHORT character) | |
397 { | |
398 USHORT current_code; | |
399 | |
400 current_code = (USHORT)(character<<8)+(USHORT)(character>>8); // Swap bytes round for correct unicode | |
401 return (t_font_bitmap *)get_bitmap(current_code); | |
402 } | |
403 | |
404 #endif |