?lang_form? ?lang_select? ?lang_submit? ?lang_endform?
{HEADER END}
{BLAME START}

library

?curdirlinks? -

Blame information for rev 32

Line No. Rev Author Line
1 32 kaklik /*****************************************************************************
2 * Module for Microchip Graphics Library
3 * GOL Layer
4 * List Box
5 *****************************************************************************
6 * FileName: ListBox.c
7 * Dependencies: None
8 * Processor: PIC24F, PIC24H, dsPIC, PIC32
9 * Compiler: MPLAB C30 V3.00, MPLAB C32
10 * Linker: MPLAB LINK30, MPLAB 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 * Anton Alkhimenok 11/12/07 Version 1.0 release
40 *****************************************************************************/
41 #include "Graphics\Graphics.h"
42  
43 #ifdef USE_LISTBOX
44  
45 /*********************************************************************
46 * Function: LISTBOX *LbCreate(WORD ID, SHORT left, SHORT top, SHORT right, SHORT bottom,
47 * WORD state, XCHAR* pText, GOL_SCHEME *pScheme)
48 *
49 * Overview: creates the list box
50 *
51 ********************************************************************/
52 LISTBOX *LbCreate
53 (
54 WORD ID,
55 SHORT left,
56 SHORT top,
57 SHORT right,
58 SHORT bottom,
59 WORD state,
60 XCHAR *pText,
61 GOL_SCHEME *pScheme
62 )
63 {
64 LISTBOX *pLb = NULL;
65 XCHAR *pointer;
66 WORD counter;
67  
68 pLb = (LISTBOX *)GFX_malloc(sizeof(LISTBOX));
69  
70 if(pLb == NULL)
71 return (pLb);
72  
73 pLb->hdr.ID = ID;
74 pLb->hdr.pNxtObj = NULL;
75 pLb->hdr.type = OBJ_LISTBOX;
76 pLb->hdr.left = left;
77 pLb->hdr.top = top;
78 pLb->hdr.right = right;
79 pLb->hdr.bottom = bottom;
80 pLb->hdr.state = state;
81 pLb->pItemList = NULL;
82 pLb->scrollY = 0;
83 pLb->itemsNumber = 0;
84  
85 // Set the style scheme to be used
86 if(pScheme == NULL)
87 pLb->hdr.pGolScheme = _pDefaultGolScheme;
88 else
89 pLb->hdr.pGolScheme = (GOL_SCHEME *)pScheme;
90  
91 pLb->textHeight = GetTextHeight(pLb->hdr.pGolScheme->pFont);
92  
93 GOLAddObject((OBJ_HEADER *)pLb);
94  
95 // Add items if there's an initialization text (each line will become one item,
96 // lines must be separated by '\n' character)
97 if(pText != NULL)
98 {
99 pointer = pText;
100 counter = 0;
101 while(*pointer)
102 {
103 if(NULL == LbAddItem(pLb, NULL, pointer, NULL, 0, counter))
104 break;
105 while((XCHAR) *pointer++ > (XCHAR)31);
106 if(*(pointer - 1) == 0)
107 break;
108 counter++;
109 }
110 }
111  
112 pLb->pFocusItem = pLb->pItemList;
113  
114 // Set focus for the object if FOCUSED state is set
115 #ifdef USE_FOCUS
116 if(GetState(pLb, LB_FOCUSED))
117 GOLSetFocus((OBJ_HEADER *)pLb);
118 #endif
119 return (pLb);
120 }
121  
122 /*********************************************************************
123 * Function: LISTITEM* LbAddItem(LISTBOX *pLb, LISTITEM *pPrevItem, XCHAR *pText, void* pBitmap, WORD status, WORD data)
124 *
125 * Input: pLb - the pointer to the list box,
126 * pPrevItem - pointer to the item after which a new item must be inserted,
127 * if this pointer is NULL, the item will be appended at the end of the items list,
128 * pText - pointer to the text,
129 * pBitmap - pointer to the bitmap,
130 * status - status after creation,
131 * data - some data associated with the item
132 *
133 * Output: pointer to the item created, NULL if the operation was not successful
134 *
135 * Overview: allocates memory for a new item and adds it to the list box
136 *
137 ********************************************************************/
138 LISTITEM *LbAddItem(LISTBOX *pLb, LISTITEM *pPrevItem, XCHAR *pText, void *pBitmap, WORD status, WORD data)
139 {
140 LISTITEM *pItem;
141 LISTITEM *pCurItem;
142  
143 pItem = (LISTITEM *)GFX_malloc(sizeof(LISTITEM));
144  
145 if(pItem == NULL)
146 {
147 return (NULL);
148 }
149  
150 pLb->itemsNumber++;
151  
152 if(pLb->pItemList == NULL)
153 {
154 pLb->pItemList = pItem;
155 pItem->pNextItem = NULL;
156 pItem->pPrevItem = NULL;
157 }
158 else
159 {
160 if(pPrevItem == NULL)
161 {
162  
163 // Find last item
164 pCurItem = (LISTITEM *)pLb->pItemList;
165 while(pCurItem->pNextItem != NULL)
166 pCurItem = (LISTITEM *)pCurItem->pNextItem;
167 }
168 else
169 {
170 pCurItem = (LISTITEM *)pPrevItem;
171 }
172  
173 // Insert a new item
174 pItem->pNextItem = pCurItem->pNextItem;
175 pItem->pPrevItem = pCurItem;
176 pCurItem->pNextItem = pItem;
177 }
178  
179 pItem->pText = pText;
180 pItem->pBitmap = pBitmap;
181 pItem->status = status;
182 pItem->data = data;
183  
184 return (pItem);
185 }
186  
187 /*********************************************************************
188 * Function: void LbDelItem(LISTBOX *pLb, LISTITEM *pItem)
189 *
190 * Input: pLb - the pointer to the object,
191 * pItem - the pointer to the item must be deleted
192 *
193 * Output: none
194 *
195 * Overview: removes an item from the list box and frees memory
196 *
197 ********************************************************************/
198 void LbDelItem(LISTBOX *pLb, LISTITEM *pItem)
199 {
200 if(pItem->pNextItem != NULL)
201 {
202 ((LISTITEM *)pItem->pNextItem)->pPrevItem = pItem->pPrevItem;
203 if(pItem->pPrevItem == NULL)
204 pLb->pItemList = (LISTITEM *)pItem->pNextItem;
205 }
206  
207 if(pItem->pPrevItem != NULL)
208 ((LISTITEM *)pItem->pPrevItem)->pNextItem = pItem->pNextItem;
209  
210 GFX_free(pItem);
211  
212 pLb->itemsNumber--;
213  
214 if(pLb->itemsNumber == 0)
215 pLb->pItemList = NULL;
216 }
217  
218 /*********************************************************************
219 * Function: void LbDelItemsList(LISTBOX *pLb)
220 *
221 * Input: pLb - the pointer to the object
222 *
223 * Output: none
224 *
225 * Overview: removes all items from list box and frees memory
226 *
227 ********************************************************************/
228 void LbDelItemsList(LISTBOX *pLb)
229 {
230 LISTITEM *pCurItem;
231 LISTITEM *pItem;
232  
233 pCurItem = pLb->pItemList;
234  
235 while(pCurItem != NULL)
236 {
237 pItem = pCurItem;
238 pCurItem = (LISTITEM *)pCurItem->pNextItem;
239 GFX_free(pItem);
240 }
241  
242 pLb->pItemList = NULL;
243 }
244  
245 /*********************************************************************
246 * Function: LISTITEM* LbGetSel(LISTBOX *pLb, LISTITEM *pFromItem)
247 *
248 * Input: pLb - the pointer to the object,
249 * pFromItem - pointer to the item the seach must start from,
250 * if the pointer is NULL the search begins from the start of the items list
251 *
252 * Output: pointer to the selected item, NULL if there are no items selected
253 *
254 * Overview: seaches for selected items
255 *
256 ********************************************************************/
257 LISTITEM *LbGetSel(LISTBOX *pLb, LISTITEM *pFromItem)
258 {
259 if(pFromItem == NULL)
260 {
261 pFromItem = pLb->pItemList;
262 }
263  
264 while(pFromItem != NULL)
265 {
266 if(pFromItem->status & LB_STS_SELECTED)
267 break;
268 pFromItem = (LISTITEM *)pFromItem->pNextItem;
269 }
270  
271 return (pFromItem);
272 }
273  
274 /*********************************************************************
275 * Function: void LbChangeSel(LISTBOX *pLb, LISTITEM *pItem)
276 *
277 * Input: pLb - the pointer to the object,
278 * pItem - pointer to the item the selection status will be changed
279 *
280 * Output: none
281 *
282 * Overview: changes selection status of an item
283 *
284 ********************************************************************/
285 void LbChangeSel(LISTBOX *pLb, LISTITEM *pItem)
286 {
287 LISTITEM *pCurItem;
288  
289 if(GetState(pLb, LB_SINGLE_SEL))
290 {
291  
292 // Remove selection from all items
293 pCurItem = pLb->pItemList;
294 while(pCurItem != NULL)
295 {
296 if(pCurItem->status & LB_STS_SELECTED)
297 {
298 pCurItem->status &= ~LB_STS_SELECTED;
299 pCurItem->status |= LB_STS_REDRAW;
300 }
301  
302 pCurItem = (LISTITEM *)pCurItem->pNextItem;
303 }
304 }
305  
306 pItem->status ^= LB_STS_SELECTED;
307 pItem->status |= LB_STS_REDRAW;
308 }
309  
310 /*********************************************************************
311 * Function: void LbSetFocusedItem(LISTBOX* pLb, SHORT index)
312 *
313 * Input: pLb - the pointer to the object
314 * index - item number from the list beginning
315 *
316 * Output: none
317 *
318 * Overview: sets focus for the item with index defined
319 *
320 ********************************************************************/
321 void LbSetFocusedItem(LISTBOX *pLb, SHORT index)
322 {
323 LISTITEM *pCurItem;
324  
325 // Look for item to be focused
326 pCurItem = pLb->pItemList;
327  
328 if(pCurItem == NULL)
329 return;
330  
331 while(pCurItem->pNextItem != NULL)
332 {
333 if(index <= 0)
334 break;
335 index--;
336 pCurItem = (LISTITEM *)pCurItem->pNextItem;
337 }
338  
339 if(pCurItem != NULL)
340 {
341 if(pLb->pFocusItem != NULL)
342 {
343 pLb->pFocusItem->status |= LB_STS_REDRAW;
344 }
345  
346 pLb->pFocusItem = pCurItem;
347 pCurItem->status |= LB_STS_REDRAW;
348 }
349 }
350  
351 /*********************************************************************
352 * Function: SHORT LbGetFocusedItem(LISTBOX* pLb)
353 *
354 * Input: pLb - the pointer to the list box
355 *
356 * Output: index of the focused item, -1 if there's no item in focus
357 *
358 * Overview: returns focused item number from the list beginning
359 *
360 ********************************************************************/
361 SHORT LbGetFocusedItem(LISTBOX *pLb)
362 {
363 LISTITEM *pCurItem;
364 SHORT index;
365  
366 if(pLb->pFocusItem == NULL)
367 return (-1);
368  
369 // Look for the focused item index
370 index = 0;
371 pCurItem = pLb->pItemList;
372 while(pCurItem->pNextItem != NULL)
373 {
374 if(pCurItem == pLb->pFocusItem)
375 break;
376 index++;
377 pCurItem = (LISTITEM *)pCurItem->pNextItem;
378 }
379  
380 return (index);
381 }
382  
383 /*********************************************************************
384 * Function: WORD LbTranslateMsg(LISTBOX *pLb, GOL_MSG *pMsg)
385 *
386 * Overview: translates the GOL message for the list box
387 *
388 ********************************************************************/
389 WORD LbTranslateMsg(LISTBOX *pLb, GOL_MSG *pMsg)
390 {
391  
392 // Evaluate if the message is for the list box
393 // Check if disabled first
394 if(GetState(pLb, LB_DISABLED))
395 return (OBJ_MSG_INVALID);
396  
397 #ifdef USE_TOUCHSCREEN
398 if(pMsg->type == TYPE_TOUCHSCREEN)
399 {
400  
401 // Check if it falls in list box borders
402 if
403 (
404 (pLb->hdr.left < pMsg->param1) &&
405 (pLb->hdr.right > pMsg->param1) &&
406 (pLb->hdr.top < pMsg->param2) &&
407 (pLb->hdr.bottom > pMsg->param2)
408 ) return (LB_MSG_TOUCHSCREEN);
409  
410 return (OBJ_MSG_INVALID);
411 }
412  
413 #endif
414 #ifdef USE_KEYBOARD
415 if(pMsg->type == TYPE_KEYBOARD)
416 if(pMsg->param1 == pLb->hdr.ID)
417 {
418 if(pMsg->uiEvent == EVENT_KEYSCAN)
419 {
420 if((pMsg->param2 == SCAN_UP_PRESSED) || (pMsg->param2 == SCAN_DOWN_PRESSED))
421 return (LB_MSG_MOVE);
422  
423 if((pMsg->param2 == SCAN_SPACE_PRESSED) || (pMsg->param2 == SCAN_CR_PRESSED))
424 return (LB_MSG_SEL);
425 }
426  
427 return (OBJ_MSG_INVALID);
428 }
429  
430 #endif
431 return (OBJ_MSG_INVALID);
432 }
433  
434 /*********************************************************************
435 * Function: void LbMsgDefault(WORD translatedMsg, LISTBOX *pLb, GOL_MSG *pMsg)
436 *
437 * Overview: changes the state of the list box by default
438 *
439 ********************************************************************/
440 void LbMsgDefault(WORD translatedMsg, LISTBOX *pLb, GOL_MSG *pMsg)
441 {
442 #ifdef USE_TOUCHSCREEN
443  
444 SHORT pos;
445 LISTITEM *pItem;
446  
447 if(pMsg->type == TYPE_TOUCHSCREEN)
448 {
449 #ifdef USE_FOCUS
450 if(pMsg->type == TYPE_TOUCHSCREEN)
451 {
452 if(!GetState(pLb, LB_FOCUSED))
453 {
454 GOLSetFocus((OBJ_HEADER *)pLb);
455 }
456 }
457  
458 #endif
459 if(pMsg->uiEvent == EVENT_PRESS)
460 {
461 pos = (pMsg->param2 - pLb->scrollY - pLb->hdr.top - LB_INDENT - GOL_EMBOSS_SIZE) / pLb->textHeight;
462 pItem = (LISTITEM *)pLb->pItemList;
463 while(pos)
464 {
465 if(pItem == NULL)
466 break;
467 if(pItem->pNextItem == NULL)
468 break;
469 pItem = (LISTITEM *)pItem->pNextItem;
470 pos--;
471 }
472  
473 if(pLb->pFocusItem != pItem)
474 {
475 pItem->status |= LB_STS_REDRAW;
476 pLb->pFocusItem->status |= LB_STS_REDRAW;
477 pLb->pFocusItem = pItem;
478 SetState(pLb, LB_DRAW_ITEMS);
479 }
480  
481 LbChangeSel(pLb, pItem);
482 SetState(pLb, LB_DRAW_ITEMS);
483 }
484 }
485  
486 #endif
487 #ifdef USE_KEYBOARD
488 if(pMsg->type == TYPE_KEYBOARD)
489 {
490 switch(translatedMsg)
491 {
492 case LB_MSG_SEL:
493 if(pLb->pFocusItem != NULL)
494 LbChangeSel(pLb, pLb->pFocusItem);
495 SetState(pLb, LB_DRAW_ITEMS);
496 break;
497  
498 case LB_MSG_MOVE:
499 switch(pMsg->param2)
500 {
501 case SCAN_UP_PRESSED:
502 LbSetFocusedItem(pLb, LbGetFocusedItem(pLb) - 1);
503 SetState(pLb, LB_DRAW_ITEMS);
504 break;
505  
506 case SCAN_DOWN_PRESSED:
507 LbSetFocusedItem(pLb, LbGetFocusedItem(pLb) + 1);
508 SetState(pLb, LB_DRAW_ITEMS);
509 break;
510 }
511  
512 break;
513 }
514 } // end of if
515 #endif
516 }
517  
518 /*********************************************************************
519 * Function: WORD LbDraw(LISTBOX *pLb)
520 *
521 * Output: returns the status of the drawing
522 * 0 - not completed
523 * 1 - done
524 *
525 * Overview: draws edit box
526 *
527 ********************************************************************/
528 WORD LbDraw(LISTBOX *pLb)
529 {
530 typedef enum
531 {
532 LB_STATE_START,
533 LB_STATE_PANEL,
534 LB_STATE_ERASEITEM,
535 LB_STATE_ITEMFOCUS,
536 LB_STATE_BITMAP,
537 LB_STATE_TEXT
538 } LB_DRAW_STATES;
539  
540 static LB_DRAW_STATES state = LB_STATE_START;
541 static LISTITEM *pCurItem;
542 static SHORT temp;
543  
544 switch(state)
545 {
546  
547 /////////////////////////////////////////////////////////////////////
548 // REMOVE FROM SCREEN
549 /////////////////////////////////////////////////////////////////////
550 case LB_STATE_START:
551 if(GetState(pLb, LB_HIDE))
552 {
553 SetColor(pLb->hdr.pGolScheme->CommonBkColor);
554 if(!Bar(pLb->hdr.left, pLb->hdr.top, pLb->hdr.right, pLb->hdr.bottom))
555 return (0);
556 return (1);
557 }
558  
559 if(GetState(pLb, LB_DRAW_FOCUS))
560 {
561 if(pLb->pFocusItem != NULL)
562 ((LISTITEM *)pLb->pFocusItem)->status |= LB_STS_REDRAW;
563 SetState(pLb, LB_DRAW_ITEMS);
564 }
565  
566 /////////////////////////////////////////////////////////////////////
567 // DRAW PANEL
568 /////////////////////////////////////////////////////////////////////
569 if(GetState(pLb, LB_DRAW))
570 {
571 if(GetState(pLb, LB_DISABLED))
572 {
573 temp = pLb->hdr.pGolScheme->ColorDisabled;
574 }
575 else
576 {
577 temp = pLb->hdr.pGolScheme->Color0;
578 }
579  
580 GOLPanelDraw
581 (
582 pLb->hdr.left,
583 pLb->hdr.top,
584 pLb->hdr.right,
585 pLb->hdr.bottom,
586 0,
587 temp,
588 pLb->hdr.pGolScheme->EmbossDkColor,
589 pLb->hdr.pGolScheme->EmbossLtColor,
590 NULL,
591 GOL_EMBOSS_SIZE
592 );
593  
594 state = LB_STATE_PANEL;
595  
596 case LB_STATE_PANEL:
597 if(!GOLPanelDrawTsk())
598 return (0);
599 }
600  
601 /////////////////////////////////////////////////////////////////////
602 // DRAW ITEMS
603 /////////////////////////////////////////////////////////////////////
604 L_LB_DRAW:
605 SetClip(CLIP_ENABLE);
606  
607 SetClipRgn
608 (
609 pLb->hdr.left + GOL_EMBOSS_SIZE + LB_INDENT,
610 pLb->hdr.top + GOL_EMBOSS_SIZE + LB_INDENT,
611 pLb->hdr.right - GOL_EMBOSS_SIZE - LB_INDENT,
612 pLb->hdr.bottom - GOL_EMBOSS_SIZE - LB_INDENT
613 );
614  
615 SetFont(pLb->hdr.pGolScheme->pFont);
616  
617 // Set graphics cursor
618 MoveTo(pLb->hdr.left + GOL_EMBOSS_SIZE + LB_INDENT, pLb->hdr.top + GOL_EMBOSS_SIZE + LB_INDENT + pLb->scrollY);
619  
620 pCurItem = pLb->pItemList;
621  
622 /////////////////////////////////////////////////////////////////////
623 // DRAW CURRENT ITEM
624 /////////////////////////////////////////////////////////////////////
625 L_LB_DRAWITEM:
626 if(pCurItem == NULL)
627 {
628 state = LB_STATE_START;
629 SetClip(CLIP_DISABLE);
630 return (1);
631 }
632  
633 /////////////////////////////////////////////////////////////////////
634 if(GetY() < pLb->hdr.bottom - GOL_EMBOSS_SIZE - LB_INDENT)
635 if((GetY() + pLb->textHeight) >= (pLb->hdr.top + GOL_EMBOSS_SIZE + LB_INDENT))
636 {
637 if(!GetState(pLb, LB_DRAW))
638 if(!(pCurItem->status & LB_STS_REDRAW))
639 goto L_LB_NEXTITEM;
640  
641 pCurItem->status &= ~LB_STS_REDRAW;
642  
643 state = LB_STATE_ERASEITEM;
644  
645 case LB_STATE_ERASEITEM:
646 if(IsDeviceBusy())
647 return (0);
648  
649 if(GetState(pLb, LB_DISABLED))
650 {
651 SetColor(pLb->hdr.pGolScheme->ColorDisabled);
652 }
653 else
654 {
655 SetColor(pLb->hdr.pGolScheme->Color0);
656 if(pCurItem != NULL)
657 if(pCurItem->status & LB_STS_SELECTED)
658 {
659 SetColor(pLb->hdr.pGolScheme->Color1);
660 }
661 }
662  
663 if
664 (
665 !Bar
666 (
667 pLb->hdr.left + GOL_EMBOSS_SIZE + LB_INDENT,
668 GetY(),
669 pLb->hdr.right - GOL_EMBOSS_SIZE - LB_INDENT,
670 GetY() + pLb->textHeight
671 )
672 ) return (0);
673  
674 if(!GetState(pLb, LB_CENTER_ALIGN | LB_RIGHT_ALIGN))
675 {
676 MoveTo(pLb->hdr.left + GOL_EMBOSS_SIZE + LB_INDENT, GetY());
677 }
678 else
679 {
680 temp = GetTextWidth(pCurItem->pText, pLb->hdr.pGolScheme->pFont);
681 if(pCurItem->pBitmap != NULL)
682 {
683 temp += GetImageWidth(pCurItem->pBitmap) + LB_INDENT;
684 }
685  
686 if(GetState(pLb, LB_RIGHT_ALIGN))
687 {
688 MoveTo(pLb->hdr.right - temp - LB_INDENT - GOL_EMBOSS_SIZE, GetY());
689 }
690 else
691 {
692 MoveTo((pLb->hdr.left + pLb->hdr.right - temp) >> 1, GetY());
693 }
694 }
695  
696 if(GetState(pLb, LB_DISABLED))
697 {
698 SetColor(pLb->hdr.pGolScheme->TextColorDisabled);
699 }
700 else
701 {
702 if(pCurItem->status & LB_STS_SELECTED)
703 {
704 SetColor(pLb->hdr.pGolScheme->TextColor1);
705 }
706 else
707 {
708 SetColor(pLb->hdr.pGolScheme->TextColor0);
709 }
710 }
711  
712 state = LB_STATE_BITMAP;
713  
714 case LB_STATE_BITMAP:
715 if(pCurItem->pBitmap != NULL)
716 {
717 if
718 (
719 !PutImage
720 (
721 GetX(),
722 GetY() + ((pLb->textHeight - GetImageHeight(pCurItem->pBitmap)) >> 1),
723 pCurItem->pBitmap,
724 1
725 )
726 ) return (0);
727  
728 MoveRel(GetImageWidth(pCurItem->pBitmap) + LB_INDENT, 0);
729 }
730  
731 state = LB_STATE_TEXT;
732  
733 case LB_STATE_TEXT:
734 if(!OutText(pCurItem->pText))
735 return (0);
736 }
737  
738 /////////////////////////////////////////////////////////////////////
739 L_LB_NEXTITEM:
740 state = LB_STATE_ITEMFOCUS;
741  
742 case LB_STATE_ITEMFOCUS:
743 if(pLb->pFocusItem == pCurItem)
744 {
745 if(IsDeviceBusy())
746 return (0);
747  
748 if(GetState(pLb, LB_FOCUSED))
749 {
750 SetColor(pLb->hdr.pGolScheme->TextColor1);
751 }
752 else
753 {
754 SetColor(pLb->hdr.pGolScheme->TextColor0);
755 }
756  
757 SetLineType(FOCUS_LINE);
758 temp = GetY();
759 if
760 (
761 !Rectangle
762 (
763 pLb->hdr.left + GOL_EMBOSS_SIZE + LB_INDENT,
764 GetY(),
765 pLb->hdr.right - GOL_EMBOSS_SIZE - LB_INDENT,
766 GetY() + pLb->textHeight - 1
767 )
768 ) return (0);
769 MoveTo(0, temp);
770 SetLineType(SOLID_LINE);
771  
772 // Scroll if needed
773 if(GetY() < (pLb->hdr.top + GOL_EMBOSS_SIZE + LB_INDENT))
774 {
775 pLb->scrollY += (pLb->hdr.top + GOL_EMBOSS_SIZE + LB_INDENT) - GetY();
776 SetState(pLb, LB_DRAW);
777 goto L_LB_DRAW;
778 }
779  
780 if((GetY() + pLb->textHeight) > (pLb->hdr.bottom - GOL_EMBOSS_SIZE - LB_INDENT))
781 {
782 pLb->scrollY += pLb->hdr.bottom - GetY() - pLb->textHeight - GOL_EMBOSS_SIZE - LB_INDENT;
783 SetState(pLb, LB_DRAW);
784 goto L_LB_DRAW;
785 }
786 }
787  
788 pCurItem = (LISTITEM *)pCurItem->pNextItem;
789 MoveRel(0, pLb->textHeight);
790  
791 goto L_LB_DRAWITEM;
792 } // end of switch
793  
794 return (1);
795 }
796  
797 #endif // USE_LISTBOX
{BLAME END}
{FOOTER START}

Powered by WebSVN v2.8.3