comparison g23m/condat/ms/src/bmi/MmiLatinPredText.c @ 0:509db1a7b7b8

initial import: leo2moko-r1
author Space Falcon <falcon@ivan.Harhan.ORG>
date Mon, 01 Jun 2015 03:24:05 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:509db1a7b7b8
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
14 $Module: MMI
15 $File: MmiLatinPredText.c
16 $Revision: 1.0
17
18 $Author: Condat(UK)
19 $Date:
20
21 ********************************************************************************
22
23 Description: Latin alphabet predictiev text editor. English-only for the moment.
24
25
26
27 ********************************************************************************
28
29 $History: MmLatinPredText.c
30 03/10/02 Replaced most of the file with version on 3.3.3 line (MC, SPR 1242)
31
32 $End
33
34 *******************************************************************************/
35
36 #include <stdio.h>
37 #include <string.h>
38 #include <stdlib.h>
39
40
41 #if defined (NEW_FRAME)
42
43 #include "typedefs.h"
44 #include "Vsi.h"
45 #include "PEI.H"
46 #include "custom.h"
47 #include "gsm.h"
48
49 #else
50
51 #include "STDDEFS.H"
52 #include "custom.h"
53 #include "gsm.h"
54 #include "vsi.h"
55
56 #endif
57
58 #include "mfw_mfw.h"
59 #include "mfw_win.h"
60 #include "mfw_kbd.h"
61 #include "mfw_edt.h"
62 #include "mfw_tim.h"
63 #include "mfw_phb.h"
64 #include "mfw_sms.h"
65 #include "mfw_ss.h"
66 #include "mfw_icn.h"
67 #include "mfw_mnu.h"
68 #include "mfw_lng.h"
69 #include "mfw_sat.h"
70 #include "mfw_kbd.h"
71 #include "mfw_nm.h"
72 #include "mfw_cm.h"
73
74 #include "dspl.h"
75
76 #include "ksd.h"
77 #include "psa.h"
78
79
80 #include "MmiMain.h"
81 #include "MmiDummy.h"
82 #include "MmiMmi.h"
83
84 #include "MmiDialogs.h"
85 #include "MmiLists.h"
86 #include "MmiMenu.h"
87 #include "MmiSoftKeys.h"
88 #include "MmiIdle.h"
89
90 #include "MmiEditor.h"
91 #include "MmiEditor_i.h"
92 #include "MmiDictionary.h"
93 #include "mmiColours.h"
94
95 #include "cus_aci.h"
96 #include "prim.h"
97
98
99 #ifndef MFW_EVENT_PASSED
100 #define MFW_EVENT_PASSED 0
101 #endif
102
103 //data structure for punctuation symbols selection screen
104 typedef struct
105 {
106 T_MMI_CONTROL mmi_control;
107 T_MFW_HND parent;
108 T_MFW_HND edt_win;
109 T_MFW_HND edt_edt;
110 T_MFW_HND edt_kbd;
111 T_MFW_HND edt_kbd_long;
112 T_MFW_HND edt_tim; // c015 rsa
113 T_MFW_HND edt_input; // RM 25-08
114
115 T_EDITOR_DATA editor_data;
116 UBYTE cursor_position;
117 char* output_symbol;
118
119 }
120 T_SYMBOL_INFO;
121
122 //events in main editor screen
123 typedef enum
124 {
125 EDITOR_INIT,
126 EDITOR_DEINIT,
127 EDITOR_UPDATE
128 } editor_events;
129
130 /*********************************************************************
131 **********************************************************************
132
133 DYNAMIC EDITOR WINDOW. DECLARATION
134
135 *********************************************************************
136 **********************************************************************/
137
138
139 //protoypes
140
141
142
143 static T_MFW_HND SymbolScreencreate (T_MFW_HND parent);
144 static int SymbolScreenwin_cb (T_MFW_EVENT event, T_MFW_WIN * win);
145 static int SymbolScreenkbd_cb (T_MFW_EVENT event, T_MFW_KBD *keyboard);
146 static void SymbolScreenexec_cb (T_MFW_HND win, USHORT event, SHORT value, char * symbol);
147
148 char SymbolChar;
149
150
151
152 /*******************************************************************************
153
154 $Function: SymbolScreendestroy
155
156 $Description: Destroy thesymbol screen
157
158 $Returns: None.
159
160 $Arguments: window handle
161
162 *******************************************************************************/
163
164 void SymbolScreendestroy (T_MFW_HND window)
165 {
166 T_MFW_WIN * win = ((T_MFW_HDR *)window)->data;
167 T_SYMBOL_INFO * data = (T_SYMBOL_INFO *)win->user;
168 char Punctuation_symbol = *data->output_symbol;
169 TRACE_FUNCTION ("SymbolScreendestroy()");
170
171
172 SEND_EVENT (data->parent, EDITOR_UPDATE,(short)Punctuation_symbol, NULL);
173 if (data)
174 {
175 /*
176 * Delete WIN Handler
177 */
178 win_delete (data->edt_win);
179 /*
180 * Free Memory
181 */
182 FREE_MEMORY ((void *)data, sizeof (T_SYMBOL_INFO));
183 }
184 else
185 {
186 TRACE_EVENT ("SymbolScreendestroy() called twice");
187 return ;
188 }
189 }
190
191
192 /*******************************************************************************
193
194 $Function: SymbolScreenstart
195
196 $Description: Starts the symbol screen
197
198 $Returns: handle
199
200 $Arguments: parent window, editor data
201
202 *******************************************************************************/
203 T_MFW_HND SymbolScreenstart (T_MFW_HND parent, char * symbol)
204 {
205 T_MFW_HND win;
206
207
208 TRACE_FUNCTION ("SymbolScreenstart()");
209
210 win = SymbolScreencreate (parent);
211
212 if (win NEQ NULL)
213 {
214 SEND_EVENT (win, E_EDITOR_INIT, 0, 0);
215 }
216 return win;
217 }
218
219
220 /*******************************************************************************
221
222 $Function: LatinEditorcreate
223
224 $Description: Creation of a symbol screen
225
226 $Returns: handle of new window
227
228 $Arguments: parent window
229
230 *******************************************************************************/
231 static T_MFW_HND SymbolScreencreate (T_MFW_HND parent)
232 {
233 T_SYMBOL_INFO * data = (T_SYMBOL_INFO *)ALLOC_MEMORY (sizeof (T_SYMBOL_INFO));
234 T_MFW_WIN * win;
235
236 TRACE_FUNCTION ("SymbolScreencreate()");
237
238 /*
239 * Create window handler
240 */
241
242 data->edt_win = win_create (parent, 0, E_WIN_VISIBLE, (T_MFW_CB)SymbolScreenwin_cb);
243
244 if (data->edt_win EQ NULL)
245 {
246 return NULL;
247 }
248
249 /*
250 * connect the dialog data to the MFW-window
251 */
252
253
254 data->mmi_control.dialog = (T_DIALOG_FUNC)SymbolScreenexec_cb;
255 data->mmi_control.data = data;
256 data->parent = parent;
257 win = ((T_MFW_HDR *)data->edt_win)->data;
258 win->user = (void *)data;
259
260 return data->edt_win;
261 }
262
263 /*******************************************************************************
264
265 $Function: SymbolScreenexec_cb
266
267 $Description: handles events for symbol window
268
269 $Returns: None.
270
271 $Arguments: window, event, value, editor data
272
273 *******************************************************************************/
274 static void SymbolScreenexec_cb (T_MFW_HND win, USHORT event, SHORT value, char * symbol)
275 {
276 T_MFW_WIN * win_data = ((T_MFW_HDR *)win)->data;
277 T_SYMBOL_INFO * data = (T_SYMBOL_INFO *)win_data->user;
278
279 T_MFW_HND parent_win = data->parent;
280 USHORT Identifier = data->editor_data.Identifier;
281 T_EDIT_CB Callback = data->editor_data.Callback;
282 char debug[20];
283 char* symStr = ".,?!:;-+#*()\'\"_@&$£%/<>=";
284
285 TRACE_FUNCTION ("SymbolScreenexec_cb()");
286
287 switch (event)
288 {
289 case E_EDITOR_INIT:
290
291
292 /* Note that we do not copy the edited buffer here */
293 data->editor_data.editor_attr.predText[0] = '\0';
294
295 /*
296 * Create the handler
297 */
298 data->edt_kbd = kbd_create (data->edt_win, KEY_ALL, (T_MFW_CB)SymbolScreenkbd_cb);
299 data->edt_edt = edtCreate (data->edt_win, &data->editor_data.editor_attr,MfwEdtVisible,0);
300
301 /*
302 * Set the mode for the editor
303 */
304 editor_attr_init(&data->editor_data.editor_attr, 0, edtCurMask, NULL, symStr, strlen(symStr), COLOUR_EDITOR );
305 editActivate(data->edt_edt,ALPHA_MODE);
306 data->output_symbol = symbol;
307 data->cursor_position = 0;
308
309 edtChar(data->edt_edt,ecTop); /* in read-only mode set cursor to begin */
310 win_show(data->edt_win);
311
312 break;
313
314 case E_EDITOR_DEINIT:
315
316 SymbolScreendestroy (data->edt_win);
317 break;
318
319 default:
320 break;
321 }
322 }
323 /*******************************************************************************
324
325 $Function: SymbolScreenwin_cb
326
327 $Description: Editor window event handler.
328
329 $Returns: status int
330
331 $Arguments: event, window
332
333 *******************************************************************************/
334 static int SymbolScreenwin_cb (T_MFW_EVENT event, T_MFW_WIN * win)
335 {
336 T_SYMBOL_INFO * data = (T_SYMBOL_INFO *)win->user;
337 TRACE_FUNCTION ("SymbolScreen_win_cb()");
338
339
340 if (data->edt_edt!=activeEditor())
341 editActivate(data->edt_edt,data->editor_data.mode);
342 if (data EQ 0)
343 {
344 return MFW_EVENT_CONSUMED;
345 }
346
347 switch (event)
348 {
349 case E_WIN_VISIBLE: /* window is visible */
350 if (win->flags & E_WIN_VISIBLE)
351 {
352 /*
353 * Clear Screen
354 */
355 dspl_ClearAll();
356
357 /*
358 * Print the information
359 */
360 edtShow(data->edt_edt);
361
362 /*
363 * Print the softkeys
364 */
365 displaySoftKeys(TxtSoftSelect, TxtSoftBack);
366
367 }
368 break;
369 default:
370 return MFW_EVENT_PASSED;
371 }
372 return MFW_EVENT_CONSUMED;
373 }
374 /*******************************************************************************
375
376 $Function: SymbolScreen_kbd_cb
377
378 $Description: Symbol screen keyboard event handler
379
380 $Returns: None.
381
382 $Arguments: event, keyborad data
383
384 *******************************************************************************/
385 static int SymbolScreenkbd_cb (T_MFW_EVENT event, T_MFW_KBD *keyboard)
386 {
387 T_MFW_HND win = mfw_parent (mfw_header());
388 T_MFW_WIN * win_data = ((T_MFW_HDR *)win)->data;
389 T_SYMBOL_INFO * data = (T_SYMBOL_INFO *)win_data->user;
390 char debug[20];
391 TRACE_FUNCTION ("SymbolScreen_kbd_cb()");
392
393
394
395 switch (keyboard->code)
396 {
397 case KCD_MNUUP:
398 edtChar(data->edt_edt,ecLeft);
399 if (data->cursor_position > 0)
400 data->cursor_position--;
401 edtShow(data->edt_edt);
402 break;
403
404 case KCD_MNUDOWN:
405 edtChar(data->edt_edt,ecRight);
406 if (data->cursor_position < strlen(data->editor_data.editor_attr.text))
407 data->cursor_position++;
408 edtShow(data->edt_edt);
409 break;
410
411 case KCD_LEFT:
412 *data->output_symbol = data->editor_data.editor_attr.text[data->cursor_position];
413 SymbolChar = data->editor_data.editor_attr.text[data->cursor_position];
414 TRACE_EVENT(debug);
415 SymbolScreendestroy(data->edt_win);
416 break;
417
418
419 case KCD_HUP:
420 case KCD_RIGHT:
421 *data->output_symbol = '\0';
422 SymbolChar ='\0' ;
423 SymbolScreendestroy(data->edt_win);
424
425 break;
426
427 }
428
429 return MFW_EVENT_CONSUMED;
430 }
431