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.
domain_up_down.h
Go to the documentation of this file.
1 #pragma once
5 #include "up_down_base.h"
6 
8 namespace xtd {
10  namespace forms {
20  class forms_export_ domain_up_down : public up_down_base {
21  public:
23  class item {
24  public:
26  item() = default;
29  item(const xtd::ustring& value) : value_(value) {}
33  item(const xtd::ustring& value, const std::any& tag) : value_(value), tag_(tag) {}
35  item(const char* value) : value_(value) {}
36  item(const item& value) = default;
37  virtual ~item() = default;
38  bool operator==(const item& value) const {return value_ == value.value_;}
39  bool operator!=(const item& value) const {return !operator==(value);}
40  bool operator<(const item& value) const {return value_ < value.value_;}
41  bool operator<=(const item& value) const {return value_ <= value.value_;}
42  bool operator>(const item& value) const {return value_ > value.value_;}
43  bool operator>=(const item& value) const {return value_ >= value.value_;}
44  friend std::ostream& operator<<(std::ostream& os, const item& value) {return os << value.to_string();}
46 
49  virtual const xtd::ustring& value() const {return value_;}
50 
53  virtual std::any tag() const {return tag_;}
54 
57  xtd::ustring to_string() const {return value_;}
58 
59  private:
60  xtd::ustring value_;
61  std::any tag_;
62  };
63 
66 
69 
73  object_collection& items() {return items_;}
76  const object_collection& items() const {return items_;}
80  const domain_up_down& items(const object_collection& items) {
81  items_ = items;
82  return *this;
83  }
86  virtual size_t selected_index() const {return selected_index_;}
90  virtual domain_up_down& selected_index(size_t selected_index);
91 
94  const item& selected_item() const {return selected_item_;}
98  domain_up_down& selected_item(const item& selected_item);
99 
102  virtual bool wrap() {return wrap_;}
106  virtual domain_up_down& wrap(bool value);
107 
108  forms::create_params create_params() const override;
109 
113 
117 
119  static const size_t npos = std::numeric_limits<size_t>::max();
120 
121  protected:
122  drawing::color default_back_color() const override {return xtd::forms::theme_colors::current_theme().window();}
123 
124  drawing::color default_fore_color() const override {return xtd::forms::theme_colors::current_theme().window_text();}
125 
126  drawing::size default_size() const override {return {150, 21};}
127 
128  void on_handle_created(const event_args& e) override;
129 
132  virtual void on_selected_item_changed(const event_args& e);
133 
134  void on_text_changed(const event_args& e) override;
135 
137  object_collection items_;
138  size_t selected_index_ = npos;
139  item selected_item_;
140  bool wrap_ = false;
142  };
143  }
144 }
Represents the base class for classes that contain event data, and provides a value to use for events...
Definition: event_args.h:18
event< domain_up_down, event_handler > selected_item_changed
Occurs when the selected_item property has been changed.
Definition: domain_up_down.h:112
drawing::color default_fore_color() const override
Gets the default foreground color of the control.
Definition: domain_up_down.h:124
Stores an ordered pair of integers, which specify a height and width.
Definition: size.h:25
drawing::color default_back_color() const override
Gets the default background color of the control.
Definition: domain_up_down.h:122
The xtd namespace contains all fundamental classes to access Hardware, Os, System, and more.
Definition: system_report.h:17
Implements the basic functionality required by a spin box (also known as an up-down control)...
Definition: up_down_base.h:18
virtual size_t selected_index() const
Gets the zero-based index of the currently selected item.
Definition: domain_up_down.h:86
Represents text as a sequence of UTF-8 code units.
Definition: ustring.h:48
Represents a collection of objects.
Definition: arranged_element_collection.h:28
object_collection & items()
Gets an object representing the collection of the items contained in this domain_up_down. Gets an object representing the collection of the items contained in this domain_up_down.
Definition: domain_up_down.h:73
Represents an ARGB (alpha, red, green, blue) color.
Definition: color.h:39
const domain_up_down & items(const object_collection &items)
Sets an object representing the collection of the items contained in this domain_up_down. Gets an object representing the collection of the items contained in this domain_up_down.
Definition: domain_up_down.h:80
Represents an event.
Definition: event.h:21
drawing::size default_size() const override
Gets the default size of the control.
Definition: domain_up_down.h:126
const object_collection & items() const
Gets an object representing the collection of the items contained in this domain_up_down. Gets an object representing the collection of the items contained in this domain_up_down.
Definition: domain_up_down.h:76
Represent an item contained in the domain_up_down::object_collection collection.
Definition: domain_up_down.h:23
item(const xtd::ustring &value, const std::any &tag)
Initializes a new instance of the item class with specified value and tag.
Definition: domain_up_down.h:33
Indicates that all styles except allow_binary_specifier, allow_octal_specifier and allow_hex_specifie...
virtual bool wrap()
Gets a value indicating whether the collection of items continues to the first or last item if the us...
Definition: domain_up_down.h:102
xtd::ustring to_string() const
Returns a string containing the vague of the item.
Definition: domain_up_down.h:57
Represents a Windows spin box (also known as an up-down control) that displays string values...
Definition: domain_up_down.h:20
The xtd::forms namespace contains classes for creating Windows-based applications that take full adva...
Definition: about_box.h:13
virtual const xtd::ustring & value() const
Gets the value of the item.
Definition: domain_up_down.h:49
event< domain_up_down, event_handler > value_changed
Occurs when the value property has been changed.
Definition: domain_up_down.h:116
Contains xtd::forms::up_down_base control.
item(const xtd::ustring &value)
Initializes a new instance of the item class with specified value.
Definition: domain_up_down.h:29
virtual std::any tag() const
Gets the tag of the item.
Definition: domain_up_down.h:53
const item & selected_item() const
Gets the selected item based on the index value of the selected item in the collection.
Definition: domain_up_down.h:94