Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

87 lines (64 sloc) 6.813 kB
//
// AppDelegate.h
// PopoverTester
//
// Created by Dorian Johnson on 7/10/12.
// Copyright (c) 2012 Dorian Johnson. All rights reserved.
// Licensed under the BSD License <http://www.opensource.org/licenses/bsd-license>
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
/*
On 10.7+, this simply creates and returns an NSPopover.
On 10.6, this uses an INPopoverController, with an API identical to NSPopover.
*/
#import <AppKit/AppKit.h>
@class INPopoverController, NSView, NSViewController, NSWindow, NSNotification, NSString;
@interface INCompatibilityPopover : NSResponder {
@private
id <NSPopoverDelegate> _delegate;
NSViewController *_contentViewController;
INPopoverController* _popover;
NSPopoverAppearance _appearance;
NSPopoverBehavior _behavior;
NSRect _positioningRect;
}
#pragma mark -
#pragma mark Properties
/* All properties of NSPopover are KVO compliant.
*/
/* The delegate of the popover. The delegate is not retained.
*/
@property(assign) IBOutlet id <NSPopoverDelegate> delegate;
/* The appearance of the popover. The default appearance is NSPopoverAppearanceMinimal. See the declaration of NSPopoverAppearance above for more information about appearances.
*/
@property NSPopoverAppearance appearance;
/* The behavior of the popover. The default behavior is NSPopoverBehaviorApplicationDefined. See the declaration of NSPopoverBehavior above for more information about popover behaviors.
*/
@property NSPopoverBehavior behavior;
/* The view controller that manages the content of the popover. The default value is nil. You must set the content view controller of the popover to a non-nil value before the popover is shown. Changes to the popover's content view controller while the popover is shown will animate (provided animates is YES).
*/
@property(retain) IBOutlet NSViewController *contentViewController;
/* The content size of the popover. The popover's content size is set to match the size of the content view when the content view controller is set. Changes to the content size of the popover will animate while the popover is shown (provided animates is YES).
*/
@property NSSize contentSize;
/* YES if the popover is being shown, NO otherwise. The popover is considered to be shown from the point when -showRelativeToRect:ofView:preferredEdge: is invoked until the popover is closed in response to an invocation of either -close or -performClose:.
*/
@property(readonly, getter=isShown) BOOL shown;
/* Popovers are positioned relative to a positioning view and are automatically moved when the location or size of the positioning view changes. Sometimes it is desirable to position popovers relative to a rectangle within the positioning view. In this case, you must update the positioningRect binding whenever this rectangle changes, or use the positioningRect binding so AppKit can re-position the popover when appropriate.
*/
@property NSRect positioningRect;
#pragma mark -
#pragma mark Show and Close
/* Shows the popover positioned relative to positioningRect of positioningView (see the description of positioningRect above). The common case is to pass [positioningView bounds] for positioningRect, in which case the popover will be placed adjacent to the positioningView and there is no need to update positioningRect (AppKit will detect the the bounds of the positioning view was specified and automatically update the positioningView). preferredEdge is a hint to AppKit about the desired placement of the anchor of the popover towards the positioningRect, and is with respect to the -isFlipped state of the positioningView. Also, if positioningRect is an empty rect, the [view bounds] will automatically be used. The current (but not guaranteed) behavior is that AppKit will place the anchor towards the preferredEdge of the positioningRect unless such a placement would cause the popover not to fit on the screen of positioningView. If the anchor cannot be placed towards the preferredEdge, AppKit will (in the current implementation) attempt to place the anchor on the opposite side of the positioningRect. If that cannot be done, AppKit will attempt to place the anchor on a remaining sides of the popover, and failing that will center the popover on the screen, causing it to (at least temporarily) lose its anchor. The popover will animate onscreen and eventually animate offscreen when it is closed (unless the property animates is set to NO). This method will throw a NSInvalidArgumentException if view is nil or if view is not in a window, or if the popover's behavior is NSPopoverBehaviorSemitransient and the popover's positioningView is in a popover or child window. It will throw a NSInternalInconsistencyException if the popover's content view controller (or the view controller's view) is nil. If the popover is already being shown, this method will update to be associated with the new view and positioningRect passed. If the positioning view is not visible, this method does nothing.
*/
- (void)showRelativeToRect:(NSRect)positioningRect ofView:(NSView *)positioningView preferredEdge:(NSRectEdge)preferredEdge;
/* Attempts to close the popover. The popover will not be closed if it has a delegate and the delegate returns NO to -popoverShouldClose: (or if the popover's class implements -popoverShouldClose: to return NO). The operation will fail if it is displaying a nested popover, or if it has a child window. A window will attempt to close its popovers when it receives a -performClose: message. The popover will animate out when closed (unless the animates property is set to NO).
*/
- (IBAction)performClose:(id)sender;
/* Forces the popover to close without consulting its delegate. Any popovers nested within the popovers will also receive a close message. When a window is closed in response to the -close message being sent, all of its popovers will be closed. The popover will animate out when closed (unless the animates property is set to NO).
*/
- (void)close;
@end
#pragma mark -
@interface INCompatibilityPopover (INExtras)
- (id)controller;
@end
Jump to Line
Something went wrong with that request. Please try again.