1 /*
2    GSNibTemplates.h
3 
4    Copyright (C) 1997, 1999 Free Software Foundation, Inc.
5 
6    Author:  Gregory John Casamento <greg_casamento@yahoo.com>
7    Date: 2002
8 
9    This file is part of the GNUstep GUI Library.
10 
11    This library is free software; you can redistribute it and/or
12    modify it under the terms of the GNU Lesser General Public
13    License as published by the Free Software Foundation; either
14    version 2 of the License, or (at your option) any later version.
15 
16    This library is distributed in the hope that it will be useful,
17    but WITHOUT ANY WARRANTY; without even the implied warranty of
18    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the GNU
19    Lesser General Public License for more details.
20 
21    You should have received a copy of the GNU Lesser General Public
22    License along with this library; see the file COPYING.LIB.
23    If not, see <http://www.gnu.org/licenses/> or write to the
24    Free Software Foundation, 51 Franklin Street, Fifth Floor,
25    Boston, MA 02110-1301, USA.
26 */
27 
28 #ifndef _GNUstep_H_GSNibTemplates
29 #define _GNUstep_H_GSNibTemplates
30 
31 #import <Foundation/NSObject.h>
32 #import "GNUstepGUI/GSNibContainer.h"
33 
34 
35 // version of the nib container and the templates.
36 #define GNUSTEP_NIB_VERSION 2
37 #define GSSWAPPER_VERSION   0
38 #define GSWINDOWT_VERSION   1
39 #define GSVIEWT_VERSION     0
40 #define GSCONTROLT_VERSION  0
41 #define GSTEXTT_VERSION     0
42 #define GSTEXTVIEWT_VERSION 0
43 #define GSMENUT_VERSION     0
44 #define GSOBJECTT_VERSION   0
45 
46 @class NSString;
47 @class NSDictionary;
48 @class NSMutableDictionary;
49 @class NSMutableSet;
50 @class NSWindow;
51 
52 /** Window template autopositioning constants */
53 enum {
54   GSWindowAutoPositionNone = 0,
55   GSWindowMinXMargin = 1,
56   GSWindowMaxXMargin = 2,
57   GSWindowMinYMargin = 4,
58   GSWindowMaxYMargin = 8
59 };
60 
61 /*
62  * This is the class that holds objects within a nib.
63  */
64 @interface GSNibContainer : NSObject <NSCoding, GSNibContainer>
65 {
66   NSMutableDictionary	*nameTable;
67   NSMutableArray	*connections;
68   NSMutableArray	*visibleWindows;
69   NSMutableArray	*deferredWindows;
70   NSMutableSet          *topLevelObjects;
71   NSMutableDictionary	*customClasses;
72   BOOL			isAwake;
73 }
74 - (NSMutableArray*) visibleWindows;
75 - (NSMutableArray*) deferredWindows;
76 - (NSMutableDictionary *) customClasses;
77 @end
78 
79 /*
80  * Template classes
81  */
82 @protocol GSTemplate
83 - (id) initWithObject: (id)object className: (NSString *)className superClassName: (NSString *)superClassName;
84 - (void) setClassName: (NSString *)className;
85 - (NSString *)className;
86 @end
87 
88 @interface GSClassSwapper : NSObject <GSTemplate, NSCoding>
89 {
90   id                   _object;
91   NSString            *_className;
92   Class                _superClass;
93 }
94 - (BOOL) shouldSwapClass;
95 @end
96 
97 @interface GSNibItem : NSObject <NSCoding>
98 {
99   NSString		*theClass;
100   NSRect		theFrame;
101   unsigned int          autoresizingMask;
102 }
103 @end
104 
105 @interface GSCustomView : GSNibItem <NSCoding>
106 {
107 }
108 @end
109 
110 @interface GSWindowTemplate : GSClassSwapper
111 {
112   BOOL                 _deferFlag;
113   unsigned int         _autoPositionMask;
114   NSRect               _screenRect;
115 }
116 // auto position the window.
117 - (unsigned int) autoPositionMask;
118 - (void) setAutoPositionMask: (unsigned int)flag;
119 - (void) autoPositionWindow: (NSWindow *)window;
120 
121 // set attributes specific to the template.
122 - (void) setDeferFlag: (BOOL)flag;
123 - (BOOL) deferFlag;
124 @end
125 
126 @interface GSViewTemplate : GSClassSwapper
127 @end
128 
129 @interface GSTextTemplate : GSClassSwapper
130 @end
131 
132 @interface GSTextViewTemplate : GSClassSwapper
133 @end
134 
135 @interface GSMenuTemplate : GSClassSwapper
136 @end
137 
138 @interface GSControlTemplate : GSClassSwapper
139 @end
140 
141 @interface GSObjectTemplate : GSClassSwapper
142 @end
143 
144 @interface GSTemplateFactory : NSObject
145 + (id) templateForObject: (id) object
146 	   withClassName: (NSString *)className
147       withSuperClassName: (NSString *)superClassName;
148 @end
149 #endif /* _GNUstep_H_GSNibTemplates */
150