2017-04-15 06:32:05 -04:00
|
|
|
/*
|
|
|
|
* rofi
|
|
|
|
*
|
|
|
|
* MIT/X11 License
|
|
|
|
* Copyright © 2013-2017 Qball Cow <qball@gmpclient.org>
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining
|
|
|
|
* a copy of this software and associated documentation files (the
|
|
|
|
* "Software"), to deal in the Software without restriction, including
|
|
|
|
* without limitation the rights to use, copy, modify, merge, publish,
|
|
|
|
* distribute, sublicense, and/or sell copies of the Software, and to
|
|
|
|
* permit persons to whom the Software is furnished to do so, subject to
|
|
|
|
* the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be
|
|
|
|
* included in all copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
|
|
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
|
|
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
|
|
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
|
|
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
|
|
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2016-10-08 12:57:59 -04:00
|
|
|
#ifndef ROFI_LISTVIEW_H
|
|
|
|
#define ROFI_LISTVIEW_H
|
|
|
|
|
2021-08-17 19:16:45 -04:00
|
|
|
#include "widgets/textbox.h"
|
|
|
|
|
2016-10-08 12:57:59 -04:00
|
|
|
/**
|
|
|
|
* @defgroup listview listview
|
2016-10-13 03:22:08 -04:00
|
|
|
* @ingroup widget
|
2016-10-08 12:57:59 -04:00
|
|
|
*
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
2016-11-15 02:24:06 -05:00
|
|
|
/**
|
|
|
|
* Handle to the listview.
|
|
|
|
* No internal fields should be accessed directly.
|
|
|
|
*/
|
2017-10-21 05:18:52 -04:00
|
|
|
typedef struct _listview listview;
|
2016-10-08 12:57:59 -04:00
|
|
|
|
2016-11-15 02:24:06 -05:00
|
|
|
/**
|
|
|
|
* The scrolling type used in the list view
|
|
|
|
*/
|
2021-08-19 07:34:01 -04:00
|
|
|
typedef enum {
|
|
|
|
/** Flip through the pages. */
|
|
|
|
LISTVIEW_SCROLL_PER_PAGE,
|
|
|
|
/** keep selected item centered */
|
|
|
|
LISTVIEW_SCROLL_CONTINIOUS
|
2016-10-08 12:57:59 -04:00
|
|
|
} ScrollType;
|
|
|
|
|
2016-11-15 02:24:06 -05:00
|
|
|
/**
|
|
|
|
* @param tb The textbox to set
|
|
|
|
* @param entry The position of the textbox
|
|
|
|
* @param udata User data
|
2021-08-19 07:34:01 -04:00
|
|
|
* @param type The textbox font style to apply to this entry (normal, selected,
|
|
|
|
* alternative row)
|
2016-11-15 02:24:06 -05:00
|
|
|
* @param full If true Set both text and style.
|
|
|
|
*
|
|
|
|
* Update callback, this is called to set the value of each (visible) element.
|
|
|
|
*/
|
2021-08-19 07:34:01 -04:00
|
|
|
typedef void (*listview_update_callback)(textbox *tb, icon *ico,
|
|
|
|
unsigned int entry, void *udata,
|
|
|
|
TextBoxFontType *type, gboolean full);
|
2016-11-15 02:24:06 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Callback when a element is activated.
|
|
|
|
*/
|
2021-08-19 07:34:01 -04:00
|
|
|
typedef void (*listview_mouse_activated_cb)(listview *, gboolean, void *);
|
2016-10-08 12:57:59 -04:00
|
|
|
|
2016-11-15 02:24:06 -05:00
|
|
|
/**
|
2017-09-09 05:25:33 -04:00
|
|
|
* @param parent The widget's parent.
|
2017-01-01 12:40:49 -05:00
|
|
|
* @param name The name of the to be created widget.
|
2016-11-15 02:24:06 -05:00
|
|
|
* @param cb The update callback.
|
|
|
|
* @param udata The user data to pass to the callback
|
|
|
|
* @param eh The height of one element
|
2017-01-04 07:34:02 -05:00
|
|
|
* @param reverse Reverse the listview order.
|
2016-11-15 02:24:06 -05:00
|
|
|
*
|
|
|
|
* @returns a new listview
|
|
|
|
*/
|
2021-08-19 07:34:01 -04:00
|
|
|
listview *listview_create(widget *parent, const char *name,
|
|
|
|
listview_update_callback cb, void *udata,
|
|
|
|
unsigned int eh, gboolean reverse);
|
2016-10-08 12:57:59 -04:00
|
|
|
|
2016-11-15 02:24:06 -05:00
|
|
|
/**
|
|
|
|
* @param lv The listview handle
|
|
|
|
* @param rows Number of elements
|
|
|
|
*
|
|
|
|
* Set the maximum number of elements to display.
|
|
|
|
*/
|
2021-08-19 07:34:01 -04:00
|
|
|
void listview_set_num_elements(listview *lv, unsigned int rows);
|
2016-11-15 02:24:06 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @param lv The listview handle
|
|
|
|
* @param selected The row index to select
|
|
|
|
*
|
|
|
|
* Select the row, if selected > the number of rows, it selects the last one.
|
|
|
|
*/
|
2021-08-19 07:34:01 -04:00
|
|
|
void listview_set_selected(listview *lv, unsigned int selected);
|
2016-11-15 02:24:06 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @param lv The listview handle
|
|
|
|
*
|
|
|
|
* Returns the selected row.
|
|
|
|
*
|
|
|
|
* @returns the selected row.
|
|
|
|
*/
|
2021-08-19 07:34:01 -04:00
|
|
|
unsigned int listview_get_selected(listview *lv);
|
2016-11-15 02:24:06 -05:00
|
|
|
|
2022-03-07 14:37:58 -05:00
|
|
|
/**
|
|
|
|
* @param lv The listview handle
|
|
|
|
*
|
|
|
|
* Move the selection next element.
|
|
|
|
* - Wrap around.
|
|
|
|
*/
|
|
|
|
void listview_nav_next(listview *lv);
|
|
|
|
/**
|
|
|
|
* @param lv The listview handle
|
|
|
|
*
|
|
|
|
* Move the selection previous element.
|
|
|
|
* - Wrap around.
|
|
|
|
*/
|
|
|
|
void listview_nav_prev(listview *lv);
|
|
|
|
|
2016-10-08 12:57:59 -04:00
|
|
|
/**
|
2016-11-15 02:24:06 -05:00
|
|
|
* @param lv The listview handle
|
2016-10-08 12:57:59 -04:00
|
|
|
*
|
|
|
|
* Move the selection one row up.
|
|
|
|
* - Wrap around.
|
|
|
|
*/
|
2021-08-19 07:34:01 -04:00
|
|
|
void listview_nav_up(listview *lv);
|
2016-10-08 12:57:59 -04:00
|
|
|
/**
|
|
|
|
* @param lv listview handle.
|
|
|
|
*
|
|
|
|
* Move the selection one row down.
|
|
|
|
* - Wrap around.
|
|
|
|
*/
|
2021-08-19 07:34:01 -04:00
|
|
|
void listview_nav_down(listview *lv);
|
2016-10-08 12:57:59 -04:00
|
|
|
/**
|
2016-11-15 15:54:31 -05:00
|
|
|
* @param lv The listview handle
|
2016-10-08 12:57:59 -04:00
|
|
|
*
|
|
|
|
* Move the selection one column to the right.
|
|
|
|
* - No wrap around.
|
|
|
|
* - Do not move to top row when at start.
|
|
|
|
*/
|
2021-08-19 07:34:01 -04:00
|
|
|
void listview_nav_right(listview *lv);
|
2016-10-08 12:57:59 -04:00
|
|
|
/**
|
2017-01-08 11:18:49 -05:00
|
|
|
* @param lv The listview handle
|
2016-10-08 12:57:59 -04:00
|
|
|
*
|
|
|
|
* Move the selection one column to the left.
|
|
|
|
* - No wrap around.
|
|
|
|
*/
|
2021-08-19 07:34:01 -04:00
|
|
|
void listview_nav_left(listview *lv);
|
2016-10-08 12:57:59 -04:00
|
|
|
/**
|
2017-01-08 11:18:49 -05:00
|
|
|
* @param lv The listview handle
|
2016-10-08 12:57:59 -04:00
|
|
|
*
|
|
|
|
* Move the selection one page down.
|
|
|
|
* - No wrap around.
|
|
|
|
* - Clip at top/bottom
|
|
|
|
*/
|
2021-08-19 07:34:01 -04:00
|
|
|
void listview_nav_page_next(listview *lv);
|
2016-10-08 12:57:59 -04:00
|
|
|
|
|
|
|
/**
|
2017-01-08 11:18:49 -05:00
|
|
|
* @param lv The listview handle
|
2016-10-08 12:57:59 -04:00
|
|
|
*
|
|
|
|
* Move the selection one page up.
|
|
|
|
* - No wrap around.
|
|
|
|
* - Clip at top/bottom
|
|
|
|
*/
|
2021-08-19 07:34:01 -04:00
|
|
|
void listview_nav_page_prev(listview *lv);
|
2016-10-14 12:56:09 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @param lv Handler to the listview object
|
|
|
|
* @param enabled enable
|
|
|
|
*
|
|
|
|
* Hide the scrollbar.
|
|
|
|
*/
|
2021-08-19 07:34:01 -04:00
|
|
|
void listview_set_show_scrollbar(listview *lv, gboolean enabled);
|
2016-10-14 12:56:09 -04:00
|
|
|
/**
|
|
|
|
* @param lv Handler to the listview object
|
|
|
|
* @param width Width in pixels
|
|
|
|
*
|
|
|
|
* Set the width of the scrollbar
|
|
|
|
*/
|
2021-08-19 07:34:01 -04:00
|
|
|
void listview_set_scrollbar_width(listview *lv, unsigned int width);
|
2016-10-14 12:56:09 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @param lv Handler to the listview object
|
|
|
|
* @param cycle True for cycle mode
|
|
|
|
*
|
2016-10-15 09:39:08 -04:00
|
|
|
* Set cycle mode. On last entry go to first.
|
2016-10-14 12:56:09 -04:00
|
|
|
*/
|
2021-08-19 07:34:01 -04:00
|
|
|
void listview_set_cycle(listview *lv, gboolean cycle);
|
2016-10-14 12:56:09 -04:00
|
|
|
/**
|
|
|
|
* @param lv Handler to the listview object
|
|
|
|
* @param type ScrollType
|
|
|
|
*
|
2021-08-19 07:34:01 -04:00
|
|
|
* Set the scroll type ScrollType::LISTVIEW_SCROLL_CONTINIOUS or
|
|
|
|
* ScrollType::LISTVIEW_SCROLL_PER_PAGE
|
2016-10-14 12:56:09 -04:00
|
|
|
*/
|
2021-08-19 07:34:01 -04:00
|
|
|
void listview_set_scroll_type(listview *lv, ScrollType type);
|
2016-10-14 12:56:09 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @param lv Handler to the listview object
|
|
|
|
* @param cb The callback
|
|
|
|
* @param udata User data
|
|
|
|
*
|
|
|
|
* Set the mouse activated callback.
|
|
|
|
*/
|
2021-08-19 07:34:01 -04:00
|
|
|
void listview_set_mouse_activated_cb(listview *lv,
|
|
|
|
listview_mouse_activated_cb cb,
|
|
|
|
void *udata);
|
2016-10-14 12:56:09 -04:00
|
|
|
/**
|
|
|
|
* @param lv Handler to the listview object
|
2016-11-15 15:54:31 -05:00
|
|
|
* @param enable boolean to enable/disable multi-select
|
2016-10-14 12:56:09 -04:00
|
|
|
*
|
|
|
|
* Enable,disable multi-select.
|
|
|
|
*/
|
2021-08-19 07:34:01 -04:00
|
|
|
void listview_set_multi_select(listview *lv, gboolean enable);
|
2017-01-02 15:19:27 -05:00
|
|
|
/**
|
|
|
|
* @param lv Handler to the listview object.
|
|
|
|
* @param num_lines the maximum number of lines to display.
|
|
|
|
*
|
|
|
|
* Set the maximum number of lines to display.
|
|
|
|
*/
|
2021-08-19 07:34:01 -04:00
|
|
|
void listview_set_num_lines(listview *lv, unsigned int num_lines);
|
2017-01-02 15:19:27 -05:00
|
|
|
|
2017-01-08 11:18:49 -05:00
|
|
|
/**
|
|
|
|
* @param lv Handler to the listview object.
|
|
|
|
*
|
|
|
|
* Get the fixed-height property.
|
|
|
|
*
|
|
|
|
* @returns get fixed-height.
|
|
|
|
*/
|
2021-08-19 07:34:01 -04:00
|
|
|
gboolean listview_get_fixed_num_lines(listview *lv);
|
2017-01-08 11:18:49 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @param lv Handler to the listview object.
|
|
|
|
*
|
|
|
|
* Set fixed num lines mode.
|
|
|
|
*/
|
2021-08-19 07:34:01 -04:00
|
|
|
void listview_set_fixed_num_lines(listview *lv);
|
2017-01-08 11:18:49 -05:00
|
|
|
|
2017-01-02 15:19:27 -05:00
|
|
|
/**
|
|
|
|
* @param lv Handler to the listview object.
|
|
|
|
* @param max_lines the maximum number of lines to display.
|
|
|
|
*
|
|
|
|
* Set the maximum number of lines to display.
|
|
|
|
*/
|
2021-08-19 07:34:01 -04:00
|
|
|
void listview_set_max_lines(listview *lv, unsigned int max_lines);
|
2017-01-03 14:33:30 -05:00
|
|
|
|
2019-05-04 05:01:09 -04:00
|
|
|
/**
|
|
|
|
* @param lv Handler to the listview object.
|
|
|
|
*
|
2020-04-16 17:31:43 -04:00
|
|
|
* Set ellipsize mode.
|
2019-05-04 05:01:09 -04:00
|
|
|
*/
|
2021-08-19 07:34:01 -04:00
|
|
|
void listview_toggle_ellipsizing(listview *lv);
|
2020-04-16 17:31:43 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @param lv Handler to the listview object.
|
|
|
|
*
|
|
|
|
* Set ellipsize mode to start.
|
|
|
|
*/
|
|
|
|
|
2021-08-19 07:34:01 -04:00
|
|
|
void listview_set_ellipsize_start(listview *lv);
|
2022-04-20 17:24:52 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @param lv Handler to the listview object.
|
|
|
|
* @param filtered boolean indicating if list is filtered.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
void listview_set_filtered ( listview *lv, gboolean filtered );
|
2020-10-12 15:39:36 -04:00
|
|
|
/** @} */
|
2016-10-08 12:57:59 -04:00
|
|
|
|
|
|
|
#endif // ROFI_LISTVIEW_H
|