1 /*
2    NSPopover.h
3 
4    The popover class
5 
6    Copyright (C) 2013 Free Software Foundation, Inc.
7 
8    Author:  Gregory Casamento <greg.casamento@gmail.com>
9    Date: 2013
10 
11    This file is part of the GNUstep GUI Library.
12 
13    This library is free software; you can redistribute it and/or
14    modify it under the terms of the GNU Lesser General Public
15    License as published by the Free Software Foundation; either
16    version 2 of the License, or (at your option) any later version.
17 
18    This library is distributed in the hope that it will be useful,
19    but WITHOUT ANY WARRANTY; without even the implied warranty of
20    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the GNU
21    Lesser General Public License for more details.
22 
23    You should have received a copy of the GNU Lesser General Public
24    License along with this library; see the file COPYING.LIB.
25    If not, see <http://www.gnu.org/licenses/> or write to the
26    Free Software Foundation, 51 Franklin Street, Fifth Floor,
27    Boston, MA 02110-1301, USA.
28 */
29 #ifndef _GNUstep_H_NSPopover
30 #define _GNUstep_H_NSPopover
31 
32 #import <Foundation/NSGeometry.h>
33 #import <AppKit/NSNibDeclarations.h>
34 #import <AppKit/NSResponder.h>
35 
36 #if OS_API_VERSION(MAC_OS_X_VERSION_10_7, GS_API_LATEST)
37 /* Keys */
38 APPKIT_EXPORT NSString *NSPopoverCloseReasonKey;
39 APPKIT_EXPORT NSString *NSPopoverCloseReasonStandard;
40 APPKIT_EXPORT NSString *NSPopoverCloseReasonDetachToWindow;
41 
42 /* Notifications */
43 APPKIT_EXPORT NSString *NSPopoverWillShowNotification;
44 APPKIT_EXPORT NSString *NSPopoverDidShowNotification;
45 APPKIT_EXPORT NSString *NSPopoverWillCloseNotification;
46 APPKIT_EXPORT NSString *NSPopoverDidCloseNotification;
47 
48 /* Constants and enums */
49 enum {
50    NSPopoverAppearanceMinimal = 0,
51    NSPopoverAppearanceHUD = 1
52 };
53 typedef NSInteger NSPopoverAppearance;
54 
55 enum {
56    NSPopoverBehaviorApplicationDefined = 0,
57    NSPopoverBehaviorTransient = 1,
58    NSPopoverBehaviorSemitransient = 2
59 };
60 typedef NSInteger NSPopoverBehavior;
61 
62 /* Forward declarations */
63 @class NSViewController, NSWindow, NSView, NSNotification;
64 @protocol NSPopoverDelegate;
65 
66 /* Class */
67 @interface NSPopover : NSResponder
68 {
69   BOOL _animates;
70   NSPopoverAppearance _appearance;
71   NSPopoverBehavior _behavior;
72   NSSize _contentSize;
73   IBOutlet NSViewController *_contentViewController;
74   id _delegate;
75   NSRect _positioningRect;
76   BOOL _shown;
77 
78   NSWindow *_realWindow;
79 }
80 
81 /* Properties */
82 - (void)setAnimates:(BOOL)flag;
83 - (BOOL)animates;
84 - (void)setAppearance: (NSPopoverAppearance)value;
85 - (NSPopoverAppearance)appearance;
86 - (void)setBehavior:(NSPopoverBehavior)value;
87 - (NSPopoverBehavior)behavior;
88 - (void)setContentSize:(NSSize)value;
89 - (NSSize)contentSize;
90 - (void)setContentViewController:(NSViewController *)controller;
91 - (NSViewController *)contentViewController;
92 - (void)setDelegate:(id)value;
93 - (id)delegate;
94 - (void)setPositioningRect:(NSRect)value;
95 - (NSRect)positioningRect;
96 - (BOOL)isShown;
97 
98 /* Methods */
99 - (void)close;
100 - (IBAction)performClose:(id)sender;
101 - (void)showRelativeToRect:(NSRect)positioningRect
102 		    ofView:(NSView *)positioningView
103 	     preferredEdge:(NSRectEdge)preferredEdge;
104 @end
105 
106 /* Delegate */
107 @protocol NSPopoverDelegate
108 #if GS_PROTOCOLS_HAVE_OPTIONAL
109 @optional
110 #else
111 @end
112 @interface NSObject (NSPopoverDelegate)
113 #endif
114 - (NSWindow *)detachableWindowForPopover:(NSPopover *)popover;
115 - (void)popoverDidClose:(NSNotification *)notification;
116 - (void)popoverDidShow:(NSNotification *)notification;
117 - (BOOL)popoverShouldClose:(NSPopover *)popover;
118 - (void)popoverWillClose:(NSNotification *)notification;
119 - (void)popoverWillShow:(NSNotification *)notification;
120 @end
121 
122 #endif
123 #endif
124