xtd - Reference Guide  0.1.0
Modern c++17/20 framework to create console, GUI and unit test applications on Windows, macOS, Linux, iOS and android.
list_box.h
1 #pragma once
2 #include "layout/arranged_element_collection.h"
3 #include "border_style.h"
4 #include "list_control.h"
5 #include "selection_mode.h"
6 
8 namespace xtd {
10  namespace forms {
11  class forms_export_ list_box : public list_control {
12  public:
13  list_box();
14 
15  virtual forms::border_style border_style() const {return border_style_;}
17 
18  drawing::color default_back_color() const override {return xtd::forms::theme_colors::current_theme().window();}
19 
20  drawing::color default_fore_color() const override {return xtd::forms::theme_colors::current_theme().window_text();}
21 
22  drawing::size default_size() const override {return {120, 96};}
23 
24  item_collection& items() {return items_;}
25 
26  const item_collection& items() const {return items_;}
27 
28  const list_box& items(const item_collection& items) {
29  items_ = items;
30  return *this;
31  }
32 
34  list_control& selected_index(size_t selected_index) override;
35 
36  virtual std::vector<size_t> selected_indices() const;
37 
38  const item& selected_item() const {return selected_item_;}
39 
40  list_box& selected_item(const item& selected_item);
41 
42  std::vector<item> selected_items() const;
43 
44  virtual forms::selection_mode selection_mode() const {return selection_mode_;}
45 
47 
48  virtual bool sorted() const {return sorted_;}
49  virtual list_box& sorted(bool sorted);
50 
51  using list_control::text;
52  control& text(const std::string& text) override {return *this;}
53 
54  void begin_update();
55  void end_update();
56 
57  protected:
58  bool allow_selection() override {return selection_mode_ != forms::selection_mode::none;}
59 
60  forms::create_params create_params() const override;
61 
62  void on_handle_created(const event_args& e) override;
63 
64  void on_selected_value_changed(const event_args& e) override;
65 
66  void wnd_proc(message& message) override;
67 
68  virtual void wm_reflect_command(message& message);
69 
70  virtual void wm_mouse_double_click(message& message);
71 
72  virtual void wm_mouse_down(message& message);
73 
74  virtual void wm_mouse_up(message& message);
75 
77  item_collection items_;
78  item selected_item_;
80  bool sorted_ = false;
81  };
82  }
83 }
Definition: list_box.h:11
bool allow_selection() override
Gets a value indicating whether the list enables selection of list items.
Definition: list_box.h:58
control & text(const std::string &text) override
Sets the text associated with this control.
Definition: list_box.h:52
Represents the base class for classes that contain event data, and provides a value to use for events...
Definition: event_args.h:9
Stores an ordered pair of integers, which specify a height and width.
Definition: size.h:16
The xtd namespace contains all fundamental classes to access Hardware, Os, System, and more.
Definition: system_report.h:15
Represents a collection of objects.
Definition: arranged_element_collection.h:25
drawing::color default_back_color() const override
Gets the default background color of the control.
Definition: list_box.h:18
Represents an ARGB (alpha, red, green, blue) color.
Definition: color.h:29
selection_mode
Specifies the selection behavior of a list box.
Definition: selection_mode.h:10
Only one item can be selected.
No items can be selected.
Definition: message.h:11
virtual const std::string & text() const
Gets the text associated with this control.
Definition: control.h:534
Provides a common implementation of members for the list_box and combo_box classes.
Definition: list_control.h:11
drawing::color default_fore_color() const override
Gets the default foreground color of the control.
Definition: list_box.h:20
Defines the base class for controls, which are components with visual representation.
Definition: control.h:61
virtual size_t selected_index() const
Gets the zero-based index of the currently selected item.
Definition: list_control.h:57
border_style
Specifies the border style for a control.
Definition: border_style.h:10
drawing::size default_size() const override
Gets the default size of the control.
Definition: list_box.h:22