xtd 1.0.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/usize_object>
10
12namespace xtd {
14 namespace forms {
28 struct data;
29
30 public:
32 class item : public xtd::object, public xtd::icomparable<item>, public xtd::iequatable<item> {
33 public:
35 struct sorter {
37
43 template<typename type_t>
44 auto operator()(type_t first, type_t last) -> void {std::sort(first, last);}
46 };
47
49
52 static const item empty;
54
56
59 item() = default;
62 item(const xtd::string& value); // Can't be explicit by design.
68
70 item(const char* value); // Can't be explicit by design.
71 virtual ~item() = default;
73
75
79 [[nodiscard]] virtual auto value() const noexcept -> const xtd::string&;
80
83 [[nodiscard]] virtual auto tag() const noexcept -> const xtd::any_object&;
85
87
99 [[nodiscard]] auto compare_to(const item& value) const noexcept -> xtd::int32 override;
100
104 [[nodiscard]] auto equals(const xtd::object& obj) const noexcept -> bool override;
108 [[nodiscard]] auto equals(const item& other) const noexcept -> bool override;
109
112 [[nodiscard]] auto get_hash_code() const noexcept -> xtd::usize override;
113
116 [[nodiscard]] auto to_string() const noexcept -> xtd::string override;
118
119 private:
120 xtd::string value_;
121 xtd::any_object tag_;
122 };
123
125
128 using object_collection = xtd::forms::layout::arranged_element_collection<item, item::sorter>;
130
132
136 inline static constexpr xtd::usize npos = object_collection::npos;
137
140 static inline constexpr xtd::usize bpos = object_collection::bpos;
141
146 static inline constexpr xtd::usize epos = object_collection::epos;
148
150
154 [[nodiscard]] virtual auto selected_index() const noexcept -> xtd::usize;
158 virtual auto selected_index(xtd::usize value) -> list_control& = 0;
160
162
167
172
173 protected:
175
180
182
184 [[nodiscard]] auto default_back_color() const noexcept -> xtd::drawing::color override;
185 [[nodiscard]] auto default_fore_color() const noexcept -> xtd::drawing::color override;
187
189
193 [[nodiscard]] virtual auto allow_selection() const noexcept -> bool;
194
196 virtual auto on_selected_index_changed(const event_args& e) -> void;
197
199 virtual auto on_selected_value_changed(const event_args& e) -> void;
200
203 auto set_selected_index(xtd::usize value) -> void;
205
206 private:
207 xtd::sptr<data> data_;
208 };
209 }
210}
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:23
Defines the base class for controls, which are components with visual representation.
Definition control.hpp:81
xtd::event< control, xtd::event_handler > layout
Occurs when a xtd::forms::control should reposition its child controls.
Definition control.hpp:1617
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.
virtual auto tag() const noexcept -> const xtd::any_object &
Gets the tag of the item.
item()=default
Initializes a new instance of the item class.
auto compare_to(const item &value) const noexcept -> xtd::int32 override
Compares the current instance with another object of the same type.
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:52
auto get_hash_code() const noexcept -> xtd::usize override
Serves as a hash function for a particular type.
auto equals(const xtd::object &obj) const noexcept -> bool override
Determines whether the specified object is equal to the current object.
item(const xtd::string &value, const xtd::any_object &tag)
Initializes a new instance of the item class with specified value and tag.
auto to_string() const noexcept -> xtd::string override
Returns a string containing the value of the item.
virtual auto value() const noexcept -> const xtd::string &
Gets the value of the item.
xtd::event< list_control, xtd::event_handler > selected_index_changed
Occurs when the selected_index property changes.
Definition list_control.hpp:166
xtd::event< list_control, xtd::event_handler > selected_value_changed
Occurs when the selected_value property changes.
Definition list_control.hpp:170
virtual auto on_selected_value_changed(const event_args &e) -> void
Raises the list_control::selected_value_changed event.
static constexpr xtd::usize npos
Represents a value that is not a valid position in a collection.
Definition list_control.hpp:136
virtual auto on_selected_index_changed(const event_args &e) -> void
@briefautoRaises the list_control::selected_index_changed event.
auto default_back_color() const noexcept -> xtd::drawing::color override
Gets the default background color of the control.
xtd::forms::layout::arranged_element_collection< item, item::sorter > object_collection
Represents the collection of items in a list_control.
Definition list_control.hpp:128
auto set_selected_index(xtd::usize value) -> void
Sets the currently selected item.
virtual auto allow_selection() const noexcept -> bool
Gets a value indicating whether the list enables selection of list items.
list_control()
Initializes a new instance of the list_control class.
virtual auto selected_index() const noexcept -> xtd::usize
Gets the zero-based index of the currently selected item.
static constexpr xtd::usize bpos
Represents the index of the first valid element in a collection.
Definition list_control.hpp:140
static constexpr xtd::usize epos
Represents the index of the last valid element in a collection.
Definition list_control.hpp:146
auto default_fore_color() const noexcept -> xtd::drawing::color 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:22
Defines a generalized method that a value type or class implements to create a type-specific method f...
Definition iequatable.hpp:23
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes....
Definition object.hpp:45
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
xtd::shared_ptr_object< type_t > sptr
The xtd::sptr object is a shared pointer.
Definition sptr.hpp:25
std::int32_t int32
Represents a 32-bit signed integer.
Definition int32.hpp:25
std::size_t usize
Represents an unsigned size of any object in bytes.
Definition usize.hpp:22
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
auto first() const -> read_only_span< type_t, count >
Obtains a subspan consisting of the first count elements of the sequence.
Definition read_only_span.hpp:249
constexpr auto data() const noexcept -> const_pointer
Gets direct access to the underlying contiguous storage.
Definition read_only_span.hpp:197
auto last() const -> read_only_span< type_t, count >
Obtains a subspan consisting of the last N elements of the sequence.
Definition read_only_span.hpp:274
Represent the sorter struct used by list_control::object_collection collection.
Definition list_control.hpp:35
auto operator()(type_t first, type_t last) -> void
sorter functor.
Definition list_control.hpp:44