message_center_view.h revision c2e0dbddbe15c98d52c4786dac06cb8952a8ae6d
1// Copyright (c) 2013 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#ifndef UI_MESSAGE_CENTER_VIEWS_MESSAGE_CENTER_VIEWS_H_ 6#define UI_MESSAGE_CENTER_VIEWS_MESSAGE_CENTER_VIEWS_H_ 7 8#include "ui/views/view.h" 9 10#include "ui/message_center/message_center_export.h" 11#include "ui/message_center/message_center_observer.h" 12#include "ui/message_center/notification_list.h" 13 14namespace views { 15class Button; 16} // namespace views 17 18namespace message_center { 19 20class MessageCenter; 21class MessageCenterBubble; 22class MessageView; 23class MessageListView; 24 25// MessageCenterButtonBar ////////////////////////////////////////////////////// 26 27// If you know how to better hide this implementation class please do so, and 28// otherwise please refrain from using it :-). 29class MessageCenterButtonBar : public views::View { 30 public: 31 explicit MessageCenterButtonBar(MessageCenter* message_center); 32 virtual ~MessageCenterButtonBar(); 33 34 void SetCloseAllVisible(bool visible); 35 36 protected: 37 MessageCenter* message_center() { return message_center_; } 38 views::Button* close_all_button() { return close_all_button_; } 39 void set_close_all_button(views::Button* button) { 40 close_all_button_ = button; 41 } 42 43 private: 44 MessageCenter* message_center_; // Weak reference. 45 views::Button* close_all_button_; 46 47 DISALLOW_COPY_AND_ASSIGN(MessageCenterButtonBar); 48}; 49 50// MessageCenterView /////////////////////////////////////////////////////////// 51 52class MESSAGE_CENTER_EXPORT MessageCenterView : public views::View, 53 public MessageCenterObserver { 54 public: 55 MessageCenterView(MessageCenter* message_center, int max_height); 56 virtual ~MessageCenterView(); 57 58 void SetNotifications(const NotificationList::Notifications& notifications); 59 60 size_t NumMessageViewsForTest() const; 61 62 protected: 63 // Overridden from views::View: 64 virtual void Layout() OVERRIDE; 65 virtual bool OnMouseWheel(const ui::MouseWheelEvent& event) OVERRIDE; 66 virtual void OnMouseExited(const ui::MouseEvent& event) OVERRIDE; 67 68 // Overridden from MessageCenterObserver: 69 virtual void OnNotificationAdded(const std::string& id) OVERRIDE; 70 virtual void OnNotificationRemoved(const std::string& id, 71 bool by_user) OVERRIDE; 72 virtual void OnNotificationUpdated(const std::string& id) OVERRIDE; 73 74 private: 75 friend class MessageCenterViewTest; 76 77 void AddNotificationAt(const Notification& notification, int index); 78 void NotificationsChanged(); 79 void SetNotificationViewForTest(views::View* view); 80 81 MessageCenter* message_center_; // Weak reference. 82 std::vector<MessageView*> message_views_; 83 views::ScrollView* scroller_; 84 MessageListView* message_list_view_; 85 MessageCenterButtonBar* button_bar_; 86 87 DISALLOW_COPY_AND_ASSIGN(MessageCenterView); 88}; 89 90} // namespace message_center 91 92#endif // UI_MESSAGE_CENTER_VIEWS_MESSAGE_CENTER_VIEWS_H_ 93