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