summaryrefslogtreecommitdiffstats
path: root/ui/message_center/message_view.h
blob: e59484ddf88823d822ea19ac6f7aef0a8cb6bf97 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef UI_MESSAGE_CENTER_MESSAGE_VIEW_H_
#define UI_MESSAGE_CENTER_MESSAGE_VIEW_H_

#include "ui/message_center/notification_list.h"
#include "ui/views/controls/button/button.h"
#include "ui/views/controls/slide_out_view.h"
#include "ui/views/view.h"

namespace views {
class ImageButton;
class ScrollView;
}

namespace message_center {

// Individual notifications constants.
const int kPaddingBetweenItems = 10;
const int kPaddingHorizontal = 18;
const int kWebNotificationButtonWidth = 32;
const int kWebNotificationIconSize = 40;
const int kWebNotificationWidth = 320;

// An abstract class that forms the basis of a view for a notification entry.
class MessageView : public views::SlideOutView,
                    public views::ButtonListener {
 public:
  MessageView(NotificationList::Delegate* list_delegate,
              const NotificationList::Notification& notification);

  virtual ~MessageView();

  // Creates the elements that make up the view layout. Must be called
  // immediately after construction.
  virtual void SetUpView() = 0;

  void set_scroller(views::ScrollView* scroller) { scroller_ = scroller; }

  // views::View overrides.
  virtual bool OnMousePressed(const ui::MouseEvent& event) OVERRIDE;

  // ui::EventHandler overrides.
  virtual ui::EventResult OnGestureEvent(ui::GestureEvent* event) OVERRIDE;

  // Overridden from ButtonListener.
  virtual void ButtonPressed(views::Button* sender,
                             const ui::Event& event) OVERRIDE;

 protected:
  MessageView();

  // Shows the menu for the notification.
  void ShowMenu(gfx::Point screen_location);

  // Overridden from views::SlideOutView.
  virtual void OnSlideOut() OVERRIDE;

  NotificationList::Delegate* list_delegate_;
  NotificationList::Notification notification_;
  views::ImageButton* close_button_;

  views::ScrollView* scroller_;

  DISALLOW_COPY_AND_ASSIGN(MessageView);
};

}  // namespace message_center

#endif // UI_MESSAGE_CENTER_MESSAGE_VIEW_H_