xtd 0.2.0
domain_up_down.h
Go to the documentation of this file.
1 #pragma once
5 #include "up_down_base.h"
6 #include "application.h"
7 #include <xtd/iequatable>
8 
10 namespace xtd {
12  namespace forms {
29  class forms_export_ domain_up_down : public up_down_base {
30  struct data;
31 
32  public:
34  class item : public object, public icomparable<item>, public xtd::iequatable<item> {
35  public:
37 
40  item() = default;
43  item(const xtd::ustring& value); // Can't be explicit by design.
47  item(const xtd::ustring& value, const std::any& tag);
49 
51  item(const char* value); // Can't be explicit by design.
52  item(const item& value) = default;
53  item& operator =(const item& value) = default;
55 
57 
61  virtual const xtd::ustring& value() const noexcept;
62 
65  virtual std::any tag() const noexcept;
67 
69 
71  int32 compare_to(const item& value) const noexcept override;
72  bool equals(const item& value) const noexcept override;
75  xtd::ustring to_string() const noexcept override;
77 
78  private:
79  xtd::ustring value_;
80  std::any tag_;
81  };
82 
84 
89 
91 
94  static const size_t npos = std::numeric_limits<size_t>::max();
96 
98 
101  domain_up_down();
103 
105 
110  object_collection& items() noexcept;
113  const object_collection& items() const noexcept;
117  const domain_up_down& items(const object_collection& items);
120  virtual size_t selected_index() const noexcept;
124  virtual domain_up_down& selected_index(size_t selected_index);
125 
128  const item& selected_item() const noexcept;
132  domain_up_down& selected_item(const item& selected_item);
133 
136  virtual bool wrap() const noexcept;
140  virtual domain_up_down& wrap(bool value);
142 
143 
145 
147  using control::create;
154  static domain_up_down create(const object_collection& items, size_t selected_index = object_collection::npos, const drawing::point& location = {-1, -1}, const drawing::size& size = {-1, -1}, const xtd::ustring& name = xtd::ustring::empty_string);
162  static domain_up_down create(const control& parent, const object_collection& items, size_t selected_index, const drawing::point& location = {-1, -1}, const drawing::size& size = {-1, -1}, const xtd::ustring& name = xtd::ustring::empty_string);
164 
166 
171 
176 
177  protected:
179 
181  forms::create_params create_params() const noexcept override;
182  drawing::color default_back_color() const noexcept override;
183  drawing::color default_fore_color() const noexcept override;
185 
187 
189  void on_handle_created(const event_args& e) override;
190 
191  void on_lost_focus(const event_args& e) override;
192 
195  virtual void on_selected_item_changed(const event_args& e);
196 
197  void on_text_changed(const event_args& e) override;
198  void wnd_proc(message& message) override;
200 
202  void wm_scroll_control(message& message);
204 
205  private:
206  void on_items_item_added(size_t pos, const item& item);
207  void on_items_item_removed(size_t pos, const item& item);
208  void on_items_item_updated(size_t pos, const item& item);
209 
210  std::shared_ptr<data> data_;
211  };
212  }
213 }
Contains xtd::forms::application class.
Represents the base class for classes that contain event data, and provides a value to use for events...
Definition: event_args.h:18
Defines a generalized comparison method that a value type or class implements to create a type-specif...
Definition: icomparable.h:17
Represents an ordered pair of integer x- and y-coordinates that defines a point in a two-dimensional ...
Definition: point.h:54
Stores an ordered pair of integers, which specify a height and width.
Definition: size.h:31
event< domain_up_down, event_handler > selected_item_changed
Occurs when the selected_item property has been changed.
Definition: domain_up_down.h:170
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:21
Encapsulates the information needed when creating a control.
Definition: create_params.h:27
Represents text as a sequence of UTF-8 code units.
Definition: ustring.h:46
Represents a collection of objects.
Definition: arranged_element_collection.h:31
std::string to_string(const date_time &value, const std::string &fmt, const std::locale &loc)
Convert a specified value into a string with specified format and locale.
Definition: date_time.h:1063
event< domain_up_down, event_handler > value_changed
Occurs when the value property has been changed.
Definition: domain_up_down.h:174
Represents an event.
Definition: event.h:21
Defines a generalized method that a value type or class implements to create a type-specific method f...
Definition: iequatable.h:18
Represent an item contained in the domain_up_down::object_collection collection.
Definition: domain_up_down.h:34
Indicates that all styles except allow_binary_specifier, allow_octal_specifier and allow_hex_specifie...
Implements a Windows message.
Definition: message.h:26
Defines the base class for controls, which are components with visual representation.
Definition: control.h:78
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes...
Definition: object.h:32
int_least32_t int32
Represents a 32-bit signed integer.
Definition: types.h:129
Represents a Windows spin box (also known as an up-down control) that displays string values...
Definition: domain_up_down.h:29
The xtd::forms namespace contains classes for creating Windows-based applications that take full adva...
Definition: about_box.h:13
static const ustring empty_string
Represents the empty string.
Definition: ustring.h:53
Specifies that both the x and y coordinates of the control are defined.
Contains xtd::forms::up_down_base control.
size_t size
Represents a size of any object in bytes.
Definition: types.h:195