18 #define KEY_BUFFER_TIMEOUT 1000 // time to clear buffer in milliseconds
20 #define DEFAULT_LISTBOX_ITEM_LENGTH 128
42 scrollbar.
set_bmaps(b_up_fname, b_down_fname, sb_fname);
65 max_items = _max_items;
67 num_items = _numitems;
68 check_list = _check_list;
69 num_items_displayed = nrows;
81 if (_numitems > nrows) {
82 scrollbar.
create( wnd, _x+_w+3, _y, real_h, 0, _numitems-nrows, 0, nrows );
100 void UI_LISTBOX::draw()
110 if (
bmap_ids[LBOX_DISABLED] >= 0 ) {
138 stop = first_item+num_items_displayed;
139 if (stop>num_items) stop = num_items;
144 for ( i=first_item; i<stop; i++ ) {
150 if (i !=current_item) {
188 if ( check_list[i] ) {
203 ui_rect( x1+w1+2, y1,
w-1, y1+h1-1 );
204 ui_rect( x1, y1, x1+1, y1+h1-1 );
210 if (stop < num_items_displayed-1 && !
uses_bmaps) {
216 void UI_LISTBOX::process(
int focus)
218 int OnMe, mitem, kf = 0;
231 scrollbar.process(0);
241 old_current_item = current_item;
242 old_first_item = first_item;
251 old_current_item = current_item;
252 old_first_item = first_item;
257 if (scrollbar.moved) {
258 first_item = scrollbar.position;
261 if (current_item<first_item)
262 current_item = first_item;
264 if (current_item > first_item + num_items_displayed - 1)
265 current_item = first_item + num_items_displayed - 1;
278 key_buffer_count = 0;
286 selected_item = current_item;
290 toggled_item = current_item;
309 current_item=num_items - 1;
314 current_item -= num_items_displayed;
319 current_item += num_items_displayed;
325 key_buffer_count = 0;
332 if (!key_buffer_count)
335 for (i=0; i<num_items; i++) {
339 for (j=0; j<key_buffer_count; j++)
343 if (j == key_buffer_count) {
353 if (current_item < 0)
356 if (current_item >= num_items)
357 current_item = num_items - 1;
359 if (current_item < first_item)
360 first_item = current_item;
362 if (current_item >= first_item + num_items_displayed)
363 first_item = current_item - num_items_displayed + 1;
365 if (num_items <= num_items_displayed ) {
370 scrollbar.position = first_item;
372 scrollbar.bar_position = scrollbar.position - scrollbar.start;
373 scrollbar.bar_position *= scrollbar.
h - scrollbar.bar_size;
374 scrollbar.bar_position /= scrollbar.stop - scrollbar.start;
376 if (scrollbar.bar_position < 0) {
377 scrollbar.bar_position = 0;
380 if (scrollbar.bar_position > scrollbar.
h - scrollbar.bar_size) {
381 scrollbar.bar_position = scrollbar.
h - scrollbar.bar_size;
406 if ((mitem >= 0) && (mitem<num_items_displayed)) {
407 current_item = mitem + first_item;
410 if (current_item < 0)
413 if (current_item >= num_items)
414 current_item = num_items - 1;
416 if (current_item < first_item)
417 first_item = current_item;
419 if (current_item >= first_item + num_items_displayed)
420 first_item = current_item - num_items_displayed + 1;
422 if (num_items <= num_items_displayed) {
425 }
else if (has_scrollbar) {
426 scrollbar.position = first_item;
428 scrollbar.bar_position = scrollbar.position - scrollbar.start;
429 scrollbar.bar_position *= scrollbar.
h - scrollbar.bar_size;
430 scrollbar.bar_position /= scrollbar.stop - scrollbar.start;
432 if (scrollbar.bar_position < 0) {
433 scrollbar.bar_position = 0;
436 if (scrollbar.bar_position > scrollbar.
h - scrollbar.bar_size) {
437 scrollbar.bar_position = scrollbar.
h - scrollbar.bar_size;
444 toggled_item = current_item;
448 selected_item = current_item;
467 return selected_item;
478 current_item = _index;
485 else if (_index > num_items)
500 for ( idx=0; idx<num_items; idx++ )
509 num_items = _numitems;
516 if (num_items > num_items_displayed)
517 first_item = num_items - num_items_displayed + 1;
522 for (
int i = 0; i < num_items-1; i++)
556 return old_current_item == current_item ? 0 : 1;
void gr_rect(int x, int y, int w, int h, int resize_mode)
void set_first_item(int _index)
#define GR_RESIZE_MENU_NO_OFFSET
GLfloat GLfloat GLfloat GLfloat h
int bmap_ids[MAX_BMAPS_PER_GADGET]
__inline void gr_string(int x, int y, const char *string, int resize_mode=GR_RESIZE_FULL)
void create(UI_WINDOW *wnd, int _x, int _y, int _w, int _h, int _numitem, char **_list, char *_check_list=NULL, int _max_items=-1)
void base_create(UI_WINDOW *wnd, int _kind, int _x, int _y, int _w, int _h)
void gr_set_color_fast(color *dst)
void gr_set_bitmap(int bitmap_num, int alphablend_mode, int bitblt_mode, float alpha)
void create(UI_WINDOW *wnd, int _x, int _y, int _h, int _start, int _stop, int _position, int _window_size)
__inline void gr_set_clip(int x, int y, int w, int h, int resize_mode=GR_RESIZE_FULL)
int set_bmaps(char *ani_filename, int nframes=3, int start_frame=1)
void set_drawframe(int mode)
void set_current(int _index)
void link_hotspot(int up_button_num, int down_button_num)
void ui_draw_sunken_border(int x1, int y1, int x2, int y2)
char * get_string(int _index)
#define B1_DOUBLE_CLICKED
int add_string(char *str)
int shifted_ascii_table[128]
GLint GLint GLint GLint GLint x
int set_bmaps(char *up_button_fname, char *down_button_fname, char *line_fname)
void set_parent(UI_GADGET *_parent)
GLubyte GLubyte GLubyte GLubyte w
#define KEY_BUFFER_TIMEOUT
void gr_get_string_size(int *w, int *h, const char *text, int len=9999)
int set_bmaps(char *lbox_fname, char *b_up_fname, char *b_down_fname, char *sb_fname)
void ui_rect(int x1, int y1, int x2, int y2)
void set_new_list(int _numitems, char **_list)
void gr_bitmap(int _x, int _y, int resize_mode)
#define DEFAULT_LISTBOX_ITEM_LENGTH
GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint GLdouble w1
void gr_set_font(int fontnum)
void link_hotspot(int up_button_num, int down_button_num)
int timer_get_milliseconds()
UI_GADGET * selected_gadget