ftp.nice.ch/pub/next/developer/resources/classes/misckit/MiscKit.1.10.0.s.gnutar.gz#/MiscKit/Documentation/Classes/MiscSplitView.rtf

This is MiscSplitView.rtf in view mode; [Download] [Up]

Version 1.42; April 4, 1997. Copyright © 1996, 1997 by Dwight D. Everhart (everhart@alterlife.com).  All Rights Reserved.




MiscSplitView






Inherits From:	View : Responder : Object

Declared In:	<misckit/MiscSplitView.h>





Class Description

A MiscSplitView object lets several Views share a region within a window.  It works exactly like an NXSplitView, except that it can tile its subviews horizontally as well as vertically.  To change the orientation of a MiscSplitView, use the setHorizontal: method.  The default is vertical, the orientation that NXSplitView uses.

For vertical orientations, the MiscSplitView resizes its subviews so that each subview is the same width as the MiscSplitView, and the total of the subviews' heights plus the total of the divider's heights is equal to the height of the MiscSplitView.  The MiscSplitView positions its subviews so that the first subview is at the top of the MiscSplitView, and each successive subview is positioned below.  For horizontal orientations, the MiscSplitView resizes its subviews so that each subview is the same height as the MiscSplitView, and the total of the subviews' widths plus the total of the divider's widths is equal to the width of the MiscSplitView.  The MiscSplitView positions its subviews so that the first subview is at the left edge of the MiscSplitView, and each successive subview is positioned to the right.  The user can change the size of any two subviews by moving a bar between them called the divider, which makes one subview smaller and the other larger.

To add a View to a MiscSplitView, use the addSubview: View method.  When the MiscSplitView is displayed, it checks to see if its subviews are properly tiled.  If not, it invokes the splitView:resizeSubviews: delegate method, allowing the delegate to specify the heights or widths of specific subviews.  If the delegate doesn't implement a splitView:resizeSubviews: method, the MiscSplitView sends adjustSubviews to itself to yield a default tiling behavior.

When a mouse-down event occurs in a MiscSplitView's divider, the MiscSplitView determines the limits of the divider's travel and tracks the mouse to allow the user to drag the divider within these limits.  With the following mouse-up, the MiscSplitView resizes the two affected subviews, informs the delegate that the subviews were resized, and displays the affected Views and divider.  The MiscSplitView's delegate can constrain the travel of specific dividers by implementing the splitView:getMinY:maxY:ofSubviewAt: method for vertical MiscSplitViews and the splitView:getMinX:maxX:ofSubviewAt: method for horizontal MiscSplitViews.

In addition to implementing the features of the NXSplitView class, MiscSplitView adds the ability to save the view's divider positions in the defaults database, in a manner modeled after Window's frame saving mechanism.  To automatically save a MiscSplitView's divider positions in the defaults database, invoke setDividersAutosaveName: with the name that will be used to identify the MiscSplitView in the defaults database.  Invoking this method also sets the view's divider positions to the previously saved value, if one exists.  To manually save and set the divider positions, use the saveDividersUsingName: and setDividersUsingName: methods.





Instance Variables

id delegate;
struct _msvFlags {
unsigned int horizontal:1;
unsigned int needsRetiling:1;
} msvFlags;



delegate 	The object that receives notification messages from the MiscSplitView.
msvFlags.horizontal 	YES if the MiscSplitView has a horizontal orientation.
msvFlags.needsRetiling	YES if resizeSubviews: needs to be called before the MiscSplitView is displayed. 





Method Types

Initializing a MiscSplitView	 + initialize
 - initFrame:

Freeing a MiscSplitView	 - free

Assigning a delegate	 - delegate
 - setDelegate:

Assigning orientation	 - isHorizontal
 - setHorizontal:

Accessing the dividers	 - setDividersFromString:
 - saveDividersToString:
 - setDividersUsingName:
 - saveDividersUsingName:
 + removeDividersUsingName:
 - dividersAutosaveName
 - setDividersAutosaveName:
 + requireUniqueAutosaveNames:

Drawing the view	 - dividerSize
 - dividerHeight
 - dividerWidth
 - drawSelf::
 - drawDivider:

Managing component Views	 - constrainDivider:leftFrame:rightFrame:min:max:
 - constrainFramesLeft:andRight:besideDivider:
 - adjustSubviews
 - resizeSubviews:
 - setAutoresizeSubviews:
 - addSubview:
 - addSubview::relativeTo:
 - replaceSubview:with:

Handling Events	 - mouseDown:
 - acceptsFirstMouse

Archiving	 - read:
 - write:





Class Methods

initialize
+ initialize

Initializes the MiscSplitView class object.  The class object receives an initialize message before it receives any other message.  You never send an initialize message directly.  Returns self.

See also:  + initialize (Object)




removeDividersUsingName:
+ removeDividersUsingName:(const char *)name

Removes the dividers position data named name from the application's defaults.    Returns self.

See also:  - saveDividersUsingName:, - setDividersUsingName:, - setDividersAutosaveName:




 requireUniqueAutosaveNames:
+ requireUniqueAutosaveNames:(BOOL)require

Enables or disables a uniqueness check when an autosave name is set with the setDividersAutosaveName: method.  If the check is enabled, attempts to set a MiscSplitView's name to one that another MiscSplitView in the application is using will fail and no name will be set, resulting in the MiscSplitView's divider positions not being recorded in the defaults database.  By default, unique names are not required.  Returns self.

See also:  - setDividersAutosaveName:





Instance Methods

acceptsFirstMouse
- (BOOL)acceptsFirstMouse

Returns YES, thus allowing the MiscSplitView to respond to the mouse event that made its Window the key window.

See also:  - acceptsFirstMouse (View)




addSubview:
- addSubview:aView

Sets the msv.needsRetiling flag to ensure that the subviews are resized the next time the MiscSplitView is displayed.

See also:  - addSubview: (View)




addSubview::relativeTo:
- addSubview:aView
:(int)place
relativeTo:otherView

Sets the msv.needsRetiling flag to ensure that the subviews are resized the next time the MiscSplitView is displayed.

See also:  - addSubview::relativeTo: (View)




adjustSubviews
- adjustSubviews

Adjusts the widths or heights, as appropriate, of the MiscSplitView's subviews so that the total fills the MiscSplitView.  The delegate is given an opportunity to constrain the new sizes through the splitView:getMinX:maxX:ofSubviewAt: method (for horizontal MiscSplitViews) or the splitView:getMinY:maxY:ofSubviewAt: method (for vertical MiscSplitViews).  The subviews are resized proportionally; the size of a subview relative to the other subviews doesn't change, unless one or more subviews is constrained by the delegate.  This method is called by resizeSubviews: after the MiscSplitView is resized, if the MiscSplitView's delegate doesn't respond to the splitView:resizeSubviews: message.  Returns self.

See also:  - resizeSubviews:, - splitView:getMinX:maxX:ofSubviewAt: (delegate method), - splitView:getMinY:maxY:ofSubviewAt: (delegate method), - splitView:resizeSubviews: (delegate method)




constrainDivider:leftFrame:rightFrame:min:max:
-  constrainDivider:(int)dividerIndex
  leftFrame:(const NXRect *)leftFrame
  rightFrame:(const NXRect *)rightFrame
  min:(NXCoord *)min max:(NXCoord *)max

Constrains a divider's position to the left or top edge of leftFrame and the right or bottom edge of rightFrame (left and right are used for horizontal MiscSplitViews; top and bottom are used for vertical MiscSplitViews).  If the delegate implements splitView:getMinX:maxX:ofSubviewAt: or splitView:getMinY:maxY:ofSubviewAt: (as appropriate), that method is called to allow the delegate to constrain the divider further.  The constraining coordinates are returned in min and max.  The initial values of min and max are ignored.  You may want to override this method to implement different constraining behavior.  Used by constrainFramesLeft:andRight:besideDivider: and mouseDown:.  Returns self.

See also:  - splitView:getMinX:maxX:ofSubviewAt: (delegate method), - splitView:getMinY:maxY:ofSubviewAt: (delegate method), - constrainFramesLeft:andRight:besideDivider:, - mouseDown:




constrainFramesLeft:andRight:besideDivider:
-  constrainFramesLeft:(NXRect *)leftFrame
andRight:(NXRect *)rightFrame
besideDivider:(int)dividerIndex

Constrains the frames on either side of the divider at position dividerIndex.  Calls constrainDivider:leftFrame:rightFrame:min:max: to constrain the divider's position and then adjusts the given frames so that the divider lies between them.  For vertical MiscSplitViews, left is interpreted as upper, and right is interpreted as lower.  You may want to override this method to implement different constraining behavior.  Used by adjustSubviews.  Returns self.

See also:  - constrainDivider:leftFrame:rightFrame:min:max:, - adjustSubviews




delegate
- delegate

Returns the MiscSplitView's delegate.

See also:  - setDelegate:




dividerHeight
- (NXCoord)dividerHeight

Returns the height of the divider for a vertically-orientated MiscSplitView.  Calls and returns dividerSize by default.  You can override this method to change the divider's height, if necessary.

See also:  - dividerSize, - dividerWidth, - drawDivider:




dividersAutosaveName
- (const char *)dividersAutosaveName

Returns the name that's used to automatically save the MiscSplitView's divider positions in the defaults system, as set through setDividersAutosaveName:.  If the MiscSplitView has an autosave name, its dividers' positions are written as a default whenever a divider's position changes.

See also:  - setDividersAutosaveName:




dividerSize
- (NXCoord)dividerSize

Returns the size of the divider.  Normally, dividers for both horizontal and vertical MiscSplitViews are the same size.  You can override this method to change the divider's size, if necessary.

See also:  - dividerHeight, - dividerWidth, - drawDivider:




dividerWidth
- (NXCoord)dividerWidth

Returns the width of the divider for a horizontally-orientated MiscSplitView.  Calls and returns dividerSize by default.  You can override this method to change the divider's width, if necessary.

See also:  - dividerSize, - dividerHeight, - drawDivider:




drawDivider:
- drawDivider:(const NXRect *)aRect

Draws a divider between two of the MiscSplitView's subviews.  aRect describes the entire divider rectangle in the MiscSplitView's coordinates, which are flipped.  The default implementation composites a default image to the center of aRect; if you override this method and use a different icon to identify the divider, you may want to change the size of the divider.  Returns self.

See also:  - dividerSize, - dividerHeight, - dividerWidth, - composite:toPoint: (NXImage)




drawSelf::
- drawSelf:(const NXRect *)rects :(int)rectCount

Draws the MiscSplitView by calling drawDivider: for each divider that needs to be displayed.  If the msv.needsRetiling flag is set, resizeSubviews: is invoked before any drawing is done.  You never invoke this method directly; it's invoked by the display mechanism.  Returns self.

See also:  - drawDivider:, - resizeSubviews:, - display: (View)




free
- free

Frees the MiscSplitView.  Returns nil.

See also:  - initFrame:




initFrame:
- initFrame:(const NXRect *)frameRect

Initializes the MiscSplitView, which must be a newly allocated MiscSplitView instance, setting its frame rectangle to the argument.  The MiscSplitView's coordinate system is flipped, it's set to autoresize its subviews, and it's given a vertical orientation.  This method is the designated initializer for the MiscSplitView class.  Returns self.

See also:  - setAutoresizeSubviews:, - setHorizontal:, - setFlipped: (View), - free




isHorizontal
- (BOOL)isHorizontal

Returns YES if the receiver tiles its subviews horizontally or NO if it tiles them vertically.  By default, MiscSplitViews are vertically oriented.

See also:  - setHorizontal:




mouseDown:
- mouseDown:(NXEvent *)theEvent

Causes a divider to be moved as the user drags the mouse.  When the user lets up on the mouse button, the subviews to the left and right of (or above and below) the divider are resized.  You never invoke this method; it's invoked when the user clicks in the MiscSplitView.  Returns self.

See also:  - splitView:getMinX:maxX:ofSubviewAt: (delegate method), - splitView:getMinY:maxY:ofSubviewAt: (delegate method), - splitViewDidResizeSubviews: (delegate method), - constrainDivider:leftFrame:rightFrame:min:max:, - saveDividersUsingName:, - dividersAutosaveName




read:
- read:(NXTypedStream *)stream

Reads the MiscSplitView and a reference to its delegate from the typed stream stream.  Returns self.

See also:  - write:




replaceSubview:with:
- replaceSubview:oldView with:newView

Sets the msv.needsRetiling flag to ensure that the subviews are resized the next time the MiscSplitView is displayed.

See also:  - addSubview::relativeTo: (View)




resizeSubviews:
- resizeSubviews:(const NXSize *)oldSize

Ensures that the MiscSplitView's subviews are properly sized to fill the MiscSplitView.  If the delegate implements the splitView:resizeSubviews: method, that method is invoked to resize the subviews; otherwise, the adjustSubviews method is invoked to resize the subviews.  In either case, this method then informs the delegate that the subviews were resized by invoking splitViewDidResizeSubviews:.  oldSize is the previous bounds rectangle size.  This method is invoked by setDividersFromString: and by drawSelf:: when the msv.needsRetiling flag is set.  Returns self.

See also:  - splitView:resizeSubviews: (delegate method), - adjustSubviews, - splitViewDidResizeSubviews: (delegate method), - setDividersFromString:, - drawSelf::, - resizeSubviews: (View)




saveDividersToString:
- saveDividersToString:(char *)string

Saves the MiscSplitViews's divider positions as a NULL-terminated ASCII string to the buffer pointed to by string.  The string can be stored as you see fit and used later to set the positions of the dividers through the setDividersFromString: method.  You should ensure that the buffer is large enough to hold at least four characters for each of the MiscSplitView's subviews plus three additional characters.  Used by saveDividersUsingName:.  Returns self.

See also:  - setDividersFromString:, - saveDividersUsingName:




saveDividersUsingName:
- saveDividersUsingName:(const char *)name

Saves the MiscSplitView's divider positions as a system default.  With the companion method setDividersUsingName:, you can save and reset a MiscSplitView's divider positions over various launchings of an application.  The default is owned by the application, filed under the name

	ªMiscSplitView Dividers nameº

Returns self.

See also:  - setDividersUsingName:, - saveDividersToString:




setAutoresizeSubviews:
- setAutoresizeSubviews:(BOOL)flag

Overrides View's setAutoresizeSubviews: method to ensure that automatic resizing of subviews will not be disabled.  You should never invoke this method.  Returns self.

See also:  - setAutoresizeSubviews: (View)




setDelegate:
- setDelegate:anObject

Makes anObject the MiscSplitView's delegate.  The notification messages that the delegate can expect to receive are listed at the end of the MiscSplitView class specifications.  The delegate may implement as many or as few of the delegate methods as it wishes.  Returns self.

See also:  - delegate




setDividersAutosaveName:
- setDividersAutosaveName:(const char *)name

Sets the name that's used to automatically save the MiscSplitView's divider positions in the defaults system and sets its divider positions to the current value of that default, if the default already exists.  If name isn't NULL, the MiscSplitView's divider positions are saved as a default (using saveDividersUsingName:) each time a divider's position changes.  This happens when the user changes a divider's position with the mouse in mouseDown:, when the MiscSplitView is resized (through resizeSubviews:), and when adjustSubviews is invoked.

Passing NULL as an argument disables the autosave feature.  A MiscSplitView can have only one dividers autosave name at a time; if the MiscSplitView already has an autosave name, the old one is replaced.  If name is already being used as an autosave name by a MiscSplitView in the application, and unique names are required (enabled through the requireUniqueAutosaveNames: class method), the name isn't set and this method returns nil; otherwise it returns self.  By default, unique names are not required.

See also:  - setDividersUsingName:, - saveDividersUsingName:, + removeDividersUsingName:, + requireUniqueAutosaveNames:, - dividersAutosaveName, - adjustSubviews, - resizeSubviews:, - mouseDown:




setDividersFromString:
- setDividersFromString:(const char *)data

Sets the MiscSplitView's divider positions by reading them from data.  The positions should have been previously stored through the saveDividersToString: method.  The dividers are constrained according to the minimum and maximum values returned by the delegate method splitView:getMinX:maxX:ofSubviewAt: or splitView:getMinY:maxY:ofSubviewAt: as appropriate, if the delegate implements the method.  After the dividers are set, a splitViewDidResizeSubviews: message is sent to the delegate.  Returns self.

See also:  - saveDividersToString:, - splitView:getMinX:maxX:ofSubviewAt: (delegate method), - splitView:getMinY:maxY:ofSubviewAt: (delegate method), - splitViewDidResizeSubviews: (delegate method)




setDividersUsingName:
- setDividersUsingName:(const char *)name

Sets the MiscSplitView's divider positions by reading, from the defaults system, the position data stored in name.  The dividers are constrained according to the minimum and maximum values returned by the delegate method splitView:getMinX:maxX:ofSubviewAt: or splitView:getMinY:maxY:ofSubviewAt: as appropriate, if the delegate implements the method.  After the dividers are set, a splitViewDidResizeSubviews: message is sent to the delegate.

If name doesn't exist, the dividers are not set and this method returns nil; otherwise it returns self.

See also:  - saveDividersUsingName:, - setDividersAutosaveName:, + removeDividersUsingName:, - saveDividersToString:, - setDividersFromString:, - splitView:getMinX:maxX:ofSubviewAt: (delegate method), - splitView:getMinY:maxY:ofSubviewAt: (delegate method), - splitViewDidResizeSubviews: (delegate method)




setHorizontal:
- setHorizontal:(BOOL)flag

Sets the orientation of the MiscSplitView.  If flag is YES, the MiscSplitView's subviews will be tiled from left to right, with their heights equal.  If flag is NO, the MiscSplitView's subviews will be tiled from top to bottom, with their widths equal.  By default, MiscSplitViews are vertically orientated.

If the MiscSplitView's orientation is changed by this method, the subviews will be retiled the next time drawSelf:: is called.  Returns self.

See also:  - isHorizontal, - drawSelf::, - initFrame:




write:
- write:(NXTypedStream *)stream

Writes the MiscSplitView and a reference to its delegate to the typed stream stream.  Returns self.

See also:  - read:





Methods Implemented by the Delegate

splitView:getMinX:maxX:ofSubviewAt:
- splitView:sender
getMinX:(NXCoord *)minX
maxX:(NXCoord *)maxX
ofSubviewAt:(int)offset

Allows the delegate to constrain the x coordinate limits of a divider when the user drags the mouse in a horizontal MiscSplitView.  This method is invoked before the MiscSplitView begins tracking the mouse to position the divider.  When this method is invoked, the limits have already been set and are stored in minX (the leftmost limit) and maxX (the rightmost limit).  You may further constrain the limits by setting the variables indicated by minX and maxX, but you cannot extend the divider limits.  minX and maxX are specified in the MiscSplitView's flipped coordinate system.  The divider to be repositioned is indicated by offset, an index that counts the dividers from left to right starting with divider 0.   The returned value is ignored.

See also:  - mouseDown:, - adjustSubviews, - constrainDivider:leftFrame:rightFrame:min:max:, - splitView:getMinY:maxY:ofSubviewAt: (delegate method)




splitView:getMinY:maxY:ofSubviewAt:
- splitView:sender
getMinY:(NXCoord *)minY
maxY:(NXCoord *)maxY
ofSubviewAt:(int)offset

Allows the delegate to constrain the y coordinate limits of a divider when the user drags the mouse in a vertical MiscSplitView.  This method is invoked before the MiscSplitView begins tracking the mouse to position the divider.  When this method is invoked, the limits have already been set and are stored in minY (the topmost limit) and maxY (the bottommost limit).  You may further constrain the limits by setting the variables indicated by minY and maxY, but you cannot extend the divider limits.  minY and maxY are specified in the MiscSplitView's flipped coordinate system.  The divider to be repositioned is indicated by offset, an index that counts the dividers from top to bottom starting with divider 0.    The returned value is ignored.

See also:  - mouseDown:,  - adjustSubviews, - constrainDivider:leftFrame:rightFrame:min:max:, - splitView:getMinX:maxX:ofSubviewAt: (delegate method)




splitView:resizeSubviews:
- splitView:sender resizeSubviews:(const NXSize *)oldSize

Allows the delegate to specify custom sizing behavior for the subviews of the MiscSplitView.  If the delegate implements this method, it is invoked after the MiscSplitView is resized; otherwise, adjustSubviews is invoked to retile the subviews.  The old size of the MiscSplitView is indicated by oldSize.

For a vertical MiscSplitView, the subviews should be resized such that the sum of the heights of the subviews plus the sum of the heights of the dividers equals the height of the MiscSplitView's new frame.  For a horizontal MiscSplitView, the subviews should be resized such that the sum of the widths of the subviews plus the sum of the widths of the dividers equals the width of the MiscSplitView's new frame.

You can get the height of a divider through the dividerHeight method and the width of a divider through the dividerWidth method.  Normally they are the same.  You can determine the orientation of the sender through the isHorizontal method.   The returned value is ignored.

See also:  - adjustSubviews, - dividerHeight, - dividerWidth, - dividerSize, - isHorizontal




splitViewDidResizeSubviews:
- splitViewDidResizeSubviews:sender 

Informs the delegate that the sizes of some or all of the MiscSplitView's subviews were changed.  This method is invoked when the MiscSplitView resizes all its subviews because its frame rectangle changed, when the divider positions are changed through setDividersFromString: or setDividersUsingName:, and also after the MiscSplitView resizes two subviews in response to the repositioning of a divider.   The returned value is ignored.

See also:  - resizeSubviews:, -  setDividersFromString:, - setDividersUsingName:, - mouseDown:



These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.