Release 1.0  Copyright ã1994 by BITart, Regensburg.  All Rights Reserved.  Author: Gerd Knops.

SampleGTool

Inherits From:	Object

Declared In:	SampleGTool.h

Class Description

SampleGTool is a simple text editor, that serves as an example in how to program a GTool. In order to keep it simple, some methods have been implemented in a quite 'simplistic' manner.  

Instance Variables

id myWindow; 
id myText; 
char *myPath; 
BOOL pathIsValid; 

myWindow	our window 

myText	our text object 

myPath	the path of the file 

pathIsValid	wether myPath is a valid path 

Method Types

Class methods 	+ initialize
	+ sampleGToolNew:
	+ sampleGToolOpen:
	+ uniqueNumber

Factory methods and related methods 
	- init
	- initFromFile:
	- free

responder methods 	- save:
	- saveAs:
	- revert:

Text delegate methods 	- textDidGetKeys:isEmpty:

Window delegate methods 	- windowWillClose:

Menu cell validation 	- validateCommand:

Internal methods 	- loadFromFile

Class Methods

initialize
+ initialize 

During initialize, we 'connect' our menu cells to our code. 

sampleGToolNew:
+ sampleGToolNew:sender

This method will opens an empty sampleGTool window. 

sampleGToolOpen:
+ sampleGToolOpen:sender

This method shows some use of the GKIOCtrl class. It shows, how to run the open panel, with multiple selections enabled. 

It should be checked, wether one of the files is already opened, we don't do it in order to keep it simple. 

uniqueNumber
+ (int)uniqueNumber 

This method returns a unique number for untitled documents. 

Instance Methods

init
- init 

init simply calls initFromFile: (the designated initializer) with NULL as argument. 

initFromFile:
- initFromFile:(const char *)theFile

This is the designated initializer for the SampleGTool class. 

free
- free 

We have to free myPath. 

save:
- save:sender

Save the data to the file pointed to by myPath. Returns nil on error; self otherwise. Note, that if we can respond to save:, GTools will automatically ask the user about saving the windows contents, when GTools will be quitted. 

saveAs:
- saveAs:sender

This method runs a save panel, sets myPath to the new path, and the calls save:. 

revert:
- revert:sender

Ask the user, wether this is, what he really wants; if so, reload from file. 

textDidGetKeys:isEmpty:
- textDidGetKeys:sender isEmpty:(BOOL)flag

This gets called when the contents of myText were changed; we reflect this in the windows close button. 

windowWillClose:
- windowWillClose:sender

If a modification was not saved yet, warn the user and ask, what to do. 

validateCommand:
- (BOOL)validateCommand:menuCell

This method ensures, that the 'Revert to Saved' menu cell will only be enabled, if the key window was edited. 

loadFromFile
- loadFromFile 

This method loads the data from the path held in the instance variable myPath. Returns nil on error, self otherwise. 

Generated by DocMaker on Wed May  4 22:24:29 1994