OLD | NEW |
| (Empty) |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef UI_VIEWS_CONTROLS_TEXTFIELD_NATIVE_TEXTFIELD_GTK_H_ | |
6 #define UI_VIEWS_CONTROLS_TEXTFIELD_NATIVE_TEXTFIELD_GTK_H_ | |
7 #pragma once | |
8 | |
9 #include <gtk/gtk.h> | |
10 | |
11 #include "base/string16.h" | |
12 #include "ui/base/gtk/gtk_signal.h" | |
13 #include "ui/views/controls/native_control_gtk.h" | |
14 #include "ui/views/controls/textfield/native_textfield_wrapper.h" | |
15 | |
16 namespace gfx { | |
17 class SelectionModel; | |
18 } | |
19 | |
20 namespace views { | |
21 | |
22 class NativeTextfieldGtk : public NativeControlGtk, | |
23 public NativeTextfieldWrapper { | |
24 public: | |
25 explicit NativeTextfieldGtk(Textfield* parent); | |
26 virtual ~NativeTextfieldGtk(); | |
27 | |
28 // Returns the textfield this NativeTextfieldGtk wraps. | |
29 Textfield* textfield() const { return textfield_; } | |
30 | |
31 // Returns the inner border of the entry. | |
32 static gfx::Insets GetEntryInnerBorder(GtkEntry* entry); | |
33 static gfx::Insets GetTextViewInnerBorder(GtkTextView* text_view); | |
34 | |
35 // Overridden from NativeTextfieldWrapper: | |
36 virtual string16 GetText() const OVERRIDE; | |
37 virtual void UpdateText() OVERRIDE; | |
38 virtual void AppendText(const string16& text) OVERRIDE; | |
39 virtual string16 GetSelectedText() const OVERRIDE; | |
40 virtual void SelectAll() OVERRIDE; | |
41 virtual void ClearSelection() OVERRIDE; | |
42 virtual void UpdateBorder() OVERRIDE; | |
43 virtual void UpdateTextColor() OVERRIDE; | |
44 virtual void UpdateBackgroundColor() OVERRIDE; | |
45 virtual void UpdateCursorColor() OVERRIDE; | |
46 virtual void UpdateReadOnly() OVERRIDE; | |
47 virtual void UpdateFont() OVERRIDE; | |
48 virtual void UpdateIsObscured() OVERRIDE; | |
49 virtual void UpdateEnabled() OVERRIDE; | |
50 virtual gfx::Insets CalculateInsets() OVERRIDE; | |
51 virtual void UpdateHorizontalMargins() OVERRIDE; | |
52 virtual void UpdateVerticalMargins() OVERRIDE; | |
53 virtual bool SetFocus() OVERRIDE; | |
54 virtual View* GetView() OVERRIDE; | |
55 virtual gfx::NativeView GetTestingHandle() const OVERRIDE; | |
56 virtual bool IsIMEComposing() const OVERRIDE; | |
57 virtual void GetSelectedRange(ui::Range* range) const OVERRIDE; | |
58 virtual void SelectRange(const ui::Range& range) OVERRIDE; | |
59 virtual void GetSelectionModel(gfx::SelectionModel* sel) const OVERRIDE; | |
60 virtual void SelectSelectionModel(const gfx::SelectionModel& sel) OVERRIDE; | |
61 virtual size_t GetCursorPosition() const OVERRIDE; | |
62 virtual bool HandleKeyPressed(const views::KeyEvent& e) OVERRIDE; | |
63 virtual bool HandleKeyReleased(const views::KeyEvent& e) OVERRIDE; | |
64 virtual void HandleFocus() OVERRIDE; | |
65 virtual void HandleBlur() OVERRIDE; | |
66 virtual ui::TextInputClient* GetTextInputClient() OVERRIDE; | |
67 virtual void ApplyStyleRange(const gfx::StyleRange& style) OVERRIDE; | |
68 virtual void ApplyDefaultStyle() OVERRIDE; | |
69 virtual void ClearEditHistory() OVERRIDE; | |
70 virtual int GetFontHeight() OVERRIDE; | |
71 | |
72 // Overridden from NativeControlGtk: | |
73 virtual void CreateNativeControl() OVERRIDE; | |
74 virtual void NativeControlCreated(GtkWidget* widget) OVERRIDE; | |
75 | |
76 // Returns true if the textfield is obscured (shown as *****). | |
77 bool IsObscured(); | |
78 | |
79 private: | |
80 // Gtk signal callbacks. | |
81 CHROMEGTK_CALLBACK_0(NativeTextfieldGtk, void, OnActivate); | |
82 CHROMEGTK_CALLBACK_1(NativeTextfieldGtk, gboolean, OnButtonPressEvent, | |
83 GdkEventButton*); | |
84 CHROMEGTK_CALLBACK_1(NativeTextfieldGtk, gboolean, OnButtonReleaseEventAfter, | |
85 GdkEventButton*); | |
86 CHROMEG_CALLBACK_0(NativeTextfieldGtk, void, OnChanged, GObject*); | |
87 CHROMEGTK_CALLBACK_1(NativeTextfieldGtk, gboolean, OnKeyPressEvent, | |
88 GdkEventKey*); | |
89 CHROMEGTK_CALLBACK_1(NativeTextfieldGtk, gboolean, OnKeyPressEventAfter, | |
90 GdkEventKey*); | |
91 CHROMEGTK_CALLBACK_3(NativeTextfieldGtk, void, OnMoveCursor, | |
92 GtkMovementStep, gint, gboolean); | |
93 CHROMEGTK_CALLBACK_0(NativeTextfieldGtk, void, OnPasteClipboard); | |
94 | |
95 Textfield* textfield_; | |
96 | |
97 // Indicates that user requested to paste clipboard. | |
98 // The actual paste clipboard action might be performed later if the | |
99 // clipboard is not empty. | |
100 bool paste_clipboard_requested_; | |
101 | |
102 DISALLOW_COPY_AND_ASSIGN(NativeTextfieldGtk); | |
103 }; | |
104 | |
105 } // namespace views | |
106 | |
107 #endif // UI_VIEWS_CONTROLS_TEXTFIELD_NATIVE_TEXTFIELD_GTK_H_ | |
OLD | NEW |