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" | |
15 #include "app/gtk_signal.h" | 14 #include "app/gtk_signal.h" |
16 #include "app/gtk_signal_registrar.h" | 15 #include "app/gtk_signal_registrar.h" |
17 #include "base/basictypes.h" | 16 #include "base/basictypes.h" |
18 #include "base/scoped_ptr.h" | 17 #include "base/scoped_ptr.h" |
19 #include "base/string_util.h" | 18 #include "base/string_util.h" |
20 #include "chrome/browser/autocomplete/autocomplete_edit_view.h" | 19 #include "chrome/browser/autocomplete/autocomplete_edit_view.h" |
21 #include "chrome/browser/gtk/owned_widget_gtk.h" | 20 #include "chrome/browser/gtk/owned_widget_gtk.h" |
22 #include "chrome/browser/ui/toolbar/toolbar_model.h" | 21 #include "chrome/browser/ui/toolbar/toolbar_model.h" |
23 #include "chrome/common/notification_observer.h" | 22 #include "chrome/common/notification_observer.h" |
24 #include "chrome/common/notification_registrar.h" | 23 #include "chrome/common/notification_registrar.h" |
25 #include "chrome/common/page_transition_types.h" | 24 #include "chrome/common/page_transition_types.h" |
26 #include "gfx/rect.h" | 25 #include "gfx/rect.h" |
| 26 #include "ui/base/animation/animation_delegate.h" |
27 #include "webkit/glue/window_open_disposition.h" | 27 #include "webkit/glue/window_open_disposition.h" |
28 | 28 |
29 class AutocompleteEditController; | 29 class AutocompleteEditController; |
30 class AutocompleteEditModel; | 30 class AutocompleteEditModel; |
31 class AutocompletePopupView; | 31 class AutocompletePopupView; |
32 class MultiAnimation; | |
33 class Profile; | 32 class Profile; |
34 class TabContents; | 33 class TabContents; |
35 | 34 |
36 namespace gfx{ | 35 namespace gfx { |
37 class Font; | 36 class Font; |
38 } | 37 } |
39 | 38 |
| 39 namespace ui { |
| 40 class MultiAnimation; |
| 41 } |
| 42 |
40 namespace views { | 43 namespace views { |
41 class View; | 44 class View; |
42 } | 45 } |
43 | 46 |
44 #if !defined(TOOLKIT_VIEWS) | 47 #if !defined(TOOLKIT_VIEWS) |
45 class GtkThemeProvider; | 48 class GtkThemeProvider; |
46 #endif | 49 #endif |
47 | 50 |
48 class AutocompleteEditViewGtk : public AutocompleteEditView, | 51 class AutocompleteEditViewGtk : public AutocompleteEditView, |
49 public NotificationObserver, | 52 public NotificationObserver, |
50 public AnimationDelegate { | 53 public ui::AnimationDelegate { |
51 public: | 54 public: |
52 // Modeled like the Windows CHARRANGE. Represent a pair of cursor position | 55 // Modeled like the Windows CHARRANGE. Represent a pair of cursor position |
53 // offsets. Since GtkTextIters are invalid after the buffer is changed, we | 56 // offsets. Since GtkTextIters are invalid after the buffer is changed, we |
54 // work in character offsets (not bytes). | 57 // work in character offsets (not bytes). |
55 struct CharRange { | 58 struct CharRange { |
56 CharRange() : cp_min(0), cp_max(0) { } | 59 CharRange() : cp_min(0), cp_max(0) { } |
57 CharRange(int n, int x) : cp_min(n), cp_max(x) { } | 60 CharRange(int n, int x) : cp_min(n), cp_max(x) { } |
58 | 61 |
59 // Returns the start/end of the selection. | 62 // Returns the start/end of the selection. |
60 int selection_min() const { return std::min(cp_min, cp_max); } | 63 int selection_min() const { return std::min(cp_min, cp_max); } |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 virtual void OnBeforePossibleChange(); | 145 virtual void OnBeforePossibleChange(); |
143 virtual bool OnAfterPossibleChange(); | 146 virtual bool OnAfterPossibleChange(); |
144 virtual gfx::NativeView GetNativeView() const; | 147 virtual gfx::NativeView GetNativeView() const; |
145 virtual CommandUpdater* GetCommandUpdater(); | 148 virtual CommandUpdater* GetCommandUpdater(); |
146 | 149 |
147 // Overridden from NotificationObserver: | 150 // Overridden from NotificationObserver: |
148 virtual void Observe(NotificationType type, | 151 virtual void Observe(NotificationType type, |
149 const NotificationSource& source, | 152 const NotificationSource& source, |
150 const NotificationDetails& details); | 153 const NotificationDetails& details); |
151 | 154 |
152 // Overridden from AnimationDelegate. | 155 // Overridden from ui::AnimationDelegate. |
153 virtual void AnimationEnded(const Animation* animation); | 156 virtual void AnimationEnded(const ui::Animation* animation); |
154 virtual void AnimationProgressed(const Animation* animation); | 157 virtual void AnimationProgressed(const ui::Animation* animation); |
155 virtual void AnimationCanceled(const Animation* animation); | 158 virtual void AnimationCanceled(const ui::Animation* animation); |
156 | 159 |
157 // Sets the colors of the text view according to the theme. | 160 // Sets the colors of the text view according to the theme. |
158 void SetBaseColor(); | 161 void SetBaseColor(); |
159 // Sets the colors of the instant suggestion view according to the theme and | 162 // Sets the colors of the instant suggestion view according to the theme and |
160 // the animation state. | 163 // the animation state. |
161 void UpdateInstantViewColors(); | 164 void UpdateInstantViewColors(); |
162 | 165 |
163 void SetInstantSuggestion(const std::string& suggestion); | 166 void SetInstantSuggestion(const std::string& suggestion); |
164 bool CommitInstantSuggestion(); | 167 bool CommitInstantSuggestion(); |
165 | 168 |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
359 GtkTextTag* normal_text_tag_; | 362 GtkTextTag* normal_text_tag_; |
360 | 363 |
361 // Objects for the instant suggestion text view. | 364 // Objects for the instant suggestion text view. |
362 GtkTextTag* instant_anchor_tag_; | 365 GtkTextTag* instant_anchor_tag_; |
363 | 366 |
364 // A widget for displaying instant suggestion text. It'll be attached to a | 367 // A widget for displaying instant suggestion text. It'll be attached to a |
365 // child anchor in the |text_buffer_| object. | 368 // child anchor in the |text_buffer_| object. |
366 GtkWidget* instant_view_; | 369 GtkWidget* instant_view_; |
367 // Animation from instant suggest (faded text) to autocomplete (selected | 370 // Animation from instant suggest (faded text) to autocomplete (selected |
368 // text). | 371 // text). |
369 scoped_ptr<MultiAnimation> instant_animation_; | 372 scoped_ptr<ui::MultiAnimation> instant_animation_; |
370 | 373 |
371 // A mark to split the content and the instant anchor. Wherever the end | 374 // A mark to split the content and the instant anchor. Wherever the end |
372 // iterator of the text buffer is required, the iterator to this mark should | 375 // iterator of the text buffer is required, the iterator to this mark should |
373 // be used. | 376 // be used. |
374 GtkTextMark* instant_mark_; | 377 GtkTextMark* instant_mark_; |
375 | 378 |
376 scoped_ptr<AutocompleteEditModel> model_; | 379 scoped_ptr<AutocompleteEditModel> model_; |
377 scoped_ptr<AutocompletePopupView> popup_view_; | 380 scoped_ptr<AutocompletePopupView> popup_view_; |
378 AutocompleteEditController* controller_; | 381 AutocompleteEditController* controller_; |
379 ToolbarModel* toolbar_model_; | 382 ToolbarModel* toolbar_model_; |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
511 // The view that is going to be focused next. Only valid while handling | 514 // The view that is going to be focused next. Only valid while handling |
512 // "focus-out" events. | 515 // "focus-out" events. |
513 GtkWidget* going_to_focus_; | 516 GtkWidget* going_to_focus_; |
514 | 517 |
515 GtkSignalRegistrar signals_; | 518 GtkSignalRegistrar signals_; |
516 | 519 |
517 DISALLOW_COPY_AND_ASSIGN(AutocompleteEditViewGtk); | 520 DISALLOW_COPY_AND_ASSIGN(AutocompleteEditViewGtk); |
518 }; | 521 }; |
519 | 522 |
520 #endif // CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_EDIT_VIEW_GTK_H_ | 523 #endif // CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_EDIT_VIEW_GTK_H_ |
OLD | NEW |