xtd 0.2.0
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<class 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 xtd::any_object& 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 const xtd::any_object& tag() const noexcept;
92
94
106 int32 compare_to(const item& value) const noexcept override;
107
111 bool equals(const xtd::object& obj) const noexcept override;
115 bool equals(const item& other) const noexcept override;
116
119 xtd::size get_hash_code() const noexcept override;
120
123 xtd::string to_string() const noexcept override;
125
126 private:
127 xtd::string value_;
128 xtd::any_object tag_;
129 };
130
132
135 using object_collection = layout::arranged_element_collection<item, item::sorter>;
137
139
142 static constexpr xtd::size npos = size_object::max_value;
144
146
150 virtual size_t selected_index() const noexcept;
154 virtual list_control& selected_index(size_t selected_index) = 0;
156
158
162 event<list_control, event_handler> selected_index_changed;
163
166 event<list_control, event_handler> selected_value_changed;
168
169 protected:
171
176
178
180 drawing::color default_back_color() const noexcept override;
181 drawing::color default_fore_color() const noexcept override;
183
185
189 virtual bool allow_selection() const noexcept;
190
192 virtual void on_selected_index_changed(const event_args& e);
193
195 virtual void on_selected_value_changed(const event_args& e);
196
199 void set_selected_index(size_t value);
201
202 private:
203 xtd::sptr<data> data_;
204 };
205 }
206}
Contains xtd::forms::application class.
Represent a polymorphic wrapper capable of holding any type.
Definition any_object.hpp:29
Represents text as a sequence of character units.
Definition basic_string.hpp:71
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:35
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 xtd::any_object &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:43
The xtd::shared_ptr_object is a shared pointer as std::shared_ptr.
Definition shared_ptr_object.hpp:30
generic_event_handler< const xtd::event_args & > event_handler
Represents the method that will handle an event that has no event data.
Definition event_handler.hpp:24
#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
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::style_sheets::control class.