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 }
48
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.
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;
156
158
163
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
193
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 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
event< control, event_handler > layout
Occurs when a xtd::forms::control should reposition its child controls.
Definition control.hpp:1636
control()
Initializes a new instance of the xtd::forms::control class with default settings.
virtual drawing::size size() const noexcept
Gets the height and width of the control.
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.
int32 compare_to(const item &value) const noexcept override
Compares the current instance with another object of the same type.
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
virtual const xtd::any_object & tag() const noexcept
Gets the tag of the item.
bool equals(const xtd::object &obj) const noexcept override
Determines whether the specified object is equal to the current object.
xtd::size get_hash_code() const noexcept override
Serves as a hash function for a particular type.
xtd::string to_string() const noexcept override
Returns a string containing the value of the item.
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.
event< list_control, event_handler > selected_index_changed
Occurs when the selected_index property changes.
Definition list_control.hpp:162
void set_selected_index(size_t value)
Sets the currently selected item.
drawing::color default_back_color() const noexcept override
Gets the default background color of the control.
virtual size_t selected_index() const noexcept
Gets the zero-based index of the currently selected item.
virtual bool allow_selection() const noexcept
Gets a value indicating whether the list enables selection of list items.
event< list_control, event_handler > selected_value_changed
Occurs when the selected_value property changes.
Definition list_control.hpp:166
virtual void on_selected_index_changed(const event_args &e)
Raises the list_control::selected_index_changed event.
static constexpr xtd::size npos
This is a special value equal to the maximum value representable by the type size_t.
Definition list_control.hpp:142
layout::arranged_element_collection< item, item::sorter > object_collection
Represents the collection of items in a list_control.
Definition list_control.hpp:135
virtual void on_selected_value_changed(const event_args &e)
Raises the list_control::selected_value_changed event.
list_control()
Initializes a new instance of the list_control class.
drawing::color default_fore_color() const noexcept override
Gets the default foreground color of the control.
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
object()=default
Create a new instance of the ultimate base class object.
Contains xtd::forms::control control.
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
xtd::basic_string< char > string
Represents text as a sequence of UTF-8 code units.
Definition __string_definitions.hpp:43
box_integer< size_t > size_object
Represent a boxed size_t.
Definition size_object.hpp:28
xtd::shared_ptr_object< type_t > sptr
The xtd::sptr object is a shared pointer.
Definition sptr.hpp:25
int32_t int32
Represents a 32-bit signed integer.
Definition int32.hpp:23
@ other
The operating system is other.
Definition platform_id.hpp:58
@ e
The E key.
Definition keys.hpp:207
The xtd::drawing namespace provides access to GDI+ basic graphics functionality. More advanced functi...
Definition actions_system_images.hpp:10
The xtd::forms namespace contains classes for creating Windows-based applications that take full adva...
Definition texts.hpp:219
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition abstract_object.hpp:8
read_only_span< type_t, count > first() const
Obtains a subspan consisting of the first count elements of the sequence.
Definition read_only_span.hpp:282
read_only_span< type_t, count > last() const
Obtains a subspan consisting of the last N elements of the sequence.
Definition read_only_span.hpp:307
constexpr const_pointer data() const noexcept
Gets direct access to the underlying contiguous storage.
Definition read_only_span.hpp:201