xtd 0.2.0
checked_list_box.h
Go to the documentation of this file.
1 #pragma once
6 #include "list_box.h"
7 #include <xtd/iequatable>
8 
10 namespace xtd {
12  namespace forms {
34  class forms_export_ checked_list_box : public list_box {
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 
89  virtual forms::check_state check_state() const;
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:
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 
130 
135  checked_index_collection checked_indices() const noexcept;
136 
140  checked_item_collection checked_items() const noexcept;
141 
145  object_collection& items() noexcept;
149  const object_collection& items() const noexcept;
152  const list_box& items(const object_collection& items);
153 
154  using list_box::selected_index;
158  list_control& selected_index(size_t selected_index) override;
159 
160  std::vector<size_t> selected_indices() const noexcept override;
161 
166  const item& selected_item() const noexcept;
171  checked_list_box& selected_item(const item& selected_item);
172 
177  selected_object_collection selected_items() const noexcept;
178 
179  using list_box::text;
182  control& text(const xtd::ustring& text) override;
184 
186 
190  void begin_update();
191 
192  using control::create;
199  static checked_list_box create(const object_collection& items, size_t selected_index = object_collection::npos, const drawing::point& location = {-1, -1}, const drawing::size& size = {-1, -1}, const xtd::ustring& name = xtd::ustring::empty_string);
207  static checked_list_box create(const control& parent, const object_collection& items, size_t selected_index, const drawing::point& location = {-1, -1}, const drawing::size& size = {-1, -1}, const xtd::ustring& name = xtd::ustring::empty_string);
208 
211  void end_update();
212 
217  bool get_item_checked(size_t index) const;
218 
223  forms::check_state get_item_check_state(size_t index) const;
224 
228  const xtd::ustring& get_item_text(size_t index) const;
229 
234  void set_item_checked(size_t index, bool checked);
235 
241  void set_item_check_state(size_t index, forms::check_state check_state);
242 
246  void set_item_text(size_t index, const xtd::ustring& text);
248 
250 
256 
257  protected:
259 
261  bool allow_selection() const noexcept override;
262  forms::create_params create_params() const noexcept override;
264 
266 
268  void on_handle_created(const event_args& e) override;
269 
272  virtual void on_item_check(item_check_event_args& e);
273 
274  void on_selected_value_changed(const event_args& e) override;
275  void wnd_proc(message& message) override;
277 
278  private:
279  void on_items_item_added(size_t pos, const item& item);
280  void on_items_item_removed(size_t pos, const item& item);
281  void on_items_item_updated(size_t pos, const item& item);
282  void wm_command_control(message& message);
283  void wm_mouse_double_click(message& message);
284  void wm_mouse_down(message& message);
285  void wm_mouse_up(message& message);
286 
287  std::shared_ptr<data> data_;
288  };
289  }
290 }
Represents a standard Windows list box.
Definition: list_box.h:31
check_state
Specifies the state of a control, such as a check box, that can be checked, unchecked, or set to an indeterminate state.
Definition: check_state.h:21
Contains xtd::forms::item_check_event_handler event handler.
The control is unchecked.
std::vector< item > selected_object_collection
Represents the collection of selected items in the list_box.
Definition: checked_list_box.h:118
std::vector< item > checked_item_collection
Encapsulates the collection of checked items, including items in an indeterminate state...
Definition: checked_list_box.h:115
Represents the base class for classes that contain event data, and provides a value to use for events...
Definition: event_args.h:18
Defines a generalized comparison method that a value type or class implements to create a type-specif...
Definition: icomparable.h:17
The button has a checked or latched appearance. Use this appearance to show that a toggle button has ...
Represents an ordered pair of integer x- and y-coordinates that defines a point in a two-dimensional ...
Definition: point.h:54
Stores an ordered pair of integers, which specify a height and width.
Definition: size.h:31
Represent an item contained in the checked_list_box::object_collection collection.
Definition: checked_list_box.h:39
The xtd namespace contains all fundamental classes to access Hardware, Os, System, and more.
Definition: system_report.h:17
Contains xtd::forms::list_box control.
Encapsulates the information needed when creating a control.
Definition: create_params.h:27
Represents text as a sequence of UTF-8 code units.
Definition: ustring.h:46
Represents a collection of objects.
Definition: arranged_element_collection.h:31
Represents an event.
Definition: event.h:21
Defines a generalized method that a value type or class implements to create a type-specific method f...
Definition: iequatable.h:18
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
Indicates that all styles except allow_binary_specifier, allow_octal_specifier and allow_hex_specifie...
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
Implements a Windows message.
Definition: message.h:26
Provides a common implementation of members for the list_box, choice and combo_box classes...
Definition: list_control.h:23
Defines the base class for controls, which are components with visual representation.
Definition: control.h:78
int_least32_t int32
Represents a 32-bit signed integer.
Definition: types.h:129
The xtd::forms namespace contains classes for creating Windows-based applications that take full adva...
Definition: about_box.h:13
static const ustring empty_string
Represents the empty string.
Definition: ustring.h:53
Specifies that both the x and y coordinates of the control are defined.
Provides data for the item_check event of the checked_list_box and list_view controls.
Definition: item_check_event_args.h:27
event< checked_list_box, item_check_event_handler > item_check
Occurs when the checked state of an item changes.
Definition: checked_list_box.h:254
The xtd::forms::status_bar_panel displays text in the standard font.
size_t size
Represents a size of any object in bytes.
Definition: types.h:195