diff --git a/AppKit/CPSplitView.j b/AppKit/CPSplitView.j index 9280eb15a..9dfcb2f14 100644 --- a/AppKit/CPSplitView.j +++ b/AppKit/CPSplitView.j @@ -33,6 +33,14 @@ var CPSplitViewHorizontalImage = nil, /*! @ingroup appkit + @class CPSplitView + + CPSplitView is a view that allows you to stack several subviews vertically or horizontally. The user is given divider to resize the subviews. + The divider indicies are zero-based. So the divider on the top (or left for vertical dividers) will be index 0. + + CPSplitView can be supplied a delegate to provide control over the resizing of the splitview and subviews. Those methods are documented in setDelegate: + + CPSplitView will add dividers for each subview you add. So just like adding subviews to a CPView you should call addSubview: to add new resizable subviews in your splitview. */ @implementation CPSplitView : CPView @@ -96,16 +104,28 @@ var CPSplitViewHorizontalImage = nil, return self; } +/*! + Returns the thickness of the divider. + @return float - the thickness of the divider. +*/ - (float)dividerThickness { return [self currentValueForThemeAttribute:[self isPaneSplitter] ? @"pane-divider-thickness" : @"divider-thickness"]; } +/*! + Returns YES if the divers are vertical, otherwise NO. + @return YES if vertical, otherwise NO. +*/ - (BOOL)isVertical { return _isVertical; } +/*! + Sets if the splitview dividers are vertical. + @param shouldBeVertical - YES if the splitview diverers should be vertical, otherwise NO. +*/ - (void)setVertical:(BOOL)shouldBeVertical { if (![self _setVertical:shouldBeVertical]) @@ -147,11 +167,19 @@ var CPSplitViewHorizontalImage = nil, return changed; } +/*! + Use to find if the diver is a larger pane splitter. + @return BOOL - YES if the divers are the larger pane splitters. Otherwise NO. +*/ - (BOOL)isPaneSplitter { return _isPaneSplitter; } +/*! + Used to set if the split view dividers should be the larger pane splitter. + @param shouldBePaneSplitter - YES if the divers should be the thicker pane splitter, otherwise NO. +*/ - (void)setIsPaneSplitter:(BOOL)shouldBePaneSplitter { if (_isPaneSplitter == shouldBePaneSplitter) @@ -173,11 +201,21 @@ var CPSplitViewHorizontalImage = nil, _needsResizeSubviews = YES; } +/*! + Returns YES if the supplied subview is collapsed, otherwise NO. + @param aSubview - the subview you are interested in. + @return BOOL - YES if the subview is collapsed, otherwise NO. +*/ - (BOOL)isSubviewCollapsed:(CPView)subview { return [subview frame].size[_sizeComponent] < 1 ? YES : NO; } +/*! + Returns the CGRect of the divider at a given index. + @param int - The index of a divider. + @return CGRect - The rect of a divider. +*/ - (CGRect)rectOfDividerAtIndex:(int)aDivider { var frame = [_subviews[aDivider] frame], @@ -191,6 +229,11 @@ var CPSplitViewHorizontalImage = nil, return rect; } +/*! + Returns the rect of the diver which the user is able to drag to resize. + @param int - The index of the divider. + @return CGRect - The rect the user can drag. +*/ - (CGRect)effectiveRectOfDividerAtIndex:(int)aDivider { var realRect = [self rectOfDividerAtIndex:aDivider], @@ -212,7 +255,10 @@ var CPSplitViewHorizontalImage = nil, [self drawDividerInRect:[self rectOfDividerAtIndex:count]]; } } - +/*! + Draws the divder at a given rect. + @param aRect - the rect of the divider to draw. +*/ - (void)drawDividerInRect:(CGRect)aRect { #if PLATFORM(DOM) @@ -485,6 +531,11 @@ var CPSplitViewHorizontalImage = nil, [[CPCursor arrowCursor] set]; } +/*! + Returns the maximum possible position of a divider at a given index. + @param the index of the divider. + @return float - the max possible position. +*/ - (float)maxPossiblePositionOfDividerAtIndex:(int)dividerIndex { var frame = [_subviews[dividerIndex + 1] frame]; @@ -495,6 +546,11 @@ var CPSplitViewHorizontalImage = nil, return [self frame].size[_sizeComponent] - [self dividerThickness]; } +/*! + Returns the minimum possible position of a divider at a given index. + @param the index of the divider. + @return float - the min possible position. +*/ - (float)minPossiblePositionOfDividerAtIndex:(int)dividerIndex { if (dividerIndex > 0) @@ -535,6 +591,11 @@ var CPSplitViewHorizontalImage = nil, return realPosition; } +/*! + Sets the position of a divider at a given index. + @param position - The float value of the position to place the divider. + @param dividerIndex - The index of the divider to position. +*/ - (void)setPosition:(float)position ofDividerAtIndex:(int)dividerIndex { [self _adjustSubviewsWithCalculatedSize]; @@ -644,6 +705,48 @@ var CPSplitViewHorizontalImage = nil, [self _postNotificationDidResize]; } +/*! + Sets the delegate of the reciver. + Possible delegate methods to implement are listed below. + +
+ - (void)splitViewDidResizeSubviews:(CPSplitView)aSplitView; + Notifies the delegate when the subviews have resized. + + - (void)splitViewWillResizeSubviews:(CPSplitView)aSplitView; + Notifies the delegate when the subviews wil be resized. + + - (CGRect)splitView:(CPSplitView)aSplitView effectiveRect:(CGRect)aRect forDrawnRect:(CGRect)aDrawnRect ofDividerAtIndex:(int)aDividerIndex; + Lets the delegate specify a different rect for which the user can drag the splitView divider. + + - (CGRect)splitView:(CPSplitView)aSplitView additionalEffectiveRectOfDividerAtIndex:(int)indexOfDivider; + Lets the delegate specify an additional rect for which the user can drag the splitview divider. + + - (BOOL)splitView:(CPSplitView)aSplitView canCollapseSubview:(CPView)aSubview; + Notifies teh delegate that the splitview is about to be collapsed. This usally happens when the user + Double clicks on the divider. Return YES if the subview can be collapsed, otherwise NO. + + - (BOOL)splitView:(CPSplitView)aSplitView shouldCollapseSubview:(CPView)aSubview; + Notifies teh delegate that the splitview is about to be collapsed. This usally happens when the user + Double clicks on the divider. Return YES if the subview should be collapsed, otherwise NO. + + - (float)splitView:(CPSplitView)aSpiltView constrainSplitPosition:(float)proposedPosition ofSubviewAt:(int)subviewIndex; + Allows the delegate to constrain the subview beings resized. This method is called continiously as the user resizes the divider. + For example if the subview needs to have a width which is a multiple of a certain number you could return that multiple with this method. + + - (float)splitView:(CPSplitView)aSplitView constrainMinCoordinate:(float)proposedMin ofSubviewAt:(int)subviewIndex; + Allows the delegate to constrain the minimum position of a subview. + + - (float)splitView:(CPSplitView)aSplitView constrainMaxCoordinate:(float)proposedMax ofSubviewAt:(int)subviewIndex; + Allows teh delegate to constraing the maximum position of a subview. + + - (void)splitView:(CPSplitView)aSplitView resizeSubviewsWithOldSize:(CGSize)oldSize; + Allows the splitview to specify a custom resizing behaviour. This is called when the splitview is resized. + The sum of the views and the sum of the dividers should be equal to the size of the splitview. ++ + @param delegate - The delegate of the splitview. +*/ - (void)setDelegate:(id)delegate { if ([_delegate respondsToSelector:@selector(splitViewDidResizeSubviews:)]) @@ -676,6 +779,9 @@ var CPSplitViewHorizontalImage = nil, This method will automatically configure the hasResizeControl and resizeControlIsLeftAligned parameters of the button bar, and will override any currently set values. + + @param CPButtonBar - The supplied button bar. + @param unsiged int - The divider index the button bar will be assigned to. */ - (void)setButtonBar:(CPButtonBar)aButtonBar forDividerAtIndex:(unsigned)dividerIndex { @@ -741,7 +847,7 @@ var CPSplitViewDelegateKey = "CPSplitViewDelegateKey", _buttonBars = [aCoder decodeObjectForKey:CPSplitViewButtonBarsKey] || []; - _delegate = [aCoder decodeObjectForKey:CPSplitViewDelegateKey]; + [self setDelegate:[aCoder decodeObjectForKey:CPSplitViewDelegateKey]]; _isPaneSplitter = [aCoder decodeBoolForKey:CPSplitViewIsPaneSplitterKey]; [self _setVertical:[aCoder decodeBoolForKey:CPSplitViewIsVerticalKey]]; diff --git a/AppKit/CPWindow/CPWindow.j b/AppKit/CPWindow/CPWindow.j index 0532b1bbe..c1c233497 100644 --- a/AppKit/CPWindow/CPWindow.j +++ b/AppKit/CPWindow/CPWindow.j @@ -539,6 +539,12 @@ CPTexturedBackgroundWindowMask } } +/*! + Sets the reciever as a full platform window. If you pass YES the CPWindow instance will fill the entier browser content area, + otherwise the CPWindow will be a window inside of your browser window which the user can drag around, and resize (if you allow). + + @param BOOL - YES if the window should fill the browser window, otherwise NO. +*/ - (void)setFullPlatformWindow:(BOOL)shouldBeFullPlatformWindow { if (![_platformWindow supportsFullPlatformWindows]) @@ -579,6 +585,9 @@ CPTexturedBackgroundWindowMask } } +/*! + @return BOOL - YES if the CPWindow fills the browser window, otherwise NO. +*/ - (BOOL)isFullPlatformWindow { return _isFullPlatformWindow; @@ -594,6 +603,18 @@ CPTexturedBackgroundWindowMask /*! Returns the frame rectangle used by a window. + Style masks include: +
+ CPBorderlessWindowMask + CPTitledWindowMask + CPClosableWindowMask + CPMiniaturizableWindowMask (NOTE: only available in NativeHost) + CPResizableWindowMask + CPTexturedBackgroundWindowMask + CPBorderlessBridgeWindowMask + CPHUDBackgroundWindowMask ++ @param aContentRect the content rectangle of the window @param aStyleMask the style mask of the window @return the matching window's frame rectangle @@ -635,7 +656,7 @@ CPTexturedBackgroundWindowMask the resize operation, and redraw itself if necessary. @param aFrame the new size and location for the window @param shouldDisplay whether the window should redraw its views - @param shouldAnimate whether the window resize should be animated + @param shouldAnimate whether the window resize should be animated. */ - (void)_setClippedFrame:(CGRect)aFrame display:(BOOL)shouldDisplay animate:(BOOL)shouldAnimate { @@ -644,6 +665,13 @@ CPTexturedBackgroundWindowMask [self setFrame:aFrame display:shouldDisplay animate:shouldAnimate]; } +/*! + Sets the frame of the window. + + @param aFrame - A CGRect of the new frame for the reciever. + @param shouldDisplay - YES if the window should call setNeedsDisplay otherwise NO. + @param shouldAniamte - YES if the window should animate to it's new size and position, otherwise NO. +*/ - (void)setFrame:(CGRect)aFrame display:(BOOL)shouldDisplay animate:(BOOL)shouldAnimate { aFrame = _CGRectMakeCopy(aFrame); @@ -721,6 +749,11 @@ CPTexturedBackgroundWindowMask } } +/*! + Sets the window's frame rect. + @param aFrame - The new CGRect of the window. + @param shouldDisplay - YES if the window should call setNeedsDisplay: otherwise NO. +*/ - (void)setFrame:(CGRect)aFrame display:(BOOL)shouldDisplay { [self _setClippedFrame:aFrame display:shouldDisplay animate:NO]; @@ -728,6 +761,7 @@ CPTexturedBackgroundWindowMask /*! Sets the window's frame rectangle + @param aFrame - The CGRect of the windows new frame */ - (void)setFrame:(CGRect)aFrame { @@ -1111,6 +1145,17 @@ CPTexturedBackgroundWindowMask [self _updateShadow]; } +/*! + Sets the shadow style of the reciever. + Values are: +
+ CPWindowShadowStyleStandard + CPWindowShadowStyleMenu + CPWindowShadowStylePanel ++ + @param aStyle - The new shadow style of the reciever. +*/ - (void)setShadowStyle:(unsigned)aStyle { _shadowStyle = aStyle; @@ -2448,16 +2493,31 @@ CPTexturedBackgroundWindowMask [self makeFirstResponder:[aView previousValidKeyView]]; } +/*! + Sets the default button for the window. + Note: this method is deprecated use setDefaultButton: instead. + @param aButton - The button that should become default. +*/ - (void)setDefaultButtonCell:(CPButton)aButton { [self setDefaultButton:aButton]; } +/*! + Returns the default button of the reciever. + NOTE: This method is deprecated. Use defaultButton instead. +*/ - (CPButton)defaultButtonCell { return [self defaultButton]; } +/*! + Sets the default button for the window. + This is equivilant to setting the the key equivilant of the button to "return". + Additionally this will turn your button blue (with the Aristo theme). + @param aButton - The button that should become default. +*/ - (void)setDefaultButton:(CPButton)aButton { if (_defaultButton === aButton) @@ -2472,26 +2532,43 @@ CPTexturedBackgroundWindowMask [_defaultButton setKeyEquivalent:CPCarriageReturnCharacter]; } +/*! + Returns the default button of the reciever. +*/ - (CPButton)defaultButton { return _defaultButton; } +/*! + Sets the default button key equivilant to "return". +*/ - (void)enableKeyEquivalentForDefaultButton { _defaultButtonEnabled = YES; } +/*! + Sets the default button key equivilant to "return". + NOTE: this method is deprecated. Use enableKeyEquivalentForDefaultButton instead. +*/ - (void)enableKeyEquivalentForDefaultButtonCell { [self enableKeyEquivalentForDefaultButton]; } +/*! + Removes the key equivilant for the default button. +*/ - (void)disableKeyEquivalentForDefaultButton { _defaultButtonEnabled = NO; } +/*! + Removes the key equivilant for the default button. + Note: this method is deprecated. Use disableKeyEquivalentForDefaultButton instead. +*/ - (void)disableKeyEquivalentForDefaultButtonCell { [self disableKeyEquivalentForDefaultButton]; @@ -2603,16 +2680,25 @@ var keyViewComparator = function(lhs, rhs, context) return _autoresizingMask; } +/*! + Converts aPoint from the window coordinate system to the global coordinate system. +*/ - (CGPoint)convertBaseToGlobal:(CGPoint)aPoint { return [CPPlatform isBrowser] ? [self convertBaseToPlatformWindow:aPoint] : [self convertBaseToScreen:aPoint]; } +/*! + Converts aPoint from the global coordinate system to the window coordinate system. +*/ - (CGPoint)convertGlobalToBase:(CGPoint)aPoint { return [CPPlatform isBrowser] ? [self convertPlatformWindowToBase:aPoint] : [self convertScreenToBase:aPoint]; } +/*! + Converts aPoint from the window coordinate system to the coordinate system of the parent platform window. +*/ - (CGPoint)convertBaseToPlatformWindow:(CGPoint)aPoint { if ([self _sharesChromeWithPlatformWindow]) @@ -2623,6 +2709,9 @@ var keyViewComparator = function(lhs, rhs, context) return _CGPointMake(aPoint.x + origin.x, aPoint.y + origin.y); } +/*! + Converts aPoint from the parent platform window coordiante system to the windows coordinate system. +*/ - (CGPoint)convertPlatformWindowToBase:(CGPoint)aPoint { if ([self _sharesChromeWithPlatformWindow]) @@ -2712,12 +2801,19 @@ var keyViewComparator = function(lhs, rhs, context) @end @implementation CPWindow (Deprecated) - +/*! + Sets the CPWindow to fill the whole browser window. + NOTE: this method has been deprecated in favor of setFullPlatformWindow: +*/ - (void)setFullBridge:(BOOL)shouldBeFullBridge { [self setFullPlatformWindow:shouldBeFullBridge]; } +/*! + Returns YES if the window fills the full browser window, otherwise NO. + NOTE: this method has been deprecated in favor of isFullPlatformWindow. +*/ - (BOOL)isFullBridge { return [self isFullPlatformWindow];