xtd 0.2.0
checked_list_box.hpp
Go to the documentation of this file.
1
4#pragma once
6#include "list_box.hpp"
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 xtd::any_object& tag);
67 item(const xtd::string& value, bool checked, const xtd::any_object& 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:
105 };
106
108
112
115
118
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
149
157 const object_collection& items() const noexcept;
161
167
169
174 const item& selected_item() const noexcept;
180
186
187 using list_box::text;
190 control& text(const xtd::string& text) override;
192
194
199
203
208 bool get_item_checked(size_t index) const;
209
215
219 const xtd::string& get_item_text(size_t index) const;
220
225 void set_item_checked(size_t index, bool checked);
226
233
237 void set_item_text(size_t index, const xtd::string& text);
239
241
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);
282 static checked_list_box create(const object_collection& items, const drawing::point& location, const drawing::size& size, const xtd::string& name);
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);
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);
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);
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
419
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}
Represent a polymorphic wrapper capable of holding any type.
Definition any_object.hpp:29
Represents a strongly typed list of objects that can be accessed by index. Provides methods to search...
Definition list.hpp:79
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
Represent an item contained in the checked_list_box::object_collection collection.
Definition checked_list_box.hpp: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.
item(const xtd::string &value, const xtd::any_object &tag)
Initializes a new instance of the item class with specified value and tag.
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, bool checked, const xtd::any_object &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, forms::check_state check_state, const xtd::any_object &tag)
Initializes a new instance of the item class with specified value, check state and tag.
xtd::collections::generic::list< item > selected_object_collection
Represents the collection of selected items in the list_box.
Definition checked_list_box.hpp:120
event< checked_list_box, item_check_event_handler > item_check
Occurs when the checked state of an item changes.
Definition checked_list_box.hpp:394
void end_update()
Resumes painting the checked_list_box control after painting is suspended by the begin_update method.
virtual void on_item_check(item_check_event_args &e)
Raises the checked_list_box::item_check event.
selected_object_collection selected_items() const noexcept
Gets a collection containing the currently selected items in the list_box.
void set_item_check_state(size_t index, forms::check_state check_state)
Sets the check state of the item at the specified index.
bool get_item_checked(size_t index) const
Returns a value indicating whether the specified item is checked.
selected_index_collection selected_indices() const noexcept override
Gets a collection that contains the zero-based indexes of all currently selected items in the list_bo...
checked_list_box()
Initializes a new instance of the checked_list_box class.
list_control & selected_index(size_t selected_index) override
When overridden in a derived class, Sets the zero-based index of the currently selected item.
forms::check_state get_item_check_state(size_t index) const
Returns a value indicating the check state of the current item.
layout::arranged_element_collection< item > object_collection
Represents the collection of items in a checked_list_box.
Definition checked_list_box.hpp:111
void wnd_proc(message &message) override
Processes Windows messages.
object_collection & items() noexcept
Gets the collection of items in this checked_list_box.
void begin_update()
Maintains performance while items are added to the checked_list_box one at a time by preventing the c...
void set_item_checked(size_t index, bool checked)
Sets check_state for the item at the specified index to checked.
const xtd::string & get_item_text(size_t index) const
Returns the text value of the current item.
void set_item_text(size_t index, const xtd::string &text)
Sets the text value of the item at the specified index.
const item & selected_item() const noexcept
Gets the currently selected item in the checked_list_box.
static checked_list_box create()
A factory to create an xtd::forms::checked_list_box.
bool allow_selection() const noexcept override
Gets a value indicating whether the list enables selection of list items.
checked_index_collection checked_indices() const noexcept
Collection of checked indexes in this checked_list_box.
control & text(const xtd::string &text) override
Sets the text associated with this control.
checked_item_collection checked_items() const noexcept
Collection of checked items in this checked_list_box.
void on_handle_created(const event_args &e) override
Raises the xtd::forms::control::handle_created event.
xtd::uptr< xtd::object > clone() const override
Creates a new object that is a copy of the current instance.
xtd::collections::generic::list< item > checked_item_collection
Encapsulates the collection of checked items, including items in an indeterminate state,...
Definition checked_list_box.hpp:117
forms::create_params create_params() const noexcept override
Gets the required creation parameters when the control handle is created.
void on_selected_value_changed(const event_args &e) override
Raises the list_control::selected_value_changed event.
xtd::collections::generic::list< size_t > checked_index_collection
Encapsulates the collection of indexes of checked items (including items in an indeterminate state)
Definition checked_list_box.hpp:114
Defines the base class for controls, which are components with visual representation.
Definition control.hpp:81
virtual xtd::any_object tag() const noexcept
Gets the object that contains data about the control.
virtual const xtd::string & name() const noexcept
Gets the name of the control.
virtual std::optional< control_ref > parent() const noexcept
Gets the parent container of the control.
Provides data for the item_check event of the checked_list_box and list_view controls.
Definition item_check_event_args.hpp:30
Represents a collection of objects.
Definition arranged_element_collection.hpp:35
xtd::array< xtd::size > selected_index_collection
Represents the collection containing the indexes to the selected items in a list_box.
Definition list_box.hpp:41
list_box()
Initializes a new instance of the list_box class.
Represent an item contained in the list_control::object_collection collection.
Definition list_control.hpp:32
Provides a common implementation of members for the list_box, choice and combo_box classes.
Definition list_control.hpp:27
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
xtd::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.hpp:28
#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
int32_t int32
Represents a 32-bit signed integer.
Definition int32.hpp:23
xtd::unique_ptr_object< type_t > uptr
The xtd::uptr object is a unique pointer.
Definition uptr.hpp:25
check_state
Specifies the state of a control, such as a check box, that can be checked, unchecked,...
Definition check_state.hpp:23
@ checked
The button has a checked or latched appearance. Use this appearance to show that a toggle button has ...
Definition button_state.hpp:31
@ e
The E key.
Definition keys.hpp:207
@ location
Specifies that both the x and y coordinates of the control are defined.
Definition bounds_specified.hpp:30
@ size
Specifies that both the width and height property values of the control are defined.
Definition bounds_specified.hpp:36
@ unchecked
The control is unchecked.
Definition check_state.hpp:25
Contains xtd::forms::item_check_event_handler event handler.
Contains xtd::forms::list_box control.
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
constexpr const_pointer data() const noexcept
Gets direct access to the underlying contiguous storage.
Definition read_only_span.hpp:201
Implements a Windows message.
Definition message.hpp:33