1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2005 by Kevin Ferrare
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.
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
18 ****************************************************************************/
25 #include "screen_access.h"
27 #define SCROLLBAR_WIDTH 6
32 LIST_WRAP_UNLESS_HELD
,
36 * The gui_list is based on callback functions, if you want the list
37 * to display something you have to provide it a function that
38 * tells it what to display.
39 * There are three callback function :
40 * one to get the text, one to get the icon and one to get the color
45 * - selected_item : an integer that tells the number of the item to display
46 * - data : a void pointer to the data you gave to the list when you
48 * Returns a pointer to the icon, the value inside it is used to display the
49 * icon after the function returns.
50 * Note : we use the ICON type because the real type depends of the plateform
52 typedef enum themable_icons
list_get_icon(int selected_item
, void * data
);
55 * - selected_item : an integer that tells the number of the item to display
56 * - data : a void pointer to the data you gave to the list when you
58 * - buffer : a buffer to put the resulting text on it
59 * (The content of the buffer may not be used by the list, we use
60 * the return value of the function in all cases to avoid filling
61 * a buffer when it's not necessary)
62 * Returns a pointer to a string that contains the text to display
64 typedef char * list_get_name(int selected_item
, void * data
, char * buffer
);
68 * - selected_item : an integer that tells the number of the item to display
69 * - data : a void pointer to the data you gave to the list when you
71 * Returns an int with the lower 16 bits representing the color to display the
72 * selected item, negative value for default coloring.
74 typedef int list_get_color(int selected_item
, void * data
);
79 /* defines wether the list should stop when reaching the top/bottom
80 * or should continue (by going to bottom/top) */
82 /* wether the text of the whole items of the list have to be
83 * scrolled or only for the selected item */
88 int start_item
; /* the item that is displayed at the top of the screen */
89 /* the number of lines that are selected at the same time */
91 /* These are used to calculate how much of the screen content we need
93 int last_displayed_selected_item
;
94 int last_displayed_start_item
;
95 #ifdef HAVE_LCD_BITMAP
96 int offset_position
; /* the list's screen scroll placement in pixels */
98 /* Cache the width of the title string in pixels/characters */
101 list_get_icon
*callback_get_item_icon
;
102 list_get_name
*callback_get_item_name
;
104 struct screen
* display
;
105 /* The data that will be passed to the callback function YOU implement */
107 /* The optional title, set to NULL for none */
109 /* Optional title icon */
110 enum themable_icons title_icon
;
111 bool show_selection_marker
; /* set to true by default */
113 #ifdef HAVE_LCD_COLOR
115 list_get_color
*callback_get_item_color
;
120 * Sets the numbers of items the list can currently display
121 * note that the list's context like the currently pointed item is resetted
122 * - gui_list : the list structure
123 * - nb_items : the numbers of items you want
125 #define gui_list_set_nb_items(gui_list, nb) \
126 (gui_list)->nb_items = nb
129 * Returns the numbers of items currently in the list
130 * - gui_list : the list structure
132 #define gui_list_get_nb_items(gui_list) \
136 * Sets the icon callback function
137 * - gui_list : the list structure
138 * - _callback : the callback function
140 #define gui_list_set_icon_callback(gui_list, _callback) \
141 (gui_list)->callback_get_item_icon=_callback
143 #ifdef HAVE_LCD_COLOR
145 * Sets the color callback function
146 * - gui_list : the list structure
147 * - _callback : the callback function
149 #define gui_list_set_color_callback(gui_list, _callback) \
150 (gui_list)->callback_get_item_color=_callback
154 * Gives the position of the selected item
155 * - gui_list : the list structure
156 * Returns the position
158 #define gui_list_get_sel_pos(gui_list) \
159 (gui_list)->selected_item
162 #ifdef HAVE_LCD_BITMAP
163 /* parse global setting to static int */
164 extern void gui_list_screen_scroll_step(int ofs
);
166 /* parse global setting to static bool */
167 extern void gui_list_screen_scroll_out_of_view(bool enable
);
168 #endif /* HAVE_LCD_BITMAP */
170 * Tells the list wether it should stop when reaching the top/bottom
171 * or should continue (by going to bottom/top)
172 * - gui_list : the list structure
174 * - true : stops when reaching top/bottom
175 * - false : continues to go to bottom/top when reaching top/bottom
177 #define gui_list_limit_scroll(gui_list, scroll) \
178 (gui_list)->limit_scroll=scroll
181 * This part handles as many lists as there are connected screens
182 * (the api is similar to the ones above)
183 * The lists on the screens are synchronized ;
184 * theirs items and selected items are the same, but of course,
185 * they can be displayed on screens with different sizes
186 * The final aim is to let the programmer handle many lists in one
187 * function call and make its code independant from the number of screens
191 struct gui_list gui_list
[NB_SCREENS
];
194 extern void gui_synclist_init(
195 struct gui_synclist
* lists
,
196 list_get_name callback_get_item_name
,
201 extern void gui_synclist_set_nb_items(struct gui_synclist
* lists
, int nb_items
);
202 extern void gui_synclist_set_icon_callback(struct gui_synclist
* lists
, list_get_icon icon_callback
);
203 extern int gui_synclist_get_nb_items(struct gui_synclist
* lists
);
205 extern int gui_synclist_get_sel_pos(struct gui_synclist
* lists
);
207 extern void gui_synclist_draw(struct gui_synclist
* lists
);
208 extern void gui_synclist_select_item(struct gui_synclist
* lists
,
210 extern void gui_synclist_add_item(struct gui_synclist
* lists
);
211 extern void gui_synclist_del_item(struct gui_synclist
* lists
);
212 extern void gui_synclist_limit_scroll(struct gui_synclist
* lists
, bool scroll
);
213 extern void gui_synclist_flash(struct gui_synclist
* lists
);
214 extern void gui_synclist_set_title(struct gui_synclist
* lists
, char * title
,
216 extern void gui_synclist_hide_selection_marker(struct gui_synclist
*lists
,
219 * Do the action implied by the given button,
220 * returns true if the action was handled.
221 * NOTE: *action may be changed regardless of return value
223 extern bool gui_synclist_do_button(struct gui_synclist
* lists
,
227 #endif /* _GUI_LIST_H_ */