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 {
37 struct data;
38
39 public:
41 class item : public list_box::item, public xtd::icomparable<item>, public xtd::iequatable<item> {
42 public:
44
47 item() = default;
50 item(const xtd::string& value); // Can't be explicit by design.
54 item(const xtd::string& value, bool checked);
62 item(const xtd::string& value, const std::any& tag);
67 item(const xtd::string& value, bool checked, const std::any& tag);
72 item(const xtd::string& value, forms::check_state check_state, const std::any& tag);
74
76 item(const char* value); // Can't be explicit by design.
77 item(const item& value) = default;
78 item& operator =(const item& value) = default;
80
82
86 virtual bool checked() const;
87
93
95
97 using list_box::item::compare_to;
98 int32 compare_to(const item& value) const noexcept override;
99 using list_box::item::equals;
100 bool equals(const item& value) const noexcept override;
102
103 private:
104 forms::check_state check_state_ = forms::check_state::unchecked;
105 };
106
108
112
114 using checked_index_collection = std::vector<size_t>;
115
117 using checked_item_collection = std::vector<item>;
118
120 using selected_object_collection = std::vector<item>;
122
124
130
133 checked_list_box(const checked_list_box&) = default;
134 checked_list_box& operator =(const checked_list_box&) = default;
136
138
144
148 checked_item_collection checked_items() const noexcept;
149
153 object_collection& items() noexcept;
157 const object_collection& items() const noexcept;
160 const list_box& items(const object_collection& items);
161
162 using list_box::selected_index;
166 list_control& selected_index(size_t selected_index) override;
167
168 std::vector<size_t> selected_indices() const noexcept override;
169
174 const item& selected_item() const noexcept;
179 checked_list_box& selected_item(const item& selected_item);
180
185 selected_object_collection selected_items() const noexcept;
186
187 using list_box::text;
190 control& text(const xtd::string& text) override;
192
194
198 void begin_update();
199
202 void end_update();
203
208 bool get_item_checked(size_t index) const;
209
214 forms::check_state get_item_check_state(size_t index) const;
215
219 const xtd::string& get_item_text(size_t index) const;
220
225 void set_item_checked(size_t index, bool checked);
226
232 void set_item_check_state(size_t index, forms::check_state check_state);
233
237 void set_item_text(size_t index, const xtd::string& text);
239
241
245 static checked_list_box create();
249 static checked_list_box create(const drawing::point& location);
254 static checked_list_box create(const drawing::point& location, const drawing::size& size);
260 static checked_list_box create(const drawing::point& location, const drawing::size& size, const xtd::string& name);
264 static checked_list_box create(const object_collection& items);
269 static checked_list_box create(const object_collection& items, const drawing::point& location);
275 static checked_list_box create(const object_collection& items, const drawing::point& location, const drawing::size& size);
282 static checked_list_box create(const object_collection& items, const drawing::point& location, const drawing::size& size, const xtd::string& name);
287 static checked_list_box create(const object_collection& items, size_t selected_index);
293 static checked_list_box create(const object_collection& items, size_t selected_index, const drawing::point& location);
300 static checked_list_box create(const object_collection& items, size_t selected_index, const drawing::point& location, const drawing::size& size);
308 static checked_list_box create(const object_collection& items, size_t selected_index, const drawing::point& location, const drawing::size& size, const xtd::string& name);
312 static checked_list_box create(const control& parent);
317 static checked_list_box create(const control& parent, const drawing::point& location);
323 static checked_list_box create(const control& parent, const drawing::point& location, const drawing::size& size);
330 static checked_list_box create(const control& parent, const drawing::point& location, const drawing::size& size, const xtd::string& name);
335 static checked_list_box create(const control& parent, const object_collection& items);
341 static checked_list_box create(const control& parent, const object_collection& items, const drawing::point& location);
348 static checked_list_box create(const control& parent, const object_collection& items, const drawing::point& location, const drawing::size& size);
356 static checked_list_box create(const control& parent, const object_collection& items, const drawing::point& location, const drawing::size& size, const xtd::string& name);
362 static checked_list_box create(const control& parent, const object_collection& items, size_t selected_index);
369 static checked_list_box create(const control& parent, const object_collection& items, size_t selected_index, const drawing::point& location);
377 static checked_list_box create(const control& parent, const object_collection& items, size_t selected_index, const drawing::point& location, const drawing::size& size);
386 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::string& name);
388
390
396
397 protected:
399
401 bool allow_selection() const noexcept override;
402 forms::create_params create_params() const noexcept override;
404
406
412 xtd::uptr<xtd::object> clone() const override;
413
414 void on_handle_created(const event_args& e) override;
415
418 virtual void on_item_check(item_check_event_args& e);
419
420 void on_selected_value_changed(const event_args& e) override;
421 void wnd_proc(message& message) override;
423
424 private:
425 void on_items_item_added(size_t pos, const item& item);
426 void on_items_item_removed(size_t pos, const item& item);
427 void on_items_item_updated(size_t pos, const item& item);
428 void wm_command_control(message& message);
429 void wm_mouse_double_click(message& message);
430 void wm_mouse_down(message& message);
431 void wm_mouse_up(message& message);
432
433 xtd::sptr<data> data_;
434 };
435 }
436}
Represents text as a sequence of character units.
Definition basic_string.h:79
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:41
item(const xtd::string &value, bool checked)
Initializes a new instance of the item class with specified value and check state.
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::string &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::string &value)
Initializes a new instance of the item class with specified value.
item(const xtd::string &value, forms::check_state check_state)
Initializes a new instance of the item class with specified value and checked state.
item(const xtd::string &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::string &value, const std::any &tag)
Initializes a new instance of the item class with specified value and tag.
Displays a xtd::forms::list_box in which a check box is displayed to the left of each item.
Definition checked_list_box.h:36
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:114
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:117
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:120
Defines the base class for controls, which are components with visual representation.
Definition control.h:81
Encapsulates the information needed when creating a control.
Definition create_params.h:29
Provides data for the item_check event of the checked_list_box and list_view controls.
Definition item_check_event_args.h:30
Represents a collection of objects.
Definition arranged_element_collection.h:34
Represents a standard Windows list box.
Definition list_box.h:33
Provides a common implementation of members for the list_box, choice and combo_box classes.
Definition list_control.h:27
Implements a Windows message.
Definition message.h:28
Defines a generalized comparison method that a value type or class implements to create a type-specif...
Definition icomparable.h:21
Defines a generalized method that a value type or class implements to create a type-specific method f...
Definition iequatable.h:22
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:25
#define forms_export_
Define shared library export.
Definition forms_export.h:13
int32_t int32
Represents a 32-bit signed integer.
Definition int32.h:23
std::unique_ptr< type_t > uptr
The xtd::uptr object is a unique pointer.
Definition uptr.h:25
size_t size
Represents a size of any object in bytes.
Definition size.h:23
std::shared_ptr< type_t > sptr
The xtd::sptr object is a shared pointer.
Definition sptr.h:25
check_state
Specifies the state of a control, such as a check box, that can be checked, unchecked,...
Definition check_state.h:23
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