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 #import <Cocoa/Cocoa.h> | 5 #import <Cocoa/Cocoa.h> |
6 | 6 |
7 #include "base/memory/scoped_nsobject.h" | 7 #include "base/mac/scoped_nsobject.h" |
8 | 8 |
9 // A view class that looks like a "bubble" with rounded corners and displays | 9 // A view class that looks like a "bubble" with rounded corners and displays |
10 // text inside. Can be themed. To put flush against the sides of a window, the | 10 // text inside. Can be themed. To put flush against the sides of a window, the |
11 // corner flags can be adjusted. | 11 // corner flags can be adjusted. |
12 | 12 |
13 // Constants that define where the bubble will have a rounded corner. If | 13 // Constants that define where the bubble will have a rounded corner. If |
14 // not set, the corner will be square. | 14 // not set, the corner will be square. |
15 enum { | 15 enum { |
16 kRoundedTopLeftCorner = 1, | 16 kRoundedTopLeftCorner = 1, |
17 kRoundedTopRightCorner = 1 << 1, | 17 kRoundedTopRightCorner = 1 << 1, |
18 kRoundedBottomLeftCorner = 1 << 2, | 18 kRoundedBottomLeftCorner = 1 << 2, |
19 kRoundedBottomRightCorner = 1 << 3, | 19 kRoundedBottomRightCorner = 1 << 3, |
20 kRoundedAllCorners = kRoundedTopLeftCorner | | 20 kRoundedAllCorners = kRoundedTopLeftCorner | |
21 kRoundedTopRightCorner | | 21 kRoundedTopRightCorner | |
22 kRoundedBottomLeftCorner | | 22 kRoundedBottomLeftCorner | |
23 kRoundedBottomRightCorner | 23 kRoundedBottomRightCorner |
24 }; | 24 }; |
25 | 25 |
26 // Constants that affect where the text is positioned within the view. They | 26 // Constants that affect where the text is positioned within the view. They |
27 // are exposed in case anyone needs to use the padding to set the content string | 27 // are exposed in case anyone needs to use the padding to set the content string |
28 // length appropriately based on available space (such as eliding a URL). | 28 // length appropriately based on available space (such as eliding a URL). |
29 enum { | 29 enum { |
30 kBubbleViewTextPositionX = 4, | 30 kBubbleViewTextPositionX = 4, |
31 kBubbleViewTextPositionY = 2 | 31 kBubbleViewTextPositionY = 2 |
32 }; | 32 }; |
33 | 33 |
34 @interface BubbleView : NSView { | 34 @interface BubbleView : NSView { |
35 @private | 35 @private |
36 scoped_nsobject<NSString> content_; | 36 base::scoped_nsobject<NSString> content_; |
37 unsigned long cornerFlags_; | 37 unsigned long cornerFlags_; |
38 // The window from which we get the theme used to draw. In some cases, | 38 // The window from which we get the theme used to draw. In some cases, |
39 // it might not be the window we're in. As a result, this may or may not | 39 // it might not be the window we're in. As a result, this may or may not |
40 // directly own us, so it needs to be weak to prevent a cycle. | 40 // directly own us, so it needs to be weak to prevent a cycle. |
41 NSWindow* themeProvider_; | 41 NSWindow* themeProvider_; |
42 } | 42 } |
43 | 43 |
44 // Designated initializer. |provider| is the window from which we get the | 44 // Designated initializer. |provider| is the window from which we get the |
45 // current theme to draw text and backgrounds. If nil, the current window will | 45 // current theme to draw text and backgrounds. If nil, the current window will |
46 // be checked. The caller needs to ensure |provider| can't go away as it will | 46 // be checked. The caller needs to ensure |provider| can't go away as it will |
(...skipping 12 matching lines...) Expand all Loading... |
59 // The font used to display the content string. | 59 // The font used to display the content string. |
60 - (NSFont*)font; | 60 - (NSFont*)font; |
61 | 61 |
62 @end | 62 @end |
63 | 63 |
64 // APIs exposed only for testing. | 64 // APIs exposed only for testing. |
65 @interface BubbleView(TestingOnly) | 65 @interface BubbleView(TestingOnly) |
66 - (NSString*)content; | 66 - (NSString*)content; |
67 - (unsigned long)cornerFlags; | 67 - (unsigned long)cornerFlags; |
68 @end | 68 @end |
OLD | NEW |