xtd 0.2.0
Loading...
Searching...
No Matches
checked_list_box.h
Go to the documentation of this file.
1
4#pragma once
6#include "list_box.h"
7#include <xtd/iequatable>
8
10namespace xtd {
12 namespace forms {
35 struct data;
36
37 public:
39 class item : public list_box::item, public xtd::icomparable<item>, public xtd::iequatable<item> {
40 public:
42
45 item() = default;
48 item(const xtd::ustring& value); // Can't be explicit by design.
52 item(const xtd::ustring& value, bool checked);
60 item(const xtd::ustring& value, const std::any& tag);
65 item(const xtd::ustring& value, bool checked, const std::any& tag);
70 item(const xtd::ustring& value, forms::check_state check_state, const std::any& tag);
72
74 item(const char* value); // Can't be explicit by design.
75 item(const item& value) = default;
76 item& operator =(const item& value) = default;
78
80
84 virtual bool checked() const;
85
91
93
95 using list_box::item::compare_to;
96 int32 compare_to(const item& value) const noexcept override;
97 using list_box::item::equals;
98 bool equals(const item& value) const noexcept override;
100
101 private:
102 forms::check_state check_state_ = forms::check_state::unchecked;
103 };
104
106
110
112 using checked_index_collection = std::vector<size_t>;
113
115 using checked_item_collection = std::vector<item>;
116
118 using selected_object_collection = std::vector<item>;
120
122
128
131 checked_list_box(const checked_list_box&) = default;
132 checked_list_box& operator =(const checked_list_box&) = default;
134
136
142
146 checked_item_collection checked_items() const noexcept;
147
151 object_collection& items() noexcept;
155 const object_collection& items() const noexcept;
158 const list_box& items(const object_collection& items);
159
160 using list_box::selected_index;
164 list_control& selected_index(size_t selected_index) override;
165
166 std::vector<size_t> selected_indices() const noexcept override;
167
172 const item& selected_item() const noexcept;
177 checked_list_box& selected_item(const item& selected_item);
178
183 selected_object_collection selected_items() const noexcept;
184
185 using list_box::text;
188 control& text(const xtd::ustring& text) override;
190
192
196 void begin_update();
197
200 void end_update();
201
206 bool get_item_checked(size_t index) const;
207
212 forms::check_state get_item_check_state(size_t index) const;
213
217 const xtd::ustring& get_item_text(size_t index) const;
218
223 void set_item_checked(size_t index, bool checked);
224
230 void set_item_check_state(size_t index, forms::check_state check_state);
231
235 void set_item_text(size_t index, const xtd::ustring& text);
237
239
243 static checked_list_box create();
247 static checked_list_box create(const drawing::point& location);
252 static checked_list_box create(const drawing::point& location, const drawing::size& size);
258 static checked_list_box create(const drawing::point& location, const drawing::size& size, const xtd::ustring& name);
262 static checked_list_box create(const object_collection& items);
267 static checked_list_box create(const object_collection& items, const drawing::point& location);
273 static checked_list_box create(const object_collection& items, const drawing::point& location, const drawing::size& size);
280 static checked_list_box create(const object_collection& items, const drawing::point& location, const drawing::size& size, const xtd::ustring& name);
285 static checked_list_box create(const object_collection& items, size_t selected_index);
291 static checked_list_box create(const object_collection& items, size_t selected_index, const drawing::point& location);
298 static checked_list_box create(const object_collection& items, size_t selected_index, const drawing::point& location, const drawing::size& size);
306 static checked_list_box create(const object_collection& items, size_t selected_index, const drawing::point& location, const drawing::size& size, const xtd::ustring& name);
310 static checked_list_box create(const control& parent);
315 static checked_list_box create(const control& parent, const drawing::point& location);
321 static checked_list_box create(const control& parent, const drawing::point& location, const drawing::size& size);
328 static checked_list_box create(const control& parent, const drawing::point& location, const drawing::size& size, const xtd::ustring& name);
333 static checked_list_box create(const control& parent, const object_collection& items);
339 static checked_list_box create(const control& parent, const object_collection& items, const drawing::point& location);
346 static checked_list_box create(const control& parent, const object_collection& items, const drawing::point& location, const drawing::size& size);
354 static checked_list_box create(const control& parent, const object_collection& items, const drawing::point& location, const drawing::size& size, const xtd::ustring& name);
360 static checked_list_box create(const control& parent, const object_collection& items, size_t selected_index);
367 static checked_list_box create(const control& parent, const object_collection& items, size_t selected_index, const drawing::point& location);
375 static checked_list_box create(const control& parent, const object_collection& items, size_t selected_index, const drawing::point& location, const drawing::size& size);
384 static checked_list_box create(const control& parent, const object_collection& items, size_t selected_index, const drawing::point& location, const drawing::size& size, const xtd::ustring& name);
386
388
394
395 protected:
397
399 bool allow_selection() const noexcept override;
400 forms::create_params create_params() const noexcept override;
402
404
410 std::unique_ptr<xtd::object> clone() const override;
411
412 void on_handle_created(const event_args& e) override;
413
416 virtual void on_item_check(item_check_event_args& e);
417
418 void on_selected_value_changed(const event_args& e) override;
419 void wnd_proc(message& message) override;
421
422 private:
423 void on_items_item_added(size_t pos, const item& item);
424 void on_items_item_removed(size_t pos, const item& item);
425 void on_items_item_updated(size_t pos, const item& item);
426 void wm_command_control(message& message);
427 void wm_mouse_double_click(message& message);
428 void wm_mouse_down(message& message);
429 void wm_mouse_up(message& message);
430
431 std::shared_ptr<data> data_;
432 };
433 }
434}
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
Represent an item contained in the checked_list_box::object_collection collection.
Definition checked_list_box.h:39
item(const xtd::ustring &value, bool checked, const std::any &tag)
Initializes a new instance of the item class with specified value, check state and tag.
item(const xtd::ustring &value, bool checked)
Initializes a new instance of the item class with specified value and check state.
item(const xtd::ustring &value, forms::check_state check_state, const std::any &tag)
Initializes a new instance of the item class with specified value, check state and tag.
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.
virtual bool checked() const
Gets a value indicating whether the item is in the checked state.
virtual forms::check_state check_state() const
Gets the state of the item.
item(const xtd::ustring &value)
Initializes a new instance of the item class with specified value.
item(const xtd::ustring &value, forms::check_state check_state)
Initializes a new instance of the item class with specified value and checked state.
Displays a xtd::forms::list_box in which a check box is displayed to the left of each item.
Definition checked_list_box.h:34
std::vector< size_t > checked_index_collection
Encapsulates the collection of indexes of checked items (including items in an indeterminate state)
Definition checked_list_box.h:112
checked_list_box()
Initializes a new instance of the checked_list_box class.
std::vector< item > checked_item_collection
Encapsulates the collection of checked items, including items in an indeterminate state,...
Definition checked_list_box.h:115
checked_index_collection checked_indices() const noexcept
Collection of checked indexes in this checked_list_box.
std::vector< item > selected_object_collection
Represents the collection of selected items in the list_box.
Definition checked_list_box.h:118
Defines the base class for controls, which are components with visual representation.
Definition control.h:79
Encapsulates the information needed when creating a control.
Definition create_params.h:27
Provides data for the item_check event of the checked_list_box and list_view controls.
Definition item_check_event_args.h:28
Represents a collection of objects.
Definition arranged_element_collection.h:32
Represents a standard Windows list box.
Definition list_box.h:31
Provides a common implementation of members for the list_box, choice and combo_box classes.
Definition list_control.h:25
Implements a Windows message.
Definition message.h:26
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
Represents text as a sequence of UTF-8 code units.
Definition ustring.h:47
delegate< void(object &sender, item_check_event_args &e)> item_check_event_handler
Represents the method that will handle the ItemCheck event of a CheckedListBox or ListView control.
Definition item_check_event_handler.h:23
#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
size_t size
Represents a size of any object in bytes.
Definition types.h:197
check_state
Specifies the state of a control, such as a check box, that can be checked, unchecked,...
Definition check_state.h:21
Contains xtd::forms::item_check_event_handler event handler.
Contains xtd::forms::list_box control.
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