• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (c) 2016 Marshall A. Greenblatt. All rights reserved.
2 //
3 // Redistribution and use in source and binary forms, with or without
4 // modification, are permitted provided that the following conditions are
5 // met:
6 //
7 //    * Redistributions of source code must retain the above copyright
8 // notice, this list of conditions and the following disclaimer.
9 //    * Redistributions in binary form must reproduce the above
10 // copyright notice, this list of conditions and the following disclaimer
11 // in the documentation and/or other materials provided with the
12 // distribution.
13 //    * Neither the name of Google Inc. nor the name Chromium Embedded
14 // Framework nor the names of its contributors may be used to endorse
15 // or promote products derived from this software without specific prior
16 // written permission.
17 //
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 //
30 // ---------------------------------------------------------------------------
31 //
32 // The contents of this file must follow a specific format in order to
33 // support the CEF translator tool. See the translator.README.txt file in the
34 // tools directory for more information.
35 //
36 
37 #ifndef CEF_INCLUDE_VIEWS_CEF_TEXTFIELD_H_
38 #define CEF_INCLUDE_VIEWS_CEF_TEXTFIELD_H_
39 #pragma once
40 
41 #include "include/views/cef_textfield_delegate.h"
42 #include "include/views/cef_view.h"
43 
44 ///
45 // A Textfield supports editing of text. This control is custom rendered with no
46 // platform-specific code. Methods must be called on the browser process UI
47 // thread unless otherwise indicated.
48 ///
49 /*--cef(source=library)--*/
50 class CefTextfield : public CefView {
51  public:
52   ///
53   // Create a new Textfield.
54   ///
55   /*--cef(optional_param=delegate)--*/
56   static CefRefPtr<CefTextfield> CreateTextfield(
57       CefRefPtr<CefTextfieldDelegate> delegate);
58 
59   ///
60   // Sets whether the text will be displayed as asterisks.
61   ///
62   /*--cef()--*/
63   virtual void SetPasswordInput(bool password_input) = 0;
64 
65   ///
66   // Returns true if the text will be displayed as asterisks.
67   ///
68   /*--cef()--*/
69   virtual bool IsPasswordInput() = 0;
70 
71   ///
72   // Sets whether the text will read-only.
73   ///
74   /*--cef()--*/
75   virtual void SetReadOnly(bool read_only) = 0;
76 
77   ///
78   // Returns true if the text is read-only.
79   ///
80   /*--cef()--*/
81   virtual bool IsReadOnly() = 0;
82 
83   ///
84   // Returns the currently displayed text.
85   ///
86   /*--cef()--*/
87   virtual CefString GetText() = 0;
88 
89   ///
90   // Sets the contents to |text|. The cursor will be moved to end of the text if
91   // the current position is outside of the text range.
92   ///
93   /*--cef()--*/
94   virtual void SetText(const CefString& text) = 0;
95 
96   ///
97   // Appends |text| to the previously-existing text.
98   ///
99   /*--cef()--*/
100   virtual void AppendText(const CefString& text) = 0;
101 
102   ///
103   // Inserts |text| at the current cursor position replacing any selected text.
104   ///
105   /*--cef()--*/
106   virtual void InsertOrReplaceText(const CefString& text) = 0;
107 
108   ///
109   // Returns true if there is any selected text.
110   ///
111   /*--cef()--*/
112   virtual bool HasSelection() = 0;
113 
114   ///
115   // Returns the currently selected text.
116   ///
117   /*--cef()--*/
118   virtual CefString GetSelectedText() = 0;
119 
120   ///
121   // Selects all text. If |reversed| is true the range will end at the logical
122   // beginning of the text; this generally shows the leading portion of text
123   // that overflows its display area.
124   ///
125   /*--cef()--*/
126   virtual void SelectAll(bool reversed) = 0;
127 
128   ///
129   // Clears the text selection and sets the caret to the end.
130   ///
131   /*--cef()--*/
132   virtual void ClearSelection() = 0;
133 
134   ///
135   // Returns the selected logical text range.
136   ///
137   /*--cef()--*/
138   virtual CefRange GetSelectedRange() = 0;
139 
140   ///
141   // Selects the specified logical text range.
142   ///
143   /*--cef()--*/
144   virtual void SelectRange(const CefRange& range) = 0;
145 
146   ///
147   // Returns the current cursor position.
148   ///
149   /*--cef()--*/
150   virtual size_t GetCursorPosition() = 0;
151 
152   ///
153   // Sets the text color.
154   ///
155   /*--cef()--*/
156   virtual void SetTextColor(cef_color_t color) = 0;
157 
158   ///
159   // Returns the text color.
160   ///
161   /*--cef()--*/
162   virtual cef_color_t GetTextColor() = 0;
163 
164   ///
165   // Sets the selection text color.
166   ///
167   /*--cef()--*/
168   virtual void SetSelectionTextColor(cef_color_t color) = 0;
169 
170   ///
171   // Returns the selection text color.
172   ///
173   /*--cef()--*/
174   virtual cef_color_t GetSelectionTextColor() = 0;
175 
176   ///
177   // Sets the selection background color.
178   ///
179   /*--cef()--*/
180   virtual void SetSelectionBackgroundColor(cef_color_t color) = 0;
181 
182   ///
183   // Returns the selection background color.
184   ///
185   /*--cef()--*/
186   virtual cef_color_t GetSelectionBackgroundColor() = 0;
187 
188   ///
189   // Sets the font list. The format is "<FONT_FAMILY_LIST>,[STYLES] <SIZE>",
190   // where:
191   // - FONT_FAMILY_LIST is a comma-separated list of font family names,
192   // - STYLES is an optional space-separated list of style names (case-sensitive
193   //   "Bold" and "Italic" are supported), and
194   // - SIZE is an integer font size in pixels with the suffix "px".
195   //
196   // Here are examples of valid font description strings:
197   // - "Arial, Helvetica, Bold Italic 14px"
198   // - "Arial, 14px"
199   ///
200   /*--cef()--*/
201   virtual void SetFontList(const CefString& font_list) = 0;
202 
203   ///
204   // Applies |color| to the specified |range| without changing the default
205   // color. If |range| is empty the color will be set on the complete text
206   // contents.
207   ///
208   /*--cef()--*/
209   virtual void ApplyTextColor(cef_color_t color, const CefRange& range) = 0;
210 
211   ///
212   // Applies |style| to the specified |range| without changing the default
213   // style. If |add| is true the style will be added, otherwise the style will
214   // be removed. If |range| is empty the style will be set on the complete text
215   // contents.
216   ///
217   /*--cef()--*/
218   virtual void ApplyTextStyle(cef_text_style_t style,
219                               bool add,
220                               const CefRange& range) = 0;
221 
222   ///
223   // Returns true if the action associated with the specified command id is
224   // enabled. See additional comments on ExecuteCommand().
225   ///
226   /*--cef()--*/
227   virtual bool IsCommandEnabled(cef_text_field_commands_t command_id) = 0;
228 
229   ///
230   // Performs the action associated with the specified command id.
231   ///
232   /*--cef()--*/
233   virtual void ExecuteCommand(cef_text_field_commands_t command_id) = 0;
234 
235   ///
236   // Clears Edit history.
237   ///
238   /*--cef()--*/
239   virtual void ClearEditHistory() = 0;
240 
241   ///
242   // Sets the placeholder text that will be displayed when the Textfield is
243   // empty.
244   ///
245   /*--cef()--*/
246   virtual void SetPlaceholderText(const CefString& text) = 0;
247 
248   ///
249   // Returns the placeholder text that will be displayed when the Textfield is
250   // empty.
251   ///
252   /*--cef()--*/
253   virtual CefString GetPlaceholderText() = 0;
254 
255   ///
256   // Sets the placeholder text color.
257   ///
258   /*--cef()--*/
259   virtual void SetPlaceholderTextColor(cef_color_t color) = 0;
260 
261   ///
262   // Set the accessible name that will be exposed to assistive technology (AT).
263   ///
264   /*--cef()--*/
265   virtual void SetAccessibleName(const CefString& name) = 0;
266 };
267 
268 #endif  // CEF_INCLUDE_VIEWS_CEF_TEXTFIELD_H_
269