xtd 0.2.0
Loading...
Searching...
No Matches
list_control.hpp
Go to the documentation of this file.
1
4#pragma once
5
6#include "application.hpp"
7#include "control.hpp"
8#include <xtd/iequatable>
9#include <xtd/size_object>
10
12namespace xtd {
14 namespace forms {
28 struct data;
29
30 public:
32 class item : public object, public icomparable<item>, public xtd::iequatable<item> {
33 public:
35 class sorter {
36 public:
38
44 template<typename type_t>
45 void operator()(type_t first, type_t last) {
46 std::sort(first, last);
47 }
49 };
50
52
55 static const item empty;
57
59
62 item() = default;
65 item(const xtd::string& value); // Can't be explicit by design.
69 item(const xtd::string& value, const std::any& tag);
71
73 item(const char* value); // Can't be explicit by design.
74 item(const item& value) = default;
75 item(item&& value) = default;
76 item& operator =(const item& value) = default;
77 item& operator =(item&& value) = default;
78 virtual ~item() = default;
80
82
86 virtual const xtd::string& value() const noexcept;
87
90 virtual std::any tag() const noexcept;
92
94
96 int32 compare_to(const item& value) const noexcept override;
97
98 using object::equals;
99 bool equals(const item& value) const noexcept override;
100
103 xtd::string to_string() const noexcept override;
105
106 private:
107 xtd::string value_;
108 std::any tag_;
109 };
110
112
115 using object_collection = layout::arranged_element_collection<item, item::sorter>;
117
119
122 static constexpr xtd::size npos = size_object::max_value;
124
126
130 virtual size_t selected_index() const noexcept;
134 virtual list_control& selected_index(size_t selected_index) = 0;
136
138
142 event<list_control, event_handler> selected_index_changed;
143
146 event<list_control, event_handler> selected_value_changed;
148
149 protected:
151
156
158
160 drawing::color default_back_color() const noexcept override;
161 drawing::color default_fore_color() const noexcept override;
163
165
169 virtual bool allow_selection() const noexcept;
170
172 virtual void on_selected_index_changed(const event_args& e);
173
175 virtual void on_selected_value_changed(const event_args& e);
176
179 void set_selected_index(size_t value);
181
182 private:
183 xtd::sptr<data> data_;
184 };
185 }
186}
Represents text as a sequence of character units.
Definition basic_string.hpp:79
Represents a boxed integer object.
Definition box_integer.hpp:52
Represents the base class for classes that contain event data, and provides a value to use for events...
Definition event_args.hpp:18
Represents an event.
Definition event.hpp:21
Defines the base class for controls, which are components with visual representation.
Definition control.hpp:81
Represents a collection of objects.
Definition arranged_element_collection.hpp:34
Represent the sorter class used by list_control::object_collection collection.
Definition list_control.hpp:35
void operator()(type_t first, type_t last)
sorter functor.
Definition list_control.hpp:45
Represent an item contained in the list_control::object_collection collection.
Definition list_control.hpp:32
item(const xtd::string &value)
Initializes a new instance of the item class with specified value.
item()=default
Initializes a new instance of the item class.
static const item empty
Represents an empty item that value is equal to xtd::string::empty_string and tag has no vlaue.
Definition list_control.hpp:55
item(const xtd::string &value, const std::any &tag)
Initializes a new instance of the item class with specified value and tag.
virtual const xtd::string & value() const noexcept
Gets the value of the item.
Provides a common implementation of members for the list_box, choice and combo_box classes.
Definition list_control.hpp:27
Defines a generalized comparison method that a value type or class implements to create a type-specif...
Definition icomparable.hpp:21
Defines a generalized method that a value type or class implements to create a type-specific method f...
Definition iequatable.hpp:22
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes....
Definition object.hpp:42
generic_event_handler<> event_handler
Represents the method that will handle an event that has no event data.
Definition event_handler.hpp:32
#define forms_export_
Define shared library export.
Definition forms_export.hpp:13
int32_t int32
Represents a 32-bit signed integer.
Definition int32.hpp:23
size_t size
Represents a size of any object in bytes.
Definition size.hpp:23
std::shared_ptr< type_t > sptr
The xtd::sptr object is a shared pointer.
Definition sptr.hpp:25
The xtd::forms namespace contains classes for creating Windows-based applications that take full adva...
Definition xtd_about_box.hpp:12
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.hpp:10
Contains xtd::forms::application class.
Contains xtd::forms::style_sheets::control class.