xtd - Reference Guide  0.1.1
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 {
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 an ARGB (alpha, red, green, blue) color.
Definition: color.h:39
Stores an ordered pair of integers, which specify a height and width.
Definition: size.h:25
Represents the base class for classes that contain event data, and provides a value to use for events...
Definition: event_args.h:18
Represents an event.
Definition: event.h:21
Represent an item contained in the domain_up_down::object_collection collection.
Definition: domain_up_down.h:23
item(const xtd::ustring &value)
Initializes a new instance of the item class with specified value.
Definition: domain_up_down.h:29
item()=default
Initializes a new instance of the item class.
virtual const xtd::ustring & value() const
Gets the value of the item.
Definition: domain_up_down.h:49
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
virtual std::any tag() const
Gets the tag of the item.
Definition: domain_up_down.h:53
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
domain_up_down & selected_item(const item &selected_item)
Gets the selected item based on the index value of the selected item in the collection.
void on_text_changed(const event_args &e) override
Raises the control::text_changed event.
drawing::color default_fore_color() const override
Gets the default foreground color of the control.
Definition: domain_up_down.h:124
virtual domain_up_down & wrap(bool value)
Sets a value indicating whether the collection of items continues to the first or last item if the us...
virtual size_t selected_index() const
Gets the zero-based index of the currently selected item.
Definition: domain_up_down.h:86
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....
Definition: domain_up_down.h:76
const domain_up_down & items(const object_collection &items)
Sets an object representing the collection of the items contained in this domain_up_down....
Definition: domain_up_down.h:80
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
domain_up_down()
Initializes a new instance of the DomainUpDown class.
void on_handle_created(const event_args &e) override
Raises the control::handle_created event.
object_collection & items()
Gets an object representing the collection of the items contained in this domain_up_down....
Definition: domain_up_down.h:73
virtual void on_selected_item_changed(const event_args &e)
Raises the domain_up_down::selected_item_changed event.
forms::create_params create_params() const override
Gets the required creation parameters when the control handle is created.
drawing::color default_back_color() const override
Gets the default background color of the control.
Definition: domain_up_down.h:122
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
virtual domain_up_down & selected_index(size_t selected_index)
When overridden in a derived class, Sets the zero-based index of the currently selected item.
Represents a collection of objects.
Definition: arranged_element_collection.h:28
Implements the basic functionality required by a spin box (also known as an up-down control).
Definition: up_down_base.h:18
Represents text as a sequence of UTF-8 code units.
Definition: ustring.h:48
event< domain_up_down, event_handler > value_changed
Occurs when the value property has been changed.
Definition: domain_up_down.h:116
event< domain_up_down, event_handler > selected_item_changed
Occurs when the selected_item property has been changed.
Definition: domain_up_down.h:112
#define forms_export_
Define shared library export.
Definition: forms_export.h:13
The xtd::forms namespace contains classes for creating Windows-based applications that take full adva...
Definition: about_box.h:13
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition: system_report.h:17
Contains xtd::forms::up_down_base control.