Nana C++ Library. Reference for users.
What we need to use nana
|
A rectangle containing a list of strings from which the user can select. This widget contain a list of categories, with in turn contain a list of items. A category is a text with can be selected, checked and expanded to show the items. An item is formed by column-fields, each corresponding to one of the headers. An item can be selected and checked. The user can drag the header to resize it or to reorganize it. By clicking on one header the list get reordered, first up, and then down alternatively. More...
Public Member Functions | |
listbox ()=default | |
listbox (window, bool visible) | |
listbox (window, const rectangle &={}, bool visible=true) | |
cat_proxy | at (size_type pos) |
Returns the category at specified location pos, with bounds checking. More... | |
const cat_proxy | at (size_type pos) const |
item_proxy | at (const index_pair &abs_pos) |
Returns the item at specified absolute position. More... | |
const item_proxy | at (const index_pair &abs_pos) const |
cat_proxy | operator[] (size_type pos) |
Returns the category at specified location pos, no bounds checking is performed. More... | |
const cat_proxy | operator[] (size_type pos) const |
item_proxy | operator[] (const index_pair &abs_pos) |
Returns the item at specified absolute position, no bounds checking is performed. More... | |
const item_proxy | operator[] (const index_pair &abs_pos) const |
template<typename Key > | |
cat_proxy | assoc (Key &&key) |
Returns a proxy to the category of the key or create a new one in the right order. More... | |
template<typename Key > | |
cat_proxy | assoc_at (Key &&key) |
Returns a proxy to the category of the key or create a new one in the right order. More... | |
template<typename Key > | |
void | assoc_erase (Key &&key) |
Removes the category associated with the specified key. More... | |
bool | assoc_ordered (bool) |
void | auto_draw (bool) noexcept |
Set state: Redraw automatically after an operation. More... | |
template<typename Function > | |
void | avoid_drawing (Function fn) |
void | scroll (bool to_bottom, size_type cat_pos=::nana::npos) |
Scrolls the view to the first or last item of a specified category. More... | |
void | scroll (bool to_bottom, const index_pair &abs_pos) |
Scrolls the view to show an item specified by absolute position at top/bottom of the listbox. More... | |
size_type | append_header (std::string text_utf8, unsigned width=120) |
size_type | append_header (std::wstring text, unsigned width=120) |
void | clear_headers () |
Removes all the columns. More... | |
cat_proxy | append (std::string category) |
Appends a new category to the end. More... | |
cat_proxy | append (std::wstring category) |
Appends a new category to the end. More... | |
void | append (std::initializer_list< std::string > categories) |
Appends categories to the end. More... | |
void | append (std::initializer_list< std::wstring > categories) |
Appends categories to the end. More... | |
column_interface & | column_at (size_type pos, bool disp_order=false) |
Access a column at specified position. More... | |
const column_interface & | column_at (size_type pos, bool disp_order=false) const |
Access a column at specified position. More... | |
size_type | column_size () const |
Returns the number of columns. More... | |
void | move_column (size_type abs_pos, size_type view_pos) |
Move column to view_position. More... | |
void | reorder_columns (size_type first_col, size_type last_col, index_pair row, bool reverse, std::function< bool(const std::string &cell1, size_type col1, const std::string &cell2, size_type col2, const nana::any *rowval, bool reverse)> comp) |
Sort columns in range first_col to last_col inclusive using the values from a row. More... | |
void | column_resizable (bool resizable) |
bool | column_resizable () const |
void | column_movable (bool) |
bool | column_movable () const |
rectangle | content_area () const |
Returns the rectangle where the content is drawn. More... | |
cat_proxy | insert (cat_proxy,::std::string) |
cat_proxy | insert (cat_proxy,::std::wstring) |
void | insert_item (const index_pair &abs_pos,::std::string text) |
Inserts an item before a specified position. More... | |
void | insert_item (const index_pair &abs_pos, const ::std::wstring &text) |
Inserts an item before a specified position. More... | |
void | insert_item (index_pair abs_pos, const listbox &rhs, const index_pairs &indexes) |
index_pair | cast (const point &screen_pos) const |
Returns the index pair of the item which contains the specified "screen" point. More... | |
index_pair | hovered (bool return_end) const |
Returns the item which is hovered. More... | |
size_type | column_from_pos (const point &screen_pos) const |
Returns the absolute position of the column which contains the specified "screen" point. More... | |
void | checkable (bool make_checkeable) |
Display a checkbox at te links of each item if make_checkeable=true. More... | |
index_pairs | checked () const |
Returns all the items which are checked. More... | |
void | clear (size_type cat) |
Removes all the items from the specified category. More... | |
void | clear () |
Removes all the items from all categories. More... | |
void | erase (size_type cat) |
Erases a category. More... | |
void | erase () |
Erases all categories. More... | |
void | erase (index_pairs indexes) |
Erases specified items. More... | |
item_proxy | erase (item_proxy indx) |
Erases specified item. More... | |
bool | sortable () const |
return whether the listbox is set to be sortable More... | |
void | sortable (bool enable) |
set the listbox to be or not to be sortable More... | |
void | set_sort_compare (size_type col, std::function< bool(const std::string &, nana::any *, const std::string &, nana::any *, bool reverse)> strick_ordering) |
Sets a strict weak ordering comparer for a column. More... | |
void | sort_col (size_type col, bool reverse=false) |
sort() and invalidates any existing reference from display position to absolute item, that is: after sort() display offset point to different items More... | |
size_type | sort_col () const |
return the column currently used to sort items More... | |
void | unsort () |
Prevent sorting until freeze is set to false. More... | |
bool | freeze_sort (bool freeze) |
index_pairs | selected () const |
Get the absolute indexes of all the selected items. More... | |
void | show_header (bool) |
bool | visible_header () const |
void | move_select (bool upwards) |
Selects an item besides the current selected item in the display. More... | |
size_type | size_categ () const |
Get the number of categories. More... | |
size_type | size_item (size_type cat) const |
The number of items in category "cat". More... | |
void | enable_single (bool for_selection, bool category_limited) |
void | disable_single (bool for_selection) |
bool | is_single_enabled (bool for_selection) const noexcept |
Determines whether the single selection/check is enabled. More... | |
export_options & | def_export_options () |
return a modifiable reference to the export options in use More... | |
listbox & | category_icon (std::function< void(paint::graphics &graph, const rectangle &rt_icon, bool expanded)> icon_renderer) |
Sets a renderer for category icon. More... | |
listbox & | category_icon (const paint::image &img_expanded, const paint::image &img_collapsed) |
Sets category icons. More... | |
index_pair | first_visible () const |
Returns first visible element. More... | |
index_pair | last_visible () const |
Returns last visible element. More... | |
index_pairs | visibles () const |
Returns all visible items. More... | |
void | set_deselect (std::function< bool(nana::mouse)> predicate) |
Sets a predicate that indicates whether to deselect items when mouse_up is triggered. More... | |
unsigned | suspension_width () const |
![]() | |
widget_object () | |
~widget_object () | |
event_type & | events () const |
bool | create (window parent_wd, bool visible) |
bool | create (window parent_wd, const rectangle &r={}, bool visible=true) |
widget_object & | borderless (bool enable) |
bool | borderless () const |
scheme_type & | scheme () const |
void | filter_event (const event_code evt_code, const bool bDisabled) |
void | filter_event (const std::vector< event_code > evt_codes, const bool bDisabled) |
void | filter_event (const event_filter_status &evt_all_states) |
bool | filter_event (const event_code evt_code) |
event_filter_status | filter_event () |
void | clear_filter () |
![]() | |
window | handle () const override |
Returns the handle of window, returns 0 if window is not created. More... | |
![]() | |
widget ()=default | |
virtual | ~widget ()=default |
bool | empty () const |
Determines whether the manipulator is handling a window. More... | |
void | close () |
window | parent () const |
::std::string | caption () const noexcept |
::std::wstring | caption_wstring () const noexcept |
native_string_type | caption_native () const noexcept |
widget & | caption (std::string utf8) |
widget & | caption (std::wstring) |
template<typename... Args> | |
void | i18n (std::string msgid, Args &&...args) |
void | i18n (i18n_eval) |
void | cursor (nana::cursor) |
nana::cursor | cursor () const |
Retrieves the shape of cursor. More... | |
void | typeface (const paint::font &font) |
paint::font | typeface () const |
bool | enabled () const |
Determines whether the window is enabled for mouse and keyboard input. More... | |
void | enabled (bool) |
void | enable_dropfiles (bool) |
Enables/Disables a window to accept dropped files. More... | |
void | focus () |
bool | focused () const |
std::shared_ptr < scroll_operation_interface > | scroll_operation () |
void | show () |
Sets the window visible. More... | |
void | hide () |
Sets the window invisible. More... | |
bool | visible () const |
nana::size | size () const |
void | size (const nana::size &) |
void | set_capture (bool ignore_children) |
Enables the widget to grab the mouse input. More... | |
void | release_capture () |
Disables the widget to grab the mouse input. More... | |
point | pos () const |
void | move (int x, int y) |
void | move (const point &) |
void | move (const rectangle &) |
void | fgcolor (const nana::color &) |
nana::color | fgcolor () const |
void | bgcolor (const nana::color &) |
nana::color | bgcolor () const |
general_events & | events () const |
void | umake_event (event_handle eh) const |
Deletes an event callback by a handle. More... | |
widget & | register_shortkey (wchar_t) |
Registers a shortkey. To remove a registered key, pass 0. More... | |
widget & | take_active (bool activated, window take_if_not_activated) |
widget & | tooltip (const ::std::string &) |
operator dummy_bool_type () const | |
operator window () const | |
![]() | |
virtual | ~any_objective ()=default |
void | anyobj (const Target &t) |
void | anyobj (Target &&t) |
Target * | anyobj () const |
< Retrieves the attached object. Returns a nullptr if empty or if the type not match. More... | |
A rectangle containing a list of strings from which the user can select. This widget contain a list of categories, with in turn contain a list of items. A category is a text with can be selected, checked and expanded to show the items. An item is formed by column-fields, each corresponding to one of the headers. An item can be selected and checked. The user can drag the header to resize it or to reorganize it. By clicking on one header the list get reordered, first up, and then down alternatively.
Iterator to access category.
The representation of an item cell.
Column operations.
The options for exporting items into a string variable.
The representation of a category/item.
A index_pair package.
The interface for user-defined inline widgets.
The input resolver that converts an object to an item.
Iterator to access item.
The output resolver that converts an item to an object.
An unsigned integral type.
|
default |
nana::listbox::listbox | ( | window | wd, |
bool | visible | ||
) |
listbox::cat_proxy nana::listbox::append | ( | std::string | category | ) |
Appends a new category to the end.
listbox::cat_proxy nana::listbox::append | ( | std::wstring | category | ) |
Appends a new category to the end.
void nana::listbox::append | ( | std::initializer_list< std::string > | categories | ) |
Appends categories to the end.
void nana::listbox::append | ( | std::initializer_list< std::wstring > | categories | ) |
Appends categories to the end.
listbox::size_type nana::listbox::append_header | ( | std::string | text_utf8, |
unsigned | width = 120 |
||
) |
Appends a new column with a header text and the specified width at the end, and return it position
If a width of 0 is passed the width will be set to fit the header text.
listbox::size_type nana::listbox::append_header | ( | std::wstring | text, |
unsigned | width = 120 |
||
) |
|
inline |
Returns a proxy to the category of the key or create a new one in the right order.
key | The key of category to find |
|
inline |
Returns a proxy to the category of the key or create a new one in the right order.
key | The key of category to find |
|
inline |
Removes the category associated with the specified key.
key | The key of category to remove |
bool nana::listbox::assoc_ordered | ( | bool | enable | ) |
listbox::cat_proxy nana::listbox::at | ( | size_type | pos | ) |
Returns the category at specified location pos, with bounds checking.
const listbox::cat_proxy nana::listbox::at | ( | size_type | pos | ) | const |
listbox::item_proxy nana::listbox::at | ( | const index_pair & | abs_pos | ) |
Returns the item at specified absolute position.
const listbox::item_proxy nana::listbox::at | ( | const index_pair & | abs_pos | ) | const |
|
noexcept |
Set state: Redraw automatically after an operation.
|
inline |
listbox::index_pair nana::listbox::cast | ( | const point & | screen_pos | ) | const |
Returns the index pair of the item which contains the specified "screen" point.
listbox & nana::listbox::category_icon | ( | std::function< void(paint::graphics &graph, const rectangle &rt_icon, bool expanded)> | icon_renderer | ) |
Sets a renderer for category icon.
icon_renderer | The renderer of category icon |
listbox & nana::listbox::category_icon | ( | const paint::image & | img_expanded, |
const paint::image & | img_collapsed | ||
) |
Sets category icons.
img_expanded | An icon displayed in front of category title when the category is expanded. |
img_collapsed | An icon displayed in front of category title when the category is collapsed. |
void nana::listbox::checkable | ( | bool | make_checkeable | ) |
Display a checkbox at te links of each item if make_checkeable=true.
auto nana::listbox::checked | ( | ) | const |
Returns all the items which are checked.
void nana::listbox::clear | ( | size_type | cat | ) |
Removes all the items from the specified category.
void nana::listbox::clear | ( | ) |
Removes all the items from all categories.
void nana::listbox::clear_headers | ( | ) |
Removes all the columns.
auto nana::listbox::column_at | ( | size_type | pos, |
bool | disp_order = false |
||
) |
Access a column at specified position.
pos | Position of column |
disp_order | Indicates whether the pos is display position or absolute position. |
auto nana::listbox::column_at | ( | size_type | pos, |
bool | disp_order = false |
||
) | const |
Access a column at specified position.
pos | Position of column |
disp_order | Indicates whether the pos is display position or absolute position. |
listbox::size_type nana::listbox::column_from_pos | ( | const point & | screen_pos | ) | const |
Returns the absolute position of the column which contains the specified "screen" point.
void nana::listbox::column_movable | ( | bool | movable | ) |
bool nana::listbox::column_movable | ( | ) | const |
void nana::listbox::column_resizable | ( | bool | resizable | ) |
bool nana::listbox::column_resizable | ( | ) | const |
auto nana::listbox::column_size | ( | ) | const |
Returns the number of columns.
rectangle nana::listbox::content_area | ( | ) | const |
Returns the rectangle where the content is drawn.
listbox::export_options & nana::listbox::def_export_options | ( | ) |
return a modifiable reference to the export options in use
void nana::listbox::disable_single | ( | bool | for_selection | ) |
void nana::listbox::enable_single | ( | bool | for_selection, |
bool | category_limited | ||
) |
void nana::listbox::erase | ( | size_type | cat | ) |
Erases a category.
void nana::listbox::erase | ( | ) |
Erases all categories.
void nana::listbox::erase | ( | index_pairs | indexes | ) |
Erases specified items.
listbox::item_proxy nana::listbox::erase | ( | item_proxy | indx | ) |
Erases specified item.
auto nana::listbox::first_visible | ( | ) | const |
Returns first visible element.
It may return an item or a category item.
bool nana::listbox::freeze_sort | ( | bool | freeze | ) |
listbox::index_pair nana::listbox::hovered | ( | bool | return_end | ) | const |
Returns the item which is hovered.
return_end | Indicates whether to return an end position instead of an empty position if no item is hovered. |
cat_proxy nana::listbox::insert | ( | cat_proxy | , |
::std::string | |||
) |
cat_proxy nana::listbox::insert | ( | cat_proxy | , |
::std::wstring | |||
) |
void nana::listbox::insert_item | ( | const index_pair & | abs_pos, |
::std::string | text | ||
) |
Inserts an item before a specified position.
abs_pos | The absolute position before which an item will be inserted. |
text | Text of the first column, UTF-8 encoded. |
void nana::listbox::insert_item | ( | const index_pair & | abs_pos, |
const ::std::wstring & | text | ||
) |
Inserts an item before a specified position.
abs_pos | The absolute position before which an item will be inserted. |
text | Text of the first column. |
void nana::listbox::insert_item | ( | index_pair | abs_pos, |
const listbox & | rhs, | ||
const index_pairs & | indexes | ||
) |
|
noexcept |
Determines whether the single selection/check is enabled.
auto nana::listbox::last_visible | ( | ) | const |
Returns last visible element.
It may return an item or a category item.
Move column to view_position.
void nana::listbox::move_select | ( | bool | upwards | ) |
Selects an item besides the current selected item in the display.
upwards | Selects an item besides the current selected item in the display. |
Returns the category at specified location pos, no bounds checking is performed.
item_proxy nana::listbox::operator[] | ( | const index_pair & | abs_pos | ) |
Returns the item at specified absolute position, no bounds checking is performed.
const item_proxy nana::listbox::operator[] | ( | const index_pair & | abs_pos | ) | const |
void nana::listbox::reorder_columns | ( | size_type | first_col, |
size_type | last_col, | ||
index_pair | row, | ||
bool | reverse, | ||
std::function< bool(const std::string &cell1, size_type col1, const std::string &cell2, size_type col2, const nana::any *rowval, bool reverse)> | comp | ||
) |
Sort columns in range first_col to last_col inclusive using the values from a row.
Sort columns in range first_col to last_col inclusive using a row.
void nana::listbox::scroll | ( | bool | to_bottom, |
size_type | cat_pos = ::nana::npos |
||
) |
Scrolls the view to the first or last item of a specified category.
void nana::listbox::scroll | ( | bool | to_bottom, |
const index_pair & | abs_pos | ||
) |
Scrolls the view to show an item specified by absolute position at top/bottom of the listbox.
auto nana::listbox::selected | ( | ) | const |
Get the absolute indexes of all the selected items.
void nana::listbox::set_deselect | ( | std::function< bool(nana::mouse)> | predicate | ) |
Sets a predicate that indicates whether to deselect items when mouse_up is triggered.
The predicate is called before the listbox attempts to deselect the selected items in the mouse_up event. Other situations, the predicates isn't called, for example, releasing mouse button after user performed a box selection, because listbox doesn't deselect the items during this operation.
predicate | Decides to deselect the items. The paramater of predicate indicates the mouse button which is releasing. It returns true to deselect the selected items. It returns false to cancel to deselect the selected items. |
void nana::listbox::set_sort_compare | ( | size_type | col, |
std::function< bool(const std::string &, nana::any *, const std::string &, nana::any *, bool reverse)> | strick_ordering | ||
) |
Sets a strict weak ordering comparer for a column.
void nana::listbox::show_header | ( | bool | sh | ) |
listbox::size_type nana::listbox::size_categ | ( | ) | const |
Get the number of categories.
listbox::size_type nana::listbox::size_item | ( | size_type | cat | ) | const |
The number of items in category "cat".
void nana::listbox::sort_col | ( | size_type | col, |
bool | reverse = false |
||
) |
sort() and invalidates any existing reference from display position to absolute item, that is: after sort() display offset point to different items
Sort the items using the specified column.
Invalidates any existing reference from display position to absolute item, that is: after sort() display offset point to different items
auto nana::listbox::sort_col | ( | ) | const |
return the column currently used to sort items
bool nana::listbox::sortable | ( | ) | const |
return whether the listbox is set to be sortable
void nana::listbox::sortable | ( | bool | enable | ) |
set the listbox to be or not to be sortable
unsigned nana::listbox::suspension_width | ( | ) | const |
void nana::listbox::unsort | ( | ) |
Prevent sorting until freeze
is set to false.
potentially invalidates any existing reference from display position to absolute item, that is: after sort() display offset point to different items
Eliminate any "column sorting", effectively setting the items in the order of creation.
Potentially invalidates any existing reference from display position to absolute item, that is: after unsort() display offset may point to different items
bool nana::listbox::visible_header | ( | ) | const |
auto nana::listbox::visibles | ( | ) | const |
Returns all visible items.
It returns all visible items that are displayed in listbox window.