OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2009 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 // Draws the view for the balloons. |
| 6 |
| 7 #ifndef CHROME_BROWSER_NOTIFICATIONS_BALLOON_VIEW_H_ |
| 8 #define CHROME_BROWSER_NOTIFICATIONS_BALLOON_VIEW_H_ |
| 9 |
| 10 #include "app/slide_animation.h" |
| 11 #include "base/basictypes.h" |
| 12 #include "base/gfx/point.h" |
| 13 #include "base/gfx/rect.h" |
| 14 #include "base/gfx/size.h" |
| 15 #include "base/scoped_ptr.h" |
| 16 #include "base/task.h" |
| 17 #include "chrome/common/notification_registrar.h" |
| 18 #include "chrome/common/notification_service.h" |
| 19 #include "views/view.h" |
| 20 |
| 21 namespace views { |
| 22 class WidgetWin; |
| 23 class ImagePainter; |
| 24 class TextButton; |
| 25 class ButtonListener; |
| 26 } // namespace views |
| 27 |
| 28 class Balloon; |
| 29 class BalloonContents; |
| 30 class NotificationDetails; |
| 31 class NotificationSource; |
| 32 |
| 33 class SlideAnimation; |
| 34 |
| 35 class BalloonView : public views::View, |
| 36 public NotificationObserver, |
| 37 public AnimationDelegate { |
| 38 public: |
| 39 BalloonView(); |
| 40 ~BalloonView(); |
| 41 void Show(Balloon* balloon); |
| 42 void RepositionToBalloon(); |
| 43 void Close(); |
| 44 |
| 45 private: |
| 46 // Overridden from views::View. |
| 47 virtual void Paint(gfx::Canvas* canvas); |
| 48 virtual void DidChangeBounds(const gfx::Rect& previous, |
| 49 const gfx::Rect& current); |
| 50 virtual gfx::Size GetPreferredSize() { |
| 51 return gfx::Size(1000, 1000); |
| 52 } |
| 53 |
| 54 // Initialize the view, parented to |parent|, and show it. |
| 55 void Init(HWND parent); |
| 56 |
| 57 // NotificationObserver method. |
| 58 virtual void Observe(NotificationType type, |
| 59 const NotificationSource& source, |
| 60 const NotificationDetails& details); |
| 61 |
| 62 // AnimationDelegate method. |
| 63 virtual void AnimationProgressed(const Animation* animation); |
| 64 |
| 65 // How to mask the balloon contents to fit within the frame. |
| 66 // The caller is responsible for deleting the returned object. |
| 67 HRGN GetContentsMask(gfx::Rect& contents_rect) const; |
| 68 |
| 69 // Adjust the contents window size to be appropriate for the frame. |
| 70 void SizeContentsWindow(); |
| 71 |
| 72 // Do the delayed close work. |
| 73 void DelayedClose(); |
| 74 |
| 75 // True after Init() has completed. |
| 76 bool initialized_; |
| 77 |
| 78 // The height of the balloon's shelf. |
| 79 // The shelf is where is close button is located. |
| 80 int shelf_height() const; |
| 81 |
| 82 // The width of the frame (not including any shadow). |
| 83 int frame_width() const; |
| 84 |
| 85 // The height of the frame (not including any shadow). |
| 86 int total_frame_height() const; |
| 87 |
| 88 // The height of the part of the frame around the balloon. |
| 89 int balloon_frame_height() const; |
| 90 |
| 91 // Where the balloon contents should be placed with respect to the top left |
| 92 // of the frame. |
| 93 gfx::Point contents_offset() const; |
| 94 |
| 95 // Where the balloon contents should be in screen coordinates. |
| 96 gfx::Rect contents_rectangle() const; |
| 97 |
| 98 // The associated balloon. |
| 99 Balloon* balloon_; |
| 100 |
| 101 // The window that contains the BalloonFrame. |
| 102 views::WidgetWin* frame_container_; |
| 103 |
| 104 // The window that contains the BalloonContents. |
| 105 views::WidgetWin* html_container_; |
| 106 |
| 107 // The html content renderer. |
| 108 BalloonContents* html_contents_; |
| 109 |
| 110 // The following factory is used to call methods at a later time. |
| 111 ScopedRunnableMethodFactory<BalloonView> method_factory_; |
| 112 |
| 113 scoped_ptr<views::ImagePainter> shelf_background_; |
| 114 scoped_ptr<views::ImagePainter> balloon_background_; |
| 115 |
| 116 views::TextButton* close_button_; |
| 117 scoped_ptr<views::ButtonListener> close_button_listener_; |
| 118 |
| 119 // An animation to move the balloon on the screen as the collection |
| 120 // changes. |
| 121 scoped_ptr<SlideAnimation> animation_; |
| 122 gfx::Rect anim_frame_start_; |
| 123 gfx::Rect anim_frame_end_; |
| 124 |
| 125 NotificationRegistrar notification_registrar_; |
| 126 |
| 127 DISALLOW_COPY_AND_ASSIGN(BalloonView); |
| 128 }; |
| 129 |
| 130 #endif // CHROME_BROWSER_NOTIFICATIONS_BALLOON_VIEW_H_ |
| 131 |
OLD | NEW |