No longer register app window placement preference keys on
[chromium-blink-merge.git] / chrome / browser / ui / cocoa / bubble_view.h
blob12c89f42e599a282ee8753a3013144cacf7d324e
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
3 // found in the LICENSE file.
5 #import <Cocoa/Cocoa.h>
7 #include "base/mac/scoped_nsobject.h"
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
11 // corner flags can be adjusted.
13 // Constants that define where the bubble will have a rounded corner. If
14 // not set, the corner will be square.
15 enum {
16 kRoundedTopLeftCorner = 1,
17 kRoundedTopRightCorner = 1 << 1,
18 kRoundedBottomLeftCorner = 1 << 2,
19 kRoundedBottomRightCorner = 1 << 3,
20 kRoundedAllCorners = kRoundedTopLeftCorner |
21 kRoundedTopRightCorner |
22 kRoundedBottomLeftCorner |
23 kRoundedBottomRightCorner
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
28 // length appropriately based on available space (such as eliding a URL).
29 enum {
30 kBubbleViewTextPositionX = 4,
31 kBubbleViewTextPositionY = 2
34 @interface BubbleView : NSView {
35 @private
36 base::scoped_nsobject<NSString> content_;
37 unsigned long cornerFlags_;
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
40 // directly own us, so it needs to be weak to prevent a cycle.
41 NSWindow* themeProvider_;
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
46 // be checked. The caller needs to ensure |provider| can't go away as it will
47 // not be retained. Defaults to all corners being rounded.
48 - (id)initWithFrame:(NSRect)frame themeProvider:(NSWindow*)provider;
50 // Sets the string displayed in the bubble. A copy of the string is made.
51 - (void)setContent:(NSString*)content;
53 // Sets which corners will be rounded.
54 - (void)setCornerFlags:(unsigned long)flags;
56 // Sets the window whose theme is used to draw.
57 - (void)setThemeProvider:(NSWindow*)provider;
59 // The font used to display the content string.
60 - (NSFont*)font;
62 @end
64 // APIs exposed only for testing.
65 @interface BubbleView(TestingOnly)
66 - (NSString*)content;
67 - (unsigned long)cornerFlags;
68 @end