add Packard Bell Vibe 500 to RBUtil.
[kugel-rb.git] / apps / gui / charcell / list.c
blobf36d3c9f7dcc5f438117124155b069d3071600d9
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2007 by Jonathan Gordon
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
22 /* This file contains the code to draw the list widget on BITMAP LCDs. */
24 #include "config.h"
25 #include "lcd.h"
26 #include "font.h"
27 #include "button.h"
28 #include "sprintf.h"
29 #include "string.h"
30 #include "settings.h"
31 #include "kernel.h"
32 #include "system.h"
33 #include "file.h"
35 #include "list.h"
36 #include "screen_access.h"
37 #include "scrollbar.h"
38 #include "lang.h"
39 #include "sound.h"
40 #include "misc.h"
42 void gui_synclist_scroll_stop(struct gui_synclist *lists)
44 int i;
45 (void)lists;
46 FOR_NB_SCREENS(i)
48 screens[i].stop_scroll();
52 void list_draw(struct screen *display, struct gui_synclist *gui_list)
54 int text_pos;
55 bool draw_icons = (gui_list->callback_get_item_icon != NULL &&
56 global_settings.show_icons);
57 bool draw_cursor;
58 int i;
59 int lines;
60 int start, end;
62 display->set_viewport(NULL);
63 lines = display->getnblines();
65 display->clear_display();
66 start = 0;
67 end = display->getnblines();
69 /* Adjust the position of icon, cursor, text for the list */
70 draw_cursor = true;
71 if(draw_icons)
72 text_pos = 2; /* here it's in chars */
73 else
74 text_pos = 1;
76 for (i = start; i < end; i++)
78 unsigned const char *s;
79 char entry_buffer[MAX_PATH];
80 unsigned char *entry_name;
81 int current_item = gui_list->start_item[display->screen_type] + i;
83 /* When there are less items to display than the
84 * current available space on the screen, we stop*/
85 if(current_item >= gui_list->nb_items)
86 break;
87 s = gui_list->callback_get_item_name(current_item,
88 gui_list->data,
89 entry_buffer,
90 sizeof(entry_buffer));
91 entry_name = P2STR(s);
94 if(gui_list->show_selection_marker &&
95 current_item >= gui_list->selected_item &&
96 current_item < gui_list->selected_item + gui_list->selected_size)
97 {/* The selected item must be displayed scrolling */
98 display->puts_scroll(text_pos, i, entry_name);
100 if (draw_cursor)
102 screen_put_icon_with_offset(display, 0, i,
103 (draw_scrollbar || SHOW_LIST_TITLE)?
104 SCROLLBAR_WIDTH: 0,
105 0, Icon_Cursor);
108 else
109 {/* normal item */
110 if(gui_list->scroll_all)
112 display->puts_scroll(text_pos, i, entry_name);
114 else
116 display->puts(text_pos, i, entry_name);
119 /* Icons display */
120 if(draw_icons)
122 enum themable_icons icon;
123 icon = gui_list->callback_get_item_icon(current_item,
124 gui_list->data);
125 if(icon > Icon_NOICON)
127 screen_put_icon(display, 1, i, icon);
132 display->update_viewport();
133 display->update();