2003-08-06 17:40:46 +00:00
# import <Foundation / Foundation.h>
2008-07-31 21:31:19 +00:00
# import "TemplateStream.h"
2003-08-06 17:40:46 +00:00
/*
This is the base class for all template field types . Subclass this to
define a field type of your own .
Note that subclasses * must * implement the NSCopying protocol , which means
if you have instance variables , you must provide your own copyWithZone :
implementation that calls through to the superclass and then copies its
own variables ' values ( or retains references to them , if that is more
effective and the object in question isn ' t mutable ) .
*/
2008-07-31 21:31:19 +00:00
@ interface Element : NSObject < NSCopying >
2003-08-06 17:40:46 +00:00
{
2008-07-31 21:31:19 +00:00
BOOL _isTMPL ; // for debugging
NSString * type ; // Type code of this item (4 chars if from TMPL resource, but we may support longer types later).
NSString * label ; // Label ("name") of this field.
NSMutableArray * parentArray ; // The NSMutableArray* of the template field containing us, or the template window's list.
2003-08-06 17:40:46 +00:00
}
2008-07-31 21:31:19 +00:00
+ ( id ) elementForType : ( NSString * ) type withLabel : ( NSString * ) label ;
- ( id ) initForType : ( NSString * ) type withLabel : ( NSString * ) label ;
2003-08-06 17:40:46 +00:00
2008-07-31 21:31:19 +00:00
// This is used to instantiate copies of the item from the template for storing data of the resource. A copy created with this is then sent readDataFrom:.
- ( id ) copyWithZone : ( NSZone * ) zone ;
2003-08-06 17:40:46 +00:00
// Accessors:
2008-07-31 21:31:19 +00:00
- ( void ) setIsTMPL : ( BOOL ) t ;
- ( BOOL ) isTMPL ;
- ( void ) setType : ( NSString * ) t ;
- ( NSString * ) type ;
2003-08-06 17:40:46 +00:00
2008-07-31 21:31:19 +00:00
- ( void ) setLabel : ( NSString * ) l ;
- ( NSString * ) label ;
2003-08-06 17:40:46 +00:00
2008-07-31 21:31:19 +00:00
- ( void ) setParentArray : ( NSMutableArray * ) array ;
- ( NSMutableArray * ) parentArray ;
2003-08-09 22:53:58 +00:00
2008-07-31 21:31:19 +00:00
- ( NSString * ) stringValue ; // Used to display your data in the list.
- ( BOOL ) editable ;
2003-08-06 17:40:46 +00:00
// Items that have sub-items (like LSTB, LSTZ, LSTC and other lists) should implement these:
2008-07-31 21:31:19 +00:00
- ( int ) subElementCount ;
- ( Element * ) subElementAtIndex : ( int ) n ;
- ( void ) readSubElementsFrom : ( TemplateStream * ) stream ;
2003-08-06 17:40:46 +00:00
// This is called on an item of your class when displaying resource data using a template that uses your field:
2008-07-31 21:31:19 +00:00
- ( void ) readDataFrom : ( TemplateStream * ) stream ;
2003-08-06 17:40:46 +00:00
// The following are used to write resource data back out:
2008-07-31 21:31:19 +00:00
- ( unsigned int ) sizeOnDisk ;
- ( void ) writeDataTo : ( TemplateStream * ) stream ;
2003-08-06 17:40:46 +00:00
2008-07-31 21:31:19 +00:00
/* Apart from these messages, a Element may also implement the IBActions for
2003-08-10 04:41:30 +00:00
the standard edit commands ( cut , copy , paste , clear ) . When an element is selected ,
the template editor will forward any calls to these items to the element , if it
implements them , and it will automatically enable the appropriate menu items . It
2008-07-31 21:31:19 +00:00
will also forward validateMenuItem : for the Paste menu item to the element .
2003-08-10 04:41:30 +00:00
2008-07-31 21:31:19 +00:00
The createListEntry : action will also be forwarded to elements by the
2003-08-10 04:41:30 +00:00
template editor . Use this to allow creating new list items or for similar
purposes ( " Create New Resource... " is renamed to " Create List Entry " while the
template editor is key ) . */
2003-08-06 17:40:46 +00:00
@ end