Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_UI_VIEWS_AUTOCOMPLETE_AUTOCOMPLETE_POPUP_CONTENTS_VIEW_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_AUTOCOMPLETE_AUTOCOMPLETE_POPUP_CONTENTS_VIEW_H_ |
| 6 #define CHROME_BROWSER_UI_VIEWS_AUTOCOMPLETE_AUTOCOMPLETE_POPUP_CONTENTS_VIEW_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_AUTOCOMPLETE_AUTOCOMPLETE_POPUP_CONTENTS_VIEW_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "chrome/browser/autocomplete/autocomplete.h" | 9 #include "chrome/browser/autocomplete/autocomplete.h" |
| 10 #include "chrome/browser/autocomplete/autocomplete_popup_model.h" | 10 #include "chrome/browser/autocomplete/autocomplete_popup_model.h" |
| 11 #include "chrome/browser/autocomplete/autocomplete_popup_view.h" | 11 #include "chrome/browser/autocomplete/autocomplete_popup_view.h" |
| 12 #include "chrome/browser/ui/views/autocomplete/autocomplete_result_view.h" | |
| 12 #include "ui/base/animation/animation_delegate.h" | 13 #include "ui/base/animation/animation_delegate.h" |
| 13 #include "ui/base/animation/slide_animation.h" | 14 #include "ui/base/animation/slide_animation.h" |
| 14 #include "ui/gfx/font.h" | 15 #include "ui/gfx/canvas_skia.h" |
| 15 #include "views/view.h" | 16 #include "views/view.h" |
| 16 #include "webkit/glue/window_open_disposition.h" | 17 #include "webkit/glue/window_open_disposition.h" |
| 17 | 18 |
| 18 #if defined(OS_WIN) | 19 #if defined(OS_WIN) |
| 19 #include "chrome/browser/ui/views/autocomplete/autocomplete_popup_win.h" | 20 #include "chrome/browser/ui/views/autocomplete/autocomplete_popup_win.h" |
| 20 #else | 21 #else |
| 21 #include "chrome/browser/ui/views/autocomplete/autocomplete_popup_gtk.h" | 22 #include "chrome/browser/ui/views/autocomplete/autocomplete_popup_gtk.h" |
| 22 #endif | 23 #endif |
| 23 | 24 |
| 24 class AutocompleteEditModel; | 25 class AutocompleteEditModel; |
| 25 class AutocompleteEditViewWin; | 26 class AutocompleteEditViewWin; |
| 26 struct AutocompleteMatch; | 27 struct AutocompleteMatch; |
| 27 class BubbleBorder; | 28 class BubbleBorder; |
| 28 class Profile; | 29 class Profile; |
| 29 | 30 |
| 30 // An interface implemented by an object that provides data to populate | 31 namespace gfx { |
| 31 // individual result views. | 32 class Insets; |
| 32 class AutocompleteResultViewModel { | 33 } |
| 33 public: | |
| 34 // Returns true if the index is selected. | |
| 35 virtual bool IsSelectedIndex(size_t index) const = 0; | |
| 36 | |
| 37 // Returns true if the index is hovered. | |
| 38 virtual bool IsHoveredIndex(size_t index) const = 0; | |
| 39 | |
| 40 // Returns the special-case icon we should use for the given index, or NULL | |
| 41 // if we should use the default icon. | |
| 42 virtual const SkBitmap* GetSpecialIcon(size_t index) const = 0; | |
| 43 }; | |
| 44 | 34 |
| 45 // A view representing the contents of the autocomplete popup. | 35 // A view representing the contents of the autocomplete popup. |
| 46 class AutocompletePopupContentsView : public views::View, | 36 class AutocompletePopupContentsView : public views::View, |
| 47 public AutocompleteResultViewModel, | 37 public AutocompleteResultViewModel, |
| 48 public AutocompletePopupView, | 38 public AutocompletePopupView, |
| 49 public ui::AnimationDelegate { | 39 public ui::AnimationDelegate { |
| 50 public: | 40 public: |
| 51 AutocompletePopupContentsView(const gfx::Font& font, | 41 AutocompletePopupContentsView(const gfx::Font& font, |
| 52 AutocompleteEditView* edit_view, | 42 AutocompleteEditView* edit_view, |
| 53 AutocompleteEditModel* edit_model, | 43 AutocompleteEditModel* edit_model, |
| 54 Profile* profile, | 44 Profile* profile, |
| 55 const views::View* location_bar); | 45 const views::View* location_bar); |
| 56 virtual ~AutocompletePopupContentsView(); | 46 virtual ~AutocompletePopupContentsView(); |
| 57 | 47 |
| 48 AutocompletePopupModel* model() { return model_.get(); } | |
|
Peter Kasting
2011/02/16 00:50:35
Do we need these public accessors? Wouldn't simpl
varunjain
2011/02/16 18:48:10
Done.
| |
| 49 views::View* opt_in_view() { return opt_in_view_; } | |
| 50 | |
| 58 // Returns the bounds the popup should be shown at. This is the display bounds | 51 // Returns the bounds the popup should be shown at. This is the display bounds |
| 59 // and includes offsets for the dropshadow which this view's border renders. | 52 // and includes offsets for the dropshadow which this view's border renders. |
| 60 gfx::Rect GetPopupBounds() const; | 53 gfx::Rect GetPopupBounds() const; |
| 61 | 54 |
| 62 // Overridden from AutocompletePopupView: | 55 // Overridden from AutocompletePopupView: |
| 63 virtual bool IsOpen() const; | 56 virtual bool IsOpen() const; |
| 64 virtual void InvalidateLine(size_t line); | 57 virtual void InvalidateLine(size_t line); |
| 65 virtual void UpdatePopupAppearance(); | 58 virtual void UpdatePopupAppearance(); |
| 66 virtual gfx::Rect GetTargetBounds(); | 59 virtual gfx::Rect GetTargetBounds(); |
| 67 virtual void PaintUpdatesNow(); | 60 virtual void PaintUpdatesNow(); |
| 68 virtual void OnDragCanceled(); | 61 virtual void OnDragCanceled(); |
| 69 virtual AutocompletePopupModel* GetModel(); | 62 virtual AutocompletePopupModel* GetModel(); |
| 70 | 63 |
| 71 // Overridden from AutocompleteResultViewModel: | 64 // Overridden from AutocompleteResultViewModel: |
| 72 virtual bool IsSelectedIndex(size_t index) const; | 65 virtual bool IsSelectedIndex(size_t index) const; |
| 73 virtual bool IsHoveredIndex(size_t index) const; | 66 virtual bool IsHoveredIndex(size_t index) const; |
| 74 virtual const SkBitmap* GetSpecialIcon(size_t index) const; | 67 virtual const SkBitmap* GetSpecialIcon(size_t index) const; |
| 75 | 68 |
| 76 // Overridden from ui::AnimationDelegate: | 69 // Overridden from ui::AnimationDelegate: |
| 77 virtual void AnimationProgressed(const ui::Animation* animation); | 70 virtual void AnimationProgressed(const ui::Animation* animation); |
| 78 | 71 |
| 79 // Overridden from views::View: | 72 // Overridden from views::View: |
| 80 virtual void Paint(gfx::Canvas* canvas); | 73 virtual void Paint(gfx::Canvas* canvas); |
| 81 virtual void PaintChildren(gfx::Canvas* canvas) { | 74 virtual void PaintChildren(gfx::CanvasSkia* canvas); |
| 82 // We paint our children inside Paint(). | |
| 83 } | |
| 84 virtual void Layout(); | 75 virtual void Layout(); |
| 76 virtual void LayoutChildren(); | |
| 85 virtual void OnMouseEntered(const views::MouseEvent& event); | 77 virtual void OnMouseEntered(const views::MouseEvent& event); |
| 86 virtual void OnMouseMoved(const views::MouseEvent& event); | 78 virtual void OnMouseMoved(const views::MouseEvent& event); |
| 87 virtual void OnMouseExited(const views::MouseEvent& event); | 79 virtual void OnMouseExited(const views::MouseEvent& event); |
| 88 virtual bool OnMousePressed(const views::MouseEvent& event); | 80 virtual bool OnMousePressed(const views::MouseEvent& event); |
| 89 virtual void OnMouseReleased(const views::MouseEvent& event, bool canceled); | 81 virtual void OnMouseReleased(const views::MouseEvent& event, bool canceled); |
| 90 virtual bool OnMouseDragged(const views::MouseEvent& event); | 82 virtual bool OnMouseDragged(const views::MouseEvent& event); |
| 91 virtual views::View* GetViewForPoint(const gfx::Point& point); | 83 virtual views::View* GetViewForPoint(const gfx::Point& point); |
| 92 | 84 |
| 85 protected: | |
| 86 // Calculates the height needed to show all the results in the model. | |
| 87 virtual int CalculatePopupHeight(); | |
| 88 virtual AutocompleteResultView* CreateResultView( | |
| 89 AutocompleteResultViewModel* model, | |
| 90 int model_index, | |
| 91 const gfx::Font& font, | |
| 92 const gfx::Font& bold_font); | |
| 93 | |
| 93 private: | 94 private: |
| 94 #if defined(OS_WIN) | 95 #if defined(OS_WIN) |
| 95 typedef AutocompletePopupWin AutocompletePopupClass; | 96 typedef AutocompletePopupWin AutocompletePopupClass; |
| 96 #else | 97 #else |
| 97 typedef AutocompletePopupGtk AutocompletePopupClass; | 98 typedef AutocompletePopupGtk AutocompletePopupClass; |
| 98 #endif | 99 #endif |
| 99 class InstantOptInView; | 100 class InstantOptInView; |
| 100 | 101 |
| 101 // Returns true if the model has a match at the specified index. | 102 // Returns true if the model has a match at the specified index. |
| 102 bool HasMatchAt(size_t index) const; | 103 bool HasMatchAt(size_t index) const; |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 169 gfx::Rect start_bounds_; | 170 gfx::Rect start_bounds_; |
| 170 gfx::Rect target_bounds_; | 171 gfx::Rect target_bounds_; |
| 171 | 172 |
| 172 // If non-NULL the instant opt-in-view is visible. | 173 // If non-NULL the instant opt-in-view is visible. |
| 173 views::View* opt_in_view_; | 174 views::View* opt_in_view_; |
| 174 | 175 |
| 175 DISALLOW_COPY_AND_ASSIGN(AutocompletePopupContentsView); | 176 DISALLOW_COPY_AND_ASSIGN(AutocompletePopupContentsView); |
| 176 }; | 177 }; |
| 177 | 178 |
| 178 #endif // CHROME_BROWSER_UI_VIEWS_AUTOCOMPLETE_AUTOCOMPLETE_POPUP_CONTENTS_VIEW _H_ | 179 #endif // CHROME_BROWSER_UI_VIEWS_AUTOCOMPLETE_AUTOCOMPLETE_POPUP_CONTENTS_VIEW _H_ |
| OLD | NEW |