* Onda VX747: add browse screen, pitchscreen, context menu, quickscreen, rewind...
[kugel-rb.git] / apps / gui / charcell / list.c
blob285cd3eacda1fd397db8cdb765b5989962989abc
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"
34 #include "list.h"
35 #include "screen_access.h"
36 #include "scrollbar.h"
37 #include "lang.h"
38 #include "sound.h"
39 #include "misc.h"
41 void list_draw(struct screen *display, struct gui_synclist *gui_list)
43 int text_pos;
44 bool draw_icons = (gui_list->callback_get_item_icon != NULL &&
45 global_settings.show_icons);
46 bool draw_cursor;
47 int i;
48 int lines;
49 int start, end;
51 display->set_viewport(NULL);
52 lines = display->getnblines();
54 display->clear_display();
55 start = 0;
56 end = display->getnblines();
57 gui_list->last_displayed_start_item[display->screen_type] =
58 gui_list->start_item[display->screen_type];
60 gui_list->last_displayed_selected_item = gui_list->selected_item;
62 /* Adjust the position of icon, cursor, text for the list */
63 draw_cursor = true;
64 if(draw_icons)
65 text_pos = 2; /* here it's in chars */
66 else
67 text_pos = 1;
69 for (i = start; i < end; i++)
71 unsigned char *s;
72 char entry_buffer[MAX_PATH];
73 unsigned char *entry_name;
74 int current_item = gui_list->start_item[display->screen_type] + i;
76 /* When there are less items to display than the
77 * current available space on the screen, we stop*/
78 if(current_item >= gui_list->nb_items)
79 break;
80 s = gui_list->callback_get_item_name(current_item,
81 gui_list->data,
82 entry_buffer,
83 sizeof(entry_buffer));
84 entry_name = P2STR(s);
87 if(gui_list->show_selection_marker &&
88 current_item >= gui_list->selected_item &&
89 current_item < gui_list->selected_item + gui_list->selected_size)
90 {/* The selected item must be displayed scrolling */
91 display->puts_scroll(text_pos, i, entry_name);
93 if (draw_cursor)
95 screen_put_icon_with_offset(display, 0, i,
96 (draw_scrollbar || SHOW_LIST_TITLE)?
97 SCROLLBAR_WIDTH: 0,
98 0, Icon_Cursor);
101 else
102 {/* normal item */
103 if(gui_list->scroll_all)
105 display->puts_scroll(text_pos, i, entry_name);
107 else
109 display->puts(text_pos, i, entry_name);
112 /* Icons display */
113 if(draw_icons)
115 enum themable_icons icon;
116 icon = gui_list->callback_get_item_icon(current_item,
117 gui_list->data);
118 if(icon > Icon_NOICON)
120 screen_put_icon(display, 1, i, icon);
125 display->update_viewport();
126 display->update();