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...
|
| 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.
- The resolver is used to resolute an object of the specified type into (or back from) a listbox item.
- nana::listbox creates the category 0 by default. This is an special category, because it is invisible, while the associated items are visible. The optional, user-created categories begin at index 1 and are visible. The member functions without the categ parameter operate the items that belong to category 0.
- A sort compare is used for sorting the items. It is a strict weak ordering comparer that must meet the requirement: Irreflexivity (comp(x, x) returns false) and Antisymmetry(comp(a, b) != comp(b, a) returns true) A simple example. bool sort_compare( const std::string& s1, nana::any*, const std::string& s2, nana::any*, bool reverse) { return (reverse ? s1 > s2 : s1 < s2); } listbox.set_sort_compare(0, sort_compare); The listbox supports attaching a customer's object for each item, therefore the items can be sorted by comparing these customer's object. bool sort_compare( const std::string&, nana::any* o1, const std::string&, nana::any* o2, bool reverse) { if(o1 && o2) //some items may not attach a customer object. { int * i1 = any_cast<int>(*o1); int * i2 = any_cast<int>(*o2); return (i1 && i2 && (reverse ? *i1 > *i2 : *i1 < *i2)); ^ some types may not be int. } return false; } auto cat = listbox.at(0); cat.at(0).value(10); //10 is custom data. cat.at(1).value(20); //20 is custom data.
- listbox is a widget_object, with template parameters drawerbase::listbox::trigger and drawerbase::listbox::scheme among others. That means that listbox have a member trigger_ constructed first and accessible with get_drawer_trigger() and a member (unique pointer to) scheme_ accessible with scheme_type& scheme() created in the constructor with API::dev::make_scheme<Scheme>() which call API::detail::make_scheme(::nana::detail::scheme_factory<Scheme>()) which call restrict::bedrock.make_scheme(static_cast<::nana::detail::scheme_factory_base&&>(factory)); which call pi_data_->scheme.create(std::move(factory)); which call factory.create(scheme_template(std::move(factory))); which call (new Scheme(static_cast<Scheme&>(other))); and which in create is set with: API::dev::set_scheme(handle_, scheme_.get()); which save the scheme pointer in the nana::detail::basic_window member pointer scheme
- Todo:
- doc: actualize this example listbox.at(0)...
- See Also
- nana::drawerbase::listbox::cat_proxy
-
nana::drawerbase::listbox::item_proxy
- Examples:
- example_listbox.cpp, file_explorer.cpp, listbox_inline_widget.cpp, listbox_Resolver.cpp, widget_show.cpp, and widget_show2.cpp.