xtd 0.2.0
Loading...
Searching...
No Matches
list_control.h
Go to the documentation of this file.
1
4#pragma once
5
6#include "application.h"
7#include "control.h"
8#include <xtd/iequatable>
9#include <xtd/size_object>
10
12namespace xtd {
14 namespace forms {
26 struct data;
27
28 public:
30 class item : public object, public icomparable<item>, public xtd::iequatable<item> {
31 public:
33 class sorter {
34 public:
36
42 template<typename type_t>
43 void operator()(type_t first, type_t last) {
44 std::sort(first, last);
45 }
47 };
48
50
53 static const item empty;
55
57
60 item() = default;
63 item(const xtd::ustring& value); // Can't be explicit by design.
67 item(const xtd::ustring& value, const std::any& tag);
69
71 item(const char* value); // Can't be explicit by design.
72 item(const item& value) = default;
73 item(item&& value) = default;
74 item& operator =(const item& value) = default;
75 item& operator =(item&& value) = default;
76 virtual ~item() = default;
78
80
84 virtual const xtd::ustring& value() const noexcept;
85
88 virtual std::any tag() const noexcept;
90
92
94 int32 compare_to(const item& value) const noexcept override;
95
96 bool equals(const item& value) const noexcept override;
97
100 xtd::ustring to_string() const noexcept override;
102
103 private:
104 xtd::ustring value_;
105 std::any tag_;
106 };
107
109
112 using object_collection = layout::arranged_element_collection<item, item::sorter>;
114
116
119 static const size_t npos = size_object::max_value;
121
123
127 virtual size_t selected_index() const noexcept;
131 virtual list_control& selected_index(size_t selected_index) = 0;
133
135
139 event<list_control, event_handler> selected_index_changed;
140
143 event<list_control, event_handler> selected_value_changed;
145
146 protected:
148
153
155
157 drawing::color default_back_color() const noexcept override;
158 drawing::color default_fore_color() const noexcept override;
160
162
166 virtual bool allow_selection() const noexcept;
167
169 virtual void on_selected_index_changed(const event_args& e);
170
172 virtual void on_selected_value_changed(const event_args& e);
173
176 void set_selected_index(size_t value);
178
179 private:
180 std::shared_ptr<data> data_;
181 };
182 }
183}
Contains xtd::forms::application class.
Represents a boxed integer object.
Definition box_integer.h:50
Represents the base class for classes that contain event data, and provides a value to use for events...
Definition event_args.h:18
Represents an event.
Definition event.h:21
Defines the base class for controls, which are components with visual representation.
Definition control.h:79
Represents a collection of objects.
Definition arranged_element_collection.h:32
Represent the sorter class used by list_control::object_collection collection.
Definition list_control.h:33
void operator()(type_t first, type_t last)
sorter functor.
Definition list_control.h:43
Represent an item contained in the list_control::object_collection collection.
Definition list_control.h:30
item(const xtd::ustring &value, const std::any &tag)
Initializes a new instance of the item class with specified value and tag.
item()=default
Initializes a new instance of the item class.
item(const xtd::ustring &value)
Initializes a new instance of the item class with specified value.
static const item empty
Represents an empty item that value is equal to xtd::ustring::empty_string and tag has no vlaue.
Definition list_control.h:53
virtual const xtd::ustring & 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.h:25
Defines a generalized comparison method that a value type or class implements to create a type-specif...
Definition icomparable.h:17
Defines a generalized method that a value type or class implements to create a type-specific method f...
Definition iequatable.h:18
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes....
Definition object.h:32
Represents text as a sequence of UTF-8 code units.
Definition ustring.h:47
generic_event_handler<> event_handler
Represents the method that will handle an event that has no event data.
Definition event_handler.h:32
#define forms_export_
Define shared library export.
Definition forms_export.h:13
int_least32_t int32
Represents a 32-bit signed integer.
Definition types.h:131
The xtd::forms namespace contains classes for creating Windows-based applications that take full adva...
Definition xtd_about_box.h:12
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.h:10
Contains xtd::forms::style_sheets::control class.