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.
text_box.h
Go to the documentation of this file.
1 #pragma once
5 #include "border_style.h"
6 #include "character_casing.h"
7 #include "text_box_base.h"
8 
10 namespace xtd {
12  namespace forms {
22  class forms_export_ text_box : public text_box_base {
23  public:
25  text_box();
26 
30  virtual bool accepts_return() const {return accepts_return_;}
35  virtual text_box& accepts_return(bool value) {
36  if (accepts_return_ != value) {
37  accepts_return_ = value;
38  recreate_handle();
39  on_accepts_return_changed(event_args::empty);
40  }
41  return *this;
42  }
43 
47  virtual xtd::forms::character_casing character_casing() const {return character_casing_;}
53 
54  drawing::color default_back_color() const override {return xtd::forms::theme_colors::current_theme().text_box();}
55 
56  drawing::color default_fore_color() const override {return xtd::forms::theme_colors::current_theme().text_box_text();}
57 
58  drawing::size default_size() const override {return {100, 21};}
59 
64  virtual char32_t password_char() const {return password_char_;}
70  virtual text_box& password_char(char32_t value);
71 
76  size_t selection_length() const override;
77 
82  size_t selection_start() const override;
83 
84  const xtd::ustring& text() const override;
85  control& text(const xtd::ustring& text) override;
86 
90  virtual bool use_system_password_char() const {return use_system_password_char_;}
95  virtual text_box& use_system_password_char(bool value);
96 
100 
101  void append_text(const xtd::ustring& value) override;
102 
103  void select(size_t start, size_t length) override;
104 
105  protected:
106  forms::create_params create_params() const override;
107 
108  drawing::size measure_control() const override;
109 
112  virtual void on_accepts_return_changed(const event_args& e) {if (can_raise_events()) accepts_return_changed(*this, e);}
113 
114  void on_handle_created(const event_args& e) override;
115 
116  void on_text_changed(const event_args& e) override;
117 
121  void wnd_proc(message& message) override;
122 
124  void wm_key_char(message& message);
125  void wm_set_text(message& message);
126 
127  bool accepts_return_ = false;
129  char32_t password_char_ = 0;
130  bool use_system_password_char_ = false;
132  };
133  }
134 }
virtual void on_accepts_return_changed(const event_args &e)
Raises the text_box::accepts_return_changed event.
Definition: text_box.h:112
virtual bool use_system_password_char() const
Gets a value indicating whether the text in the TextBox control should appear as the default password...
Definition: text_box.h:90
The default appearance defined by the control class.
drawing::color default_fore_color() const override
Gets the default foreground color of the control.
Definition: text_box.h:56
Represents the base class for classes that contain event data, and provides a value to use for events...
Definition: event_args.h:18
static const event_args empty
Provides a value to use with events that do not have event data.
Definition: event_args.h:31
virtual char32_t password_char() const
Gets the character used to mask characters of a password in a single-line TextBox control...
Definition: text_box.h:64
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: text_box.h:54
virtual size_t selection_start() const
Gets o the starting point of text selected in the text box.
Definition: text_box_base.h:120
The xtd namespace contains all fundamental classes to access Hardware, Os, System, and more.
Definition: system_report.h:17
virtual xtd::forms::character_casing character_casing() const
Gets whether the text_box control modifies the case of characters as they are typed.
Definition: text_box.h:47
virtual text_box & accepts_return(bool value)
Sets a value indicating whether pressing ENTER in a multiline text_box control creates a new line of ...
Definition: text_box.h:35
Implements the basic functionality required by text controls.
Definition: text_box_base.h:20
Represents text as a sequence of UTF-8 code units.
Definition: ustring.h:48
drawing::size default_size() const override
Gets the default size of the control.
Definition: text_box.h:58
virtual size_t selection_length() const
Gets the number of characters selected in the text box.
Definition: text_box_base.h:107
Represents a standard Windows text box.
Definition: text_box.h:22
Represents an ARGB (alpha, red, green, blue) color.
Definition: color.h:39
Represents an event.
Definition: event.h:21
The system-defined color of the accent color (macos specific. On other platform is same as window)...
Contains xtd::forms::character_casing enum class.
Contains xtd::forms::text_box_base control.
The SELECT key.
character_casing
Specifies the case of characters in a text_box control.
Definition: character_casing.h:18
Implements a Windows message.
Definition: message.h:25
Defines the base class for controls, which are components with visual representation.
Definition: control.h:67
The xtd::forms namespace contains classes for creating Windows-based applications that take full adva...
Definition: about_box.h:13
virtual bool accepts_return() const
Gets a value indicating whether pressing ENTER in a multiline text_box control creates a new line of ...
Definition: text_box.h:30
Contains xtd::forms::border_style enum class.
event< text_box, event_handler > accepts_return_changed
Occurs when the value of the accepts_return property has changed.
Definition: text_box.h:99