comparison src/aci2/bmi/mmiSoftKeys.c @ 120:3c2acfa1a72f

src/aci2/bmi: file renames to make filename case consistent
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 07 Oct 2016 03:46:05 +0000
parents src/aci2/bmi/MmiSoftKeys.c@93999a60b835
children
comparison
equal deleted inserted replaced
119:b92a33c204b6 120:3c2acfa1a72f
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: Softkeys
15 $File: MmiSoftkeys.c
16 $Revision: 1.0
17
18 $Author: Condat(UK)
19 $Date: 22/02/01
20
21 ********************************************************************************
22
23 Description:
24
25
26
27 ********************************************************************************
28
29 $History:
30
31 xrashmic 5 Oct, 2005 MMI-SPR-29356, MMI-SPR-29357
32 To display '?' to indicate to the user that help is available for a STK menu
33
34 25/10/00 Original Condat(UK) BMI version.
35
36 $End
37
38 *******************************************************************************/
39
40
41 /*******************************************************************************
42
43 Include Files
44
45 *******************************************************************************/
46
47 #define ENTITY_MFW
48
49 /* includes */
50 #include <string.h>
51 #include <stdio.h>
52 #include <stdlib.h>
53
54
55 #if defined (NEW_FRAME)
56
57 #include "typedefs.h"
58 #include "vsi.h"
59 #include "pei.h"
60 #include "custom.h"
61 #include "gsm.h"
62
63 #else
64
65 #include "STDDEFS.H"
66 #include "custom.h"
67 #include "gsm.h"
68 #include "vsi.h"
69
70 #endif
71 #include "mfw_sys.h"
72 #include "prim.h"
73
74 #include "mfw_mfw.h"
75 #include "mfw_win.h"
76 #include "mfw_kbd.h"
77 #include "mfw_lng.h"
78 #include "mfw_phb.h"
79 #include "mfw_nm.h"
80 #include "dspl.h"
81
82 #include "ksd.h"
83 #include "psa.h"
84
85
86 #include "MmiMmi.h"
87 #include "MmiMain.h"
88
89 #include "MmiUserData.h"
90 #include "MmiSoftKeys.h"
91 #include "MmiResources.h"
92
93 #include "mmiColours.h"
94
95 typedef struct
96 {
97 MfwHnd leftKeyHandler;
98 MfwHnd rightKeyHandler;
99
100 LangTxt leftKeyLabel;
101 LangTxt rightKeyLabel;
102 } SoftKeysData, *SoftKeys;
103
104
105 #ifdef LSCREEN
106 #define HorizontalOffset 4
107 #else
108 #define HorizontalOffset 1
109 #endif
110 #define LeftMargin (HorizontalOffset)
111 #define RightMargin (HorizontalOffset)
112
113 #define ALLOC_MEMORY mfwAlloc
114 #define FREE_MEMORY mfwFree
115
116 static U8 softKeyFont = 0;
117 static UBYTE softKeysDisplayAttibutes = DSPL_TXTATTR_NORMAL;
118
119
120 /*
121 * Change the <font> and <displayAttibutes> for _all_ softkeys.
122 * All consecutive calls of softKeysUpdate() will reflect the change.
123 * Returns SOFTKEYS_CHANGED when everything went fine,
124 * or SOFTKEYS_FAILURE on failure.
125 */
126 SoftKeysResult softKeysAttributes( U8 font, UBYTE displayAttibutes)
127 {
128 if( font == (U8)-1 )
129 {
130 return SOFTKEYS_FAILURE;
131 }
132
133 softKeyFont = font;
134 softKeysDisplayAttibutes = displayAttibutes;
135
136 return SOFTKEYS_CHANGED;
137 }
138
139
140 /*
141 * Creates the softkeys for <window>, which will display the
142 * <leftKeyLabel> and <rightKeyLabel> in the softkey area
143 * on the screen, and invoke <leftKeyCallBack> or <rightKeyCallBack>
144 * when the approrpiate key is pressed. Returns SOFTKEYS_CREATED when
145 * everything went fine, or SOFTKEYS_FAILURE on failure.
146 */
147 SoftKeysResult softKeysHndCreate( MfwHnd window, SoftKeysSetup *setup)
148 {
149 if( window == NULL || setup == NULL )
150 {
151 return SOFTKEYS_FAILURE;
152 }
153
154 return softKeysWinCreate( (MfwWin *)((MfwHdr *)window)->data, setup);
155 }
156
157
158 SoftKeysResult softKeysWinCreate( MfwWin *window, SoftKeysSetup *setup)
159 {
160 SoftKeys newKeys;
161
162 if( window == NULL || setup == NULL )
163 {
164 return SOFTKEYS_FAILURE;
165 }
166
167 newKeys = (SoftKeys)ALLOC_MEMORY(sizeof(SoftKeysData));
168
169 if( newKeys == NULL )
170 {
171 return SOFTKEYS_FAILURE;
172 }
173
174 if( userDataWinSet( window, UD_SOFTKEYS, (void *)newKeys) == NULL )
175 {
176 FREE_MEMORY( (void *)newKeys, sizeof(SoftKeysData));
177
178 return SOFTKEYS_FAILURE;
179 }
180
181 newKeys->leftKeyHandler = kbdCreate( NULL, KEY_LEFT,
182 setup->leftKeyCallBack);
183 newKeys->rightKeyHandler = kbdCreate( NULL, KEY_RIGHT,
184 setup->rightKeyCallBack);
185
186 newKeys->leftKeyLabel = setup->leftKeyLabel;
187 newKeys->rightKeyLabel = setup->rightKeyLabel;
188
189 if( newKeys->leftKeyHandler == NULL || newKeys->rightKeyHandler == NULL )
190 {
191 kbdDelete(newKeys->leftKeyHandler);
192 kbdDelete(newKeys->rightKeyHandler);
193
194 userDataWinDelete( window, UD_SOFTKEYS);
195
196 FREE_MEMORY( (void *)newKeys, sizeof(SoftKeysData));
197
198 return SOFTKEYS_FAILURE;
199 }
200
201 return SOFTKEYS_CREATED;
202 }
203
204
205 /*
206 * Change the setup of the softkeys for <window>. Use TxtNull if you
207 * don't want to change a ...Label, and NULL if you don't want to change
208 * a ...CallBack. Returns SOFTKEYS_CHANGED when everything went fine,
209 * or SOFTKEYS_FAILURE on failure.
210 */
211 SoftKeysResult softKeysHndSet( MfwHnd window, SoftKeysSetup *changes)
212 {
213 if( window == NULL || changes == NULL )
214 {
215 return SOFTKEYS_FAILURE;
216 }
217
218 return softKeysWinSet( (MfwWin *)((MfwHdr *)window)->data, changes);
219 }
220
221
222 SoftKeysResult softKeysWinSet( MfwWin *window, SoftKeysSetup *changes)
223 {
224 SoftKeys softKeys = (SoftKeys)userDataWinGet( window, UD_SOFTKEYS);
225
226 if( window == NULL || softKeys == NULL || changes == NULL )
227 {
228 return SOFTKEYS_FAILURE;
229 }
230
231 if( changes->leftKeyCallBack != NULL )
232 {
233 MfwHnd NewKeyHandler = kbdCreate( NULL, KEY_LEFT,
234 changes->leftKeyCallBack);
235
236 if( NewKeyHandler == NULL )
237 {
238 return SOFTKEYS_FAILURE;
239 }
240 else
241 {
242 kbdDelete(softKeys->leftKeyHandler);
243
244 softKeys->leftKeyHandler = NewKeyHandler;
245 }
246 }
247
248 if( changes->rightKeyCallBack != NULL )
249 {
250 MfwHnd NewKeyHandler = kbdCreate( NULL, KEY_LEFT,
251 changes->rightKeyCallBack);
252
253 if( NewKeyHandler == NULL )
254 {
255 return SOFTKEYS_FAILURE;
256 }
257 else
258 {
259 kbdDelete(softKeys->rightKeyHandler);
260
261 softKeys->rightKeyHandler = NewKeyHandler;
262 }
263 }
264
265 if( changes->leftKeyLabel != TxtNull )
266 {
267 softKeys->leftKeyLabel = changes->leftKeyLabel;
268 }
269
270 if( changes->rightKeyLabel != TxtNull )
271 {
272 softKeys->rightKeyLabel = changes->rightKeyLabel;
273 }
274
275 return SOFTKEYS_CHANGED;
276 }
277
278
279 /*
280 * You will need to call this whenever <window> is updated.
281 */
282 void softKeysHndUpdate(MfwHnd window)
283 {
284 if( window == NULL )
285 {
286 return;
287 }
288
289 softKeysWinUpdate((MfwWin *)((MfwHdr *)window)->data);
290 }
291
292
293 void softKeysWinUpdate(MfwWin *window)
294 {
295 SoftKeys softKeys = (SoftKeys)userDataWinGet( window, UD_SOFTKEYS);
296 U8 oldFont = dspl_SelectFontbyID(softKeyFont);
297
298 if( window == NULL || softKeys == NULL )
299 {
300 return;
301 }
302
303 PROMPT( LeftMargin,Mmi_layout_line(LAST_LINE_TOP), 0, softKeys->leftKeyLabel);
304
305 dspl_SelectFontbyID(oldFont);
306 }
307
308
309 /*
310 * Deletes the softkeys for <window>.
311 */
312 void softkeysHndDelete(MfwHnd window)
313 {
314 if( window == NULL )
315 {
316 return;
317 }
318
319 softkeysWinDelete((MfwWin *)((MfwHdr *)window)->data);
320 }
321
322
323 void softkeysWinDelete(MfwWin *window)
324 {
325 SoftKeys softKeys = (SoftKeys)userDataWinDelete( window, UD_SOFTKEYS);
326
327 if( window == NULL || softKeys == NULL )
328 {
329 return;
330 }
331
332 kbdDelete(softKeys->leftKeyHandler);
333 kbdDelete(softKeys->rightKeyHandler);
334
335 FREE_MEMORY( (void *)softKeys, sizeof(SoftKeysData));
336 }
337 typedef struct {
338 char* str;
339 int posX;
340 int posY;
341 } T_SK_DATA;
342 typedef struct {
343 T_SK_DATA lsk;
344 T_SK_DATA rsk;
345 MfwRect* rect;
346 } T_SK_DSPL_STRUCT;
347
348 /*******************************************************************************
349
350 $Function:
351
352 $Description:
353
354 $Returns:
355
356 $Arguments:
357
358 $History
359 GW 28/11/02 -
360
361 *******************************************************************************/
362 static void softKeys_displayAll(T_SK_DSPL_STRUCT* sk_data , int format, unsigned int colIndex )
363 {
364 resources_setSKColour(colIndex);
365 // #ifdef COLOURDISPLAY
366 dspl_Clear( sk_data->rect->px,
367 sk_data->rect->py,
368 sk_data->rect->px+sk_data->rect->sx-1,
369 sk_data->rect->py+sk_data->rect->sy-1);
370 /* Line height must be less than rect.sy */
371 // #endif
372 if (sk_data->lsk.str!= NULL)
373 dspl_TextOut(sk_data->lsk.posX, sk_data->lsk.posY,DSPL_TXTATTR_CURRENT_MODE, sk_data->lsk.str);
374 if (sk_data->rsk.str!= NULL)
375 dspl_TextOut(sk_data->rsk.posX, sk_data->rsk.posY,DSPL_TXTATTR_CURRENT_MODE, sk_data->rsk.str);
376 resources_restoreMnuColour();
377 }
378
379 /*******************************************************************************
380
381 $Function:
382
383 $Description:
384
385 $Returns:
386
387 $Arguments:
388
389 $History
390 GW 28/11/02 -
391
392 *******************************************************************************/
393 void softKeys_displayStrXY(char* leftSoftKey_str,char* rightSoftKey_str, int format, unsigned int colIndex, MfwRect* rect )
394 {
395 MfwRect defRect;
396
397 T_SK_DSPL_STRUCT sk_data;
398 sk_data.lsk.str = leftSoftKey_str;
399 sk_data.rsk.str = rightSoftKey_str;
400 if (rect != NULL)
401 sk_data.rect = rect;
402 else
403 {
404 Mmi_layout_softkeyArea( &defRect );
405 sk_data.rect = &defRect;
406 }
407 sk_data.lsk.posY = sk_data.rect->py + (sk_data.rect->sy-Mmi_layout_line_height())/2;
408 sk_data.rsk.posY = sk_data.lsk.posY;
409 sk_data.lsk.posX = sk_data.rect->px+LeftMargin;
410 sk_data.rsk.posX = sk_data.rect->px+sk_data.rect->sx-RightMargin-dspl_GetTextExtent(sk_data.rsk.str, 0);
411
412 softKeys_displayAll( &sk_data , format, colIndex);
413 }
414 /*******************************************************************************
415
416 $Function:
417
418 $Description:
419
420 $Returns:
421
422 $Arguments:
423
424 $History
425 GW 28/11/02 -
426
427 *******************************************************************************/
428 void softKeys_displayStr(char* leftSoftKey_str,char* rightSoftKey_str, int format, int unsigned colIndex)
429 {
430 softKeys_displayStrXY(leftSoftKey_str, rightSoftKey_str,format,colIndex, NULL);
431 }
432
433 /*******************************************************************************
434
435 $Function:
436
437 $Description:
438
439 $Returns:
440
441 $Arguments:
442
443 $History
444 GW 28/11/02 -
445
446 *******************************************************************************/
447 void softKeys_displayId(int leftSoftKey,int rightSoftKey, int format, unsigned int colIndex)
448 {
449 char *lsk,*rsk;
450 lsk = MmiRsrcGetText(leftSoftKey);
451 rsk = MmiRsrcGetText(rightSoftKey);
452 softKeys_displayStrXY(lsk,rsk,format,colIndex,NULL);
453 }
454
455 /*******************************************************************************
456
457 $Function:
458
459 $Description:
460
461 $Returns:
462
463 $Arguments:
464
465 $History
466 GW 28/11/02 -
467
468 *******************************************************************************/
469 //Old function - replace with calls to 'softKeys_displayId'
470 //GW 28/11/02 - Removed commented out code
471 void displaySoftKeys(int leftSoftKey,int rightSoftKey)
472 {
473 char *lsk,*rsk;
474 lsk = MmiRsrcGetText(leftSoftKey);
475 rsk = MmiRsrcGetText(rightSoftKey);
476 softKeys_displayStrXY(lsk,rsk,0, COLOUR_LIST_SUBMENU, NULL);
477 }
478
479 /*******************************************************************************
480
481 $Function:
482
483 $Description:
484
485 $Returns:
486
487 $Arguments:
488
489 $History
490 GW 28/11/02 -
491
492 *******************************************************************************/
493 void displaySoftKeysXY(int leftSoftKey,int rightSoftKey,int lskX,int rskX, int lpos)
494 {
495 char *lsk,*rsk;
496 MfwRect rect;
497
498 lsk = MmiRsrcGetText(leftSoftKey);
499 rsk = MmiRsrcGetText(rightSoftKey);
500 rect.px = lskX;
501 rect.py = lpos;
502 rect.sx = rskX-lskX;
503 rect.sy = Mmi_layout_softkeyHeight();
504 softKeys_displayStrXY(lsk, rsk, 0,COLOUR_LIST_MAIN, &rect);
505
506
507
508 }
509
510
511 /*******************************************************************************
512
513 $Function: displaySoftKeys_edition
514
515 $Description:
516
517 $Returns:
518
519 $Arguments:
520
521 $History
522
523 *******************************************************************************/
524 void displaySoftKeys_edition(int leftSoftKey,int index, int rightSoftKey)
525 {
526 char *lsk,*rsk, *ind;
527 USHORT lpos;
528
529 lsk = MmiRsrcGetText(leftSoftKey);
530 ind = MmiRsrcGetText(index);
531 rsk = MmiRsrcGetText(rightSoftKey);
532 lpos = Mmi_layout_line(SECOND_LAST_LINE_TOP);
533
534 dspl_TextOut(LeftMargin,lpos, 0,lsk);
535
536 dspl_TextOut( 5 + dspl_GetTextExtent(lsk, (USHORT)strlen(lsk)) ,lpos, 0, ind);
537
538 dspl_TextOut((mmiScrX-1)-RightMargin-dspl_GetTextExtent(rsk, (USHORT)strlen(rsk)),lpos ,0, rsk);
539 }
540
541
542 /*******************************************************************************
543
544 $Function: displayCustSoftKeys
545
546 $Description: Display softkeys with text strings instead of text ID's
547
548 $Returns: None
549
550 $Arguments: LeftSoftKey - char array to be displayed at the bottom-left of the display
551 or NULL if no string is to be displayed
552 RightSoftKey- char array to be displayed at the bottom-right of the display
553 or NULL if no string is to be displayed
554
555 $History
556 GW 28/11/02 -
557
558 *******************************************************************************/
559 // SH - 25/5/01
560 // This function provided for WAP, to allow the printing of custom softkeys
561 // from strings provided.
562
563 void displayCustSoftKeys(char *LeftSoftKey, char *RightSoftKey)
564 {
565 softKeys_displayStrXY(LeftSoftKey,RightSoftKey,0,COLOUR_LIST_MAIN, NULL);
566 }
567
568
569 /*******************************************************************************
570
571 $Function: displayHelpSymbol
572
573 $Description: Displaying '?' to indicate to the user that help is available for a menu
574 xrashmic 5 Oct, 2005 MMI-SPR-29356, MMI-SPR-29357
575
576 $Returns: None
577
578 $Arguments: None
579 *******************************************************************************/
580 void displayHelpSymbol(void)
581 {
582 MfwRect defRect, rect;
583 U16 line_height;
584 T_SK_DSPL_STRUCT sk_data;
585 Mmi_layout_softkeyArea( &defRect );
586 rect.px = defRect.sx >> 1;
587 rect.py = defRect.py + 4;
588 resources_setSKColour(COLOUR_LIST_XX);
589 //Display the symbol in the center between the softkeys
590 dspl_TextOut(rect.px, rect.py, DSPL_TXTATTR_CURRENT_MODE, "?");
591 resources_restoreMnuColour();
592
593 }