OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_EDIT_VIEW_GTK_H_ | 5 #ifndef CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_EDIT_VIEW_GTK_H_ |
6 #define CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_EDIT_VIEW_GTK_H_ | 6 #define CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_EDIT_VIEW_GTK_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <gtk/gtk.h> | 9 #include <gtk/gtk.h> |
10 | 10 |
11 #include <algorithm> | 11 #include <algorithm> |
12 #include <string> | 12 #include <string> |
13 | 13 |
14 #include "app/animation_delegate.h" | 14 #include "app/animation_delegate.h" |
15 #include "app/gtk_signal.h" | 15 #include "app/gtk_signal.h" |
16 #include "app/gtk_signal_registrar.h" | 16 #include "app/gtk_signal_registrar.h" |
17 #include "base/basictypes.h" | 17 #include "base/basictypes.h" |
18 #include "base/scoped_ptr.h" | 18 #include "base/scoped_ptr.h" |
19 #include "base/string_util.h" | 19 #include "base/string_util.h" |
20 #include "chrome/browser/autocomplete/autocomplete_edit_view.h" | 20 #include "chrome/browser/autocomplete/autocomplete_edit_view.h" |
21 #include "chrome/browser/gtk/owned_widget_gtk.h" | 21 #include "chrome/browser/gtk/owned_widget_gtk.h" |
22 #include "chrome/browser/ui/toolbar/toolbar_model.h" | 22 #include "chrome/browser/ui/toolbar/toolbar_model.h" |
23 #include "chrome/common/notification_observer.h" | 23 #include "chrome/common/notification_observer.h" |
24 #include "chrome/common/notification_registrar.h" | 24 #include "chrome/common/notification_registrar.h" |
25 #include "chrome/common/page_transition_types.h" | 25 #include "chrome/common/page_transition_types.h" |
26 #include "gfx/rect.h" | 26 #include "gfx/rect.h" |
27 #include "webkit/glue/window_open_disposition.h" | 27 #include "webkit/glue/window_open_disposition.h" |
28 | 28 |
| 29 class AccessibleWidgetHelper; |
29 class AutocompleteEditController; | 30 class AutocompleteEditController; |
30 class AutocompleteEditModel; | 31 class AutocompleteEditModel; |
31 class AutocompletePopupView; | 32 class AutocompletePopupView; |
32 class MultiAnimation; | 33 class MultiAnimation; |
33 class Profile; | 34 class Profile; |
34 class TabContents; | 35 class TabContents; |
35 | 36 |
36 namespace gfx{ | 37 namespace gfx{ |
37 class Font; | 38 class Font; |
38 } | 39 } |
(...skipping 25 matching lines...) Expand all Loading... |
64 int cp_min; // For a selection: Represents the start. | 65 int cp_min; // For a selection: Represents the start. |
65 int cp_max; // For a selection: Represents the end (insert position). | 66 int cp_max; // For a selection: Represents the end (insert position). |
66 }; | 67 }; |
67 | 68 |
68 AutocompleteEditViewGtk(AutocompleteEditController* controller, | 69 AutocompleteEditViewGtk(AutocompleteEditController* controller, |
69 ToolbarModel* toolbar_model, | 70 ToolbarModel* toolbar_model, |
70 Profile* profile, | 71 Profile* profile, |
71 CommandUpdater* command_updater, | 72 CommandUpdater* command_updater, |
72 bool popup_window_mode, | 73 bool popup_window_mode, |
73 #if defined(TOOLKIT_VIEWS) | 74 #if defined(TOOLKIT_VIEWS) |
74 const views::View* location_bar); | 75 const views::View* location_bar |
75 #else | 76 #else |
76 GtkWidget* location_bar); | 77 GtkWidget* location_bar |
77 #endif | 78 #endif |
78 ~AutocompleteEditViewGtk(); | 79 ); |
| 80 virtual ~AutocompleteEditViewGtk(); |
79 | 81 |
80 // Initialize, create the underlying widgets, etc. | 82 // Initialize, create the underlying widgets, etc. |
81 void Init(); | 83 void Init(); |
82 | |
83 // Returns the width in pixels needed to display the current text. The | |
84 // returned value includes margins. | |
85 int TextWidth(); | |
86 | |
87 // Returns the width in pixels needed to display the text from one character | 84 // Returns the width in pixels needed to display the text from one character |
88 // before the caret to the end of the string. See comments in | 85 // before the caret to the end of the string. See comments in |
89 // LocationBarView::Layout as to why this uses -1. | 86 // LocationBarView::Layout as to why this uses -1. |
90 int WidthOfTextAfterCursor(); | 87 int WidthOfTextAfterCursor(); |
91 | 88 |
92 // Returns the font. | 89 // Returns the font. |
93 gfx::Font GetFont(); | 90 gfx::Font GetFont(); |
94 | 91 |
95 // Implement the AutocompleteEditView interface. | 92 // Implement the AutocompleteEditView interface. |
96 virtual AutocompleteEditModel* model(); | 93 virtual AutocompleteEditModel* model(); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 | 133 |
137 virtual void OnTemporaryTextMaybeChanged(const std::wstring& display_text, | 134 virtual void OnTemporaryTextMaybeChanged(const std::wstring& display_text, |
138 bool save_original_selection); | 135 bool save_original_selection); |
139 virtual bool OnInlineAutocompleteTextMaybeChanged( | 136 virtual bool OnInlineAutocompleteTextMaybeChanged( |
140 const std::wstring& display_text, size_t user_text_length); | 137 const std::wstring& display_text, size_t user_text_length); |
141 virtual void OnRevertTemporaryText(); | 138 virtual void OnRevertTemporaryText(); |
142 virtual void OnBeforePossibleChange(); | 139 virtual void OnBeforePossibleChange(); |
143 virtual bool OnAfterPossibleChange(); | 140 virtual bool OnAfterPossibleChange(); |
144 virtual gfx::NativeView GetNativeView() const; | 141 virtual gfx::NativeView GetNativeView() const; |
145 virtual CommandUpdater* GetCommandUpdater(); | 142 virtual CommandUpdater* GetCommandUpdater(); |
| 143 #if defined(TOOLKIT_VIEWS) |
| 144 virtual views::View* AddToView(views::View* parent); |
| 145 virtual bool CommitInstantSuggestion(const std::wstring& typed_text, |
| 146 const std::wstring& suggested_text); |
| 147 virtual void SetInstantSuggestion(const string16& suggestion); |
| 148 |
| 149 // Enables accessibility on AutocompleteEditView. |
| 150 void EnableAccessibility(); |
| 151 |
| 152 // A factory method to create an AutocompleteEditView instance initialized for |
| 153 // linux_views. This currently returns an instance of |
| 154 // AutocompleteEditViewGtk only, but AutocompleteEditViewViews will |
| 155 // be added as an option when TextfieldViews is enabled. |
| 156 static AutocompleteEditView* Create(AutocompleteEditController* controller, |
| 157 ToolbarModel* toolbar_model, |
| 158 Profile* profile, |
| 159 CommandUpdater* command_updater, |
| 160 bool popup_window_mode, |
| 161 const views::View* location_bar); |
| 162 #endif |
| 163 virtual int TextWidth() const; |
146 | 164 |
147 // Overridden from NotificationObserver: | 165 // Overridden from NotificationObserver: |
148 virtual void Observe(NotificationType type, | 166 virtual void Observe(NotificationType type, |
149 const NotificationSource& source, | 167 const NotificationSource& source, |
150 const NotificationDetails& details); | 168 const NotificationDetails& details); |
151 | 169 |
152 // Overridden from AnimationDelegate. | 170 // Overridden from AnimationDelegate. |
153 virtual void AnimationEnded(const Animation* animation); | 171 virtual void AnimationEnded(const Animation* animation); |
154 virtual void AnimationProgressed(const Animation* animation); | 172 virtual void AnimationProgressed(const Animation* animation); |
155 virtual void AnimationCanceled(const Animation* animation); | 173 virtual void AnimationCanceled(const Animation* animation); |
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
507 // track preedit_'s content, as it'll be treated as part of text content. | 525 // track preedit_'s content, as it'll be treated as part of text content. |
508 size_t preedit_size_before_change_; | 526 size_t preedit_size_before_change_; |
509 #endif | 527 #endif |
510 | 528 |
511 // The view that is going to be focused next. Only valid while handling | 529 // The view that is going to be focused next. Only valid while handling |
512 // "focus-out" events. | 530 // "focus-out" events. |
513 GtkWidget* going_to_focus_; | 531 GtkWidget* going_to_focus_; |
514 | 532 |
515 GtkSignalRegistrar signals_; | 533 GtkSignalRegistrar signals_; |
516 | 534 |
| 535 #if defined(TOOLKIT_VIEWS) |
| 536 scoped_ptr<AccessibleWidgetHelper> accessible_widget_helper_; |
| 537 #endif |
| 538 |
517 DISALLOW_COPY_AND_ASSIGN(AutocompleteEditViewGtk); | 539 DISALLOW_COPY_AND_ASSIGN(AutocompleteEditViewGtk); |
518 }; | 540 }; |
519 | 541 |
520 #endif // CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_EDIT_VIEW_GTK_H_ | 542 #endif // CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_EDIT_VIEW_GTK_H_ |
OLD | NEW |