xtd.forms - Reference Guide  0.1.0
Modern c++17 library containing classes for creating Windows-based applications that take full advantage of the rich user interface features available in the Microsoft Windows, Apple macOS and Linux like Ubuntu operating system.
combo_box.h
1 #pragma once
2 #include "layout/arranged_element_collection.h"
3 #include "combo_box_style.h"
4 #include "list_control.h"
5 
7 namespace xtd {
9  namespace forms {
16  class combo_box : public list_control {
17  public:
19  combo_box();
20 
21  virtual drawing::size default_size() const override {return {121, 23};}
22 
23  combo_box_style drop_down_style() const {return this->drop_down_style_;}
24  combo_box& drop_down_style(combo_box_style drop_down_style);
25 
26  item_collection& items() {return this->items_;}
27 
28  const item_collection& items() const {return this->items_;}
29 
30  const combo_box& items(const item_collection& items) {
31  this->items_ = items;
32  return *this;
33  }
34 
36  list_control& selected_index(size_t selected_index) override;
37 
38  const item& selected_item() const {return this->selected_item_;}
39 
40  combo_box& selected_item(const item& selected_item);
41 
42  virtual bool sorted() const {return this->sorted_;}
43  virtual combo_box& sorted(bool sorted);
44 
45  using list_control::text;
46  control& text(const std::string& text) override {return *this;}
47 
48  void begin_update();
49  void end_update();
50 
51  event<combo_box, event_handler<control&>> drop_down_style_changed;
52 
53  protected:
56  forms::create_params create_params() const override;
57 
58  virtual void on_drop_down_style_changed(const event_args& e);
59 
60  void on_handle_created(const event_args& e) override;
61 
62  void on_selected_value_changed(const event_args& e) override;
63 
64  void set_bounds_core(int32_t x, int32_t y, int32_t width, int32_t height, bounds_specified specified) override;
65 
66  void set_client_size_core(int32_t width, int32_t height) override;
67 
68  void wnd_proc(message& message) override;
69 
70  virtual void wm_reflect_command(message& message);
71 
72  virtual void wm_mouse_double_click(message& message);
73 
74  virtual void wm_mouse_down(message& message);
75 
76  virtual void wm_mouse_up(message& message);
77 
78  int32_t drop_down_height_ = 0;
80  int32_t drop_down_width_ = 0;
81  item_collection items_;
82  item selected_item_;
83  bool sorted_ = false;
84  bool user_set_size_ = false;
85  };
86  }
87 }
void set_client_size_core(int32_t width, int32_t height) override
Sets the size of the client area of the control.
forms::create_params create_params() const override
The xtd namespace contains all fundamental classes to access Hardware, Os, System, and more.
combo_box()
Initializes a new instance of the combo_box class.
Represents a collection of objects.
Definition: arranged_element_collection.h:23
combo_box_style
Specifies the combo_box style.
Definition: combo_box_style.h:12
Represents a Windows combo box control.
Definition: combo_box.h:16
void set_bounds_core(int32_t x, int32_t y, int32_t width, int32_t height, bounds_specified specified) override
Performs the work of setting the specified bounds of this control.
void wnd_proc(message &message) override
Processes Windows messages.
Specifies that the list is displayed by clicking the down arrow and that the text portion is editable...
Specifies that the left edge of the control is defined.
Specifies that the top edge of the control is defined.
Definition: message.h:10
Provides a common implementation of members for the list_box and combo_box classes.
Definition: list_control.h:11
Defines the base class for controls, which are components with visual representation.
Definition: control.h:60
bounds_specified
Specifies the bounds of the control to use when defining a control&#39;s size and position.
Definition: bounds_specified.h:10
virtual size_t selected_index() const
Gets the zero-based index of the currently selected item.
Definition: list_control.h:57