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.
choice.h
Go to the documentation of this file.
1 #pragma once
6 #include "list_control.h"
7 
9 namespace xtd {
11  namespace forms {
25  class forms_export_ choice : public list_control {
26  public:
28  choice();
29 
30  virtual drawing::size default_size() const override {return {121, 23};}
31 
35  object_collection& items() {return items_;}
38  const object_collection& items() const {return items_;}
41  const choice& items(const object_collection& items) {
42  items_ = items;
43  return *this;
44  }
45 
49  list_control& selected_index(size_t selected_index) override;
50 
53  const item& selected_item() const {return selected_item_;}
56  choice& selected_item(const item& selected_item);
57 
61  virtual bool sorted() const {return sorted_;}
65  virtual choice& sorted(bool sorted);
66 
67  using list_control::text;
70  control& text(const xtd::ustring& text) override {return *this;}
71 
74  void begin_update();
77  void end_update();
78 
79  protected:
80  forms::create_params create_params() const override;
81 
82  void on_handle_created(const event_args& e) override;
83 
84  void on_selected_value_changed(const event_args& e) override;
85 
86  void set_bounds_core(int32_t x, int32_t y, int32_t width, int32_t height, bounds_specified specified) override;
87 
88  void set_client_size_core(int32_t width, int32_t height) override;
89 
90  void wnd_proc(message& message) override;
91 
94  virtual void wm_reflect_command(message& message);
95 
98  virtual void wm_mouse_double_click(message& message);
99 
102  virtual void wm_mouse_down(message& message);
103 
106  virtual void wm_mouse_up(message& message);
107 
109  object_collection items_;
110  item selected_item_;
111  bool sorted_ = false;
112  bool user_set_size_ = false;
114  };
115  }
116 }
Represents the base class for classes that contain event data, and provides a value to use for events...
Definition: event_args.h:18
virtual drawing::size default_size() const override
Gets the default size of the control.
Definition: choice.h:30
const object_collection & items() const
Gets an object representing the collection of the items contained in this choice. ...
Definition: choice.h:38
Contains xtd::forms::arranged_element_collection collection.
control & text(const xtd::ustring &text) override
Sets the text associated with this control.
Definition: choice.h:70
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
object_collection & items()
Gets an object representing the collection of the items contained in this choice. ...
Definition: choice.h:35
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
Specifies that the height of the control is defined.
Specifies that the width of the control is defined.
const item & selected_item() const
Gets currently selected item in the choice.
Definition: choice.h:53
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
Contains xtd::forms::list_control control.
Represents a choice control.
Definition: choice.h:25
The xtd::forms namespace contains classes for creating Windows-based applications that take full adva...
Definition: about_box.h:13
const choice & items(const object_collection &items)
Sets an object representing the collection of the items contained in this choice. ...
Definition: choice.h:41
bounds_specified
Specifies the bounds of the control to use when defining a control'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
virtual bool sorted() const
Gets a value indicating whether the items in the choice are sorted.
Definition: choice.h:61
virtual size_t selected_index() const
Gets the zero-based index of the currently selected item.
Definition: list_control.h:84