1 /*
2    NSPanel.h
3 
4    Panel window class
5 
6    Copyright (C) 1996 Free Software Foundation, Inc.
7 
8    Author:  Scott Christley <scottc@net-community.com>
9    Date: 1996
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 
30 #ifndef _GNUstep_H_NSPanel
31 #define _GNUstep_H_NSPanel
32 #import <GNUstepBase/GSVersionMacros.h>
33 
34 #import <AppKit/NSWindow.h>
35 
36 #if	defined(__cplusplus)
37 extern "C" {
38 #endif
39 
40 @class NSString;
41 
42 enum {
43   NSUtilityWindowMask = 16,
44   NSDocModalWindowMask = 32,
45   NSNonactivatingPanelMask = 128,
46   NSHUDWindowMask = 8192
47 };
48 
49 enum {
50   NSOKButton = 1,
51   NSCancelButton = 0
52 };
53 
54 enum {
55   NSAlertDefaultReturn = 1,
56   NSAlertAlternateReturn = 0,
57   NSAlertOtherReturn = -1,
58   NSAlertErrorReturn  = -2
59 };
60 
61 // from MacOS X docs
62 #define NSAlertDefault NSAlertDefaultReturn
63 #define NSAlertAlternate NSAlertAlternateReturn
64 #define NSAlertOther NSAlertOtherReturn
65 
66 #if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST)
67 #define	NS_ALERTDEFAULT		NSAlertDefaultReturn
68 #define	NS_ALERTALTERNATE	NSAlertAlternateReturn
69 #define	NS_ALERTOTHER		NSAlertOtherReturn
70 #define	NS_ALERTERROR		NSAlertErrorReturn
71 #endif
72 
73 @interface NSPanel : NSWindow
74 {
75   // Think of the following as BOOL ivars
76 #define _becomesKeyOnlyIfNeeded _f.subclass_bool_one
77 #define _isFloatingPanel _f.subclass_bool_two
78 #define _worksWhenModal _f.subclass_bool_three
79 }
80 
81 //
82 // Determining the Panel Behavior
83 //
84 - (BOOL)becomesKeyOnlyIfNeeded;
85 - (BOOL)isFloatingPanel;
86 - (void)setBecomesKeyOnlyIfNeeded:(BOOL)flag;
87 - (void)setFloatingPanel:(BOOL)flag;
88 - (void)setWorksWhenModal:(BOOL)flag;
89 - (BOOL)worksWhenModal;
90 
91 @end
92 
93 //
94 // Create an Attention Panel without Running It Yet
95 //
96 APPKIT_EXPORT id NSGetAlertPanel(NSString *title,
97 				  NSString *msg,
98 				  NSString *defaultButton,
99 				  NSString *alternateButton,
100 				  NSString *otherButton, ...);
101 
102 #if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST)
103 APPKIT_EXPORT id NSGetCriticalAlertPanel(NSString *title,
104 					  NSString *msg,
105 					  NSString *defaultButton,
106 					  NSString *alternateButton,
107 					  NSString *otherButton, ...);
108 
109 APPKIT_EXPORT id NSGetInformationalAlertPanel(NSString *title,
110 					       NSString *msg,
111 					       NSString *defaultButton,
112 					       NSString *alternateButton,
113 					       NSString *otherButton, ...);
114 #endif
115 
116 //
117 // Create and Run an Attention Panel
118 //
119 APPKIT_EXPORT NSInteger NSRunAlertPanel(NSString *title,
120                                         NSString *msg,
121                                         NSString *defaultButton,
122                                         NSString *alternateButton,
123                                         NSString *otherButton, ...);
124 
125 #if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST)
126 APPKIT_EXPORT NSInteger NSRunCriticalAlertPanel(NSString *title,
127                                                 NSString *msg,
128                                                 NSString *defaultButton,
129                                                 NSString *alternateButton,
130                                                 NSString *otherButton, ...);
131 
132 APPKIT_EXPORT NSInteger NSRunInformationalAlertPanel(NSString *title,
133                                                      NSString *msg,
134                                                      NSString *defaultButton,
135                                                      NSString *alternateButton,
136                                                      NSString *otherButton, ...);
137 #endif
138 
139 #if OS_API_VERSION(GS_API_ONE, GS_API_ONE)
140 APPKIT_EXPORT NSInteger NSRunLocalizedAlertPanel(NSString *table,
141                                                  NSString *title,
142                                                  NSString *msg,
143                                                  NSString *defaultButton,
144                                                  NSString *alternateButton,
145                                                  NSString *otherButton, ...);
146 #endif
147 
148 #if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST)
149 //
150 // New alert interface of Mac OS X
151 //
152 APPKIT_EXPORT void NSBeginAlertSheet(NSString *title,
153 				      NSString *defaultButton,
154 				      NSString *alternateButton,
155 				      NSString *otherButton,
156 				      NSWindow *docWindow,
157 				      id modalDelegate,
158 				      SEL willEndSelector,
159 				      SEL didEndSelector,
160 				      void *contextInfo,
161 				      NSString *msg, ...);
162 
163 APPKIT_EXPORT void NSBeginCriticalAlertSheet(NSString *title,
164 					      NSString *defaultButton,
165 					      NSString *alternateButton,
166 					      NSString *otherButton,
167 					      NSWindow *docWindow,
168 					      id modalDelegate,
169 					      SEL willEndSelector,
170 					      SEL didEndSelector,
171 					      void *contextInfo,
172 					      NSString *msg, ...);
173 
174 APPKIT_EXPORT void NSBeginInformationalAlertSheet(NSString *title,
175 						   NSString *defaultButton,
176 						   NSString *alternateButton,
177 						   NSString *otherButton,
178 						   NSWindow *docWindow,
179 						   id modalDelegate,
180 						   SEL willEndSelector,
181 						   SEL didEndSelector,
182 						   void *contextInfo,
183 						   NSString *msg, ...);
184 
185 APPKIT_EXPORT NSInteger GSRunExceptionPanel(NSString *title,
186                                             NSException *exception,
187                                             NSString *defaultButton,
188                                             NSString *alternateButton,
189                                             NSString *otherButton);
190 
191 #endif
192 
193 //
194 // Release an Attention Panel
195 //
196 APPKIT_EXPORT void NSReleaseAlertPanel(id panel);
197 
198 #if	defined(__cplusplus)
199 }
200 #endif
201 
202 #endif // _GNUstep_H_NSPanel
203