xtd - Reference Guide  0.2.0
Modern c++17/20 framework to create console, GUI and unit test applications on Windows, macOS, Linux, iOS and android.
combo_box.h
Go to the documentation of this file.
1 #pragma once
6 #include "combo_box_style.h"
7 #include "list_control.h"
8 
10 namespace xtd {
12  namespace forms {
27  class forms_export_ combo_box : public list_control {
28  public:
30  combo_box();
31 
32  virtual drawing::size default_size() const override {return {121, 23};}
33 
37  combo_box_style drop_down_style() const {return drop_down_style_;}
41  combo_box& drop_down_style(combo_box_style drop_down_style);
42 
46  object_collection& items() {return items_;}
49  const object_collection& items() const {return items_;}
53  const combo_box& items(const object_collection& items) {
54  items_ = items;
55  return *this;
56  }
57 
62  list_control& selected_index(size_t selected_index) override;
63 
66  const item& selected_item() const {return selected_item_;}
70  combo_box& selected_item(const item& selected_item);
71 
75  virtual bool sorted() const {return sorted_;}
80  virtual combo_box& sorted(bool sorted);
81 
82  using list_control::text;
85  control& text(const xtd::ustring& text) override {return *this;}
86 
89  void begin_update();
92  void end_update();
93 
97 
98  protected:
99  forms::create_params create_params() const override;
100 
102  virtual void on_drop_down_style_changed(const event_args& e);
103 
104  void on_handle_created(const event_args& e) override;
105 
106  void on_selected_value_changed(const event_args& e) override;
107 
108  void set_bounds_core(int32_t x, int32_t y, int32_t width, int32_t height, bounds_specified specified) override;
109 
110  void set_client_size_core(int32_t width, int32_t height) override;
111 
112  void wnd_proc(message& message) override;
113 
116  virtual void wm_reflect_command(message& message);
117 
120  virtual void wm_mouse_double_click(message& message);
121 
124  virtual void wm_mouse_down(message& message);
125 
128  virtual void wm_mouse_up(message& message);
129 
131  int32_t drop_down_height_ = 0;
132  combo_box_style drop_down_style_ = combo_box_style::drop_down;
133  int32_t drop_down_width_ = 0;
134  object_collection items_;
135  item selected_item_;
136  bool sorted_ = false;
137  bool user_set_size_ = false;
139  };
140  }
141 }
virtual drawing::size default_size() const override
Gets the default size of the control.
Definition: combo_box.h:32
combo_box_style drop_down_style() const
Gets a value specifying the style of the combo box.
Definition: combo_box.h:37
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::arranged_element_collection collection.
Represent an item contained in the list_control::object_collection collection.
Definition: list_control.h:22
Stores an ordered pair of integers, which specify a height and width.
Definition: size.h:25
Specifies that the top edge of the control is defined.
The xtd namespace contains all fundamental classes to access Hardware, Os, System, and more.
Definition: system_report.h:17
const combo_box & items(const object_collection &items)
Sets an object representing the collection of the items contained in this combo_box. Gets an object representing the collection of the items contained in this combo_box.
Definition: combo_box.h:53
Represents text as a sequence of UTF-8 code units.
Definition: ustring.h:48
Specifies that the left edge of the control is defined.
Represents a collection of objects.
Definition: arranged_element_collection.h:28
const object_collection & items() const
Gets an object representing the collection of the items contained in this combo_box. Gets an object representing the collection of the items contained in this combo_box.
Definition: combo_box.h:49
const item & selected_item() const
Gets currently selected item in the combo_box.
Definition: combo_box.h:66
virtual bool sorted() const
Gets a value indicating whether the items in the combo_box are sorted alphabetically.
Definition: combo_box.h:75
Specifies that the height of the control is defined.
Represents an event.
Definition: event.h:21
Represents a Windows combo box control.
Definition: combo_box.h:27
event< combo_box, event_handler > drop_down_style_changed
Occurs when the drop_down_style property has changed.
Definition: combo_box.h:96
Specifies that the width of the control is defined.
Implements a Windows message.
Definition: message.h:25
Provides a common implementation of members for the list_box, choice and combo_box classes...
Definition: list_control.h:19
Defines the base class for controls, which are components with visual representation.
Definition: control.h:68
Specifies that the list is displayed by clicking the down arrow and that the text portion is editable...
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
bounds_specified
Specifies the bounds of the control to use when defining a control&#39;s size and position. This enumeration has a flags attribute that allows a bitwise combination of its member values.
Definition: bounds_specified.h:18
virtual const xtd::ustring & text() const
Gets the text associated with this control.
Definition: control.h:678
control & text(const xtd::ustring &text) override
Sets the text associated with this control.
Definition: combo_box.h:85
object_collection & items()
Gets an object representing the collection of the items contained in this combo_box. Gets an object representing the collection of the items contained in this combo_box.
Definition: combo_box.h:46
Contains xtd::forms::combo_box_style enum class.
combo_box_style
Specifies the combo_box style.
Definition: combo_box_style.h:20
virtual size_t selected_index() const
Gets the zero-based index of the currently selected item.
Definition: list_control.h:84