FreeCalypso > hg > fc-tourmaline
comparison src/ui/bmi/AUICalcEditor.c @ 135:70ea7526b59e
bmi/AUI*.c: bogotab fixes
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sat, 14 Nov 2020 03:18:11 +0000 |
parents | c0052fe355d3 |
children |
comparison
equal
deleted
inserted
replaced
134:62480f597962 | 135:70ea7526b59e |
---|---|
9 | 9 |
10 ******************************************************************************** | 10 ******************************************************************************** |
11 | 11 |
12 $Project name: Basic MMI | 12 $Project name: Basic MMI |
13 $Project code: BMI (6349) | 13 $Project code: BMI (6349) |
14 $Module: MMI | 14 $Module: MMI |
15 $File: AUICalcEditor.c | 15 $File: AUICalcEditor.c |
16 $Revision: 1.0 | 16 $Revision: 1.0 |
17 | 17 |
18 $Author: Condat(UK) | 18 $Author: Condat(UK) |
19 $Date: 22/02/01 | 19 $Date: 22/02/01 |
20 | 20 |
21 ******************************************************************************** | 21 ******************************************************************************** |
22 | 22 |
23 Description: Editor for calculator, or generic floating-point number input | 23 Description: Editor for calculator, or generic floating-point number input |
24 | 24 |
25 | 25 |
26 | |
27 ******************************************************************************** | 26 ******************************************************************************** |
28 | 27 |
29 $History: AUICalcEditor.c | 28 $History: AUICalcEditor.c |
30 | 29 |
31 xrashmic 20 Oct, 2005 MMI-SPR-33845 | 30 xrashmic 20 Oct, 2005 MMI-SPR-33845 |
32 To display BACK softkey when no more character are left in the calculator editor | 31 To display BACK softkey when no more character are left in the calculator editor |
33 | 32 |
34 14/11/02 Original Condat(UK) BMI version. | 33 14/11/02 Original Condat(UK) BMI version. |
35 $End | 34 $End |
36 | 35 |
37 *******************************************************************************/ | 36 *******************************************************************************/ |
106 | 105 |
107 #include "AUICalcEditor.h" | 106 #include "AUICalcEditor.h" |
108 | 107 |
109 typedef struct | 108 typedef struct |
110 { | 109 { |
111 T_MMI_CONTROL mmi_control; | 110 T_MMI_CONTROL mmi_control; |
112 T_MFW_HND parent; // The parent window | 111 T_MFW_HND parent; // The parent window |
113 T_MFW_HND win; // The edit window | 112 T_MFW_HND win; // The edit window |
114 T_MFW_HND kbd; // The keyboard handler | 113 T_MFW_HND kbd; // The keyboard handler |
115 T_MFW_HND kbd_long; // The longpress keyboard handler | 114 T_MFW_HND kbd_long; // The longpress keyboard handler |
116 T_MFW_HND timer; // The timer for timeouts | 115 T_MFW_HND timer; // The timer for timeouts |
117 | 116 |
118 T_ED_DATA *editor; /* The ATB editor */ | 117 T_ED_DATA *editor; /* The ATB editor */ |
119 T_AUI_EDITOR_DATA editor_data; /* The MMI editor data, provided by caller */ | 118 T_AUI_EDITOR_DATA editor_data; /* The MMI editor data, provided by caller */ |
120 T_AUI_ENTRY_DATA *entry_data; /* The MMI text entry data */ | 119 T_AUI_ENTRY_DATA *entry_data; /* The MMI text entry data */ |
121 | 120 |
122 BOOL haveTitle; /* TRUE if a title is supplied */ | 121 BOOL haveTitle; /* TRUE if a title is supplied */ |
123 T_ATB_TEXT title; /* Title of editor */ | 122 T_ATB_TEXT title; /* Title of editor */ |
124 BOOL haveResult; /* TRUE if a result is supplied */ | 123 BOOL haveResult; /* TRUE if a result is supplied */ |
125 T_ATB_TEXT result; /* Text of result */ | 124 T_ATB_TEXT result; /* Text of result */ |
126 | 125 |
127 BOOL doNextLongPress; /* Flag used to notice/not notice long keypress */ | 126 BOOL doNextLongPress; /* Flag used to notice/not notice long keypress */ |
128 BOOL hasDecimalPoint; /* Ensures only one decimal point per number */ | 127 BOOL hasDecimalPoint; /* Ensures only one decimal point per number */ |
129 } | 128 } |
130 T_AUI_CALC_DATA; | 129 T_AUI_CALC_DATA; |
131 | 130 |
132 /* LOCAL FUNCTION PROTOTYPES */ | 131 /* LOCAL FUNCTION PROTOTYPES */ |
133 static T_MFW_HND AUI_calc_Create(T_MFW_HND parent, T_AUI_EDITOR_DATA *editor_data); | 132 static T_MFW_HND AUI_calc_Create(T_MFW_HND parent, T_AUI_EDITOR_DATA *editor_data); |
135 static int AUI_calc_WinCb(T_MFW_EVENT event, T_MFW_WIN *win_data); | 134 static int AUI_calc_WinCb(T_MFW_EVENT event, T_MFW_WIN *win_data); |
136 static int AUI_calc_KbdCb(T_MFW_EVENT event, T_MFW_KBD *keyboard); | 135 static int AUI_calc_KbdCb(T_MFW_EVENT event, T_MFW_KBD *keyboard); |
137 static int AUI_calc_KbdLongCb(T_MFW_EVENT event, T_MFW_KBD *keyboard); | 136 static int AUI_calc_KbdLongCb(T_MFW_EVENT event, T_MFW_KBD *keyboard); |
138 | 137 |
139 | 138 |
140 | 139 /******************************************************************************* |
141 | 140 |
142 /******************************************************************************* | 141 $Function: AUI_calc_Start |
143 | 142 |
144 $Function: AUI_calc_Start | 143 $Description: Start the Calc editor. |
145 | 144 |
146 $Description: Start the Calc editor. | 145 $Returns: None. |
147 | 146 |
148 $Returns: None. | 147 $Arguments: None. |
149 | |
150 $Arguments: None. | |
151 | 148 |
152 *******************************************************************************/ | 149 *******************************************************************************/ |
153 | 150 |
154 T_MFW_HND AUI_calc_Start(T_MFW_HND parent, T_AUI_EDITOR_DATA *editor_data) | 151 T_MFW_HND AUI_calc_Start(T_MFW_HND parent, T_AUI_EDITOR_DATA *editor_data) |
155 { | 152 { |
162 } | 159 } |
163 | 160 |
164 | 161 |
165 /******************************************************************************* | 162 /******************************************************************************* |
166 | 163 |
167 $Function: AUI_calc_Create | 164 $Function: AUI_calc_Create |
168 | 165 |
169 $Description: Create the Calc editor. | 166 $Description: Create the Calc editor. |
170 | 167 |
171 $Returns: Pointer to the editor's window. | 168 $Returns: Pointer to the editor's window. |
172 | 169 |
173 $Arguments: parent - The parent window. | 170 $Arguments: parent - The parent window. |
174 | 171 |
175 *******************************************************************************/ | 172 *******************************************************************************/ |
176 | 173 |
177 static T_MFW_HND AUI_calc_Create(T_MFW_HND parent, T_AUI_EDITOR_DATA *editor_data) | 174 static T_MFW_HND AUI_calc_Create(T_MFW_HND parent, T_AUI_EDITOR_DATA *editor_data) |
178 { | 175 { |
179 T_AUI_CALC_DATA *data = (T_AUI_CALC_DATA *)ALLOC_MEMORY(sizeof (T_AUI_CALC_DATA)); | 176 T_AUI_CALC_DATA *data = (T_AUI_CALC_DATA *)ALLOC_MEMORY(sizeof (T_AUI_CALC_DATA)); |
180 T_MFW_WIN *win_data; | 177 T_MFW_WIN *win_data; |
181 | 178 |
182 TRACE_FUNCTION ("AUI_calc_Create()"); | 179 TRACE_FUNCTION ("AUI_calc_Create()"); |
183 | 180 |
184 /* Create window handler */ | 181 /* Create window handler */ |
185 | 182 |
186 data->win = win_create(parent, 0, E_WIN_VISIBLE, (T_MFW_CB)AUI_calc_WinCb); // Create window | 183 data->win = win_create(parent, 0, E_WIN_VISIBLE, (T_MFW_CB)AUI_calc_WinCb); // Create window |
187 | 184 |
188 if (data->win==NULL) // Make sure window exists | 185 if (data->win==NULL) // Make sure window exists |
189 { | 186 { |
190 return NULL; | 187 return NULL; |
191 } | 188 } |
192 | 189 |
193 /* Connect the dialog data to the MFW-window */ | 190 /* Connect the dialog data to the MFW-window */ |
194 | 191 |
195 data->mmi_control.dialog = (T_DIALOG_FUNC)AUI_calc_ExecCb; /* Setup the destination for events */ | 192 data->mmi_control.dialog = (T_DIALOG_FUNC)AUI_calc_ExecCb; /* Setup the destination for events */ |
196 data->mmi_control.data = data; | 193 data->mmi_control.data = data; |
197 data->parent = parent; | 194 data->parent = parent; |
198 win_data = ((T_MFW_HDR *)data->win)->data; | 195 win_data = ((T_MFW_HDR *)data->win)->data; |
199 win_data->user = (void *)data; | 196 win_data->user = (void *)data; |
200 | 197 |
201 data->kbd = kbd_create(data->win, KEY_ALL,(T_MFW_CB)AUI_calc_KbdCb); | 198 data->kbd = kbd_create(data->win, KEY_ALL,(T_MFW_CB)AUI_calc_KbdCb); |
202 data->kbd_long = kbd_create(data->win, KEY_ALL|KEY_LONG,(T_MFW_CB)AUI_calc_KbdLongCb); | 199 data->kbd_long = kbd_create(data->win, KEY_ALL|KEY_LONG,(T_MFW_CB)AUI_calc_KbdLongCb); |
203 data->editor = ATB_edit_Create(&data->editor_data.editor_attr,0); | 200 data->editor = ATB_edit_Create(&data->editor_data.editor_attr,0); |
204 | 201 |
205 data->editor_data = *editor_data; | 202 data->editor_data = *editor_data; |
206 data->entry_data = AUI_entry_Create(data->win, data->editor, E_CALC_UPDATE); | 203 data->entry_data = AUI_entry_Create(data->win, data->editor, E_CALC_UPDATE); |
207 | 204 |
208 SEND_EVENT(data->win, E_CALC_INIT, 0, 0); | 205 SEND_EVENT(data->win, E_CALC_INIT, 0, 0); |
209 | 206 |
210 /* Return window handle */ | 207 /* Return window handle */ |
211 | 208 |
212 return data->win; | 209 return data->win; |
213 } | 210 } |
214 | 211 |
215 | 212 |
216 /******************************************************************************* | 213 /******************************************************************************* |
217 | 214 |
218 $Function: AUI_calc_Destroy | 215 $Function: AUI_calc_Destroy |
219 | 216 |
220 $Description: Destroy the Calc editor. | 217 $Description: Destroy the Calc editor. |
221 | 218 |
222 $Returns: None. | 219 $Returns: None. |
223 | 220 |
224 $Arguments: window - The editor window. | 221 $Arguments: window - The editor window. |
225 | 222 |
226 *******************************************************************************/ | 223 *******************************************************************************/ |
227 | 224 |
228 void AUI_calc_Destroy(T_MFW_HND win) | 225 void AUI_calc_Destroy(T_MFW_HND win) |
229 { | 226 { |
230 T_MFW_WIN *win_data = ((T_MFW_HDR *)win)->data; | 227 T_MFW_WIN *win_data = ((T_MFW_HDR *)win)->data; |
231 T_AUI_CALC_DATA *data = (T_AUI_CALC_DATA *)win_data->user; | 228 T_AUI_CALC_DATA *data = (T_AUI_CALC_DATA *)win_data->user; |
232 | 229 |
233 if (data) | 230 if (data) |
234 { | 231 { |
235 AUI_entry_Destroy(data->entry_data); | 232 AUI_entry_Destroy(data->entry_data); |
236 | 233 |
237 win_delete (data->win); | 234 win_delete (data->win); |
238 | 235 |
239 /* Free memory allocated to store result */ | 236 /* Free memory allocated to store result */ |
240 | 237 |
241 if (data->haveResult) | 238 if (data->haveResult) |
242 { | 239 { |
243 FREE_MEMORY(data->result.data, data->result.len*sizeof(char)); | 240 FREE_MEMORY(data->result.data, data->result.len*sizeof(char)); |
244 } | 241 } |
245 | 242 |
246 /* Free editor memory */ | 243 /* Free editor memory */ |
247 | 244 |
248 ATB_edit_Destroy(data->editor); | 245 ATB_edit_Destroy(data->editor); |
249 FREE_MEMORY ((void *)data, sizeof (T_AUI_CALC_DATA)); | 246 FREE_MEMORY ((void *)data, sizeof (T_AUI_CALC_DATA)); |
250 } | 247 } |
251 | 248 |
252 return; | 249 return; |
253 } | 250 } |
254 | 251 |
255 | 252 |
256 /******************************************************************************* | 253 /******************************************************************************* |
257 | 254 |
258 $Function: AUI_calc_ExecCb | 255 $Function: AUI_calc_ExecCb |
259 | 256 |
260 $Description: Dialog function for Calc editor. | 257 $Description: Dialog function for Calc editor. |
261 | 258 |
262 $Returns: None. | 259 $Returns: None. |
263 | 260 |
264 $Arguments: None. | 261 $Arguments: None. |
265 | 262 |
266 *******************************************************************************/ | 263 *******************************************************************************/ |
267 | 264 |
268 static void AUI_calc_ExecCb(T_MFW_HND win, USHORT event, SHORT value, void *parameter) | 265 static void AUI_calc_ExecCb(T_MFW_HND win, USHORT event, SHORT value, void *parameter) |
269 { | 266 { |
270 T_MFW_WIN *win_data = ((T_MFW_HDR *)win)->data; | 267 T_MFW_WIN *win_data = ((T_MFW_HDR *)win)->data; |
271 T_AUI_CALC_DATA *data = (T_AUI_CALC_DATA *)win_data->user; | 268 T_AUI_CALC_DATA *data = (T_AUI_CALC_DATA *)win_data->user; |
272 T_MFW_HND parent_win = data->parent; | 269 T_MFW_HND parent_win = data->parent; |
273 USHORT textIndex; | 270 USHORT textIndex; |
274 T_ATB_TEXT text; | 271 T_ATB_TEXT text; |
275 /* Store these in case editor is destroyed on callback */ | 272 /* Store these in case editor is destroyed on callback */ |
276 USHORT Identifier = data->editor_data.Identifier; | 273 USHORT Identifier = data->editor_data.Identifier; |
277 T_AUI_EDIT_CB Callback = data->editor_data.Callback; | 274 T_AUI_EDIT_CB Callback = data->editor_data.Callback; |
278 UBYTE destroyEditor = data->editor_data.destroyEditor; | 275 UBYTE destroyEditor = data->editor_data.destroyEditor; |
279 | 276 |
280 TRACE_FUNCTION ("AUI_calc_ExecCb()"); | 277 TRACE_FUNCTION ("AUI_calc_ExecCb()"); |
281 | 278 |
282 switch (event) | 279 switch (event) |
283 { | 280 { |
284 /* Initialise */ | 281 /* Initialise */ |
285 | 282 |
286 case E_CALC_INIT: | 283 case E_CALC_INIT: |
287 TRACE_EVENT("E_CALC_INIT"); | 284 TRACE_EVENT("E_CALC_INIT"); |
288 ATB_edit_Init(data->editor); | 285 ATB_edit_Init(data->editor); |
289 | 286 |
290 data->haveTitle = FALSE; | 287 data->haveTitle = FALSE; |
291 data->haveResult = FALSE; | 288 data->haveResult = FALSE; |
292 | 289 |
293 /* If we require an output line, shrink editor to fit it at bottom | 290 /* If we require an output line, shrink editor to fit it at bottom |
294 * NB TitleString is assumed here to be a numeric string of ascii digits */ | 291 * NB TitleString is assumed here to be a numeric string of ascii digits */ |
295 | 292 |
296 if (data->editor_data.TitleString) | 293 if (data->editor_data.TitleString) |
297 { | 294 { |
298 data->haveResult = TRUE; | 295 data->haveResult = TRUE; |
299 text.dcs = ATB_DCS_ASCII; | 296 text.dcs = ATB_DCS_ASCII; |
300 text.data = data->editor_data.TitleString; | 297 text.data = data->editor_data.TitleString; |
301 text.len = ATB_string_Length(&text); | 298 text.len = ATB_string_Length(&text); |
302 | 299 |
303 data->result.data = ALLOC_MEMORY(text.len*sizeof(char)); | 300 data->result.data = ALLOC_MEMORY(text.len*sizeof(char)); |
304 ATB_string_Copy(&data->result, &text); | 301 ATB_string_Copy(&data->result, &text); |
305 | 302 |
306 /* Change size of editor to fit result line in */ | 303 /* Change size of editor to fit result line in */ |
307 data->editor_data.editor_attr.win_size.sy -= ATB_display_StringHeight(&data->result, NULL); | 304 data->editor_data.editor_attr.win_size.sy -= ATB_display_StringHeight(&data->result, NULL); |
308 } | 305 } |
309 | 306 |
310 /* Set up title */ | 307 /* Set up title */ |
311 | 308 |
312 if (data->editor_data.TitleId!=NULL) | 309 if (data->editor_data.TitleId!=NULL) |
313 { | 310 { |
314 data->haveTitle = TRUE; | 311 data->haveTitle = TRUE; |
315 data->title.data = (UBYTE *)MmiRsrcGetText(data->editor_data.TitleId); | 312 data->title.data = (UBYTE *)MmiRsrcGetText(data->editor_data.TitleId); |
316 } | 313 } |
317 | 314 |
318 /* If title exists, get its dcs and length */ | 315 /* If title exists, get its dcs and length */ |
319 | 316 |
320 if (data->haveTitle) | 317 if (data->haveTitle) |
321 { | 318 { |
322 if (data->title.data[0]==0x80) | 319 if (data->title.data[0]==0x80) |
323 { | 320 { |
324 data->title.data += 2; /* Skip over two unicode indicator bytes */ | 321 data->title.data += 2; /* Skip over two unicode indicator bytes */ |
325 data->title.dcs = ATB_DCS_UNICODE; | 322 data->title.dcs = ATB_DCS_UNICODE; |
326 } | 323 } |
327 #ifdef EASY_TEXT_ENABLED | 324 #ifdef EASY_TEXT_ENABLED |
328 else if (Mmi_getCurrentLanguage() == CHINESE_LANGUAGE) | 325 else if (Mmi_getCurrentLanguage() == CHINESE_LANGUAGE) |
329 { | 326 { |
330 data->title.dcs = ATB_DCS_UNICODE; | 327 data->title.dcs = ATB_DCS_UNICODE; |
331 } | 328 } |
332 #endif | 329 #endif |
333 else | 330 else |
334 { | 331 { |
335 data->title.dcs = ATB_DCS_ASCII; | 332 data->title.dcs = ATB_DCS_ASCII; |
336 } | 333 } |
337 | 334 |
338 data->title.len = ATB_string_Length(&data->title); | 335 data->title.len = ATB_string_Length(&data->title); |
339 } | 336 } |
340 | 337 |
341 /* Check to see if number already has decimal point */ | 338 /* Check to see if number already has decimal point */ |
342 | 339 |
343 data->hasDecimalPoint = FALSE; | 340 data->hasDecimalPoint = FALSE; |
344 | 341 |
345 for (textIndex = 0; textIndex<data->editor->attr->text.len; textIndex++) | 342 for (textIndex = 0; textIndex<data->editor->attr->text.len; textIndex++) |
346 { | 343 { |
347 if (ATB_string_GetChar(&data->editor->attr->text, textIndex)==UNICODE_FULLSTOP) | 344 if (ATB_string_GetChar(&data->editor->attr->text, textIndex)==UNICODE_FULLSTOP) |
348 { | 345 { |
349 data->hasDecimalPoint = TRUE; | 346 data->hasDecimalPoint = TRUE; |
350 } | 347 } |
351 } | 348 } |
352 | 349 |
353 /* Show the window */ | 350 /* Show the window */ |
354 win_show(data->win); | 351 win_show(data->win); |
355 break; | 352 break; |
356 | 353 |
357 case E_CALC_UPDATE: | 354 case E_CALC_UPDATE: |
358 TRACE_EVENT("E_CALC_UPDATE"); | 355 TRACE_EVENT("E_CALC_UPDATE"); |
359 win_show(data->win); | 356 win_show(data->win); |
360 break; | 357 break; |
361 | 358 |
362 case E_CALC_DEINIT: | 359 case E_CALC_DEINIT: |
363 TRACE_EVENT("E_CALC_DEINIT"); | 360 TRACE_EVENT("E_CALC_DEINIT"); |
364 | 361 |
365 if (Callback) | 362 if (Callback) |
366 (Callback) (parent_win, Identifier, value); | 363 (Callback) (parent_win, Identifier, value); |
367 | 364 |
368 if (destroyEditor) | 365 if (destroyEditor) |
369 AUI_calc_Destroy(data->win); | 366 AUI_calc_Destroy(data->win); |
370 | 367 |
371 break; | 368 break; |
372 | 369 |
373 } | 370 } |
374 | 371 |
375 return; | 372 return; |
376 } | 373 } |
377 | 374 |
378 /******************************************************************************* | 375 /******************************************************************************* |
379 | 376 |
380 $Function: AUI_calc_WinCb | 377 $Function: AUI_calc_WinCb |
381 | 378 |
382 $Description: Calc editor window event handler. | 379 $Description: Calc editor window event handler. |
383 | 380 |
384 $Returns: None. | 381 $Returns: None. |
385 | 382 |
386 $Arguments: event - the event | 383 $Arguments: event - the event |
387 win - the editor window | 384 win - the editor window |
388 | 385 |
389 *******************************************************************************/ | 386 *******************************************************************************/ |
390 | 387 |
391 static int AUI_calc_WinCb(T_MFW_EVENT event, T_MFW_WIN *win_data) | 388 static int AUI_calc_WinCb(T_MFW_EVENT event, T_MFW_WIN *win_data) |
392 { | 389 { |
393 T_AUI_CALC_DATA *data = (T_AUI_CALC_DATA *)win_data->user; | 390 T_AUI_CALC_DATA *data = (T_AUI_CALC_DATA *)win_data->user; |
394 T_ED_DATA *editor = data->editor; | 391 T_ED_DATA *editor = data->editor; |
395 T_ATB_WIN_SIZE *win_size = &data->editor->attr->win_size; | 392 T_ATB_WIN_SIZE *win_size = &data->editor->attr->win_size; |
396 T_DS_TEXTFORMAT format; | 393 T_DS_TEXTFORMAT format; |
397 // USHORT titleLen; // RAVI | 394 // USHORT titleLen; // RAVI |
398 | 395 |
399 TRACE_EVENT("AUI_calc_WinCb"); | 396 TRACE_EVENT("AUI_calc_WinCb"); |
400 | 397 |
401 if (!data) | 398 if (!data) |
402 return MFW_EVENT_CONSUMED; | 399 return MFW_EVENT_CONSUMED; |
403 | 400 |
404 switch(event) | 401 switch(event) |
405 { | 402 { |
406 case E_WIN_VISIBLE: /* window is visible */ | 403 case E_WIN_VISIBLE: /* window is visible */ |
407 if (win_data->flags & E_WIN_VISIBLE) | 404 if (win_data->flags & E_WIN_VISIBLE) |
408 { | 405 { |
409 if (editor->update==ED_UPDATE_TRIVIAL) | 406 if (editor->update==ED_UPDATE_TRIVIAL) |
410 { | 407 { |
411 TRACE_EVENT("Only updating editor."); | 408 TRACE_EVENT("Only updating editor."); |
412 ATB_edit_Show(data->editor); | 409 ATB_edit_Show(data->editor); |
413 } | 410 } |
414 else | 411 else |
415 { | 412 { |
416 TRACE_EVENT("Updating whole screen."); | 413 TRACE_EVENT("Updating whole screen."); |
417 | 414 |
418 ATB_edit_Show(data->editor); | 415 ATB_edit_Show(data->editor); |
419 | 416 |
420 /* Set the colour for drawing title */ | 417 /* Set the colour for drawing title */ |
421 | 418 |
422 resources_setTitleColour(COLOUR_EDITOR); | 419 resources_setTitleColour(COLOUR_EDITOR); |
423 | 420 |
424 /* TITLE */ | 421 /* TITLE */ |
425 | 422 |
426 dspl_Clear(0,0, SCREEN_SIZE_X-1, win_size->py-1); | 423 dspl_Clear(0,0, SCREEN_SIZE_X-1, win_size->py-1); |
427 | 424 |
428 if (data->haveTitle) | 425 if (data->haveTitle) |
429 { | 426 { |
430 ATB_display_SetFormatAttr(&format, 0, FALSE); | 427 ATB_display_SetFormatAttr(&format, 0, FALSE); |
431 ATB_display_Text(0,0,&format, &data->title); | 428 ATB_display_Text(0,0,&format, &data->title); |
432 } | 429 } |
433 | 430 |
434 /* RESULT */ | 431 /* RESULT */ |
435 | 432 |
436 if (data->haveResult) | 433 if (data->haveResult) |
437 { | 434 { |
438 resources_setHLColour(COLOUR_EDITOR); | 435 resources_setHLColour(COLOUR_EDITOR); |
439 ATB_display_SetFormatAttr(&format, 0, FALSE); | 436 ATB_display_SetFormatAttr(&format, 0, FALSE); |
440 dspl_Clear( win_size->px, win_size->py+win_size->sy, win_size->px+win_size->sx, | 437 dspl_Clear( win_size->px, win_size->py+win_size->sy, win_size->px+win_size->sx, |
441 win_size->py+win_size->sy+ATB_display_StringHeight(&data->result, &format)); | 438 win_size->py+win_size->sy+ATB_display_StringHeight(&data->result, &format)); |
442 | 439 |
443 ATB_display_Text(win_size->px+win_size->sx-ATB_display_StringWidth(&data->result, &format), | 440 ATB_display_Text(win_size->px+win_size->sx-ATB_display_StringWidth(&data->result, &format), |
444 win_size->py+win_size->sy,&format, &data->result); | 441 win_size->py+win_size->sy,&format, &data->result); |
445 } | 442 } |
446 | 443 |
447 /* Display Soft Keys */ | 444 /* Display Soft Keys */ |
448 //xrashmic 20 Oct, 2005 MMI-SPR-33845 | 445 //xrashmic 20 Oct, 2005 MMI-SPR-33845 |
449 //Need to display the alternate right softkey when the editor is does not contain any character other than 0. | 446 //Need to display the alternate right softkey when the editor is does not contain any character other than 0. |
450 if (data->editor_data.editor_attr.text.len == data->editor_data.min_enter && (data->editor_data.editor_attr.text.data[0] == '0')) | 447 if (data->editor_data.editor_attr.text.len == data->editor_data.min_enter && (data->editor_data.editor_attr.text.data[0] == '0')) |
451 { | 448 { |
452 /* entered less than the required number of chars: Alternate Softkey appears */ | 449 /* entered less than the required number of chars: Alternate Softkey appears */ |
453 displaySoftKeys(data->editor_data.LeftSoftKey,data->editor_data.AltRightSoftKey); | 450 displaySoftKeys(data->editor_data.LeftSoftKey,data->editor_data.AltRightSoftKey); |
454 } | 451 } |
455 else | 452 else |
456 { | 453 { |
457 /* entered sufficient number of chars: Normal Softkey appears */ | 454 /* entered sufficient number of chars: Normal Softkey appears */ |
458 displaySoftKeys(data->editor_data.LeftSoftKey, data->editor_data.RightSoftKey); | 455 displaySoftKeys(data->editor_data.LeftSoftKey, data->editor_data.RightSoftKey); |
459 } | 456 } |
460 } | 457 } |
461 } | 458 } |
462 break; | 459 break; |
463 } | 460 } |
464 | 461 |
465 data->editor->update = ED_UPDATE_DEFAULT; | 462 data->editor->update = ED_UPDATE_DEFAULT; |
466 | 463 |
467 return MFW_EVENT_CONSUMED; | 464 return MFW_EVENT_CONSUMED; |
468 } | 465 } |
469 | 466 |
470 | 467 |
471 /******************************************************************************* | 468 /******************************************************************************* |
472 | 469 |
473 $Function: AUI_calc_KbdCb | 470 $Function: AUI_calc_KbdCb |
474 | 471 |
475 $Description: Calc editor keyboard event handler | 472 $Description: Calc editor keyboard event handler |
476 | 473 |
477 $Returns: None. | 474 $Returns: None. |
478 | 475 |
479 $Arguments: event - The keyboard event | 476 $Arguments: event - The keyboard event |
480 keyboard - The keypress info | 477 keyboard - The keypress info |
481 | 478 |
482 *******************************************************************************/ | 479 *******************************************************************************/ |
483 | 480 |
484 static int AUI_calc_KbdCb(T_MFW_EVENT event, T_MFW_KBD *keyboard) | 481 static int AUI_calc_KbdCb(T_MFW_EVENT event, T_MFW_KBD *keyboard) |
485 { | 482 { |
486 T_MFW_HND win = mfw_parent (mfw_header()); | 483 T_MFW_HND win = mfw_parent (mfw_header()); |
487 T_MFW_WIN *win_data = ((T_MFW_HDR *)win)->data; | 484 T_MFW_WIN *win_data = ((T_MFW_HDR *)win)->data; |
488 T_AUI_CALC_DATA *data = (T_AUI_CALC_DATA *)win_data->user; | 485 T_AUI_CALC_DATA *data = (T_AUI_CALC_DATA *)win_data->user; |
489 ED_RES result; | 486 ED_RES result; |
490 | 487 |
491 TRACE_FUNCTION("AUI_calc_KbdCb()"); | 488 TRACE_FUNCTION("AUI_calc_KbdCb()"); |
492 | 489 |
493 /* Suppress unwanted long keypresses */ | 490 /* Suppress unwanted long keypresses */ |
494 | 491 |
495 data->doNextLongPress = TRUE; /* next Key_long event is correct */ | 492 data->doNextLongPress = TRUE; /* next Key_long event is correct */ |
496 data->editor->update = ED_UPDATE_DEFAULT; /* Default behaviour is just to update text */ | 493 data->editor->update = ED_UPDATE_DEFAULT; /* Default behaviour is just to update text */ |
497 | 494 |
498 switch (keyboard->code) | 495 switch (keyboard->code) |
499 { | 496 { |
500 #ifdef COLOURDISPLAY | 497 #ifdef COLOURDISPLAY |
501 case KCD_MNUSELECT: | 498 case KCD_MNUSELECT: |
502 if (data->editor_data.Callback) | 499 if (data->editor_data.Callback) |
503 (data->editor_data.Callback) (data->parent, data->editor_data.Identifier, INFO_KCD_SELECT); | 500 (data->editor_data.Callback) (data->parent, data->editor_data.Identifier, INFO_KCD_SELECT); |
504 break; | 501 break; |
505 | 502 |
506 #endif /* COLOURDISPLAY */ | 503 #endif /* COLOURDISPLAY */ |
507 | 504 |
508 case KCD_STAR: | 505 case KCD_STAR: |
509 if (data->editor_data.Callback) | 506 if (data->editor_data.Callback) |
510 (data->editor_data.Callback) (data->parent, data->editor_data.Identifier, INFO_KCD_STAR); | 507 (data->editor_data.Callback) (data->parent, data->editor_data.Identifier, INFO_KCD_STAR); |
511 break; | 508 break; |
512 | 509 |
513 case KCD_HASH: | 510 case KCD_HASH: |
514 /* Insert decimal point, if the number doesn't have one already */ | 511 /* Insert decimal point, if the number doesn't have one already */ |
515 if (!data->hasDecimalPoint) | 512 if (!data->hasDecimalPoint) |
516 { | 513 { |
517 data->hasDecimalPoint = TRUE; | 514 data->hasDecimalPoint = TRUE; |
518 AUI_entry_EditChar(data->entry_data, UNICODE_FULLSTOP, FALSE); | 515 AUI_entry_EditChar(data->entry_data, UNICODE_FULLSTOP, FALSE); |
519 win_show(data->win); | 516 win_show(data->win); |
520 } | 517 } |
521 break; | 518 break; |
522 | 519 |
523 case KCD_LEFT: | 520 case KCD_LEFT: |
524 if (data->editor_data.editor_attr.text.len < data->editor_data.min_enter) | 521 if (data->editor_data.editor_attr.text.len < data->editor_data.min_enter) |
525 { | 522 { |
526 /* Entered less than the required number of chars */ | 523 /* Entered less than the required number of chars */ |
527 if (data->editor_data.AltLeftSoftKey!=TxtNull) | 524 if (data->editor_data.AltLeftSoftKey!=TxtNull) |
528 { | 525 { |
529 /* an alternate softkey is defined: execute it */ | 526 /* an alternate softkey is defined: execute it */ |
530 SEND_EVENT (win, E_CALC_DEINIT, INFO_KCD_ALTERNATELEFT, NULL); | 527 SEND_EVENT (win, E_CALC_DEINIT, INFO_KCD_ALTERNATELEFT, NULL); |
531 } | 528 } |
532 } | 529 } |
533 else if (data->editor_data.LeftSoftKey!=TxtNull) | 530 else if (data->editor_data.LeftSoftKey!=TxtNull) |
534 { | 531 { |
535 /* Left Softkey is enabled (and entered sufficient number of chars): execute it */ | 532 /* Left Softkey is enabled (and entered sufficient number of chars): execute it */ |
536 SEND_EVENT (win, E_CALC_DEINIT, INFO_KCD_LEFT, NULL); | 533 SEND_EVENT (win, E_CALC_DEINIT, INFO_KCD_LEFT, NULL); |
537 } | 534 } |
538 break; | 535 break; |
539 | 536 |
540 case KCD_HUP: | 537 case KCD_HUP: |
541 SEND_EVENT(data->win, E_CALC_DEINIT, INFO_KCD_HUP, 0); | 538 SEND_EVENT(data->win, E_CALC_DEINIT, INFO_KCD_HUP, 0); |
542 break; | 539 break; |
543 | 540 |
544 case KCD_RIGHT: | 541 case KCD_RIGHT: |
545 /* If we're deleting the decimal point... */ | 542 /* If we're deleting the decimal point... */ |
546 if (ATB_edit_GetCursorChar(data->editor, -1)==UNICODE_FULLSTOP) | 543 if (ATB_edit_GetCursorChar(data->editor, -1)==UNICODE_FULLSTOP) |
547 { | 544 { |
548 data->hasDecimalPoint = FALSE; | 545 data->hasDecimalPoint = FALSE; |
549 } | 546 } |
550 | 547 |
551 /* If we've just got a zero, delete it so we can exit with next call to ATB_edit_DeleteLeft() */ | 548 /* If we've just got a zero, delete it so we can exit with next call to ATB_edit_DeleteLeft() */ |
552 | 549 |
553 if (ATB_edit_GetCursorChar(data->editor, -1)==ATB_char_Unicode('0')) | 550 if (ATB_edit_GetCursorChar(data->editor, -1)==ATB_char_Unicode('0')) |
554 { | 551 { |
555 ATB_edit_DeleteLeft(data->editor, FALSE); /* SPR#2342 - SH */ | 552 ATB_edit_DeleteLeft(data->editor, FALSE); /* SPR#2342 - SH */ |
556 } | 553 } |
557 | 554 |
558 /* Perform normal delete */ | 555 /* Perform normal delete */ |
559 result = ATB_edit_DeleteLeft(data->editor, TRUE); /* SPR#2342 - SH */ | 556 result = ATB_edit_DeleteLeft(data->editor, TRUE); /* SPR#2342 - SH */ |
560 | 557 |
561 /* If buffer is now empty, insert '0' */ | 558 /* If buffer is now empty, insert '0' */ |
562 if (data->editor->attr->text.len==0 && result!=ED_DONE) | 559 if (data->editor->attr->text.len==0 && result!=ED_DONE) |
563 { | 560 { |
564 AUI_entry_EditChar(data->entry_data, ATB_char_Unicode('0'), FALSE); | 561 AUI_entry_EditChar(data->entry_data, ATB_char_Unicode('0'), FALSE); |
565 } | 562 } |
566 | 563 |
567 /* If we've deleted on an empty buffer, exit editor */ | 564 /* If we've deleted on an empty buffer, exit editor */ |
568 if (result==ED_DONE) | 565 if (result==ED_DONE) |
569 { | 566 { |
570 SEND_EVENT(data->win, E_CALC_DEINIT, INFO_KCD_RIGHT, 0); | 567 SEND_EVENT(data->win, E_CALC_DEINIT, INFO_KCD_RIGHT, 0); |
571 } | 568 } |
572 else | 569 else |
573 { | 570 { |
574 win_show(data->win); | 571 win_show(data->win); |
575 } | 572 } |
576 break; | 573 break; |
577 | 574 |
578 /* 0 - 9 */ | 575 /* 0 - 9 */ |
579 | 576 |
580 case KCD_0: | 577 case KCD_0: |
581 case KCD_1: | 578 case KCD_1: |
582 case KCD_2: | 579 case KCD_2: |
583 case KCD_3: | 580 case KCD_3: |
584 case KCD_4: | 581 case KCD_4: |
585 case KCD_5: | 582 case KCD_5: |
586 case KCD_6: | 583 case KCD_6: |
587 case KCD_7: | 584 case KCD_7: |
588 case KCD_8: | 585 case KCD_8: |
589 case KCD_9: | 586 case KCD_9: |
590 /* Remove leading zero */ | 587 /* Remove leading zero */ |
591 if (data->editor->attr->text.len==1 && ATB_edit_GetCursorChar(data->editor, -1)==ATB_char_Unicode('0')) | 588 if (data->editor->attr->text.len==1 && ATB_edit_GetCursorChar(data->editor, -1)==ATB_char_Unicode('0')) |
592 { | 589 { |
593 ATB_edit_DeleteLeft(data->editor, FALSE); /* SPR#2342 - SH */ | 590 ATB_edit_DeleteLeft(data->editor, FALSE); /* SPR#2342 - SH */ |
594 } | 591 } |
595 | 592 |
596 /* Insert the digit */ | 593 /* Insert the digit */ |
597 AUI_entry_EventKey(data->entry_data, event, keyboard); | 594 AUI_entry_EventKey(data->entry_data, event, keyboard); |
598 win_show(data->win); | 595 win_show(data->win); |
599 break; | 596 break; |
600 } | 597 } |
601 | 598 |
602 return MFW_EVENT_CONSUMED; | 599 return MFW_EVENT_CONSUMED; |
603 } | 600 } |
604 | 601 |
605 | 602 |
606 /******************************************************************************* | 603 /******************************************************************************* |
607 | 604 |
608 $Function: AUI_calc_KbdLongCb | 605 $Function: AUI_calc_KbdLongCb |
609 | 606 |
610 $Description: Calc editor long keypress event handler | 607 $Description: Calc editor long keypress event handler |
611 | 608 |
612 $Returns: None. | 609 $Returns: None. |
613 | 610 |
614 $Arguments: event - The keyboard event | 611 $Arguments: event - The keyboard event |
615 keyboard - The keypress info | 612 keyboard - The keypress info |
616 | 613 |
617 *******************************************************************************/ | 614 *******************************************************************************/ |
618 | 615 |
619 static int AUI_calc_KbdLongCb(T_MFW_EVENT event, T_MFW_KBD *keyboard) | 616 static int AUI_calc_KbdLongCb(T_MFW_EVENT event, T_MFW_KBD *keyboard) |
620 { | 617 { |
621 T_MFW_HND win = mfw_parent (mfw_header()); | 618 T_MFW_HND win = mfw_parent (mfw_header()); |
622 T_MFW_WIN *win_data = ((T_MFW_HDR *)win)->data; | 619 T_MFW_WIN *win_data = ((T_MFW_HDR *)win)->data; |
623 T_AUI_CALC_DATA *data = (T_AUI_CALC_DATA *)win_data->user; | 620 T_AUI_CALC_DATA *data = (T_AUI_CALC_DATA *)win_data->user; |
624 ED_RES result; | 621 ED_RES result; |
625 | 622 |
626 /* Suppress unwanted long keypresses */ | 623 /* Suppress unwanted long keypresses */ |
627 | 624 |
628 if ( data->doNextLongPress ) | 625 if ( data->doNextLongPress ) |
629 data->doNextLongPress = FALSE; /* mark Key_long event as consumed but do current long press */ | 626 data->doNextLongPress = FALSE; /* mark Key_long event as consumed but do current long press */ |
630 else | 627 else |
631 return MFW_EVENT_CONSUMED; /* don't do current long press */ | 628 return MFW_EVENT_CONSUMED; /* don't do current long press */ |
632 | 629 |
633 switch (keyboard->code) | 630 switch (keyboard->code) |
634 { | 631 { |
635 case KCD_RIGHT: | 632 case KCD_RIGHT: |
636 /* Long press of RSK deletes buffer */ | 633 /* Long press of RSK deletes buffer */ |
637 result = ATB_edit_ClearAll(data->editor); | 634 result = ATB_edit_ClearAll(data->editor); |
638 | 635 |
639 /* If buffer is now empty, insert '0' */ | 636 /* If buffer is now empty, insert '0' */ |
640 if (data->editor->attr->text.len==0 && result!=ED_DONE) | 637 if (data->editor->attr->text.len==0 && result!=ED_DONE) |
641 { | 638 { |
642 AUI_entry_EditChar(data->entry_data, ATB_char_Unicode('0'), FALSE); | 639 AUI_entry_EditChar(data->entry_data, ATB_char_Unicode('0'), FALSE); |
643 } | 640 } |
644 | 641 |
645 /* If we've deleted on an empty buffer, exit editor */ | 642 /* If we've deleted on an empty buffer, exit editor */ |
646 if (result==ED_DONE) | 643 if (result==ED_DONE) |
647 { | 644 { |
648 SEND_EVENT(data->win, E_CALC_DEINIT, INFO_KCD_RIGHT, 0); | 645 SEND_EVENT(data->win, E_CALC_DEINIT, INFO_KCD_RIGHT, 0); |
649 } | 646 } |
650 else | 647 else |
651 { | 648 { |
652 win_show(data->win); | 649 win_show(data->win); |
653 } | 650 } |
654 break; | 651 break; |
655 } | 652 } |
656 | 653 |
657 return MFW_EVENT_CONSUMED; | 654 return MFW_EVENT_CONSUMED; |
658 } | 655 } |