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.
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 {
23  public:
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 }
Contains xtd::forms::border_style enum class.
Contains xtd::forms::character_casing enum class.
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
static const event_args empty
Provides a value to use with events that do not have event data.
Definition: event_args.h:31
Represents an event.
Definition: event.h:21
Defines the base class for controls, which are components with visual representation.
Definition: control.h:67
Implements a Windows message.
Definition: message.h:25
Implements the basic functionality required by text controls.
Definition: text_box_base.h:20
virtual size_t selection_start() const
Gets o the starting point of text selected in the text box.
Definition: text_box_base.h:120
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
size_t selection_length() const override
Gets the number of characters selected in the text box.
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
const xtd::ustring & text() const override
Gets the text associated with this control.
control & text(const xtd::ustring &text) override
Sets the text associated with this control.
drawing::color default_fore_color() const override
Gets the default foreground color of the control.
Definition: text_box.h:56
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
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
void wnd_proc(message &message) override
Processes Windows messages.
void on_handle_created(const event_args &e) override
Raises the control::handle_created event.
text_box()
initializes a new instance of the text_box class.
size_t selection_start() const override
Gets o the starting point of text selected in the text box.
virtual text_box & character_casing(xtd::forms::character_casing value)
Sets whether the text_box control modifies the case of characters as they are typed.
drawing::color default_back_color() const override
Gets the default background color of the control.
Definition: text_box.h:54
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
forms::create_params create_params() const override
Gets the required creation parameters when the control handle is created.
drawing::size default_size() const override
Gets the default size of the control.
Definition: text_box.h:58
virtual text_box & use_system_password_char(bool value)
Sets a value indicating whether the text in the TextBox control should appear as the default password...
void append_text(const xtd::ustring &value) override
Appends text to the current text of a text box.
virtual void on_accepts_return_changed(const event_args &e)
Raises the text_box::accepts_return_changed event.
Definition: text_box.h:112
void on_text_changed(const event_args &e) override
Raises the control::text_changed event.
void select(size_t start, size_t length) override
Selects a range of text in the text box.
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
drawing::size measure_control() const override
Measure this control.
virtual text_box & password_char(char32_t value)
Sets the character used to mask characters of a password in a single-line TextBox control.
Represents text as a sequence of UTF-8 code units.
Definition: ustring.h:48
event< text_box, event_handler > accepts_return_changed
Occurs when the value of the accepts_return property has changed.
Definition: text_box.h:99
#define forms_export_
Define shared library export.
Definition: forms_export.h:13
@ e
The E key.
character_casing
Specifies the case of characters in a text_box control.
Definition: character_casing.h:18
@ normal
The case of characters is left unchanged.
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::text_box_base control.