summaryrefslogtreecommitdiff
path: root/apps/gui/charcell
diff options
context:
space:
mode:
authorJonathan Gordon <rockbox@jdgordon.info>2008-03-05 09:58:30 +0000
committerJonathan Gordon <rockbox@jdgordon.info>2008-03-05 09:58:30 +0000
commit0e5cec2d187dbded9b3c36dbcfd1469d00fe47af (patch)
treeab02e321e04ebfb4fb2e0a5327b5443a10761176 /apps/gui/charcell
parent8232e1a7c8d7cfaa16e3c8283fdb6d5a46aaf577 (diff)
downloadrockbox-0e5cec2d187dbded9b3c36dbcfd1469d00fe47af.tar.gz
rockbox-0e5cec2d187dbded9b3c36dbcfd1469d00fe47af.zip
FS#8457 - convert the list drawing code to use viewports. This does not include any of the customizability which was in the patch, so unless any bugs show up users should not notice any difference.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@16527 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/gui/charcell')
-rw-r--r--apps/gui/charcell/list.c129
1 files changed, 129 insertions, 0 deletions
diff --git a/apps/gui/charcell/list.c b/apps/gui/charcell/list.c
new file mode 100644
index 0000000000..3d699e84dd
--- /dev/null
+++ b/apps/gui/charcell/list.c
@@ -0,0 +1,129 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2007 by Jonathan Gordon
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19
20/* This file contains the code to draw the list widget on BITMAP LCDs. */
21
22#include "config.h"
23#include "lcd.h"
24#include "font.h"
25#include "button.h"
26#include "sprintf.h"
27#include "string.h"
28#include "settings.h"
29#include "kernel.h"
30#include "system.h"
31
32#include "list.h"
33#include "screen_access.h"
34#include "scrollbar.h"
35#include "statusbar.h"
36#include "textarea.h"
37#include "lang.h"
38#include "sound.h"
39#include "misc.h"
40#include "talk.h"
41
42void list_draw(struct screen *display, struct viewport *parent,
43 struct gui_synclist *gui_list)
44{
45 (void)parent;
46 int text_pos;
47 bool draw_icons = (gui_list->callback_get_item_icon != NULL &&
48 global_settings.show_icons);
49 bool draw_cursor;
50 int i;
51 int lines;
52 int start, end;
53
54 display->set_viewport(NULL);
55 lines = display->nb_lines;
56
57 gui_textarea_clear(display);
58 start = 0;
59 end = display->nb_lines;
60 gui_list->last_displayed_start_item[display->screen_type] =
61 gui_list->start_item[display->screen_type];
62
63 gui_list->last_displayed_selected_item = gui_list->selected_item;
64
65 /* Adjust the position of icon, cursor, text for the list */
66 draw_cursor = true;
67 if(draw_icons)
68 text_pos = 2; /* here it's in chars */
69 else
70 text_pos = 1;
71
72 for (i = start; i < end; i++)
73 {
74 unsigned char *s;
75 char entry_buffer[MAX_PATH];
76 unsigned char *entry_name;
77 int current_item = gui_list->start_item[display->screen_type] + i;
78
79 /* When there are less items to display than the
80 * current available space on the screen, we stop*/
81 if(current_item >= gui_list->nb_items)
82 break;
83 s = gui_list->callback_get_item_name(current_item,
84 gui_list->data,
85 entry_buffer);
86 entry_name = P2STR(s);
87
88
89 if(gui_list->show_selection_marker &&
90 current_item >= gui_list->selected_item &&
91 current_item < gui_list->selected_item + gui_list->selected_size)
92 {/* The selected item must be displayed scrolling */
93 display->puts_scroll(text_pos, i, entry_name);
94
95 if (draw_cursor)
96 {
97 screen_put_icon_with_offset(display, 0, i,
98 (draw_scrollbar || SHOW_LIST_TITLE)?
99 SCROLLBAR_WIDTH: 0,
100 0, Icon_Cursor);
101 }
102 }
103 else
104 {/* normal item */
105 if(gui_list->scroll_all)
106 {
107 display->puts_scroll(text_pos, i, entry_name);
108 }
109 else
110 {
111 display->puts(text_pos, i, entry_name);
112 }
113 }
114 /* Icons display */
115 if(draw_icons)
116 {
117 enum themable_icons icon;
118 icon = gui_list->callback_get_item_icon(current_item,
119 gui_list->data);
120 if(icon > Icon_NOICON)
121 {
122 screen_put_icon(display, 1, i, icon);
123 }
124 }
125 }
126
127 display->update_viewport();
128 gui_textarea_update(display);
129}