| Line No. | Rev | Author | Line |
|---|---|---|---|
| 1 | 32 | kaklik | /***************************************************************************** |
| 2 | * Module for Microchip Graphics Library |
||
| 3 | * GOL Layer |
||
| 4 | * TextEntry |
||
| 5 | ***************************************************************************** |
||
| 6 | * FileName: Textentry.c |
||
| 7 | * Dependencies: Textentry.h |
||
| 8 | * Processor: PIC24F, PIC24H, dsPIC, PIC32 |
||
| 9 | * Compiler: MPLAB C30 Version 3.00, C32 |
||
| 10 | * Linker: MPLAB LINK30, LINK32 |
||
| 11 | * Company: Microchip Technology Incorporated |
||
| 12 | * |
||
| 13 | * Software License Agreement |
||
| 14 | * |
||
| 15 | * Copyright © 2008 Microchip Technology Inc. All rights reserved. |
||
| 16 | * Microchip licenses to you the right to use, modify, copy and distribute |
||
| 17 | * Software only when embedded on a Microchip microcontroller or digital |
||
| 18 | * signal controller, which is integrated into your product or third party |
||
| 19 | * product (pursuant to the sublicense terms in the accompanying license |
||
| 20 | * agreement). |
||
| 21 | * |
||
| 22 | * You should refer to the license agreement accompanying this Software |
||
| 23 | * for additional information regarding your rights and obligations. |
||
| 24 | * |
||
| 25 | * SOFTWARE AND DOCUMENTATION ARE PROVIDED AS IS WITHOUT WARRANTY OF ANY |
||
| 26 | * KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY WARRANTY |
||
| 27 | * OF MERCHANTABILITY, TITLE, NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR |
||
| 28 | * PURPOSE. IN NO EVENT SHALL MICROCHIP OR ITS LICENSORS BE LIABLE OR |
||
| 29 | * OBLIGATED UNDER CONTRACT, NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, |
||
| 30 | * BREACH OF WARRANTY, OR OTHER LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT |
||
| 31 | * DAMAGES OR EXPENSES INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, |
||
| 32 | * INDIRECT, PUNITIVE OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, |
||
| 33 | * COST OF PROCUREMENT OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY |
||
| 34 | * CLAIMS BY THIRD PARTIES (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), |
||
| 35 | * OR OTHER SIMILAR COSTS. |
||
| 36 | * |
||
| 37 | * Author Date Comment |
||
| 38 | *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
||
| 39 | * Harold Serrano 10/24/08 ... |
||
| 40 | * PAT 07/01/09 Updated for 2D accelerated primitive support. |
||
| 41 | * PAT 04/15/10 Corrected TeSetBuffer() issue on string max size. |
||
| 42 | *****************************************************************************/ |
||
| 43 | #include "Graphics\Graphics.h" |
||
| 44 | |||
| 45 | #ifdef USE_TEXTENTRY |
||
| 46 | |||
| 47 | /********************************************************************* |
||
| 48 | * Function: TEXTENTRY *TeCreate(WORD ID, SHORT left, SHORT top, SHORT right, SHORT bottom, WORD state |
||
| 49 | * SHORT horizontalKeys, SHORT verticalKeys, XCHAR *pText[], |
||
| 50 | * void *pBuffer, WORD bufferLength, void *pDisplayFont, |
||
| 51 | * GOL_SCHEME *pScheme) |
||
| 52 | * |
||
| 53 | * |
||
| 54 | * Notes: |
||
| 55 | * |
||
| 56 | ********************************************************************/ |
||
| 57 | TEXTENTRY *TeCreate |
||
| 58 | ( |
||
| 59 | WORD ID, |
||
| 60 | SHORT left, |
||
| 61 | SHORT top, |
||
| 62 | SHORT right, |
||
| 63 | SHORT bottom, |
||
| 64 | WORD state, |
||
| 65 | SHORT horizontalKeys, |
||
| 66 | SHORT verticalKeys, |
||
| 67 | XCHAR *pText[], |
||
| 68 | void *pBuffer, |
||
| 69 | WORD bufferLength, |
||
| 70 | void *pDisplayFont, |
||
| 71 | GOL_SCHEME *pScheme |
||
| 72 | ) |
||
| 73 | { |
||
| 74 | TEXTENTRY *pTe = NULL; //Text entry |
||
| 75 | pTe = (TEXTENTRY *)GFX_malloc(sizeof(TEXTENTRY)); |
||
| 76 | if(pTe == NULL) |
||
| 77 | return (NULL); |
||
| 78 | |||
| 79 | pTe->hdr.ID = ID; |
||
| 80 | pTe->hdr.pNxtObj = NULL; |
||
| 81 | pTe->hdr.type = OBJ_TEXTENTRY; // set object type |
||
| 82 | pTe->hdr.left = left; //left parameter of the text-entry |
||
| 83 | pTe->hdr.top = top; //top parameter of the text-entry |
||
| 84 | pTe->hdr.right = right; //right parameter of the text-entry |
||
| 85 | pTe->hdr.bottom = bottom; //bottom parameter of the text-entry |
||
| 86 | pTe->hdr.state = state; //State of the Text-Entry |
||
| 87 | pTe->horizontalKeys = horizontalKeys; //number of horizontal keys |
||
| 88 | pTe->verticalKeys = verticalKeys; //number of vertical keys |
||
| 89 | pTe->CurrentLength = 0; //current length of text |
||
| 90 | pTe->pHeadOfList = NULL; |
||
| 91 | TeSetBuffer(pTe, pBuffer, bufferLength); //set the text to be displayed buffer length is also initialized in this call |
||
| 92 | pTe->pActiveKey = NULL; |
||
| 93 | |||
| 94 | // Set the color scheme to be used |
||
| 95 | if(pScheme == NULL) |
||
| 96 | pTe->hdr.pGolScheme = _pDefaultGolScheme; |
||
| 97 | else |
||
| 98 | pTe->hdr.pGolScheme = (GOL_SCHEME *)pScheme; |
||
| 99 | |||
| 100 | // Set the font to be used |
||
| 101 | if(pDisplayFont == NULL) |
||
| 102 | pTe->pDisplayFont = (void *) &GOLFontDefault; |
||
| 103 | else |
||
| 104 | pTe->pDisplayFont = pDisplayFont; |
||
| 105 | |||
| 106 | //check if either values of horizontal keys and vertical keys are equal to zero |
||
| 107 | if((pTe->horizontalKeys != 0) || (pTe->verticalKeys != 0)) |
||
| 108 | { |
||
| 109 | |||
| 110 | //create the key members, return null if not successful |
||
| 111 | if(TeCreateKeyMembers(pTe, pText) == 0) |
||
| 112 | { |
||
| 113 | GFX_free(pTe); |
||
| 114 | return (NULL); |
||
| 115 | } |
||
| 116 | } |
||
| 117 | |||
| 118 | //Add this new widget object to the GOL list |
||
| 119 | GOLAddObject((OBJ_HEADER *)pTe); |
||
| 120 | return (pTe); |
||
| 121 | } //end TeCreate() |
||
| 122 | |||
| 123 | /********************************************************************* |
||
| 124 | * Function: TeDraw(TEXTENTRY *pTe) |
||
| 125 | * |
||
| 126 | * Notes: This function draws the keys with their appropriate text |
||
| 127 | * |
||
| 128 | ********************************************************************/ |
||
| 129 | WORD TeDraw(TEXTENTRY *pTe) |
||
| 130 | { |
||
| 131 | static WORD faceClr, embossLtClr, embossDkClr, xText, yText; |
||
| 132 | static XCHAR XcharTmp; |
||
| 133 | static KEYMEMBER *pKeyTemp = NULL; |
||
| 134 | |||
| 135 | static WORD CountOfKeys = 0; |
||
| 136 | static WORD counter = 0; |
||
| 137 | static XCHAR hideChar[2] = {0x2A, 0x00}; |
||
| 138 | |||
| 139 | typedef enum |
||
| 140 | { |
||
| 141 | TE_START, |
||
| 142 | TE_HIDE_WIDGET, |
||
| 143 | TE_DRAW_PANEL, |
||
| 144 | TE_INIT_DRAW_EDITBOX, |
||
| 145 | TE_DRAW_EDITBOX, |
||
| 146 | TE_DRAW_KEY_INIT, |
||
| 147 | TE_DRAW_KEY_SET_PANEL, |
||
| 148 | TE_DRAW_KEY_DRAW_PANEL, |
||
| 149 | TE_DRAW_KEY_TEXT, |
||
| 150 | TE_DRAW_KEY_UPDATE, |
||
| 151 | TE_UPDATE_STRING_INIT, |
||
| 152 | TE_UPDATE_STRING, |
||
| 153 | TE_WAIT_ERASE_EBOX_AREA, |
||
| 154 | TE_UPDATE_CHARACTERS, |
||
| 155 | } TE_DRAW_STATES; |
||
| 156 | |||
| 157 | static TE_DRAW_STATES state = TE_START; |
||
| 158 | |||
| 159 | if(IsDeviceBusy()) |
||
| 160 | return (0); |
||
| 161 | |||
| 162 | switch(state) |
||
| 163 | { |
||
| 164 | case TE_START: |
||
| 165 | if(IsDeviceBusy()) |
||
| 166 | return (0); |
||
| 167 | |||
| 168 | if(GetState(pTe, TE_HIDE)) |
||
| 169 | { |
||
| 170 | SetColor(pTe->hdr.pGolScheme->CommonBkColor); |
||
| 171 | Bar(pTe->hdr.left, pTe->hdr.top, pTe->hdr.right, pTe->hdr.bottom); |
||
| 172 | state = TE_HIDE_WIDGET; |
||
| 173 | goto te_hide_widget; |
||
| 174 | } |
||
| 175 | else |
||
| 176 | { |
||
| 177 | if(GetState(pTe, TE_DRAW)) |
||
| 178 | { |
||
| 179 | |||
| 180 | /************DRAW THE WIDGET PANEL*****************************/ |
||
| 181 | GOLPanelDraw |
||
| 182 | ( |
||
| 183 | pTe->hdr.left, |
||
| 184 | pTe->hdr.top, |
||
| 185 | pTe->hdr.right, |
||
| 186 | pTe->hdr.bottom, |
||
| 187 | 0, |
||
| 188 | pTe->hdr.pGolScheme->Color0, //face color of panel |
||
| 189 | pTe->hdr.pGolScheme->EmbossDkColor, //emboss dark color |
||
| 190 | pTe->hdr.pGolScheme->EmbossLtColor, //emboss light color |
||
| 191 | NULL, |
||
| 192 | GOL_EMBOSS_SIZE |
||
| 193 | ); |
||
| 194 | state = TE_DRAW_PANEL; |
||
| 195 | goto te_draw_panel; |
||
| 196 | } |
||
| 197 | |||
| 198 | // update the keys (if TE_UPDATE_TEXT is also set it will also be redrawn) |
||
| 199 | // at the states after the keys are updated |
||
| 200 | else if(GetState(pTe, TE_UPDATE_KEY)) |
||
| 201 | { |
||
| 202 | state = TE_DRAW_KEY_INIT; |
||
| 203 | goto te_draw_key_init_st; |
||
| 204 | } |
||
| 205 | |||
| 206 | // check if updating only the text displayed |
||
| 207 | else if(GetState(pTe, TE_UPDATE_TEXT)) |
||
| 208 | { |
||
| 209 | state = TE_UPDATE_STRING_INIT; |
||
| 210 | goto te_update_string_init_st; |
||
| 211 | } |
||
| 212 | } |
||
| 213 | |||
| 214 | /*hide the widget*/ |
||
| 215 | case TE_HIDE_WIDGET: |
||
| 216 | te_hide_widget : if(IsDeviceBusy()) return (0); |
||
| 217 | state = TE_START; |
||
| 218 | return (1); |
||
| 219 | |||
| 220 | /*Draw the widget of the Text-Entry*/ |
||
| 221 | case TE_DRAW_PANEL: |
||
| 222 | te_draw_panel : if(!GOLPanelDrawTsk()) return (0); |
||
| 223 | state = TE_INIT_DRAW_EDITBOX; |
||
| 224 | |||
| 225 | case TE_INIT_DRAW_EDITBOX: |
||
| 226 | |||
| 227 | //Draw the editbox |
||
| 228 | GOLPanelDraw |
||
| 229 | ( |
||
| 230 | pTe->hdr.left, |
||
| 231 | pTe->hdr.top, |
||
| 232 | pTe->hdr.right, |
||
| 233 | pTe->hdr.top + GetTextHeight(pTe->pDisplayFont) + (GOL_EMBOSS_SIZE << 1), |
||
| 234 | 0, |
||
| 235 | pTe->hdr.pGolScheme->Color1; , |
||
| 236 | pTe->hdr.pGolScheme->EmbossDkColor, |
||
| 237 | pTe->hdr.pGolScheme->EmbossLtColor, |
||
| 238 | NULL, |
||
| 239 | GOL_EMBOSS_SIZE |
||
| 240 | ); |
||
| 241 | |||
| 242 | state = TE_DRAW_EDITBOX; |
||
| 243 | |||
| 244 | case TE_DRAW_EDITBOX: |
||
| 245 | if(!GOLPanelDrawTsk()) |
||
| 246 | return (0); |
||
| 247 | state = TE_DRAW_KEY_INIT; |
||
| 248 | |||
| 249 | /* ********************************************************************* */ |
||
| 250 | |||
| 251 | /* Update the keys */ |
||
| 252 | |||
| 253 | /* ********************************************************************* */ |
||
| 254 | case TE_DRAW_KEY_INIT: |
||
| 255 | te_draw_key_init_st : embossLtClr = pTe->hdr.pGolScheme->EmbossLtColor; |
||
| 256 | embossDkClr = pTe->hdr.pGolScheme->EmbossDkColor; |
||
| 257 | faceClr = pTe->hdr.pGolScheme->Color0; |
||
| 258 | |||
| 259 | // if the active key update flag is set, only one needs to be redrawn |
||
| 260 | if((GetState(pTe, TE_DRAW) != TE_DRAW) && (pTe->pActiveKey->update == TRUE)) |
||
| 261 | { |
||
| 262 | CountOfKeys = (pTe->horizontalKeys * pTe->verticalKeys) - |
||
| 263 | 1; |
||
| 264 | pKeyTemp = pTe->pActiveKey; |
||
| 265 | } |
||
| 266 | else |
||
| 267 | { |
||
| 268 | CountOfKeys = 0; |
||
| 269 | pKeyTemp = pTe->pHeadOfList; |
||
| 270 | } |
||
| 271 | |||
| 272 | state = TE_DRAW_KEY_SET_PANEL; |
||
| 273 | |||
| 274 | case TE_DRAW_KEY_SET_PANEL: |
||
| 275 | te_draw_key_set_panel_st : if(CountOfKeys < (pTe->horizontalKeys * pTe->verticalKeys)) |
||
| 276 | { |
||
| 277 | |||
| 278 | // check if we need to draw the panel |
||
| 279 | if(GetState(pTe, TE_DRAW) != TE_DRAW) |
||
| 280 | { |
||
| 281 | if(pKeyTemp->update == TRUE) |
||
| 282 | { |
||
| 283 | |||
| 284 | // set the colors needed |
||
| 285 | if(GetState(pTe, TE_KEY_PRESSED)) |
||
| 286 | { |
||
| 287 | embossLtClr = pTe->hdr.pGolScheme->EmbossDkColor; |
||
| 288 | embossDkClr = pTe->hdr.pGolScheme->EmbossLtColor; |
||
| 289 | faceClr = pTe->hdr.pGolScheme->Color1; |
||
| 290 | } |
||
| 291 | else |
||
| 292 | { |
||
| 293 | embossLtClr = pTe->hdr.pGolScheme->EmbossLtColor; |
||
| 294 | embossDkClr = pTe->hdr.pGolScheme->EmbossDkColor; |
||
| 295 | faceClr = pTe->hdr.pGolScheme->Color0; |
||
| 296 | } |
||
| 297 | } |
||
| 298 | else |
||
| 299 | { |
||
| 300 | state = TE_DRAW_KEY_UPDATE; |
||
| 301 | goto te_draw_key_update_st; |
||
| 302 | } |
||
| 303 | } |
||
| 304 | |||
| 305 | if(GetState(pTe, TE_DISABLED) == TE_DISABLED) |
||
| 306 | { |
||
| 307 | faceClr = SetColor(pTe->hdr.pGolScheme->ColorDisabled); |
||
| 308 | } |
||
| 309 | |||
| 310 | // set up the panel |
||
| 311 | GOLPanelDraw |
||
| 312 | ( |
||
| 313 | pKeyTemp->left, |
||
| 314 | pKeyTemp->top, |
||
| 315 | pKeyTemp->right, |
||
| 316 | pKeyTemp->bottom, |
||
| 317 | 0, |
||
| 318 | faceClr, |
||
| 319 | embossLtClr, |
||
| 320 | embossDkClr, |
||
| 321 | NULL, |
||
| 322 | GOL_EMBOSS_SIZE |
||
| 323 | ); |
||
| 324 | |||
| 325 | state = TE_DRAW_KEY_DRAW_PANEL; |
||
| 326 | } |
||
| 327 | else |
||
| 328 | { |
||
| 329 | state = TE_UPDATE_STRING_INIT; |
||
| 330 | goto te_update_string_init_st; |
||
| 331 | } |
||
| 332 | |||
| 333 | case TE_DRAW_KEY_DRAW_PANEL: |
||
| 334 | if(!GOLPanelDrawTsk()) |
||
| 335 | return (0); |
||
| 336 | |||
| 337 | // reset the update flag since the key panel is already redrawn |
||
| 338 | pKeyTemp->update = FALSE; |
||
| 339 | |||
| 340 | //set the text coordinates of the drawn key |
||
| 341 | xText = ((pKeyTemp->left) + (pKeyTemp->right) - (pKeyTemp->textWidth)) >> |
||
| 342 | 1; |
||
| 343 | yText = ((pKeyTemp->bottom) + (pKeyTemp->top) - (pKeyTemp->textHeight)) >> |
||
| 344 | 1; |
||
| 345 | |||
| 346 | //set color of text |
||
| 347 | // if the object is disabled, draw the disabled colors |
||
| 348 | if(GetState(pTe, TE_DISABLED) == TE_DISABLED) |
||
| 349 | { |
||
| 350 | SetColor(pTe->hdr.pGolScheme->TextColorDisabled); |
||
| 351 | } |
||
| 352 | else |
||
| 353 | { |
||
| 354 | if((GetState(pTe, TE_DRAW) != TE_DRAW) && (GetState(pTe, TE_KEY_PRESSED)) == TE_KEY_PRESSED) |
||
| 355 | { |
||
| 356 | SetColor(pTe->hdr.pGolScheme->TextColor1); |
||
| 357 | } |
||
| 358 | else |
||
| 359 | { |
||
| 360 | SetColor(pTe->hdr.pGolScheme->TextColor0); |
||
| 361 | } |
||
| 362 | } |
||
| 363 | |||
| 364 | //output the text |
||
| 365 | MoveTo(xText, yText); |
||
| 366 | |||
| 367 | // set the font to be used |
||
| 368 | SetFont(pTe->hdr.pGolScheme->pFont); |
||
| 369 | |||
| 370 | state = TE_DRAW_KEY_TEXT; |
||
| 371 | |||
| 372 | case TE_DRAW_KEY_TEXT: |
||
| 373 | if(!OutText(pKeyTemp->pKeyName)) |
||
| 374 | return (0); |
||
| 375 | state = TE_DRAW_KEY_UPDATE; |
||
| 376 | |||
| 377 | case TE_DRAW_KEY_UPDATE: |
||
| 378 | te_draw_key_update_st : |
||
| 379 | |||
| 380 | // update loop variables |
||
| 381 | CountOfKeys++; |
||
| 382 | pKeyTemp = pKeyTemp->pNextKey; |
||
| 383 | |||
| 384 | state = TE_DRAW_KEY_SET_PANEL; |
||
| 385 | goto te_draw_key_set_panel_st; |
||
| 386 | |||
| 387 | /* ********************************************************************* */ |
||
| 388 | |||
| 389 | /* Update the displayed string */ |
||
| 390 | |||
| 391 | /* ********************************************************************* */ |
||
| 392 | case TE_UPDATE_STRING_INIT: |
||
| 393 | te_update_string_init_st : |
||
| 394 | |||
| 395 | // check if there are characters to remove |
||
| 396 | if(pTe->pActiveKey != NULL) |
||
| 397 | { |
||
| 398 | if(pTe->pActiveKey->command == TE_DELETE_COM) |
||
| 399 | { |
||
| 400 | if(pTe->CurrentLength == 0) |
||
| 401 | { |
||
| 402 | state = TE_START; |
||
| 403 | return (1); |
||
| 404 | } |
||
| 405 | } |
||
| 406 | } |
||
| 407 | else |
||
| 408 | { |
||
| 409 | |||
| 410 | // check if text indeed needs to be updated |
||
| 411 | if(pTe->CurrentLength == pTe->outputLenMax) |
||
| 412 | { |
||
| 413 | state = TE_START; |
||
| 414 | return (1); |
||
| 415 | } |
||
| 416 | } |
||
| 417 | |||
| 418 | //set the clipping region |
||
| 419 | SetClipRgn |
||
| 420 | ( |
||
| 421 | pTe->hdr.left + GOL_EMBOSS_SIZE, |
||
| 422 | pTe->hdr.top + GOL_EMBOSS_SIZE, |
||
| 423 | pTe->hdr.right - GOL_EMBOSS_SIZE, |
||
| 424 | pTe->hdr.top + GOL_EMBOSS_SIZE + GetTextHeight(pTe->pDisplayFont) |
||
| 425 | ); |
||
| 426 | |||
| 427 | SetClip(1); //set the clipping |
||
| 428 | if(GetState(pTe, TE_DRAW)) |
||
| 429 | { |
||
| 430 | |||
| 431 | // update only the displayed text |
||
| 432 | // position the string rendering on the right position |
||
| 433 | if(GetState(pTe, TE_ECHO_HIDE)) |
||
| 434 | { |
||
| 435 | |||
| 436 | // fill the area with '*' character so we use the width of this character |
||
| 437 | MoveTo |
||
| 438 | ( |
||
| 439 | pTe->hdr.right - 4 - GOL_EMBOSS_SIZE - (GetTextWidth(hideChar, pTe->pDisplayFont) * pTe->CurrentLength), |
||
| 440 | pTe->hdr.top + GOL_EMBOSS_SIZE |
||
| 441 | ); |
||
| 442 | } |
||
| 443 | else |
||
| 444 | { |
||
| 445 | MoveTo |
||
| 446 | ( |
||
| 447 | pTe->hdr.right - 4 - GOL_EMBOSS_SIZE - GetTextWidth(pTe->pTeOutput, pTe->pDisplayFont), |
||
| 448 | pTe->hdr.top + GOL_EMBOSS_SIZE |
||
| 449 | ); |
||
| 450 | } |
||
| 451 | } |
||
| 452 | else if(GetState(pTe, TE_UPDATE_TEXT)) |
||
| 453 | { |
||
| 454 | |||
| 455 | // erase the current text by drawing a bar over the edit box area |
||
| 456 | SetColor(pTe->hdr.pGolScheme->Color1); |
||
| 457 | Bar |
||
| 458 | ( |
||
| 459 | pTe->hdr.left + GOL_EMBOSS_SIZE, |
||
| 460 | pTe->hdr.top + GOL_EMBOSS_SIZE, |
||
| 461 | pTe->hdr.right - GOL_EMBOSS_SIZE, |
||
| 462 | pTe->hdr.top + GOL_EMBOSS_SIZE + GetTextHeight(pTe->pDisplayFont) |
||
| 463 | ); |
||
| 464 | |||
| 465 | // we have to make sure we finish the Bar() first before we continue. |
||
| 466 | state = TE_WAIT_ERASE_EBOX_AREA; |
||
| 467 | goto te_wait_erase_ebox_area; |
||
| 468 | } |
||
| 469 | else |
||
| 470 | { |
||
| 471 | SetClip(0); //reset the clipping |
||
| 472 | state = TE_START; |
||
| 473 | return (1); |
||
| 474 | } |
||
| 475 | |||
| 476 | counter = 0; |
||
| 477 | state = TE_UPDATE_STRING; |
||
| 478 | goto te_update_string; |
||
| 479 | |||
| 480 | case TE_WAIT_ERASE_EBOX_AREA: |
||
| 481 | te_wait_erase_ebox_area : if(IsDeviceBusy()) return (0); |
||
| 482 | |||
| 483 | // check if the command given is delete a character |
||
| 484 | if(pTe->pActiveKey->command == TE_DELETE_COM) |
||
| 485 | { |
||
| 486 | *(pTe->pTeOutput + (--pTe->CurrentLength)) = 0; |
||
| 487 | } |
||
| 488 | |||
| 489 | // position the cursor to the start of string rendering |
||
| 490 | // notice that we need to remove the characters first before we position the cursor when |
||
| 491 | // deleting characters |
||
| 492 | if(GetState(pTe, TE_ECHO_HIDE)) |
||
| 493 | { |
||
| 494 | |||
| 495 | // fill the area with '*' character so we use the width of this character |
||
| 496 | MoveTo |
||
| 497 | ( |
||
| 498 | pTe->hdr.right - 4 - GOL_EMBOSS_SIZE - (GetTextWidth(hideChar, pTe->pDisplayFont) * (pTe->CurrentLength)), |
||
| 499 | pTe->hdr.top + GOL_EMBOSS_SIZE |
||
| 500 | ); |
||
| 501 | } |
||
| 502 | else |
||
| 503 | { |
||
| 504 | MoveTo |
||
| 505 | ( |
||
| 506 | pTe->hdr.right - 4 - GOL_EMBOSS_SIZE - GetTextWidth(pTe->pTeOutput, pTe->pDisplayFont), |
||
| 507 | pTe->hdr.top + GOL_EMBOSS_SIZE |
||
| 508 | ); |
||
| 509 | } |
||
| 510 | |||
| 511 | counter = 0; |
||
| 512 | state = TE_UPDATE_STRING; |
||
| 513 | |||
| 514 | case TE_UPDATE_STRING: |
||
| 515 | te_update_string : |
||
| 516 | |||
| 517 | //output the text |
||
| 518 | SetColor(pTe->hdr.pGolScheme->TextColor1); |
||
| 519 | SetFont(pTe->pDisplayFont); |
||
| 520 | |||
| 521 | // this is manually doing the OutText() function but with the capability to replace the |
||
| 522 | // characters to the * character when hide echo is enabled. |
||
| 523 | XcharTmp = *((pTe->pTeOutput) + counter); |
||
| 524 | if(XcharTmp < (unsigned XCHAR)15) |
||
| 525 | { |
||
| 526 | |||
| 527 | // update is done time to return to start and exit with success |
||
| 528 | SetClip(0); //reset the clipping |
||
| 529 | state = TE_START; |
||
| 530 | return (1); |
||
| 531 | } |
||
| 532 | else |
||
| 533 | { |
||
| 534 | if(GetState(pTe, TE_ECHO_HIDE)) |
||
| 535 | OutChar(0x2A); |
||
| 536 | else |
||
| 537 | OutChar(XcharTmp); |
||
| 538 | state = TE_UPDATE_CHARACTERS; |
||
| 539 | } |
||
| 540 | |||
| 541 | case TE_UPDATE_CHARACTERS: |
||
| 542 | if(IsDeviceBusy()) return (0); |
||
| 543 | counter++; |
||
| 544 | state = TE_UPDATE_STRING; |
||
| 545 | goto te_update_string; |
||
| 546 | } //end switch |
||
| 547 | |||
| 548 | return (1); |
||
| 549 | } //end TeDraw() |
||
| 550 | |||
| 551 | /********************************************************************* |
||
| 552 | * Function: TeTranslateMsg(TEXTENTRY *pTe, GOL_MSG *pMsg) |
||
| 553 | * |
||
| 554 | * Notes: Function to check which key was pressed/released |
||
| 555 | * |
||
| 556 | ********************************************************************/ |
||
| 557 | WORD TeTranslateMsg(TEXTENTRY *pTe, GOL_MSG *pMsg) |
||
| 558 | { |
||
| 559 | SHORT NumberOfKeys, param1, param2; |
||
| 560 | KEYMEMBER *pKeyTemp = NULL; |
||
| 561 | |||
| 562 | // Check if disabled first |
||
| 563 | if(GetState(pTe, TE_DISABLED)) |
||
| 564 | return (OBJ_MSG_INVALID); |
||
| 565 | |||
| 566 | #ifdef USE_TOUCHSCREEN |
||
| 567 | |||
| 568 | //find the total number of keys |
||
| 569 | NumberOfKeys = (pTe->horizontalKeys) * |
||
| 570 | (pTe->verticalKeys); |
||
| 571 | param1 = pMsg->param1; |
||
| 572 | param2 = pMsg->param2; |
||
| 573 | |||
| 574 | if((pMsg->type == TYPE_TOUCHSCREEN)) |
||
| 575 | { |
||
| 576 | |||
| 577 | // Check if it falls in the panel of the TextEntry |
||
| 578 | if |
||
| 579 | ( |
||
| 580 | (pTe->hdr.left < pMsg->param1) && |
||
| 581 | (pTe->hdr.right > pMsg->param1) && |
||
| 582 | (pTe->hdr.top + (GetTextHeight(pTe->pDisplayFont) + (GOL_EMBOSS_SIZE << 1)) < pMsg->param2) && |
||
| 583 | (pTe->hdr.bottom > pMsg->param2) |
||
| 584 | ) |
||
| 585 | { |
||
| 586 | |||
| 587 | /* If it fell inside the TextEntry panel, go through the link list and check which one was pressed |
||
| 588 | At this point the touch screen event is either EVENT_MOVE or EVENT_PRESS. |
||
| 589 | */ |
||
| 590 | |||
| 591 | //point to the head of the link list |
||
| 592 | pKeyTemp = pTe->pHeadOfList; |
||
| 593 | |||
| 594 | while(pKeyTemp != NULL) |
||
| 595 | { |
||
| 596 | if |
||
| 597 | ( |
||
| 598 | (pKeyTemp->left < param1) && |
||
| 599 | (pKeyTemp->right > param1) && |
||
| 600 | (pKeyTemp->top < param2) && |
||
| 601 | (pKeyTemp->bottom > param2) |
||
| 602 | ) |
||
| 603 | { |
||
| 604 | if(pMsg->uiEvent == EVENT_RELEASE) |
||
| 605 | { |
||
| 606 | pTe->pActiveKey = pKeyTemp; |
||
| 607 | pKeyTemp->update = TRUE; |
||
| 608 | |||
| 609 | if(pTe->pActiveKey->state == TE_KEY_PRESSED) |
||
| 610 | { |
||
| 611 | if(pKeyTemp->command == 0) |
||
| 612 | return (TE_MSG_ADD_CHAR); |
||
| 613 | |||
| 614 | //command for a TE_DELETE_COM key |
||
| 615 | if(pKeyTemp->command == TE_DELETE_COM) |
||
| 616 | return (TE_MSG_DELETE); |
||
| 617 | |||
| 618 | //command for a TE_SPACE_COM key 0x20 |
||
| 619 | if(pKeyTemp->command == TE_SPACE_COM) |
||
| 620 | return (TE_MSG_SPACE); |
||
| 621 | |||
| 622 | //command for a TE_ENTER_COM key |
||
| 623 | if(pKeyTemp->command == TE_ENTER_COM) |
||
| 624 | return (TE_MSG_ENTER); |
||
| 625 | } |
||
| 626 | |||
| 627 | // this is a catch all backup |
||
| 628 | return (TE_MSG_RELEASED); |
||
| 629 | } |
||
| 630 | else |
||
| 631 | { |
||
| 632 | |||
| 633 | // to shift the press to another key make sure that there are no other |
||
| 634 | // keys currently pressed. If there is one it must be released first. |
||
| 635 | // check if there are previously pressed keys |
||
| 636 | if(GetState(pTe, TE_KEY_PRESSED)) |
||
| 637 | { |
||
| 638 | |||
| 639 | // there is a key being pressed. |
||
| 640 | if(pKeyTemp->index != pTe->pActiveKey->index) |
||
| 641 | { |
||
| 642 | |||
| 643 | // release the currently pressed key first |
||
| 644 | pTe->pActiveKey->update = TRUE; |
||
| 645 | return (TE_MSG_RELEASED); |
||
| 646 | } |
||
| 647 | } |
||
| 648 | else |
||
| 649 | { |
||
| 650 | |||
| 651 | // check if the active key is not pressed |
||
| 652 | // if not, set to press since the current touch event |
||
| 653 | // is either move or press |
||
| 654 | // check if there is an active key already set |
||
| 655 | // if none, set the current key as active and return a pressed mesage |
||
| 656 | if(pTe->pActiveKey == NULL) |
||
| 657 | { |
||
| 658 | pTe->pActiveKey = pKeyTemp; |
||
| 659 | pKeyTemp->update = TRUE; |
||
| 660 | return (TE_MSG_PRESSED); |
||
| 661 | } |
||
| 662 | |||
| 663 | if(pTe->pActiveKey->state != TE_KEY_PRESSED) |
||
| 664 | { |
||
| 665 | pTe->pActiveKey = pKeyTemp; |
||
| 666 | pKeyTemp->update = TRUE; |
||
| 667 | return (TE_MSG_PRESSED); |
||
| 668 | } |
||
| 669 | else |
||
| 670 | { |
||
| 671 | return (OBJ_MSG_INVALID); |
||
| 672 | } |
||
| 673 | } |
||
| 674 | } |
||
| 675 | } |
||
| 676 | else |
||
| 677 | { |
||
| 678 | |||
| 679 | // if the key is in the pressed state and current touch is not here |
||
| 680 | // then it has to be redrawn |
||
| 681 | if(pKeyTemp->state == TE_KEY_PRESSED) |
||
| 682 | { |
||
| 683 | pTe->pActiveKey = pKeyTemp; |
||
| 684 | pKeyTemp->update = TRUE; |
||
| 685 | return (TE_MSG_RELEASED); |
||
| 686 | } |
||
| 687 | } |
||
| 688 | |||
| 689 | //access the next link list |
||
| 690 | pKeyTemp = pKeyTemp->pNextKey; |
||
| 691 | } //end while |
||
| 692 | } |
||
| 693 | else |
||
| 694 | { |
||
| 695 | if((pMsg->uiEvent == EVENT_MOVE) && (GetState(pTe, TE_KEY_PRESSED))) |
||
| 696 | { |
||
| 697 | pTe->pActiveKey->update = TRUE; |
||
| 698 | return (TE_MSG_RELEASED); |
||
| 699 | } |
||
| 700 | } |
||
| 701 | } |
||
| 702 | |||
| 703 | return (OBJ_MSG_INVALID); |
||
| 704 | #endif // USE_TOUCHSCREEN |
||
| 705 | } //end TeTranslateMsg() |
||
| 706 | |||
| 707 | /********************************************************************* |
||
| 708 | * Function: TeMsgDefault(WORD translatedMsg, TEXTENTRY *pTe, GOL_MSG* pMsg) |
||
| 709 | * |
||
| 710 | * |
||
| 711 | * Notes: This the default operation to change the state of the key. |
||
| 712 | * Called inside GOLMsg() when GOLMsgCallback() returns a 1. |
||
| 713 | * |
||
| 714 | ********************************************************************/ |
||
| 715 | void TeMsgDefault(WORD translatedMsg, TEXTENTRY *pTe, GOL_MSG *pMsg) |
||
| 716 | { |
||
| 717 | switch(translatedMsg) |
||
| 718 | { |
||
| 719 | case TE_MSG_DELETE: |
||
| 720 | SetState(pTe, TE_UPDATE_KEY | TE_UPDATE_TEXT); |
||
| 721 | break; |
||
| 722 | |||
| 723 | case TE_MSG_SPACE: |
||
| 724 | TeSpaceChar(pTe); |
||
| 725 | SetState(pTe, TE_UPDATE_KEY | TE_UPDATE_TEXT); |
||
| 726 | break; |
||
| 727 | |||
| 728 | case TE_MSG_ENTER: |
||
| 729 | SetState(pTe, TE_UPDATE_KEY); |
||
| 730 | break; |
||
| 731 | |||
| 732 | case TE_MSG_ADD_CHAR: |
||
| 733 | TeAddChar(pTe); |
||
| 734 | SetState(pTe, TE_UPDATE_KEY | TE_UPDATE_TEXT); |
||
| 735 | break; |
||
| 736 | |||
| 737 | case TE_MSG_PRESSED: |
||
| 738 | (pTe->pActiveKey)->state = TE_KEY_PRESSED; |
||
| 739 | SetState(pTe, TE_KEY_PRESSED | TE_UPDATE_KEY); |
||
| 740 | return; |
||
| 741 | |||
| 742 | case TE_MSG_RELEASED: |
||
| 743 | (pTe->pActiveKey)->state = 0; |
||
| 744 | ClrState(pTe, TE_KEY_PRESSED); // reset pressed |
||
| 745 | SetState(pTe, TE_UPDATE_KEY); // redraw |
||
| 746 | return; |
||
| 747 | } |
||
| 748 | |||
| 749 | if(pTe->pActiveKey != NULL) |
||
| 750 | (pTe->pActiveKey)->state = 0; |
||
| 751 | ClrState(pTe, TE_KEY_PRESSED); |
||
| 752 | } |
||
| 753 | |||
| 754 | /********************************************************************* |
||
| 755 | * Function: void TeClearBuffer(TEXTENTRY *pTe) |
||
| 756 | * |
||
| 757 | * Notes: This function will clear the edibox and the buffer. |
||
| 758 | * You must set the drawing state bit TE_UPDATE_TEXT |
||
| 759 | * to update the TEXTENTRY on the screen. |
||
| 760 | * |
||
| 761 | ********************************************************************/ |
||
| 762 | void TeClearBuffer(TEXTENTRY *pTe) |
||
| 763 | { |
||
| 764 | WORD i; |
||
| 765 | |||
| 766 | //clear the buffer |
||
| 767 | for(i = 0; i < (pTe->outputLenMax); i++) |
||
| 768 | { |
||
| 769 | *(pTe->pTeOutput + i) = 0; |
||
| 770 | } |
||
| 771 | |||
| 772 | pTe->CurrentLength = 0; |
||
| 773 | } |
||
| 774 | |||
| 775 | /********************************************************************* |
||
| 776 | * Function: void TeSetBuffer(TEXTENTRY *pTe, XCHAR *pText, WORD size) |
||
| 777 | * |
||
| 778 | * Notes: This function will replace the currently used buffer. |
||
| 779 | * MaxSize defines the length of the buffer. Buffer must be |
||
| 780 | * a NULL terminated string. |
||
| 781 | * |
||
| 782 | ********************************************************************/ |
||
| 783 | void TeSetBuffer(TEXTENTRY *pTe, XCHAR *pText, WORD MaxSize) |
||
| 784 | { |
||
| 785 | WORD count = 0; |
||
| 786 | XCHAR *pTemp; |
||
| 787 | |||
| 788 | pTemp = pText; |
||
| 789 | |||
| 790 | while(*pTemp != 0) |
||
| 791 | { |
||
| 792 | if(count >= MaxSize) |
||
| 793 | break; |
||
| 794 | *pTemp++; |
||
| 795 | count++; |
||
| 796 | } |
||
| 797 | |||
| 798 | // terminate the string |
||
| 799 | *pTemp = 0; |
||
| 800 | |||
| 801 | pTe->CurrentLength = count; |
||
| 802 | pTe->outputLenMax = MaxSize-1; |
||
| 803 | pTe->pTeOutput = pText; |
||
| 804 | } |
||
| 805 | |||
| 806 | /********************************************************************* |
||
| 807 | * Function: BOOL TeIsKeyPressed(TEXTENTRY *pTe,WORD index) |
||
| 808 | * |
||
| 809 | * Notes: This function will check if the key was pressed. If no |
||
| 810 | * key was pressed it will return FALSE. |
||
| 811 | * |
||
| 812 | ********************************************************************/ |
||
| 813 | BOOL TeIsKeyPressed(TEXTENTRY *pTe, WORD index) |
||
| 814 | { |
||
| 815 | KEYMEMBER *pTemp; |
||
| 816 | |||
| 817 | pTemp = pTe->pHeadOfList; |
||
| 818 | |||
| 819 | //search the key using the given index |
||
| 820 | while(index != pTemp->index) |
||
| 821 | { |
||
| 822 | |||
| 823 | // catch all check |
||
| 824 | if(pTemp == NULL) |
||
| 825 | return (FALSE); |
||
| 826 | pTemp = pTemp->pNextKey; |
||
| 827 | } |
||
| 828 | |||
| 829 | if(pTemp->state == TE_KEY_PRESSED) |
||
| 830 | { |
||
| 831 | return (TRUE); |
||
| 832 | } |
||
| 833 | else |
||
| 834 | { |
||
| 835 | return (FALSE); |
||
| 836 | } |
||
| 837 | } |
||
| 838 | |||
| 839 | /********************************************************************* |
||
| 840 | * Function: BOOL TeSetKeyCommand(TEXTENTRY *pTe,WORD index,WORD command) |
||
| 841 | * |
||
| 842 | * Notes: This function will assign a command to a particular key. |
||
| 843 | * Returns TRUE if sucessful and FALSE if not. |
||
| 844 | * |
||
| 845 | ********************************************************************/ |
||
| 846 | BOOL TeSetKeyCommand(TEXTENTRY *pTe, WORD index, WORD command) |
||
| 847 | { |
||
| 848 | KEYMEMBER *pTemp; |
||
| 849 | |||
| 850 | pTemp = pTe->pHeadOfList; |
||
| 851 | |||
| 852 | //search the key using the given index |
||
| 853 | while(index != pTemp->index) |
||
| 854 | { |
||
| 855 | |||
| 856 | // catch all check |
||
| 857 | if(pTemp == NULL) |
||
| 858 | return (FALSE); |
||
| 859 | pTemp = pTemp->pNextKey; |
||
| 860 | } |
||
| 861 | |||
| 862 | pTemp->command = command; |
||
| 863 | return (TRUE); |
||
| 864 | } |
||
| 865 | |||
| 866 | /********************************************************************* |
||
| 867 | * Function: TeGetKeyCommand(pTe, index) |
||
| 868 | * |
||
| 869 | * Notes: This function will return the currently used command by a key |
||
| 870 | * with the given index. |
||
| 871 | * |
||
| 872 | ********************************************************************/ |
||
| 873 | WORD TeGetKeyCommand(TEXTENTRY *pTe, WORD index) |
||
| 874 | { |
||
| 875 | KEYMEMBER *pTemp; |
||
| 876 | |||
| 877 | pTemp = pTe->pHeadOfList; |
||
| 878 | |||
| 879 | //search the key using the given index |
||
| 880 | while(index != pTemp->index) |
||
| 881 | { |
||
| 882 | |||
| 883 | // catch all check |
||
| 884 | if(pTemp == NULL) |
||
| 885 | return (0); |
||
| 886 | pTemp = pTemp->pNextKey; |
||
| 887 | } |
||
| 888 | |||
| 889 | return (pTemp->command); |
||
| 890 | } |
||
| 891 | |||
| 892 | /********************************************************************* |
||
| 893 | * Function: BOOL TeSetKeyText(TEXTENTRY *pTe,WORD index, XCHAR *pText) |
||
| 894 | * |
||
| 895 | * Notes: This function will set the string associated with the key |
||
| 896 | * with the new string pText. The key to be modified is determined |
||
| 897 | * by the index. Returns TRUE if sucessful and FALSE if not. |
||
| 898 | * |
||
| 899 | ********************************************************************/ |
||
| 900 | BOOL TeSetKeyText(TEXTENTRY *pTe, WORD index, XCHAR *pText) |
||
| 901 | { |
||
| 902 | KEYMEMBER *pTemp; |
||
| 903 | |||
| 904 | pTemp = pTe->pHeadOfList; |
||
| 905 | |||
| 906 | //search the key using the given index |
||
| 907 | while(index != pTemp->index) |
||
| 908 | { |
||
| 909 | // catch all check |
||
| 910 | if(pTemp == NULL) |
||
| 911 | return (FALSE); |
||
| 912 | pTemp = pTemp->pNextKey; |
||
| 913 | } |
||
| 914 | |||
| 915 | // Set the the text |
||
| 916 | pTemp->pKeyName = pText; |
||
| 917 | |||
| 918 | return (TRUE); |
||
| 919 | } |
||
| 920 | |||
| 921 | |||
| 922 | /********************************************************************* |
||
| 923 | * Function: KEYMEMBER *TeCreateKeyMembers(TEXTENTRY *pTe,XCHAR *pText[]) |
||
| 924 | * |
||
| 925 | * Notes: This function will create the members of the list |
||
| 926 | * |
||
| 927 | ********************************************************************/ |
||
| 928 | KEYMEMBER *TeCreateKeyMembers(TEXTENTRY *pTe, XCHAR *pText[]) |
||
| 929 | { |
||
| 930 | SHORT NumberOfKeys, width, height; |
||
| 931 | SHORT keyTop, keyLeft; |
||
| 932 | WORD rowcount, colcount; |
||
| 933 | WORD index = 0; |
||
| 934 | |||
| 935 | KEYMEMBER *pKl = NULL; //link list |
||
| 936 | KEYMEMBER *pTail = NULL; |
||
| 937 | |||
| 938 | // determine starting positions of the keys |
||
| 939 | keyTop = pTe->hdr.top + |
||
| 940 | GetTextHeight(pTe->pDisplayFont) + |
||
| 941 | (GOL_EMBOSS_SIZE << 1); |
||
| 942 | keyLeft = pTe->hdr.left; // + GOL_EMBOSS_SIZE; |
||
| 943 | |||
| 944 | //calculate the total number of keys, and width and height of each key |
||
| 945 | NumberOfKeys = pTe->horizontalKeys * |
||
| 946 | pTe->verticalKeys; |
||
| 947 | width = (pTe->hdr.right - keyLeft + 1) / pTe->horizontalKeys; |
||
| 948 | height = (pTe->hdr.bottom - keyTop + 1) / pTe->verticalKeys; |
||
| 949 | |||
| 950 | /*create the list and calculate the coordinates of each bottom, and the textwidth/textheight of each font*/ |
||
| 951 | |||
| 952 | //Add a list for each key |
||
| 953 | for(colcount = 0; colcount < pTe->verticalKeys; colcount++) |
||
| 954 | { |
||
| 955 | for(rowcount = 0; rowcount < pTe->horizontalKeys; rowcount++) |
||
| 956 | { |
||
| 957 | |||
| 958 | //get storage for new entry |
||
| 959 | pKl = (KEYMEMBER *)GFX_malloc(sizeof(KEYMEMBER)); |
||
| 960 | if(pKl == NULL) |
||
| 961 | return (NULL); |
||
| 962 | if(pTe->pHeadOfList == NULL) |
||
| 963 | pTe->pHeadOfList = pKl; |
||
| 964 | if(pTail == NULL) |
||
| 965 | { |
||
| 966 | pTail = pKl; |
||
| 967 | } |
||
| 968 | else |
||
| 969 | { |
||
| 970 | pTail->pNextKey = pKl; |
||
| 971 | pTail = pTail->pNextKey; |
||
| 972 | } |
||
| 973 | |||
| 974 | //set the index for the new list |
||
| 975 | pKl->index = index; |
||
| 976 | |||
| 977 | // set update flag to off |
||
| 978 | pKl->update = FALSE; |
||
| 979 | |||
| 980 | //calculate the x-y coordinate for each key |
||
| 981 | pKl->left = keyLeft + (rowcount * width); |
||
| 982 | pKl->top = keyTop + (colcount * height); |
||
| 983 | pKl->right = keyLeft + ((rowcount + 1) * width); |
||
| 984 | pKl->bottom = keyTop + ((colcount + 1) * height); |
||
| 985 | |||
| 986 | //Add the text to the list and increase the index |
||
| 987 | pKl->pKeyName = pText[index++]; |
||
| 988 | |||
| 989 | //set the COMMAND to NULL for all keys |
||
| 990 | pKl->command = 0; |
||
| 991 | |||
| 992 | //calculate the textwidth, textheight |
||
| 993 | pKl->textWidth = 0; |
||
| 994 | pKl->textHeight = 0; |
||
| 995 | if(pKl->pKeyName != NULL) |
||
| 996 | { |
||
| 997 | |||
| 998 | // Calculate the text width & height |
||
| 999 | pKl->textWidth = GetTextWidth(pKl->pKeyName, pTe->hdr.pGolScheme->pFont); |
||
| 1000 | pKl->textHeight = GetTextHeight(pTe->hdr.pGolScheme->pFont); |
||
| 1001 | } //end if |
||
| 1002 | } //end for |
||
| 1003 | } //end for |
||
| 1004 | |||
| 1005 | pTail->pNextKey = NULL; |
||
| 1006 | |||
| 1007 | return (pKl); |
||
| 1008 | } |
||
| 1009 | |||
| 1010 | /********************************************************************* |
||
| 1011 | * Function: void TeDelKeyMembers(TEXTENTRY *pTe) |
||
| 1012 | * |
||
| 1013 | * Notes: This function will delete the members of the list |
||
| 1014 | ********************************************************************/ |
||
| 1015 | void TeDelKeyMembers(TEXTENTRY *pTe) |
||
| 1016 | { |
||
| 1017 | KEYMEMBER *pCurItem; |
||
| 1018 | KEYMEMBER *pItem; |
||
| 1019 | |||
| 1020 | pCurItem = pTe->pHeadOfList; |
||
| 1021 | |||
| 1022 | while(pCurItem != NULL) |
||
| 1023 | { |
||
| 1024 | pItem = pCurItem; |
||
| 1025 | pCurItem = pCurItem->pNextKey; |
||
| 1026 | GFX_free(pItem); |
||
| 1027 | } |
||
| 1028 | |||
| 1029 | pTe->pHeadOfList = NULL; |
||
| 1030 | } |
||
| 1031 | |||
| 1032 | /********************************************************************* |
||
| 1033 | * Function: void TeSpaceChar(TEXTENTRY *pTe) |
||
| 1034 | * |
||
| 1035 | * Notes: This function will add a space to the buffer/editbox |
||
| 1036 | ********************************************************************/ |
||
| 1037 | void TeSpaceChar(TEXTENTRY *pTe) |
||
| 1038 | { |
||
| 1039 | |||
| 1040 | //first determine if the array has not overflown |
||
| 1041 | if((pTe->CurrentLength) < pTe->outputLenMax) |
||
| 1042 | { |
||
| 1043 | *(pTe->pTeOutput + (pTe->CurrentLength)) = 0x20; |
||
| 1044 | *(pTe->pTeOutput + (pTe->CurrentLength) + 1) = 0; |
||
| 1045 | } //end if |
||
| 1046 | (pTe->CurrentLength)++; |
||
| 1047 | } |
||
| 1048 | |||
| 1049 | /********************************************************************* |
||
| 1050 | * Function: void TeAddChar(TEXTENTRY *pTe) |
||
| 1051 | * |
||
| 1052 | * Notes: This function will add a character to the buffer/editbox |
||
| 1053 | ********************************************************************/ |
||
| 1054 | void TeAddChar(TEXTENTRY *pTe) |
||
| 1055 | { |
||
| 1056 | XCHAR *pPoint; |
||
| 1057 | |||
| 1058 | //first determine if the array has not overflown |
||
| 1059 | if((pTe->CurrentLength) < pTe->outputLenMax) |
||
| 1060 | { |
||
| 1061 | pPoint = (pTe->pActiveKey)->pKeyName; |
||
| 1062 | while(*(pPoint) != 0) |
||
| 1063 | { |
||
| 1064 | *(pTe->pTeOutput + (pTe->CurrentLength)) = *(pPoint)++; |
||
| 1065 | } |
||
| 1066 | } //end if |
||
| 1067 | else |
||
| 1068 | { |
||
| 1069 | |||
| 1070 | // it is full ignore the added key |
||
| 1071 | return; |
||
| 1072 | } |
||
| 1073 | |||
| 1074 | (pTe->CurrentLength)++; |
||
| 1075 | // add the string terminator |
||
| 1076 | *(pTe->pTeOutput + pTe->CurrentLength) = 0; |
||
| 1077 | } |
||
| 1078 | |||
| 1079 | #endif // USE_TEXTENTRY |
Powered by WebSVN v2.8.3