home *** CD-ROM | disk | FTP | other *** search
- /* MiscSwapContentsController.m
- *
- * A very simple class for controlling swapAble views. A subclass is a must
- * to easily work with the MiscSwapView classes.
- *
- * For more interface-info see the header file. In depth information
- * can be found here in the source-code.
- *
- * Written by: Thomas Engel
- * Created: 24.01.1994 (Copyleft)
- * Last Modified: 14.02.1994
- */
-
- //#import "MiscSwapContentsController.h"
- //#import "MiscSwapView.h"
- #import <misckit/misckit.h>
-
- @implementation MiscSwapContentsController
-
- - setSwapView:aView
- {
- // Here we set our swapView. This objects is the right place to
- // register ourselves for the swapping. But only if we have a trigger..
- // otherwise we have to wait for a awakeFromNib message.
- // Sorry we can only register for one swapView at a time. So if we had
- // a swapView before..lets say good bye.
-
- if( swapView ) [swapView removeController:self];
-
- swapView = aView;
- if( trigger ) [swapView addController:self];
- return self;
- }
-
- - swapView
- {
- return swapView;
- }
-
- - setView:aView
- {
- view = aView;
- return self;
- }
-
- - view
- {
- return view;
- }
-
- - setTrigger:anObject
- {
- // The trigger is the object we are related to. By default we try to set
- // the triggerTag according to that object.
- // Activating the trigger object (or an object with this tag) will cause
- // us to swap in.
-
- trigger = anObject;
-
- if( [trigger respondsTo:@selector(tag)] )
- [self setTriggerTag:[trigger tag]];
- else [self setTriggerTag:0];
-
- return self;
- }
-
- - trigger
- {
- return trigger;
- }
-
- - setTriggerTag:(int)tag
- {
- // Sets the tag we will be activated for.
- // Working with tags frees us from having to know what typ of object caused
- // the action (TextCell,ButtonCell,Matrix or what ever..) as long as the
- // tags are handled the right way.
-
- triggerTag = tag;
- return self;
- }
-
- - (int)triggerTag
- {
- return triggerTag;
- }
-
- /*
- * These revert/ok msg are send to setup/save the contents of a view.
- * Only the revert msg is invoked by default. If you have to store some
- * data when swapping out implement a [self ok:self] msg iside willSwapOut.
- * Ok should be used to save the changes made and revert should init the
- * view to show the current settings.
- */
-
- - ok:sender
- {
- return self;
- }
-
- - revert:sender
- {
- return self;
- }
-
- /*
- * These messages we will get from our swapView. That´s how we can
- * recognize that maybe some things have to be written to the defaults
- * database or something has to be updated etc.
- * You should override them in you subclass.
- * They are no actionMethods because we always know who our swapCtrl. is.
- * So sender is not needed here.
- */
-
- - willSwapIn
- {
- [self revert:self];
- return self;
- }
-
- - willSwapOut
- {
- return self;
- }
-
- - didSwapIn
- {
- return self;
- }
-
- - didSwapOut
- {
- return self;
- }
-
- - awakeFromNib
- {
- // Ok. Now the swapView and trigger should be set. If they exits we will
- // register ourself.
- // We have to wait for the trigger because the swapView does trigger
- // checking to ensure unifique controllers per trigger.
-
- if( swapView && trigger ) [swapView addController:self];
- return self;
- }
-
- @end
-
- /*
- * History: 14.02.94 Changed the classes name to MiscSwapContentsController
- * from the MiscSwapSubviewController becauses it fits better
- * to what it really is.
- *
- * 24.01.94 Made it a Misc object and changed it to work with the
- * new Misc stuff.
- *
- * 09.01.94 Added the ok/revert stuff.
- *
- * 08.01.94 Derived from my old swapViewdelegate. The code+methods
- * were cleaned up a bit.
- *
- *
- * Bugs: - no read/write;
- *
- * - Maybe I should do more responds to or class checking.. hmm ??
- *
- * - Not a bug but: I don't love the double registry made by awakeFromNib
- * and setSwapView. It works but it's not elegant.
- */