190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)// Copyright (c) 2013 The Chromium Authors. All rights reserved.
290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)// found in the LICENSE file.
490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)
590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#ifndef UI_MESSAGE_CENTER_COCOA_STATUS_ITEM_VIEW_H_
690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#define UI_MESSAGE_CENTER_COCOA_STATUS_ITEM_VIEW_H_
790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)
890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#import <AppKit/AppKit.h>
990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)
1090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#include "base/mac/scoped_block.h"
11eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch#include "base/mac/scoped_nsobject.h"
1290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#include "ui/message_center/message_center_export.h"
1390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)
1490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)namespace message_center {
1590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)
1690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)// Callback block for when the status item is clicked.
1790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)typedef void(^StatusItemClickedCallack)();
1890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)
1990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)}  // namespace message_center
2090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)
2190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)// This view is meant to be used with a NSStatusItem. It will fire a callback
2290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)// when it is clicked. It draws a small icon and the unread count, if greater
2390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)// than zero, to the icon's right. It can also paint the highlight background
2490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)// pattern outisde of a mouse event sequence, for when an attached window is
2590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)// open.
2690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)MESSAGE_CENTER_EXPORT
2790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)@interface MCStatusItemView : NSView {
2890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) @private
2990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)  // The status item.
30eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch  base::scoped_nsobject<NSStatusItem> statusItem_;
3190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)
3290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)  // Callback issued when the status item is clicked.
3390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)  base::mac::ScopedBlock<message_center::StatusItemClickedCallack> callback_;
3490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)
3590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)  // The unread count number to be drawn next to the icon.
3690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)  size_t unreadCount_;
3790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)
38a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)  // Whether or not we are to display the quiet mode version of the status icon.
39a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)  BOOL quietMode_;
40a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)
4190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)  // Whether or not to force the highlight pattern to be drawn.
4290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)  BOOL highlight_;
4390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)
4490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)  // Whether or not the view is currently handling mouse events and should
4590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)  // draw the highlight pattern.
4690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)  BOOL inMouseEventSequence_;
4790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)}
4890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)
4990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)@property(copy, nonatomic) message_center::StatusItemClickedCallack callback;
5090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)@property(nonatomic) BOOL highlight;
5190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)
527d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)// Designated initializer. Creates a new NSStatusItem in the system menubar.
537d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)- (id)init;
547d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)
55a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)// Sets the unread count and quiet mode status of the icon.
56a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)- (void)setUnreadCount:(size_t)unreadCount withQuietMode:(BOOL)quietMode;
57a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)
587d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)// Removes the status item from the menubar. Must be called to break the
597d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)// retain cycle between self and the NSStatusItem view.
607d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)- (void)removeItem;
6190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)
6290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)@end
6390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)
64a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)@interface MCStatusItemView (TestingAPI)
65a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)
66a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)- (size_t)unreadCount;
67a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)
68a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)@end
69a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)
7090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#endif  // UI_MESSAGE_CENTER_COCOA_STATUS_ITEM_VIEW_H_
71