2005-10-28 00:00:00 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
* $Id$
|
|
|
|
*
|
2005-10-30 01:24:35 +00:00
|
|
|
* Copyright (C) 2005 by Kevin Ferrare
|
2005-10-28 00:00:00 +00:00
|
|
|
*
|
|
|
|
* All files in this archive are subject to the GNU General Public License.
|
|
|
|
* See the file COPYING in the source tree root for full license agreement.
|
|
|
|
*
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifndef _GUI_LIST_H_
|
|
|
|
#define _GUI_LIST_H_
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
#include "icon.h"
|
|
|
|
#include "screen_access.h"
|
|
|
|
|
|
|
|
#define SCROLLBAR_WIDTH 6
|
|
|
|
|
2006-11-06 10:11:51 +00:00
|
|
|
enum list_wrap {
|
|
|
|
LIST_WRAP_ON = 0,
|
|
|
|
LIST_WRAP_OFF,
|
|
|
|
LIST_WRAP_UNLESS_HELD,
|
|
|
|
};
|
|
|
|
|
2005-10-29 02:33:19 +00:00
|
|
|
/*
|
|
|
|
* The gui_list is based on callback functions, if you want the list
|
|
|
|
* to display something you have to provide it a function that
|
|
|
|
* tells it what to display.
|
2007-06-17 21:16:34 +00:00
|
|
|
* There are three callback function :
|
|
|
|
* one to get the text, one to get the icon and one to get the color
|
2005-11-16 02:12:25 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Icon callback
|
|
|
|
* - selected_item : an integer that tells the number of the item to display
|
2007-06-17 21:16:34 +00:00
|
|
|
* - data : a void pointer to the data you gave to the list when you
|
|
|
|
* initialized it
|
|
|
|
* Returns a pointer to the icon, the value inside it is used to display the
|
|
|
|
* icon after the function returns.
|
2005-11-16 02:12:25 +00:00
|
|
|
* Note : we use the ICON type because the real type depends of the plateform
|
|
|
|
*/
|
2007-04-16 09:14:36 +00:00
|
|
|
typedef enum themable_icons list_get_icon(int selected_item, void * data);
|
2005-11-16 02:12:25 +00:00
|
|
|
/*
|
2005-10-29 02:33:19 +00:00
|
|
|
* Text callback
|
|
|
|
* - selected_item : an integer that tells the number of the item to display
|
2007-06-17 21:16:34 +00:00
|
|
|
* - data : a void pointer to the data you gave to the list when you
|
|
|
|
* initialized it
|
2005-10-29 02:33:19 +00:00
|
|
|
* - buffer : a buffer to put the resulting text on it
|
|
|
|
* (The content of the buffer may not be used by the list, we use
|
|
|
|
* the return value of the function in all cases to avoid filling
|
|
|
|
* a buffer when it's not necessary)
|
|
|
|
* Returns a pointer to a string that contains the text to display
|
|
|
|
*/
|
2007-06-17 21:16:34 +00:00
|
|
|
typedef char * list_get_name(int selected_item, void * data, char * buffer);
|
|
|
|
#ifdef HAVE_LCD_COLOR
|
|
|
|
/*
|
|
|
|
* Color callback
|
|
|
|
* - selected_item : an integer that tells the number of the item to display
|
|
|
|
* - data : a void pointer to the data you gave to the list when you
|
|
|
|
* initialized it
|
|
|
|
* Returns an int with the lower 16 bits representing the color to display the
|
|
|
|
* selected item, negative value for default coloring.
|
|
|
|
*/
|
|
|
|
typedef int list_get_color(int selected_item, void * data);
|
|
|
|
#endif
|
2005-11-16 02:12:25 +00:00
|
|
|
|
2005-10-28 00:00:00 +00:00
|
|
|
struct gui_list
|
|
|
|
{
|
2005-10-28 23:52:49 +00:00
|
|
|
/* defines wether the list should stop when reaching the top/bottom
|
|
|
|
* or should continue (by going to bottom/top) */
|
|
|
|
bool limit_scroll;
|
2006-07-02 12:28:27 +00:00
|
|
|
/* wether the text of the whole items of the list have to be
|
|
|
|
* scrolled or only for the selected item */
|
|
|
|
bool scroll_all;
|
2007-04-12 23:53:17 +00:00
|
|
|
bool cursor_flash_state;
|
|
|
|
|
|
|
|
int nb_items;
|
|
|
|
int selected_item;
|
|
|
|
int start_item; /* the item that is displayed at the top of the screen */
|
2006-07-02 12:28:27 +00:00
|
|
|
/* the number of lines that are selected at the same time */
|
|
|
|
int selected_size;
|
2007-03-11 10:52:36 +00:00
|
|
|
/* These are used to calculate how much of the screen content we need
|
|
|
|
to redraw. */
|
|
|
|
int last_displayed_selected_item;
|
|
|
|
int last_displayed_start_item;
|
2007-04-12 23:53:17 +00:00
|
|
|
#ifdef HAVE_LCD_BITMAP
|
|
|
|
int offset_position; /* the list's screen scroll placement in pixels */
|
|
|
|
#endif
|
2006-08-15 12:23:55 +00:00
|
|
|
/* Cache the width of the title string in pixels/characters */
|
2006-08-23 20:02:06 +00:00
|
|
|
int title_width;
|
2007-04-12 23:53:17 +00:00
|
|
|
|
|
|
|
list_get_icon *callback_get_item_icon;
|
|
|
|
list_get_name *callback_get_item_name;
|
|
|
|
|
|
|
|
struct screen * display;
|
|
|
|
/* The data that will be passed to the callback function YOU implement */
|
|
|
|
void * data;
|
|
|
|
/* The optional title, set to NULL for none */
|
|
|
|
char * title;
|
2006-08-23 20:02:06 +00:00
|
|
|
/* Optional title icon */
|
2007-04-16 09:14:36 +00:00
|
|
|
enum themable_icons title_icon;
|
2007-06-07 12:14:31 +00:00
|
|
|
bool show_selection_marker; /* set to true by default */
|
2007-06-17 21:16:34 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_LCD_COLOR
|
|
|
|
int title_color;
|
|
|
|
list_get_color *callback_get_item_color;
|
|
|
|
#endif
|
2005-10-28 00:00:00 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
2005-10-28 23:52:49 +00:00
|
|
|
* Sets the numbers of items the list can currently display
|
2005-10-28 00:00:00 +00:00
|
|
|
* note that the list's context like the currently pointed item is resetted
|
2005-11-16 17:23:49 +00:00
|
|
|
* - gui_list : the list structure
|
2005-10-28 00:00:00 +00:00
|
|
|
* - nb_items : the numbers of items you want
|
|
|
|
*/
|
2005-10-29 02:33:19 +00:00
|
|
|
#define gui_list_set_nb_items(gui_list, nb) \
|
|
|
|
(gui_list)->nb_items = nb
|
2005-10-28 00:00:00 +00:00
|
|
|
|
2005-10-30 22:34:51 +00:00
|
|
|
/*
|
|
|
|
* Returns the numbers of items currently in the list
|
2005-11-16 17:23:49 +00:00
|
|
|
* - gui_list : the list structure
|
2005-10-30 22:34:51 +00:00
|
|
|
*/
|
|
|
|
#define gui_list_get_nb_items(gui_list) \
|
|
|
|
(gui_list)->nb_items
|
|
|
|
|
2005-11-16 17:23:49 +00:00
|
|
|
/*
|
|
|
|
* Sets the icon callback function
|
|
|
|
* - gui_list : the list structure
|
|
|
|
* - _callback : the callback function
|
|
|
|
*/
|
|
|
|
#define gui_list_set_icon_callback(gui_list, _callback) \
|
|
|
|
(gui_list)->callback_get_item_icon=_callback
|
|
|
|
|
2007-06-17 21:16:34 +00:00
|
|
|
#ifdef HAVE_LCD_COLOR
|
|
|
|
/*
|
|
|
|
* Sets the color callback function
|
|
|
|
* - gui_list : the list structure
|
|
|
|
* - _callback : the callback function
|
|
|
|
*/
|
|
|
|
#define gui_list_set_color_callback(gui_list, _callback) \
|
|
|
|
(gui_list)->callback_get_item_color=_callback
|
|
|
|
#endif
|
|
|
|
|
2005-10-28 00:00:00 +00:00
|
|
|
/*
|
|
|
|
* Gives the position of the selected item
|
|
|
|
* - gui_list : the list structure
|
|
|
|
* Returns the position
|
|
|
|
*/
|
2005-10-29 02:33:19 +00:00
|
|
|
#define gui_list_get_sel_pos(gui_list) \
|
|
|
|
(gui_list)->selected_item
|
2005-10-28 00:00:00 +00:00
|
|
|
|
2005-10-30 22:34:51 +00:00
|
|
|
|
2006-01-22 04:24:26 +00:00
|
|
|
#ifdef HAVE_LCD_BITMAP
|
|
|
|
/* parse global setting to static int */
|
|
|
|
extern void gui_list_screen_scroll_step(int ofs);
|
|
|
|
|
|
|
|
/* parse global setting to static bool */
|
|
|
|
extern void gui_list_screen_scroll_out_of_view(bool enable);
|
|
|
|
#endif /* HAVE_LCD_BITMAP */
|
2005-10-28 23:52:49 +00:00
|
|
|
/*
|
|
|
|
* Tells the list wether it should stop when reaching the top/bottom
|
|
|
|
* or should continue (by going to bottom/top)
|
|
|
|
* - gui_list : the list structure
|
|
|
|
* - scroll :
|
|
|
|
* - true : stops when reaching top/bottom
|
|
|
|
* - false : continues to go to bottom/top when reaching top/bottom
|
|
|
|
*/
|
2005-10-29 02:33:19 +00:00
|
|
|
#define gui_list_limit_scroll(gui_list, scroll) \
|
|
|
|
(gui_list)->limit_scroll=scroll
|
2005-10-28 00:00:00 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* This part handles as many lists as there are connected screens
|
|
|
|
* (the api is similar to the ones above)
|
|
|
|
* The lists on the screens are synchronized ;
|
|
|
|
* theirs items and selected items are the same, but of course,
|
|
|
|
* they can be displayed on screens with different sizes
|
|
|
|
* The final aim is to let the programmer handle many lists in one
|
|
|
|
* function call and make its code independant from the number of screens
|
|
|
|
*/
|
|
|
|
struct gui_synclist
|
|
|
|
{
|
|
|
|
struct gui_list gui_list[NB_SCREENS];
|
|
|
|
};
|
|
|
|
|
2005-10-29 02:33:19 +00:00
|
|
|
extern void gui_synclist_init(
|
|
|
|
struct gui_synclist * lists,
|
2005-11-16 02:12:25 +00:00
|
|
|
list_get_name callback_get_item_name,
|
2006-07-02 12:28:27 +00:00
|
|
|
void * data,
|
|
|
|
bool scroll_all,
|
|
|
|
int selected_size
|
2005-10-29 02:33:19 +00:00
|
|
|
);
|
2005-10-28 00:00:00 +00:00
|
|
|
extern void gui_synclist_set_nb_items(struct gui_synclist * lists, int nb_items);
|
2005-11-16 17:23:49 +00:00
|
|
|
extern void gui_synclist_set_icon_callback(struct gui_synclist * lists, list_get_icon icon_callback);
|
2006-04-03 08:51:08 +00:00
|
|
|
extern int gui_synclist_get_nb_items(struct gui_synclist * lists);
|
2005-11-16 17:23:49 +00:00
|
|
|
|
2005-10-28 23:52:49 +00:00
|
|
|
extern int gui_synclist_get_sel_pos(struct gui_synclist * lists);
|
2005-10-29 02:33:19 +00:00
|
|
|
|
2005-10-28 00:00:00 +00:00
|
|
|
extern void gui_synclist_draw(struct gui_synclist * lists);
|
|
|
|
extern void gui_synclist_select_item(struct gui_synclist * lists,
|
|
|
|
int item_number);
|
|
|
|
extern void gui_synclist_add_item(struct gui_synclist * lists);
|
|
|
|
extern void gui_synclist_del_item(struct gui_synclist * lists);
|
2005-10-28 23:52:49 +00:00
|
|
|
extern void gui_synclist_limit_scroll(struct gui_synclist * lists, bool scroll);
|
2005-11-09 01:17:57 +00:00
|
|
|
extern void gui_synclist_flash(struct gui_synclist * lists);
|
2006-08-23 20:02:06 +00:00
|
|
|
extern void gui_synclist_set_title(struct gui_synclist * lists, char * title,
|
2007-04-16 09:14:36 +00:00
|
|
|
int icon);
|
2007-06-07 12:14:31 +00:00
|
|
|
extern void gui_synclist_hide_selection_marker(struct gui_synclist *lists,
|
|
|
|
bool hide);
|
2005-10-28 00:00:00 +00:00
|
|
|
/*
|
|
|
|
* Do the action implied by the given button,
|
2007-09-17 10:08:50 +00:00
|
|
|
* returns true if the action was handled.
|
|
|
|
* NOTE: *action may be changed regardless of return value
|
2005-10-28 00:00:00 +00:00
|
|
|
*/
|
2007-09-17 10:08:50 +00:00
|
|
|
extern bool gui_synclist_do_button(struct gui_synclist * lists,
|
|
|
|
unsigned *action,
|
2006-11-06 10:11:51 +00:00
|
|
|
enum list_wrap);
|
2005-10-28 00:00:00 +00:00
|
|
|
|
|
|
|
#endif /* _GUI_LIST_H_ */
|