xtd - Reference Guide  0.1.2
Modern c++17/20 framework to create console, GUI and unit test applications on Windows, macOS, Linux, iOS and android.
Loading...
Searching...
No Matches
list_box.h
Go to the documentation of this file.
1
4#pragma once
6#include "border_style.h"
7#include "list_control.h"
8#include "selection_mode.h"
9
11namespace xtd {
13 namespace forms {
24 public:
26 using selected_index_collection = std::vector<size_t>;
27
29 using selected_object_collection = std::vector<item>;
30
33
36 virtual forms::border_style border_style() const {return border_style_;}
41
42 drawing::color default_back_color() const override {return xtd::forms::theme_colors::current_theme().window();}
43
44 drawing::color default_fore_color() const override {return xtd::forms::theme_colors::current_theme().window_text();}
45
46 drawing::size default_size() const override {return {120, 96};}
47
51 object_collection& items() {return items_;}
54 const object_collection& items() const {return items_;}
59 const list_box& items(const object_collection& items) {
60 items_ = items;
61 return *this;
62 }
63
64 using list_control::selected_index;
68 list_control& selected_index(size_t selected_index) override;
69
75
80 const item& selected_item() const {return selected_item_;}
86 list_box& selected_item(const item& selected_item);
87
93
97 virtual forms::selection_mode selection_mode() const {return selection_mode_;}
103
107 virtual bool sorted() const {return sorted_;}
112 virtual list_box& sorted(bool sorted);
113
114 using list_control::text;
117 control& text(const xtd::ustring& text) override {return *this;}
118
125
126 protected:
127 bool allow_selection() override {return selection_mode_ != forms::selection_mode::none;}
128
129 forms::create_params create_params() const override;
130
131 void on_handle_created(const event_args& e) override;
132
133 void on_selected_value_changed(const event_args& e) override;
134
135 void wnd_proc(message& message) override;
136
140
144
148
152
154 forms::border_style border_style_ = forms::border_style::fixed_single;
155 object_collection items_;
156 item selected_item_;
157 forms::selection_mode selection_mode_ = forms::selection_mode::one;
158 bool sorted_ = false;
160 };
161 }
162}
Contains xtd::forms::arranged_element_collection collection.
Contains xtd::forms::border_style enum class.
Represents an ARGB (alpha, red, green, blue) color.
Definition color.h:39
Stores an ordered pair of integers, which specify a height and width.
Definition size.h:25
Represents the base class for classes that contain event data, and provides a value to use for events...
Definition event_args.h:18
Defines the base class for controls, which are components with visual representation.
Definition control.h:67
Represents a collection of objects.
Definition arranged_element_collection.h:28
Represents a standard Windows list box.
Definition list_box.h:23
virtual forms::selection_mode selection_mode() const
Gets the method in which items are selected in the list_box.
Definition list_box.h:97
void on_handle_created(const event_args &e) override
Raises the control::handle_created event.
object_collection & items()
Gets the items of the list_box.
Definition list_box.h:51
control & text(const xtd::ustring &text) override
Sets the text associated with this control.
Definition list_box.h:117
const item & selected_item() const
Gets the currently selected item in the list_box.
Definition list_box.h:80
virtual forms::border_style border_style() const
Gets the type of border that is drawn around the list_box.
Definition list_box.h:36
bool allow_selection() override
Gets a value indicating whether the list enables selection of list items.
Definition list_box.h:127
list_box()
Initializes a new instance of the list_box class.
virtual void wm_reflect_command(message &message)
Processes the command message the list_box control receives from the top-level window.
selected_object_collection selected_items() const
Gets a collection containing the currently selected items in the list_box.
virtual void wm_mouse_double_click(message &message)
Processes the mouse double-click message the list_box control receives from the top-level window.
drawing::color default_back_color() const override
Gets the default background color of the control.
Definition list_box.h:42
std::vector< item > selected_object_collection
Represents the collection of selected items in the list_box.
Definition list_box.h:29
drawing::color default_fore_color() const override
Gets the default foreground color of the control.
Definition list_box.h:44
void begin_update()
Maintains performance while items are added to the list_box one at a time by preventing the control f...
list_box & selected_item(const item &selected_item)
Sets the currently selected item in the list_box.
virtual void wm_mouse_up(message &message)
Processes the mouse up message the list_box control receives from the top-level window.
virtual bool sorted() const
Gets a value indicating whether the items in the list_box are sorted alphabetically.
Definition list_box.h:107
forms::create_params create_params() const override
Gets the required creation parameters when the control handle is created.
list_control & selected_index(size_t selected_index) override
When overridden in a derived class, Sets the zero-based index of the currently selected item.
void wnd_proc(message &message) override
Processes Windows messages.
drawing::size default_size() const override
Gets the default size of the control.
Definition list_box.h:46
virtual list_box & border_style(forms::border_style border_style)
Sets the type of border that is drawn around the list_box.
virtual selected_index_collection selected_indices() const
Gets a collection that contains the zero-based indexes of all currently selected items in the list_bo...
virtual void wm_mouse_down(message &message)
Processes the mouse down message the list_box control receives from the top-level window.
virtual list_box & selection_mode(forms::selection_mode selection_mode)
Sets the method in which items are selected in the list_box.
std::vector< size_t > selected_index_collection
Represents the collection containing the indexes to the selected items in a list_box.
Definition list_box.h:26
const object_collection & items() const
Gets the items of the list_box.
Definition list_box.h:54
const list_box & items(const object_collection &items)
Sets the items of the list_box.
Definition list_box.h:59
void end_update()
Resumes painting the list_box control after painting is suspended by the begin_update method.
virtual list_box & sorted(bool sorted)
Sets a value indicating whether the items in the list_box are sorted alphabetically.
void on_selected_value_changed(const event_args &e) override
Raises the list_control::selected_value_changed event.
Represent an item contained in the list_control::object_collection collection.
Definition list_control.h:24
Provides a common implementation of members for the list_box, choice and combo_box classes.
Definition list_control.h:21
Implements a Windows message.
Definition message.h:25
Represents text as a sequence of UTF-8 code units.
Definition ustring.h:48
#define forms_export_
Define shared library export.
Definition forms_export.h:13
selection_mode
Specifies the selection behavior of a list box.
Definition selection_mode.h:18
border_style
Specifies the border style for a control.
Definition border_style.h:18
Contains xtd::forms::list_control control.
The xtd::forms namespace contains classes for creating Windows-based applications that take full adva...
Definition about_box.h:13
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition system_report.h:17
Contains xtd::forms::selection_mode enum class.