OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2010 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 #import <Cocoa/Cocoa.h> |
| 6 |
| 7 #import "base/cocoa_protocols_mac.h" |
| 8 #include "base/scoped_nsobject.h" |
| 9 #include "base/scoped_ptr.h" |
| 10 |
| 11 @class InfoBubbleView; |
| 12 |
| 13 // Base class for bubble controllers. Manages a xib that contains an |
| 14 // InfoBubbleWindow which contains an InfoBubbleView. Contains code to close |
| 15 // the bubble window on clicks outside of the window, and the like. |
| 16 // To use this class: |
| 17 // 1. Create a new xib that contains a window. Change the window's class to |
| 18 // InfoBubbleWindow. Give it a child view that autosizes to the window's full |
| 19 // size, give it class InfoBubbleView. Make the controller the window's |
| 20 // delegate. |
| 21 // 2. Create a subclass of BaseBubbleController. |
| 22 // 3. Change the xib's File Owner to your subclass. |
| 23 // 4. Hook up the File Owner's |bubble_| to the InfoBubbleView in the xib. |
| 24 @interface BaseBubbleController : NSWindowController<NSWindowDelegate> { |
| 25 @private |
| 26 NSWindow* parentWindow_; // weak |
| 27 NSPoint anchor_; |
| 28 IBOutlet InfoBubbleView* bubble_; // to set arrow position |
| 29 } |
| 30 |
| 31 // Creates a bubble. |nibPath| is just the basename, e.g. @"FirstRunBubble". |
| 32 // |anchoredAt| is in screen space. You need to call -showWindow: to make the |
| 33 // bubble visible. It will autorelease itself when the user dismisses the |
| 34 // bubble. |
| 35 // This is the designated initializer. |
| 36 - (id)initWithWindowNibPath:(NSString*)nibPath |
| 37 parentWindow:(NSWindow*)parentWindow |
| 38 anchoredAt:(NSPoint)anchoredAt; |
| 39 |
| 40 |
| 41 // Creates a bubble. |nibPath| is just the basename, e.g. @"FirstRunBubble". |
| 42 // |view| must be in a window. The bubble will point at |offset| relative to |
| 43 // |view|'s lower left corner. You need to call -showWindow: to make the |
| 44 // bubble visible. It will autorelease itself when the user dismisses the |
| 45 // bubble. |
| 46 - (id)initWithWindowNibPath:(NSString*)nibPath |
| 47 relativeToView:(NSView*)view |
| 48 offset:(NSPoint)offset; |
| 49 |
| 50 |
| 51 @property (nonatomic, readonly) InfoBubbleView* bubble; |
| 52 |
| 53 @end |
OLD | NEW |