Linus Nielsen Feltzing | 7da9477 | 2005-10-28 00:00:00 +0000 | [diff] [blame] | 1 | /*************************************************************************** |
| 2 | * __________ __ ___. |
| 3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ |
| 4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / |
| 5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < |
| 6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ |
| 7 | * \/ \/ \/ \/ \/ |
| 8 | * $Id$ |
| 9 | * |
Kevin Ferrare | a3ed62b | 2005-10-30 01:24:35 +0000 | [diff] [blame] | 10 | * Copyright (C) 2005 by Kevin Ferrare |
Linus Nielsen Feltzing | 7da9477 | 2005-10-28 00:00:00 +0000 | [diff] [blame] | 11 | * |
Daniel Stenberg | 2acc0ac | 2008-06-28 18:10:04 +0000 | [diff] [blame] | 12 | * This program is free software; you can redistribute it and/or |
| 13 | * modify it under the terms of the GNU General Public License |
| 14 | * as published by the Free Software Foundation; either version 2 |
| 15 | * of the License, or (at your option) any later version. |
Linus Nielsen Feltzing | 7da9477 | 2005-10-28 00:00:00 +0000 | [diff] [blame] | 16 | * |
| 17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY |
| 18 | * KIND, either express or implied. |
| 19 | * |
| 20 | ****************************************************************************/ |
| 21 | |
| 22 | #ifndef _GUI_LIST_H_ |
| 23 | #define _GUI_LIST_H_ |
| 24 | |
| 25 | #include "config.h" |
| 26 | #include "icon.h" |
| 27 | #include "screen_access.h" |
Jonathan Gordon | 9b6ac01 | 2011-09-06 13:49:41 +0000 | [diff] [blame] | 28 | #include "skin_engine/skin_engine.h" |
Linus Nielsen Feltzing | 7da9477 | 2005-10-28 00:00:00 +0000 | [diff] [blame] | 29 | |
Maurus Cuelenaere | 567d83e | 2009-08-17 22:41:22 +0000 | [diff] [blame] | 30 | #define SCROLLBAR_WIDTH global_settings.scrollbar_width |
Linus Nielsen Feltzing | 7da9477 | 2005-10-28 00:00:00 +0000 | [diff] [blame] | 31 | |
Jonathan Gordon | 6a1161b | 2006-11-06 10:11:51 +0000 | [diff] [blame] | 32 | enum list_wrap { |
| 33 | LIST_WRAP_ON = 0, |
| 34 | LIST_WRAP_OFF, |
| 35 | LIST_WRAP_UNLESS_HELD, |
| 36 | }; |
| 37 | |
Kevin Ferrare | e75cbdd | 2005-10-29 02:33:19 +0000 | [diff] [blame] | 38 | /* |
| 39 | * The gui_list is based on callback functions, if you want the list |
| 40 | * to display something you have to provide it a function that |
| 41 | * tells it what to display. |
Brandon Low | 74cbb0a | 2007-06-17 21:16:34 +0000 | [diff] [blame] | 42 | * There are three callback function : |
| 43 | * one to get the text, one to get the icon and one to get the color |
Kevin Ferrare | 8517ed8 | 2005-11-16 02:12:25 +0000 | [diff] [blame] | 44 | */ |
| 45 | |
| 46 | /* |
| 47 | * Icon callback |
| 48 | * - selected_item : an integer that tells the number of the item to display |
Brandon Low | 74cbb0a | 2007-06-17 21:16:34 +0000 | [diff] [blame] | 49 | * - data : a void pointer to the data you gave to the list when you |
| 50 | * initialized it |
| 51 | * Returns a pointer to the icon, the value inside it is used to display the |
| 52 | * icon after the function returns. |
Kevin Ferrare | 8517ed8 | 2005-11-16 02:12:25 +0000 | [diff] [blame] | 53 | * Note : we use the ICON type because the real type depends of the plateform |
| 54 | */ |
Jonathan Gordon | 6a5cc0b | 2007-04-16 09:14:36 +0000 | [diff] [blame] | 55 | typedef enum themable_icons list_get_icon(int selected_item, void * data); |
Kevin Ferrare | 8517ed8 | 2005-11-16 02:12:25 +0000 | [diff] [blame] | 56 | /* |
Kevin Ferrare | e75cbdd | 2005-10-29 02:33:19 +0000 | [diff] [blame] | 57 | * Text callback |
| 58 | * - selected_item : an integer that tells the number of the item to display |
Brandon Low | 74cbb0a | 2007-06-17 21:16:34 +0000 | [diff] [blame] | 59 | * - data : a void pointer to the data you gave to the list when you |
| 60 | * initialized it |
Kevin Ferrare | e75cbdd | 2005-10-29 02:33:19 +0000 | [diff] [blame] | 61 | * - buffer : a buffer to put the resulting text on it |
| 62 | * (The content of the buffer may not be used by the list, we use |
| 63 | * the return value of the function in all cases to avoid filling |
| 64 | * a buffer when it's not necessary) |
Nils Wallménius | 6848961 | 2008-04-09 15:25:17 +0000 | [diff] [blame] | 65 | * - buffer_len : length of the buffer |
Kevin Ferrare | e75cbdd | 2005-10-29 02:33:19 +0000 | [diff] [blame] | 66 | * Returns a pointer to a string that contains the text to display |
Kevin Ferrare | e75cbdd | 2005-10-29 02:33:19 +0000 | [diff] [blame] | 67 | */ |
Nils Wallménius | 3200d04 | 2009-08-20 16:47:44 +0000 | [diff] [blame] | 68 | typedef const char * list_get_name(int selected_item, void * data, |
| 69 | char * buffer, size_t buffer_len); |
Stéphane Doyon | 8486c04 | 2007-10-21 00:20:10 +0000 | [diff] [blame] | 70 | /* |
| 71 | * Voice callback |
| 72 | * - selected_item : an integer that tells the number of the item to speak |
| 73 | * - data : a void pointer to the data you gave to the list when you |
| 74 | * initialized it |
| 75 | * Returns an integer, 0 means success, ignored really... |
| 76 | */ |
| 77 | typedef int list_speak_item(int selected_item, void * data); |
Brandon Low | 74cbb0a | 2007-06-17 21:16:34 +0000 | [diff] [blame] | 78 | #ifdef HAVE_LCD_COLOR |
| 79 | /* |
| 80 | * Color callback |
| 81 | * - selected_item : an integer that tells the number of the item to display |
| 82 | * - data : a void pointer to the data you gave to the list when you |
| 83 | * initialized it |
| 84 | * Returns an int with the lower 16 bits representing the color to display the |
| 85 | * selected item, negative value for default coloring. |
| 86 | */ |
| 87 | typedef int list_get_color(int selected_item, void * data); |
| 88 | #endif |
Kevin Ferrare | 8517ed8 | 2005-11-16 02:12:25 +0000 | [diff] [blame] | 89 | |
Jonathan Gordon | f5ec3e4 | 2007-12-17 02:37:21 +0000 | [diff] [blame] | 90 | struct gui_synclist |
Linus Nielsen Feltzing | 7da9477 | 2005-10-28 00:00:00 +0000 | [diff] [blame] | 91 | { |
Kevin Ferrare | d452d26 | 2005-10-28 23:52:49 +0000 | [diff] [blame] | 92 | /* defines wether the list should stop when reaching the top/bottom |
| 93 | * or should continue (by going to bottom/top) */ |
| 94 | bool limit_scroll; |
Kevin Ferrare | f77ac7a | 2006-07-02 12:28:27 +0000 | [diff] [blame] | 95 | /* wether the text of the whole items of the list have to be |
| 96 | * scrolled or only for the selected item */ |
| 97 | bool scroll_all; |
Jens Arnold | c05ee02 | 2007-04-12 23:53:17 +0000 | [diff] [blame] | 98 | int nb_items; |
| 99 | int selected_item; |
Jonathan Gordon | f5ec3e4 | 2007-12-17 02:37:21 +0000 | [diff] [blame] | 100 | int start_item[NB_SCREENS]; /* the item that is displayed at the top of the screen */ |
Kevin Ferrare | f77ac7a | 2006-07-02 12:28:27 +0000 | [diff] [blame] | 101 | /* the number of lines that are selected at the same time */ |
| 102 | int selected_size; |
Thomas Martitz | eec89a9 | 2013-12-20 23:34:28 +0100 | [diff] [blame] | 103 | /* the number of pixels each line occupies (including optional padding on touchscreen */ |
| 104 | int line_height[NB_SCREENS]; |
Jens Arnold | c05ee02 | 2007-04-12 23:53:17 +0000 | [diff] [blame] | 105 | #ifdef HAVE_LCD_BITMAP |
Jonathan Gordon | f5ec3e4 | 2007-12-17 02:37:21 +0000 | [diff] [blame] | 106 | int offset_position[NB_SCREENS]; /* the list's screen scroll placement in pixels */ |
Jens Arnold | c05ee02 | 2007-04-12 23:53:17 +0000 | [diff] [blame] | 107 | #endif |
Thomas Martitz | 0acdc87 | 2011-10-07 17:22:49 +0000 | [diff] [blame] | 108 | long scheduled_talk_tick, last_talked_tick, dirty_tick; |
Jens Arnold | c05ee02 | 2007-04-12 23:53:17 +0000 | [diff] [blame] | 109 | |
| 110 | list_get_icon *callback_get_item_icon; |
| 111 | list_get_name *callback_get_item_name; |
Stéphane Doyon | 8486c04 | 2007-10-21 00:20:10 +0000 | [diff] [blame] | 112 | list_speak_item *callback_speak_item; |
Jens Arnold | c05ee02 | 2007-04-12 23:53:17 +0000 | [diff] [blame] | 113 | |
Jens Arnold | c05ee02 | 2007-04-12 23:53:17 +0000 | [diff] [blame] | 114 | /* The data that will be passed to the callback function YOU implement */ |
| 115 | void * data; |
| 116 | /* The optional title, set to NULL for none */ |
Nils Wallménius | 8e33c2f | 2009-10-11 09:40:47 +0000 | [diff] [blame] | 117 | char * title; |
Mark Arigo | 34301bb | 2006-08-23 20:02:06 +0000 | [diff] [blame] | 118 | /* Optional title icon */ |
Jonathan Gordon | 6a5cc0b | 2007-04-16 09:14:36 +0000 | [diff] [blame] | 119 | enum themable_icons title_icon; |
Jonathan Gordon | 3823486 | 2007-06-07 12:14:31 +0000 | [diff] [blame] | 120 | bool show_selection_marker; /* set to true by default */ |
Brandon Low | 74cbb0a | 2007-06-17 21:16:34 +0000 | [diff] [blame] | 121 | |
| 122 | #ifdef HAVE_LCD_COLOR |
| 123 | int title_color; |
| 124 | list_get_color *callback_get_item_color; |
| 125 | #endif |
Jonathan Gordon | 0e5cec2 | 2008-03-05 09:58:30 +0000 | [diff] [blame] | 126 | struct viewport *parent[NB_SCREENS]; |
Linus Nielsen Feltzing | 7da9477 | 2005-10-28 00:00:00 +0000 | [diff] [blame] | 127 | }; |
| 128 | |
Kevin Ferrare | db8415c | 2005-10-30 22:34:51 +0000 | [diff] [blame] | 129 | |
Brandon Low | d3a03b6 | 2006-01-22 04:24:26 +0000 | [diff] [blame] | 130 | #ifdef HAVE_LCD_BITMAP |
Thomas Martitz | 2eb1cb6 | 2009-09-07 17:37:06 +0000 | [diff] [blame] | 131 | extern void list_init(void); |
Brandon Low | d3a03b6 | 2006-01-22 04:24:26 +0000 | [diff] [blame] | 132 | /* parse global setting to static int */ |
| 133 | extern void gui_list_screen_scroll_step(int ofs); |
| 134 | |
| 135 | /* parse global setting to static bool */ |
| 136 | extern void gui_list_screen_scroll_out_of_view(bool enable); |
| 137 | #endif /* HAVE_LCD_BITMAP */ |
Linus Nielsen Feltzing | 7da9477 | 2005-10-28 00:00:00 +0000 | [diff] [blame] | 138 | |
Kevin Ferrare | e75cbdd | 2005-10-29 02:33:19 +0000 | [diff] [blame] | 139 | extern void gui_synclist_init( |
| 140 | struct gui_synclist * lists, |
Kevin Ferrare | 8517ed8 | 2005-11-16 02:12:25 +0000 | [diff] [blame] | 141 | list_get_name callback_get_item_name, |
Kevin Ferrare | f77ac7a | 2006-07-02 12:28:27 +0000 | [diff] [blame] | 142 | void * data, |
| 143 | bool scroll_all, |
Jonathan Gordon | 5ca1539 | 2008-03-26 03:35:24 +0000 | [diff] [blame] | 144 | int selected_size, |
| 145 | struct viewport parent[NB_SCREENS] /* NOTE: new screens should NOT set this to NULL */ |
Kevin Ferrare | e75cbdd | 2005-10-29 02:33:19 +0000 | [diff] [blame] | 146 | ); |
Linus Nielsen Feltzing | 7da9477 | 2005-10-28 00:00:00 +0000 | [diff] [blame] | 147 | extern void gui_synclist_set_nb_items(struct gui_synclist * lists, int nb_items); |
Kevin Ferrare | 15046f9 | 2005-11-16 17:23:49 +0000 | [diff] [blame] | 148 | extern void gui_synclist_set_icon_callback(struct gui_synclist * lists, list_get_icon icon_callback); |
Stéphane Doyon | 8486c04 | 2007-10-21 00:20:10 +0000 | [diff] [blame] | 149 | extern void gui_synclist_set_voice_callback(struct gui_synclist * lists, list_speak_item voice_callback); |
Thomas Martitz | 5c509d1 | 2011-10-22 10:09:23 +0000 | [diff] [blame] | 150 | extern void gui_synclist_set_viewport_defaults(struct viewport *vp, enum screen_type screen); |
Jonathan Gordon | 0e5cec2 | 2008-03-05 09:58:30 +0000 | [diff] [blame] | 151 | #ifdef HAVE_LCD_COLOR |
| 152 | extern void gui_synclist_set_color_callback(struct gui_synclist * lists, list_get_color color_callback); |
| 153 | #endif |
Stéphane Doyon | 8486c04 | 2007-10-21 00:20:10 +0000 | [diff] [blame] | 154 | extern void gui_synclist_speak_item(struct gui_synclist * lists); |
Hristo Kovachev | 38deb8f | 2006-04-03 08:51:08 +0000 | [diff] [blame] | 155 | extern int gui_synclist_get_nb_items(struct gui_synclist * lists); |
Kevin Ferrare | 15046f9 | 2005-11-16 17:23:49 +0000 | [diff] [blame] | 156 | |
Kevin Ferrare | d452d26 | 2005-10-28 23:52:49 +0000 | [diff] [blame] | 157 | extern int gui_synclist_get_sel_pos(struct gui_synclist * lists); |
Kevin Ferrare | e75cbdd | 2005-10-29 02:33:19 +0000 | [diff] [blame] | 158 | |
Linus Nielsen Feltzing | 7da9477 | 2005-10-28 00:00:00 +0000 | [diff] [blame] | 159 | extern void gui_synclist_draw(struct gui_synclist * lists); |
Teruaki Kawashima | 93f9e7c | 2010-02-11 10:41:06 +0000 | [diff] [blame] | 160 | extern void gui_synclist_scroll_stop(struct gui_synclist *lists); |
Linus Nielsen Feltzing | 7da9477 | 2005-10-28 00:00:00 +0000 | [diff] [blame] | 161 | extern void gui_synclist_select_item(struct gui_synclist * lists, |
| 162 | int item_number); |
Linus Nielsen Feltzing | 7da9477 | 2005-10-28 00:00:00 +0000 | [diff] [blame] | 163 | extern void gui_synclist_add_item(struct gui_synclist * lists); |
| 164 | extern void gui_synclist_del_item(struct gui_synclist * lists); |
Kevin Ferrare | d452d26 | 2005-10-28 23:52:49 +0000 | [diff] [blame] | 165 | extern void gui_synclist_limit_scroll(struct gui_synclist * lists, bool scroll); |
Nils Wallménius | 8e33c2f | 2009-10-11 09:40:47 +0000 | [diff] [blame] | 166 | extern void gui_synclist_set_title(struct gui_synclist * lists, char * title, |
Andrew Mahone | 1bc67c8 | 2009-07-11 00:22:26 +0000 | [diff] [blame] | 167 | enum themable_icons icon); |
Jonathan Gordon | 3823486 | 2007-06-07 12:14:31 +0000 | [diff] [blame] | 168 | extern void gui_synclist_hide_selection_marker(struct gui_synclist *lists, |
| 169 | bool hide); |
Solomon Peachy | 4beafe1 | 2019-02-08 19:59:57 -0500 | [diff] [blame^] | 170 | extern bool gui_synclist_item_is_onscreen(struct gui_synclist *lists, |
| 171 | enum screen_type screen, int item); |
Jonathan Gordon | eb2ea7f | 2012-01-12 22:28:36 +1100 | [diff] [blame] | 172 | |
| 173 | #if CONFIG_CODEC == SWCODEC |
| 174 | extern bool gui_synclist_keyclick_callback(int action, void* data); |
| 175 | #endif |
Linus Nielsen Feltzing | 7da9477 | 2005-10-28 00:00:00 +0000 | [diff] [blame] | 176 | /* |
| 177 | * Do the action implied by the given button, |
Jonathan Gordon | cf1cef5 | 2007-09-17 10:08:50 +0000 | [diff] [blame] | 178 | * returns true if the action was handled. |
| 179 | * NOTE: *action may be changed regardless of return value |
Linus Nielsen Feltzing | 7da9477 | 2005-10-28 00:00:00 +0000 | [diff] [blame] | 180 | */ |
Jonathan Gordon | cf1cef5 | 2007-09-17 10:08:50 +0000 | [diff] [blame] | 181 | extern bool gui_synclist_do_button(struct gui_synclist * lists, |
Jonathan Gordon | e385ee1 | 2008-12-31 05:59:26 +0000 | [diff] [blame] | 182 | int *action, |
Jonathan Gordon | 6a1161b | 2006-11-06 10:11:51 +0000 | [diff] [blame] | 183 | enum list_wrap); |
Jonathan Gordon | 9b6ac01 | 2011-09-06 13:49:41 +0000 | [diff] [blame] | 184 | #if defined(HAVE_LCD_BITMAP) && !defined(PLUGIN) |
| 185 | struct listitem_viewport_cfg { |
| 186 | struct wps_data *data; |
Frank Gevaerts | 680c6fc | 2012-02-21 14:33:42 +0100 | [diff] [blame] | 187 | OFFSETTYPE(char *) label; |
Jonathan Gordon | 9b6ac01 | 2011-09-06 13:49:41 +0000 | [diff] [blame] | 188 | int width; |
| 189 | int height; |
| 190 | int xmargin; |
| 191 | int ymargin; |
| 192 | bool tile; |
| 193 | struct skin_viewport selected_item_vp; |
| 194 | }; |
Frank Gevaerts | 7151111 | 2012-06-13 23:07:49 +0200 | [diff] [blame] | 195 | |
| 196 | bool skinlist_get_item(struct screen *display, struct gui_synclist *list, int x, int y, int *item); |
Jonathan Gordon | 9b6ac01 | 2011-09-06 13:49:41 +0000 | [diff] [blame] | 197 | bool skinlist_draw(struct screen *display, struct gui_synclist *list); |
| 198 | bool skinlist_is_selected_item(void); |
| 199 | void skinlist_set_cfg(enum screen_type screen, |
| 200 | struct listitem_viewport_cfg *cfg); |
Jonathan Gordon | 3d0317a | 2011-09-11 10:44:17 +0000 | [diff] [blame] | 201 | const char* skinlist_get_item_text(int offset, bool wrap, char* buf, size_t buf_size); |
Frank Gevaerts | 28d5f2a | 2011-09-18 12:35:32 +0000 | [diff] [blame] | 202 | int skinlist_get_item_number(void); |
Frank Gevaerts | b5cd5ce | 2012-02-25 02:34:23 +0100 | [diff] [blame] | 203 | int skinlist_get_item_row(void); |
| 204 | int skinlist_get_item_column(void); |
Jonathan Gordon | 3d0317a | 2011-09-11 10:44:17 +0000 | [diff] [blame] | 205 | enum themable_icons skinlist_get_item_icon(int offset, bool wrap); |
Jonathan Gordon | 9b6ac01 | 2011-09-06 13:49:41 +0000 | [diff] [blame] | 206 | bool skinlist_needs_scrollbar(enum screen_type screen); |
| 207 | void skinlist_get_scrollbar(int* nb_item, int* first_shown, int* last_shown); |
| 208 | int skinlist_get_line_count(enum screen_type screen, struct gui_synclist *list); |
| 209 | #endif |
Jonathan Gordon | 5eac010 | 2007-10-21 01:27:17 +0000 | [diff] [blame] | 210 | |
Bertrik Sikken | d767883 | 2009-08-06 09:28:25 +0000 | [diff] [blame] | 211 | #if defined(HAVE_TOUCHSCREEN) |
| 212 | /* this needs to be fixed if we ever get more than 1 touchscreen on a target */ |
Thomas Martitz | b673ae2 | 2010-10-31 11:11:46 +0000 | [diff] [blame] | 213 | extern unsigned gui_synclist_do_touchscreen(struct gui_synclist * gui_list); |
| 214 | /* only for private use in gui/list.c */ |
| 215 | extern void _gui_synclist_stop_kinetic_scrolling(void); |
Bertrik Sikken | d767883 | 2009-08-06 09:28:25 +0000 | [diff] [blame] | 216 | #endif |
| 217 | |
Jonathan Gordon | 5eac010 | 2007-10-21 01:27:17 +0000 | [diff] [blame] | 218 | /* If the list has a pending postponed scheduled announcement, that |
| 219 | may become due before the next get_action tmieout. This function |
| 220 | adjusts the get_action timeout appropriately. */ |
| 221 | extern int list_do_action_timeout(struct gui_synclist *lists, int timeout); |
| 222 | /* This one combines a get_action call (with timeout overridden by |
| 223 | list_do_action_timeout) with the gui_synclist_do_button call, for |
| 224 | convenience. */ |
| 225 | extern bool list_do_action(int context, int timeout, |
| 226 | struct gui_synclist *lists, int *action, |
| 227 | enum list_wrap wrap); |
| 228 | |
| 229 | |
Jonathan Gordon | 5f893be | 2007-10-20 12:32:55 +0000 | [diff] [blame] | 230 | /** Simplelist implementation. |
| 231 | USe this if you dont need to reimplement the list code, |
| 232 | and just need to show a list |
| 233 | **/ |
| 234 | |
| 235 | struct simplelist_info { |
| 236 | char *title; /* title to show on the list */ |
| 237 | int count; /* number of items in the list, each item is selection_size high */ |
Bertrik Sikken | 44fa025 | 2010-01-05 21:15:20 +0000 | [diff] [blame] | 238 | int selection_size; /* list selection size, usually 1 */ |
Jonathan Gordon | 5f893be | 2007-10-20 12:32:55 +0000 | [diff] [blame] | 239 | bool hide_selection; |
| 240 | bool scroll_all; |
Jonathan Gordon | 0465101 | 2007-10-21 13:47:43 +0000 | [diff] [blame] | 241 | int timeout; |
Jonathan Gordon | 67df5f2 | 2008-09-25 07:56:34 +0000 | [diff] [blame] | 242 | int selection; /* the item to select when the list is first displayed */ |
| 243 | /* when the list is exited, this will be set to the |
Jonathan Gordon | 2438d78 | 2008-09-25 08:12:25 +0000 | [diff] [blame] | 244 | index of the last item selected, or -1 if the list |
| 245 | was exited with ACTION_STD_CANCEL */ |
Jonathan Gordon | 5f893be | 2007-10-20 12:32:55 +0000 | [diff] [blame] | 246 | int (*action_callback)(int action, struct gui_synclist *lists); /* can be NULL */ |
| 247 | /* action_callback notes: |
| 248 | action == the action pressed by the user |
| 249 | _after_ gui_synclist_do_button returns. |
Jonathan Gordon | 573f220 | 2011-09-03 13:24:56 +0000 | [diff] [blame] | 250 | lists == the lists struct so the callback can get selection and count etc. */ |
| 251 | enum themable_icons title_icon; |
Jonathan Gordon | 5f893be | 2007-10-20 12:32:55 +0000 | [diff] [blame] | 252 | list_get_icon *get_icon; /* can be NULL */ |
| 253 | list_get_name *get_name; /* NULL if you're using simplelist_addline() */ |
Jonathan Gordon | 5eac010 | 2007-10-21 01:27:17 +0000 | [diff] [blame] | 254 | list_speak_item *get_talk; /* can be NULL to not speak */ |
Jonathan Gordon | 573f220 | 2011-09-03 13:24:56 +0000 | [diff] [blame] | 255 | #ifdef HAVE_LCD_COLOR |
| 256 | list_get_color *get_color; |
| 257 | #endif |
Jonathan Gordon | 5f893be | 2007-10-20 12:32:55 +0000 | [diff] [blame] | 258 | void *callback_data; /* data for callbacks */ |
| 259 | }; |
| 260 | |
| 261 | #define SIMPLELIST_MAX_LINES 32 |
Cástor Muñoz | d20185a | 2014-12-09 19:38:47 +0100 | [diff] [blame] | 262 | #ifdef HAVE_ATA_SMART |
| 263 | #define SIMPLELIST_MAX_LINELENGTH 48 |
| 264 | #else |
Jonathan Gordon | 5f893be | 2007-10-20 12:32:55 +0000 | [diff] [blame] | 265 | #define SIMPLELIST_MAX_LINELENGTH 32 |
Cástor Muñoz | d20185a | 2014-12-09 19:38:47 +0100 | [diff] [blame] | 266 | #endif |
Jonathan Gordon | 5f893be | 2007-10-20 12:32:55 +0000 | [diff] [blame] | 267 | |
| 268 | /** The next three functions are used if the text is mostly static. |
| 269 | These should be called in the action callback for the list. |
| 270 | **/ |
| 271 | /* set the amount of lines shown in the list |
| 272 | Only needed if simplelist_info.get_name == NULL */ |
| 273 | void simplelist_set_line_count(int lines); |
| 274 | /* get the current amount of lines shown */ |
| 275 | int simplelist_get_line_count(void); |
Jonathan Gordon | 69228f9 | 2013-02-12 20:35:11 +1100 | [diff] [blame] | 276 | /* add a line in the list. */ |
| 277 | void simplelist_addline(const char *fmt, ...); |
Jonathan Gordon | 5f893be | 2007-10-20 12:32:55 +0000 | [diff] [blame] | 278 | |
Jonathan Gordon | 5eac010 | 2007-10-21 01:27:17 +0000 | [diff] [blame] | 279 | /* setup the info struct. members not setup in this function need to be assigned manually |
| 280 | members set in this function: |
Jonathan Gordon | 616971c | 2007-10-21 06:42:52 +0000 | [diff] [blame] | 281 | info.selection_size = 1; |
Jonathan Gordon | 5eac010 | 2007-10-21 01:27:17 +0000 | [diff] [blame] | 282 | info.hide_selection = false; |
| 283 | info.scroll_all = false; |
| 284 | info.action_callback = NULL; |
Jonathan Gordon | 573f220 | 2011-09-03 13:24:56 +0000 | [diff] [blame] | 285 | info.title_icon = Icon_NOICON; |
Jonathan Gordon | 5eac010 | 2007-10-21 01:27:17 +0000 | [diff] [blame] | 286 | info.get_icon = NULL; |
| 287 | info.get_name = NULL; |
| 288 | info.get_voice = NULL; |
Jonathan Gordon | 573f220 | 2011-09-03 13:24:56 +0000 | [diff] [blame] | 289 | info.get_color = NULL; |
Jonathan Gordon | 0465101 | 2007-10-21 13:47:43 +0000 | [diff] [blame] | 290 | info.timeout = HZ/10; |
Jonathan Gordon | 67df5f2 | 2008-09-25 07:56:34 +0000 | [diff] [blame] | 291 | info.selection = 0; |
Jonathan Gordon | 5eac010 | 2007-10-21 01:27:17 +0000 | [diff] [blame] | 292 | */ |
| 293 | void simplelist_info_init(struct simplelist_info *info, char* title, |
Jonathan Gordon | 616971c | 2007-10-21 06:42:52 +0000 | [diff] [blame] | 294 | int count, void* data); |
Teruaki Kawashima | d50c78c | 2010-02-16 11:59:37 +0000 | [diff] [blame] | 295 | |
Jonathan Gordon | 5f893be | 2007-10-20 12:32:55 +0000 | [diff] [blame] | 296 | /* show a list. |
| 297 | if list->action_callback != NULL it is called with the action ACTION_REDRAW |
| 298 | before the list is dislplayed for the first time */ |
| 299 | bool simplelist_show_list(struct simplelist_info *info); |
Linus Nielsen Feltzing | 7da9477 | 2005-10-28 00:00:00 +0000 | [diff] [blame] | 300 | |
Linus Nielsen Feltzing | 7da9477 | 2005-10-28 00:00:00 +0000 | [diff] [blame] | 301 | #endif /* _GUI_LIST_H_ */ |