xtd 0.2.0
list_box.h
Go to the documentation of this file.
1 #pragma once
6 #include "border_sides.h"
7 #include "border_style.h"
8 #include "list_control.h"
9 #include "selection_mode.h"
10 
12 namespace xtd {
14  namespace forms {
31  class forms_export_ list_box : public list_control {
32  struct data;
33 
34  public:
36 
39  using selected_index_collection = std::vector<size_t>;
40 
42  using selected_object_collection = std::vector<item>;
44 
46 
49  list_box();
51 
53 
57  virtual forms::border_sides border_sides() const noexcept;
61 
64  virtual forms::border_style border_style() const noexcept;
69 
73  object_collection& items() noexcept;
76  const object_collection& items() const noexcept;
81  const list_box& items(const object_collection& items);
82 
83  using list_control::selected_index;
87  list_control& selected_index(size_t selected_index) override;
88 
93  virtual selected_index_collection selected_indices() const noexcept;
94 
99  const item& selected_item() const noexcept;
105  list_box& selected_item(const item& selected_item);
106 
111  selected_object_collection selected_items() const noexcept;
112 
116  virtual forms::selection_mode selection_mode() const noexcept;
122 
126  virtual bool sorted() const noexcept;
131  virtual list_box& sorted(bool sorted);
132 
133  using list_control::text;
136  control& text(const xtd::ustring& text) override;
138 
140 
144  void begin_update();
145 
146  using control::create;
153  static 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);
161  static list_box create(const control& parent, 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);
162 
165  void end_update();
167 
168  protected:
170 
172  bool allow_selection() const noexcept override;
173  forms::create_params create_params() const noexcept override;
174  drawing::color default_back_color() const noexcept override;
175  drawing::color default_fore_color() const noexcept override;
179 
181  void on_handle_created(const event_args& e) override;
182  void on_selected_value_changed(const event_args& e) override;
183  void wnd_proc(message& message) override;
185 
186  private:
187  void on_items_item_added(size_t pos, const item& item);
188  void on_items_item_removed(size_t pos, const item& item);
189  void on_items_item_updated(size_t pos, const item& item);
190  void wm_command_control(message& message);
191  void wm_mouse_double_click(message& message);
192  void wm_mouse_down(message& message);
193  void wm_mouse_up(message& message);
194 
195  std::shared_ptr<data> data_;
196  };
197  }
198 }
Represents a standard Windows list box.
Definition: list_box.h:31
Contains xtd::forms::selection_mode enum class.
Represents the base class for classes that contain event data, and provides a value to use for events...
Definition: event_args.h:18
Contains xtd::forms::layout::arranged_element_collection collection.
Represent an item contained in the list_control::object_collection collection.
Definition: list_control.h:28
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
The xtd namespace contains all fundamental classes to access Hardware, Os, System, and more.
Definition: system_report.h:17
Encapsulates the information needed when creating a control.
Definition: create_params.h:27
std::vector< item > selected_object_collection
Represents the collection of selected items in the list_box.
Definition: list_box.h:42
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
std::vector< size_t > selected_index_collection
Represents the collection containing the indexes to the selected items in a list_box.
Definition: list_box.h:39
border_sides
Specifies how a control anchors to the edges of its container.
Definition: border_sides.h:21
border_style
Specifies the border style for a control.
Definition: border_style.h:20
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
Contains xtd::forms::border_sides enum class.
Defines the base class for controls, which are components with visual representation.
Definition: control.h:78
Contains xtd::forms::list_control control.
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.
Contains xtd::forms::border_style enum class.
selection_mode
Specifies the selection behavior of a list box.
Definition: selection_mode.h:20
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