-
Notifications
You must be signed in to change notification settings - Fork 1
/
ui_list_box.tbs
586 lines (534 loc) · 20.1 KB
/
ui_list_box.tbs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
'*********************************************************************************
' ON SCREEN LIST BOX CONTROL
'
' List Box module is used to create a pop up option window. User can go through
' the list and select certain item in the list. Since the key config and layout
' is differ in each device, the printing and operating of the keys are defined in
' the external device specific functions. User can use device_list_box_pre() to
' prepare the list box including printing of button, and use device_lb_key_proc()
' to process the key.
' This list is defined by 'listbox_data'. The format of the 'listbox_data' is as
' below:
'
' value1-description1;value2-description2;value3-description3;
'
' and so on. The list will be seen as below:
' ------------------
' |-> description1 |
' | description2 |
' | description3 |
' ------------------
'
' When a list item is selected the correspond item value will be returned.
'
'*********************************************************************************
include "global.tbh"
declare sub ui_listbox_string_parse(index as byte, byref listbox_display_string as string)
declare sub ui_listbox_display(listbox_display_string as string, disable as no_yes)
declare sub ui_listbox_cursor_display(disable as no_yes)
declare sub ui_listbox_up(listbox_display_string as string)
declare sub ui_listbox_down(listbox_display_string as string)
declare sub ui_listbox_print_val
declare sub ui_listbox_scroll(refresh as no_yes, disable as no_yes)
declare sub ui_list_box_timer_proc
declare sub ui_list_box_key_proc(key_event as pl_kp_event_codes, key_code as byte)
declare sub ui_list_process_esc_seq(byref s as string)
dim ui_listbox_string as string
dim listbox_item_val as string(10)
dim lb_timeout_ctr, lb_timeout as byte
dim listbox_pos_x, listbox_pos_y, listbox_height, listbox_width as word
dim listbox_item_spacing, listbox_display_max, listbox_display_index, listbox_item_index, listbox_start_index, listbox_item_count as byte
dim list_box_result as ui_list_box_results
dim font_height as byte
dim lb_interrupt_flag as no_yes
#if LIST_BOX_CURSOR_STYLE > 0
dim previous_listbox_index as byte
#endif
'=============================================================
public function ui_list_box(
x_coord as word, 'x coordination
y_coord as word, 'y coordination
list_width as word, 'list box width
list_height as word, 'list box height
byref listbox_data as string, 'values and display strings of all list box items
byref listbox_value as string(10), 'the value of selected list box item
byref disable_print as no_yes,
timeout as byte 'if no respond from the keypad within the time defined by "timeout", exit the list box and return to the previous screen. If timeout=0, no time out applies
) as ui_list_box_results
dim i,b, pos1, pos2 as byte
dim option as string(10)
dim kp_event as pl_kp_event_codes
dim kp_code as byte
dim t as word
dim listbox_display_string as string(DISPLAY_STR_LEN)
listbox_pos_x=x_coord
listbox_pos_y=y_coord
listbox_item_val=listbox_value
ui_listbox_string=""
listbox_height=list_height
listbox_width=list_width
font_height=lcd.fontheight
listbox_item_spacing=font_height + ULB_VER_SPACING
listbox_display_max=(list_height-2)/listbox_item_spacing
lb_timeout_ctr=timeout
lb_timeout=timeout
listbox_item_count=1
if right(listbox_data,1)=";" then listbox_data=left(listbox_data,len(listbox_data)-1)
ui_listbox_string=listbox_data
'Extract list item value from listbox_data, and if it is equal to the listbox_value,
'set list_item_index to point to that item.
if listbox_value="" then
listbox_item_index=0
else
for i=0 to len(ui_listbox_string) - 1
b=b + 1
if i=0 then
option=left(listbox_data,instr(1,listbox_data,"-",1)-1)
b=0
else
pos1=instr(i+1,ui_listbox_string,";",1)+1
pos2=instr(pos1,listbox_data,"-",1)
option=mid(listbox_data,pos1,pos2-pos1)
i=pos1
if pos1=1 or pos2=0 then
lcd_print_msg(SYS_ERROR_REBOOT,x_coord,y_coord,list_width,list_height,PL_LCD_TEXT_ALIGNMENT_MIDDLE_CENTER,yes)
goto err
end if
end if
if listbox_value=option then
listbox_item_index=b
exit for
end if
next i
end if
if listbox_item_index < listbox_display_max then
listbox_start_index=0
listbox_display_index=listbox_item_index
else
listbox_start_index=listbox_item_index - listbox_display_max + 1
listbox_display_index=listbox_display_max-1
end if
for i=0 to len(ui_listbox_string)-1
i=instr(i+1,ui_listbox_string,";",1)
if i > 0 then
i=i - 1
listbox_item_count=listbox_item_count + 1
ui_listbox_string=left(ui_listbox_string,i) + "`" + right(listbox_data,len(ui_listbox_string)-i-1)
else
exit for
end if
next i
ui_listbox_string_parse(listbox_start_index,listbox_display_string)
ui_list_process_esc_seq(listbox_display_string)
LCD_LOCK
lcd_clear(listbox_pos_x-SCROLL_BORDER/2,listbox_pos_y-SCROLL_BORDER/2,listbox_width+SCROLL_BORDER,listbox_height+SCROLL_BORDER)
ui_listbox_display(listbox_display_string,NO)
ui_listbox_scroll(YES,NO)
ui_listbox_cursor_display(NO)
lcd.rectangle(listbox_pos_x-SCROLL_BORDER/2,listbox_pos_y ,listbox_pos_x+listbox_width,listbox_pos_y+listbox_height)
device_list_box_pre(x_coord,y_coord,list_width,list_height,listbox_data,listbox_value,timeout)
LCD_UNLOCK
if kp.enabled=NO or kp.genkpevent<>NO then
kp.enabled=NO
kp.genkpevent=NO
kp.enabled=YES
else
kp.clearbuffer
end if
err:
list_box_result=LIST_BOX_RESULT_TIMEOUT
wait:
device_lb_interrupt() 'allow user to executes other procedures while inside the list box
if kp.enabled=NO then kp.enabled=YES
if kp.getkey(kp_event,kp_code)=OK then
if kp_event=PL_KP_EVENT_LOCKEDUP then
reset_keypad()
goto wait
end if
ui_list_box_key_proc(kp_event,kp_code)
end if
if list_box_result<>LIST_BOX_RESULT_TIMEOUT then
ui_list_box=list_box_result
goto key_pressed
end if
if t<>sys.timercount then
t=sys.timercount
ui_list_box_timer_proc()
end if
if timeout=0 then
goto wait
else
if lb_timeout_ctr=0 then 'list box timeout
ui_list_box=LIST_BOX_RESULT_TIMEOUT
key_pressed:
if list_box_result=LIST_BOX_RESULT_OK then
ui_list_process_esc_seq(listbox_item_val)
ui_listbox_print_val()
listbox_value=listbox_item_val
else
listbox_value=""
end if
device_list_box_post(x_coord,y_coord,list_width,list_height,listbox_data,listbox_value,disable_print,timeout)
if disable_print=NO then
lcd_clear(x_coord-SCROLL_BORDER,y_coord-SCROLL_BORDER,list_width+SCROLL_BORDER*2,list_height+SCROLL_BORDER*2)
else
ui_listbox_display(listbox_display_string,YES)
ui_listbox_scroll(YES,YES)
ui_listbox_cursor_display(YES)
lcd.rectangle(listbox_pos_x-SCROLL_BORDER/2,listbox_pos_y ,listbox_pos_x+listbox_width,listbox_pos_y+listbox_height)
end if
exit function
end if
goto wait
end if
end function
'=============================================================
public function ui_list_box_ext(
x_coord as word, 'x coordination
y_coord as word, 'y coordination
list_width as word, 'list box width
list_height as word, 'list box height
byref listbox_data as string, 'values and display strings of all list box items
byref listbox_value as string(10), 'the value of selected list box item
byref disable_print as no_yes,
timeout as byte 'if no respond from the keypad within the time defined by "timeout", exit the list box and return to the previous screen. If timeout=0, no time out applies
) as ui_list_box_results
dim i,b, pos1, pos2 as byte
dim option as string(10)
dim kp_event as pl_kp_event_codes
dim kp_code as byte
dim t as word
dim listbox_display_string as string(DISPLAY_STR_LEN)
listbox_pos_x=x_coord
listbox_pos_y=y_coord
listbox_item_val=listbox_value
ui_listbox_string=""
listbox_height=list_height
listbox_width=list_width
font_height=lcd.fontheight
listbox_item_spacing=font_height + ULB_VER_SPACING
listbox_display_max=(list_height-2)/listbox_item_spacing
lb_timeout_ctr=timeout
lb_timeout=timeout
listbox_item_count=1
lb_interrupt_flag=NO
if right(listbox_data,1)=";" then listbox_data=left(listbox_data,len(listbox_data)-1)
ui_listbox_string=listbox_data
'Extract list item value from listbox_data, and if it is equal to the listbox_value,
'set list_item_index to point to that item.
if listbox_value="" then
listbox_item_index=0
else
for i=0 to len(ui_listbox_string) - 1
b=b + 1
if i=0 then
option=left(listbox_data,instr(1,listbox_data,"-",1)-1)
b=0
else
pos1=instr(i+1,ui_listbox_string,";",1)+1
pos2=instr(pos1,listbox_data,"-",1)
option=mid(listbox_data,pos1,pos2-pos1)
i=pos1
if pos1=1 or pos2=0 then
lcd_print_msg(SYS_ERROR_REBOOT,x_coord,y_coord,list_width,list_height,PL_LCD_TEXT_ALIGNMENT_MIDDLE_CENTER,yes)
goto err
end if
end if
if listbox_value=option then
listbox_item_index=b
exit for
end if
next i
end if
if listbox_item_index < listbox_display_max then
listbox_start_index=0
listbox_display_index=listbox_item_index
else
listbox_start_index=listbox_item_index - listbox_display_max + 1
listbox_display_index=listbox_display_max-1
end if
for i=0 to len(ui_listbox_string)-1
i=instr(i+1,ui_listbox_string,";",1)
if i > 0 then
i=i - 1
listbox_item_count=listbox_item_count + 1
ui_listbox_string=left(ui_listbox_string,i) + "`" + right(listbox_data,len(ui_listbox_string)-i-1)
else
exit for
end if
next i
ui_listbox_string_parse(listbox_start_index,listbox_display_string)
ui_list_process_esc_seq(listbox_display_string)
LCD_LOCK
lcd_clear(listbox_pos_x-SCROLL_BORDER/2,listbox_pos_y-SCROLL_BORDER/2,listbox_width+SCROLL_BORDER,listbox_height+SCROLL_BORDER)
ui_listbox_display(listbox_display_string,NO)
ui_listbox_scroll(YES,NO)
ui_listbox_cursor_display(NO)
lcd.rectangle(listbox_pos_x-SCROLL_BORDER/2,listbox_pos_y ,listbox_pos_x+listbox_width,listbox_pos_y+listbox_height)
device_list_box_pre(x_coord,y_coord,list_width,list_height,listbox_data,listbox_value,timeout)
LCD_UNLOCK
if kp.enabled=NO or kp.genkpevent<>NO then
kp.enabled=NO
kp.genkpevent=NO
kp.enabled=YES
else
kp.clearbuffer
end if
err:
list_box_result=LIST_BOX_RESULT_TIMEOUT
wait:
doevents
device_lb_interrupt() 'allow user to executes other procedures while inside the list box
if lb_interrupt_flag=YES then
goto timeout_exit
end if
if kp.enabled=NO then kp.enabled=YES
if kp.getkey(kp_event,kp_code)=OK then
if kp_event=PL_KP_EVENT_LOCKEDUP then
reset_keypad()
goto wait
end if
end if
if list_box_result<>LIST_BOX_RESULT_TIMEOUT then
ui_list_box_ext=list_box_result
goto key_pressed
end if
if t<>sys.timercount then
t=sys.timercount
ui_list_box_timer_proc()
end if
if timeout=0 then
goto wait
else
if lb_timeout_ctr=0 then 'list box timeout
timeout_exit:
ui_list_box_ext=LIST_BOX_RESULT_TIMEOUT
key_pressed:
if list_box_result=LIST_BOX_RESULT_OK then
ui_list_process_esc_seq(listbox_item_val)
ui_listbox_print_val()
listbox_value=listbox_item_val
else
listbox_value=""
end if
device_list_box_post(x_coord,y_coord,list_width,list_height,listbox_data,listbox_value,disable_print,timeout)
if disable_print=NO then
lcd_clear(x_coord-SCROLL_BORDER,y_coord-SCROLL_BORDER,list_width+SCROLL_BORDER*2,list_height+SCROLL_BORDER*2)
else
ui_listbox_display(listbox_display_string,YES)
ui_listbox_scroll(YES,YES)
ui_listbox_cursor_display(YES)
lcd.rectangle(listbox_pos_x-SCROLL_BORDER/2,listbox_pos_y ,listbox_pos_x+listbox_width,listbox_pos_y+listbox_height)
end if
exit function
end if
goto wait
end if
end function
'=============================================================
sub ui_list_box_key_proc(key_event as pl_kp_event_codes, key_code as byte)
'The keypad process for the list box module, 4 keys are used in this module, moving
'the cursor up and down in the list box, select, and cancel.
dim key_action as list_box_key_action
device_lb_key_proc(key_event,key_code,key_action)
lb_timeout_ctr=lb_timeout
select case key_action
case LIST_BOX_CURSOR_UP:
ui_listbox_up(ui_listbox_string)
ui_listbox_cursor_display(NO)
case LIST_BOX_CURSOR_DOWN:
ui_listbox_down(ui_listbox_string)
ui_listbox_cursor_display(NO)
case LIST_BOX_CONFIRM:
list_box_result=LIST_BOX_RESULT_OK
case LIST_BOX_CANCEL:
list_box_result=LIST_BOX_RESULT_CANCEL
end select
end sub
'=============================================================
sub ui_listbox_cursor_display(disable as no_yes)
'Displays the cursor in the list box. The position of the cursor is refered to the listbox_display_index.
'Note that the listbox_display_index is the index of the pointed item in the current LCD,
'it's not necessary the really index. The real index is stored in listbox_item_index
dim x, y as byte
if disable=YES then lcd.forecolor=LCD_DISABLE_FORECOLOR
#if LIST_BOX_CURSOR_STYLE=0
romfile.open(SMALL_ICON_FILE)
lcd_clear(listbox_pos_x, listbox_pos_y, SCROLL_CURSOR_WIDTH, listbox_height)
x=listbox_pos_x + 1
y=listbox_pos_y + listbox_display_index * (font_height + ULB_VER_SPACING)+(font_height/2)-3
ui_listbox_scroll(NO,disable)
lcd.bmp(romfile.offset,x,y,19,0,5,8)
#elif LIST_BOX_CURSOR_STYLE=1
x=listbox_pos_x+SCROLL_BORDER/2+SCROLL_CURSOR_WIDTH/2
if listbox_display_index <> previous_listbox_index then
lcd.forecolor=LCD_BACKCOLOR
y=listbox_pos_y+SCROLL_BORDER/2+SCROLL_CURSOR_WIDTH+(previous_listbox_index)*(font_height+ULB_VER_SPACING)-ULB_VER_SPACING/2-3
lcd.rectangle(x,y,x+listbox_width-SCROLL_CURSOR_WIDTH-SCROLL_BAR_WIDTH-SCROLL_BORDER-CURSOR_BAR_LEN_OFFSET,y+font_height+ULB_VER_SPACING)
end if
if disable<>YES then lcd.forecolor=LCD_CURSORCOLOR
y=listbox_pos_y+SCROLL_BORDER/2+SCROLL_CURSOR_WIDTH+listbox_display_index * (font_height + ULB_VER_SPACING)-ULB_VER_SPACING/2-3
lcd.rectangle(x,y,x+listbox_width-SCROLL_CURSOR_WIDTH-SCROLL_BAR_WIDTH-SCROLL_BORDER-CURSOR_BAR_LEN_OFFSET,y+font_height+ULB_VER_SPACING)
lcd.forecolor=LCD_FORECOLOR
ui_listbox_scroll(NO,disable)
#else
#endif
end sub
'=============================================================
sub ui_listbox_string_parse(index as byte, byref listbox_display_string as string)
'Construct the listbox_display_string. This is the string used to display list options in the list box.
dim pos1,pos2,i as byte
dim stemp as string(DISPLAY_STR_LEN)
listbox_display_string=""
if index > 0 then
pos1=instr(1,ui_listbox_string,"`",index)
else
pos1=0
end if
stemp=right(ui_listbox_string,len(ui_listbox_string)- pos1)
pos2=1
for i=0 to listbox_display_max
pos1=instr(pos2,stemp,"-",1)
pos2=instr(pos1,stemp,"`",1)
listbox_display_string=listbox_display_string+mid(stemp,pos1+1,pos2-pos1)
if pos2=0 then exit sub
next i
end sub
'=============================================================
sub ui_listbox_display(listbox_display_string as string, disable as no_yes)
'Print the listbox_display_string on the LCD
lcd.textalignment=PL_LCD_TEXT_ALIGNMENT_TOP_LEFT
romfile.open(LCD_STD_FONT)
lcd.setfont(romfile.offset)
lcd.textverticalspacing=ULB_VER_SPACING
lcd.texthorizontalspacing=ULB_HOR_SPACING
if disable=YES then lcd.forecolor=LCD_DISABLE_FORECOLOR
LCD_LOCK
lcd_clear(listbox_pos_x+SCROLL_BORDER/2, listbox_pos_y+SCROLL_BORDER, listbox_width - SCROLL_CURSOR_WIDTH*2-SCROLL_BORDER, listbox_height-SCROLL_BORDER*2)
lcd.printaligned(listbox_display_string,listbox_pos_x+SCROLL_BORDER/2+SCROLL_CURSOR_WIDTH, listbox_pos_y+SCROLL_BORDER/2+SCROLL_CURSOR_WIDTH,listbox_width-SCROLL_CURSOR_WIDTH*2-SCROLL_BORDER-SCROLL_BAR_WIDTH, listbox_height-SCROLL_CURSOR_WIDTH*2-SCROLL_BORDER)
LCD_UNLOCK
end sub
'=============================================================
sub ui_listbox_print_val()
'get value of the list box item
dim pos1, pos2 as byte
if listbox_item_index=0 then
listbox_item_val=left(ui_listbox_string,instr(1,ui_listbox_string,"-",1)-1)
else
pos1=instr(1,ui_listbox_string,"`",listbox_item_index)
pos2=instr(pos1+1,ui_listbox_string,"-",1)
listbox_item_val=mid(ui_listbox_string,pos1+1,pos2-pos1-1)
end if
end sub
'=============================================================
sub ui_listbox_up(listbox_display_string as string)
'cursor in the list box moving up
dim listbox_prev_start as byte
listbox_prev_start=listbox_start_index
if listbox_item_index > 0 then
listbox_item_index=listbox_item_index - 1
else
exit sub
end if
if listbox_display_index=0 and listbox_start_index > 0 then
listbox_start_index=listbox_start_index - 1
ui_listbox_string_parse(listbox_start_index,listbox_display_string)
ui_listbox_display(listbox_display_string,NO)
else
#if LIST_BOX_CURSOR_STYLE=1
previous_listbox_index=listbox_display_index
#endif
listbox_display_index=listbox_display_index-1
end if
if listbox_prev_start=listbox_start_index then exit sub
if listbox_start_index=listbox_item_count-listbox_display_max-1 or listbox_start_index=0 then
ui_listbox_scroll(YES,NO)
end if
end sub
'=============================================================
sub ui_listbox_down(listbox_display_string as string)
'cursor in the list box moving down
dim listbox_prev_start as byte
listbox_prev_start=listbox_start_index
listbox_item_index=listbox_item_index+1
if listbox_item_index > listbox_item_count-1 then
listbox_item_index=listbox_item_index-1
exit sub
end if
#if LIST_BOX_CURSOR_STYLE=1
previous_listbox_index=listbox_display_index
#endif
listbox_display_index=listbox_display_index+1
if listbox_display_index > listbox_display_max-1 then
listbox_display_index=listbox_display_index-1
listbox_start_index=listbox_item_index-listbox_display_index
ui_listbox_string_parse(listbox_start_index,listbox_display_string)
ui_listbox_display(listbox_display_string,NO)
end if
if listbox_prev_start=listbox_start_index then exit sub
if listbox_start_index=listbox_item_count-listbox_display_max or listbox_start_index=1 then
ui_listbox_scroll(YES,NO)
end if
end sub
'=============================================================
sub ui_listbox_scroll(refresh as no_yes,disable as no_yes)
'move the scroll cursor of the list box, refresh the list box if necessary
dim scroll_cursor as byte
dim x, y, h, h1 as word
x=listbox_pos_x + listbox_width - SCROLL_BAR_WIDTH-SCROLL_BORDER*2
y=listbox_pos_y
h=listbox_height-SCROLL_ARROW_HEIGHT*2-SCROLL_BORDER
h1=(h-13)/ listbox_item_count
if h1 < 2 then h1=2
if listbox_item_count > 0 and listbox_item_count > listbox_item_index then
if listbox_item_index=0 then
scroll_cursor=y+SCROLL_ARROW_HEIGHT+SCROLL_BORDER/2
else
if listbox_item_index=listbox_item_count-1 then
scroll_cursor=y+h+SCROLL_ARROW_HEIGHT+SCROLL_BORDER-h1
else
scroll_cursor=y+SCROLL_ARROW_HEIGHT+SCROLL_BORDER/2-1 + (h-SCROLL_BORDER)*listbox_item_index/(listbox_item_count)
end if
end if
else
exit sub
end if
if disable=YES then lcd.forecolor=LCD_DISABLE_FORECOLOR
lcd.linewidth=SCROLL_BORDER
lcd.filledrectangle(x,y+SCROLL_ARROW_HEIGHT,x+SCROLL_BAR_WIDTH,y+h+SCROLL_ARROW_HEIGHT)
lcd.fill(x+SCROLL_BORDER/2,scroll_cursor,SCROLL_BAR_WIDTH-SCROLL_BORDER+1,h1)
if refresh=NO then exit sub
romfile.open(SMALL_ICON_FILE)
if listbox_start_index=0 then
lcd.bmp(romfile.offset,x+SCROLL_ARROW_X_POS_OFFSET,y+SCROLL_ARROW_Y_POS_OFFSET,39,3,19,10)
else
lcd.bmp(romfile.offset,x+SCROLL_ARROW_X_POS_OFFSET,y+SCROLL_ARROW_Y_POS_OFFSET,1,2,19,11)
end if
if listbox_start_index=listbox_item_count-listbox_display_max or listbox_item_count < listbox_display_max then
lcd.bmp(romfile.offset,x+SCROLL_ARROW_X_POS_OFFSET,y+h+SCROLL_ARROW_Y_POS_OFFSET+SCROLL_ARROW_HEIGHT,39,6,19,11)
else
lcd.bmp(romfile.offset,x+SCROLL_ARROW_X_POS_OFFSET,y+h+SCROLL_ARROW_Y_POS_OFFSET+SCROLL_ARROW_HEIGHT,20,2,19,11)
end if
end sub
'=============================================================
sub ui_list_box_timer_proc()
'count list box time out
if lb_timeout_ctr>0 then
lb_timeout_ctr=lb_timeout_ctr-1
end if
end sub
'=============================================================
sub ui_list_process_esc_seq(byref s as string)
dim pos,x as byte
'process escape sequences
pos=instr(1,s,"\x5Cx",1) 'we are searching for "\x"
while pos>0
x=val("&h"+mid(s,pos+2,2))
s=mid(s,1,pos-1)+chr(x)+mid(s,pos+4,255)
pos=instr(1,s,"\x5C",1)
wend
end sub
'=============================================================
sub ui_list_box_interrupt()
lb_interrupt_flag=YES
end sub