1 /* IBDocuments.h
2  *
3  * Copyright (C) 2003 Free Software Foundation, Inc.
4  *
5  * Author:	Gregory John Casamento <greg_casamento@yahoo.com>
6  * Date:	2003
7  *
8  * This file is part of GNUstep.
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU Lesser General Public License as published by
12  * the Free Software Foundation; either version 2.1 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA.
23  */
24 
25 #ifndef INCLUDED_IBDOCUMENTS_H
26 #define INCLUDED_IBDOCUMENTS_H
27 
28 #include <Foundation/NSGeometry.h>
29 #include <InterfaceBuilder/IBEditors.h>
30 #include <InterfaceBuilder/IBConnectors.h>
31 #include <InterfaceBuilder/IBSystem.h>
32 
33 IB_EXTERN NSString *IBDidOpenDocumentNotification;
34 IB_EXTERN NSString *IBWillSaveDocumentNotification;
35 IB_EXTERN NSString *IBDidSaveDocumentNotification;
36 IB_EXTERN NSString *IBWillCloseDocumentNotification;
37 
38 @protocol IBDocuments <NSObject>
39 /**
40  * Add a connection
41  */
42 - (void) addConnector: (id<IBConnectors>)aConnector;
43 
44 /**
45  * Returns an array containing all connections for the receiver.
46  */
47 - (NSArray*) allConnectors;
48 
49 /**
50  * Attaches an object to the document and makes the association
51  * with the parent.
52  */
53 - (void) attachObject: (id)anObject toParent: (id)aParent;
54 
55 /**
56  * Iterates over anArray and attaches all objects in it to the
57  * receiver with aParent as the parent.
58  */
59 - (void) attachObjects: (NSArray*)anArray toParent: (id)aParent;
60 
61 /**
62  * Returns an autoreleased array containing all connections for
63  * the given destination.
64  */
65 - (NSArray*) connectorsForDestination: (id)destination;
66 
67 /**
68  * Returns an autoreleased array containing all connectors of
69  * the given class for the destination.
70  */
71 - (NSArray*) connectorsForDestination: (id)destination
72 			      ofClass: (Class)aConnectorClass;
73 /**
74  * Returns an autoreleased array containing all connections for
75  * the given source.
76  */
77 - (NSArray*) connectorsForSource: (id)source;
78 
79 /**
80  * Returns an autoreleased array containing all connectors of the
81  * given class for the source.
82  */
83 - (NSArray*) connectorsForSource: (id)source
84 			 ofClass: (Class)aConnectorClass;
85 
86 /**
87  * Returns YES, if the receiver contains anObject.
88  */
89 - (BOOL) containsObject: (id)anObject;
90 
91 /**
92  * Returns YES, if the receiver contains an object with the given name
93  * and parent.
94  */
95 - (BOOL) containsObjectWithName: (NSString*)aName forParent: (id)parent;
96 
97 /**
98  * Copies anObject to the pasteboard with the aType.
99  */
100 - (BOOL) copyObject: (id)anObject
101 	       type: (NSString*)aType
102        toPasteboard: (NSPasteboard*)aPasteboard;
103 
104 /**
105  * Copues an array of objects to aPasteboard with aType.
106  */
107 - (BOOL) copyObjects: (NSArray*)anArray
108 		type: (NSString*)aType
109 	toPasteboard: (NSPasteboard*)aPasteboard;
110 
111 /**
112  * Detaches anObject from the receiver.
113  */
114 - (void) detachObject: (id)anObject;
115 
116 /**
117  * Detaches an array of objects from the receiver.
118  */
119 - (void) detachObjects: (NSArray*)anArray;
120 
121 /**
122  * The path of the file which represents the document.
123  */
124 - (NSString*) documentPath;
125 
126 /**
127  * Called when an editor is closed.
128  */
129 - (void) editor: (id<IBEditors>)anEditor didCloseForObject: (id)anObject;
130 
131 /**
132  * Returns the associated editor for anObject, if flag is YES, it will
133  * create an instance of the editor class if one does not already exist
134  * for the given object.
135  */
136 - (id<IBEditors>) editorForObject: (id)anObject
137 			   create: (BOOL)flag;
138 
139 /**
140  * Returns the associated subeditor for anObject, if flag is YES, it will
141  * create an instance of the editor.
142  */
143 - (id<IBEditors>) editorForObject: (id)anObject
144 			 inEditor: (id<IBEditors>)anEditor
145 			   create: (BOOL)flag;
146 
147 /**
148  * Returns the name associated with the object.
149  */
150 - (NSString*) nameForObject: (id)anObject;
151 
152 /**
153  * Returns the object for the given aName.
154  */
155 - (id) objectForName: (NSString*)aName;
156 
157 /**
158  * Returns all objects in the receiver's name table.
159  */
160 - (NSArray*) objects;
161 
162 /**
163  * Creates an editor, if necessary using editorForObject:create:, opens it
164  * and brings the window containing the editor to the front.
165  */
166 - (id<IBEditors>) openEditorForObject: (id)anObject;
167 
168 /**
169  * Returns the parent of the given editor.
170  */
171 - (id<IBEditors, IBSelectionOwners>) parentEditorForEditor: (id<IBEditors>)anEditor;
172 
173 /**
174  * Return the parent of anObject.  The File's Owner is the root object in the
175  * hierarchy, if anObject's parent is the Files's Owner, this method should return
176  * nil.
177  */
178 - (id) parentOfObject: (id)anObject;
179 
180 /**
181  * Pastes the given type from the aPasteboard.
182  */
183 - (NSArray*) pasteType: (NSString*)aType
184 	fromPasteboard: (NSPasteboard*)aPasteboard
185 		parent: (id)parent;
186 
187 /**
188  * Remove aConnector from the receiver.
189  */
190 - (void) removeConnector: (id<IBConnectors>)aConnector;
191 
192 /**
193  * The current editor wants to give up the selection, this method iterates
194  * over all editors and determines if any editors will take over the selection.
195  * If one is found it is activated.
196  */
197 - (void) resignSelectionForEditor: (id<IBEditors>)editor;
198 
199 /**
200  * Set aName for object in the receiver.  This replaces any name the object
201  * may have previously had.
202  */
203 - (void) setName: (NSString*)aName forObject: (id)object;
204 
205 /**
206  * Sets the currently selected object from the given editor.
207  */
208 - (void) setSelectionFromEditor: (id<IBEditors>)anEditor;
209 
210 /**
211  * Mark document as having been changed.
212  */
213 - (void) touch;
214 
215 ////  PRIVATE
216 /**
217  * Returns a string with the name of the class for the given object.
218  */
219 
220 - (NSString *) classForObject: (id)obj;
221 - (NSArray *) actionsOfClass: (NSString *)className;
222 - (NSArray *) outletsOfClass: (NSString *)className;
223 
224 @end
225 
226 #endif
227