1 // Copyright 2016 The Chromium Embedded Framework Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be found 3 // in the LICENSE file. 4 5 #ifndef CEF_LIBCEF_BROWSER_VIEWS_TEXTFIELD_IMPL_H_ 6 #define CEF_LIBCEF_BROWSER_VIEWS_TEXTFIELD_IMPL_H_ 7 #pragma once 8 9 #include "include/views/cef_textfield.h" 10 #include "include/views/cef_textfield_delegate.h" 11 12 #include "libcef/browser/views/textfield_view.h" 13 #include "libcef/browser/views/view_impl.h" 14 15 class CefTextfieldImpl 16 : public CefViewImpl<CefTextfieldView, CefTextfield, CefTextfieldDelegate> { 17 public: 18 using ParentClass = 19 CefViewImpl<CefTextfieldView, CefTextfield, CefTextfieldDelegate>; 20 21 CefTextfieldImpl(const CefTextfieldImpl&) = delete; 22 CefTextfieldImpl& operator=(const CefTextfieldImpl&) = delete; 23 24 // Create a new CefTextfield instance. |delegate| may be nullptr. 25 static CefRefPtr<CefTextfieldImpl> Create( 26 CefRefPtr<CefTextfieldDelegate> delegate); 27 28 // CefTextfield methods: 29 void SetPasswordInput(bool password_input) override; 30 bool IsPasswordInput() override; 31 void SetReadOnly(bool read_only) override; 32 bool IsReadOnly() override; 33 CefString GetText() override; 34 void SetText(const CefString& text) override; 35 void AppendText(const CefString& text) override; 36 void InsertOrReplaceText(const CefString& text) override; 37 bool HasSelection() override; 38 CefString GetSelectedText() override; 39 void SelectAll(bool reversed) override; 40 void ClearSelection() override; 41 CefRange GetSelectedRange() override; 42 void SelectRange(const CefRange& range) override; 43 size_t GetCursorPosition() override; 44 void SetTextColor(cef_color_t color) override; 45 cef_color_t GetTextColor() override; 46 void SetSelectionTextColor(cef_color_t color) override; 47 cef_color_t GetSelectionTextColor() override; 48 void SetSelectionBackgroundColor(cef_color_t color) override; 49 cef_color_t GetSelectionBackgroundColor() override; 50 void SetFontList(const CefString& font_list) override; 51 void ApplyTextColor(cef_color_t color, const CefRange& range) override; 52 void ApplyTextStyle(cef_text_style_t style, 53 bool add, 54 const CefRange& range) override; 55 bool IsCommandEnabled(cef_text_field_commands_t command_id) override; 56 void ExecuteCommand(cef_text_field_commands_t command_id) override; 57 void ClearEditHistory() override; 58 void SetPlaceholderText(const CefString& text) override; 59 CefString GetPlaceholderText() override; 60 void SetPlaceholderTextColor(cef_color_t color) override; 61 void SetAccessibleName(const CefString& name) override; 62 63 // CefView methods: AsTextfield()64 CefRefPtr<CefTextfield> AsTextfield() override { return this; } 65 void SetBackgroundColor(cef_color_t color) override; 66 cef_color_t GetBackgroundColor() override; 67 68 // CefViewAdapter methods: GetDebugType()69 std::string GetDebugType() override { return "Textfield"; } 70 71 private: 72 // Create a new implementation object. 73 // Always call Initialize() after creation. 74 // |delegate| may be nullptr. 75 explicit CefTextfieldImpl(CefRefPtr<CefTextfieldDelegate> delegate); 76 77 // CefViewImpl methods: 78 CefTextfieldView* CreateRootView() override; 79 void InitializeRootView() override; 80 81 IMPLEMENT_REFCOUNTING_DELETE_ON_UIT(CefTextfieldImpl); 82 }; 83 84 #endif // CEF_LIBCEF_BROWSER_VIEWS_TEXTFIELD_IMPL_H_ 85