rockbox/apps/plugins/lib/printcell_helper.h
William Wilgus a7703e4926 gui lists add callback for owner drawn items
allow the guts of gui_sync_list to be used with owner drawn items

WIP

printcell_helper--

goal: allow data to be displayed in a spreadsheet format  with an easy to use interface

printcell_set_columns(gui_synclist, title, icon)
 sets title and calculates cell widths
 each column is identified by '$' character
 ex 3 columns title = "Col1$Col2$Col3"
also accepts $*WIDTH$
 ex 3 columns varying width title = "$*64$Col1$*128$Col2$Col3
printcell_enable(gui_synclist, enable)
 sets the printcell function enabled

After setting the columns and enabling the printcell function
 items can be added to the list like normal
 column items are supplied delimited by '$'
 ex item = "Item1$item2$item3"
 they will be placed in cells defined by set_columns and scroll if the cell is too small

--Fixed for 1 bit & 2 bit displays

Change-Id: I49bd7903005d7a54e93af4379b0cdea63c860656
2022-01-01 23:56:51 -05:00

45 lines
2 KiB
C

/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2021 William Wilgus
*
* 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.
*
****************************************************************************/
#ifndef _PRINTCELL_LIST_H_
#define _PRINTCELL_LIST_H_
#define PRINTCELL_MAXLINELEN MAX_PATH
/* sets the printcell function enabled */
void printcell_enable(struct gui_synclist *gui_list, bool enable, bool separator);
/* sets title and calculates cell widths each column is identified by '$' character
ex 3 columns title = "Col1$Col2$Col3" also accepts $*WIDTH$
ex 3 columns varying width title = "$*64$Col1$*128$Col2$Col3
returns number of columns
*/
int printcell_set_columns(struct gui_synclist *gui_list,
char * title, enum themable_icons icon);
/* increments the current selected column negative increment is allowed
returns the selected column
range: -1(no selection) to ncols - 1 */
int printcell_increment_column(struct gui_synclist *gui_list, int increment, bool wrap);
/* return the text of currently selected column buffer should be sized
* for max item len, buf[PRINTCELL_MAXLINELEN] is a safe bet */
char *printcell_get_selected_column_text(struct gui_synclist *gui_list, char *buf, size_t bufsz);
#endif /*_PRINTCELL_LIST_H_*/