Move c/h files implementing/defining standard library stuff into a new libc directory...
[kugel-rb.git] / apps / gui / charcell / list.c
blob8eebfe7fa13b9c5c0299f6021b0b4b6489ea9acf
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 "string.h"
29 #include "settings.h"
30 #include "kernel.h"
31 #include "system.h"
32 #include "file.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 gui_synclist_scroll_stop(struct gui_synclist *lists)
43 int i;
44 (void)lists;
45 FOR_NB_SCREENS(i)
47 screens[i].stop_scroll();
51 void list_draw(struct screen *display, struct gui_synclist *gui_list)
53 int text_pos;
54 bool draw_icons = (gui_list->callback_get_item_icon != NULL &&
55 global_settings.show_icons);
56 bool draw_cursor;
57 int i;
58 int lines;
59 int start, end;
61 display->set_viewport(NULL);
62 lines = display->getnblines();
64 display->clear_display();
65 start = 0;
66 end = display->getnblines();
68 /* Adjust the position of icon, cursor, text for the list */
69 draw_cursor = true;
70 if(draw_icons)
71 text_pos = 2; /* here it's in chars */
72 else
73 text_pos = 1;
75 for (i = start; i < end; i++)
77 unsigned const char *s;
78 char entry_buffer[MAX_PATH];
79 unsigned char *entry_name;
80 int current_item = gui_list->start_item[display->screen_type] + i;
82 /* When there are less items to display than the
83 * current available space on the screen, we stop*/
84 if(current_item >= gui_list->nb_items)
85 break;
86 s = gui_list->callback_get_item_name(current_item,
87 gui_list->data,
88 entry_buffer,
89 sizeof(entry_buffer));
90 entry_name = P2STR(s);
93 if(gui_list->show_selection_marker &&
94 current_item >= gui_list->selected_item &&
95 current_item < gui_list->selected_item + gui_list->selected_size)
96 {/* The selected item must be displayed scrolling */
97 display->puts_scroll(text_pos, i, entry_name);
99 if (draw_cursor)
101 screen_put_icon_with_offset(display, 0, i,
102 (draw_scrollbar || SHOW_LIST_TITLE)?
103 SCROLLBAR_WIDTH: 0,
104 0, Icon_Cursor);
107 else
108 {/* normal item */
109 if(gui_list->scroll_all)
111 display->puts_scroll(text_pos, i, entry_name);
113 else
115 display->puts(text_pos, i, entry_name);
118 /* Icons display */
119 if(draw_icons)
121 enum themable_icons icon;
122 icon = gui_list->callback_get_item_icon(current_item,
123 gui_list->data);
124 if(icon > Icon_NOICON)
126 screen_put_icon(display, 1, i, icon);
131 display->update_viewport();
132 display->update();