FreeCalypso > hg > tcs211-pirelli
comparison g23m/condat/ms/src/mfw/mfw_win.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 | PROJECT: MMI-Framework (8417) $Workfile:: mfw_win.c $| | |
| 4 | $Author:: Es $ CONDAT GmbH $Revision:: 21 $| | |
| 5 | CREATED: 21.09.98 $Modtime:: 23.03.00 9:08 $| | |
| 6 | STATE : code | | |
| 7 +--------------------------------------------------------------------+ | |
| 8 | |
| 9 MODULE : MFW_WIN | |
| 10 | |
| 11 PURPOSE : window handling functions | |
| 12 | |
| 13 EXPORT : | |
| 14 | |
| 15 TO DO : | |
| 16 | |
| 17 $History:: mfw_win.c $ | |
| 18 | |
| 19 Mar 30, 2005 REF: CRR 29986 xpradipg | |
| 20 Description: Optimisation 1: Removal of unused variables and dynamically | |
| 21 allocate/ deallocate mbndata | |
| 22 Solution: removed the unused varialbe mfw_twh_strlen | |
| 23 | |
| 24 * textMessage | |
| 25 * ***************** Version 21 ***************** | |
| 26 * User: Es Date: 23.03.00 Time: 14:42 | |
| 27 * Updated in $/GSM/Condat/MS/SRC/MFW | |
| 28 * Added 'winUnhide()': no update(), no event. | |
| 29 * | |
| 30 * ***************** Version 20 ***************** | |
| 31 * User: Kk Date: 14.03.00 Time: 15:52 | |
| 32 * Updated in $/GSM/Condat/MS/SRC/MFW | |
| 33 * changed update sequence | |
| 34 * | |
| 35 * ***************** Version 19 ***************** | |
| 36 * User: Es Date: 3.03.00 Time: 12:04 | |
| 37 * Updated in $/GSM/Condat/MS/SRC/MFW | |
| 38 * winUpdate(): first update windows children, then! call event | |
| 39 * handler | |
| 40 * | |
| 41 * ***************** Version 18 ***************** | |
| 42 * User: Es Date: 18.02.00 Time: 17:46 | |
| 43 * Updated in $/GSM/Condat/MS/SRC/MFW | |
| 44 * danger in winUpdate | |
| 45 * | |
| 46 * ***************** Version 17 ***************** | |
| 47 * User: Nm Date: 17.02.00 Time: 9:23 | |
| 48 * Updated in $/GSM/Condat/MS/SRC/MFW | |
| 49 * updated winIsFocussed | |
| 50 * | |
| 51 * ***************** Version 16 ***************** | |
| 52 * User: Kk Date: 17.01.00 Time: 8:56 | |
| 53 * Updated in $/GSM/Condat/MS/SRC/MFW | |
| 54 * added simple check functions for easy checking if win is visible, | |
| 55 * focussed, closed | |
| 56 * | |
| 57 * ***************** Version 15 ***************** | |
| 58 * User: Kk Date: 10.01.00 Time: 13:46 | |
| 59 * Updated in $/GSM/Condat/MS/SRC/MFW | |
| 60 * some changes done by ES | |
| 61 * | |
| 62 * ***************** Version 3 ***************** | |
| 63 * User: Rm Date: 12/22/99 Time: 4:34p | |
| 64 * Updated in $/GSM/Condat/SND-MMI/MFW | |
| 65 * | |
| 66 * ***************** Version 2 ***************** | |
| 67 * User: Es Date: 22.11.99 Time: 10:30 | |
| 68 * Updated in $/GSM/Condat/SND-MMI/MFW | |
| 69 * | |
| 70 * ***************** Version 1 ***************** | |
| 71 * User: Es Date: 18.11.99 Time: 16:35 | |
| 72 * Created in $/GSM/Condat/SND-MMI/MFW | |
| 73 * Initial | |
| 74 * | |
| 75 * ***************** Version 13 ***************** | |
| 76 * User: Es Date: 6.07.99 Time: 12:37 | |
| 77 * Updated in $/GSM/DEV/MS/SRC/MFW | |
| 78 * | |
| 79 * ***************** Version 11 ***************** | |
| 80 * User: Es Date: 14.04.99 Time: 17:34 | |
| 81 * Updated in $/GSM/DEV/MS/SRC/MFW | |
| 82 * moved to CST | |
| 83 | | |
| 84 | ***************** Version 10 ***************** | |
| 85 | User: Le Date: 14.04.99 Time: 9:51 | |
| 86 | Updated in $/GSM/DEV/MS/SRC/MFW | |
| 87 * | |
| 88 * ***************** Version 9 ***************** | |
| 89 * User: Es Date: 1.04.99 Time: 17:07 | |
| 90 * Updated in $/GSM/DEV/MS/SRC/MFW | |
| 91 * removed lots of traces | |
| 92 * | |
| 93 * ***************** Version 8 ***************** | |
| 94 * User: Es Date: 20.02.99 Time: 19:24 | |
| 95 * Updated in $/GSM/DEV/MS/SRC/MFW | |
| 96 * | |
| 97 * ***************** Version 7 ***************** | |
| 98 * User: Es Date: 20.02.99 Time: 18:22 | |
| 99 * Updated in $/GSM/DEV/MS/SRC/MFW | |
| 100 * | |
| 101 * ***************** Version 6 ***************** | |
| 102 * User: Es Date: 20.02.99 Time: 15:37 | |
| 103 * Updated in $/GSM/DEV/MS/SRC/MFW | |
| 104 * | |
| 105 * ***************** Version 5 ***************** | |
| 106 * User: Es Date: 18.02.99 Time: 17:01 | |
| 107 * Updated in $/GSM/DEV/MS/SRC/MFW | |
| 108 * | |
| 109 * ***************** Version 4 ***************** | |
| 110 * User: Es Date: 17.02.99 Time: 19:11 | |
| 111 * Updated in $/GSM/DEV/MS/SRC/MFW | |
| 112 * | |
| 113 * ***************** Version 3 ***************** | |
| 114 * User: Es Date: 14.01.99 Time: 17:19 | |
| 115 * Updated in $/GSM/DEV/MS/SRC/MFW | |
| 116 * | |
| 117 * ***************** Version 2 ***************** | |
| 118 * User: Es Date: 23.12.98 Time: 16:19 | |
| 119 * Updated in $/GSM/DEV/MS/SRC/MFW | |
| 120 */ | |
| 121 | |
| 122 | |
| 123 #define ENTITY_MFW | |
| 124 | |
| 125 #if defined (NEW_FRAME) | |
| 126 | |
| 127 #include "typedefs.h" | |
| 128 #include "vsi.h" | |
| 129 #include "custom.h" | |
| 130 #include "gsm.h" | |
| 131 | |
| 132 #else | |
| 133 | |
| 134 #include "STDDEFS.H" | |
| 135 #include "custom.h" | |
| 136 #include "gsm.h" | |
| 137 #include "vsi.h" | |
| 138 | |
| 139 #endif | |
| 140 | |
| 141 #include "mfw_mfw.h" | |
| 142 #include "mfw_sys.h" | |
| 143 #include "gdi.h" | |
| 144 #include "dspl.h" | |
| 145 #include "mfw_win.h" | |
| 146 | |
| 147 static MfwHdr *autoFocus; /* focus of toplevel window */ | |
| 148 static U8 winUseAutoFocus = 0; /* automatic focussing flag */ | |
| 149 static int winCommand (U32 cmd, void *h); | |
| 150 | |
| 151 | |
| 152 | |
| 153 /* | |
| 154 +--------------------------------------------------------------------+ | |
| 155 | PROJECT : MMI-Framework (8417) MODULE : MFW_WIN | | |
| 156 | STATE : code ROUTINE : winInit | | |
| 157 +--------------------------------------------------------------------+ | |
| 158 | |
| 159 PURPOSE : initialize window handler | |
| 160 | |
| 161 */ | |
| 162 | |
| 163 MfwRes winInit (U16 *sx, U16 *sy) | |
| 164 { | |
| 165 dspl_DevCaps displayData; | |
| 166 | |
| 167 dspl_Init(); /* init display driver */ | |
| 168 | |
| 169 displayData.DisplayType = DSPL_TYPE_GRAPHIC; | |
| 170 dspl_SetDeviceCaps(&displayData); | |
| 171 dspl_GetDeviceCaps(&displayData); | |
| 172 *sx = displayData.Width; | |
| 173 *sy = displayData.Height; | |
| 174 winUseAutoFocus = 0; | |
| 175 | |
| 176 mfwCommand[MfwTypWin] = (MfwCb) winCommand; | |
| 177 | |
| 178 return MfwResOk; | |
| 179 } | |
| 180 | |
| 181 | |
| 182 /* | |
| 183 +--------------------------------------------------------------------+ | |
| 184 | PROJECT : MMI-Framework (8417) MODULE : MFW_WIN | | |
| 185 | STATE : code ROUTINE : winExit | | |
| 186 +--------------------------------------------------------------------+ | |
| 187 | |
| 188 PURPOSE : finalize window handler | |
| 189 | |
| 190 */ | |
| 191 | |
| 192 MfwRes winExit (void) | |
| 193 { | |
| 194 mfwCommand[MfwTypWin] = 0; | |
| 195 dspl_Exit(); /* finit display driver */ | |
| 196 | |
| 197 return MfwResOk; | |
| 198 } | |
| 199 | |
| 200 | |
| 201 /* | |
| 202 +--------------------------------------------------------------------+ | |
| 203 | PROJECT : MMI-Framework (8417) MODULE : MFW_WIN | | |
| 204 | STATE : code ROUTINE : winCreate | | |
| 205 +--------------------------------------------------------------------+ | |
| 206 | |
| 207 PURPOSE : create window control | |
| 208 | |
| 209 */ | |
| 210 | |
| 211 MfwHnd winCreate (MfwHnd w, MfwWinAttr *a, MfwEvt e, MfwCb f) | |
| 212 { | |
| 213 | |
| 214 | |
| 215 MfwHdr *hdr = (MfwHdr *) mfwAlloc(sizeof(MfwHdr)); | |
| 216 MfwWin *win = (MfwWin *) mfwAlloc(sizeof(MfwWin)); | |
| 217 MfwHdr *eoc = (MfwHdr *) mfwAlloc(sizeof(MfwHdr)); | |
| 218 MfwHdr *insert_status =0; | |
| 219 | |
| 220 /* xreddymn Aug-09-2004, MMI-SPR-23964 (TII_MMS33) | |
| 221 * Implemented suspend and resume functionality for MFW windows | |
| 222 * The following code posts MfwWinSuspend event | |
| 223 */ | |
| 224 #if 1 | |
| 225 MfwWin *ee; | |
| 226 MfwHnd window; | |
| 227 window = mfwParent(mfwFocus); | |
| 228 if(window) | |
| 229 { | |
| 230 ee = (MfwWin*) ((MfwHdr *) window)->data; | |
| 231 if(ee && (((MfwHdr *) window)->type == MfwTypWin)) | |
| 232 { | |
| 233 if (ee->handler && ee->mask & MfwWinSuspend) | |
| 234 { | |
| 235 ee->handler(MfwWinSuspend,ee); | |
| 236 } | |
| 237 } | |
| 238 } | |
| 239 #endif | |
| 240 | |
| 241 | |
| 242 | |
| 243 | |
| 244 if (!hdr || !win || !eoc) | |
| 245 { | |
| 246 TRACE_ERROR("ERROR: winCreate() Mem Alloc Failed."); | |
| 247 | |
| 248 if(hdr) | |
| 249 mfwFree((U8*)hdr,sizeof(MfwHdr)); | |
| 250 | |
| 251 if(win) | |
| 252 mfwFree((U8*)win,sizeof(MfwWin)); | |
| 253 | |
| 254 if(eoc) | |
| 255 mfwFree((U8*)eoc,sizeof(MfwHdr)); | |
| 256 | |
| 257 return 0; | |
| 258 } | |
| 259 | |
| 260 eoc->next = hdr; /* setup eoc element */ | |
| 261 eoc->type = MfwTypMax; | |
| 262 eoc->data = 0; | |
| 263 | |
| 264 win->mask = e; /* setup window control */ | |
| 265 win->flags = 0; | |
| 266 win->handler = f; | |
| 267 win->attr = a; | |
| 268 win->elems = eoc; | |
| 269 win->user = 0; | |
| 270 | |
| 271 hdr->data = win; /* setup header element */ | |
| 272 hdr->type = MfwTypWin; | |
| 273 | |
| 274 if (mfwSignallingMethod == 0) | |
| 275 insert_status = mfwInsert(w,hdr); | |
| 276 else | |
| 277 { | |
| 278 insert_status = mfwInsert(mfwParent(mfwFocus),hdr); | |
| 279 mfwSetFocus(eoc); | |
| 280 } | |
| 281 | |
| 282 /* Release memory if handler installation failed. */ | |
| 283 if(!insert_status) | |
| 284 { | |
| 285 TRACE_ERROR("ERROR: winCreate() Failed to Install Handler. "); | |
| 286 mfwFree((U8*)hdr,sizeof(MfwHdr)); | |
| 287 mfwFree((U8*)win,sizeof(MfwWin)); | |
| 288 mfwFree((U8*)eoc,sizeof(MfwHdr)); | |
| 289 return 0; | |
| 290 } | |
| 291 | |
| 292 return insert_status; | |
| 293 } | |
| 294 | |
| 295 | |
| 296 /* | |
| 297 +--------------------------------------------------------------------+ | |
| 298 | PROJECT : MMI-Framework (8417) MODULE : MFW_WIN | | |
| 299 | STATE : code ROUTINE : winDelete | | |
| 300 +--------------------------------------------------------------------+ | |
| 301 | |
| 302 PURPOSE : delete window control | |
| 303 | |
| 304 */ | |
| 305 | |
| 306 MfwRes winDelete (MfwHnd w) | |
| 307 { | |
| 308 MfwCb f; | |
| 309 MfwHdr *e, *t, *r; | |
| 310 MfwRes res; | |
| 311 | |
| 312 /*NM, p012a*/ | |
| 313 MfwWin *parent_controlBlock; | |
| 314 MfwHdr *parent_win; | |
| 315 /* U8 uMode; | |
| 316 p012a end*/ | |
| 317 | |
| 318 TRACE_FUNCTION("win_delete()"); | |
| 319 | |
| 320 if (!w) | |
| 321 return MfwResIllHnd; | |
| 322 if (((MfwHdr *) w)->type != MfwTypWin) | |
| 323 return MfwResIllHnd; /* element is not a window */ | |
| 324 | |
| 325 e = ((MfwHdr *) w)->data; | |
| 326 if (!e) | |
| 327 return MfwResErr; | |
| 328 | |
| 329 ((MfwWin *) e)->flags |= MfwWinDelete; | |
| 330 if (((MfwWin *) e)->handler) | |
| 331 if (((MfwWin *) e)->mask & MfwWinDelete) | |
| 332 ((MfwWin *) e)->handler(MfwWinDelete,e); | |
| 333 | |
| 334 e = ((MfwWin *) e)->elems; | |
| 335 if (!e) | |
| 336 return MfwResErr; | |
| 337 | |
| 338 if (mfwFocus == e) /* was focus window */ | |
| 339 mfwSetFocus(0); /* no focus anymore */ | |
| 340 | |
| 341 | |
| 342 | |
| 343 while (e && e->type != MfwTypMax) /* try to delete all elems */ | |
| 344 { | |
| 345 t = e->next; | |
| 346 if (e->data) | |
| 347 { | |
| 348 if (mfwSignallingMethod != 0 && e->type == MfwTypWin) | |
| 349 { | |
| 350 r = (MfwHdr*) mfwParent(w); | |
| 351 mfwRemove(e); /* move up child window */ | |
| 352 mfwAppend(&(((MfwWin*)(r->data))->elems),e); | |
| 353 } | |
| 354 else | |
| 355 { | |
| 356 f = mfwCommand[e->type]; | |
| 357 if (f) | |
| 358 f(MfwCmdDelete,e); | |
| 359 } | |
| 360 } | |
| 361 e = t; | |
| 362 } | |
| 363 res = (mfwRemove(w)) ? MfwResOk : MfwResIllHnd; | |
| 364 | |
| 365 | |
| 366 /*NM, p012d | |
| 367 old: after deleting the focus-win start from root to top | |
| 368 new: after deleting the focus-win just give the new focus to | |
| 369 his parent-win (faster) | |
| 370 */ | |
| 371 if (mfwSignallingMethod != 0 && mfwRoot && (!mfwFocus)) | |
| 372 { | |
| 373 parent_win = (MfwHdr*) mfwParent(w); | |
| 374 | |
| 375 if (((MfwHdr *) parent_win)->type == MfwTypWin) | |
| 376 { | |
| 377 parent_controlBlock = ((MfwHdr *) parent_win)->data; | |
| 378 | |
| 379 /* xreddymn Aug-09-2004, MMI-SPR-23964 (TII_MMS33) | |
| 380 * Implemented suspend and resume functionality for MFW windows | |
| 381 * The following code posts MfwWinResume event | |
| 382 */ | |
| 383 #if 1 | |
| 384 if (parent_controlBlock->handler && parent_controlBlock->mask & MfwWinResume) | |
| 385 { | |
| 386 parent_controlBlock->handler(MfwWinResume,parent_controlBlock); | |
| 387 } | |
| 388 #endif | |
| 389 | |
| 390 | |
| 391 | |
| 392 winUpdate(parent_controlBlock); | |
| 393 mfwSetFocus(autoFocus); | |
| 394 } | |
| 395 | |
| 396 } | |
| 397 | |
| 398 | |
| 399 | |
| 400 mfwFree((MfwHnd) e,sizeof(MfwHdr)); | |
| 401 mfwFree(((MfwHdr *) w)->data,sizeof(MfwWin)); | |
| 402 mfwFree(w,sizeof(MfwHdr)); | |
| 403 | |
| 404 return res; | |
| 405 } | |
| 406 | |
| 407 | |
| 408 /* | |
| 409 +--------------------------------------------------------------------+ | |
| 410 | PROJECT : MMI-Framework (8417) MODULE : MFW_WIN | | |
| 411 | STATE : code ROUTINE : winShow | | |
| 412 +--------------------------------------------------------------------+ | |
| 413 | |
| 414 PURPOSE : show window (put in front of visibles) | |
| 415 | |
| 416 */ | |
| 417 | |
| 418 MfwRes winShow (MfwHnd w) | |
| 419 { | |
| 420 MfwWin *win; | |
| 421 | |
| 422 | |
| 423 TRACE_FUNCTION("winShow()"); | |
| 424 | |
| 425 if (!w) | |
| 426 return MfwResIllHnd; /* window does not exist */ | |
| 427 | |
| 428 if (((MfwHdr *) w)->type != MfwTypWin) | |
| 429 return MfwResIllHnd; /* element is not a window */ | |
| 430 | |
| 431 win = ((MfwHdr *) w)->data; /* get control block */ | |
| 432 | |
| 433 mfwAppend(mfwRemove(w),w); /* to front (draw at last) */ | |
| 434 win->flags |= MfwWinVisible; /* window is visible */ | |
| 435 | |
| 436 winUpdate(win); /* draw window elements */ | |
| 437 if (winUseAutoFocus) /* automatic focussing */ | |
| 438 mfwSetFocus(autoFocus); /* determined by update() */ | |
| 439 | |
| 440 return MfwResOk; | |
| 441 } | |
| 442 | |
| 443 | |
| 444 /* | |
| 445 +--------------------------------------------------------------------+ | |
| 446 | PROJECT : MMI-Framework (8417) MODULE : MFW_WIN | | |
| 447 | STATE : code ROUTINE : winHide | | |
| 448 +--------------------------------------------------------------------+ | |
| 449 | |
| 450 PURPOSE : hide window (and redraw remaining) | |
| 451 | |
| 452 */ | |
| 453 | |
| 454 MfwRes winHide (MfwHnd w) | |
| 455 { | |
| 456 MfwHdr *r; | |
| 457 MfwWin *win; | |
| 458 | |
| 459 if (!w) | |
| 460 return MfwResIllHnd; /* element does not exist */ | |
| 461 if (((MfwHdr *) w)->type != MfwTypWin) | |
| 462 return MfwResIllHnd; /* element is not a window */ | |
| 463 | |
| 464 win = ((MfwHdr *) w)->data; | |
| 465 win->flags &= ~MfwWinVisible; /* window is not visible */ | |
| 466 if (win->handler) /* call event handler */ | |
| 467 if (win->mask & MfwWinVisible) | |
| 468 win->handler(MfwWinVisible,win); | |
| 469 r = mfwRoot; /* the beginning */ | |
| 470 autoFocus = 0; /* reset focus */ | |
| 471 while (r->type != MfwTypMax) /* more links in chain */ | |
| 472 { | |
| 473 if (r->type == MfwTypWin) /* link is a window */ | |
| 474 winUpdate(r->data); | |
| 475 r = r->next; | |
| 476 } | |
| 477 if (winUseAutoFocus) /* automatic focussing */ | |
| 478 mfwSetFocus(autoFocus); /* determined by update() */ | |
| 479 | |
| 480 return MfwResOk; | |
| 481 } | |
| 482 | |
| 483 | |
| 484 /* | |
| 485 +--------------------------------------------------------------------+ | |
| 486 | PROJECT : MMI-Framework (8417) MODULE : MFW_WIN | | |
| 487 | STATE : code ROUTINE : winUnhide | | |
| 488 +--------------------------------------------------------------------+ | |
| 489 | |
| 490 PURPOSE : unhide window (without redrawing, no event) | |
| 491 | |
| 492 */ | |
| 493 | |
| 494 MfwRes winUnhide (MfwHnd w) | |
| 495 { | |
| 496 MfwWin *win; | |
| 497 | |
| 498 if (!w) | |
| 499 return MfwResIllHnd; /* element does not exist */ | |
| 500 if (((MfwHdr *) w)->type != MfwTypWin) | |
| 501 return MfwResIllHnd; /* element is not a window */ | |
| 502 | |
| 503 win = ((MfwHdr *) w)->data; | |
| 504 win->flags |= MfwWinVisible; /* window will be visible */ | |
| 505 | |
| 506 return MfwResOk; | |
| 507 } | |
| 508 | |
| 509 | |
| 510 /* | |
| 511 +--------------------------------------------------------------------+ | |
| 512 | PROJECT : MMI-Framework (8417) MODULE : MFW_WIN | | |
| 513 | STATE : code ROUTINE : winFocus | | |
| 514 +--------------------------------------------------------------------+ | |
| 515 | |
| 516 PURPOSE : assign input/event focus to window | |
| 517 | |
| 518 */ | |
| 519 | |
| 520 MfwHnd winFocus (MfwHnd w) | |
| 521 { | |
| 522 MfwWin *wNew, *wOld = 0; | |
| 523 | |
| 524 if (winUseAutoFocus) /* automatic focussing */ | |
| 525 return 0; /* ES!! only for testing !! */ | |
| 526 if (!w) | |
| 527 { | |
| 528 w = mfwFocus; | |
| 529 mfwSetFocus(0); /* delete focus */ | |
| 530 return w; /* return old focus */ | |
| 531 } | |
| 532 | |
| 533 if (((MfwHdr *) w)->type != MfwTypWin) | |
| 534 return 0; /* element is not a window */ | |
| 535 | |
| 536 if (mfwFocus) | |
| 537 { | |
| 538 while (mfwFocus->type != MfwTypMax) | |
| 539 mfwSetFocus(mfwFocus->next); /* search focus root */ | |
| 540 mfwSetFocus(mfwFocus->next); /* the focus window */ | |
| 541 if (mfwFocus->type != MfwTypWin) | |
| 542 { | |
| 543 mfwSetFocus(0); /* serious error: */ | |
| 544 return 0; /* element is not a window */ | |
| 545 } | |
| 546 wOld = mfwFocus->data; /* window control block */ | |
| 547 wOld->flags &= ~MfwWinFocussed; /* input focus / deselected */ | |
| 548 } | |
| 549 | |
| 550 wNew = ((MfwHdr *) w)->data; | |
| 551 w = mfwFocus; /* save old focus */ | |
| 552 mfwSetFocus(wNew->elems); /* focus on window elements */ | |
| 553 wNew->flags |= MfwWinFocussed; /* input focus / selected */ | |
| 554 | |
| 555 if (wNew->handler) /* call new event handler */ | |
| 556 if (wNew->mask & MfwWinFocussed) | |
| 557 wNew->handler(MfwWinFocussed,wNew); | |
| 558 if (wOld && wOld->handler) /* call old event handler */ | |
| 559 if (wOld->mask & MfwWinFocussed) | |
| 560 wOld->handler(MfwWinFocussed,wOld); | |
| 561 | |
| 562 return w; /* return old focus */ | |
| 563 } | |
| 564 | |
| 565 | |
| 566 /* | |
| 567 +--------------------------------------------------------------------+ | |
| 568 | PROJECT : MMI-Framework (8417) MODULE : MFW_WIN | | |
| 569 | STATE : code ROUTINE : winAutoFocus | | |
| 570 +--------------------------------------------------------------------+ | |
| 571 | |
| 572 PURPOSE : set auto focus mode | |
| 573 | |
| 574 */ | |
| 575 | |
| 576 U8 winAutoFocus (U8 useit) | |
| 577 { | |
| 578 U8 winUseAutoFocusOld = winUseAutoFocus; /* save previous state */ | |
| 579 | |
| 580 winUseAutoFocus = useit; | |
| 581 | |
| 582 return winUseAutoFocusOld; /* return previous state */ | |
| 583 } | |
| 584 | |
| 585 | |
| 586 /* | |
| 587 +--------------------------------------------------------------------+ | |
| 588 | PROJECT : MMI-Framework (8417) MODULE : MFW_WIN | | |
| 589 | STATE : code ROUTINE : winClear | | |
| 590 +--------------------------------------------------------------------+ | |
| 591 | |
| 592 PURPOSE : clear window | |
| 593 | |
| 594 */ | |
| 595 | |
| 596 MfwRes winClear (MfwHnd w) | |
| 597 { | |
| 598 MfwWin *win; | |
| 599 | |
| 600 if (!w) | |
| 601 { | |
| 602 dspl_ClearAll(); /* clear screen */ | |
| 603 return MfwResOk; | |
| 604 } | |
| 605 | |
| 606 win = ((MfwHdr *) w)->data; /* clear window area */ | |
| 607 dspl_Clear(win->attr->win.px,win->attr->win.py, | |
| 608 (U16) (win->attr->win.sx+win->attr->win.px-2), | |
| 609 (U16) (win->attr->win.sy+win->attr->win.py-2)); | |
| 610 | |
| 611 return MfwResOk; | |
| 612 } | |
| 613 | |
| 614 | |
| 615 /* | |
| 616 +--------------------------------------------------------------------+ | |
| 617 | PROJECT : MMI-Framework (8417) MODULE : MFW_WIN | | |
| 618 | STATE : code ROUTINE : winUpdate | | |
| 619 +--------------------------------------------------------------------+ | |
| 620 | |
| 621 PURPOSE : draw all visible windows | |
| 622 | |
| 623 */ | |
| 624 | |
| 625 MfwRes winUpdate (MfwWin *w) | |
| 626 { | |
| 627 MfwCb f = 0; /* modules command handler */ | |
| 628 MfwHdr *e; /* windows elements */ | |
| 629 | |
| 630 // TRACE_FUNCTION("winUpdate()"); | |
| 631 | |
| 632 if (!w) | |
| 633 return MfwResIllHnd; | |
| 634 | |
| 635 if (mfwSignallingMethod == 0) | |
| 636 { | |
| 637 if (!(w->flags & MfwWinVisible)) | |
| 638 return MfwResOk; /* hidden window */ | |
| 639 | |
| 640 if (w->handler) /* THEN: call event handler */ | |
| 641 if (w->mask & MfwWinVisible) | |
| 642 w->handler(MfwWinVisible,w); | |
| 643 e = w->elems; /* FIRST: update children */ | |
| 644 autoFocus = e; /* gets focus of top window */ | |
| 645 while (e->type != MfwTypMax) /* window has elements */ | |
| 646 { | |
| 647 if (e->type > MfwTypNone && e->type < MfwTypMax) | |
| 648 { | |
| 649 f = mfwCommand[e->type]; | |
| 650 if (f) /* cmd function implemented */ | |
| 651 f(MfwCmdUpdate,e); | |
| 652 } | |
| 653 e = e->next; | |
| 654 } | |
| 655 } | |
| 656 else | |
| 657 { | |
| 658 if (w->handler && (w->flags & MfwWinVisible)) | |
| 659 if (w->mask & MfwWinVisible){ | |
| 660 w->handler(MfwWinVisible,w); | |
| 661 } | |
| 662 | |
| 663 e = w->elems; /* FIRST: update children */ | |
| 664 autoFocus = e; /* gets focus of top window */ | |
| 665 while (e->type != MfwTypMax) /* window has elements */ | |
| 666 { | |
| 667 if (e->type > MfwTypNone && e->type < MfwTypMax) | |
| 668 { | |
| 669 f = mfwCommand[e->type]; | |
| 670 if (f && ((w->flags & MfwWinVisible) | |
| 671 || (e->type == MfwTypWin))) | |
| 672 f(MfwCmdUpdate,e); | |
| 673 } | |
| 674 e = e->next; | |
| 675 } | |
| 676 } | |
| 677 | |
| 678 return MfwResOk; | |
| 679 } | |
| 680 | |
| 681 | |
| 682 /* | |
| 683 +--------------------------------------------------------------------+ | |
| 684 | PROJECT : MMI-Framework (8417) MODULE : MFW_WIN | | |
| 685 | STATE : code ROUTINE : winNext | | |
| 686 +--------------------------------------------------------------------+ | |
| 687 | |
| 688 PURPOSE : show next window (for testing purposes only) | |
| 689 | |
| 690 */ | |
| 691 | |
| 692 MfwHnd winNext (MfwHnd winCur) | |
| 693 { | |
| 694 MfwHdr *cw; /* current window pointer */ | |
| 695 | |
| 696 if (!winCur) | |
| 697 return 0; | |
| 698 | |
| 699 cw = ((MfwWin *) (((MfwHdr *) winCur)->data))->elems; | |
| 700 while (cw->type != MfwTypWin) | |
| 701 { | |
| 702 if (cw->type == MfwTypMax) | |
| 703 { | |
| 704 cw = cw->next; | |
| 705 if (!cw) | |
| 706 cw = mfwRoot; | |
| 707 else | |
| 708 cw = cw->next; /* windows successor */ | |
| 709 } | |
| 710 else | |
| 711 cw = cw->next; | |
| 712 } | |
| 713 | |
| 714 return cw; | |
| 715 } | |
| 716 | |
| 717 | |
| 718 /* | |
| 719 +--------------------------------------------------------------------+ | |
| 720 | PROJECT : MMI-Framework (8417) MODULE : MFW_WIN | | |
| 721 | STATE : code ROUTINE : winPrev | | |
| 722 +--------------------------------------------------------------------+ | |
| 723 | |
| 724 PURPOSE : show previous window (for testing purposes only) | |
| 725 | |
| 726 */ | |
| 727 | |
| 728 MfwHnd winPrev (MfwHnd winCur) | |
| 729 { | |
| 730 MfwHnd wo, wc; | |
| 731 | |
| 732 wo = wc = winNext(winCur); | |
| 733 while (wc != winCur) | |
| 734 { | |
| 735 wo = wc; | |
| 736 wc = winNext(wc); | |
| 737 } | |
| 738 | |
| 739 return wo; | |
| 740 } | |
| 741 | |
| 742 | |
| 743 /* | |
| 744 +--------------------------------------------------------------------+ | |
| 745 | PROJECT : MMI-Framework (8417) MODULE : MFW_WIN | | |
| 746 | STATE : code ROUTINE : winCommand | | |
| 747 +--------------------------------------------------------------------+ | |
| 748 | |
| 749 PURPOSE : handle mfw windows command | |
| 750 | |
| 751 */ | |
| 752 | |
| 753 static int winCommand (U32 cmd, void *h) | |
| 754 { | |
| 755 switch (cmd) | |
| 756 { | |
| 757 case MfwCmdDelete: /* delete me */ | |
| 758 if (!h) | |
| 759 return 0; | |
| 760 winDelete(h); | |
| 761 return 1; | |
| 762 case MfwCmdUpdate: /* repaint */ | |
| 763 if (!h || ((MfwHdr *) h)->type != MfwTypWin) | |
| 764 return 0; | |
| 765 winUpdate(((MfwHdr *) h)->data); | |
| 766 return 1; | |
| 767 default: | |
| 768 break; | |
| 769 } | |
| 770 | |
| 771 return 0; | |
| 772 } | |
| 773 | |
| 774 /* | |
| 775 +--------------------------------------------------------------------+ | |
| 776 | PROJECT : MMI-Framework (8417) MODULE : MFW_WIN | | |
| 777 | STATE : code ROUTINE : winIsVisible | | |
| 778 +--------------------------------------------------------------------+ | |
| 779 | |
| 780 PURPOSE : check if window is visible | |
| 781 | |
| 782 */ | |
| 783 int winIsVisible(MfwHnd w) | |
| 784 { | |
| 785 MfwWin *win; | |
| 786 | |
| 787 if (!w) | |
| 788 return 0; /* no handle */ | |
| 789 | |
| 790 if (((MfwHdr *) w)->type != MfwTypWin) | |
| 791 return 0; /* element is not a window */ | |
| 792 | |
| 793 win = ((MfwHdr *) w)->data; | |
| 794 | |
| 795 return (win->flags & MfwWinVisible); | |
| 796 } | |
| 797 | |
| 798 | |
| 799 /* | |
| 800 +--------------------------------------------------------------------+ | |
| 801 | PROJECT : MMI-Framework (8417) MODULE : MFW_WIN | | |
| 802 | STATE : code ROUTINE : winIsFocussed | | |
| 803 +--------------------------------------------------------------------+ | |
| 804 | |
| 805 PURPOSE : check if window is focussed | |
| 806 | |
| 807 */ | |
| 808 int winIsFocussed(MfwHnd w) | |
| 809 { | |
| 810 MfwWin *win; | |
| 811 | |
| 812 if (!w) | |
| 813 return 0; /* no handle */ | |
| 814 | |
| 815 if (((MfwHdr *) w)->type != MfwTypWin) | |
| 816 return 0; /* element is not a window */ | |
| 817 | |
| 818 win = ((MfwHdr *) w)->data; | |
| 819 | |
| 820 return (win->elems == mfwFocus); | |
| 821 | |
| 822 } | |
| 823 | |
| 824 | |
| 825 /* | |
| 826 +--------------------------------------------------------------------+ | |
| 827 | PROJECT : MMI-Framework (8417) MODULE : MFW_WIN | | |
| 828 | STATE : code ROUTINE : winIcClosed | | |
| 829 +--------------------------------------------------------------------+ | |
| 830 | |
| 831 PURPOSE : check if window is closed | |
| 832 | |
| 833 */ | |
| 834 int winIsClosed(MfwHnd w) | |
| 835 { | |
| 836 MfwWin *win; | |
| 837 | |
| 838 if (!w) | |
| 839 return 0; /* no handle */ | |
| 840 | |
| 841 if (((MfwHdr *) w)->type != MfwTypWin) | |
| 842 return 0; /* element is not a window */ | |
| 843 | |
| 844 win = ((MfwHdr *) w)->data; | |
| 845 | |
| 846 return (win->flags & MfwWinClosed); | |
| 847 } | |
| 848 | |
| 849 MfwHdr* getHdr( MfwHnd win) | |
| 850 { | |
| 851 return((MfwHdr *) win); | |
| 852 } | |
| 853 MfwWin* getWinData( MfwHnd win) | |
| 854 { | |
| 855 MfwHdr* winHdr; | |
| 856 winHdr = getHdr(win); | |
| 857 return (winHdr->data); | |
| 858 } | |
| 859 | |
| 860 #define TWH_MAX_STR_LEN 90 | |
| 861 #define TWH_MAX_SINGLE_SIZE 21 // This is the length of the Level, Address, Type and Callback in hex plus a zero terminator | |
| 862 | |
| 863 static unsigned char trc_lvl; | |
| 864 static char mfw_twh_str[TWH_MAX_STR_LEN]; | |
| 865 | |
| 866 // Mar 30, 2005 REF: CRR 29986 xpradipg | |
| 867 // remove the definition since its not used | |
| 868 #ifndef FF_MMI_OPTIM | |
| 869 static unsigned int mfw_twh_strlen; | |
| 870 #endif | |
| 871 | |
| 872 static void mfw_twhNext(MfwHdr *next); | |
| 873 static char *mfw_twhType(MfwTyp type); | |
| 874 static void mfw_twhOut(void *ptr, MfwTyp typ); | |
| 875 static void mfw_twhCb(void *ptr); | |
| 876 static void mfw_twh_str_purge(void); | |
| 877 | |
| 878 #include <string.h> | |
| 879 | |
| 880 /* | |
| 881 +--------------------------------------------------------------------+ | |
| 882 | PROJECT : MMI-Framework (8417) MODULE : MFW_WIN | | |
| 883 | STATE : code ROUTINE : mfw_traceWinHdrs | | |
| 884 +--------------------------------------------------------------------+ | |
| 885 | |
| 886 PURPOSE : This function will trace out the entire window tree. | |
| 887 : EXTREME care should be taken using this function as it will cause a | |
| 888 : massive overhead on the CPU and processing WILL be affected!!!! | |
| 889 | |
| 890 */ | |
| 891 void mfw_traceWinHdrs(void) | |
| 892 { | |
| 893 TRACE_FUNCTION(">>>>> mfw_traceWinHdrs"); | |
| 894 | |
| 895 trc_lvl = 0; | |
| 896 | |
| 897 TRACE_EVENT("mfwRoot"); | |
| 898 | |
| 899 if (mfwRoot) | |
| 900 mfw_twhNext(mfwRoot); | |
| 901 | |
| 902 /* | |
| 903 ** Trace out the last remaining line (there will always be one) | |
| 904 */ | |
| 905 mfw_twh_str_purge(); | |
| 906 | |
| 907 TRACE_FUNCTION("<<<<< mfw_traceWinHdrs"); | |
| 908 return; | |
| 909 } | |
| 910 | |
| 911 static void mfw_twhNext(MfwHdr *next) | |
| 912 { | |
| 913 while (next) | |
| 914 { | |
| 915 if (next->type != MfwTypMax) | |
| 916 { | |
| 917 /* | |
| 918 ** Trace out this address, and its Type | |
| 919 */ | |
| 920 mfw_twhOut(next, next->type); | |
| 921 | |
| 922 /* | |
| 923 ** If this type is a Window, then it may have sub-elements | |
| 924 ** Trace them out before continuing the tree on this level | |
| 925 */ | |
| 926 if (next->type == MfwTypWin) | |
| 927 { | |
| 928 MfwWin *win_ptr = (MfwWin *)next->data; | |
| 929 | |
| 930 if (win_ptr) | |
| 931 { | |
| 932 MfwHdr *win_elems = win_ptr->elems; | |
| 933 | |
| 934 /* | |
| 935 ** Add the Callback Address before doing the sub-elements | |
| 936 */ | |
| 937 mfw_twhCb((void *)win_ptr->handler); | |
| 938 trc_lvl++; | |
| 939 mfw_twhNext(win_elems); | |
| 940 trc_lvl--; | |
| 941 } | |
| 942 } | |
| 943 | |
| 944 if (next->next == NULL) | |
| 945 { | |
| 946 mfw_twhOut(0, 0); | |
| 947 } | |
| 948 | |
| 949 next = next->next; | |
| 950 } | |
| 951 else | |
| 952 { | |
| 953 /* | |
| 954 ** Trace out this address, and its Type | |
| 955 */ | |
| 956 mfw_twhOut(next, next->type); | |
| 957 | |
| 958 next = NULL; | |
| 959 } | |
| 960 } | |
| 961 | |
| 962 return; | |
| 963 } | |
| 964 | |
| 965 static char *mfw_twhType(MfwTyp type) | |
| 966 { | |
| 967 switch (type) | |
| 968 { | |
| 969 case MfwTypNone: /* no element (first !!) */ | |
| 970 return("MfwTypNone"); | |
| 971 // break; // RAVI | |
| 972 | |
| 973 case MfwTypWin: /* window */ | |
| 974 return("MfwTypWin"); | |
| 975 // break; // RAVI | |
| 976 | |
| 977 case MfwTypEdt: /* editor */ | |
| 978 return("MfwTypEdt"); | |
| 979 // break; // RAVI | |
| 980 | |
| 981 case MfwTypMnu: /* menu handler */ | |
| 982 return("MfwTypMnu"); | |
| 983 // break; // RAVI | |
| 984 | |
| 985 case MfwTypIcn: /* icon handler */ | |
| 986 return("MfwTypIcn"); | |
| 987 // break; // RAVI | |
| 988 | |
| 989 case MfwTypKbd: /* keyboard */ | |
| 990 return("MfwTypKbd"); | |
| 991 // break; // RAVI | |
| 992 | |
| 993 case MfwTypTim: /* timer */ | |
| 994 return("MfwTypTim"); | |
| 995 // break; // RAVI | |
| 996 | |
| 997 case MfwTypMme: /* misc. mobile equipment */ | |
| 998 return("MfwTypMme"); | |
| 999 // break; //RAVI | |
| 1000 | |
| 1001 case MfwTypVmm: /* MDL virtual machine */ | |
| 1002 return("MfwTypVmm"); | |
| 1003 // break; // RAVI | |
| 1004 | |
| 1005 case MfwTypNm: /* network */ | |
| 1006 return("MfwTypNm"); | |
| 1007 // break; // RAVI | |
| 1008 | |
| 1009 case MfwTypSim: /* SIM card */ | |
| 1010 return("MfwTypSim"); | |
| 1011 // break; // RAVI | |
| 1012 | |
| 1013 case MfwTypCm: /* call handling */ | |
| 1014 return("MfwTypCm"); | |
| 1015 // break; // RAVI | |
| 1016 | |
| 1017 case MfwTypPhb: /* phonebook handling */ | |
| 1018 return("MfwTypPhb"); | |
| 1019 // break; // RAVI | |
| 1020 | |
| 1021 case MfwTypSms: /* short message handling */ | |
| 1022 return("MfwTypSms"); | |
| 1023 // break; // RAVI | |
| 1024 | |
| 1025 case MfwTypSs: /* supl. services handling */ | |
| 1026 return("MfwTypSs"); | |
| 1027 // break; // RAVI | |
| 1028 | |
| 1029 case MfwTypSat: /* SIM Toolkit handling */ | |
| 1030 return("MfwTypSat"); | |
| 1031 // break; // RAVI | |
| 1032 | |
| 1033 case MfwTypLng: /* language handling */ | |
| 1034 return("MfwTypLng"); | |
| 1035 // break; // RAVI | |
| 1036 | |
| 1037 case MfwTypInp: /* input handling */ | |
| 1038 return("MfwTypInp"); | |
| 1039 // break; // RAVI | |
| 1040 | |
| 1041 case MfwTypNode: /* node element */ | |
| 1042 return("MfwTypNode"); | |
| 1043 // break; // RAVI | |
| 1044 | |
| 1045 case MfwTypCphs: /* CPHS element */ | |
| 1046 return("MfwTypCphs"); | |
| 1047 // break; // RAVI | |
| 1048 | |
| 1049 case MfwTypGprs: /* GPRS handling */ | |
| 1050 return("MfwTypGprs"); | |
| 1051 // break; // RAVI | |
| 1052 | |
| 1053 case MfwTypEm: /*MC, SPR 1209 Eng Mode handling*/ | |
| 1054 return("MfwTypEm"); | |
| 1055 // break; // RAVI | |
| 1056 | |
| 1057 #ifdef BT_INTERFACE | |
| 1058 case MfwTypBt: /* bluetooth handling */ | |
| 1059 return("MfwTypBt"); | |
| 1060 // break; // RAVI | |
| 1061 #endif | |
| 1062 | |
| 1063 #ifdef BTE_MOBILE | |
| 1064 case MfwTypBte: /* bluetooth handling */ | |
| 1065 return("MfwTypBte"); | |
| 1066 // break; // RAVI | |
| 1067 #endif | |
| 1068 | |
| 1069 case MfwTypMax: /* end of types (last !!) */ | |
| 1070 return("MfwTypMax"); | |
| 1071 // break; // RAVI | |
| 1072 | |
| 1073 default: | |
| 1074 return("Not Known"); | |
| 1075 } | |
| 1076 } | |
| 1077 | |
| 1078 static void mfw_twhOut(void *ptr, MfwTyp typ) | |
| 1079 { | |
| 1080 unsigned char i; | |
| 1081 char fmt_str[30]; | |
| 1082 | |
| 1083 memset(fmt_str, 0, 30); | |
| 1084 | |
| 1085 #if 0 | |
| 1086 /* The code here will output the information in hex format which will need | |
| 1087 ** more decoding, but which may be necessary if the amount of information | |
| 1088 ** being output causes problems in the BMI. Change the above #if to be '#if 1' | |
| 1089 ** to use this format | |
| 1090 */ | |
| 1091 sprintf(fmt_str,"%02x%08lx%02x", trc_lvl, ptr, typ); | |
| 1092 | |
| 1093 /* | |
| 1094 ** Determine whether a new string is required | |
| 1095 */ | |
| 1096 if (mfw_twh_strlen > (TWH_MAX_STR_LEN - TWH_MAX_SINGLE_SIZE)) | |
| 1097 { | |
| 1098 /* | |
| 1099 ** Need to output the previous trace and start a new line | |
| 1100 */ | |
| 1101 mfw_twh_str_purge(); | |
| 1102 } | |
| 1103 | |
| 1104 strcat(mfw_twh_str, fmt_str); | |
| 1105 | |
| 1106 mfw_twh_strlen += 12; | |
| 1107 #else | |
| 1108 | |
| 1109 memset(mfw_twh_str, 0, TWH_MAX_STR_LEN); | |
| 1110 | |
| 1111 for (i=0; i<trc_lvl; i++) | |
| 1112 { | |
| 1113 strcat(mfw_twh_str, " "); | |
| 1114 } | |
| 1115 | |
| 1116 strcat(mfw_twh_str, "-> "); | |
| 1117 | |
| 1118 sprintf(fmt_str,"N:%08lx T:%s", ptr, mfw_twhType(typ)); | |
| 1119 | |
| 1120 strcat(mfw_twh_str, fmt_str); | |
| 1121 | |
| 1122 if (typ != MfwTypWin) | |
| 1123 { | |
| 1124 /* | |
| 1125 ** Trace out the details - There will be no callback | |
| 1126 */ | |
| 1127 TRACE_EVENT(mfw_twh_str); | |
| 1128 } | |
| 1129 #endif | |
| 1130 return; | |
| 1131 } | |
| 1132 | |
| 1133 static void mfw_twhCb(void *ptr) | |
| 1134 { | |
| 1135 char fmt_str[20]; | |
| 1136 | |
| 1137 memset(fmt_str, 0, 20); | |
| 1138 #if 0 | |
| 1139 /* The code here will output the information in hex format which will need | |
| 1140 ** more decoding, but which may be necessary if the amount of information | |
| 1141 ** being output causes problems in the BMI. Change the above #if to be '#if 1' | |
| 1142 ** to use this format | |
| 1143 */ | |
| 1144 /* | |
| 1145 ** No Need to test whether there is enough space for the callback ...already checked in mfw_twhOut() | |
| 1146 */ | |
| 1147 sprintf(fmt_str,"%08lx", ptr); | |
| 1148 | |
| 1149 strcat(mfw_twh_str, fmt_str); | |
| 1150 | |
| 1151 mfw_twh_strlen += 8; | |
| 1152 #else | |
| 1153 /* | |
| 1154 ** No Need to test whether there is enough space for the callback ...already checked in mfw_twhOut() | |
| 1155 */ | |
| 1156 sprintf(fmt_str," Cb:%08lx", ptr); | |
| 1157 | |
| 1158 strcat(mfw_twh_str, fmt_str); | |
| 1159 | |
| 1160 TRACE_EVENT(mfw_twh_str); | |
| 1161 #endif | |
| 1162 return; | |
| 1163 } | |
| 1164 | |
| 1165 static void mfw_twh_str_purge(void) | |
| 1166 { | |
| 1167 #if 0 | |
| 1168 /* The code here is needed when using the hex format output which will need | |
| 1169 ** more decoding, but which may be necessary if the amount of information | |
| 1170 ** being output causes problems in the BMI. Change the above #if to be '#if 1' | |
| 1171 ** to use this format | |
| 1172 */ | |
| 1173 TRACE_EVENT(mfw_twh_str); | |
| 1174 | |
| 1175 memset(mfw_twh_str, 0, TWH_MAX_STR_LEN); | |
| 1176 mfw_twh_strlen = 0; | |
| 1177 | |
| 1178 vsi_t_sleep(VSI_CALLER 10); | |
| 1179 #endif | |
| 1180 return; | |
| 1181 } | |
| 1182 |
