OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this |
2 // source code is governed by a BSD-style license that can be found in the | 2 // source code is governed by a BSD-style license that can be found in the |
3 // LICENSE file. | 3 // LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_VIEWS_AUTOCOMPLETE_AUTOCOMPLETE_POPUP_CONTENTS_VIEW_H_ | 5 #ifndef CHROME_BROWSER_VIEWS_AUTOCOMPLETE_AUTOCOMPLETE_POPUP_CONTENTS_VIEW_H_ |
6 #define CHROME_BROWSER_VIEWS_AUTOCOMPLETE_AUTOCOMPLETE_POPUP_CONTENTS_VIEW_H_ | 6 #define CHROME_BROWSER_VIEWS_AUTOCOMPLETE_AUTOCOMPLETE_POPUP_CONTENTS_VIEW_H_ |
7 | 7 |
8 #include "app/gfx/font.h" | 8 #include "app/gfx/font.h" |
9 #include "app/slide_animation.h" | 9 #include "app/slide_animation.h" |
10 #include "chrome/browser/autocomplete/autocomplete.h" | 10 #include "chrome/browser/autocomplete/autocomplete.h" |
11 #include "chrome/browser/autocomplete/autocomplete_popup_model.h" | 11 #include "chrome/browser/autocomplete/autocomplete_popup_model.h" |
12 #include "chrome/browser/autocomplete/autocomplete_popup_view.h" | 12 #include "chrome/browser/autocomplete/autocomplete_popup_view.h" |
13 #if defined(OS_WIN) | |
14 #include "chrome/browser/views/autocomplete/autocomplete_popup_win.h" | |
15 #endif | |
16 #include "views/view.h" | 13 #include "views/view.h" |
17 #include "webkit/glue/window_open_disposition.h" | 14 #include "webkit/glue/window_open_disposition.h" |
18 | 15 |
| 16 #if defined(OS_WIN) |
| 17 #include "chrome/browser/views/autocomplete/autocomplete_popup_win.h" |
| 18 #else |
| 19 #include "chrome/browser/views/autocomplete/autocomplete_popup_gtk.h" |
| 20 #endif |
| 21 |
19 class AutocompleteEditModel; | 22 class AutocompleteEditModel; |
20 class AutocompleteEditViewWin; | 23 class AutocompleteEditViewWin; |
21 class AutocompletePopupWin; | |
22 class Profile; | 24 class Profile; |
23 | 25 |
24 // An interface implemented by an object that provides data to populate | 26 // An interface implemented by an object that provides data to populate |
25 // individual result views. | 27 // individual result views. |
26 class AutocompleteResultViewModel { | 28 class AutocompleteResultViewModel { |
27 public: | 29 public: |
28 // Returns true if the index is selected. | 30 // Returns true if the index is selected. |
29 virtual bool IsSelectedIndex(size_t index) const = 0; | 31 virtual bool IsSelectedIndex(size_t index) const = 0; |
30 | 32 |
31 // Called when the line at the specified index should be opened with the | 33 // Called when the line at the specified index should be opened with the |
32 // provided disposition. | 34 // provided disposition. |
33 virtual void OpenIndex(size_t index, WindowOpenDisposition disposition) = 0; | 35 virtual void OpenIndex(size_t index, WindowOpenDisposition disposition) = 0; |
34 | 36 |
35 // Called when the line at the specified index should be shown as hovered. | 37 // Called when the line at the specified index should be shown as hovered. |
36 virtual void SetHoveredLine(size_t index) = 0; | 38 virtual void SetHoveredLine(size_t index) = 0; |
37 | 39 |
38 // Called when the line at the specified index should be shown as selected. | 40 // Called when the line at the specified index should be shown as selected. |
39 virtual void SetSelectedLine(size_t index, bool revert_to_default) = 0; | 41 virtual void SetSelectedLine(size_t index, bool revert_to_default) = 0; |
40 }; | 42 }; |
41 | 43 |
42 // A view representing the contents of the autocomplete popup. | 44 // A view representing the contents of the autocomplete popup. |
43 class AutocompletePopupContentsView : public views::View, | 45 class AutocompletePopupContentsView : public views::View, |
44 public AutocompleteResultViewModel, | 46 public AutocompleteResultViewModel, |
45 public AutocompletePopupView, | 47 public AutocompletePopupView, |
46 public AnimationDelegate { | 48 public AnimationDelegate { |
47 public: | 49 public: |
48 AutocompletePopupContentsView(const gfx::Font& font, | 50 AutocompletePopupContentsView(const gfx::Font& font, |
49 AutocompleteEditViewWin* edit_view, | 51 AutocompleteEditView* edit_view, |
50 AutocompleteEditModel* edit_model, | 52 AutocompleteEditModel* edit_model, |
51 Profile* profile, | 53 Profile* profile, |
52 AutocompletePopupPositioner* popup_positioner); | 54 AutocompletePopupPositioner* popup_positioner); |
53 virtual ~AutocompletePopupContentsView() {} | 55 virtual ~AutocompletePopupContentsView() {} |
54 | 56 |
55 // Returns the bounds the popup should be shown at. This is the display bounds | 57 // Returns the bounds the popup should be shown at. This is the display bounds |
56 // and includes offsets for the dropshadow which this view's border renders. | 58 // and includes offsets for the dropshadow which this view's border renders. |
57 gfx::Rect GetPopupBounds() const; | 59 gfx::Rect GetPopupBounds() const; |
58 | 60 |
59 // Overridden from AutocompletePopupView: | 61 // Overridden from AutocompletePopupView: |
(...skipping 30 matching lines...) Expand all Loading... |
90 | 92 |
91 // Updates the window's blur region for the current size. | 93 // Updates the window's blur region for the current size. |
92 void UpdateBlurRegion(); | 94 void UpdateBlurRegion(); |
93 | 95 |
94 // Makes the contents of the canvas slightly transparent. | 96 // Makes the contents of the canvas slightly transparent. |
95 void MakeCanvasTransparent(gfx::Canvas* canvas); | 97 void MakeCanvasTransparent(gfx::Canvas* canvas); |
96 | 98 |
97 #if defined(OS_WIN) | 99 #if defined(OS_WIN) |
98 // The popup that contains this view. | 100 // The popup that contains this view. |
99 scoped_ptr<AutocompletePopupWin> popup_; | 101 scoped_ptr<AutocompletePopupWin> popup_; |
| 102 #else |
| 103 scoped_ptr<AutocompletePopupGtk> popup_; |
100 #endif | 104 #endif |
101 | 105 |
102 // The provider of our result set. | 106 // The provider of our result set. |
103 scoped_ptr<AutocompletePopupModel> model_; | 107 scoped_ptr<AutocompletePopupModel> model_; |
104 | 108 |
105 // The edit view that invokes us. | 109 // The edit view that invokes us. |
106 AutocompleteEditViewWin* edit_view_; | 110 AutocompleteEditView* edit_view_; |
107 | 111 |
108 // An object that tells the popup how to position itself. | 112 // An object that tells the popup how to position itself. |
109 AutocompletePopupPositioner* popup_positioner_; | 113 AutocompletePopupPositioner* popup_positioner_; |
110 | 114 |
111 // The font that we should use for result rows. This is based on the font used | 115 // The font that we should use for result rows. This is based on the font used |
112 // by the edit that created us. | 116 // by the edit that created us. |
113 gfx::Font result_font_; | 117 gfx::Font result_font_; |
114 | 118 |
115 // The popup sizes vertically using an animation when the popup is getting | 119 // The popup sizes vertically using an animation when the popup is getting |
116 // shorter (not larger, that makes it look "slow"). | 120 // shorter (not larger, that makes it look "slow"). |
117 SlideAnimation size_animation_; | 121 SlideAnimation size_animation_; |
118 gfx::Rect start_bounds_; | 122 gfx::Rect start_bounds_; |
119 gfx::Rect target_bounds_; | 123 gfx::Rect target_bounds_; |
120 | 124 |
121 DISALLOW_COPY_AND_ASSIGN(AutocompletePopupContentsView); | 125 DISALLOW_COPY_AND_ASSIGN(AutocompletePopupContentsView); |
122 }; | 126 }; |
123 | 127 |
124 | 128 |
125 #endif // #ifndef CHROME_BROWSER_VIEWS_AUTOCOMPLETE_AUTOCOMPLETE_POPUP_CONTENTS
_VIEW_H_ | 129 #endif // #ifndef CHROME_BROWSER_VIEWS_AUTOCOMPLETE_AUTOCOMPLETE_POPUP_CONTENTS
_VIEW_H_ |
OLD | NEW |