xtd 1.0.0
Loading...
Searching...
No Matches
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 xtd::forms::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 [[nodiscard]] virtual auto checked() const -> bool;
87
91 [[nodiscard]] virtual auto check_state() const -> xtd::forms::check_state;
93
95
97 using xtd::forms::list_box::item::compare_to;
98 [[nodiscard]] auto compare_to(const item& value) const noexcept -> xtd::int32 override;
99 using xtd::forms::list_box::item::equals;
100 [[nodiscard]] auto equals(const item& value) const noexcept -> bool override;
102
103 private:
104 xtd::forms::check_state check_state_ = xtd::forms::check_state::unchecked;
105 };
106
108
111 using object_collection = layout::arranged_element_collection<item>;
112
115
117 using checked_item_collection = xtd::collections::generic::list<item>;
118
122
124
130
132
137 [[nodiscard]] auto checked_indices() const noexcept -> checked_index_collection;
138
142 [[nodiscard]] auto checked_items() const noexcept -> checked_item_collection;
143
147 [[nodiscard]] auto items() noexcept -> object_collection&;
151 [[nodiscard]] auto items() const noexcept -> const object_collection&;
154 auto items(const object_collection& value) -> const list_box&;
155
160 auto selected_index(xtd::usize value) -> list_control& override;
161
162 [[nodiscard]] auto selected_indices() const noexcept -> selected_index_collection override;
163
168 [[nodiscard]] auto selected_item() const noexcept -> const item&;
173 auto selected_item(const item& value) -> checked_list_box&;
174
179 [[nodiscard]] auto selected_items() const noexcept -> selected_object_collection;
180
181 using xtd::forms::list_box::text;
184 auto text(const xtd::string& value) -> xtd::forms::control& override;
186
188
192 auto begin_update() -> void;
193
196 auto end_update() -> void;
197
202 [[nodiscard]] auto get_item_checked(xtd::usize index) const -> bool;
203
208 [[nodiscard]] auto get_item_check_state(xtd::usize index) const -> xtd::forms::check_state;
209
213 [[nodiscard]] auto get_item_text(xtd::usize index) const -> const xtd::string&;
214
219 auto set_item_checked(xtd::usize index, bool checked) -> void;
220
227
231 auto set_item_text(xtd::usize index, const xtd::string& text) -> void;
233
235
239 [[nodiscard]] static auto create() -> checked_list_box;
243 [[nodiscard]] static auto create(const xtd::drawing::point& location) -> checked_list_box;
248 [[nodiscard]] static auto create(const xtd::drawing::point& location, const xtd::drawing::size& size) -> checked_list_box;
254 [[nodiscard]] static auto create(const xtd::drawing::point& location, const xtd::drawing::size& size, const xtd::string& name) -> checked_list_box;
258 [[nodiscard]] static auto create(const object_collection& items) -> checked_list_box;
263 [[nodiscard]] static auto create(const object_collection& items, const xtd::drawing::point& location) -> checked_list_box;
269 [[nodiscard]] static auto create(const object_collection& items, const xtd::drawing::point& location, const xtd::drawing::size& size) -> checked_list_box;
276 [[nodiscard]] static auto create(const object_collection& items, const xtd::drawing::point& location, const xtd::drawing::size& size, const xtd::string& name) -> checked_list_box;
281 [[nodiscard]] static auto create(const object_collection& items, xtd::usize selected_index) -> checked_list_box;
287 [[nodiscard]] static auto create(const object_collection& items, xtd::usize selected_index, const xtd::drawing::point& location) -> checked_list_box;
294 [[nodiscard]] static auto create(const object_collection& items, xtd::usize selected_index, const xtd::drawing::point& location, const xtd::drawing::size& size) -> checked_list_box;
302 [[nodiscard]] static auto create(const object_collection& items, xtd::usize selected_index, const xtd::drawing::point& location, const xtd::drawing::size& size, const xtd::string& name) -> checked_list_box;
306 [[nodiscard]] static auto create(const xtd::forms::control& parent) -> checked_list_box;
311 [[nodiscard]] static auto create(const xtd::forms::control& parent, const xtd::drawing::point& location) -> checked_list_box;
317 [[nodiscard]] static auto create(const xtd::forms::control& parent, const xtd::drawing::point& location, const xtd::drawing::size& size) -> checked_list_box;
324 [[nodiscard]] static auto create(const xtd::forms::control& parent, const xtd::drawing::point& location, const xtd::drawing::size& size, const xtd::string& name) -> checked_list_box;
329 [[nodiscard]] static auto create(const xtd::forms::control& parent, const object_collection& items) -> checked_list_box;
335 [[nodiscard]] static auto create(const xtd::forms::control& parent, const object_collection& items, const xtd::drawing::point& location) -> checked_list_box;
342 [[nodiscard]] static auto create(const xtd::forms::control& parent, const object_collection& items, const xtd::drawing::point& location, const xtd::drawing::size& size) -> checked_list_box;
350 [[nodiscard]] static auto create(const xtd::forms::control& parent, const object_collection& items, const xtd::drawing::point& location, const xtd::drawing::size& size, const xtd::string& name) -> checked_list_box;
356 [[nodiscard]] static auto create(const xtd::forms::control& parent, const object_collection& items, xtd::usize selected_index) -> checked_list_box;
363 [[nodiscard]] static auto create(const xtd::forms::control& parent, const object_collection& items, xtd::usize selected_index, const xtd::drawing::point& location) -> checked_list_box;
371 [[nodiscard]] static auto create(const xtd::forms::control& parent, const object_collection& items, xtd::usize selected_index, const xtd::drawing::point& location, const xtd::drawing::size& size) -> checked_list_box;
380 [[nodiscard]] static auto create(const xtd::forms::control& parent, const object_collection& items, xtd::usize selected_index, const xtd::drawing::point& location, const xtd::drawing::size& size, const xtd::string& name) -> checked_list_box;
382
384
390
391 protected:
393
395 [[nodiscard]] auto allow_selection() const noexcept -> bool override;
396 [[nodiscard]] auto create_params() const noexcept -> xtd::forms::create_params override;
398
400
402 auto on_handle_created(const event_args& e) -> void override;
403
406 virtual auto on_item_check(item_check_event_args& e) -> void;
407
408 auto on_selected_value_changed(const event_args& e) -> void override;
409 auto wnd_proc(message& message) -> void override;
411
412 private:
413 auto wm_command_control(message& message) -> void;
414 auto wm_mouse_double_click(message& message) -> void;
415 auto wm_mouse_down(message& message) -> void;
416 auto wm_mouse_up(message& message) -> void;
417
418 xtd::sptr<data> data_;
419 };
420 }
421}
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
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 auto check_state() const -> xtd::forms::check_state
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.
virtual auto checked() const -> bool
Gets a value indicating whether the item is in the checked state.
item(const xtd::string &value, xtd::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.
item(const xtd::string &value, xtd::forms::check_state check_state)
Initializes a new instance of the item class with specified value and checked state.
auto get_item_checked(xtd::usize index) const -> bool
Returns a value indicating whether the specified item is checked.
auto selected_index(xtd::usize value) -> list_control &override
When overridden in a derived class, Sets the zero-based index of the currently selected item.
xtd::collections::generic::list< item > selected_object_collection
Represents the collection of selected items in the list_box.
Definition checked_list_box.hpp:120
auto checked_items() const noexcept -> checked_item_collection
Collection of checked items in this checked_list_box.
auto checked_indices() const noexcept -> checked_index_collection
Collection of checked indexes in this checked_list_box.
auto end_update() -> void
Resumes painting the checked_list_box control after painting is suspended by the begin_update method.
auto selected_items() const noexcept -> selected_object_collection
Gets a collection containing the currently selected items in the list_box.
xtd::event< checked_list_box, xtd::forms::item_check_event_handler > item_check
Occurs when the checked state of an item changes.
Definition checked_list_box.hpp:388
checked_list_box()
Initializes a new instance of the checked_list_box class.
auto on_selected_value_changed(const event_args &e) -> void override
Raises the list_control::selected_value_changed event.
auto get_item_check_state(xtd::usize index) const -> xtd::forms::check_state
Returns a value indicating the check state of the current item.
auto on_handle_created(const event_args &e) -> void override
Raises the xtd::forms::control::handle_created event.
layout::arranged_element_collection< item > object_collection
Represents the collection of items in a checked_list_box.
Definition checked_list_box.hpp:111
auto create_params() const noexcept -> xtd::forms::create_params override
Gets the required creation parameters when the control handle is created.
auto get_item_text(xtd::usize index) const -> const xtd::string &
Returns the text value of the current item.
auto selected_indices() const noexcept -> selected_index_collection override
Gets a collection that contains the zero-based indexes of all currently selected items in the list_bo...
auto set_item_text(xtd::usize index, const xtd::string &text) -> void
Sets the text value of the item at the specified index.
virtual auto on_item_check(item_check_event_args &e) -> void
Raises the checked_list_box::item_check event.
static auto create() -> checked_list_box
A factory to create an xtd::forms::checked_list_box.
auto set_item_checked(xtd::usize index, bool checked) -> void
Sets check_state for the item at the specified index to checked.
auto selected_item() const noexcept -> const item &
Gets the currently selected item in the checked_list_box.
auto text(const xtd::string &value) -> xtd::forms::control &override
Sets the text associated with this control.
xtd::collections::generic::list< xtd::usize > checked_index_collection
Encapsulates the collection of indexes of checked items (including items in an indeterminate state).
Definition checked_list_box.hpp:114
auto items() noexcept -> object_collection &
Gets the collection of items in this checked_list_box.
auto set_item_check_state(xtd::usize index, xtd::forms::check_state check_state) -> void
Sets the check state of the item at the specified index.
auto begin_update() -> void
Maintains performance while items are added to the checked_list_box one at a time by preventing the c...
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
auto wnd_proc(message &message) -> void override
Processes Windows messages.
auto allow_selection() const noexcept -> bool override
Gets a value indicating whether the list enables selection of list items.
Defines the base class for controls, which are components with visual representation.
Definition control.hpp:81
virtual auto size() const noexcept -> xtd::drawing::size
Gets the height and width of the control.
virtual auto parent() const noexcept -> std::optional< xtd::forms::control_ref >
Gets the parent container of the control.
virtual auto tag() const noexcept -> const xtd::any_object &
Gets the object that contains data about the control.
virtual auto name() const noexcept -> const xtd::string &
Gets the name of the control.
virtual auto location() const noexcept -> xtd::drawing::point
Gets the coordinates of the upper-left corner of the control relative to the upper-left corner of its...
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 standard Windows list box.
Definition list_box.hpp:33
xtd::array< xtd::usize > 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.
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:22
Defines a generalized method that a value type or class implements to create a type-specific method f...
Definition iequatable.hpp:23
xtd::delegate< void(xtd::object &sender, xtd::forms::item_check_event_args &e)> item_check_event_handler
Represents the method that will handle the xtd::forms::checked_list_box::item_check event of a xtd::f...
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
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
check_state
Specifies the state of a control, such as a check box, that can be checked, unchecked,...
Definition check_state.hpp:23
Contains xtd::forms::item_check_event_handler event handler.
Contains xtd::forms::list_box control.
The xtd::collections namespace contains interfaces and classes that define various collections of obj...
Definition any_pair.hpp:10
The xtd::drawing namespace provides access to GDI+ basic graphics functionality. More advanced functi...
Definition actions_system_images.hpp:10
The xtd::forms::layout namespace contains classes for implementing layout behaviors in your form or c...
Definition arranged_element_collection.hpp:25
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 auto data() const noexcept -> const_pointer
Gets direct access to the underlying contiguous storage.
Definition read_only_span.hpp:197
Implements a Windows message.
Definition message.hpp:33