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 */
85 bool cursor_flash_state
;
89 int start_item
; /* the item that is displayed at the top of the screen */
90 /* the number of lines that are selected at the same time */
92 /* These are used to calculate how much of the screen content we need
94 int last_displayed_selected_item
;
95 int last_displayed_start_item
;
96 #ifdef HAVE_LCD_BITMAP
97 int offset_position
; /* the list's screen scroll placement in pixels */
99 /* Cache the width of the title string in pixels/characters */
102 list_get_icon
*callback_get_item_icon
;
103 list_get_name
*callback_get_item_name
;
105 struct screen
* display
;
106 /* The data that will be passed to the callback function YOU implement */
108 /* The optional title, set to NULL for none */
110 /* Optional title icon */
111 enum themable_icons title_icon
;
112 bool show_selection_marker
; /* set to true by default */
114 #ifdef HAVE_LCD_COLOR
116 list_get_color
*callback_get_item_color
;
121 * Sets the numbers of items the list can currently display
122 * note that the list's context like the currently pointed item is resetted
123 * - gui_list : the list structure
124 * - nb_items : the numbers of items you want
126 #define gui_list_set_nb_items(gui_list, nb) \
127 (gui_list)->nb_items = nb
130 * Returns the numbers of items currently in the list
131 * - gui_list : the list structure
133 #define gui_list_get_nb_items(gui_list) \
137 * Sets the icon callback function
138 * - gui_list : the list structure
139 * - _callback : the callback function
141 #define gui_list_set_icon_callback(gui_list, _callback) \
142 (gui_list)->callback_get_item_icon=_callback
144 #ifdef HAVE_LCD_COLOR
146 * Sets the color callback function
147 * - gui_list : the list structure
148 * - _callback : the callback function
150 #define gui_list_set_color_callback(gui_list, _callback) \
151 (gui_list)->callback_get_item_color=_callback
155 * Gives the position of the selected item
156 * - gui_list : the list structure
157 * Returns the position
159 #define gui_list_get_sel_pos(gui_list) \
160 (gui_list)->selected_item
163 #ifdef HAVE_LCD_BITMAP
164 /* parse global setting to static int */
165 extern void gui_list_screen_scroll_step(int ofs
);
167 /* parse global setting to static bool */
168 extern void gui_list_screen_scroll_out_of_view(bool enable
);
169 #endif /* HAVE_LCD_BITMAP */
171 * Tells the list wether it should stop when reaching the top/bottom
172 * or should continue (by going to bottom/top)
173 * - gui_list : the list structure
175 * - true : stops when reaching top/bottom
176 * - false : continues to go to bottom/top when reaching top/bottom
178 #define gui_list_limit_scroll(gui_list, scroll) \
179 (gui_list)->limit_scroll=scroll
182 * This part handles as many lists as there are connected screens
183 * (the api is similar to the ones above)
184 * The lists on the screens are synchronized ;
185 * theirs items and selected items are the same, but of course,
186 * they can be displayed on screens with different sizes
187 * The final aim is to let the programmer handle many lists in one
188 * function call and make its code independant from the number of screens
192 struct gui_list gui_list
[NB_SCREENS
];
195 extern void gui_synclist_init(
196 struct gui_synclist
* lists
,
197 list_get_name callback_get_item_name
,
202 extern void gui_synclist_set_nb_items(struct gui_synclist
* lists
, int nb_items
);
203 extern void gui_synclist_set_icon_callback(struct gui_synclist
* lists
, list_get_icon icon_callback
);
204 extern int gui_synclist_get_nb_items(struct gui_synclist
* lists
);
206 extern int gui_synclist_get_sel_pos(struct gui_synclist
* lists
);
208 extern void gui_synclist_draw(struct gui_synclist
* lists
);
209 extern void gui_synclist_select_item(struct gui_synclist
* lists
,
211 extern void gui_synclist_add_item(struct gui_synclist
* lists
);
212 extern void gui_synclist_del_item(struct gui_synclist
* lists
);
213 extern void gui_synclist_limit_scroll(struct gui_synclist
* lists
, bool scroll
);
214 extern void gui_synclist_flash(struct gui_synclist
* lists
);
215 extern void gui_synclist_set_title(struct gui_synclist
* lists
, char * title
,
217 extern void gui_synclist_hide_selection_marker(struct gui_synclist
*lists
,
220 * Do the action implied by the given button,
221 * returns true if the action was handled.
222 * NOTE: *action may be changed regardless of return value
224 extern bool gui_synclist_do_button(struct gui_synclist
* lists
,
228 #endif /* _GUI_LIST_H_ */