EDSwapView


Inherits From:
NSView
Declared In:
EDSwapView.h


Class Description

Swap views are very similar to NSTabViews in that they allow to switch between several views in one place. They differ in that EDSwapView never contains the widget to switch between views and it allows more than one view to be visible; usually with different positions in the swap view. This is useful in inspectors that have multiple switching areas.

The main advantage of EDSwapView are the instance variables and methods dealing with view numbers, allowing the developer to wire up the entire interface in IB. (Zero code approach.)


Instance Variables

NSMutableSet *views;
NSMutableSet *visibleViews;
struct EDSVFlags flags;
id delegate;
IBOutlet NSView *view0;
IBOutlet NSView *view1;
IBOutlet NSView *view2;
IBOutlet NSView *view3;
IBOutlet NSView *view4;

viewsThese instance variables are private.
visibleViews
flags
delegate
view0Connect in Interface Builder.
view1
view2
view3
view4


Method Types

Managing views by number
- setView0:
- view0
- setView1:
- view1
- setView2:
- view2
- setView3:
- view3
- setView4:
- view4
- switchToViewNumber:
- takeViewNumber:
Managing views by object reference
- addView:
- addView:atPoint:
- removeView:
- showView:
- hideView:
- switchToView:
- hideAllViews
- isShowingView:
- visibleViews
Assigning a delegate
- setDelegate:
- delegate

Instance Methods

addView:

- (void)addView:(NSView *)aView

Calls addView:atPoint: with NSZeroPoint.


addView:atPoint:

- (void)addView:(NSView *)aView atPoint:(NSPoint)point

Adds aView to the receiver's list of views to be displayed at point. This does not make the view visible. It does remove the view from it's superview; provided it had one before. None if the viewX variables are affected.


delegate

- (id)delegate

Returns the receiver's delegate.


hideAllViews

- (void)hideAllViews

Ensures that no views are visible. If any view needs to be swapped out the corresponding delegate method is called.


hideView:

- (void)hideView:(NSView *)aView

Ensures that aView is not visible. If the view needs to be swapped out and a delegate exists and implements swapView:willSwapoutView: this method is called before the view is swapped out but after window flushing is disabled.


isShowingView:

- (BOOL)isShowingView:(NSView *)aView

Returns YES if aView is currently visible.


removeView:

- (void)removeView:(NSView *)aView

Removes aView from the receiver's list of views. If the view was visible it is hidden first.


setDelegate:

- (void)setDelegate:(id)anObject

Sets the receiver's delegate to anObject.


setView0:

- (void)setView0:(NSView *)aView

Sets view0 to aView and adds it to the receiver's list of views. If aView is an NSBox its contents are used instead.


setView1:

- (void)setView1:(NSView *)aView

Sets view1 to aView and adds it to the receiver's list of views. If aView is an NSBox its contents are used instead.


setView2:

- (void)setView2:(NSView *)aView

Sets view2 to aView and adds it to the receiver's list of views. If aView is an NSBox its contents are used instead.


setView3:

- (void)setView3:(NSView *)aView

Sets view3 to aView and adds it to the receiver's list of views. If aView is an NSBox its contents are used instead.


setView4:

- (void)setView4:(NSView *)aView

Sets view4 to aView and adds it to the receiver's list of views. If aView is an NSBox its contents are used instead.


showView:

- (void)showView:(NSView *)aView

Ensures that aView is visible. If the view needs to be swapped in and a delegate exists and implements swapView:didSwapinView: this method is called after the view is swapped in but before the window is flushed.


switchToView:

- (void)switchToView:(NSView *)aView

Ensures that only aView is visible. If any view needs to be swapped in or out the corresponding delegate methods are called.


switchToViewNumber:

- (void)switchToViewNumber:(int)number

Calls switchToView: with the corresponding view from the viewX instance variables.


takeViewNumber:

- (IBAction)takeViewNumber:(id)sender

Calls switchToViewNumber: with the view number taken from the sender. If this is an NSPopUpButton or NSMatrix the tag of the selected item/cell is used, if it is an NSButton this method returns 1 if the button's state is NSOnState and zero otherwise, and in all other cases it returns the tag of the sender.


view0

- (NSView *)view0

Returns view0, or nil if this has not been set.


view1

- (NSView *)view1

Returns view1, or nil if this has not been set.


view2

- (NSView *)view2

Returns view2, or nil if this has not been set.


view3

- (NSView *)view3

Returns view3, or nil if this has not been set.


view4

- (NSView *)view4

Returns view4, or nil if this has not been set.


visibleViews

- (NSArray *)visibleViews

Returns an array containing all views that are currently visible.


Version 2.0 Copyright ©2002 by Erik Doernenburg. All Rights Reserved.