Boost.UI
User Interface Boost library
text_box.hpp
Go to the documentation of this file.
1 // Copyright (c) 2017 Kolya Kosenko
2 
3 // Distributed under the Boost Software License, Version 1.0.
4 // See http://www.boost.org/LICENSE_1_0.txt
5 
7 
8 #ifndef BOOST_UI_TEXT_BOX_HPP
9 #define BOOST_UI_TEXT_BOX_HPP
10 
11 #include <boost/ui/config.hpp>
12 
13 #ifdef BOOST_HAS_PRAGMA_ONCE
14 #pragma once
15 #endif
16 
17 #include <boost/ui/widget.hpp>
18 
19 namespace boost {
20 namespace ui {
21 
27 
28 class BOOST_UI_DECL text_box_base : public widget
29 {
30 public:
32  void clear();
33 
35  text_box_base& text(const uistring& text);
36 
38  uistring text() const;
39 
41  BOOST_UI_DETAIL_HANDLER(edit, text_box_base);
43 
44 protected:
45  text_box_base() {}
46 
47 #ifndef DOXYGEN
48  void detail_create(widget& parent, const uistring& text, int style);
49  text_box_base& detail_placeholder(const uistring& text);
50  uistring detail_placeholder() const;
51 #endif
52 
53 private:
54  void on_edit_raw(const boost::function<void()>& handler);
55 
56  class detail_impl;
57  detail_impl* get_impl();
58  const detail_impl* get_impl() const;
59 };
60 
67 
68 class BOOST_UI_DECL string_box : public text_box_base
69 {
70 public:
71  string_box() {}
72 
76  explicit string_box(widget& parent, const uistring& text = uistring())
77  { create(parent, text); }
78  string_box& create(widget& parent, const uistring& text = uistring());
80 
82  string_box& placeholder(const uistring& text) { detail_placeholder(text); return *this; }
83 
85  uistring placeholder() const { return detail_placeholder(); }
86 };
87 
94 
95 class BOOST_UI_DECL password_box : public text_box_base
96 {
97 public:
98  password_box() {}
99 
103  explicit password_box(widget& parent, const uistring& text = uistring())
104  { create(parent, text); }
105  password_box& create(widget& parent, const uistring& text = uistring());
107 };
108 
115 
116 class BOOST_UI_DECL text_box : public text_box_base
117 {
118 public:
119  text_box() {}
120 
124  explicit text_box(widget& parent, const uistring& text = uistring())
125  { create(parent, text); }
126  text_box& create(widget& parent, const uistring& text = uistring());
128 };
129 
130 } // namespace ui
131 } // namespace boost
132 
133 #endif // BOOST_UI_TEXT_BOX_HPP
boost::ui::string_box::placeholder
uistring placeholder() const
Returns placeholder text from the editor.
Definition: text_box.hpp:85
boost::ui::string_box::string_box
string_box(widget &parent, const uistring &text=uistring())
Creates widget.
Definition: text_box.hpp:76
boost::ui::uistring
Helper class to convert string between UI and application logic only.
Definition: string.hpp:49
boost::ui::text_box
Multi-line text editor widget.
Definition: text_box.hpp:116
config.hpp
Configuration options.
widget.hpp
Widget class.
boost::ui::text_box::text_box
text_box(widget &parent, const uistring &text=uistring())
Creates widget.
Definition: text_box.hpp:124
boost
Boost C++ libraries namespace.
Definition: window.hpp:19
boost::ui::string_box::placeholder
string_box & placeholder(const uistring &text)
Sets placeholder text into the editor.
Definition: text_box.hpp:82
boost::ui::string_box
Single-line text editor widget.
Definition: text_box.hpp:68
boost::ui::password_box::password_box
password_box(widget &parent, const uistring &text=uistring())
Creates widget.
Definition: text_box.hpp:103
boost::ui::text_box_base
Abstract text editor widget.
Definition: text_box.hpp:28
boost::ui::widget
Base class for all widgets.
Definition: widget.hpp:45
boost::ui::password_box
Password editor widget.
Definition: text_box.hpp:95