From a40fbd79618d04b97a9362e4102ad08af9581f57 Mon Sep 17 00:00:00 2001
From: Ross Boucher startAnimation
.
+ @param animation the animation that will start
+ @return YES
allows the animation to start.
+ NO
stops the animation.
+
+ @delegate -(void)animationDidEnd:(CPAnimation)animation;
+ Called when an animation has completed.
+ @param animation the animation that completed
+
+ @delegate -(void)animationDidStop:(CPAnimation)animation;
+ Called when the animation was stopped (before completing).
+ @param animation the animation that was stopped
+
+ @delegate - (float)animation:(CPAnimation)animation valueForProgress:(float)progress;
+ The value from this method will be returned when currentValue
method is called.
+ @param animation the animation to obtain the curve value for
+ @param progress the current animation progress
+ @return the curve value
+*/
@implementation CPAnimation : CPObject
{
CPTimeInterval _startTime;
@@ -41,19 +80,25 @@ ACTUAL_FRAME_RATE = 0;
CAMediaTimingFunction _timingFunction;
float _frameRate;
- CPAnimationProgress _progress;
+ float _progress;
id _delegate;
CPTimer _timer;
}
+/*
+ Initializes the animation with a duration and animation curve.
+ @param aDuration the length of the animation
+ @param anAnimationCurve defines the animation's pace
+ @throws CPInvalidArgumentException if an invalid animation curve is specified
+*/
- (id)initWithDuration:(float)aDuration animationCurve:(CPAnimationCurve)anAnimationCurve
{
self = [super init];
if (self)
{
- _duration = aDuration;
+ _duration = MAX(0.0, aDuration);
_animationCurve = anAnimationCurve;
_frameRate = 60.0;
}
@@ -61,6 +106,11 @@ ACTUAL_FRAME_RATE = 0;
return self;
}
+/*
+ Sets the animation's pace.
+ @param anAnimationCurve the animation's pace
+ @throws CPInvalidArgumentException if an invalid animation curve is specified
+*/
- (void)setAnimationCurve:(CPAnimationCurve)anAnimationCurve
{
_animationCurve = anAnimationCurve;
@@ -77,46 +127,87 @@ ACTUAL_FRAME_RATE = 0;
case CPAnimationEaseOut: timingFunctionName = kCAMediaTimingFunctionEaseOut;
break;
+
+ default: [CPException raise:CPInvalidArgumentException
+ reason:"Invalid value provided for animation curve"];
+ break;
}
_timingFunction = [CAMediaTimingFunction functionWithName:timingFunctionName];
}
+/*
+ Returns the animation's pace
+*/
- (CPAnimationCurve)animationCurve
{
return _animationCurve;
}
+/*
+ Sets the animation's length.
+ @param aDuration the new animation length
+ @throws CPInvalidArgumentException if aDuration
is negative
+*/
- (void)setDuration:(CPTimeInterval)aDuration
{
+ if (aDuration < 0)
+ [CPException raise:CPInvalidArgumentException reason:"aDuration can't be negative"];
+
_duration = aDuration;
}
+/*
+ Returns the length of the animation.
+*/
- (CPTimeInterval)duration
{
return _duration;
}
-- (void)setFramesPerSecond:(float)framesPerSecond
+/*
+ Sets the animation frame rate. This is not a guaranteed frame rate. 0 means to go as fast as possible.
+ @param frameRate the new desired frame rate
+ @throws CPInvalidArgumentException if frameRate
is negative
+*/
+- (void)setFrameRate:(float)frameRate
{
- _frameRate = framesPerSecond;
+ if (frameRate < 0)
+ [CPException raise:CPInvalidArgumentException reason:"frameRate can't be negative"];
+
+ _frameRate = frameRate;
}
+/*
+ Returns the desired frame rate.
+*/
- (float)frameRate
{
return _frameRate;
}
+/*
+ Returns the animation's delegate
+*/
- (id)delegate
{
return _delegate;
}
+/*
+ Sets the animation's delegate.
+ @param aDelegate the new delegate
+*/
- (void)setDelegate:(id)aDelegate
{
_delegate = aDelegate;
}
+/*
+ Starts the animation. The method calls animationShouldStart:
+ on the delegate (if it implements it) to see if the animation
+ should begin.
+*/
- (void)startAnimation
{
// If we're already animating, or our delegate stops us, animate.
@@ -133,11 +224,16 @@ ACTUAL_FRAME_RATE = 0;
}, 1); // must be 1ms not 0 for IE. //_duration * 1000 / _frameRate);
}
+/*
+ @ignore
+*/
- (void)animationTimerDidFire:(CPTimer)aTimer
{
var elapsed = new Date() - _startTime,
progress = MIN(1.0, 1.0 - (_duration - elapsed / 1000.0) / _duration);
-++ACTUAL_FRAME_RATE;
+
+ ++ACTUAL_FRAME_RATE;
+
[self setCurrentProgress:progress];
if (progress == 1.0)
@@ -151,6 +247,9 @@ ACTUAL_FRAME_RATE = 0;
}
+/*
+ Stops the animation before it has completed.
+*/
- (void)stopAnimation
{
if (!_timer)
@@ -162,21 +261,35 @@ ACTUAL_FRAME_RATE = 0;
[_delegate animationDidStop:self];
}
+/*
+ Returns YES
if the animation
+ is running.
+*/
- (BOOL)isAnimating
{
return _timer;
}
-- (void)setCurrentProgress:(CPAnimationProgress)aProgress
+/*
+ Sets the animation's progress.
+ @param aProgress the animation's progress
+*/
+- (void)setCurrentProgress:(float)aProgress
{
_progress = aProgress;
}
-- (CPAnimationProgress)currentProgress
+/*
+ Returns the animation's progress
+*/
+- (float)currentProgress
{
return _progress;
}
+/*
+ Returns the animation's timing progress.
+*/
- (float)currentValue
{
if ([_delegate respondsToSelector:@selector(animation:valueForProgress:)])
diff --git a/AppKit/CPApplication.j b/AppKit/CPApplication.j
index 290581fb1c..f2c81c12a2 100644
--- a/AppKit/CPApplication.j
+++ b/AppKit/CPApplication.j
@@ -37,6 +37,28 @@ CPRunStoppedResponse = -1000;
CPRunAbortedResponse = -1001;
CPRunContinuesResponse = -1002;
+/*
+ CPApplication is THE way to start up the Cappucino framework for your application to use.
+ Every GUI application has exactly one instance of CPApplication (or of a custom subclass of
+ CPApplication). Your program's main() function can create that instance by calling the
+ CPApplicationMain
function. A simple example looks like this:
+
+
+ function main(args, namedArgs)
+ {
+ CPApplicationMain(args, namedArgs);
+ }
+
+
+ @delegate -(void)applicationDidFinishLaunching:(CPNotification)aNotification;
+ Sent from the notification center after the app initializes, but before
+ receiving events.
+ @param aNotification contains information about the event
+
+ @delegate -(void)applicationWillFinishLaunching:(CPNotification)aNotification;
+ Sent from the notification center before the app is initialized.
+ @param aNotification contains information about the event
+*/
@implementation CPApplication : CPResponder
{
CPArray _eventListeners;
@@ -59,6 +81,11 @@ CPRunContinuesResponse = -1002;
CPArray _args;
}
+/*
+ Returns the singleton instance of the running application. If it
+ doesn't exist, it will be created, and then returned.
+ @return the application singleton
+*/
+ (CPApplication)sharedApplication
{
if (!CPApp)
@@ -67,6 +94,11 @@ CPRunContinuesResponse = -1002;
return CPApp;
}
+/*
+ Initializes the Document based application with basic menu functions.
+ Functions are New, Open, Undo, Redo, Save, Cut, Copy, Paste
.
+ @return the initialized application
+*/
- (id)init
{
self = [super init];
@@ -142,6 +174,12 @@ CPRunContinuesResponse = -1002;
// Configuring Applications
+/*
+ Sets the delegate for this application. The delegate will receive various notifications
+ caused by user interactions during the application's run. The delegate can choose to
+ react to these events.
+ @param aDelegate the delegate object
+*/
- (void)setDelegate:(id)aDelegate
{
if (_delegate == aDelegate)
@@ -179,11 +217,20 @@ CPRunContinuesResponse = -1002;
object:self];
}
+/*
+ Returns the application's delegate. The app can only have one delegate at a time.
+*/
- (id)delegate
{
return _delegate;
}
+/*
+ This method is called by run
before the event loop begins.
+ When it successfully completes, it posts the notification
+ finishLaunching
, the subclass method should invoke the superclass method.
+*/
- (void)finishLaunching
{
var bundle = [CPBundle mainBundle],
@@ -221,18 +268,30 @@ CPRunContinuesResponse = -1002;
[[CPRunLoop currentRunLoop] performSelectors];
}
+/*
+ Calls finishLaunching
method which results in starting
+ the main event loop.
+*/
- (void)run
{
[self finishLaunching];
}
// Managing the Event Loop
-
+/*
+ Starts a modal event loop for aWindow
+ @param aWindow the window to start the event loop for
+*/
- (void)runModalForWindow:(CPWindow)aWindow
{
[self runModalSession:[self beginModalSessionForWindow:aWindow]];
}
+/*
+ Stops the event loop started by runModalForWindow:
and
+ sets the code that runModalForWindow:
will return.
+ @param aCode the return code for the modal event
+*/
- (void)stopModalWithCode:(int)aCode
{
if (!_currentSession)
@@ -248,6 +307,7 @@ CPRunContinuesResponse = -1002;
[self _removeRunModalLoop];
}
+/* @ignore */
- (void)_removeRunModalLoop
{
var count = _eventListeners.length;
@@ -261,21 +321,35 @@ CPRunContinuesResponse = -1002;
}
}
+/*
+ Stops the modal event loop
+*/
- (void)stopModal
{
[self stopModalWithCode:CPRunStoppedResponse]
}
+/*
+ Aborts the event loop started by runModalForWindow:
+*/
- (void)abortModal
{
[self stopModalWithCode:CPRunAbortedResponse];
}
+/*
+ Sets up a modal session with theWindow
.
+ @param aWindow the window to set up the modal session for
+*/
- (CPModalSession)beginModalSessionForWindow:(CPWindow)aWindow
{
return _CPModalSessionMake(aWindow, 0);
}
+/*
+ Runs a modal session
+ @param CPModalSession the session to run
+*/
- (void)runModalSession:(CPModalSession)aModalSession
{
aModalSession._previous = _currentSession;
@@ -291,6 +365,10 @@ CPRunContinuesResponse = -1002;
[CPApp setCallback:_CPRunModalLoop forNextEventMatchingMask:CPAnyEventMask untilDate:nil inMode:0 dequeue:NO];
}
+/*
+ Returns the window for the current modal session. If there is no
+ modal session, it returns nil
.
+*/
- (CPWindow)modalWindow
{
if (!_currentSession)
@@ -299,6 +377,7 @@ CPRunContinuesResponse = -1002;
return _currentSession._window;
}
+/* @ignore */
- (BOOL)_handleKeyEquivalent:(CPEvent)anEvent
{
if ([_mainMenu performKeyEquivalent:anEvent])
@@ -307,6 +386,10 @@ CPRunContinuesResponse = -1002;
return NO;
}
+/*
+ Dispatches events to other objects.
+ @param anEvent the event to dispatch
+*/
- (void)sendEvent:(CPEvent)anEvent
{
// Check if this is a candidate for key equivalent...
@@ -335,40 +418,66 @@ CPRunContinuesResponse = -1002;
[super doCommandBySelector:aSelector];
}
+/*
+ Returns the key window.
+*/
- (CPWindow)keyWindow
{
return _keyWindow;
}
+/*
+ Returns the main window.
+*/
- (CPWindow)mainWindow
{
return _mainWindow;
}
+/*
+ Returns the aWindowNumber
.
+*/
- (CPWindow)windowWithWindowNumber:(int)aWindowNumber
{
return _windows[aWindowNumber];
}
+/*
+ Returns an array of the application's YES
if the action was performed
+*/
- (BOOL)tryToPerform:(SEL)anAction with:(id)anObject
{
if (!anAction)
@@ -387,6 +496,13 @@ CPRunContinuesResponse = -1002;
return NO;
}
+/*
+ Sends an action to a target.
+ @param anAction the action to send
+ @param aTarget the target for the action
+ @param aSender the action sender
+ @return YES
+*/
- (BOOL)sendAction:(SEL)anAction to:(id)aTarget from:(id)aSender
{
var target = [self targetForAction:anAction to:aTarget from:aSender];
@@ -399,6 +515,17 @@ CPRunContinuesResponse = -1002;
return YES;
}
+/*
+ Finds a target for the specified action. If the
+ action is nil
, returns nil
.
+ If the target is not nil
, aTarget
is
+ returned. Otherwise, it calls targetForAction:
+ to search for a target.
+ @param anAction the action to find a target for
+ @param aTarget if not nil
, this will be returned
+ @aSender not used
+ @return a target for the action
+*/
- (id)targetForAction:(SEL)anAction to:(id)aTarget from:(id)aSender
{
if (!anAction)
@@ -410,6 +537,23 @@ CPRunContinuesResponse = -1002;
return [self targetForAction:anAction];
}
+/*
+ Finds an action-target for a specified window.
+ It finds a matching target in the following order:
+
+
+ @param aWindow the window to search for a target
+ @param anAction the action to find a responder to
+ @return the object that responds to the action, or nil
+ if no matching target was found
+ @ignore
+*/
- (id)_targetForWindow:(CPWindow)aWindow action:(SEL)anAction
{
var responder = [aWindow firstResponder],
@@ -431,7 +575,7 @@ CPRunContinuesResponse = -1002;
var delegate = [aWindow delegate];
- if ([aWindow respondsToSelector:anAction])
+ if ([delegate respondsToSelector:anAction])
return delegate;
var windowController = [aWindow windowController];
@@ -447,6 +591,20 @@ CPRunContinuesResponse = -1002;
return nil;
}
+/*
+ Looks for a target that can handle the specified action.
+ Checks for a target in the following order:
+
+
+ @param anAction the action to handle
+ @return a target that can respond, or nil
+ if no match could be found
+*/
- (id)targetForAction:(SEL)anAction
{
if (!anAction)
@@ -488,6 +646,14 @@ CPRunContinuesResponse = -1002;
// Managing Sheets
+/*
+ Displays a window as a sheet.
+ @param aSheet the window to display as a sheet
+ @param aWindow the window that will hold the sheet as a child
+ @param aModalDelegate
+ @param aDidEndSelector
+ @param aContextInfo
+*/
- (void)beginSheet:(CPWindow)aSheet modalForWindow:(CPWindow)aWindow modalDelegate:(id)aModalDelegate didEndSelector:(SEL)aDidEndSelector contextInfo:(id)aContextInfo
{
[aWindow _attachSheet:aSheet modalDelegate:aModalDelegate didEndSelector:aDidEndSelector contextInfo:aContextInfo];
@@ -532,6 +698,12 @@ var _CPRunModalLoop = function(anEvent)
[CPApp _removeRunModalLoop];
}
+/*
+ Starts the GUI and Cappuccino frameworks. This function should be
+ called from the main()
function of your program.
+ @class CPApplication
+ @return void
+*/
function CPApplicationMain(args, namedArgs)
{
var mainBundle = [CPBundle mainBundle],
diff --git a/AppKit/CPButton.j b/AppKit/CPButton.j
index 5a4f1ed911..dcaeac5376 100644
--- a/AppKit/CPButton.j
+++ b/AppKit/CPButton.j
@@ -27,48 +27,188 @@ import "CPControl.j"
#include "CoreGraphics/CGGeometry.h"
-
CPScaleProportionally = 0;
CPScaleToFit = 1;
CPScaleNone = 2;
+/*
+ @global
+ @group CPCellImagePosition
+*/
CPNoImage = 0;
+/*
+ @global
+ @group CPCellImagePosition
+*/
CPImageOnly = 1;
+/*
+ @global
+ @group CPCellImagePosition
+*/
CPImageLeft = 2;
+/*
+ @global
+ @group CPCellImagePosition
+*/
CPImageRight = 3;
+/*
+ @global
+ @group CPCellImagePosition
+*/
CPImageBelow = 4;
+/*
+ @global
+ @group CPCellImagePosition
+*/
CPImageAbove = 5;
+/*
+ @global
+ @group CPCellImagePosition
+*/
CPImageOverlaps = 6;
+/*
+ @global
+ @class CPButton
+*/
CPOnState = 1;
+/*
+ @global
+ @class CPButton
+*/
CPOffState = 0;
+/*
+ @global
+ @class CPButton
+*/
CPMixedState = -1;
+/*
+ @global
+ @group CPBezelStyle
+*/
CPRoundedBezelStyle = 1;
+/*
+ @global
+ @group CPBezelStyle
+*/
CPRegularSquareBezelStyle = 2;
+/*
+ @global
+ @group CPBezelStyle
+*/
CPThickSquareBezelStyle = 3;
+/*
+ @global
+ @group CPBezelStyle
+*/
CPThickerSquareBezelStyle = 4;
+/*
+ @global
+ @group CPBezelStyle
+*/
CPDisclosureBezelStyle = 5;
+/*
+ @global
+ @group CPBezelStyle
+*/
CPShadowlessSquareBezelStyle = 6;
+/*
+ @global
+ @group CPBezelStyle
+*/
CPCircularBezelStyle = 7;
+/*
+ @global
+ @group CPBezelStyle
+*/
CPTexturedSquareBezelStyle = 8;
+/*
+ @global
+ @group CPBezelStyle
+*/
CPHelpButtonBezelStyle = 9;
+/*
+ @global
+ @group CPBezelStyle
+*/
CPSmallSquareBezelStyle = 10;
+/*
+ @global
+ @group CPBezelStyle
+*/
CPTexturedRoundedBezelStyle = 11;
+/*
+ @global
+ @group CPBezelStyle
+*/
CPRoundRectBezelStyle = 12;
+/*
+ @global
+ @group CPBezelStyle
+*/
CPRecessedBezelStyle = 13;
+/*
+ @global
+ @group CPBezelStyle
+*/
CPRoundedDisclosureBezelStyle = 14;
+/*
+ @global
+ @group CPBezelStyle
+*/
CPHUDBezelStyle = -1;
+
+/*
+ @global
+ @group CPButtonType
+*/
CPMomentaryLightButton = 0;
+/*
+ @global
+ @group CPButtonType
+*/
CPPushOnPushOffButton = 1;
+/*
+ @global
+ @group CPButtonType
+*/
CPToggleButton = 2;
+/*
+ @global
+ @group CPButtonType
+*/
CPSwitchButton = 3;
+/*
+ @global
+ @group CPButtonType
+*/
CPRadioButton = 4;
+/*
+ @global
+ @group CPButtonType
+*/
CPMomentaryChangeButton = 5;
+/*
+ @global
+ @group CPButtonType
+*/
CPOnOffButton = 6;
+/*
+ @global
+ @group CPButtonType
+*/
CPMomentaryPushInButton = 7;
+/*
+ @global
+ @group CPButtonType
+*/
CPMomentaryPushButton = 0;
+/*
+ @global
+ @group CPButtonType
+*/
CPMomentaryLight = 7;
@@ -79,6 +219,11 @@ var _CPButtonClassName = nil,
_CPButtonBezelStyleIdentifiers = {},
_CPButtonBezelStyleHighlightedIdentifier = @"Highlighted";
+/*
+ anImagePosition
.
+ @param anImagePosition the position for the button's image
+*/
- (void)setImagePosition:(CPCellImagePosition)anImagePosition
{
if (_imagePosition == anImagePosition)
@@ -196,11 +352,18 @@ var _CPButtonClassName = nil,
[self drawContentsWithHighlight:_isHighlighted];
}
+/*
+ Returns the buton's image position
+*/
- (CPCellImagePosition)imagePosition
{
return _imagePosition;
}
+/*
+ Sets the button's images scaling method
+ @param anImageScaling the image scaling method
+*/
- (void)setImageScaling:(CPImageScaling)anImageScaling
{
if (_imageScaling == anImageScaling)
@@ -211,11 +374,18 @@ var _CPButtonClassName = nil,
[self drawContentsWithHighlight:_isHighlighted];
}
+/*
+ Returns the button's image scaling method
+*/
- (CPImageScaling)imageScaling
{
return _imageScaling;
}
+/*
+ Sets the color of the button's text
+ @param aColor the color to use for drawing the button text
+*/
- (void)setTextColor:(CPColor)aColor
{
[super setTextColor:aColor];
@@ -223,6 +393,10 @@ var _CPButtonClassName = nil,
[self drawContentsWithHighlight:_isHighlighted];
}
+/*
+ Sets the font that will be used to draw the button text
+ @param aFont the font used to draw the button text
+*/
- (void)setFont:(CPFont)aFont
{
[super setFont:aFont];
@@ -231,17 +405,26 @@ var _CPButtonClassName = nil,
}
// Setting the state
-
+/*
+ Returns YES
if the button has a 'mixed' state in addition to on and off.
+*/
- (BOOL)allowsMixedState
{
return _allowsMixedState;
}
+/*
+ Sets whether the button can have a 'mixed' state.
+ @param aFlag specifies whether a 'mixed' state is allowed or not
+*/
- (void)setAllowsMixedState:(BOOL)aFlag
{
_allowsMixedState = aFlag;
}
+/*
+ Sets the button to its next state.
+*/
- (void)setNextState
{
if (_state == CPOffState)
@@ -250,16 +433,28 @@ var _CPButtonClassName = nil,
_state = (_state >= CPOnState && _allowsMixedState) ? CPMixedState : CPOffState;
}
+/*
+ Sets the button's state to aState
.
+ @param aState Possible states are any of the CPOffState, CPOnState, CPMixedState
+*/
- (void)setState:(int)aState
{
_state = aState;
}
+/*
+ Returns the button's current state
+*/
- (int)state
{
return _state;
}
+/*
+ Sets the alignment of the text on the button.
+ @param anAlignment an alignment object
+*/
- (void)setAlignment:(CPTextAlignment)anAlignment
{
[super setAlignment:anAlignment];
@@ -267,6 +462,10 @@ var _CPButtonClassName = nil,
[self drawContentsWithHighlight:_isHighlighted];
}
+/*
+ Sets the image that will be drawn on the button.
+ @param anImage the image that will be drawn
+*/
- (void)setImage:(CPImage)anImage
{
if (_image == anImage)
@@ -277,21 +476,35 @@ var _CPButtonClassName = nil,
[self drawContentsWithHighlight:_isHighlighted];
}
+/*
+ Returns the image that will be drawn on the button
+*/
- (CPImage)image
{
return _image;
}
+/*
+ Sets the button's image which is used in its alternate state.
+ @param anImage the image to be used while the button is in an alternate state
+*/
- (void)setAlternateImage:(CPImage)anImage
{
_alternateImage = anImage;
}
+/*
+ Returns the image used when the button is in an alternate state.
+*/
- (CPImage)alternateImage
{
return _alternateImage;
}
+/*
+ Sets the button's title.
+ @param aTitle the new title for the button
+*/
- (void)setTitle:(CPString)aTitle
{
if (_title == aTitle)
@@ -302,11 +515,17 @@ var _CPButtonClassName = nil,
[self drawContentsWithHighlight:_isHighlighted];
}
+/*
+ Returns the button's title string
+*/
- (CPString)title
{
return _title;
}
+/*
+ Lays out the button.
+*/
- (void)tile
{
var size = [self bounds].size;
@@ -328,6 +547,9 @@ var _CPButtonClassName = nil,
[_imageAndTitleView setFrameSize:size];
}
+/*
+ Compacts the button's frame to fit its contents.
+*/
- (void)sizeToFit
{
[_imageAndTitleView sizeToFit];
@@ -346,29 +568,48 @@ var _CPButtonClassName = nil,
[self setFrameSize:CGSizeMake(CGRectGetWidth(frame), height)];
}
-- (void)setFrameSize:(CPSize)aSize
+/*
+ Sets the frame size for the button.
+ @param the new frame size
+*/
+- (void)setFrameSize:(CGSize)aSize
{
[super setFrameSize:aSize];
[self tile];
}
+/*
+ Highlights the receiver based on aFlag
.
+ @param If YES
the button will highlight, NO
the button will unhighlight.
+*/
- (void)highlight:(BOOL)aFlag
{
[self drawBezelWithHighlight:aFlag];
[self drawContentsWithHighlight:aFlag];
}
+/*
+ Sets button's tag.
+ @param aTag the button's new tag
+*/
- (void)setTag:(int)aTag
{
_tag = aTag;
}
+/*
+ Returns the button's tag.
+*/
- (int)tag
{
return _tag;
}
+/*
+ Called when the user clicks on this button.
+ @param anEvent the event with information about the click
+*/
- (void)mouseDown:(CPEvent)anEvent
{
_isHighlighted = YES;
@@ -376,6 +617,10 @@ var _CPButtonClassName = nil,
[self highlight:_isHighlighted];
}
+/*
+ Called when the user drags on the button.
+ @param anEvent the event with information about the drag
+*/
- (void)mouseDragged:(CPEvent)anEvent
{
_isHighlighted = CGRectContainsPoint([self bounds], [self convertPoint:[anEvent locationInWindow] fromView:nil]);
@@ -383,6 +628,10 @@ var _CPButtonClassName = nil,
[self highlight:_isHighlighted];
}
+/*
+ Called when the user releases the mouse button
+ @param anEvent the event with information about the mouse release
+*/
- (void)mouseUp:(CPEvent)anEvent
{
_isHighlighted = NO;
@@ -392,7 +641,10 @@ var _CPButtonClassName = nil,
[super mouseUp:anEvent];
}
-// FIXME: This probably belongs in CPControl.
+/*
+ Sets the button's control size.
+ @param aControlSize the button's new control size
+*/
- (void)setControlSize:(CPControlSize)aControlSize
{
if (_controlSize == aControlSize)
@@ -404,11 +656,18 @@ var _CPButtonClassName = nil,
[self _updateTextAttributes];
}
+/*
+ Returns the button's control size.
+*/
- (CPControlSize)controlSize
{
return _controlSize;
}
+/*
+ Sets whether the button has a bezeled border.
+ @param If YES
, the the button will have a bezeled border.
+*/
- (void)setBordered:(BOOL)isBordered
{
if (_isBordered == isBordered)
@@ -422,11 +681,18 @@ var _CPButtonClassName = nil,
[self tile];
}
+/*
+ Returns YES
if the border is bezeled.
+*/
- (BOOL)isBordered
{
return _isBordered;
}
+/*
+ Sets the button's bezel style.
+ @param aBezelStye one of the predefined bezel styles
+*/
- (void)setBezelStyle:(CPBezelStyle)aBezelStyle
{
// FIXME: We need real support for these:
@@ -457,11 +723,15 @@ var _CPButtonClassName = nil,
[self tile];
}
+/*
+ Returns the current bezel style
+*/
- (int)bezelStyle
{
return _bezelStyle;
}
+/* @ignore */
- (void)updateBackgroundColors
{
if (_isBordered)
@@ -488,6 +758,7 @@ var _CPButtonClassName = nil,
}
}
+/* @ignore */
- (void)drawBezelWithHighlight:(BOOL)shouldHighlight
{
_bezelBorderNeedsUpdate = ![self window];
@@ -498,6 +769,7 @@ var _CPButtonClassName = nil,
[self setBackgroundColorWithName:shouldHighlight ? CPControlHighlightedBackgroundColor : CPControlNormalBackgroundColor];
}
+/* @ignore */
- (void)drawContentsWithHighlight:(BOOL)isHighlighted
{
if (!_title && !_image && !_alternateTitle && !_alternateImage && !_imageAndTitleView)
@@ -528,6 +800,7 @@ var _CPButtonClassName = nil,
[self drawBezelWithHighlight:_isHighlighted];
}
+/* @ignore */
- (void)_updateTextAttributes
{
if (_bezelStyle == CPHUDBezelStyle)
@@ -553,6 +826,10 @@ var CPButtonImageKey = @"CPButtonImageKey",
@implementation CPButton (CPCoding)
+/*
+ Initializes the button by unarchiving data from aCoder
.
+ @param aCoder the coder containing the archived aView
.
+ @param aView the new document view. It's frame origin will be changed to (0,0)
after calling this method.
+*/
- (void)setDocumentView:(CPView)aView
{
if (_documentView == aView)
@@ -78,11 +85,20 @@ import "CPView.j"
}
}
+/*
+ Returns the document view.
+*/
- (id)documentView
{
return _documentView;
}
+/*
+ Returns a new point that may be adjusted from aPoint
+ to make sure it lies within the document view.
+ @param aPoint
+ @return the adjusted point
+*/
- (CGPoint)constrainScrollPoint:(CGPoint)aPoint
{
var documentFrame = [_documentView frame];
@@ -106,11 +122,19 @@ import "CPView.j"
[superview reflectScrolledClipView:self];
}
-- (void)scrollToPoint:(CPPoint)aPoint
+/*
+ Scrolls the clip view to the specified point. The method
+ sets its bounds origin to aPoint
.
+*/
+- (void)scrollToPoint:(CGPoint)aPoint
{
[self setBoundsOrigin:[self constrainScrollPoint:aPoint]];
}
+/*
+ Handles a anItem
+ @param anItem the new item prototype
+*/
- (void)setItemPrototype:(CPCollectionViewItem)anItem
{
_itemData = [CPKeyedArchiver archivedDataWithRootObject:anItem];
@@ -94,11 +122,18 @@ import anObject
.
+ @param anObject the object to be represented.
+*/
- (CPCollectionViewItem)newItemForRepresentedObject:(id)anObject
{
var item = nil;
@@ -115,19 +150,29 @@ import YES
by default.
+*/
- (BOOL)acceptsFirstResponder
{
return YES;
}
+/*
+ Returns whether the receiver is currently the first responder.
+*/
- (BOOL)isFirstResponder
{
return [[self window] firstResponder] == self;
}
// Setting the Content
-
+/*
+ Sets the content of the collection view to the content in anArray
.
+ This array can be of any type, and each element will be passed to the setRepresentedObject:
method.
+ It's the responsibility of your custom collection view item to interpret the object.
+ @param anArray the content array
+*/
- (void)setContent:(CPArray)anArray
{
if (_content == anArray)
@@ -138,18 +183,27 @@ import YES
allows the user to select items.
+*/
- (void)setSelectable:(BOOL)isSelectable
{
if (_isSelectable == isSelectable)
@@ -166,21 +220,36 @@ import YES
if the collection view is
+ selected, and NO
otherwise.
+*/
- (BOOL)isSelected
{
return _isSelected;
}
+/*
+ Sets whether the user can select multiple items.
+ @param shouldAllowMultipleSelection YES
allows the user to select multiple items
+*/
- (void)setAllowsMultipleSelection:(BOOL)shouldAllowMultipleSelection
{
_allowsMultipleSelection = shouldAllowsMultipleSelection;
}
+/*
+ Returns YES
if the user can select multiple items, NO
otherwise.
+*/
- (BOOL)allowsMultipleSelection
{
return _allowsMultipleSelection;
}
+/*
+ Sets the selected items based on the provided indices.
+ @param anIndexSet the set of items to be selected
+*/
- (void)setSelectionIndexes:(CPIndexSet)anIndexSet
{
if (_selectionIndexes == anIndexSet)
@@ -202,11 +271,15 @@ import YES
makes the item selected. NO
deselects it.
+*/
- (void)setSelected:(BOOL)shouldBeSelected
{
if (_isSelected == shouldBeSelected)
@@ -499,13 +630,18 @@ import YES
if the item is currently selected. NO
if the item is not selected.
+*/
- (BOOL)isSelected
{
return _isSelected;
}
// Parent Collection View
-
+/*
+ Returns the collection view of which this item is a part.
+*/
- (CPCollectionView)collectionView
{
return [_view superview];
@@ -517,6 +653,9 @@ var CPCollectionViewItemViewKey = @"CPCollectionViewItemViewKey";
@implementation CPCollectionViewItem (CPCoding)
+/*
+ FIXME Not yet implemented
+*/
- (id)copy
{
@@ -528,6 +667,11 @@ var CPCollectionViewItemViewKey = @"CPCollectionViewItemViewKey";
@implementation CPCollectionViewItem (CPCoding)
+/*
+ Initializes the view item by unarchiving data from a coder.
+ @param aCoder the coder from which the data will be unarchived
+ @return the initialized collection view item
+*/
- (id)initWithCoder:(CPCoder)aCoder
{
self = [super init];
@@ -538,6 +682,10 @@ var CPCollectionViewItemViewKey = @"CPCollectionViewItemViewKey";
return self;
}
+/*
+ Archives the colletion view item to the provided coder.
+ @param aCoder the coder to which the view item should be archived
+*/
- (void)encodeWithCoder:(CPCoder)aCoder
{
[aCoder encodeObject:_view forKey:CPCollectionViewItemViewKey];
diff --git a/AppKit/CPColor.j b/AppKit/CPColor.j
index dd88941924..fccc667332 100644
--- a/AppKit/CPColor.j
+++ b/AppKit/CPColor.j
@@ -35,7 +35,19 @@ var _redComponent = 0,
var _hueComponent = 0,
_saturationComponent = 1,
_brightnessComponent = 2;
-
+
+/*
+ CPColor
can be used to represent color
+ in an RGB or HSB model with an optional transparency value.
It also provides some class helper methods that + returns instances of commonly used colors.
+ +The class does not have a set:
method
+ like NextStep based frameworks to change the color of
+ the current context. To change the color of the current
+ context, use white
for the RGB components.
+ For the alpha component, a value of 1.0 is opaque, and 0.0 means completely transparent.
+
+ @param white a float between 0.0 and 1.0
+ @param alpha the alpha component between 0.0 and 1.0
+
+ @return a color initialized to the values specified
+*/
+ (CPColor)colorWithCalibratedWhite:(float)white alpha:(float)alpha
{
return [[CPColor alloc] _initWithRGBA:[white, white, white, alpha]];
}
+/*
+ Creates a new color in HSB space.
+
+ @param hue the hue value
+ @param saturation the saturation value
+ @param brightness the brightness value
+
+ @return the initialized color
+*/
+ (CPColor)colorWithHue:(float)hue saturation:(float)saturation brightness:(float)brightness
{
if(saturation == 0.0)
@@ -76,71 +119,123 @@ var _hueComponent = 0,
}
}
+/*
+ Creates an RGB color from a hexadecimal string. For example,
+ the a string of "FFFFFF" would return a white CPColor.
+ "FF0000" would return a pure red, "00FF00" would return a
+ pure blue, and "0000FF" would return a pure green.
+
+ @param hex a 6 character long string of hex
+
+ @return an initialized RGB color
+*/
+ (CPColor)colorWithHexString:(string)hex
{
return [[CPColor alloc] _initWithRGBA: hexToRGB(hex)];
}
+/*
+ Returns a black color object. (RGBA=[0.0, 0.0, 0.0, 1.0])
+*/
+ (CPColor)blackColor
{
return [[CPColor alloc] _initWithRGBA:[0.0, 0.0, 0.0, 1.0]];
}
+/*
+ Returns a blue color object. (RGBA=[0.0, 0.0, 1.0, 1.0])
+*/
+ (CPColor)blueColor
{
return [[CPColor alloc] _initWithRGBA:[0.0, 0.0, 1.0, 1.0]];
}
+/*
+ Returns a dark gray color object. (RGBA=[0.33 ,0.33, 0.33, 1.0])
+*/
+ (CPColor)darkGrayColor
{
return [CPColor colorWithCalibratedWhite:1.0 / 3.0 alpha:1.0];
}
+/*
+ Returns a gray color object. (RGBA=[0.5, 0.5, 0.5, 1.0])
+*/
+ (CPColor)grayColor
{
return [CPColor colorWithCalibratedWhite:0.5 alpha: 1.0];
}
+/*
+ Returns a green color object. (RGBA=[0.0, 1.0, 0.0, 1.0])
+*/
+ (CPColor)greenColor
{
return [[CPColor alloc] _initWithRGBA:[0.0, 1.0, 0.0, 1.0]];
}
+/*
+ Returns a light gray color object (RGBA=[0.66, 0.66, 0.66, 1.0])
+*/
+ (CPColor)lightGrayColor
{
return [CPColor colorWithCalibratedWhite:2.0 / 3.0 alpha:1.0];
}
+/*
+ Returns a red color object (RGBA=[1.0, 0.0, 0.0, 1.0])
+*/
+ (CPColor)redColor
{
return [[CPColor alloc] _initWithRGBA:[1.0, 0.0, 0.0, 1.0]];
}
+/*
+ Returns a white color object (RGBA=[1.0, 1.0, 1.0, 1.0])
+*/
+ (CPColor)whiteColor
{
return [[CPColor alloc] _initWithRGBA:[1.0, 1.0, 1.0, 1.0]];
}
+/*
+ Returns a yellow color object (RGBA=[1.0, 1.0, 0.0, 1.0])
+*/
+ (CPColor)yellowColor
{
return [[CPColor alloc] _initWithRGBA:[1.0, 1.0, 0.0, 1.0]];
}
+/*
+ Returns a shadow looking color (RGBA=[0.0, 0.0, 0.0, 0.33])
+*/
+ (CPColor)shadowColor
{
return [[CPColor alloc] _initWithRGBA:[0.0, 0.0, 0.0, 1.0 / 3.0]];
}
+/*
+ Creates a color using a tile pattern with anImage
+ @param the image to tile
+ @return a tiled image color object
+*/
+ (CPColor)colorWithPatternImage:(CPImage)anImage
{
return [[CPColor alloc] _initWithPatternImage:anImage];
}
+/*
+ Creates a
+Index Component +0 Red +1 Green +2 Blue +3 Alpha ++*/ - (CPArray)components { return _components; } +/* + Returns a new color with the same RGB as the receiver but a new alpha component. + + @param anAlphaComponent the alpha component for the new color + + @return a new color object +*/ - (CPColor)colorWithAlphaComponent:(float)anAlphaComponent { var components = _components.slice(); @@ -270,6 +400,16 @@ var _hueComponent = 0, return [[[self class] alloc] _initWithRGBA:components]; } +/* + Returns an array with the HSB values for this color. + The index values are ordered as: +
+Index Component +0 Hue +1 Saturation +2 Brightness ++*/ - (CPArray)hsbComponents { var red = ROUND(_components[_redComponent] * 255.0), @@ -311,11 +451,23 @@ var _hueComponent = 0, ]; } +/* + Returns the CSS representation of this color. The color will + be in one of the following forms: +
+rgb(22,44,88) +rgba(22,44,88,0.5) // if there is an alpha +url("data:image/png;base64,BASE64ENCODEDDATA") // if there is a pattern image ++*/ - (CPString)cssString { return _cssString; } +/* + Returns a 6 character long hex string of this color. +*/ - (CPString)hexString { return rgbToHex([self redComponent], [self greenComponent], [self blueComponent]) @@ -328,6 +480,10 @@ var CPColorComponentsKey = @"CPColorComponentsKey", @implementation CPColor (CPCoding) +/* + Initializes this color from the data archived in a coder. + @param aCoder the coder from which the color will be loaded +*/ - (id)initWithCoder:(CPCoder)aCoder { if ([aCoder containsValueForKey:CPColorPatternImageKey]) @@ -336,6 +492,10 @@ var CPColorComponentsKey = @"CPColorComponentsKey", return [self _initWithRGBA:[aCoder decodeObjectForKey:CPColorComponentsKey]]; } +/* + Archives this color into a coder. + @param aCoder the coder into which the color will be archived. +*/ - (void)encodeWithCoder:(CPCoder)aCoder { if (_patternImage) @@ -348,6 +508,12 @@ var CPColorComponentsKey = @"CPColorComponentsKey", var hexCharacters = "0123456789ABCDEF"; +/* + Used for the
colorWithHexString:
implementation
+ @ignore
+ @class CPColor
+ @return an array of rgb components
+*/
function hexToRGB(hex)
{
if(hex.length != 6)
diff --git a/AppKit/CPColorPanel.j b/AppKit/CPColorPanel.j
index 7d088aa959..ba02ce05b5 100644
--- a/AppKit/CPColorPanel.j
+++ b/AppKit/CPColorPanel.j
@@ -37,13 +37,33 @@ var PREVIEW_HEIGHT = 20.0,
var SharedColorPanel = nil;
-CPWheelColorPickerMode = 1,
-CPKulerColorPickerMode = 2,
+/*
+ A color wheel
+ @global
+ @group CPColorPanelMode
+*/
+CPWheelColorPickerMode = 1;
+/*
+ Kuler color picker
+ @global
+ @group CPColorPanelMode
+*/
+CPKulerColorPickerMode = 2;
+/*
+ Slider based picker
+ @global
+ @group CPColorPanelMode
+*/
CPSliderColorPickerMode = 3;
CPColorPickerViewWidth = 265,
CPColorPickerViewHeight = 370;
+/*
+ sharedColorPanel
method.
+*/
@implementation CPColorPanel : CPPanel
{
_CPColorPanelToolbar _toolbar;
@@ -68,6 +88,9 @@ CPColorPickerViewHeight = 370;
int _mode;
}
+/*
+ Returns (and if necessary, creates) the shared color panel.
+*/
+ (CPColorPanel)sharedColorPanel
{
if (!SharedColorPanel)
@@ -76,12 +99,20 @@ CPColorPickerViewHeight = 370;
return SharedColorPanel;
}
-+ (void)setPickerMode:(int)mode
+/*
+ Returns the shared color panel set to display in mode
.
+ @param mode the mode to which the color panel will be set before returning
+*/
++ (void)setPickerMode:(CPColorPanelMode)mode
{
var panel = [CPColorPanel sharedColorPanel];
[panel setMode: mode];
}
+/*
+ To obtain the color panel, use sharedColorPanel
.
+ @ignore
+*/
- (id)init
{
self = [super initWithContentRect:CGRectMake(500.0, 50.0, 218.0, 360.0)
@@ -101,6 +132,9 @@ CPColorPickerViewHeight = 370;
return self;
}
+/*
+ Sets the color of the panel, and updates the picker. Also posts a CPColorPanelDidChangeNotification
.
+*/
- (void)setColor:(CPColor)aColor
{
_color = aColor;
@@ -116,6 +150,11 @@ CPColorPickerViewHeight = 370;
object:self];
}
+/*
+ Sets the selected color of the panel and optionally updates the picker.
+ @param bool whether or not to update the picker
+ @ignore
+*/
-(void)setColor:(CPColor)aColor updatePicker:(BOOL)bool
{
[self setColor: aColor];
@@ -125,32 +164,55 @@ CPColorPickerViewHeight = 370;
}
+/*
+ Returns the panel's currently selected color.
+*/
- (CPColor)color
{
return _color;
}
+/*
+ Sets the target for the color panel. Messages are sent
+ to the target when colors are selected in the panel.
+*/
- (void)setTarget:(id)aTarget
{
_target = aTarget;
}
+/*
+ Returns the current target. The target receives messages
+ when colors are selected in the panel.
+*/
- (id)target
{
return _target;
}
+/*
+ Sets the action that gets sent to the target.
+ This action is sent whenever a color is selected in the panel.
+ @param anAction the action that will be sent
+*/
- (void)setAction:(selector)anAction
{
_action = anAction;
}
+/*
+ Returns the current target action.
+*/
- (selector)action
{
return _action;
}
-- (void)setMode:(int)mode
+/*
+ Sets the mode (look) of the color panel.
+ @param mode the mode in which to display the color panel
+*/
+- (void)setMode:(CPColorPanelMode)mode
{
if(mode == _mode)
return;
@@ -175,7 +237,10 @@ CPColorPickerViewHeight = 370;
[[self contentView] addSubview: _currentView];
}
-- (int)mode
+/*
+ Returns the color panel's current display mode.
+*/
+- (CPColorPanelMode)mode
{
return _mode;
}
@@ -187,6 +252,7 @@ CPColorPickerViewHeight = 370;
[super orderFront:aSender];
}
+/* @ignore */
- (void)_loadContentsIfNecessary
{
if (_toolbar)
@@ -269,6 +335,7 @@ CPColorPickerViewHeight = 370;
var iconSize = 32,
totalIcons = 3;
+/* @ignore */
@implementation _CPColorPanelToolbar : CPView
{
CPImage _wheelImage;
@@ -366,6 +433,7 @@ var iconSize = 32,
CPColorDragType = "CPColorDragType";
var CPColorPanelSwatchesCookie = "CPColorPanelSwatchesCookie";
+/* @ignore */
@implementation _CPColorPanelSwatches : CPView
{
CPView[] _swatches;
@@ -539,6 +607,7 @@ var CPColorPanelSwatchesCookie = "CPColorPanelSwatchesCookie";
@end
+/* @ignore */
@implementation _CPColorPanelPreview : CPView
{
CPColorPanel _colorPanel;
diff --git a/AppKit/CPColorPicker.j b/AppKit/CPColorPicker.j
index 343df45c9e..fdfcba7919 100644
--- a/AppKit/CPColorPicker.j
+++ b/AppKit/CPColorPicker.j
@@ -25,13 +25,20 @@ import setPickerMode:
method. The simplest way to implement your own color picker is to create a subclass of CPColorPicker.
+*/
@implementation CPColorPicker : CPObject
{
CPColorPanel _panel;
int _mask;
}
+/*
+ Initializes the color picker.
+ @param aMask a unique unsigned int identifying your color picker
+ @param aPanel the color panel that owns this picker
+*/
- (id)initWithPickerMask:(int)aMask colorPanel:(CPColorPanel)aPanel
{
self = [super init];
@@ -42,21 +49,37 @@ import nil
+ @ignore
+*/
- (CPImage)provideNewButtonImage
{
return nil;
}
-- (void)setMode:(int)mode
+/*
+ Sets the color picker's mode.
+ @param mode the color panel mode
+*/
+- (void)setMode:(CPColorPanelMode)mode
{
return;
}
+/*
+ Sets the picker's color.
+ @param aColor the new color for the picker
+*/
- (void)setColor:(CPColor)aColor
{
return;
@@ -64,6 +87,10 @@ import An application can have one or more active activate:
method with NO
as its argument. When a mouse-down event occurs on an aSender
.
+ @param aSender the object from which to retrieve the color
+*/
- (void)takeColorFrom:(id)aSender
{
[self setColor:[aSender color]];
}
// Activating and Deactivating Color Wells
-
+/*
+ Activates the color well, displays the color panel, and makes the panel's current color the same as its own.
+ If exclusive is YES
, deactivates any other NO
, keeps them active.
+ @param shouldBeExclusive whether other color wells should be deactivated.
+*/
- (void)activate:(BOOL)shouldBeExclusive
{
if (shouldBeExclusive)
@@ -113,6 +132,9 @@ var _CPColorWellDidBecomeExclusiveNotification = @"_CPColorWellDidBecomeExclusiv
object:[CPColorPanel sharedColorPanel]];
}
+/*
+ Deactivates the color well.
+*/
- (void)deactivate
{
if (![self isActive])
@@ -126,6 +148,9 @@ var _CPColorWellDidBecomeExclusiveNotification = @"_CPColorWellDidBecomeExclusiv
object:[CPColorPanel sharedColorPanel]];
}
+/*
+ Returns YES
if the color well is active.
+*/
- (BOOL)isActive
{
return _active;
@@ -137,6 +162,10 @@ var _CPColorWellDidBecomeExclusiveNotification = @"_CPColorWellDidBecomeExclusiv
{
}
+/*
+ Draws the colored area inside the color well without borders.
+ @param aRect the location at which to draw
+*/
- (void)drawWellInside:(CGRect)aRect
{
if (!_wellView)
diff --git a/AppKit/CPControl.j b/AppKit/CPControl.j
index 29b87774ac..d76594e3bc 100644
--- a/AppKit/CPControl.j
+++ b/AppKit/CPControl.j
@@ -26,15 +26,46 @@ import "CPView.j"
#include "Platform/Platform.h"
-
+/*
+ @global
+ @group CPTextAlignment
+*/
CPLeftTextAlignment = 0;
+/*
+ @global
+ @group CPTextAlignment
+*/
CPRightTextAlignment = 1;
+/*
+ @global
+ @group CPTextAlignment
+*/
CPCenterTextAlignment = 2;
+/*
+ @global
+ @group CPTextAlignment
+*/
CPJustifiedTextAlignment = 3;
+/*
+ @global
+ @group CPTextAlignment
+*/
CPNaturalTextAlignment = 4;
+/*
+ @global
+ @group CPControlSize
+*/
CPRegularControlSize = 0;
+/*
+ @global
+ @group CPControlSize
+*/
CPSmallControlSize = 1;
+/*
+ @global
+ @group CPControlSize
+*/
CPMiniControlSize = 2;
CPControlNormalBackgroundColor = @"CPControlNormalBackgroundColor";
@@ -44,6 +75,9 @@ CPControlDisabledBackgroundColor = @"CPControlDisabledBackgroundColor";
var CPControlBlackColor = [CPColor blackColor];
+/*
+ YES
if the receiver responds to mouse events.
+*/
- (BOOL)isEnabled
{
return _isEnabled;
}
+
+/*
+ Sets the color of the receiver's text.
+*/
- (void)setTextColor:(CPColor)aColor
{
if (_textColor == aColor)
@@ -106,21 +151,35 @@ var CPControlBlackColor = [CPColor blackColor];
#endif
}
+/*
+ Returns the color of the receiver's text
+*/
- (CPColor)textColor
{
return _textColor;
}
-- (int)alignment
+/*
+ Returns the receiver's alignment
+*/
+- (CPTextAlignment)alignment
{
return _alignment;
}
-- (void)setAlignment:(int)anAlignment
+/*
+ Sets the receiver's alignment
+ @param anAlignment the receiver's alignment
+*/
+- (void)setAlignment:(CPTextAlignment)anAlignment
{
_alignment = anAlignment;
}
+/*
+ Sets the receiver's font
+ @param aFont the font for the receiver
+*/
- (void)setFont:(CPFont)aFont
{
if (_font == aFont)
@@ -133,36 +192,60 @@ var CPControlBlackColor = [CPColor blackColor];
#endif
}
+/*
+ Returns the receiver's font
+*/
- (CPFont)font
{
return _font;
}
+/*
+ Sets the shadow for the receiver's text.
+ @param aTextShadow the text shadow
+*/
- (void)setTextShadow:(CPShadow)aTextShadow
{
_DOMElement.style.textShadow = [_textShadow = aTextShadow cssString];
}
+/*
+ Returns the receiver's text shadow
+*/
- (CPShadow)textShadow
{
return _textShadow;
}
+/*
+ Returns the receiver's target action
+*/
- (SEL)action
{
return _action;
}
+/*
+ Sets the receiver's target action
+ @param anAction Sets the action message that gets sent to the target.
+*/
- (void)setAction:(SEL)anAction
{
_action = anAction;
}
+/*
+ Returns the receiver's target. The target receives action messages from the receiver.
+*/
- (id)target
{
return _target;
}
+/*
+ Sets the receiver's target. The target receives action messages from the receiver.
+ @param aTarget the object that will receive the message specified by action
+*/
- (void)setTarget:(id)aTarget
{
_target = aTarget;
@@ -176,16 +259,27 @@ var CPControlBlackColor = [CPColor blackColor];
[super mouseUp:anEvent];
}
+/*
+ Causes anAction
to be sent to anObject
.
+ @param anAction the action to send
+ @param anObject the object to which the action will be sent
+*/
- (void)sendAction:(SEL)anAction to:(id)anObject
{
[CPApp sendAction:anAction to:anObject from:self];
}
+/*
+ Returns the receiver's float value
+*/
- (float)floatValue
{
- return _value ? parseFloat(_value) : 0.0;
+ return _value ? parseFloat(_value, 10) : 0.0;
}
+/*
+ Sets the receiver's float value
+*/
- (void)setFloatValue:(float)aValue
{
_value = aValue;
@@ -239,7 +333,8 @@ var CPControlBlackColor = [CPColor blackColor];
Ð setStringValue:
Ð setNeedsDisplay
Ð attributedStringValue
-Ð setAttributedStringValue: */
+Ð setAttributedStringValue:
+*/
@end
@@ -253,6 +348,11 @@ var CPControlIsEnabledKey = @"CPControlIsEnabledKey",
@implementation CPControl (CPCoding)
+/*
+ Initializes the control by unarchiving it from a coder.
+ @param aCoder the coder from which to unarchive the control
+ @return the initialized control
+*/
- (id)initWithCoder:(CPCoder)aCoder
{
self = [super initWithCoder:aCoder];
@@ -274,6 +374,10 @@ var CPControlIsEnabledKey = @"CPControlIsEnabledKey",
return self;
}
+/*
+ Archives the control to the provided coder.
+ @param aCoder the coder to which the control will be archived.
+*/
- (void)encodeWithCoder:(CPCoder)aCoder
{
[super encodeWithCoder:aCoder];
diff --git a/AppKit/CPCookie.j b/AppKit/CPCookie.j
index 33adb1fcf4..7479d711e3 100644
--- a/AppKit/CPCookie.j
+++ b/AppKit/CPCookie.j
@@ -24,6 +24,9 @@ import aName
.
+ @param the name for the cookie
+*/
- (id)initWithName:(CPString)aName
{
self = [super init];
@@ -42,21 +49,36 @@ import aDelegate
+ @param aContextInfo passed as the argument to the message sent to the aDelegate
+ @return the initialized document
+*/
- (id)initForURL:(CPURL)anAbsoluteURL withContentsOfURL:(CPURL)absoluteContentsURL ofType:(CPString)aType delegate:(id)aDelegate didReadSelector:(SEL)aDidReadSelector contextInfo:(id)aContextInfo
{
self = [self init];
@@ -117,18 +189,39 @@ var CPDocumentUntitledCount = 0;
return self;
}
+/*
+ Returns the receiver's data in a specified type. The default implementation just
+ throws an exception.
+ @param aType the format of the data
+ @param anError not used
+ @throws CPUnsupportedMethodException if this method hasn't been overriden by the subclass
+ @return the document data
+*/
- (CPData)dataOfType:(CPString)aType error:({CPError})anError
{
- // FIXME: Throw Exception.
- return nil;
+ [CPException raise:CPUnsupportedMethodException
+ reason:"This method must be overridden by the document"];
}
+/*
+ Sets the content of the document by reading the provided
+ data. The default implementation just throws an exception.
+ @param aData the document's data
+ @param aType the document type
+ @param anError not used
+ @throws CPUnsupportedMethodException if this method hasn't been
+ overridden by the subclass
+*/
- (void)readFromData:(CPData)aData ofType:(CPString)aType error:(CPError)anError
{
+ [CPException raise:CPUnsupportedMethodException
+ reason:"This method must be overridden by the document"];
}
// Creating and managing window controllers
-
+/*
+ Creates the window controller for this document.
+*/
- (void)makeWindowControllers
{
var controller = [[CPWindowController alloc] initWithWindowCibName:nil];
@@ -136,11 +229,19 @@ var CPDocumentUntitledCount = 0;
[self addWindowController:controller];
}
+/*
+ Returns the document's window controllers
+*/
- (CPArray)windowControllers
{
return _windowControllers;
}
+/*
+ Add a controller to the document's list of controllers. This should
+ be called after making a new window controller.
+ @param aWindowController the controller to add
+*/
- (void)addWindowController:(CPWindowController)aWindowController
{
[_windowControllers addObject:aWindowController];
@@ -153,12 +254,17 @@ var CPDocumentUntitledCount = 0;
}
// Managing Document Windows
-
+/*
+ Shows all the document's windows.
+*/
- (void)showWindows
{
[_windowControllers makeObjectsPerformSelector:@selector(showWindow:) withObject:self];
}
+/*
+ Returns the name of the document as displayed in the title bar.
+*/
- (CPString)displayName
{
// FIXME: By default, return last path component of fileURL
@@ -171,21 +277,39 @@ var CPDocumentUntitledCount = 0;
return @"Untitled " + _untitledDocumentIndex;
}
+/*
+ Returns the document's Cib name
+*/
- (CPString)windowCibName
{
return nil;
}
+/*
+ Called after aWindowController
loads the document's Nib file.
+ @param aWindowController the controller that loaded the Nib file
+*/
- (void)windowControllerDidLoadNib:(CPWindowController)aWindowController
{
}
+/*
+ Called before
aWindowController
will load the document's Nib file.
+ @param aWindowController the controller that will load the Nib file
+*/
- (void)windowControllerWillLoadNib:(CPWindowController)aWindowController
{
}
// Reading from and Writing to URLs
-
+/*
+ Set the document's data from a URL. Notifies the provided delegate afterwards.
+ @param anAbsoluteURL the URL to the document's content
+ @param aType the document type
+ @param aDelegate delegate to notify after reading the data
+ @param aDidReadSelector message that will be sent to the delegate
+ @param aContextInfo context information that gets sent to the delegate
+*/
- (void)readFromURL:(CPURL)anAbsoluteURL ofType:(CPString)aType delegate:(id)aDelegate didReadSelector:(SEL)aDidReadSelector contextInfo:(id)aContextInfo
{
[_readConnection cancel];
@@ -196,11 +320,18 @@ var CPDocumentUntitledCount = 0;
_readConnection.session = _CPReadSessionMake(aType, aDelegate, aDidReadSelector, aContextInfo);
}
+/*
+ Returns the path to the document's file.
+*/
- (CPURL)fileURL
{
return _fileURL;
}
+/*
+ Sets the path to the document's file.
+ @param aFileURL the path to the document's file
+*/
- (void)setFileURL:(CPURL)aFileURL
{
if (_fileURL == aFileURL)
@@ -211,6 +342,16 @@ var CPDocumentUntitledCount = 0;
[_windowControllers makeObjectsPerformSelector:@selector(synchronizeWindowTitleWithDocumentName)];
}
+/*
+ Saves the document to the specified URL. Notifies the provided delegate
+ with the provided selector and context info afterwards.
+ @param anAbsoluteURL the url to write the document data to
+ @param aTypeName the document type
+ @param aSaveOperation the type of save operation
+ @param aDelegate the delegate to notify after saving
+ @param aDidSaveSelector the selector to send the delegate
+ @param aContextInfo context info that gets passed to the delegate
+*/
- (void)saveToURL:(CPURL)anAbsoluteURL ofType:(CPString)aTypeName forSaveOperation:(CPSaveOperationType)aSaveOperation delegate:(id)aDelegate didSaveSelector:(SEL)aDidSaveSelector contextInfo:(id)aContextInfo
{
var data = [self dataOfType:[self fileType] error:nil],
@@ -235,6 +376,10 @@ var CPDocumentUntitledCount = 0;
connection.session = _CPSaveSessionMake(anAbsoluteURL, aSaveOperation, oldChangeCount, aDelegate, aDidSaveSelector, aContextInfo, connection);
}
+/*
+ Implemented as a delegate method for CPURLConnection
+ @ignore
+*/
- (void)connection:(CPURLConnection)aConnection didReceiveResponse:(CPURLResponse)aResponse
{
var statusCode = [aResponse statusCode];
@@ -282,6 +427,10 @@ var CPDocumentUntitledCount = 0;
}
}
+/*
+ Implemented as a delegate method for CPURLConnection
+ @ignore
+*/
- (void)connection:(CPURLConnection)aConnection didReceiveData:(CPString)aData
{
var session = aConnection.session;
@@ -304,6 +453,10 @@ var CPDocumentUntitledCount = 0;
}
}
+/*
+ Implemented as a delegate method for CPURLConnection
+ @ignore
+*/
- (void)connection:(CPURLConnection)aConnection didFailWithError:(CPError)anError
{
var session = aConnection.session;
@@ -327,6 +480,10 @@ var CPDocumentUntitledCount = 0;
}
}
+/*
+ Implemented as a delegate method for CPURLConnection
+ @ignore
+*/
- (void)connectionDidFinishLoading:(CPURLConnection)aConnection
{
if (_readConnection == aConnection)
@@ -334,12 +491,18 @@ var CPDocumentUntitledCount = 0;
}
// Managing Document Status
-
+/*
+ Returns YES
if there are any unsaved changes.
+*/
- (BOOL)isDocumentEdited
{
return _changeCount != 0;
}
+/*
+ Updates the number of unsaved changes to the document.
+ @param aChangeType a new document change to apply
+*/
- (void)updateChangeCount:(CPDocumentChangeType)aChangeType
{
if (aChangeType == CPChangeDone)
@@ -356,25 +519,38 @@ var CPDocumentUntitledCount = 0;
}
// Managing File Types
-
+/*
+ Sets the document's file type
+ @param aType the document's type
+*/
- (void)setFileType:(CPString)aType
{
_fileType = aType;
}
+/*
+ Returns the document's file type
+*/
- (CPString)fileType
{
return _fileType;
}
// Working with Undo Manager
-
+/*
+ Returns YES
if the document has a
+ YES
makes the document have an undo manager
+*/
+- (void)setHasUndoManager:(BOOL)aFlag
{
if (_hasUndoManager == aFlag)
return;
@@ -385,6 +561,7 @@ var CPDocumentUntitledCount = 0;
[self setUndoManager:nil];
}
+/* @ignore */
- (void)_undoManagerWillCloseGroup:(CPNotification)aNotification
{
var undoManager = [aNotification object];
@@ -395,16 +572,23 @@ var CPDocumentUntitledCount = 0;
[self updateChangeCount:CPChangeDone];
}
+/* @ignore */
- (void)_undoManagerDidUndoChange:(CPNotification)aNotification
{
[self updateChangeCount:CPChangeUndone];
}
+/* @ignore */
- (void)_undoManagerDidRedoChange:(CPNotification)aNotification
{
[self updateChangeCount:CPChangeDone];
}
+/*
+ Sets the document's undo manager. This method will add the
+ undo manager as an observer to the notification center.
+ @param anUndoManager the new undo manager for the document
+*/
- (void)setUndoManager:(CPUndoManager)anUndoManager
{
var defaultCenter = [CPNotificationCenter defaultCenter];
@@ -446,6 +630,12 @@ var CPDocumentUntitledCount = 0;
}
}
+/*
+ Returns the document's undo manager. If the document
+ should have one, but the manager is nil
, it
+ will be created and then returned.
+ @return the document's undo manager
+*/
- (CPUndoManager)undoManager
{
if (_hasUndoManager && !_undoManager)
@@ -453,14 +643,23 @@ var CPDocumentUntitledCount = 0;
return _undoManager;
}
-
+
+/*
+ Implemented as a delegate of a fileURL
)
+ then saveDocumentAs:
will be called.
+ @param aSender the object requesting the save
+*/
- (void)saveDocument:(id)aSender
{
if (_fileURL)
@@ -475,6 +674,10 @@ var CPDocumentUntitledCount = 0;
[self saveDocumentAs:self];
}
+/*
+ Saves the document to a user specified path.
+ @param aSender the object requesting the operation
+*/
- (void)saveDocumentAs:(id)aSender
{
_documentName = window.prompt("Document Name:");
@@ -489,6 +692,9 @@ var CPDocumentUntitledCount = 0;
[self saveToURL:[self proposedFileURL] ofType:[self fileType] forSaveOperation:CPSaveAsOperation delegate:self didSaveSelector:@selector(document:didSave:contextInfo:) contextInfo:NULL];
}
+/*
+ @ignore
+*/
- (void)document:(id)aDocument didSave:(BOOL)didSave contextInfo:(id)aContextInfo
{
if (didSave)
diff --git a/AppKit/CPDocumentController.j b/AppKit/CPDocumentController.j
index 0445f96ca6..84fbd9d7a9 100644
--- a/AppKit/CPDocumentController.j
+++ b/AppKit/CPDocumentController.j
@@ -27,12 +27,20 @@ import "CPDocument.j"
var CPSharedDocumentController = nil;
+/*
+ This class is responsible for managing an application's open documents.
+*/
@implementation CPDocumentController : CPObject
{
CPArray _documents;
CPArray _documentTypes;
}
+/*
+ Returns the singleton instance of the application's document controller. If it has not
+ been created yet, it will be created then returned.
+ @return a nil
if such a document is not open
+*/
- (CPDocument)documentForURL:(CPURL)aURL
{
var index = 0,
@@ -75,6 +93,11 @@ var CPSharedDocumentController = nil;
return nil;
}
+/*
+ Creates a new document of the specified type.
+ @param aType the type of the new document
+ @param shouldDisplay whether to display the document on screen
+*/
- (void)openUntitledDocumentOfType:(CPString)aType display:(BOOL)shouldDisplay
{
var document = [self makeUntitledDocumentOfType:aType error:nil];
@@ -91,11 +114,24 @@ var CPSharedDocumentController = nil;
return document;
}
+/*
+ Creates a document of the specified type.
+ @param aType the document type
+ @param anError not used
+ @return the created document
+*/
- (CPDocument)makeUntitledDocumentOfType:(CPString)aType error:({CPError})anError
{
return [[[self documentClassForType:aType] alloc] initWithType:aType error:anError];
}
+/*
+ Opens the document at the specified URL.
+ @param anAbsoluteURL the path to the document's file
+ @param shouldDisplay whether to display the document on screen
+ @param anError not used
+ @return the opened document
+*/
- (CPDocument)openDocumentWithContentsOfURL:(CPURL)anAbsoluteURL display:(BOOL)shouldDisplay error:(CPError)anError
{
var result = [self documentForURL:anAbsoluteURL];
@@ -110,21 +146,53 @@ var CPSharedDocumentController = nil;
return result;
}
+/*
+ Loads a document for a specified URL with it's content
+ retrieved from another URL.
+ @param anAbsoluteURL the document URL
+ @param absoluteContentsURL the location of the document's contents
+ @param anError not used
+ @return the loaded document or nil
if there was an error
+*/
- (CPDocument)reopenDocumentForURL:(CPURL)anAbsoluteURL withContentsOfURL:(CPURL)absoluteContentsURL error:(CPError)anError
{
return [self makeDocumentForURL:anAbsoluteURL withContentsOfURL:absoluteContentsURL ofType:[[_documentTypes objectAtIndex:0] objectForKey:@"CPBundleTypeName"] delegate:self didReadSelector:@selector(document:didRead:contextInfo:) contextInfo:nil];
}
+/*
+ Creates a document from the contents at the specified URL.
+ Notifies the provided delegate with the provided selector afterwards.
+ @param anAbsoluteURL the location of the document data
+ @param aType the document type
+ @param aDelegate the delegate to notify
+ @param aSelector the selector to notify with
+ @param aContextInfo the context infomration passed to the delegate
+*/
- (CPDocument)makeDocumentWithContentsOfURL:(CPURL)anAbsoluteURL ofType:(CPString)aType delegate:(id)aDelegate didReadSelector:(SEL)aSelector contextInfo:(id)aContextInfo
{
return [[[self documentClassForType:aType] alloc] initWithContentsOfURL:anAbsoluteURL ofType:aType delegate:aDelegate didReadSelector:aSelector contextInfo:aContextInfo];
}
+/*
+ Creates a document from the contents of a URL, and sets
+ the document's URL location as another URL.
+ @param anAbsoluteURL the document's location
+ @param absoluteContentsURL the location of the document's contents
+ @param aType the document's data type
+ @param aDelegate receives a callback after the load has completed
+ @param aSelector the selector to invoke for the callback
+ @param aContextInfo an object passed as an argument for the callback
+ @return a new document or nil
if there was an error
+*/
- (CPDocument)makeDocumentForURL:(CPURL)anAbsoluteURL withContentsOfURL:(CPURL)absoluteContentsURL ofType:(CPString)aType delegate:(id)aDelegate didReadSelector:(SEL)aSelector contextInfo:(id)aContextInfo
{
return [[[self documentClassForType:aType] alloc] initForURL:anAbsoluteURL withContentsOfURL:absoluteContentsURL ofType:aType delegate:aDelegate didReadSelector:aSelector contextInfo:aContextInfo];
}
+/*
+ Implemented delegate method
+ @ignore
+*/
- (void)document:(CPDocument)aDocument didRead:(BOOL)didRead contextInfo:(id)aContextInfo
{
if (!didRead)
@@ -134,6 +202,10 @@ var CPSharedDocumentController = nil;
[aDocument makeWindowControllers];
}
+/*
+ Opens a new document in the application.
+ @param aSender the requesting object
+*/
- (CFAction)newDocument:(id)aSender
{
[self openUntitledDocumentOfType:[[_documentTypes objectAtIndex:0] objectForKey:@"CPBundleTypeName"] display:YES];
@@ -141,16 +213,28 @@ var CPSharedDocumentController = nil;
// Managing Documents
+/*
+ Returns the array of all documents being managed. This is
+ the same as all open documents in the application.
+*/
- (CPArray)documents
{
return _documents;
}
+/*
+ Adds aDocument
under the control of the receiver.
+ @param aDocument the document to add
+*/
- (void)addDocument:(CPDocument)aDocument
{
[_documents addObject:aDocument];
}
+/*
+ Removes aDocument
from the control of the receiver.
+ @param aDocument the document to remove
+*/
- (void)removeDocument:(CPDocument)aDocument
{
[_documents removeObjectIdenticalTo:aDocument];
@@ -158,6 +242,7 @@ var CPSharedDocumentController = nil;
// Managing Document Types
+/* @ignore */
- (CPDictionary)_infoForType:(CPString)aType
{
var i = 0,
@@ -174,11 +259,16 @@ var CPSharedDocumentController = nil;
return nil;
}
+/*
+ Returns the aType
.
+ @param aType the type of document
+ @return a Cappuccino Class object, or nil
if no match was found
+*/
- (Class)documentClassForType:(CPString)aType
{
var className = [[self _infoForType:aType] objectForKey:@"CPDocumentClass"];
- return className ? CPClassFromString(className) : Nil;
+ return className ? CPClassFromString(className) : nil;
}
@end
diff --git a/AppKit/CPDragServer.j b/AppKit/CPDragServer.j
index f9a0ca12b8..e1ce104542 100644
--- a/AppKit/CPDragServer.j
+++ b/AppKit/CPDragServer.j
@@ -114,11 +114,18 @@ var CPDragServerUpdateDragging = function(anEvent)
[CPDragServerSource draggedView:CPDragServerView movedTo:location];
}
+/*
+ YES
, aView
slides back to
+ its origin on a failed drop
+*/
+- (void)dragView:(CPView)aView fromWindow:(CPWindow)aWindow at:(CGPoint)viewLocation offset:(CGSize)mouseOffset event:(CPEvent)anEvent pasteboard:(CPPasteboard)aPasteboard source:(id)aSourceObject slideBack:(BOOL)slideBack
{
var eventLocation = [anEvent locationInWindow];
@@ -224,7 +250,19 @@ var CPDragServerUpdateDragging = function(anEvent)
CPDragServerStartDragging(anEvent);
}
-- (void)dragImage:(CPImage)anImage fromWindow:(CPWindow)aWindow at:(CPPoint)imageLocation offset:(CPSize)mouseOffset event:(CPEvent)anEvent pasteboard:(CPPasteboard)aPasteboard source:(id)aSourceObject slideBack:(BOOL)slideBack
+/*
+ Initiates a drag session.
+ @param anImage the image to be dragged
+ @param aWindow the source window of the drag session
+ @param imageLocation
+ @param mouseOffset
+ @param anEvent
+ @param aPasteboard the pasteboard where the drag data is located
+ @param aSourceObject the object where the drag started
+ @param slideBack if YES
, aView
slides back to
+ its origin on a failed drop
+*/
+- (void)dragImage:(CPImage)anImage fromWindow:(CPWindow)aWindow at:(CGPoint)imageLocation offset:(CGSize)mouseOffset event:(CPEvent)anEvent pasteboard:(CPPasteboard)aPasteboard source:(id)aSourceObject slideBack:(BOOL)slideBack
{
CPDragServerIsDraggingImage = YES;
@@ -241,6 +279,7 @@ var CPDragServerUpdateDragging = function(anEvent)
@implementation CPView (CPDraggingAdditions)
+/* @ignore */
- (CPView)_dragHitTest:(CPPoint)aPoint pasteboard:(CPPasteboard)aPasteboard
{
if(!CPRectContainsPoint(_frame, aPoint) || self == CPDragServerView)
diff --git a/AppKit/CPEvent.j b/AppKit/CPEvent.j
index 56d5469cc3..8786c9fc0d 100644
--- a/AppKit/CPEvent.j
+++ b/AppKit/CPEvent.j
@@ -24,27 +24,110 @@ import aWindowNumber
+ @param modifierFlags a bitwise combination of the modifiers specified in the YES
if this is caused by the system repeat as opposed to the user pressing the key again
+ @param code a number associated with the keyboard key of this event
+ @throws CPInternalInconsistencyException if anEventType
is not a aWindowNumber
+ @param modifierFlags a bitwise combination of the modifiers specified in the aWindowNumber
+ @param modifierFlags a bitwise combination of the modifiers specified in the nil
.
+ If window
returns nil
, then
+ the mouse coordinates will be based on the screen coordinates.
+ Otherwise, the coordinates are relative to the window's coordinates.
+ @return the location of the mouse, or nil
for non-mouse events.
+*/
+- (CGPoint)locationInWindow
{
return _location;
}
+/*
+ Returns event information as a bit mask
+*/
- (unsigned)modifierFlags
{
return _modifierFlags;
}
+/*
+ Returns the time the event occurred
+*/
- (CPTimeInterval)timestamp
{
return _timestamp;
}
+/*
+ Returns the type of event.
+*/
- (CPEventType)type
{
return _type;
}
+/*
+ Returns the event's associated window
+*/
- (CPWindow)window
{
return _window;
}
+/*
+ The number of the window associated with the event.
+*/
- (int)windowNumber
{
return _windowNumber;
}
// Mouse Event Information
-
+/*
+ Returns the button number for the mouse that generated the event.
+*/
- (int)buttonNumber
{
return _buttonNumber;
}
+/*
+ Returns the number of clicks that caused this event. (mouse only)
+*/
- (int)clickCount
{
return _clickCount;
}
+/*
+ Returns the characters associated with this event (keyboard only)
+ @throws CPInternalInconsistencyException if this method is called on a non-key event
+*/
- (CPString)characters
{
return _characters;
}
+/*
+ Returns the character ignoring any modifiers (except shift).
+ @throws CPInternalInconsistencyException if this method is called on a non-key event
+*/
- (CPString)charactersIgnoringModifiers
{
return _charactersIgnoringModifiers;
}
+/*
+ Returns YES
if the keyboard event was caused by the key being held down.
+ @throws CPInternalInconsistencyException if this method is called on a non-key event
+*/
- (BOOL)isARepeat
{
return _isARepeat;
}
+/*
+ Returns the key's key code.
+ @throws CPInternalInconsistencyException if this method is called on a non-key event
+*/
- (unsigned short)keyCode
{
return _keyCode;
@@ -275,28 +452,44 @@ var _CPEventPeriodicEventPeriod = 0,
return _pressure;
}
+/*
+ @ignore
+*/
- (DOMEvent)_DOMEvent
{
return _DOMEvent;
}
// Getting Scroll Wheel Event Infomration
-
+/*
+ Returns the change in the x-axis for a mouse event.
+*/
- (float)deltaX
{
return _deltaX;
}
+/*
+ Returns the change in the y-axis for a mouse event.
+*/
- (float)deltaY
{
return _deltaY;
}
+/*
+ Returns the change in the x-axis for a mouse event.
+*/
- (float)deltaZ
{
return _deltaZ;
}
+/*
+ Generates periodic events every aPeriod
seconds.
+ @param aDelay the number of seconds before the first event
+ @param aPeriod the length of time in seconds between successive events
+*/
+ (void)startPeriodicEventsAfterDelay:(CPTimeInterval)aDelay withPeriod:(CPTimeInterval)aPeriod
{
_CPEventPeriodicEventPeriod = aPeriod;
@@ -305,6 +498,9 @@ var _CPEventPeriodicEventPeriod = 0,
_CPEventPeriodicEventTimer = window.setTimeout(function() { _CPEventPeriodicEventTimer = window.setInterval(_CPEventFirePeriodEvent, aPeriod * 1000.0); }, aDelay * 1000.0);
}
+/*
+ Stops the periodic events from being generated
+*/
+ (void)stopPeriodicEvents
{
if (_CPEventPeriodicEventTimer === nil)
diff --git a/AppKit/CPFont.j b/AppKit/CPFont.j
index fa247d67cb..f5379ee73a 100644
--- a/AppKit/CPFont.j
+++ b/AppKit/CPFont.j
@@ -25,6 +25,9 @@ var _CPFonts = {};
#define _CPCachedFont(aName, aSize, isBold) _CPFonts[(isBold ? @"bold " : @"") + ROUND(aSize) + @"px '" + aName + @"'"]
+/*
+ The aRect
less the dX/dY
insets specified.
+ @param dX the size of the inset in the x-axis
+ @param dY the size of the inset in the y-axis
+ @group CGRect
+ @return CGRect a rectangle like aRect
with an inset
+*/
function CPRectInset(aRect, dX, dY)
{
return CPRectMake( aRect.origin.x + dX, aRect.origin.y + dY,
aRect.size.width - 2 * dX, aRect.size.height - 2*dY);
}
+/*
+ @group CGRect
+ @ignore
+ @return void
+ @deprecated
+*/
function CPRectIntegral(aRect)
{
// FIXME!!!
alert("CPRectIntegral unimplemented");
}
+/*
+ Returns the intersection of the two provided rectangles as a new rectangle
+ @group CGRect
+ @param lhsRect the first rectangle used for calculation
+ @param rhsRect the second rectangle used for calculation
+ @return CGRect the intersection of the two rectangles
+*/
function CPRectIntersection(lhsRect, rhsRect)
{
var intersection = CPRectMake(
@@ -67,21 +100,49 @@ function CPRectIntersection(lhsRect, rhsRect)
return CPRectIsEmpty(intersection) ? CPRectMakeZero() : intersection;
}
+/*
+ Creates a copy of the provided rectangle
+ @group CGRect
+ @param aRect the CGRect that will be copied
+ @return CGRect the rectangle copy
+*/
function CPRectCreateCopy(aRect)
{
return { origin: CPPointCreateCopy(aRect.origin), size: CPSizeCreateCopy(aRect.size) };
}
+/*
+ Returns a CGRect made of the specified arguments
+ @group CGRect
+ @param x the x-coordinate of the rectangle's origin
+ @param y the y-coordinate of the rectangle's origin
+ @param width the width of the new rectangle
+ @param height the height of the new rectangle
+ @return CGRect the new rectangle
+*/
function CPRectMake(x, y, width, height)
{
return { origin: CPPointMake(x, y), size: CPSizeMake(width, height) };
}
+/*
+ Creates a new rectangle with its origin offset by dX
and dY
.
+ @group CGRect
+ @param aRect the rectangle to copy the origin and size from
+ @param dX the amount added to the x-size of the new rectangle
+ @param dY the amount added to the y-size of the new rectangle
+ @return CGRect the new rectangle with modified size
+*/
function CPRectOffset(aRect, dX, dY)
{
return CPRectMake(aRect.origin.x + dX, aRect.origin.y + dY, aRect.size.width, aRect.size.height);
}
+/*
+ @group CGRect
+ @param aRect a CGRect
+ @return CGRect
+*/
function CPRectStandardize(aRect)
{
var width = CPRectGetWidth(aRect),
@@ -103,6 +164,13 @@ function CPRectStandardize(aRect)
return standardized;
}
+/*
+ Returns the smallest rectangle that can contain the two argument CGRect
s.
+ @group CGRect
+ @param lhsRect the first CGRect to use for the union calculation
+ @param rhsRect the second CGRect to use for the union calculation
+ @return CGRect the union rectangle
+*/
function CPRectUnion(lhsRect, rhsRect)
{
var minX = Math.min(CPRectGetMinX(lhsRect), CPRectGetMinX(rhsRect)),
@@ -113,16 +181,37 @@ function CPRectUnion(lhsRect, rhsRect)
return CPRectMake(minX, minY, maxX - minX, maxY - minY);
}
+/*
+ Creates and returns a copy of the provided CGSize
+ @group CGSize
+ @param aSize the CGSize to copy
+ @return CGSize the copy of the CGSize
+*/
function CPSizeCreateCopy(aSize)
{
return { width: aSize.width, height: aSize.height };
}
+/*
+ Creates and returns a new CGSize object from the provided dimensions.
+ @group CGSize
+ @param width the width for the new CGSize
+ @param height the height for the new CGSize
+ @return CGSize the new CGSize
+*/
function CPSizeMake(width, height)
{
return { width: width, height: height };
}
+/*
+ Returns YES
if the aRect
, contains
+ the aPoint
.
+ @param aRect the rectangle to test with
+ @param aPoint the point to test with
+ @group CGRect
+ @return BOOL YES
if the rectangle contains the point, NO
otherwise.
+*/
function CPRectContainsPoint(aRect, aPoint)
{
return aPoint.x >= CPRectGetMinX(aRect) &&
@@ -131,97 +220,211 @@ function CPRectContainsPoint(aRect, aPoint)
aPoint.y < CPRectGetMaxY(aRect);
}
+/*
+ Returns a BOOL
indicating whether possibleOuter
+ contains possibleInner
.
+ @group CGRect
+ @param possibleOuter the possibleInner
is inside of
+ @param possibleInner the possibleOuter
.
+ @return BOOL YES
if possibleInner
fits inside possibleOuter
.
+*/
function CPRectContainsRect(lhsRect, rhsRect)
{
return CPRectEqualToRect(CPUnionRect(lhsRect, rhsRect), rhsRect);
}
+/*
+ Tests whether the two x
and y
members.
+ @group @CGPoint
+ @param lhsPoint the first YES
if the two points have the same x's, and the same y's.
+*/
function CPPointEqualToPoint(lhsPoint, rhsPoint)
{
return lhsPoint.x == rhsPoint.x && lhsPoint.y == rhsPoint.y;
}
+/*
+ Test whether the two YES
if the two rectangles have the same origin and size. NO
, otherwise.
+*/
function CPRectEqualToRect(lhsRect, rhsRect)
{
return CPPointEqualToPoint(lhsRect.origin, rhsRect.origin) &&
CPSizeEqualToSize(lhsRect.size, rhsRect.size);
}
+/*
+ @group CGRect
+ @param aRect a YES
if the two rectangles intersect
+ @group CGRect
+ @param lhsRect the first YES
if the two rectangles have any common spaces, and NO
, otherwise.
+*/
function CPRectIntersectsRect(lhsRect, rhsRect)
{
return !CPRectIsEmpty(CPRectIntersection(lhsRect, rhsRect));
}
+/*
+ Returns YES
if the YES
if the NO
, otherwise.
+*/
function CPRectIsEmpty(aRect)
{
return aRect.size.width <= 0.0 || aRect.size.height <= 0.0;
}
+/*
+ Returns YES
if the YES
if the NO
, otherwise.
+*/
function CPRectIsNull(aRect)
{
return aRect.size.width <= 0.0 || aRect.size.height <= 0.0;
}
+/*
+ Returns YES
if the two YES
if the two sizes are identical. NO
, otherwise.
+*/
function CPSizeEqualToSize(lhsSize, rhsSize)
{
return lhsSize.width == rhsSize.width && lhsSize.height == rhsSize.height;
}
+/*
+ Returns a human readable string of the provided CPStringFromRect
+ @return CGRect the rectangle created from the string
+*/
function CPRectFromString(aString)
{
var comma = aString.indexOf(',', aString.indexOf(',') + 1);
@@ -243,21 +458,41 @@ function CPRectFromString(aString)
return { origin:CPPointFromString(aString.substr(1, comma - 1)), size:CPSizeFromString(aString.substring(comma + 2, aString.length)) };
}
+/*
+ @group CGPoint
+ @param anEvent
+ @return CGPoint
+*/
function CPPointFromEvent(anEvent)
{
return CPPointMake(anEvent.clientX, anEvent.clientY, 0);
}
+/*
+ Returns a zero sized width
and height
+*/
function CPSizeMakeZero()
{
return CPSizeMake(0, 0);
}
+/*
+ Returns a rectangle at origin (0,0)
and size of (0,0)
.
+ @group CGRect
+ @return CGRect a zeroed out CGRect
+*/
function CPRectMakeZero()
{
return CPRectMake(0, 0, 0, 0);
}
+/*
+ Returns a point located at (0, 0)
.
+ @group CGPoint
+ @return CGPoint a point located at (0, 0)
+*/
function CPPointMakeZero()
{
return CPPointMake(0, 0, 0);
diff --git a/AppKit/CPGraphicsContext.j b/AppKit/CPGraphicsContext.j
index 6b4d77f1d0..7e1584cc6a 100644
--- a/AppKit/CPGraphicsContext.j
+++ b/AppKit/CPGraphicsContext.j
@@ -22,26 +22,46 @@
var CPGraphicsContextCurrent = nil;
+/*
+ Provides an interface for drawing to the screen.
+*/
@implementation CPGraphicsContext : CPObject
{
CPContext _graphicsPort;
}
-+ (void)currentContext
+/*
+ Returns the current graphics context.
+*/
++ (CPGraphicsContext)currentContext
{
return CPGraphicsContextCurrent;
}
+/*
+ Sets the current graphics context
+*/
+ (void)setCurrentContext:(CPGraphicsContext)aGraphicsContext
{
CPGraphicsContextCurrent = aGraphicsContext;
}
-+ (id)graphicsContextWithGraphicsPort:(CPContext)aContext flipped:(BOOL)aFlag
+/*
+ Creates a graphics context with a provided port.
+ @param aContext the context to initialize with
+ @param aFlag whether the context should be flipped
+ @return the initialized graphics context
+*/
++ (CPGraphicsContext)graphicsContextWithGraphicsPort:(CGContext)aContext flipped:(BOOL)aFlag
{
return [[self alloc] initWithGraphicsPort:aContext];
}
+/*
+ Initializes the context with a graphics port.
+ @param aGraphicsPort the graphics port to initialize with
+ @return the initialized context
+*/
- (id)initWithGraphicsPort:(CPContext)aGraphicsPort
{
self = [super init];
@@ -52,7 +72,10 @@ var CPGraphicsContextCurrent = nil;
return self;
}
-- (CPContext)graphicsPort
+/*
+ Returns the graphics context's port.
+*/
+- (CGContext)graphicsPort
{
return _graphicsPort;
}
diff --git a/AppKit/CPImage.j b/AppKit/CPImage.j
index 2089602a4d..f51d44805a 100644
--- a/AppKit/CPImage.j
+++ b/AppKit/CPImage.j
@@ -44,9 +44,25 @@ CPImageLoadStatusReadError = 6;
@end
+/*
+ aFilename
is not actually loaded. It will
+ be loaded once needed.
+ @param aFilename the file containing the image
+ @param aSize the image's size
+ @return the initialized image
+*/
+- (CPImage)initByReferencingFile:(CPString)aFilename size:(CGSize)aSize
{
self = [super init];
@@ -69,7 +93,13 @@ CPImageLoadStatusReadError = 6;
return self;
}
-- (CPImage)initWithContentsOfFile:(CPString)aFilename size:(CPSize)aSize
+/*
+ Initializes the image. Loads the specified image into memory.
+ @param aFilename the image to load
+ @param aSize the size of the image
+ @return the initialized image.
+*/
+- (CPImage)initWithContentsOfFile:(CPString)aFilename size:(CGSize)aSize
{
self = [self initByReferencingFile:aFilename size:aSize];
@@ -79,6 +109,12 @@ CPImageLoadStatusReadError = 6;
return self;
}
+/*
+ Initializes the receiver with the contents of the specified
+ image file. The method loads the data into memory.
+ @param aFilename the file name of the image
+ @return the initialized image
+*/
- (CPImage)initWithContentsOfFile:(CPString)aFilename
{
self = [self initByReferencingFile:aFilename size: CGSizeMake(-1, -1)];
@@ -89,36 +125,61 @@ CPImageLoadStatusReadError = 6;
return self;
}
+/*
+ Returns the path of the file associated with this image.
+*/
- (CPString)filename
{
return _filename;
}
-- (void)setSize:(CPSize)aSize
+/*
+ Sets the size of the image.
+ @param the size of the image
+*/
+- (void)setSize:(CGSize)aSize
{
_size = CGSizeMakeCopy(aSize);
}
+/*
+ Returns the size of the image
+*/
- (CGSize)size
{
return _size;
}
+/*
+ Sets the receiver's delegate.
+ @param the delegate
+*/
- (void)setDelegate:(id)aDelegate
{
_delegate = aDelegate;
}
+/*
+ Returns the receiver's delegate
+*/
- (id)delegate
{
return _delegate;
}
+/*
+ Returns YES
if the image data has already been loaded.
+*/
- (BOOL)loadStatus
{
return _loadStatus;
}
+/*
+ Loads the image data from the file into memory. You
+ should not call this method directly. Instead use
+ one of the initializers.
+*/
- (void)load
{
if (_loadStatus == CPImageLoadStatusLoading || _loadStatus == CPImageLoadStatusCompleted)
@@ -150,6 +211,7 @@ CPImageLoadStatusReadError = 6;
return NO;
}
+/* @ignore */
- (void)_imageDidLoad
{
_loadStatus = CPImageLoadStatusCompleted;
@@ -164,6 +226,7 @@ CPImageLoadStatusReadError = 6;
[[CPRunLoop currentRunLoop] performSelectors];
}
+/* @ignore */
- (void)_imageDidError
{
_loadStatus = CPImageLoadStatusReadError;
@@ -174,6 +237,7 @@ CPImageLoadStatusReadError = 6;
[[CPRunLoop currentRunLoop] performSelectors];
}
+/* @ignore */
- (void)_imageDidAbort
{
_loadStatus = CPImageLoadStatusCancelled;
@@ -188,11 +252,20 @@ CPImageLoadStatusReadError = 6;
@implementation CPImage (CPCoding)
+/*
+ Initializes the image with data from a coder.
+ @param aCoder the coder from which to read the image data
+ @return the initialized image
+*/
- (id)initWithCoder:(CPCoder)aCoder
{
return [self initWithContentsOfFile:[aCoder decodeObjectForKey:@"CPFilename"] size:[aCoder decodeSizeForKey:@"CPSize"]];
}
+/*
+ Writes the image data from memory into the coder.
+ @param aCoder the coder to which the data will be written
+*/
- (void)encodeWithCoder:(CPCoder)aCoder
{
[aCoder encodeObject:_filename forKey:@"CPFilename"];
diff --git a/AppKit/CPImageView.j b/AppKit/CPImageView.j
index d39f3f4b1c..6aa860c5c3 100644
--- a/AppKit/CPImageView.j
+++ b/AppKit/CPImageView.j
@@ -30,8 +30,20 @@ import "CPShadowView.j"
#include "CoreGraphics/CGGeometry.h"
+/*
+ @global
+ @group CPImageScaling
+*/
CPScaleProportionally = 0;
+/*
+ @global
+ @group CPImageScaling
+*/
CPScaleToFit = 1;
+/*
+ @global
+ @group CPImageScaling
+*/
CPScaleNone = 2;
@@ -44,6 +56,9 @@ var LEFT_SHADOW_INSET = 3.0,
VERTICAL_SHADOW_INSET = TOP_SHADOW_INSET + BOTTOM_SHADOW_INSET,
HORIZONTAL_SHADOW_INSET = LEFT_SHADOW_INSET + RIGHT_SHADOW_INSET;
+/*
+ This class is a control that displays an image.
+*/
@implementation CPImageView : CPControl
{
CPImage _image;
@@ -78,11 +93,18 @@ var LEFT_SHADOW_INSET = 3.0,
return self;
}
+/*
+ Returns the view's image.
+*/
- (CPImage)image
{
return _image;
}
+/*
+ Sets the image for the view.
+ @param anImage the view's image
+*/
- (void)setImage:(CPImage)anImage
{
if (_image == anImage)
@@ -105,6 +127,19 @@ var LEFT_SHADOW_INSET = 3.0,
[self tile];
}
+/*
+ Returns YES
if the image view draws with
+ a drop shadow. The default is NO
.
+*/
+- (BOOL)hasShadow
+{
+ return _hasShadow;
+}
+
+/*
+ Sets whether the image view should draw with a drop shadow.
+ @param shouldHaveShadow whether the image view should have a shadow
+*/
- (void)setHasShadow:(BOOL)shouldHaveShadow
{
if (_hasShadow == shouldHaveShadow)
@@ -130,6 +165,11 @@ var LEFT_SHADOW_INSET = 3.0,
[self hideOrDisplayContents];
}
+/*
+ Sets the type of image scaling that should be used to
+ render the image.
+ @param anImageScaling the type of scaling to use
+*/
- (void)setImageScaling:(CPImageScaling)anImageScaling
{
if (_imageScaling == anImageScaling)
@@ -152,6 +192,10 @@ var LEFT_SHADOW_INSET = 3.0,
[self tile];
}
+/*
+ Returns the image scaling method used to
+ render this image.
+*/
- (CPImageScaling)imageScaling
{
return _imageScaling;
@@ -164,6 +208,9 @@ var LEFT_SHADOW_INSET = 3.0,
[self tile];
}
+/*
+ Toggles the display of the image view.
+*/
- (void)hideOrDisplayContents
{
if (!_image)
@@ -178,11 +225,17 @@ var LEFT_SHADOW_INSET = 3.0,
}
}
+/*
+ Returns the view's image rectangle
+*/
- (CGRect)imageRect
{
return _imageRect;
}
+/*
+ Add a description
+*/
- (void)tile
{
if (!_image)
@@ -256,6 +309,11 @@ var CPImageViewImageKey = @"CPImageViewImageKey",
@implementation CPImageView (CPCoding)
+/*
+ Initializes the image view with the provided coder.
+ @param aCoder the coder from which data will be read.
+ @return the initialized image view
+*/
- (id)initWithCoder:(CPCoder)aCoder
{
self = [super initWithCoder:aCoder];
@@ -281,6 +339,11 @@ var CPImageViewImageKey = @"CPImageViewImageKey",
return self;
}
+/*
+ Writes the image view out to the coder.
+ @param aCoder the coder to which the image
+ view will be written
+*/
- (void)encodeWithCoder:(CPCoder)aCoder
{
// We do this in order to avoid encoding the _shadowView, which
diff --git a/AppKit/CPKulerColorPicker.j b/AppKit/CPKulerColorPicker.j
index d1d6df9383..2e3f649f65 100644
--- a/AppKit/CPKulerColorPicker.j
+++ b/AppKit/CPKulerColorPicker.j
@@ -32,6 +32,9 @@ import "CPTabView.j"
import "CPTabViewItem.j"
+/*
+ @ignore
+*/
@implementation CPKulerColorPicker : CPColorPicker
{
CPView _contentView;
@@ -229,6 +232,7 @@ import "CPTabViewItem.j"
@end
+/* @ignore */
@implementation _CPKulerThemeView : CPView
{
CPArray _themes;
@@ -320,6 +324,7 @@ import "CPTabViewItem.j"
@end
+/* @ignore */
@implementation _CPColorView : CPControl
{
diff --git a/AppKit/CPMenu.j b/AppKit/CPMenu.j
index 0612244ad9..21abf40dd9 100644
--- a/AppKit/CPMenu.j
+++ b/AppKit/CPMenu.j
@@ -48,6 +48,9 @@ var _CPMenuBarVisible = NO,
_CPMenuBarIconImageAlphaValue = 1.0,
_CPMenuBarSharedWindow = nil;
+/*
+ Menus provide the user with a list of actions and/or submenus. Submenus themselves are full fledged menus and so a heirarchical structure appears.
+*/
@implementation CPMenu : CPObject
{
CPString _title;
@@ -137,7 +140,11 @@ var _CPMenuBarVisible = NO,
}
// Creating a CPMenu Object
-
+/*
+ Initializes the menu with a specified title.
+ @param aTile the menu title
+ @return the initialized menu
+*/
- (id)initWithTitle:(CPString)aTitle
{
self = [super init];
@@ -155,7 +162,11 @@ var _CPMenuBarVisible = NO,
}
// Setting Up Menu Commands
-
+/*
+ Inserts a menu item at the specified index.
+ @param aMenuItem the item to insert
+ @param anIndex the index in the menu to insert the item.
+*/
- (void)insertItem:(CPMenuItem)aMenuItem atIndex:(unsigned)anIndex
{
var menu = [aMenuItem menu];
@@ -176,6 +187,14 @@ var _CPMenuBarVisible = NO,
}
+/*
+ Creates and inserts a new menu item with the specified attributes.
+ @param aTitle the title of the menu item
+ @param anAction the action initiated when the user selects the item
+ @param aKeyEquivalent the keyboard shortcut for the item
+ @param anIndex the index location in the menu for the new item
+ @return the new menu item
+*/
- (CPMenuItem)insertItemWithTitle:(CPString)aTitle action:(SEL)anAction keyEquivalent:(CPString)aKeyEquivalent atIndex:(unsigned)anIndex
{
var item = [[CPMenuItem alloc] initWithTitle:aTitle action:anAction keyEquivalent:aKeyEquivalent];
@@ -185,21 +204,41 @@ var _CPMenuBarVisible = NO,
return item;
}
+/*
+ Adds a menu item at the end of the menu.
+ @param aMenuItem the menu item to add
+*/
- (void)addItem:(CPMenuItem)aMenuItem
{
[self insertItem:aMenuItem atIndex:[_items count]];
}
+/*
+ Creates and adds a menu item with the specified attributes
+ at the end of the menu.
+ @param aTitle the title of the new menu item
+ @param anAction the action initiated when the user selects the item
+ @param aKeyEquivalent the keyboard shortcut for the menu item
+ @return the new menu item
+*/
- (CPMenuItem)addItemWithTitle:(CPString)aTitle action:(SEL)anAction keyEquivalent:(CPString)aKeyEquivalent
{
return [self insertItemWithTitle:aTitle action:anAction keyEquivalent:aKeyEquivalent atIndex:[_items count]];
}
+/*
+ Removes the specified item from the menu
+ @param aMenuItem the item to remove
+*/
- (void)removeItem:(CPMenuItem)aMenuItem
{
[self removeItemAtIndex:[_items indexOfObjectIdenticalTo:aMenuItem]];
}
+/*
+ Removes the item at the specified index from the menu
+ @param anIndex the index of the item to remove
+*/
- (void)removeItemAtIndex:(unsigned)anIndex
{
if (anIndex < 0 || anIndex >= _items.length)
@@ -214,6 +253,10 @@ var _CPMenuBarVisible = NO,
userInfo:[CPDictionary dictionaryWithObject:anIndex forKey:@"CPMenuItemIndex"]];
}
+/*
+ Called when a menu item has visually changed.
+ @param aMenuItem the item that changed
+*/
- (void)itemChanged:(CPMenuItem)aMenuItem
{
if ([aMenuItem menu] != self)
@@ -226,7 +269,11 @@ var _CPMenuBarVisible = NO,
}
// Finding Menu Items
-
+/*
+ Returns the menu item with the specified tag
+ @param the tag of the desired menu item
+ @return the menu item or nil
if a match was not found
+*/
- (CPMenuItem)menuWithTag:(int)aTag
{
var index = [self indexOfItemWithTag:aTag];
@@ -237,6 +284,11 @@ var _CPMenuBarVisible = NO,
return _items[index];
}
+/*
+ Returns the menu item with the specified title.
+ @param aTitle the title of the menu item
+ @return the menu item or nil
if a match was not found
+*/
- (CPMenuItem)menuWithTitle:(CPString)aTitle
{
var index = [self indexOfItemWithTitle:aTitle];
@@ -247,23 +299,37 @@ var _CPMenuBarVisible = NO,
return _items[index];
}
+/*
+ Returns the menu item at the specified index
+ @param anIndex the index of the requested item
+*/
- (CPMenuItem)itemAtIndex:(int)anIndex
{
return [_items objectAtIndex:anIndex];
}
+/*
+ Returns the number of menu items in the menu
+*/
- (unsigned)numberOfItems
{
return [_items count];
}
+/*
+ Returns the array of menu items backing this menu
+*/
- (CPArray)itemArray
{
return _items;
}
// Finding Indices of Menu Items
-
+/*
+ Returns the index of the specified menu item
+ @param aMenuItem the item to find the index for
+ @return the item index or nil
if there isn't one.
+*/
- (CPMenu)attachedMenu
{
return _attachedMenu;
}
+/*
+ Returns YES
if the menu is attached to another menu.
+*/
- (BOOL)isAttached
{
return _isAttached;
}
+/*
+ Not yet implemented
+*/
- (CGPoint)locationOfSubmenu:(CPMenu)aMenu
{
// FIXME: IMPLEMENT.
}
+/*
+ Returns the super menu or nil
if there is none.
+*/
- (CPMenu)supermenu
{
return _supermenu;
}
+/*
+ Sets the super menu.
+ @param aMenu the new super menu
+*/
- (void)setSupermenu:(CPMenu)aMenu
{
_supermenu = aMenu;
}
+/*
+ If there are two instances of this menu visible, return NO
.
+ Otherwise, return YES
if we are a detached menu and visible.
+*/
- (BOOL)isTornOff
{
return !_supermenu /* || offscreen(?) */ || self == [CPApp mainMenu];
}
// Enabling and Disabling Menu Items
-
+/*
+ Sets whether the menu automatically enables menu items.
+ @param aFlag YES
sets the menu to automatically enable items.
+*/
- (void)setAutoenablesItems:(BOOL)aFlag
{
_autoenablesItems = aFlag;
}
+/*
+ Returns YES
if the menu auto enables items.
+*/
- (BOOL)autoenablesItems
{
return _autoenablesItems;
}
+/*
+ Not implemented.
+*/
- (void)update
{
}
// Managing the Title
-
+/*
+ Sets the menu title.
+ @param the new title
+*/
- (void)setTitle:(CPString)aTitle
{
_title = aTitle;
}
+/*
+ Returns the menu title
+*/
- (CPString)title
{
return _title;
@@ -470,20 +607,29 @@ var _CPMenuBarVisible = NO,
}
// Managing Display of State Column
-
+/*
+ Sets whether to show the state column
+ @param shouldShowStateColumn YES
shows the state column
+*/
- (void)setShowsStateColumn:(BOOL)shouldShowStateColumn
{
_showsStateColumn = shouldShowStateColumn;
}
+/*
+ Returns YES
if the menu shows the state column
+*/
- (BOOL)showsStateColumn
{
return _showsStateColumn;
}
// Handling Highlighting
-
-- (BOOL)highlightedItem
+/*
+ Returns the currently highlighted menu item.
+ @return the highlighted menu item or nil
if no item is currently highlighted
+*/
+- (CPMenuItem)highlightedItem
{
return _highlightedIndex >= 0 ? _items[_highlightedIndex] : nil;
}
@@ -501,17 +647,26 @@ var _CPMenuBarVisible = NO,
}
// Handling Tracking
-
+/*
+ Cancels tracking.
+*/
- (void)cancelTracking
{
[_menuWindow cancelTracking];
}
+/* @ignore */
- (void)_setMenuWindow:(_CPMenuWindow)aMenuWindow
{
_menuWindow = aMenuWindow;
}
+/*
+ Initiates the action of the menu item that
+ has a keyboard shortcut equivalent to anEvent
+ @param anEvent the keyboard event
+ @return YES
if it was handled.
+*/
- (BOOL)performKeyEquivalent:(CPEvent)anEvent
{
if (_autoenablesItems)
@@ -548,7 +703,10 @@ var _CPMenuBarVisible = NO,
}
// Simulating Mouse Clicks
-
+/*
+ Sends the action of the menu item at the specified index.
+ @param anIndex the index of the item
+*/
- (void)performActionForItemAtIndex:(unsigned)anIndex
{
var item = _items[anIndex];
@@ -557,12 +715,17 @@ var _CPMenuBarVisible = NO,
}
//
-
+/*
+ @ignore
+*/
- (BOOL)_itemIsHighlighted:(CPMenuItem)aMenuItem
{
return _items[_highlightedIndex] == aMenuItem;
}
+/*
+ @ignore
+*/
- (void)_highlightItemAtIndex:(int)anIndex
{
var previousHighlightedIndex = _highlightedIndex;
@@ -584,6 +747,11 @@ var CPMenuTitleKey = @"CPMenuTitleKey",
@implementation CPMenu (CPCoding)
+/*
+ Initializes the menu with data from the specified coder.
+ @param aCoder the coder from which to read the data
+ @return the initialized menu
+*/
- (id)initWithCoder:(CPCoder)aCoder
{
self = [super init];
@@ -597,6 +765,10 @@ var CPMenuTitleKey = @"CPMenuTitleKey",
return self;
}
+/*
+ Encodes the data of the menu into a coder
+ @param aCoder the coder to which the data will be written
+*/
- (void)encodeWithCoder:(CPCoder)aCoder
{
[aCoder encodeObject:_title forKey:CPMenuTitleKey];
@@ -627,6 +799,9 @@ var STICKY_TIME_INTERVAL = 500,
SCROLL_INDICATOR_HEIGHT = 16.0;
+/*
+ @ignore
+*/
@implementation _CPMenuWindow : CPWindow
{
_CPMenuView _menuView;
@@ -1008,6 +1183,9 @@ var STICKY_TIME_INTERVAL = 500,
@end
+/*
+ @ignore
+*/
@implementation _CPMenuView : CPView
{
CPArray _menuItemViews;
diff --git a/AppKit/CPMenuItem.j b/AppKit/CPMenuItem.j
index 68050294e1..0e4ffdf00e 100644
--- a/AppKit/CPMenuItem.j
+++ b/AppKit/CPMenuItem.j
@@ -28,7 +28,11 @@ import YES
enables the item. NO
disables it.
+*/
- (void)setEnabled:(BOOL)isEnabled
{
if ([_menu autoenablesItems])
@@ -105,23 +119,35 @@ import YES
if the item is enabled.
+*/
- (BOOL)isEnabled
{
return _isEnabled;
}
// Managing Hidden Status
-
+/*
+ Sets whether the item should be hidden. A hidden item can not be triggered by keyboard shortcuts.
+ @param isHidden YES
hides the item. NO
reveals it.
+*/
- (void)setHidden:(BOOL)isHidden
{
_isHidden = isHidden;
}
+/*
+ Returns YES
if the item is hidden.
+*/
- (BOOL)isHidden
{
return _isHidden;
}
+/*
+ Returns YES
if the item is hidden or if one of it's supermenus is hidden.
+*/
- (BOOL)isHiddenOrHasHiddenAncestor
{
if (_isHidden)
@@ -134,29 +160,45 @@ import
+
+*/
- (void)setState:(int)aState
{
if (_state == aState)
@@ -227,13 +293,24 @@ import
+
+*/
- (int)state
{
return _state;
}
// Managing the Image
-
+/*
+ Sets the menu item's image
+ @param anImage the menu item's image
+*/
- (void)setImage:(CPImage)anImage
{
if (_image == anImage)
@@ -246,21 +323,36 @@ import nil
if there is no submenu.
+*/
- (CPMenu)submenu
{
return _submenu;
}
+/*
+ Returns YES
if the menu item has a submenu.
+*/
- (BOOL)hasSubmenu
{
return _submenu ? YES : NO;
@@ -336,23 +455,35 @@ import YES
if the menu item is a separator.
+*/
- (BOOL)isSeparatorItem
{
return NO;
}
// Managing the Owning Menu
-
+/*
+ Set the container menu of this item.
+ @param aMenu the item's container menu
+*/
- (void)setMenu:(CPMenu)aMenu
{
_menu = aMenu;
}
+/*
+ Returns the container menu of this item
+*/
- (CPMenu)menu
{
return _menu;
@@ -360,38 +491,76 @@ import
+
+*/
- (void)setKeyEquivalentModifierMask:(unsigned)aMask
{
_keyEquivalentModifierMask = aMask;
}
+/*
+ Returns the item's keyboard shortcut modifier mask.
+ Can be a combination of:
+
+
+*/
- (unsigned)keyEquivalentModifierMask
{
return _keyEquivalentModifierMask;
}
// Managing Mnemonics
-
+/*
+ Sets the index of the mnemonic character in the title. The character
+ will be underlined and is used as a shortcut for navigation.
+ @param aLocation the index of the character in the title
+*/
- (void)setMnemonicLocation:(unsigned)aLocation
{
_mnemonicLocation = aLocation;
}
+/*
+ Returns the index of the mnemonic character in the title.
+*/
- (unsigned)mnemonicLocation
{
return _mnemonicLocation;
}
+/*
+ Sets the title of the menu item and the mnemonic character. The mnemonic chracter should be preceded by an '&'.
+ @param aTitle the title string with a denoted mnemonic
+*/
- (void)setTitleWithMnemonicLocation:(CPString)aTitle
{
var location = [aTitle rangeOfString:@"&"].location;
@@ -405,6 +574,9 @@ import YES
denotes that this menu item is an alternate
+*/
- (void)setAlternate:(BOOL)isAlternate
{
_isAlternate = isAlternate;
}
+/*
+ Returns YES
if the menu item is an alternate for the previous item.
+*/
- (BOOL)isAlternate
{
return _isAlternate;
@@ -424,25 +603,40 @@ import YES
if the menu item is highlighted.
+*/
- (BOOL)isHighlighted
{
return [[self menu] highlightedItem] == self;
@@ -488,6 +699,9 @@ import
+- (id)outlineView:(
+ @param aDataSource the outline's data source
+ @throws CPInternalInconsistencyException if the data source does not implement all the required methods
+*/
- (void)setDataSource:(id)aDataSource
{
+ if (![aDataSource respondsToSelector:@selector(outlineView:child:ofItem)])
+ [CPException raise:CPInternalInconsistencyException reason:"Data source must implement 'outlineView:child:ofItem'"];
+ if (![aDataSource respondsToSelector:@selector(outlineView:isItemExpandable)])
+ [CPException raise:CPInternalInconsistencyException reason:"Data source must implement 'outlineView:isItemExpandable'"];
+ if (![aDataSource respondsToSelector:@selector(outlineView:numberOfChildrenOfItem)])
+ [CPException raise:CPInternalInconsistencyException reason:"Data source must implement 'outlineView:numberOfChildrenOfItem'"];
+ if (![aDataSource respondsToSelector:@selector(outlineView:objectValueForTableColumn:byItem)])
+ [CPException raise:CPInternalInconsistencyException reason:"Data source must implement 'outlineView:objectValueForTableColumn:byItem'"];
+
_outlineDataSource = aDataSource;
[self reloadData];
}
-
+/* @ignore */
- (void)reloadData
{
_numberOfVisibleItems = [_outlineDataSource outlineView:self numberOfChildrenOfItem:nil];
@@ -64,13 +91,19 @@ import "CPTableView.j"
@end
+/* @ignore */
@implementation CPOutlineView (CPTableDataSource)
+/*
+ FIXME
+*/
+/* @ignore */
- (void)numberOfRowsInTableView:(CPTableView)aTableView
{
return _numberOfVisibleItems;
}
+/* @ignore */
- (void)tableView:(CPTableView)aTableView objectValueForTableColumn:(CPTableColumn)aTableColumn row:(int)aRowIndex
{
return [_outlineDataSource outlineView:self objectValueForTableColumn:aTableColumn byItem:_itemsByRow[aRowIndex]];
diff --git a/AppKit/CPPanel.j b/AppKit/CPPanel.j
index 345acf5a4e..282b24530c 100644
--- a/AppKit/CPPanel.j
+++ b/AppKit/CPPanel.j
@@ -26,27 +26,60 @@ import "CPWindow.j"
CPOKButton = 1;
CPCancelButton = 0;
+/*
+ The
Panels behave differently from standard windows in only a small number of ways, but the ways are important to the user interface:
+ +To aid in their auxiliary role, panels can be assigned special behaviors:
+ +YES
if the receiver is a floating panel (like a palette).
+*/
- (BOOL)isFloatingPanel
{
return [self level] == CPFloatingWindowLevel;
}
+/*
+ Sets the receiver to be a floating panel. YES
+ makes the window a floating panel. NO
makes it a normal window.
+ @param isFloatingPanel specifies whether to make it floating
+*/
- (void)setFloatingPanel:(BOOL)isFloatingPanel
{
[self setLevel:isFloatingPanel ? CPFloatingWindowLevel : CPNormalWindowLevel];
}
+/*
+ Returns YES
if the window only becomes key
+ if needed. NO
means it behaves just like other windows.
+*/
- (BOOL)becomesKeyOnlyIfNeeded
{
return _becomesKeyOnlyIfNeeded;
}
+/*
+ Sets whether the the window becomes key only if needed.
+ @param shouldBecomeKeyOnlyIfNeeded YES
makes the window become key only if needed
+*/
- (void)setBecomesKeyOnlyIfNeeded:(BOOL)shouldBecomeKeyOnlyIfNeeded
{
_becomesKeyOnlyIfNeeded = shouldBecomeKeyOnlyIfNeeded
@@ -57,6 +90,10 @@ CPCancelButton = 0;
return _worksWhenModal;
}
+/*
+ Sets whether this window can receive input while another window is running modally.
+ @param shouldWorkWhenModal whether to receive input while another window is modal
+*/
- (void)setWorksWhenModal:(BOOL)shouldWorkWhenModal
{
_worksWhenModal = shouldWorkWhenModal;
diff --git a/AppKit/CPPasteboard.j b/AppKit/CPPasteboard.j
index 80283397fe..6e4717936a 100644
--- a/AppKit/CPPasteboard.j
+++ b/AppKit/CPPasteboard.j
@@ -42,6 +42,9 @@ CPImagePboardType = @"CPImagePboardType";
var CPPasteboards = nil;
+/*
+ YES
if the data was successfully written to the pasteboard
+*/
- (BOOL)setData:(CPData)aData forType:(CPString)aType
{
[_provided setObject:aData forKey:aType];
@@ -141,35 +174,62 @@ var CPPasteboards = nil;
return YES;
}
+/*
+ Writes the specified property list as data for the specified type
+ @param aPropertyList the property list to write
+ @param aType the data type
+ @return YES
if the property list was successfully written to the pasteboard
+*/
- (BOOL)setPropertyList:(id)aPropertyList forType:(CPString)aType
{
return [self setData:[CPPropertyListSerialization dataFromPropertyList:aPropertyList format:CPPropertyListXMLFormat_v1_0 errorDescription:nil] forType:aType];
}
+/*
+ Sets the specified string as data for the specified type
+ @param aString the string to write
+ @param aType the data type
+ @return YES
if the string was successfully written to the pasteboard
+*/
- (void)setString:(CPString)aString forType:(CPString)aType
{
return [self setPropertyList:aString forType:aType];
}
// Determining Types
-
+/*
+ Checks the pasteboard's types for a match with the types listen in the specified array. The array should
+ be ordered by the requestor's most preferred data type first.
+ @param anArray an array of requested types ordered by preference
+ @return the highest match with the pasteboard's supported types or nil
if no match was found
+*/
- (CPString)availableTypeFromArray:(CPArray)anArray
{
return [_types firstObjectCommonWithArray:anArray];
}
+/*
+ Returns the pasteboards supported types
+*/
- (CPArray)types
{
return _types;
}
// Reading data
-
+/*
+ Returns the number of changes that have occurred to this pasteboard
+*/
- (unsigned)changeCount
{
return _changeCount;
}
+/*
+ Returns the pasteboard data for the specified data type
+ @param aType the requested data type
+ @return the requested data or nil
if the data doesn't exist
+*/
- (CPData)dataForType:(CPString)aType
{
var data = [_provided objectForKey:aType];
@@ -191,6 +251,11 @@ var CPPasteboards = nil;
return nil;
}
+/*
+ Returns the property list for the specified data type
+ @param aType the requested data type
+ @return the property list or nil
if the list was not found
+*/
- (id)propertyListForType:(CPString)aType
{
var data = [self dataForType:aType];
@@ -201,11 +266,17 @@ var CPPasteboards = nil;
return nil;
}
+/*
+ Returns the string for the specified data type
+ @param aType the requested data type
+ @return the string or nil
if the string was not found
+*/
- (CPString)stringForType:(CPString)aType
{
return [self propertyListForType:aType];
}
+/* @ignore */
- (CPString)_generateStateUID
{
var bits = 32;
@@ -218,6 +289,7 @@ var CPPasteboards = nil;
return _stateUID;
}
+/* @ignore */
- (CPString)_stateUID
{
return _stateUID;
diff --git a/AppKit/CPPopUpButton.j b/AppKit/CPPopUpButton.j
index 2c1898990d..a8b4a83c45 100644
--- a/AppKit/CPPopUpButton.j
+++ b/AppKit/CPPopUpButton.j
@@ -30,6 +30,9 @@ var VISIBLE_MARGIN = 7.0;
var CPPopUpButtonArrowsImage = nil;
+/*
+ A YES
makes this a pull-down menu, NO
makes it a pop-up menu.
+ @return the initialized pop-up button
+*/
- (id)initWithFrame:(CGRect)aFrame pullsDown:(BOOL)shouldPullDown
{
self = [super initWithFrame:aFrame];
@@ -96,6 +105,11 @@ var CPPopUpButtonArrowsImage = nil;
// Setting the Type of Menu
+/*
+ Specifies whether the object is a pull-down or a pop-up menu.
+ @param shouldPullDown YES
makes the pop-up button
+ a pull-down menu. NO
makes it a pop-up menu.
+*/
- (void)setPullsDown:(BOOL)shouldPullDown
{
if (_pullsDown == shouldPullDown)
@@ -113,18 +127,28 @@ var CPPopUpButtonArrowsImage = nil;
[self synchronizeTitleAndSelectedItem];
}
+/*
+ Returns YES
if the button is a pull-down menu. NO
if the button is a pop-up menu.
+*/
- (BOOL)pullsDown
{
return _pullsDown;
}
// Inserting and Deleting Items
-
+/*
+ Adds a new menu item with the specified title.
+ @param the new menu item's tite
+*/
- (void)addItemWithTitle:(CPString)aTitle
{
[_menu addItemWithTitle:aTitle action:NULL keyEquivalent:NULL];
}
+/*
+ Adds multiple new menu items with the titles specified in the provided array.
+ @param titles an arry of names for the new items
+*/
- (void)addItemsWithTitles:(CPArray)titles
{
var index = 0,
@@ -134,6 +158,11 @@ var CPPopUpButtonArrowsImage = nil;
[self addItemWithTitle:titles[index]];
}
+/*
+ Inserts a new item with the specified title and index location.
+ @param aTitle the new itme's title
+ @param anIndex the item's index in the menu
+*/
- (void)insertItemWithTitle:(CPString)aTitle atIndex:(int)anIndex
{
var items = [self itemArray],
@@ -146,6 +175,9 @@ var CPPopUpButtonArrowsImage = nil;
[_menu insertItemWithTitle:aTitle action:NULL keyEquivalent:NULL atIndex:anIndex];
}
+/*
+ Removes all menu items from the pop-up button's menu
+*/
- (void)removeAllItems
{
var count = [_menu numberOfItems];
@@ -154,12 +186,20 @@ var CPPopUpButtonArrowsImage = nil;
[_menu removeItemAtIndex:0];
}
+/*
+ Removes a menu item with the specified title from the button.
+ @param aTitle the title of the item to remove
+*/
- (void)removeItemWithTitle:(CPString)aTitle
{
[self removeItemAtIndex:[self indexOfItemWithTitle:aTitle]];
[self synchronizeTitleAndSelectedItem];
}
+/*
+ Removes the menu item at the specified index
+ @param anIndex the index of the item to remove
+*/
- (void)removeItemAtIndex:(int)anIndex
{
[_menu removeItemAtIndex:anIndex];
@@ -167,7 +207,9 @@ var CPPopUpButtonArrowsImage = nil;
}
// Getting the User's Selection
-
+/*
+ Returns the selected item or nil
if no item is selected.
+*/
- (CPMenuItem)selectedItem
{
if (_selectedIndex < 0)
@@ -176,29 +218,45 @@ var CPPopUpButtonArrowsImage = nil;
return [_menu itemAtIndex:_selectedIndex];
}
+/*
+ Returns the title of the selected item or nil
if no item is selected.
+*/
- (CPString)titleOfSelectedItem
{
return [[self selectedItem] title];
}
+/*
+ Returns the index of the selected item. If no item is selected, it returns nil
if the item does not exist.
+ @param anIndex the index of the item to obtain
+*/
- (CPMenuItem)itemAtIndex:(unsigned)anIndex
{
return [_menu itemAtIndex:anIndex];
}
+/*
+ Returns the title of the item at the specified index or nil
if no item exists.
+ @param anIndex the index of the item
+*/
- (CPString)itemTitleAtIndex:(unsigned)anIndex
{
return [[_menu itemAtIndex:anIndex] title];
}
+/*
+ Returns an array of all the menu item titles.
+*/
- (CPArray)itemTitles
{
var titles = [],
@@ -323,57 +415,100 @@ var CPPopUpButtonArrowsImage = nil;
items.push([items[index] title]);
}
+/*
+ Returns the menu item with the specified title.
+ @param aTitle the title of the desired menu item
+*/
- (CPMenuItem)itemWithTitle:(CPString)aTitle
{
return [_menu itemAtIndex:[_menu indexOfItemWithTitle:aTitle]];
}
+/*
+ Returns the last menu item
+*/
- (CPMenuItem)lastItem
{
return [[_menu itemArray] lastObject];
}
// Getting the Indices of Menu Items
-
+/*
+ Returns the index of the specified item or NO
. Cappuccino does not have multiple threads.
+*/
- (BOOL)usesThreadedAnimation
{
return NO;
}
// Advancing the Progress Bar
-
+/*
+ Increases the progress of the bar by the specified value.
+ @param aValue the amount to increase the progress value
+*/
- (void)incrementBy:(double)aValue
{
[self setDoubleValue:_doubleValue + aValue];
}
+/*
+ Sets the progress value of the indicator.
+*/
- (void)setDoubleValue:(double)aValue
{
_doubleValue = MIN(MAX(aValue, _minValue), _maxValue);
@@ -189,33 +228,53 @@ var CPProgressIndicatorSpinningStyleColors = nil,
[self drawBar];
}
+/*
+ Returns the value of the progress indicator.
+*/
- (double)doubleValue
{
return _doubleValue;
}
+/*
+ Sets the minimum value of the progress indicator. The default is 0.0.
+ @param aValue the new minimum value
+*/
- (void)setMinValue:(double)aValue
{
_minValue = aValue;
}
+/*
+ Returns the minimum value of the progress indicator.
+*/
- (double)minValue
{
return _minValue;
}
+/*
+ Sets the maximum value of the progress indicator. The default is 100.0.
+ @param aValue the new maximum value.
+*/
- (void)setMaxValue:(double)aValue
{
_maxValue = aValue;
}
+/*
+ Returns the maximum value of the progress indicator.
+*/
- (double)maxValue
{
return _maxValue;
}
// Setting the Appearance
-
+/*
+ Sets the progress indicator's size.
+ @param aControlSize the new size
+*/
- (void)setControlSize:(CPControlSize)aControlSize
{
if (_controlSize == aControlSize)
@@ -226,29 +285,48 @@ var CPProgressIndicatorSpinningStyleColors = nil,
[self updateBackgroundColor];
}
+/*
+ Returns the progress indicator's size
+*/
- (CPControlSize)controlSize
{
return _controlSize;
}
+/*
+ Not yet implemented
+*/
- (void)setControlTint:(CPControlTint)aControlTint
{
}
+/*
+ Not yet impemented.
+*/
- (CPControlTint)controlTint
{
return 0;
}
+/*
+ Not yet implemented.
+*/
- (void)setBezeled:(BOOL)isBezeled
{
}
+/*
+ Not yet implemented.
+*/
- (BOOL)isBezeled
{
return YES;
}
+/*
+ Specifies whether this progress indicator should be indeterminate or display progress based on it's max and min.
+ @param isDeterminate YES
makes the indicator indeterminate
+*/
- (void)setIndeterminate:(BOOL)isIndeterminate
{
if (_indeterminate == isIndeterminate)
@@ -259,11 +337,18 @@ var CPProgressIndicatorSpinningStyleColors = nil,
[self updateBackgroundColor];
}
+/*
+ Returns YES
if the progress bar is indeterminate.
+*/
- (BOOL)isIndeterminate
{
return _isIndeterminate;
}
+/*
+ Sets the progress indicator's style
+ @param aStyle the style to set it to
+*/
- (void)setStyle:(CPProgressIndicatorStyle)aStyle
{
if (_style == aStyle)
@@ -274,6 +359,9 @@ var CPProgressIndicatorSpinningStyleColors = nil,
[self updateBackgroundColor];
}
+/*
+ Resizes the indicator based on it's style.
+*/
- (void)sizeToFit
{
if (_style == CPProgressIndicatorSpinningStyle)
@@ -284,6 +372,11 @@ var CPProgressIndicatorSpinningStyleColors = nil,
_CPControlIdentifierForControlSize(_controlSize)][0].height)];
}
+/*
+ Sets whether the indicator should be displayed when it isn't animating. By default this is YES
if the style
+ is NO
if it's YES
means the indicator will be displayed when it's not animating.
+*/
- (void)setDisplayedWhenStopped:(BOOL)isDisplayedWhenStopped
{
if (_isDisplayedWhenStoppedSet && _isDisplayedWhenStopped == isDisplayedWhenStopped)
@@ -296,6 +389,9 @@ var CPProgressIndicatorSpinningStyleColors = nil,
[self _hideOrDisplay];
}
+/*
+ Returns YES
if the progress bar is displayed when not animating.
+*/
- (BOOL)isDisplayedWhenStopped
{
if (_isDisplayedWhenStoppedSet)
@@ -307,6 +403,7 @@ var CPProgressIndicatorSpinningStyleColors = nil,
return NO;
}
+/* @ignore */
- (void)_hideOrDisplay
{
[self setHidden:!_isAnimating && ![self isDisplayedWhenStopped]];
@@ -319,6 +416,7 @@ var CPProgressIndicatorSpinningStyleColors = nil,
[self drawBar];
}
+/* @ignore */
- (void)drawBar
{
if (_style == CPProgressIndicatorSpinningStyle)
@@ -343,6 +441,7 @@ var CPProgressIndicatorSpinningStyleColors = nil,
[_barView setFrameSize:CGSizeMake(CGRectGetWidth([self bounds]) * (_doubleValue - _minValue) / (_maxValue - _minValue) - 4.0, 9.0)];
}
+/* @ignore */
- (void)updateBackgroundColor
{
if (YES)//_isBezeled)
diff --git a/AppKit/CPResponder.j b/AppKit/CPResponder.j
index e51ed792ff..34e177677d 100644
--- a/AppKit/CPResponder.j
+++ b/AppKit/CPResponder.j
@@ -35,34 +35,55 @@ CPRightArrowKeyCode = 63235;
}
// Changing the first responder
-
+/*
+ Returns YES
if the receiver is able to become the first responder. NO
otherwise.
+*/
- (BOOL)acceptsFirstResponder
{
return NO;
}
+/*
+ Notifies the receiver that it will become the first responder. The receiver can reject first
+ responder if it returns NO
. The default implementation always returns YES
.
+ @return YES
if the receiver accepts first responder status.
+*/
- (BOOL)becomeFirstResponder
{
return YES;
}
+/*
+ Notifies the receiver that it has been asked to give up first responder status.
+ @return YES
if the receiver is willing to give up first responder status.
+*/
- (BOOL)resignFirstResponder
{
return YES;
}
// Setting the next responder
-
+/*
+ Sets the receiver's next responder.
+ @param aResponder the responder after the receiver
+*/
- (void)setNextResponder:(CPResponder)aResponder
{
_nextResponder = aResponder;
}
+/*
+ Returns the responder after the receiver.
+*/
- (CPResponder)nextResponder
{
return _nextResponder;
}
+/*
+ Called to interpret a series of key events.
+ @param events an array of key anEvent
, the receiver should simulate the event.
+ @param anEvent the event to simulate
+ @return YES
if the event receiver simulated the event
+*/
- (BOOL)performKeyEquivalent:(CPEvent)anEvent
{
return NO;
}
// Action Methods
-
+/*
+ Deletes one character backward, or the selection if anything is selected.
+ @param aSender the object requesting this
+*/
- (void)deleteBackward:(id)aSender
{
}
+/*
+ Insert a line break at the caret position or selection.
+ @param aSender the object requesting this
+*/
- (void)insertLineBreak:(id)aSender
{
}
+/*
+ Inserts some text at the caret position or selection.
+ @param aString the string to insert
+*/
- (void)insertText:(CPString)aString
{
}
// Dispatch methods
-
+/*
+ The receiver will attempt to perform the command,
+ if it responds to it. If not, the nextResponder
will be called to do it.
+ @param aSelector the command to attempt
+*/
- (void)doCommandBySelector:(SEL)aSelector
{
if([self respondsToSelector:aSelector])
@@ -164,6 +239,13 @@ CPRightArrowKeyCode = 63235;
[_nextResponder doCommandBySelector:aSelector];
}
+/*
+ The receiver will attempt to perform the command, or pass it on to the next responder if it doesn't respond to it.
+ @param aSelector the command to perform
+ @param anObject the argument to the method
+ @return YES
if the receiver was able to perform the command, or a responder down the chain was
+ able to perform the command.
+*/
- (BOOL)tryToPerform:(SEL)aSelector with:(id)anObject
{
if([self respondsToSelector:aSelector])
@@ -189,14 +271,19 @@ CPRightArrowKeyCode = 63235;
}
// Getting the Undo Manager
-
+/*
+ Returns the undo manager for the receiver.
+*/
- (CPUndoManager)undoManager
{
return [_nextResponder performSelector:_cmd];
}
// Terminating the responder chain
-
+/*
+ Called when an event finds no suitable responder.
+ @param anEventSelector the command that failed
+*/
- (void)noResponderFor:(SEL)anEventSelector
{
}
@@ -207,6 +294,11 @@ var CPResponderNextResponderKey = @"CPResponderNextResponderKey";
@implementation CPResponder (CPCoding)
+/*
+ Initializes the responder with data from a coder.
+ @param aCoder the coder from which data will be read
+ @return the initialized responder
+*/
- (id)initWithCoder:(CPCoder)aCoder
{
self = [self init];
@@ -217,6 +309,10 @@ var CPResponderNextResponderKey = @"CPResponderNextResponderKey";
return self;
}
+/*
+ Archives the responder to a coder.
+ @param aCoder the coder to which the responder will be archived
+*/
- (void)encodeWithCoder:(CPCoder)aCoder
{
[aCoder encodeConditionalObject:_nextResponder forKey:CPResponderNextResponderKey];
diff --git a/AppKit/CPScrollView.j b/AppKit/CPScrollView.j
index 30cacbe55f..989d7ee92e 100644
--- a/AppKit/CPScrollView.j
+++ b/AppKit/CPScrollView.j
@@ -26,7 +26,11 @@ import "CPScroller.j"
#include "CoreGraphics/CGGeometry.h"
-
+/*
+ Used to display views that are too large for the viewing area. the YES
lets the scroll view
+ allocate a horizontal scroller if necessary.
+*/
- (void)setHasHorizontalScroller:(BOOL)hasHorizontalScroller
{
_hasHorizontalScroller = hasHorizontalScroller;
@@ -261,11 +298,19 @@ import "CPScroller.j"
[_horizontalScroller setHidden:YES];
}
+/*
+ Returns YES
if the scroll view can have a horizontal
+ scroller.
+*/
- (BOOL)hasHorizontalScroller
{
return _hasHorizontalScroller;
}
+/*
+ Sets the scroll view's vertical scroller.
+ @param aScroller the vertical scroller
+*/
- (void)setVerticalScroller:(CPScroller)aScroller
{
if (_verticalScroller == aScroller)
@@ -282,11 +327,20 @@ import "CPScroller.j"
[self addSubview:_verticalScroller];
}
+/*
+ Return's the scroll view's vertical scroller
+*/
- (CPScroller)verticalScroller
{
return _verticalScroller;
}
+/*
+ Specifies whether the scroll view has can have
+ a vertical scroller. It allocates it if necessary.
+ @param hasVerticalScroller YES
allows
+ the scroll view to display a vertical scroller
+*/
- (void)setHasVerticalScroller:(BOOL)hasVerticalScroller
{
_hasVerticalScroller = hasVerticalScroller;
@@ -297,16 +351,29 @@ import "CPScroller.j"
[_verticalScroller setHidden:YES];
}
+/*
+ Returns YES
if the scroll view can have
+ a vertical scroller.
+*/
- (BOOL)hasHorizontalScroller
{
return _hasHorizontalScroller;
}
+/*
+ Sets whether the scroll view hides its scoll bars when not needed.
+ @param autohidesScrollers YES
causes the scroll bars
+ to be hidden when not needed.
+*/
- (void)setAutohidesScrollers:(BOOL)autohidesScrollers
{
_autohidesScrollers = autohidesScrollers;
}
+/*
+ Returns YES
if the scroll view hides its scroll
+ bars when not necessary.
+*/
- (BOOL)autohidesScrollers
{
return _autohidesScrollers;
@@ -319,6 +386,7 @@ import "CPScroller.j"
[self reflectScrolledClipView:_contentView];
}*/
+/* @ignore */
- (void)_verticalScrollerDidScroll:(CPScroller)aScroller
{
var value = [aScroller floatValue],
@@ -347,6 +415,7 @@ import "CPScroller.j"
[_contentView scrollToPoint:contentBounds.origin];
}
+/* @ignore */
- (void)_horizontalScrollerDidScroll:(CPScroller)aScroller
{
var value = [aScroller floatValue],
@@ -375,6 +444,9 @@ import "CPScroller.j"
[_contentView scrollToPoint:contentBounds.origin];
}
+/*
+ Lays out the scroll view's components.
+*/
- (void)tile
{
// yuck.
@@ -383,75 +455,135 @@ import "CPScroller.j"
// scroll: refl.
}
--(void)resizeSubviewsWithOldSize:(CPSize)aSize
+/*
+ @ignore
+*/
+-(void)resizeSubviewsWithOldSize:(CGSize)aSize
{
[self reflectScrolledClipView:_contentView];
}
// Setting Scrolling Behavior
-
+/*
+ Sets how much the document moves when scrolled. Sets
+ the vertical and horizontal scroll.
+ @param aLineScroll the amount to move the document
+ when scrolled
+*/
- (void)setLineScroll:(float)aLineScroll
{
[self setHorizonalLineScroll:aLineScroll];
[self setVerticalLineScroll:aLineScroll];
}
+/*
+ Returns how much the document moves
+ when scrolled
+*/
- (float)lineScroll
{
return [self horizontalLineScroll];
}
+/*
+ Sets how much the document moves when scrolled
+ horizontally.
+ @param aLineScroll the amount to move horizontally
+ when scrolled.
+*/
- (void)setHorizontalLineScroll:(float)aLineScroll
{
_horizontalLineScroll = aLineScroll;
}
+/*
+ Returns how much the document moves horizontally
+ when scrolled.
+*/
- (float)horizontalLineScroll
{
return _horizontalLineScroll;
}
+/*
+ Sets how much the document moves when scrolled
+ vertically.
+ @param aLineScroll the new amount to move vertically
+ when scrolled.
+*/
- (void)setVerticalLineScroll:(float)aLineScroll
{
_verticalLineScroll = aLineScroll;
}
+/*
+ Returns how much the document moves vertically
+ when scrolled.
+*/
- (float)verticalLineScroll
{
return _verticalLineScroll;
}
+/*
+ Sets the horizontal and vertical page scroll amount.
+ @param aPageScroll the new horizontal and vertical page
+ scroll amount
+*/
- (void)setPageScroll:(float)aPageScroll
{
[self setHorizontalPageScroll:aPageScroll];
[self setVerticalPageScroll:aPageScroll];
}
+/*
+ Returns the vertical and horizontal page scroll
+ amount.
+*/
- (float)pageScroll
{
return [self horizontalPageScroll];
}
+/*
+ Sets the horizontal page scroll amount.
+ @param aPageScroll the new horizontal page scroll amount
+*/
- (void)setHorizontalPageScroll:(float)aPageScroll
{
_horizontalPageScroll = aPageScroll;
}
+/*
+ Returns the horizontal page scroll amount.
+*/
- (float)horizontalPageScroll
{
return _horizontalPageScroll;
}
+/*
+ Sets the vertical page scroll amount.
+ @param aPageScroll the new vertcal page scroll
+ amount
+*/
- (void)setVerticalPageScroll:(float)aPageScroll
{
_verticalPageScroll = aPageScroll;
}
+/*
+ Returns the vertical page scroll amount.
+*/
- (float)verticalPageScroll
{
return _verticalPageScroll;
}
+/*
+ Handles a scroll wheel event from the user.
+ @param anEvent the scroll wheel event
+*/
- (void)scrollWheel:(CPEvent)anEvent
{
var value = [_verticalScroller floatValue],
diff --git a/AppKit/CPScroller.j b/AppKit/CPScroller.j
index 795e567936..ee726b4c32 100644
--- a/AppKit/CPScroller.j
+++ b/AppKit/CPScroller.j
@@ -96,6 +96,9 @@ var _CPScrollerClassName = nil,
CPView _incrementArrowView;
}
+/*
+ @ignore
+*/
+ (void)initialize
{
if (self != [CPScroller class])
@@ -178,7 +181,7 @@ var _CPScrollerClassName = nil,
// Calculating Layout
-- (id)initWithFrame:(CPRect)aFrame
+- (id)initWithFrame:(CGRect)aFrame
{
self = [super initWithFrame:aFrame];
@@ -193,7 +196,7 @@ var _CPScrollerClassName = nil,
_hitPart = CPScrollerNoPart;
- [self checkSpaceForUsableParts];
+ [self checkSpaceForParts];
[self drawParts];
[self layoutSubviews];
@@ -203,17 +206,27 @@ var _CPScrollerClassName = nil,
}
// Determining CPScroller Size
-
+/*
+ Returns the aPoint
.
+ @param aPoint the simulated point hit
+ @return the part of the scroller that intersects the point
+*/
- (CPScrollerPart)testPart:(CGPoint)aPoint
{
aPoint = [self convertPoint:aPoint fromView:nil];
@@ -294,7 +326,10 @@ var _CPScrollerClassName = nil,
return CPScrollerNoPart;
}
-- (void)checkSpaceForUsableParts
+/*
+ Check if there's enough space in the scroller to display the knob
+*/
+- (void)checkSpaceForParts
{
var bounds = [self bounds];
@@ -351,13 +386,21 @@ var _CPScrollerClassName = nil,
}
}
+/*
+ Returns all the parts of the scroller that
+ are usable for displaying.
+*/
- (CPUsableScrollerParts)usableParts
{
return _usableParts;
}
// Drawing the Parts
-
+/*
+ Draws the specified arrow and sets the highlight.
+ @param anArrow the arrow to draw
+ @param shouldHighlight sets whether the arrow should be highlighted
+*/
- (void)drawArrow:(CPScrollerArrow)anArrow highlight:(BOOL)shouldHighlight
{
var identifier = (anArrow == CPScrollerDecrementArrow ? _CPScrollerDecrementArrowIdentifier : _CPScrollerIncrementArrowIdentifier),
@@ -372,6 +415,9 @@ var _CPScrollerClassName = nil,
shouldHighlight ? _CPScrollerHighlightedIdentifier : @"")];
}
+/*
+ Draws the knob
+*/
- (void)drawKnob
{
[_knobView setBackgroundColor:_CPControlThreePartImagePattern(
@@ -383,6 +429,9 @@ var _CPScrollerClassName = nil,
_CPControlIdentifierForControlSize(_controlSize))];
}
+/*
+ Draws the knob's slot
+*/
- (void)drawKnobSlot
{
[_knobSlotView setBackgroundColor:_CPControlColorWithPatternImage(
@@ -393,6 +442,9 @@ var _CPScrollerClassName = nil,
_CPControlIdentifierForControlSize(_controlSize))];
}
+/*
+ Caches images for the scroll arrow and knob.
+*/
- (void)drawParts
{
_knobSlotView = [[CPView alloc] initWithFrame:_CGRectMakeZero()];
@@ -428,6 +480,12 @@ var _CPScrollerClassName = nil,
[self drawArrow:CPScrollerIncrementArrow highlight:NO];
}
+/*
+ Draws the scroller's arrow with a possible highlight,
+ if the user's mouse is over it.
+ @param shouldHighlight YES
will draw the
+ arrow highlighted if the mouse is hovering over it.
+*/
- (void)highlight:(BOOL)shouldHighlight
{
if (_trackingPart == CPScrollerDecrementLine)
@@ -438,12 +496,18 @@ var _CPScrollerClassName = nil,
}
// Event Handling
-
+/*
+ Returns the part of the scroller that was hit.
+*/
- (CPScrollerPart)hitPart
{
return _hitPart;
}
+/*
+ Tracks the knob.
+ @param anEvent the input event
+*/
- (void)trackKnob:(CPEvent)anEvent
{
var type = [anEvent type];
@@ -483,6 +547,10 @@ var _CPScrollerClassName = nil,
[self sendAction:[self action] to:[self target]];
}
+/*
+ Tracks the scroll button.
+ @param anEvent the input event
+*/
- (void)trackScrollButtons:(CPEvent)anEvent
{
var type = [anEvent type];
@@ -561,7 +629,7 @@ var _CPScrollerClassName = nil,
{
[super setFrameSize:aSize];
- [self checkSpaceForUsableParts];
+ [self checkSpaceForParts];
var frame = [self frame],
isHorizontal = CPRectGetWidth(frame) > CPRectGetHeight(frame);
@@ -576,6 +644,9 @@ var _CPScrollerClassName = nil,
[self layoutSubviews];
}
+/*
+ Lays out the scrollers subviews
+*/
- (void)layoutSubviews
{
[_knobSlotView setFrame:[self rectForPart:CPScrollerKnobSlot]];
diff --git a/AppKit/CPSegmentedControl.j b/AppKit/CPSegmentedControl.j
index 925f69c106..c26416cbe9 100644
--- a/AppKit/CPSegmentedControl.j
+++ b/AppKit/CPSegmentedControl.j
@@ -24,11 +24,26 @@ import aSegment
is out of bounds
+*/
- (void)setSelectedSegment:(unsigned)aSegment
{
+ // setSelected:forSegment throws the exception for us (if necessary)
[self setSelected:YES forSegment:aSegment];
}
+/*
+ Returns the selected segment.
+*/
- (unsigned)selectedSegment
{
return _selectedSegment;
}
+/*
+ Selects the button segment with the
+ specified tag.
+*/
- (BOOL)selectSegmentWithTag:(int)aTag
{
var index = 0;
@@ -172,13 +209,21 @@ CPSegmentSwitchTrackingMomentary = 2;
}
}
-- (CPSegmetnSwitchTracking)trackingMode
+/*
+ Returns the control's tracking mode.
+*/
+- (CPSegmentSwitchTracking)trackingMode
{
return _trackingMode;
}
// Working with Individual Segments
-
+/*
+ Sets the width of the specified segment.
+ @param aWidth the new width for the segment
+ @param aSegment the segment to set the width for
+ @throws CPRangeException if aSegment
is out of bounds
+*/
- (void)setWidth:(float)aWidth forSegment:(unsigned)aSegment
{
_segments[aSegment].width = aWidth;
@@ -186,11 +231,22 @@ CPSegmentSwitchTrackingMomentary = 2;
[self tileWithChangedSegment:aSegment];
}
+/*
+ Returns the width for the specified segment.
+ @param aSegment the segment to get the width for
+ @throws CPRangeException if aSegment
is out of bounds
+*/
- (float)widthForSegment:(unsigned)aSegment
{
return _segments[aSegment].width;
}
+/*
+ Sets the image for the specified segment.
+ @param anImage the image for the segment
+ @param aSegment the segment to set the image on
+ @throws CPRangeException if aSegment
is out of bounds
+*/
- (void)setImage:(CPImage)anImage forSegment:(unsigned)aSegment
{
var segment = _segments[aSegment];
@@ -223,11 +279,22 @@ CPSegmentSwitchTrackingMomentary = 2;
[self tileWithChangedSegment:aSegment];
}
+/*
+ Returns the image for the specified segment
+ @param aSegment the segment to obtain the image for
+ @throws CPRangeException if aSegment
is out of bounds
+*/
- (CPImage)imageForSegment:(unsigned)aSegment
{
return _segments[aSegment].image;
}
+/*
+ Sets the label for the specified segment
+ @param aLabel the label for the segment
+ @param aSegment the segment to label
+ @throws CPRangeException if aSegment
is out of bounds
+*/
- (void)setLabel:(CPString)aLabel forSegment:(unsigned)aSegment
{
var segment = _segments[aSegment];
@@ -262,27 +329,46 @@ CPSegmentSwitchTrackingMomentary = 2;
[self tileWithChangedSegment:aSegment];
}
-- (CPImage)labelForSegment:(unsigned)aSegment
+/*
+ Returns the label for the specified segment
+ @param the segment to obtain the label for
+ @throws CPRangeException if aSegment
is out of bounds
+*/
+- (CPString)labelForSegment:(unsigned)aSegment
{
return _segments[aSegment].label;
}
+/*
+ Sets the menu for the specified segment
+ @param aMenu the menu to set
+ @param aSegment the segment to set the menu on
+ @throws CPRangeException if aSegment
is out of bounds
+*/
- (void)setMenu:(CPMenu)aMenu forSegment:(unsigned)aSegment
{
_segments[aSegment].menu = aMenu;
}
-- (CPImage)menuForSegment:(unsigned)aSegment
+/*
+ Returns the menu for the specified segment.
+ @param aSegment the segment to obtain the menu for
+ @throws CPRangeException if aSegment
is out of bounds
+*/
+- (CPMenu)menuForSegment:(unsigned)aSegment
{
return _segments[aSegment].menu;
}
+/*
+ Sets the selection for the specified segment. If only one segment
+ can be selected at a time, any other segment will be deselected.
+ @param isSelected YES
selects the segment. NO
deselects it.
+ @param aSegment the segment to set the selection for
+ @throws CPRangeException if aSegment
is out of bounds
+*/
- (void)setSelected:(BOOL)isSelected forSegment:(unsigned)aSegment
{
- // FIXME: EXCEPTION REQUIRED
- if (aSegment < 0 || aSegment >= _segments.length)
- return;
-
var segment = _segments[aSegment];
// If we're already in this state, bail.
@@ -310,37 +396,71 @@ CPSegmentSwitchTrackingMomentary = 2;
[self drawSegmentBezel:aSegment highlight:NO];
}
-- (CPImage)isSelectedForSegment:(unsigned)aSegment
+/*
+ Returns YES
if the specified segment is selected.
+ @param aSegment the segment to check for selection
+ @throws CPRangeException if aSegment
is out of bounds
+*/
+- (BOOL)isSelectedForSegment:(unsigned)aSegment
{
return _segments[aSegment].selected;
}
+/*
+ Enables/diables the specified segment.
+ @param isEnabled YES
enables the segment
+ @param aSegment the segment to enable/disble
+ @throws CPRangeException if aSegment
is out of bounds
+*/
- (void)setEnabled:(BOOL)isEnabled forSegment:(unsigned)aSegment
{
_segments[aSegment].enabled = isEnabled;
}
-- (CPImage)isEnabledForSegment:(unsigned)aSegment
+/*
+ Returns YES
if the specified segment is enabled.
+ @param aSegment the segment to check
+ @throws CPRangeException if aSegment
is out of bounds
+*/
+- (BOOL)isEnabledForSegment:(unsigned)aSegment
{
return _segments[aSegment].enabled;
}
+/*
+ Sets a tag for the specified segment.
+ @param aTag the tag to set
+ @param aSegment the segment to set the tag on
+*/
- (void)setTag:(int)aTag forSegment:(unsigned)aSegment
{
_segments[aSegment].tag = aTag;
}
+/*
+ Returns the tag for the specified segment.
+ @param aSegment the segment to obtain the tag for
+*/
- (int)tagForSegment:(unsigned)aSegment
{
return _segments[aSegment].tag;
}
// Drawings
-
+/*
+ Draws the specified segment bezel
+ @param aSegment the segment to draw the bezel for
+ @param shouldHighlight YES
highlights the bezel
+*/
- (void)drawSegmentBezel:(int)aSegment highlgiht:(BOOL)shouldHighlight
{
}
+/*
+ Draws the specified segment
+ @param aSegment the segment to draw
+ @param shouldHighlight YES
highlights the bezel
+*/
- (void)drawSegment:(int)aSegment highlight:(BOOL)shouldHighlight
{
var segment = _segments[aSegment],
@@ -430,11 +550,20 @@ CPSegmentSwitchTrackingMomentary = 2;
[self drawSegment:aSegment highlight:NO];
}
+/*
+ Returns the bounding rectangle for the specified segment.
+ @param aSegment the segment to get the rectangle for
+*/
- (CGRect)frameForSegment:(unsigned)aSegment
{
return _segments[aSegment].frame;
}
+/*
+ Returns the segment that is hit by the specified point.
+ @param aPoint the point to test for a segment hit
+ @return the intersecting segment
+*/
- (unsigned)testSegment:(CGPoint)aPoint
{
var location = [self convertPoint:aPoint fromView:nil],
@@ -460,6 +589,10 @@ CPSegmentSwitchTrackingMomentary = 2;
{
}
+/*
+ Handles events for the segment
+ @param anEvent the event to handle
+*/
- (void)trackSegment:(CPEvent)anEvent
{
var type = [anEvent type],
diff --git a/AppKit/CPShadow.j b/AppKit/CPShadow.j
index 30b92fd526..9269d8ed4e 100644
--- a/AppKit/CPShadow.j
+++ b/AppKit/CPShadow.j
@@ -22,6 +22,9 @@
import float
, which can be retrieved by the method floatValue
and set by the method setFloatValue:
.
+*/
@implementation CPSlider : CPControl
{
double _value;
@@ -43,6 +46,9 @@ var CPSliderHorizontalKnobImage = nil
CPView _standardHorizontalBar;
}
+/*
+ @ignore
+*/
+ (void)initialize
{
if (self != [CPSlider class])
@@ -57,7 +63,7 @@ var CPSliderHorizontalKnobImage = nil
CPSliderHorizontalBarCenterImage = [[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"CPSlider/CPSliderTrackHorizontalCenter.png"] size:CPSizeMake(1.0, 4.0)];
}
-- (id)initWithFrame:(CPRect)aFrame
+- (id)initWithFrame:(CGRect)aFrame
{
self = [super initWithFrame:aFrame];
@@ -81,7 +87,7 @@ var CPSliderHorizontalKnobImage = nil
return self;
}
-- (void)setFrameSize:(CPSize)aSize
+- (void)setFrameSize:(CGSize)aSize
{
if(aSize.height > 21.0)
aSize.height = 21.0;
@@ -109,42 +115,68 @@ var CPSliderHorizontalKnobImage = nil
[_knob setFrameOrigin:[self knobPosition]];
}
-
+
+/*
+ Returns the value by which the slider will be
+ incremented if the user holds down the ALT
s key.
+*/
- (double)altIncrementValue
{
return _altIncrementValue;
}
-
+
+/*
+ Returns the thickness of the slider's knob. This value is in pixels,
+ and is the size of the knob along the slider's track.
+*/
- (float)knobThickness
{
return CPRectGetWidth([_knob frame]);
}
+/*
+ @ignore
+*/
- (CPImage)leftTrackImage
{
return CPSliderHorizontalBarLeftImage;
}
+/*
+ @ignore
+*/
- (CPImage)rightTrackImage
{
return CPSliderHorizontalBarRightImage;
}
+/*
+ @ignore
+*/
- (CPImage)centerTrackImage
{
return CPSliderHorizontalBarCenterImage
}
+/*
+ @ignore
+*/
- (CPImage)knobImage
{
return CPSliderKnobImage;
}
+/*
+ @ignore
+*/
- (CPImage)pushedKnobImage
{
return CPSliderKnobPushedImage;
}
+/*
+ Returns the slider's knob.
+*/
- (CPView)knob
{
if (!_standardKnob)
@@ -160,6 +192,9 @@ var CPSliderHorizontalKnobImage = nil
return _standardKnob;
}
+/*
+ Returns the slider's bar.
+*/
- (CPView)bar
{
// FIXME: veritcal.
@@ -185,12 +220,18 @@ var CPSliderHorizontalKnobImage = nil
}
}
+/*
+ Sets the value the slider will be incremented if the user holds the ALT
key.
+*/
- (void)setAltIncrementValue:(double)anIncrementValue
{
_altIncrementValue = anIncrementValue;
}
-- (int)isVertical
+/*
+ Returns YES
if the slider is vertical.
+*/
+- (BOOL)isVertical
{
var frame = [self frame];
@@ -200,26 +241,44 @@ var CPSliderHorizontalKnobImage = nil
return CPRectGetWidth(frame) < CPRectGetHeight(frame);
}
+/*
+ Returns the slider's maximum value
+*/
- (double)maxValue
{
return _maxValue;
}
+/*
+ Returns the slider's minimum value
+*/
- (double)minValue
{
return _minValue;
}
+/*
+ Sets the slider's maximum value
+ @param aMaxValue the new maximum value
+*/
- (void)setMaxValue:(double)aMaxValue
{
_maxValue = aMaxValue;
}
+/*
+ Sets the slider's minimum value
+ @param aMinValue the new minimum value
+*/
- (void)setMinValue:(double)aMinValue
{
_minValue = aMinValue;
}
+/*
+ Sets the slider's value
+ @param aValue the new slider value
+*/
- (void)setValue:(double)aValue
{
_value = aValue;
@@ -227,12 +286,19 @@ var CPSliderHorizontalKnobImage = nil
[_knob setFrameOrigin:[self knobPosition]];
}
+/*
+ Returns the slider's value
+*/
- (double)value
{
return _value;
}
-- (CPPoint)knobPosition
+/*
+ Returns the knob's position
+ @ignore
+*/
+- (CGPoint)knobPosition
{
if ([self isVertical])
return CPPointMake(0.0, 0.0);
@@ -242,7 +308,10 @@ var CPSliderHorizontalKnobImage = nil
(CPRectGetHeight([self frame]) - CPRectGetHeight([_knob frame])) / 2.0);
}
-- (float)valueForKnobPosition:(CPPoint)aPoint
+/*
+ @ignore
+*/
+- (float)valueForKnobPosition:(CGPoint)aPoint
{
if ([self isVertical])
return 0.0;
@@ -250,7 +319,7 @@ var CPSliderHorizontalKnobImage = nil
return MAX(MIN((aPoint.x) * (_maxValue - _minValue) / ( CPRectGetWidth([self frame]) - CPRectGetWidth([_knob frame]) ) + _minValue, _maxValue), _minValue);
}
-- (CPPoint)constrainKnobPosition:(CPPoint)aPoint
+- (CGPoint)constrainKnobPosition:(CGPoint)aPoint
{
//FIXME
aPoint.x -= _knobSize.width / 2.0;
@@ -292,6 +361,11 @@ var CPSliderMinValueKey = @"CPSliderMinValueKey",
@implementation CPSlider (CPCoding)
+/*
+ Initializes the slider from the data in a coder.
+ @param aCoder the coder from which to read the data
+ @return the initialized slider
+*/
- (id)initWithCoder:(CPCoder)aCoder
{
self = [super initWithCoder:aCoder];
@@ -316,6 +390,10 @@ var CPSliderMinValueKey = @"CPSliderMinValueKey",
return self;
}
+/*
+ Writes out the slider's instance information to a coder.
+ @param aCoder the coder to which to write the data
+*/
- (void)encodeWithCoder:(CPCoder)aCoder
{
var subviews = _subviews;
diff --git a/AppKit/CPSliderColorPicker.j b/AppKit/CPSliderColorPicker.j
index f115b1154d..ef48581af2 100644
--- a/AppKit/CPSliderColorPicker.j
+++ b/AppKit/CPSliderColorPicker.j
@@ -27,6 +27,9 @@ import Each
+CPTableColumnNoResizing; +CPTableColumnAutoresizingMask; +CPTableColumnUserResizingMask; ++ @param aMask the new resizing mask +*/ - (void)setResizingMask:(unsigned)aMask { _resizingMask = aMask; } +/* + Returns the column's resizing mask. One of: +
+CPTableColumnNoResizing; +CPTableColumnAutoresizingMask; +CPTableColumnUserResizingMask; ++*/ - (unsigned)resizingMask { return _resizingMask; } +/* + Resizes the column according to the min, max and set width. +*/ - (void)sizeToFit { var width = CPRectGetWidth([_headerView frame]); @@ -133,37 +211,63 @@ CPTableColumnUserResizingMask = 2; [self setWidth:width]; } +/* + Sets whether the column in this data is editable. + @param aFlag
YES
means the column data is editable
+*/
- (void)setEditable:(BOOL)aFlag
{
_isEditable = aFlag;
}
+/*
+ Returns YES
if the column data is editable.
+*/
- (BOOL)isEditable
{
return _isEditable;
}
+/*
+ Sets the view that draws the column's header.
+ @param aHeaderView the view that will draws the column header
+*/
- (void)setHeaderView:(CPView)aHeaderView
{
_headerView = aHeaderView;
}
+/*
+ Return the view that draws the column's header
+*/
- (CPView)headerView
{
return _headerView;
}
-- (void)setDataCell:(id)aDataCell
+/*
+ Sets the data cell that draws rows in this column.
+*/
+- (void)setDataCell:(CPCell)aDataCell
{
_dataCell = aDataCell;
}
-- (id)dataCell
+/*
+ Returns the data cell that draws rows in this column
+*/
+- (CPCell)dataCell
{
return _dataCell;
}
-- (Class)dataCellForRow:(int)aRowIndex
+/*
+ By default returns the value from dataCell
. This can
+ be overridden by a subclass to return different cells for different
+ rows.
+ @param aRowIndex the index of the row to obtain the cell for
+*/
+- (CPCell)dataCellForRow:(int)aRowIndex
{
return [self dataCell];
}
diff --git a/AppKit/CPTableView.j b/AppKit/CPTableView.j
index ed5d5aee40..8076b89940 100644
--- a/AppKit/CPTableView.j
+++ b/AppKit/CPTableView.j
@@ -26,6 +26,11 @@ import "CPTableColumn.j"
var CPTableViewCellPlaceholder = nil;
+/*
+ +- (int)numberOfRowsInTableView:(+ @param aDataSource the object with the table data + @throws CPInternalInconsistencyException ifCPTableView )aTableView +- (id)tableView:(CPTableView )aTableView objectValueForTableColumn:(CPTableColumn )aTableColumn row:(int)rowIndex +
aDataSource
doesn't implement all the required methods
+*/
- (void)setDataSource:(id)aDataSource
{
+ if (![aDataSource respondsToSelector:@selector(numberOfRowsInTableView:)])
+ [CPException raise:CPInternalInconsistencyException reason:"Data source doesn't support 'numberOfRowsInTableView:'"];
+ if (![aDataSource respondsToSelector:@selector(tableView:objectValueForTableColumn:row:)])
+ [CPException raise:CPInternalInconsistencyException reason:"Data source doesn't support 'tableView:objectValueForTableColumn:row:'"];
+
_dataSource = aDataSource;
[self reloadData];
}
+/*
+ Returns the object that has access to the table data
+*/
- (id)dataSource
{
return _dataSource;
}
-- (void)setFrameSize:(CPSize)aSize
+- (void)setFrameSize:(CGSize)aSize
{
var oldColumnHeight = [self columnHeight];
@@ -303,6 +368,10 @@ var CPTableViewCellPlaceholder = nil;
[self tile];
}
+/*
+ Tells the table view that the number of rows in the table
+ has changed.
+*/
- (void)noteNumberOfRowsChanged
{
var numberOfRows = [_dataSource numberOfRowsInTableView:self];
@@ -314,21 +383,38 @@ var CPTableViewCellPlaceholder = nil;
}
}
-- (CPRect)rectOfRow:(int)aRowIndex
+/*
+ Returns the rectangle bounding the specified row.
+ @param aRowIndex the row to obtain a rectangle for
+ @return the bounding rectangle
+*/
+- (CGRect)rectOfRow:(int)aRowIndex
{
return CPRectMake(0.0, aRowIndex * (_rowHeight + _intercellSpacing.height), CPRectGetWidth([self bounds]), _rowHeight);
}
-- (CPRect)rectOfColumn:(int)aColumnIndex
+/*
+ Returns the rectangle bounding the specified column
+ @param aColumnIndex the column to obtain a rectangle for
+ @return the bounding column
+*/
+- (CGRect)rectOfColumn:(int)aColumnIndex
{
return CPRectCreateCopy([_tableColumnViews[aColumnIndex] frame]);
}
+/*
+ Adjusts column widths to make them all visible at once. Same as tile
.
+*/
- (void)sizeToFit
{
[self tile];
}
+/*
+ Reloads the data from the dataSource
. This is an
+ expensive method, so use it lightly.
+*/
- (void)reloadData
{
_numberOfRows = [_dataSource numberOfRowsInTableView:self];
diff --git a/AppKit/CPTextField.j b/AppKit/CPTextField.j
index 67064bb9e9..6184fb61ee 100644
--- a/AppKit/CPTextField.j
+++ b/AppKit/CPTextField.j
@@ -26,15 +26,48 @@ import "CPStringDrawing.j"
#include "Platform/Platform.h"
#include "Platform/DOM/CPDOMDisplayServer.h"
-
-CPLineBreakByWordWrapping = 0,
-CPLineBreakByCharWrapping = 1,
-CPLineBreakByClipping = 2,
-CPLineBreakByTruncatingHead = 3,
-CPLineBreakByTruncatingTail = 4,
+/*
+ @global
+ @group CPLineBreakMode
+*/
+CPLineBreakByWordWrapping = 0;
+/*
+ @global
+ @group CPLineBreakMode
+*/
+CPLineBreakByCharWrapping = 1;
+/*
+ @global
+ @group CPLineBreakMode
+*/
+CPLineBreakByClipping = 2;
+/*
+ @global
+ @group CPLineBreakMode
+*/
+CPLineBreakByTruncatingHead = 3;
+/*
+ @global
+ @group CPLineBreakMode
+*/
+CPLineBreakByTruncatingTail = 4;
+/*
+ @global
+ @group CPLineBreakMode
+*/
CPLineBreakByTruncatingMiddle = 5;
+/*
+ A textfield bezel with a squared corners.
+ @global
+ @group CPTextFieldBezelStyle
+*/
CPTextFieldSquareBezel = 0;
+/*
+ A textfield bezel with rounded corners.
+ @global
+ @group CPTextFieldBezelStyle
+*/
CPTextFieldRoundedBezel = 1;
var TOP_PADDING = 4.0,
@@ -49,6 +82,9 @@ var _CPTextFieldSquareBezelColor = nil;
@implementation CPString (CPTextFieldAdditions)
+/*
+ Returns the string (self
).
+*/
- (CPString)string
{
return self;
@@ -56,6 +92,9 @@ var _CPTextFieldSquareBezelColor = nil;
@end
+/*
+ This control displays editable text in a Cappuccino application.
+*/
@implementation CPTextField : CPControl
{
BOOL _isBordered;
@@ -73,6 +112,7 @@ var _CPTextFieldSquareBezelColor = nil;
#endif
}
+/* @ignore */
#if PLATFORM(DOM)
+ (DOMElement)_inputElement
{
@@ -97,7 +137,7 @@ var _CPTextFieldSquareBezelColor = nil;
}
#endif
-- (id)initWithFrame:(CPRect)aFrame
+- (id)initWithFrame:(CGRect)aFrame
{
self = [super initWithFrame:aFrame];
@@ -125,7 +165,11 @@ var _CPTextFieldSquareBezelColor = nil;
}
// Setting the Bezel Style
-
+/*
+ Sets whether the textfield will have a bezeled border.
+ @param shouldBeBezeled YES
means the textfield
+ will draw a bezeled border
+*/
- (void)setBezeled:(BOOL)shouldBeBezeled
{
if (_isBezeled == shouldBeBezeled)
@@ -136,11 +180,19 @@ var _CPTextFieldSquareBezelColor = nil;
[self _updateBackground];
}
+/*
+ Returns YES
if the textfield draws a
+ bezeled border.
+*/
- (BOOL)isBezeled
{
return _isBezeled;
}
+/*
+ Sets the textfield's bezel style.
+ @param aBezelStyle the constant for the desired bezel style
+*/
- (void)setBezelStyle:(CPTextFieldBezelStyle)aBezelStyle
{
if (_bezelStyle == aBezelStyle)
@@ -151,11 +203,19 @@ var _CPTextFieldSquareBezelColor = nil;
[self _updateBackground];
}
+/*
+ Returns the textfield's bezel style.
+*/
- (CPTextFieldBezelStyle)bezelStyle
{
return _bezelStyle;
}
+/*
+ Sets whether the textfield will have a border drawn.
+ @param shouldBeBordered YES
makes the
+ textfield draw a border
+*/
- (void)setBordered:(BOOL)shouldBeBordered
{
if (_isBordered == shouldBeBordered)
@@ -166,11 +226,16 @@ var _CPTextFieldSquareBezelColor = nil;
[self _updateBackground];
}
+/*
+ Returns YES
if the textfield has
+ a border.
+*/
- (BOOL)isBordered
{
return _isBordered;
}
+/* @ignore */
- (void)_updateBackground
{
if (_isBordered && _bezelStyle == CPTextFieldSquareBezel && _isBezeled)
@@ -263,6 +328,10 @@ var _CPTextFieldSquareBezelColor = nil;
_isEditable = shouldBeEditable;
}
+/*
+ Returns YES
if the textfield is currently
+ editable by the user.
+*/
- (BOOL)isEditable
{
return _isEditable;
@@ -275,17 +344,30 @@ var _CPTextFieldSquareBezelColor = nil;
CPDOMDisplayServerSetStyleSize(_DOMTextElement, _frame.size.width - 2.0 * HORIZONTAL_PADDING, _frame.size.height - TOP_PADDING - BOTTOM_PADDING);
}
+/*
+ Returns YES
if the field's text is
+ selectable by the user.
+*/
- (BOOL)isSelectable
{
return _isSelectable;
}
+/*
+ Sets whether the field's text is selectable
+ by the user.
+ @param aFlag YES
makes the text selectable
+*/
- (void)setSelectable:(BOOL)aFlag
{
_isSelectable = aFlag;
}
-- (void)setAlignment:(int)anAlignment
+/*
+ Sets the alignment of the text in the field.
+ @param anAlignment
+*/
+- (void)setAlignment:(CPTextAlignment)anAlignment
{
if ([self alignment] == anAlignment)
return;
@@ -309,6 +391,10 @@ var _CPTextFieldSquareBezelColor = nil;
#endif
}
+/*
+ Sets the way line breaks occur in the text field.
+ @param aLineBreakMode the line break style
+*/
- (void)setLineBreakMode:(CPLineBreakMode)aLineBreakMode
{
_lineBreakMode = aLineBreakMode;
@@ -329,6 +415,9 @@ var _CPTextFieldSquareBezelColor = nil;
#endif
}
+/*
+ Returns the string the text field.
+*/
- (CPString)stringValue
{
// All of this needs to be better.
@@ -340,6 +429,9 @@ var _CPTextFieldSquareBezelColor = nil;
return [_value string];
}
+/*
+ Sets the string the text field.
+*/
- (void)setStringValue:(CPString)aStringValue
{
_value = aStringValue;
@@ -354,6 +446,9 @@ var _CPTextFieldSquareBezelColor = nil;
#endif
}
+/*
+ Adjusts the text field's size in the application.
+*/
- (void)sizeToFit
{
#if PLATFORM(DOM)
@@ -371,6 +466,11 @@ var CPTextFieldIsSelectableKey = @"CPTextFieldIsSelectableKey",
@implementation CPTextField (CPCoding)
+/*
+ Initializes the textfield with data from a coder.
+ @param aCoder the coder from which to read the textfield data
+ @return the initialized textfield
+*/
- (id)initWithCoder:(CPCoder)aCoder
{
#if PLATFORM(DOM)
@@ -406,6 +506,12 @@ var CPTextFieldIsSelectableKey = @"CPTextFieldIsSelectableKey",
return self;
}
+/*
+ Encodes the data of this textfield into the
+ provided coder.
+ @param aCoder the coder into which the data
+ will be written
+*/
- (void)encodeWithCoder:(CPCoder)aCoder
{
[super encodeWithCoder:aCoder];
diff --git a/AppKit/CPToolbar.j b/AppKit/CPToolbar.j
index ba07ae10bb..41fd31005f 100644
--- a/AppKit/CPToolbar.j
+++ b/AppKit/CPToolbar.j
@@ -25,14 +25,31 @@ import YES
means the item will be placed in the toolbar. NO
means the item will be displayed for
+ some other purpose (non-functional)
+ @return the toolbar item or nil
if no such item belongs in the toolbar
+*/
@implementation CPToolbar : CPObject
{
CPString _identifier;
@@ -68,6 +107,7 @@ var _CPToolbarItemVisibilityPriorityCompare = function(lhs, rhs)
CPMutableDictionary _itemIndexes;
}
+/* @ignore */
+ (void)initialize
{
if (self != [CPToolbar class])
@@ -77,6 +117,11 @@ var _CPToolbarItemVisibilityPriorityCompare = function(lhs, rhs)
CPToolbarConfigurationsByIdentifier = [CPDictionary dictionary];
}
+/*
+ Initializes the toolbar with the specified identifier.
+ @param anIdentifier the identifier for the toolbar
+ @return the initialized toolbar
+*/
- (id)initWithIdentifier:(CPString)anIdentifier
{
self = [super init];
@@ -103,26 +148,42 @@ var _CPToolbarItemVisibilityPriorityCompare = function(lhs, rhs)
return self;
}
+/*
+ Sets the toolbar's display mode. NOT YET IMPLEMENTED.
+*/
- (void)setDisplayMode:(CPToolbarDisplayMode)aDisplayMode
{
}
+/*
+ Returns the toolbar's identifier
+*/
- (CPString)identifier
{
return _identifier;
}
+/*
+ Returns the toolbar's delegate
+*/
- (id)delegate
{
return _delegate;
}
+/*
+ Returns YES
if the toolbar is currently visible
+*/
- (BOOL)isVisible
{
return _isVisible;
}
+/*
+ Sets whether the toolbar should be visible.
+ @param aFlag YES
makes the toolbar visible
+*/
- (void)setVisible:(BOOL)aFlag
{
if (_isVisible == aFlag)
@@ -134,6 +195,10 @@ var _CPToolbarItemVisibilityPriorityCompare = function(lhs, rhs)
[self _reloadToolbarItems];
}
+/*
+ Sets the delegate for the toolbar.
+ @param aDelegate the new toolbar delegate
+*/
- (void)setDelegate:(id)aDelegate
{
if (_delegate == aDelegate)
@@ -148,11 +213,13 @@ var _CPToolbarItemVisibilityPriorityCompare = function(lhs, rhs)
[self _reloadToolbarItems];
}
+/* @ignore */
- (void)_loadConfiguration
{
}
+/* @ignore */
- (CPView)_toolbarView
{
if (!_toolbarView)
@@ -166,6 +233,7 @@ var _CPToolbarItemVisibilityPriorityCompare = function(lhs, rhs)
return _toolbarView;
}
+/* @ignore */
- (void)_reloadToolbarItems
{
if (![_toolbarView superview] || !_delegate)
@@ -210,16 +278,26 @@ var _CPToolbarItemVisibilityPriorityCompare = function(lhs, rhs)
[_toolbarView reloadToolbarItems];
}
-- (void)items
+/*
+ Returns all the items in this toolbar.
+*/
+- (CPArray)items
{
return _items;
}
+/*
+ Returns all the visible items in this toolbar
+*/
- (CPArray)visibleItems
{
return [_toolbarView visibleItems];
}
+/*
+ Returns the index of the specified toolbar item
+ @param anItem the item to obtain the index for
+*/
- (int)indexOfItem:(CPToolbarItem)anItem
{
var info = [_itemIndexes objectForKey:[anItem hash]];
@@ -230,6 +308,9 @@ var _CPToolbarItemVisibilityPriorityCompare = function(lhs, rhs)
return info.index;
}
+/*
+ Returns the toolbar items sorted by their visibilityPriority
(ies).
+*/
- (CPArray)itemsSortedByVisibilityPriority
{
return _itemsSortedByVisibilityPriority;
@@ -251,6 +332,7 @@ var _CPToolbarItemInfoMake = function(anIndex, aView, aLabel, aMinWidth)
return { index:anIndex, view:aView, label:aLabel, minWidth:aMinWidth };
}
+/* @ignore */
@implementation _CPToolbarView : CPView
{
CPToolbar _toolbar;
diff --git a/AppKit/CPToolbarItem.j b/AppKit/CPToolbarItem.j
index 1a3dc9926a..454b21e080 100644
--- a/AppKit/CPToolbarItem.j
+++ b/AppKit/CPToolbarItem.j
@@ -26,10 +26,25 @@ import nil
will cause
+ the action to be passed on to the first responder.
+ @param aTarget the new target
+*/
- (void)setTarget:(id)aTarget
{
_target = aTarget;
@@ -145,11 +210,18 @@ CPToolbarPrintItemIdentifier = @"CPToolbarPrintItemIdentifier";
[_view setTarget:aTarget];
}
+/*
+ Returns the action that is triggered when the user clicks this item.
+*/
- (SEL)action
{
return _action;
}
+/*
+ Sets the action that is triggered when the user clicks this item.
+ @param anAction the new action
+*/
- (void)setAction:(SEL)anAction
{
_action = anAction;
@@ -157,21 +229,35 @@ CPToolbarPrintItemIdentifier = @"CPToolbarPrintItemIdentifier";
[_view setAction:anAction];
}
+/*
+ Returns YES
if the item is enabled.
+*/
- (BOOL)isEnabled
{
return _isEnabled;
}
+/*
+ Sets whether the item is enabled.
+ @param aFlag YES
enables the item
+*/
- (void)setEnabled:(BOOL)aFlag
{
_isEnabled = aFlag;
}
+/*
+ Returns the item's image
+*/
- (CPImage)image
{
return _image;
}
+/*
+ Sets the item's image.
+ @param anImage the new item image
+*/
- (void)setImage:(CPImage)anImage
{
_image = anImage;
@@ -179,6 +265,10 @@ CPToolbarPrintItemIdentifier = @"CPToolbarPrintItemIdentifier";
[_view setImage:anImage];
}
+/*
+ Sets the alternate image. This image is displayed on the item when the user is clicking it.
+ @param anImage the new alternate image
+*/
- (void)setAlternateImage:(CPImage)anImage
{
_alternateImage = anImage;
@@ -186,48 +276,90 @@ CPToolbarPrintItemIdentifier = @"CPToolbarPrintItemIdentifier";
[_view setAlternateImage:anImage];
}
+/*
+ Returns the alternate image. This image is displayed on the item when the user is clicking it.
+*/
- (CPImage)alternateImage
{
return _alternateImage;
}
+/*
+ Returns the item's view.
+*/
- (CPView)view
{
return _view;
}
+/*
+ Sets the item's view
+ @param aView the item's new view
+*/
- (void)setView:(CPView)aView
{
_view = aView;
}
+/*
+ Returns the item's minimum size.
+*/
- (CGSize)minSize
{
return _minSize;
}
+/*
+ Sets the item's minimum size.
+ @param aMinSize the new minimum size
+*/
- (void)setMinSize:(CGSize)aMinSize
{
_minSize = CGSizeCreateCopy(aMinSize);
}
+/*
+ Returns the item's maximum size.
+*/
- (CGSize)maxSize
{
return _maxSize;
}
+/*
+ Sets the item's new maximum size.
+ @param aMaxSize the new maximum size
+*/
- (void)setMaxSize:(CGSize)aMaxSize
{
_maxSize = CGSizeCreateCopy(aMaxSize);
}
// Visibility Priority
-
+/*
+ Returns the item's visibility priority. The value will be one of:
++CPToolbarItemVisibilityPriorityStandard +CPToolbarItemVisibilityPriorityLow +CPToolbarItemVisibilityPriorityHigh +CPToolbarItemVisibilityPriorityUser ++*/ - (int)visibilityPriority { return _visibilityPriority; } +/* + Sets the item's visibility priority. The value must be one of: +
+CPToolbarItemVisibilityPriorityStandard +CPToolbarItemVisibilityPriorityLow +CPToolbarItemVisibilityPriorityHigh +CPToolbarItemVisibilityPriorityUser ++ @param aVisiblityPriority the priority +*/ - (void)setVisibilityPriority:(int)aVisibilityPriority { _visibilityPriority = aVisibilityPriority; @@ -270,6 +402,7 @@ CPToolbarPrintItemIdentifier = @"CPToolbarPrintItemIdentifier"; @implementation CPToolbarItem (Standard) +/* @ignore */ + (CPToolbarItem)_standardItemWithItemIdentifier:(CPString)anItemIdentifier { var item = [[CPToolbarItem alloc] initWithItemIdentifier:anItemIdentifier]; diff --git a/AppKit/CPView.j b/AppKit/CPView.j index 51cf412de8..e72a2cec74 100644 --- a/AppKit/CPView.j +++ b/AppKit/CPView.j @@ -65,6 +65,20 @@ var DOMCanvasElementZIndex = -1, BackgroundNinePartImage = 3; #endif +/* +
In order to display itself, a view must be placed in a window (represented by an
+
Subclasses can override -drawRect:
in order to implement their
+ appearance. Other methods of aSubview
a subview of the receiver. It is positioned relative to anotherView
+ @param aSubview the view to add as a subview
+ @param anOrderingMode specifies aSubview
's ordering relative to anotherView
+ @param anotherView aSubview
will be positioned relative to this argument
+*/
- (void)addSubview:(CPView)aSubview positioned:(CPWindowOrderingMode)anOrderingMode relativeTo:(CPView)anotherView
{
var index = anotherView ? [_subviews indexOfObjectIdenticalTo:anotherView] : CPNotFound;
@@ -208,6 +251,7 @@ var DOMCanvasElementZIndex = -1,
[self _insertSubview:aSubview atIndex:index];
}
+/* @ignore */
- (void)_insertSubview:(CPView)aSubview atIndex:(int)anIndex
{
// We will have to adjust the z-index of all views starting at this index.
@@ -270,10 +314,18 @@ var DOMCanvasElementZIndex = -1,
[self didAddSubview:aSubview];
}
+/*
+ Called when the receiver has added aSubview
to it's child views.
+ @param aSubview the view that was added
+*/
- (void)didAddSubview:(CPView)aSubview
{
}
+/*
+ Removes the receiver from it's container view and window.
+ Does nothing if there's no container view.
+*/
- (void)removeFromSuperview
{
if (!_superview)
@@ -291,6 +343,11 @@ var DOMCanvasElementZIndex = -1,
[self _setWindow:nil];
}
+/*
+ Replaces the specified child view with another view
+ @param aSubview the view to replace
+ @param aView the replacement view
+*/
- (void)replaceSubview:(CPView)aSubview with:(CPView)aView
{
if (aSubview._superview != self)
@@ -303,6 +360,7 @@ var DOMCanvasElementZIndex = -1,
[aView _insertSubview:aView atIndex:index];
}
+/* @ignore */
- (void)_setWindow:(CPWindow)aWindow
{
// FIXME: check _window == aWindow? If not, comment why!
@@ -318,6 +376,10 @@ var DOMCanvasElementZIndex = -1,
[self viewDidMoveToWindow];
}
+/*
+ Returns YES
if the receiver is, or is a descendant of, aView
.
+ @param aView the view to test for ancestry
+*/
- (BOOL)isDescendantOf:(CPView)aView
{
var view = self;
@@ -331,28 +393,50 @@ var DOMCanvasElementZIndex = -1,
return NO;
}
+/*
+ Called when the receiver's superview has changed.
+*/
- (void)viewDidMoveToSuperview
{
if (_graphicsContext)
[self setNeedsDisplay:YES];
}
+/*
+ Called when the receiver has been moved to a new nil
if the view or one of its ancestors wasn't found
+*/
- (CPMenuItem)enclosingMenuItem
{
var view = self;
@@ -373,12 +457,23 @@ var DOMCanvasElementZIndex = -1,
return enclosingMenuItem;*/
}
+/*
+ Returns whether the view is flipped.
+ @return YES
if the view is flipped. NO
, otherwise.
+*/
- (BOOL)isFlipped
{
return YES;
}
-- (void)setFrame:(CPRect)aFrame
+/*
+ Sets the frame size of the receiver to the dimensions and origin of the provided rectangle in the coordinate system
+ of the superview. The method also posts an aSize
is the same as the frame's current dimensions, this
+ method simply returns. The method posts a superviewSizeChanged:
messages to subviews.
+ @param aSize the size for the subviews
+*/
+- (void)resizeSubviewsWithOldSize:(CGSize)aSize
{
var count = _subviews.length;
@@ -601,28 +743,50 @@ var DOMCanvasElementZIndex = -1,
[_subviews[count] resizeWithOldSuperviewSize:aSize];
}
+/*
+ Specifies whether the receiver view should automatically resize its
+ subviews when its setFrameSize:
method receives a change.
+ @param aFlag If YES
, then subviews will automatically be resized
+ when this view is resized. NO
means the views will not
+ be resized automatically.
+*/
- (void)setAutoresizesSubviews:(BOOL)aFlag
{
_autoresizesSubviews = aFlag;
}
+/*
+ Reports whether the receiver automatically resizes its subviews when its frame size changes.
+ @return YES
means it resizes its subviews on a frame size change.
+*/
- (BOOL)autoresizesSubviews
{
return _autoresizesSubviews;
}
+/*
+ Determines automatic resizing behavior.
+ @param aMask a bit mask with options
+*/
- (void)setAutoresizingMask:(unsigned)aMask
{
_autoresizingMask = aMask;
}
+/*
+ Returns the bit mask options for resizing behavior
+*/
- (unsigned)autoresizingMask
{
return _autoresizingMask;
}
// Fullscreen Mode
-
+/*
+ Puts the receiver into full screen mode.
+ @param aScreen the that should be used
+ @param options configuration options
+*/
- (BOOL)enterFullScreenMode:(CPScreen)aScreen withOptions:(CPDictionary)options
{
_fullScreenModeState = _CPViewFullScreenModeStateMake(self);
@@ -649,6 +813,10 @@ var DOMCanvasElementZIndex = -1,
return YES;
}
+/*
+ The receiver should exit full screen mode.
+ @param options configurations options
+*/
- (void)exitFullScreenModeWithOptions:(CPDictionary)options
{
if (!_isInFullScreenMode)
@@ -663,11 +831,18 @@ var DOMCanvasElementZIndex = -1,
[[self window] orderOut:self];
}
+/*
+ Returns YES
if the receiver is currently in full screen mode.
+*/
- (BOOL)isInFullScreenMode
{
return _isInFullScreenMode;
}
+/*
+ Sets whether the receiver should be hidden.
+ @param aFlag YES
makes the receiver hidden.
+*/
- (void)setHidden:(BOOL)aFlag
{
if(_isHidden == aFlag)
@@ -680,11 +855,19 @@ var DOMCanvasElementZIndex = -1,
#endif
}
+/*
+ Returns YES
if the receiver is hidden.
+*/
- (BOOL)isHidden
{
return _isHidden;
}
+/*
+ Sets the opacity of the receiver. The value must be in the range of 0.0 to 1.0, where 0.0 is
+ completely transparent and 1.0 is completely opaque.
+ @param anAlphaValue an alpha value ranging from 0.0 to 1.0.
+*/
- (void)setAlphaValue:(float)anAlphaValue
{
if (_opacity == anAlphaValue)
@@ -702,21 +885,19 @@ var DOMCanvasElementZIndex = -1,
#endif
}
+/*
+ Returns the alpha value of the receiver. Ranges from 0.0 to
+ 1.0, where 0.0 is completely transparent and 1.0 is completely opaque.
+*/
- (float)alphaValue
{
return _opacity;
}
-- (void)setOpacity:(float)anOpacity
-{
- [self setAlphaValue:anOpacity];
-}
-
-- (float)opacity
-{
- return _opacity;
-}
-
+/*
+ Returns YES
if the receiver is hidden, or one
+ of it's ancestor views is hidden. NO
, otherwise.
+*/
- (BOOL)isHiddenOrHasHiddenAncestor
{
var view = self;
@@ -727,21 +908,36 @@ var DOMCanvasElementZIndex = -1,
return view != nil;
}
+/*
+ Returns whether the receiver should be sent a mouseDown:
message for anEvent
.
+ Returns YES
by default.
+ @return YES
, if the view object accepts first mouse-down event. NO
, otherwise.
+*/
+//FIXME: should be NO by default?
- (BOOL)acceptsFirstMouse:(CPEvent)anEvent
{
return YES;
}
+/*
+ @ignore
+*/
- (BOOL)hitTests
{
return YES;
}
+/*
+ @ignore
+*/
- (void)setHitTests:(BOOL)shouldHitTest
{
_hitTests = shouldHitTest;
}
+/*
+ @ignore
+*/
- (CPView)hitTest:(CPPoint)aPoint
{
if(_isHidden || !_hitTests || !CPRectContainsPoint(_frame, aPoint))
@@ -761,6 +957,10 @@ var DOMCanvasElementZIndex = -1,
return self;
}
+/*
+ Returns YES
if mouse events aren't needed by the receiver and can be sent to the superview. The
+ default implementation returns NO
if the view is opaque.
+*/
- (BOOL)mouseDownCanMoveWindow
{
return ![self isOpaque];
@@ -772,6 +972,10 @@ var DOMCanvasElementZIndex = -1,
[super mouseDown:anEvent];
}
+/*
+ Sets the background color of the receiver.
+ @param aColor the new color for the receiver's background
+*/
- (void)setBackgroundColor:(CPColor)aColor
{
if (_backgroundColor == aColor)
@@ -883,43 +1087,93 @@ var DOMCanvasElementZIndex = -1,
#endif
}
+/*
+ Returns the background color of the receiver
+*/
- (CPColor)backgroundColor
{
return _backgroundColor;
}
// Converting Coordinates
-
+/*
+ Converts aPoint
from the coordinate space of aView
to the coordinate space of the receiver.
+ @param aPoint the point to convert
+ @param aView the view space to convert from
+ @return the converted point
+*/
- (CGPoint)convertPoint:(CGPoint)aPoint fromView:(CPView)aView
{
return CGPointApplyAffineTransform(aPoint, _CPViewGetTransform(aView, self));
}
+/*
+ Converts aPoint
from the receiver's coordinate space to the coordinate space of aView
.
+ @param aPoint the point to convert
+ @param aView the coordinate space to which the point will be converted
+ @return the converted point
+*/
- (CGPoint)convertPoint:(CGPoint)aPoint toView:(CPView)aView
{
return CGPointApplyAffineTransform(aPoint, _CPViewGetTransform(self, aView));
}
+/*
+ Convert's aSize
from aView
's coordinate space to the receiver's coordinate space.
+ @param aSize the size to convert
+ @param aView the coordinate space to convert from
+ @return the converted size
+*/
- (CGSize)convertSize:(CGSize)aSize fromView:(CPView)aView
{
return CGSizeApplyAffineTransform(aSize, _CPViewGetTransform(aView, self));
}
+/*
+ Convert's aSize
from the receiver's coordinate space to aView
's coordinate space.
+ @param aSize the size to convert
+ @param the coordinate space to which the size will be converted
+ @return the converted size
+*/
- (CGSize)convertSize:(CGSize)aSize toView:(CPView)aView
{
return CGSizeApplyAffineTransform(aSize, _CPViewGetTransform(self, aView));
}
+/*
+ Converts aRect
from aView
's coordinate space to the receiver's space.
+ @param aRect the rectangle to convert
+ @param aView the coordinate space from which to convert
+ @return the converted rectangle
+*/
- (CGRect)convertRect:(CGRect)aRect fromView:(CPView)aView
{
return CGRectApplyAffineTransform(aRect, _CPViewGetTransform(aView, self));
}
-
+
+/*
+ Converts aRect
from the receiver's coordinate space to aView
's coordinate space.
+ @param aRect the rectangle to convert
+ @param aView the coordinate space to which the rectangle will be converted
+ @return the converted rectangle
+*/
- (CGRect)convertRect:(CGRect)aRect toView:(CPView)aView
{
return CGRectApplyAffineTransform(aRect, _CPViewGetTransform(self, aView));
}
+/*
+ Sets whether the receiver posts a NO
.
+ Methods that could cause a frame change notification are:
+
+setFrame: +setFrameSize: +setFrameOrigin: ++ @param shouldPostFrameChangedNotifications
YES
makes the receiver post
+ notifications on frame changes (size or origin)
+*/
- (void)setPostsFrameChangedNotifications:(BOOL)shouldPostFrameChangedNotifications
{
if (_postsFrameChangedNotifications == shouldPostFrameChangedNotifications)
@@ -931,11 +1185,26 @@ var DOMCanvasElementZIndex = -1,
[_CPViewNotificationCenter postNotificationName:CPViewFrameDidChangeNotification object:self];
}
+/*
+ Returns YES
if the receiver posts a NO
.
+ Methods that could cause a bounds change notification are:
++setBounds: +setBoundsSize: +setBoundsOrigin: ++ @param shouldPostBoundsChangedNotifications
YES
makes the receiver post
+ notifications on bounds changes
+*/
- (void)setPostsBoundsChangedNotifications:(BOOL)shouldPostBoundsChangedNotifications
{
if (_postsBoundsChangedNotifications == shouldPostBoundsChangedNotifications)
@@ -947,45 +1216,85 @@ var DOMCanvasElementZIndex = -1,
[_CPViewNotificationCenter postNotificationName:CPViewBoundsDidChangeNotification object:self];
}
+/*
+ Returns YES
if the receiver posts a
+ anImage
+ @param mouseOffset the distance from the mouseDown:
location and the current location
+ @param anEvent the mouseDown:
that triggered the drag
+ @param aPastebaord the pasteboard that holds the drag data
+ @param aSourceObject the drag operation controller
+ @param slideBack Whether the image should 'slide back' if the drag is rejected
+*/
+- (void)dragImage:(CPImage)anImage at:(CGPoint)aLocation offset:(CGSize)mouseOffset event:(CPEvent)anEvent pasteboard:(CPPasteboard)aPasteboard source:(id)aSourceObject slideBack:(BOOL)slideBack
{
[_window dragImage:anImage at:[self convertPoint:aLocation toView:nil] offset:mouseOffset event:anEvent pasteboard:aPasteboard source:aSourceObject slideBack:slideBack];
}
+/*
+ Initiates a drag operation from the receiver to another view that accepts dragged data.
+ @param aView the view to be dragged
+ @param aLocation the lower-left corner coordinate of aView
+ @param mouseOffset the distance from the mouseDown:
location and the current location
+ @param anEvent the mouseDown:
that triggered the drag
+ @param aPastebaord the pasteboard that holds the drag data
+ @param aSourceObject the drag operation controller
+ @param slideBack Whether the view should 'slide back' if the drag is rejected
+*/
- (void)dragView:(CPView)aView at:(CPPoint)aLocation offset:(CPSize)mouseOffset event:(CPEvent)anEvent pasteboard:(CPPasteboard)aPasteboard source:(id)aSourceObject slideBack:(BOOL)slideBack
{
[_window dragView:aView at:[self convertPoint:aLocation toView:nil] offset:mouseOffset event:anEvent pasteboard:aPasteboard source:aSourceObject slideBack:slideBack];
}
+/*
+ Sets the receiver's list of acceptable data types for a dragging operation.
+ @param pasteboardTypes an array of aRect
. This method should be overridden by subclasses.
+ @param aRect the area that should be drawn into
+*/
- (void)drawRect:(CPRect)aRect
{
}
// Focus
-
+/*
+ Locks focus on the receiver, so drawing commands apply to it.
+*/
- (void)lockFocus
{
// If we don't yet have a graphics context, then we must first create a
@@ -1018,6 +1327,9 @@ var DOMCanvasElementZIndex = -1,
CGContextSaveGState([_graphicsContext graphicsPort]);
}
+/*
+ Takes focus away from the receiver, and restores it to the previous view.
+*/
- (void)unlockFocus
{
var graphicsPort = [_graphicsContext graphicsPort];
@@ -1028,39 +1340,61 @@ var DOMCanvasElementZIndex = -1,
}
// Displaying
-
+/*
+ Marks the entire view as dirty, and needing a redraw.
+*/
- (void)setNeedsDisplay:(BOOL)aFlag
{
if (aFlag)
[self display];
}
-- (void)setNeedsDisplayInRect:(CPRect)aRect
+/*
+ Marks the area denoted by aRect
as dirty, and initiates a redraw on it.
+ @param aRect the area that needs to be redrawn
+*/
+- (void)setNeedsDisplayInRect:(CGRect)aRect
{
[self displayRect:aRect];
}
+/*
+ Displays the receiver and any of its subviews that need to be displayed.
+*/
- (void)displayIfNeeded
{
}
+/*
+ Draws the entire area of the receiver as defined by its bounds
.
+*/
- (void)display
{
[self displayRect:_bounds];
}
-- (void)displayRect:(CPRect)aRect
+/*
+ Draws the receiver into the area defined by aRect
.
+ @param aRect the area to be drawn
+*/
+- (void)displayRect:(CGRect)aRect
{
[self lockFocus];
[self drawRect:aRect];
[self unlockFocus];
}
+/*
+ Returns whether the receiver is completely opaque. By default, returns NO
.
+*/
- (BOOL)isOpaque
{
return NO;
}
+/*
+ Returns the rectangle of the receiver not clipped by its superview.
+*/
- (CGRect)visibleRect
{
if (!_superview)
@@ -1070,7 +1404,7 @@ var DOMCanvasElementZIndex = -1,
}
// Scrolling
-
+/* @ignore */
- (CPScrollView)_enclosingClipView
{
var superview = _superview,
@@ -1082,6 +1416,10 @@ var DOMCanvasElementZIndex = -1,
return superview;
}
+/*
+ Changes the receiver's frame origin to a 'constrained' aPoint
.
+ @param aPoint the proposed frame origin
+*/
- (void)scrollPoint:(CGPoint)aPoint
{
var clipView = [self _enclosingClipView];
@@ -1092,6 +1430,11 @@ var DOMCanvasElementZIndex = -1,
[clipView scrollToPoint:[self convertPoint:aPoint toView:clipView]];
}
+/*
+ Scrolls the nearest ancestor aRect
can become visible.
+ @param aRect the area to become visible
+ @return NO
otherwise.
+*/
- (BOOL)scrollRectToVisible:(CGRect)aRect
{
var visibleRect = [self visibleRect];
@@ -1127,22 +1470,38 @@ var DOMCanvasElementZIndex = -1,
return YES;
}
+/*
+ FIXME Not yet implemented
+*/
- (BOOL)autoscroll:(CPEvent)anEvent
{
// FIXME: Implement.
return NO;
}
+/*
+ Subclasses can override this to modify the visible rectangle after a
+ scrolling operation. The default implementation simply returns the provided rectangle.
+ @param proposedVisibleRect the rectangle to alter
+ @return the same adjusted rectangle
+*/
- (CGRect)adjustScroll:(CGRect)proposedVisibleRect
{
return proposedVisibleRect;
}
+/*
+ Should be overridden by subclasses.
+*/
- (void)scrollRect:(CGRect)aRect by:(float)anAmount
{
}
+/*
+ Returns the YES
means the receiver wants a layer.
+*/
- (void)setWantsLayer:(BOOL)aFlag
{
_wantsLayer = aFlag;
}
-- (CALayer)wantsLayer
+/*
+ Returns YES
if the receiver uses a YES
if the receiver uses a Each window has a style, which determines how the window is decorated; whether it has a border, a title bar, a resize bar, minimise and close buttons.
+ +A window has a frame. This is the frame of the entire window on the screen, including all decorations and borders. The origin of the frame represents its bottom left corner and the frame is expressed in screen coordinates.
+ +A window always contains a content view which is the highest level view available for public (application) use. This view fills the area of the window inside any decoration/border. This is the only part of the window that application programmers are allowed to draw in directly.
+ +You can convert between view coordinates and window base coordinates using the YES
allows the window to close. NO
+ vetoes the close operation and leaves the window open.
+*/
@implementation CPWindow : CPResponder
{
int _windowNumber;
@@ -133,6 +276,10 @@ var CPWindowSaveImage = nil,
BOOL _delegateRespondsToWindowWillReturnUndoManagerSelector;
}
+/*
+ Private initializer for Objective-J
+ @ignore
+*/
+ (void)initialize
{
if (self != [CPWindow class])
@@ -145,11 +292,43 @@ var CPWindowSaveImage = nil,
CPWindowSavingImage = [[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"CPProgressIndicator/CPProgressIndicatorSpinningStyleRegular.gif"] size:CGSizeMake(16.0, 16.0)]
}
+/*
+ Initializes the window. The method also takes a style bit mask made up
+ of any of the following values:
+
+CPBorderlessWindowMask +CPTitledWindowMask +CPClosableWindowMask +CPMiniaturizableWindowMask +CPResizableWindowMask +CPTexturedBackgroundWindowMask ++ @param aContentRect the size and location of the window in screen space + @param aStyleMask a style mask + @return the initialized window +*/ - (id)initWithContentRect:(CGRect)aContentRect styleMask:(unsigned int)aStyleMask { return [self initWithContentRect:aContentRect styleMask:aStyleMask bridge:[CPDOMWindowBridge sharedDOMWindowBridge]]; } +/* + Initializes the window. The method also takes a style bit mask made up + of any of the following values: +
+CPBorderlessWindowMask +CPTitledWindowMask +CPClosableWindowMask +CPMiniaturizableWindowMask +CPResizableWindowMask +CPTexturedBackgroundWindowMask ++ @param aContentRect the size and location of the window in screen space + @param aStyleMask a style mask + @param aBridge a DOM-Window bridge object + @return the initialized window + @ignore +*/ - (id)initWithContentRect:(CGRect)aContentRect styleMask:(unsigned int)aStyleMask bridge:(CPDOMWindowBridge)aBridge { self = [super init]; @@ -205,11 +384,20 @@ var CPWindowSaveImage = nil, return self; } +/* + Returns the window's style mask. +*/ - (unsigned)styleMask { return _styleMask; } +/* + Returns the frame rectangle used by a window. + @param aContentRect the content rectangle of the window + @param aStyleMask the style mask of the window + @return the matching window's frame rectangle +*/ + (CGRect)frameRectForContentRect:(CGRect)aContentRect styleMask:(unsigned)aStyleMask { var frame = CGRectMakeCopy(aContentRect); @@ -217,6 +405,10 @@ var CPWindowSaveImage = nil, return frame; } +/* + Returns the receiver's content rectangle. A content rectangle does not include toolbars. + @param aFrame the window's frame rectangle +*/ - (CGRect)contentRectForFrameRect:(CGRect)aFrame { // FIXME: EXTRA RECT COPY @@ -246,6 +438,11 @@ var CPWindowSaveImage = nil, return contentRect; } +/* + Retrieves the frame rectangle for this window. + @param aContentRect the window's content rectangle + @return the window's frame rectangle +*/ - (CGRect)frameRectForContentRect:(CGRect)aContentRect { if (_styleMask & CPBorderlessBridgeWindowMask) @@ -256,11 +453,21 @@ var CPWindowSaveImage = nil, return frame; } +/* + Returns the window's frame rectangle +*/ - (CGRect)frame { return _frame; } +/* + Sets the window's frame rectangle. Also tells the window whether it should animate + 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 +*/ - (void)setFrame:(CGRect)aFrame display:(BOOL)shouldDisplay animate:(BOOL)shouldAnimate { if (shouldAnimate) @@ -276,11 +483,18 @@ var CPWindowSaveImage = nil, } } +/* + Sets the window's frame rectangle +*/ - (void)setFrame:(CGRect)aFrame { [self setFrame:aFrame display:YES animate:NO]; } +/* + Sets the window's location. + @param anOrigin the new location for the window +*/ - (void)setFrameOrigin:(CGPoint)anOrigin { var origin = _frame.origin; @@ -296,6 +510,10 @@ var CPWindowSaveImage = nil, #endif } +/* + Sets the window's size. + @param aSize the new size for the window +*/ - (void)setFrameSize:(CGSize)aSize { aSize = _CGSizeMake(MIN(MAX(aSize.width, _minSize.width), _maxSize.width), MIN(MAX(aSize.height, _minSize.height), _maxSize.height)); @@ -314,6 +532,9 @@ var CPWindowSaveImage = nil, [_delegate windowDidResize:self]; } +/* + @ignore +*/ - (void)trackMoveWithEvent:(CPEvent)anEvent { var type = [anEvent type]; @@ -336,6 +557,9 @@ var CPWindowSaveImage = nil, [CPApp setTarget:self selector:@selector(trackMoveWithEvent:) forNextEventMatchingMask:CPLeftMouseDraggedMask | CPLeftMouseUpMask untilDate:nil inMode:nil dequeue:YES]; } +/* + @ignore +*/ - (void)trackResizeWithEvent:(CPEvent)anEvent { var location = [anEvent locationInWindow], @@ -353,16 +577,29 @@ var CPWindowSaveImage = nil, [CPApp setTarget:self selector:@selector(trackResizeWithEvent:) forNextEventMatchingMask:CPLeftMouseDraggedMask | CPLeftMouseUpMask untilDate:nil inMode:nil dequeue:YES]; } +/* + Makes the receiver the front most window in the screen ordering. + @param aSender the object that requested this +*/ - (void)orderFront:(id)aSender { [_bridge order:CPWindowAbove window:self relativeTo:nil]; } +/* + Makes the receiver the last window in the screen ordering. + @param aSender the object that requested this + @ignore +*/ - (void)orderBack:(id)aSender { //[_bridge order:CPWindowBelow } +/* + Hides the window. + @param the object that requested this +*/ - (void)orderOut:(id)aSender { if ([_delegate respondsToSelector:@selector(windowWillClose:)]) @@ -378,46 +615,80 @@ var CPWindowSaveImage = nil, } } +/* + Relocates the window in the screen list. + @param aPlace the positioning relative to
otherWindowNumber
+ @param otherWindowNumber the window relative to which the receiver should be placed
+*/
- (void)orderWindow:(CPWindowOrderingMode)aPlace relativeTo:(int)otherWindowNumber
{
[_bridge order:aPlace window:self relativeTo:CPApp._windows[otherWindowNumber]];
}
+/*
+ Sets the window's level
+ @param the window's new level
+*/
- (void)setLevel:(int)aLevel
{
_level = aLevel;
}
+/*
+ Returns the window's current level
+*/
- (int)level
{
return _level;
}
+/*
+ Returns YES
if the window is visible. It does not mean that the window is not obscured by other windows.
+*/
- (BOOL)isVisible
{
return _isVisible;
}
+/*
+ Returns YES
if the window's resize indicator is showing. NO
otherwise.
+*/
- (BOOL)showsResizeIndicator
{
return [_windowView showsResizeIndicator];
}
+/*
+ Sets the window's resize indicator.
+ @param shouldShowResizeIndicator YES
sets the window to show its resize indicator.
+*/
- (void)setShowsResizeIndicator:(BOOL)shouldShowResizeIndicator
{
[_windowView setShowsResizeIndicator:shouldShowResizeIndicator];
}
+/*
+ Returns the offset of the window's resize indicator.
+*/
- (CGSize)resizeIndicatorOffset
{
return [_windowView resizeIndicatorOffset];
}
+/*
+ Sets the offset of the window's resize indicator.
+ @param aSize the offset for the resize indicator
+*/
- (void)setResizeIndicatorOffset:(CGSize)anOffset
{
[_windowView setResizeIndicatorOffset:anOffset];
}
+/*
+ Sets the window's content view. The new view will be resized to fit
+ inside the content rectangle of the window.
+ @param aView the new content view for the receiver
+*/
- (void)setContentView:(CPView)aView
{
if (_contentView)
@@ -430,21 +701,36 @@ var CPWindowSaveImage = nil,
[_windowView addSubview:_contentView positioned:CPWindowBelow relativeTo:nil];
}
+/*
+ Returns the window's current content view.
+*/
- (CPView)contentView
{
return _contentView;
}
+/*
+ Sets the window's background color.
+ @param aColor the new color for the background
+*/
- (void)setBackgroundColor:(CPColor)aColor
{
[_windowView setBackgroundColor:aColor];
}
+/*
+ Returns the window's background color.
+*/
- (CPColor)backgroundColor
{
return [_windowView backgroundColor];
}
+/*
+ Sets the window's minimum size. If the provided
+ size is the same as the current minimum size, the method simply returns.
+ @aSize the new minimum size for the window
+*/
- (void)setMinSize:(CGSize)aSize
{
if (CGSizeEqualToSize(_minSize, aSize))
@@ -471,11 +757,20 @@ var CPWindowSaveImage = nil,
[self setFrameSize:size];
}
+/*
+ Returns the windows minimum size.
+*/
- (CGSize)minSize
{
return _minSize;
}
+/*
+ Sets the window's maximum size. If the provided
+ size is the same as the current maximum size,
+ the method simply returns.
+ @param aSize the new maximum size
+*/
- (void)setMaxSize:(CGSize)aSize
{
if (CGSizeEqualToSize(_maxSize, aSize))
@@ -502,16 +797,26 @@ var CPWindowSaveImage = nil,
[self setFrameSize:size];
}
+/*
+ Returns the window's maximum size.
+*/
- (CGSize)maxSize
{
return _maxSize;
}
+/*
+ Returns YES
if the window has a drop shadow. NO
otherwise.
+*/
- (BOOL)hasShadow
{
return _hasShadow;
}
+/*
+ Sets whether the window should have a drop shadow.
+ @param shouldHaveShadow YES
to have a drop shadow.
+*/
- (void)setHasShadow:(BOOL)shouldHaveShadow
{
if (_hasShadow == shouldHaveShadow)
@@ -559,6 +864,10 @@ var CPWindowSaveImage = nil,
}
}
+/*
+ Sets the delegate for the window. Passing nil
will just remove the window's current delegate.
+ @param aDelegate an object to respond to the various delegate methods of aResponder
the first responder. Before trying
+ to make it the first responder, the receiver will ask the current first responder
+ to resign its first responder status. If it resigns, it will ask
+ aResponder
accept first responder, then finally tell it to become first responder.
+ @return YES
if the attempt was successful. NO
otherwise.
+*/
- (void)makeFirstResponder:(CPResponder)aResponder
{
if (_firstResponder == aResponder)
@@ -630,6 +956,9 @@ var CPWindowSaveImage = nil,
return YES;
}
+/*
+ Returns the window's current first responder.
+*/
- (CPResponder)firstResponder
{
return _firstResponder;
@@ -647,11 +976,17 @@ var CPWindowSaveImage = nil,
// Managing Titles
+/*
+ Returns the window's title bar string
+*/
- (CPString)title
{
return _title;
}
+/*
+ Sets the window's title bar string
+*/
- (void)setTitle:(CPString)aTitle
{
_title = aTitle;
@@ -661,28 +996,43 @@ var CPWindowSaveImage = nil,
[self _synchronizeMenuBarTitleWithWindowTitle];
}
+/*
+ Sets the title bar to represent a file path
+*/
- (void)setTitleWithRepresentedFilename:(CPString)aFilePath
{
[self setRepresentedFilename:aFilePath];
[self setTitle:[aFilePath lastPathComponent]];
}
+/*
+ Sets the path to the file the receiver represents
+*/
- (void)setRepresentedFilename:(CPString)aFilePath
{
// FIXME: urls vs filepaths and all.
[self setRepresentedURL:aFilePath];
}
+/*
+ Returns the path to the file the receiver represents
+*/
- (CPString)representedFilename
{
return _representedURL;
}
+/*
+ Sets the URL that the receiver represents
+*/
- (void)setRepresentedURL:(CPURL)aURL
{
_representedURL = aURL;
}
+/*
+ Returns the URL that the receiver represents
+*/
- (CPURL)representedURL
{
return _representedURL;
@@ -690,16 +1040,26 @@ var CPWindowSaveImage = nil,
// Moving
+/*
+ Sets whether the window can be moved by dragging its background. The default is based on the window style.
+ @param shouldBeMovableByWindowBackground YES
makes the window move from a background drag.
+*/
- (void)setMovableByWindowBackground:(BOOL)shouldBeMovableByWindowBackground
{
_isMovableByWindowBackground = shouldBeMovableByWindowBackground;
}
+/*
+ Returns YES
if the window can be moved by dragging its background.
+*/
- (BOOL)isMovableByWindowBackground
{
return _isMovableByWindowBackground;
}
+/*
+ Sets the window location to be the center of the screen
+*/
- (void)center
{
var size = [self frame].size,
@@ -708,6 +1068,10 @@ var CPWindowSaveImage = nil,
[self setFrameOrigin:CGPointMake((bridgeSize.width - size.width) / 2.0, (bridgeSize.height - size.height) / 2.0)];
}
+/*
+ Dispatches events that are sent to it from becomeKeyWindow
message to the first responder.
+*/
- (void)becomeKeyWindow
{
if (_firstResponder != self && [_firstResponder respondsToSelector:@selector(becomeKeyWindow)])
[_firstResponder becomeKeyWindow];
}
+/*
+ Determines if the window can become the key window.
+ @return YES
means the window can become the key window.
+*/
- (BOOL)canBecomeKeyWindow
{
return YES;
}
+/*
+ Returns YES
if the window is the key window.
+*/
- (BOOL)isKeyWindow
{
return [CPApp keyWindow] == self;
}
+/*
+ Makes the window the key window and brings it to the front of the screen list.
+ @param aSender the object requesting this
+*/
- (void)makeKeyAndOrderFront:(id)aSender
{
[self orderFront:self];
@@ -807,6 +1189,9 @@ var CPWindowSaveImage = nil,
[self makeMainWindow];
}
+/*
+ Makes this window the key window.
+*/
- (void)makeKeyWindow
{
if (![self canBecomeKeyWindow])
@@ -819,6 +1204,9 @@ var CPWindowSaveImage = nil,
[self becomeKeyWindow];
}
+/*
+ Causes the window to resign it's key window status.
+*/
- (void)resignKeyWindow
{
if (_firstResponder != self && [_firstResponder respondsToSelector:@selector(resignKeyWindow)])
@@ -828,11 +1216,31 @@ var CPWindowSaveImage = nil,
[_delegate windowDidResignKey:self];
}
+/*
+ Initiates a drag operation from the receiver to another view that accepts dragged data.
+ @param anImage the image to be dragged
+ @param aLocation the lower-left corner coordinate of anImage
+ @param mouseOffset the distance from the mouseDown:
location and the current location
+ @param anEvent the mouseDown:
that triggered the drag
+ @param aPastebaord the pasteboard that holds the drag data
+ @param aSourceObject the drag operation controller
+ @param slideBack Whether the image should 'slide back' if the drag is rejected
+*/
- (void)dragImage:(CPImage)anImage at:(CGPoint)imageLocation offset:(CGSize)mouseOffset event:(CPEvent)anEvent pasteboard:(CPPasteboard)aPasteboard source:(id)aSourceObject slideBack:(BOOL)slideBack
{
[[CPDragServer sharedDragServer] dragImage:anImage fromWindow:self at:[self convertBaseToBridge:imageLocation] offset:mouseOffset event:anEvent pasteboard:aPasteboard source:aSourceObject slideBack:slideBack];
}
+/*
+ Initiates a drag operation from the receiver to another view that accepts dragged data.
+ @param aView the view to be dragged
+ @param aLocation the lower-left corner coordinate of aView
+ @param mouseOffset the distance from the mouseDown:
location and the current location
+ @param anEvent the mouseDown:
that triggered the drag
+ @param aPastebaord the pasteboard that holds the drag data
+ @param aSourceObject the drag operation controller
+ @param slideBack Whether the view should 'slide back' if the drag is rejected
+*/
- (void)dragView:(CPView)aView at:(CGPoint)imageLocation offset:(CGSize)mouseOffset event:(CPEvent)anEvent pasteboard:(CPPasteboard)aPasteboard source:(id)aSourceObject slideBack:(BOOL)slideBack
{
[[CPDragServer sharedDragServer] dragView:aView fromWindow:self at:[self convertBaseToBridge:imageLocation] offset:mouseOffset event:anEvent pasteboard:aPasteboard source:aSourceObject slideBack:slideBack];
@@ -840,6 +1248,10 @@ var CPWindowSaveImage = nil,
// Accessing Editing Status
+/*
+ Sets whether the document has been edited.
+ @param isDocumentEdited YES
if the document has been edited.
+*/
- (void)setDocumentEdited:(BOOL)isDocumentEdited
{
if (_isDocumentEdited == isDocumentEdited)
@@ -850,6 +1262,9 @@ var CPWindowSaveImage = nil,
[CPMenu _setMenuBarIconImageAlphaValue:_isDocumentEdited ? 0.5 : 1.0];
}
+/*
+ Returns YES
if the document has been edited.
+*/
- (BOOL)isDocumentEdited
{
return _isDocumentEdited;
@@ -872,6 +1287,7 @@ var CPWindowSaveImage = nil,
return _isDocumentSaving;
}
+/* @ignore */
- (void)_synchronizeSaveMenuWithDocumentSaving
{
if (![self isMainWindow])
@@ -903,6 +1319,10 @@ var CPWindowSaveImage = nil,
// Closing Windows
+/*
+ Simulates the user closing the window, then closes the window.
+ @param aSender the object making this request
+*/
- (void)performClose:(id)aSender
{
if ([_delegate respondsToSelector:@selector(windowShouldClose:)] && ![_delegate windowShouldClose:self] ||
@@ -912,6 +1332,10 @@ var CPWindowSaveImage = nil,
[self close];
}
+/*
+ Closes the window. Posts a CPWindowWillCloseNotification
to the
+ notification center before closing the window.
+*/
- (void)close
{
[[CPNotificationCenter defaultCenter] postNotificationName:CPWindowWillCloseNotification object:self];
@@ -920,12 +1344,17 @@ var CPWindowSaveImage = nil,
}
// Managing Main Status
-
+/*
+ Returns YES
if this the main window.
+*/
- (BOOL)isMainWindow
{
return [CPApp mainWindow] == self;
}
+/*
+ Returns YES
if the window can become the main window.
+*/
- (BOOL)canBecomeMainWindow
{
// FIXME: Also check if we can resize and titlebar.
@@ -935,6 +1364,9 @@ var CPWindowSaveImage = nil,
return NO;
}
+/*
+ Makes the receiver the main window.
+*/
- (void)makeMainWindow
{
if (![self canBecomeMainWindow])
@@ -947,6 +1379,9 @@ var CPWindowSaveImage = nil,
[self becomeMainWindow];
}
+/*
+ Called to tell the receiver that it has become the main window.
+*/
- (void)becomeMainWindow
{
[self _synchronizeMenuBarTitleWithWindowTitle];
@@ -957,6 +1392,9 @@ var CPWindowSaveImage = nil,
object:self];
}
+/*
+ Called when the window resigns main window status.
+*/
- (void)resignMainWindow
{
[[CPNotificationCenter defaultCenter]
@@ -965,13 +1403,19 @@ var CPWindowSaveImage = nil,
}
// Managing Toolbars
-
+/*
+ Return's the window's toolbar
+*/
- (CPToolbar)toolbar
{
return _toolbar;
}
-- (void)setToolbar:(CPView)aToolbar
+/*
+ Sets the window's toolbar.
+ @param aToolbar the window's new toolbar
+*/
+- (void)setToolbar:(CPToolbar)aToolbar
{
if (_toolbar == aToolbar)
return;
@@ -998,6 +1442,7 @@ var CPWindowSaveImage = nil,
}
}
+/* @ignore */
- (void)_setToolbarVisible:(BOOL)aFlag
{
if (aFlag)
@@ -1016,6 +1461,7 @@ var CPWindowSaveImage = nil,
// Managing Sheets
+/* @ignore */
- (void)_setAttachedSheetFrameOrigin
{
// Position the sheet above the contentRect.
@@ -1028,6 +1474,7 @@ var CPWindowSaveImage = nil,
[_attachedSheet setFrameOrigin:sheetFrame.origin];
}
+/* @ignore */
- (void)_animateAttachedSheet
{
/* NSWindow *sheet = [sheetContext sheet];
@@ -1052,6 +1499,7 @@ var CPWindowSaveImage = nil,
[sheet setFrame:sheetFrame display:YES animate:YES];*/
}
+/* @ignore */
- (void)_attachSheet:(CPWindow)aSheet modalDelegate:(id)aModalDelegate didEndSelector:(SEL)aDidEndSelector contextInfo:(id)aContextInfo
{
// Set this as our attached sheet.
@@ -1066,23 +1514,36 @@ var CPWindowSaveImage = nil,
[_bridge order:CPWindowAbove window:aSheet relativeTo:self];
}
+/*
+ Returns the window's attached sheet.
+*/
- (CPWindow)attachedSheet
{
return _attachedSheet;
}
+/*
+ Returns YES
if the window has ever run as a sheet.
+*/
- (BOOL)isSheet
{
return _isSheet;
}
//
-
+/*
+ Used privately.
+ @ignore
+*/
- (BOOL)becomesKeyOnlyIfNeeded
{
return NO;
}
+/*
+ Returns YES
if the receiver is able to receive input events
+ even when a modal session is active.
+*/
- (BOOL)worksWhenModal
{
return NO;
@@ -1105,6 +1566,10 @@ var CPWindowSaveImage = nil,
@implementation CPWindow (BridgeSupport)
+/*
+ Sets the DOM-Window bridge for this window.
+ @ignore
+*/
- (void)setBridge:(CPDOMWindowBridge)aBridge
{
if (_bridge == aBridge)
@@ -1122,6 +1587,9 @@ var CPWindowSaveImage = nil,
[self setFrame:[aBridge contentBounds]];
}
+/*
+ @ignore
+*/
- (void)resizeWithOldBridgeSize:(CGSize)aSize
{
if (_styleMask & CPBorderlessBridgeWindowMask)
@@ -1150,16 +1618,25 @@ var CPWindowSaveImage = nil,
[self setFrame:newFrame];
}
+/*
+ @ignore
+*/
- (void)setAutoresizingMask:(unsigned)anAutoresizingMask
{
_autoresizingMask = anAutoresizingMask;
}
+/*
+ @ignore
+*/
- (unsigned)autoresizingMask
{
return _autoresizingMask;
}
+/*
+ @ignore
+*/
- (CGPoint)convertBaseToBridge:(CGPoint)aPoint
{
var origin = [self frame].origin;
@@ -1167,6 +1644,9 @@ var CPWindowSaveImage = nil,
return CGPointMake(aPoint.x + origin.x, aPoint.y + origin.y);
}
+/*
+ @ignore
+*/
- (CGPoint)convertBridgeToBase:(CGPoint)aPoint
{
var origin = [self frame].origin;
@@ -1175,7 +1655,9 @@ var CPWindowSaveImage = nil,
}
// Undo and Redo Support
-
+/*
+ Returns the window's undo manager.
+*/
- (CPUndoManager)undoManager
{
if (_delegateRespondsToWindowWillReturnUndoManagerSelector)
@@ -1187,11 +1669,19 @@ var CPWindowSaveImage = nil,
return _undoManager;
}
+/*
+ Sends the undo manager an undo
message.
+ @param aSender the object requesting this
+*/
- (void)undo:(id)aSender
{
[[self undoManager] undo];
}
+/*
+ Sends the undo manager a redo:
message.
+ @param aSender the object requesting this
+*/
- (void)redo:(id)aSender
{
[[self undoManager] redo];
@@ -1204,6 +1694,7 @@ var interpolate = function(fromValue, toValue, progress)
return fromValue + (toValue - fromValue) * progress;
}
+/* @ignore */
@implementation _CPWindowFrameAnimation : CPAnimation
{
CPWindow _window;
diff --git a/AppKit/CPWindowController.j b/AppKit/CPWindowController.j
index e0c7b8abcc..aa7a8cc0f6 100644
--- a/AppKit/CPWindowController.j
+++ b/AppKit/CPWindowController.j
@@ -29,7 +29,12 @@ import "CPDocument.j"
#include "Platform/Platform.h"
-
+/*
+ An instance of a YES
if the window has been loaded. Specifically,
+ if YES
means the document has unsaved changes.
+*/
- (void)setDocumentEdited:(BOOL)isEdited
{
[[self window] setDocumentEdited:isEdited];
@@ -198,6 +257,9 @@ import "CPDocument.j"
// Setting and Getting Window Attributes
+/*
+ Sets the title of the window as the name of the document.
+*/
- (void)synchronizeWindowTitleWithDocumentName
{
if (!_document || !_window)
@@ -207,6 +269,10 @@ import "CPDocument.j"
[_window setTitle:[self windowTitleForDocumentDisplayName:[_document displayName]]];
}
+/*
+ Returns the window title based on the document's name.
+ @param aDisplayName the document's filename
+*/
- (CPString)windowTitleForDocumentDisplayName:(CPString)aDisplayName
{
return aDisplayName;
diff --git a/AppKit/Cib/CPCustomView.j b/AppKit/Cib/CPCustomView.j
index 035b97e20a..14d55a712a 100644
--- a/AppKit/Cib/CPCustomView.j
+++ b/AppKit/Cib/CPCustomView.j
@@ -22,6 +22,7 @@
import "CPView.j"
+/* @ignore */
@implementation CPCustomView : CPView
{
CPString _className;
diff --git a/AppKit/CoreAnimation/CAAnimation.j b/AppKit/CoreAnimation/CAAnimation.j
index d46f99e1c5..f44127020b 100644
--- a/AppKit/CoreAnimation/CAAnimation.j
+++ b/AppKit/CoreAnimation/CAAnimation.j
@@ -25,12 +25,18 @@ import YES
+ @return YES
+*/
- (void)shouldArchiveValueForKey:(CPString)aKey
{
return YES;
}
+/*
+ Returns nil
+ @return nil
+*/
+ (id)defaultValueForKey:(CPString)aKey
{
return nil;
}
+/*
+ Specifies whether this animation should be removed after it has completed.
+ @param YES
means the animation should be removed
+*/
- (void)setRemovedOnCompletion:(BOOL)isRemovedOnCompletion
{
_isRemovedOnCompletion = isRemovedOnCompletion;
}
+/*
+ Returns YES
if the animation is removed after completion
+*/
- (BOOL)removedOnCompletion
{
return _isRemovedOnCompletion;
}
+/*
+ Returns YES
if the animation is removed after completion
+*/
- (BOOL)isRemovedOnCompletion
{
return _isRemovedOnCompletion;
}
+/*
+ Returns the animation's timing function. If nil
, then it has a linear pacing.
+*/
- (CAMediaTimingFunction)timingFunction
{
// Linear Pacing
return nil;
}
+/*
+ Sets the animation delegate
+ @param aDelegate the new delegate
+*/
- (void)setDelegate:(id)aDelegate
{
_delegate = aDelegate;
}
+/*
+ Returns the animation's delegate
+*/
- (id)delegate
{
return _delegate;
@@ -94,6 +128,9 @@ import "CAMediaTimingFunction.j"
@end
+/*
+
+*/
@implementation CAPropertyAnimation : CAAnimation
{
CPString _keyPath;
@@ -153,6 +190,11 @@ import "CAMediaTimingFunction.j"
@end
+/*
+ A drawInContext:
.
+ @param layer the layer to draw for
+ @param ctx the context to draw on
+
+ @delegate -(void)displayLayer:(CALayer)layer;
+ The delegate can override the layer's display
method
+ by implementing this method.
+*/
@implementation CALayer : CPObject
{
// Modifying the Layer Geometry
@@ -85,7 +99,7 @@ var CALayerRegisteredRunLoopUpdates = nil;
unsigned _runLoopUpdateMask;
BOOL _needsDisplayOnBoundsChange;
- // Modifyin the Delegate
+ // Modifying the Delegate
id _delegate;
@@ -104,11 +118,17 @@ var CALayerRegisteredRunLoopUpdates = nil;
CGAffineTransform _transformFromLayer;
}
+/*
+ Returns a new animation layer.
+*/
+ (CALayer)layer
{
return [[[self class] alloc] init];
}
+/*
+ Initializes the animation layer.
+*/
- (id)init
{
self = [super init];
@@ -152,7 +172,10 @@ var CALayerRegisteredRunLoopUpdates = nil;
}
// Modifying the Layer Geometry
-
+/*
+ Sets the bounds (origin and size) of the rectangle.
+ @param aBounds the new bounds for the layer
+*/
- (void)setBounds:(CGRect)aBounds
{
if (CGRectEqualToRect(_bounds, aBounds))
@@ -178,11 +201,18 @@ var CALayerRegisteredRunLoopUpdates = nil;
_CALayerRecalculateGeometry(self, CALayerGeometryBoundsMask);
}
+/*
+ Returns the layer's bound.
+*/
- (CGRect)bounds
{
return _bounds;
}
+/*
+ Sets the layer's position.
+ @param aPosition the layer's new position
+*/
- (void)setPosition:(CGPoint)aPosition
{
if (CGPointEqualToPoint(_position, aPosition))
@@ -193,11 +223,18 @@ var CALayerRegisteredRunLoopUpdates = nil;
_CALayerRecalculateGeometry(self, CALayerGeometryPositionMask);
}
+/*
+ Returns the layer's position
+*/
- (CGPoint)position
{
return _position;
}
+/*
+ Sets the layer's z-ordering.
+ @param aZPosition the layer's new z-ordering
+*/
- (void)setZPosition:(int)aZPosition
{
if (_zPosition == aZPosition)
@@ -208,6 +245,10 @@ var CALayerRegisteredRunLoopUpdates = nil;
[self registerRunLoopUpdateWithMask:CALayerZPositionUpdateMask];
}
+/*
+ Sets the layer's anchor point. The default point is [0.5, 0.5].
+ @param anAnchorPoint the layer's new anchor point
+*/
- (void)setAnchorPoint:(CGPoint)anAnchorPoint
{
anAnchorPoint = _CGPointMakeCopy(anAnchorPoint);
@@ -228,11 +269,18 @@ var CALayerRegisteredRunLoopUpdates = nil;
_CALayerRecalculateGeometry(self, CALayerGeometryAnchorPointMask);
}
+/*
+ Returns the layer's anchor point.
+*/
- (CGPoint)anchorPoint
{
return _anchorPoint;
}
+/*
+ Sets the affine transform applied to this layer.
+ @param anAffineTransform the new affine transform
+*/
- (void)setAffineTransform:(CGAffineTransform)anAffineTransform
{
if (CGAffineTransformEqualToTransform(_affineTransform, anAffineTransform))
@@ -243,11 +291,18 @@ var CALayerRegisteredRunLoopUpdates = nil;
_CALayerRecalculateGeometry(self, CALayerGeometryAffineTransformMask);
}
+/*
+ Returns the layer's affine transform.
+*/
- (CGAffineTransform)affineTransform
{
return _affineTransform;
}
+/*
+ Sets the affine transform that gets applied to all the sublayers.
+ @param anAffineTransform the transform to apply to sublayers
+*/
- (void)setSublayerTransform:(CGAffineTransform)anAffineTransform
{
if (CGAffineTransformEqualToTransform(_sublayerTransform, anAffineTransform))
@@ -270,24 +325,40 @@ var CALayerRegisteredRunLoopUpdates = nil;
}
}
+/*
+ Returns the affine transform applied to the sublayers.
+*/
- (CGAffineTransform)sublayerTransform
{
return _sublayerTransform;
}
+/*
+ Private
+ @ignore
+*/
- (CGAffineTransform)transformToLayer
{
return _transformToLayer;
}
+/*
+ Sets the frame of the layer. The frame defines a bounding
+ rectangle in the superlayer's coordinate system.
+ @param aFrame the new frame rectangle
+*/
- (void)setFrame:(CGRect)aFrame
{
alert("FIXME IMPLEMENT");
}
-// The frame defines the bounding box of the layer: the smallest
-// possible rectangle that could fit this layer after transform
-// properties are applied in superlayer coordinates.
+/*
+ Returns the layer's frame.
+
+ The frame defines the bounding box of the layer: the smallest
+ possible rectangle that could fit this layer after transform
+ properties are applied in superlayer coordinates.
+*/
- (CGRect)frame
{
if (!_frame)
@@ -296,16 +367,23 @@ var CALayerRegisteredRunLoopUpdates = nil;
return _frame;
}
-// The Backing Store Frame specifies the frame of the actual backing
-// store used to contain this layer. Naturally, by default it is the
-// same as the frame, however, users can specify their own custom
-// Backing Store Frame in order to speed up certain operations, such as
-// live transformation.
+/*
+ The Backing Store Frame specifies the frame of the actual backing
+ store used to contain this layer. Naturally, by default it is the
+ same as the frame, however, users can specify their own custom
+ Backing Store Frame in order to speed up certain operations, such as
+ live transformation.
+ @return the backing store frame
+*/
- (CGRect)backingStoreFrame
{
return _backingStoreFrame;
}
+/*
+ Sets the frame's backing store.
+ @param aFrame the new backing store.
+*/
- (void)setBackingStoreFrame:(CGRect)aFrame
{
_hasCustomBackingStoreFrame = (aFrame != nil);
@@ -338,12 +416,19 @@ var CALayerRegisteredRunLoopUpdates = nil;
}
// Providing Layer Content
-
+/*
+ Returns the nil
.
+*/
- (CGImage)contents
{
return _contents;
}
+/*
+ Sets the image contents of this layer.
+ @param contents the image to display
+*/
- (void)setContents:(CGImage)contents
{
if (_contents == contents)
@@ -354,6 +439,10 @@ var CALayerRegisteredRunLoopUpdates = nil;
[self composite];
}
+/*
+ Composites this layer onto the super layer, and draws its contents as well.
+ @ignore
+*/
- (void)composite
{
if (USE_BUFFER && !_contents || !_context)
@@ -390,6 +479,9 @@ var CALayerRegisteredRunLoopUpdates = nil;
CGContextRestoreGState(_context);
}
+/*
+ Displays the contents of this layer.
+*/
- (void)display
{
if (!_context)
@@ -418,7 +510,7 @@ var CALayerRegisteredRunLoopUpdates = nil;
if (USE_BUFFER)
{
if (_delegateRespondsToDisplayLayerSelector)
- return [self displayInLayer:self];
+ return [_delegate displayInLayer:self];
if (_CGRectGetWidth(_backingStoreFrame) == 0.0 || _CGRectGetHeight(_backingStoreFrame) == 0.0)
return;
@@ -434,6 +526,10 @@ var CALayerRegisteredRunLoopUpdates = nil;
[self composite];
}
+/*
+ Draws this layer's contents into the specified context.
+ @param aContext the context to draw the layer into
+*/
- (void)drawInContext:(CGContext)aContext
{ //if (!window.loop || window.nodisplay) CPLog.error("htiasd");
if (_backgroundColor)
@@ -448,12 +544,19 @@ var CALayerRegisteredRunLoopUpdates = nil;
// Style Attributes
-
+/*
+ Returns the opacity of the layer. The value is between
+ 0.0
(transparent) and 1.0
(opaque).
+*/
- (float)opacity
{
return _opacity;
}
+/*
+ Sets the opacity for the layer.
+ @param anOpacity the new opacity (between 0.0
(transparent) and 1.0
(opaque)).
+*/
- (void)setOpacity:(float)anOpacity
{
if (_opacity == anOpacity)
@@ -465,22 +568,36 @@ var CALayerRegisteredRunLoopUpdates = nil;
_DOMElement.style.filter = "alpha(opacity=" + anOpacity * 100 + ")";
}
+/*
+ Sets whether the layer is hidden.
+ @param isHidden YES
means the layer will be hidden. NO
means the layer will be visible.
+*/
- (void)setHidden:(BOOL)isHidden
{
_isHidden = isHidden;
_DOMElement.style.display = isHidden ? "none" : "block";
}
+/*
+ Returns YES
if the layer is hidden.
+*/
- (BOOL)hidden
{
return _isHidden;
}
+/*
+ Returns YES
if the layer is hidden.
+*/
- (BOOL)isHidden
{
return _isHidden;
}
+/*
+ Sets whether content that goes lies outside the bounds is hidden or visible.
+ @param masksToBounds YES
hides the excess content. NO
makes it visible.
+*/
- (void)setMasksToBounds:(BOOL)masksToBounds
{
if (_masksToBounds == masksToBounds)
@@ -490,6 +607,10 @@ var CALayerRegisteredRunLoopUpdates = nil;
_DOMElement.style.overflow = _masksToBounds ? "hidden" : "visible";
}
+/*
+ Sets the layer's background color.
+ @param aColor the new background color
+*/
- (void)setBackgroundColor:(CPColor)aColor
{
_backgroundColor = aColor;
@@ -497,18 +618,26 @@ var CALayerRegisteredRunLoopUpdates = nil;
[self setNeedsDisplay];
}
+/*
+ Returns the layer's background color.
+*/
- (CPColor)backgroundColor
{
return _backgroundColor;
}
// Managing Layer Hierarchy
-
+/*
+ Returns an array of the receiver's sublayers.
+*/
- (CPArray)sublayers
{
return _sublayers;
}
+/*
+ Returns the receiver's superlayer.
+*/
- (CALayer)superlayer
{
return _superlayer;
@@ -518,6 +647,9 @@ var CALayerRegisteredRunLoopUpdates = nil;
if (_DOMContentsElement && aLayer._zPosition > _DOMContentsElement.style.zIndex)\
_DOMContentsElement.style.zIndex -= 100.0;\
+/*
+ Adds the specified layer as a sublayer of the receiver.
+*/
- (void)addSublayer:(CALayer)aLayer
{
[self insertSublayer:aLayer atIndex:_sublayers.length];
@@ -528,6 +660,9 @@ if (_DOMContentsElement && aLayer._zPosition > _DOMContentsElement.style.zIndex)
_DOMElement.appendChild(DOM(aLayer));
}
+/*
+ Removes the receiver from its superlayer.
+*/
- (void)removeFromSuperlayer
{
if (_owningView)
@@ -542,6 +677,11 @@ if (_DOMContentsElement && aLayer._zPosition > _DOMContentsElement.style.zIndex)
_superlayer = nil;
}
+/*
+ Inserts the specified layer as a sublayer into the specified index.
+ @param aLayer the layer to insert
+ @param anIndex the index to insert the layer at
+*/
- (void)insertSublayer:(CALayer)aLayer atIndex:(unsigned)anIndex
{
if (!aLayer)
@@ -579,6 +719,12 @@ if (_DOMContentsElement && aLayer._zPosition > _DOMContentsElement.style.zIndex)
_CALayerRecalculateGeometry(aLayer, 0xFFFFFFF);
}
+/*
+ Inserts a layer below another layer.
+ @param aLayer the layer to insert
+ @param aSublayer the layer to insert below
+ @throws CALayerNotFoundException if aSublayer
is not in the array of sublayers
+*/
- (void)insertSublayer:(CALayer)aLayer below:(CALayer)aSublayer
{
var index = aSublayer ? [_sublayers indexOfObjectIdenticalTo:aSublayer] : 0;
@@ -586,13 +732,26 @@ if (_DOMContentsElement && aLayer._zPosition > _DOMContentsElement.style.zIndex)
[self insertSublayer:aLayer atIndex:index == CPNotFound ? _sublayers.length : index];
}
-- (void)insertSublayer:(CALayer)aLayer after:(CALayer)aSublayer
+/*
+ Inserts a layer above another layer.
+ @param aLayer the layer to insert
+ @param aSublayer the layer to insert above
+ @throws CALayerNotFoundException if aSublayer
is not in the array of sublayers
+*/
+- (void)insertSublayer:(CALayer)aLayer above:(CALayer)aSublayer
{
var index = aSublayer ? [_sublayers indexOfObjectIdenticalTo:aSublayer] : _sublayers.length;
+ if (index == CPNotFound)
+ [CPException raise:"CALayerNotFoundException" reason:"aSublayer is not a sublayer of this layer"];
[_sublayers insertObject:aLayer atIndex:index == CPNotFound ? _sublayers.length : index + 1];
}
+/*
+ Replaces a sublayer.
+ @param aSublayer the layer to insert
+ @param aLayer the layer to replace
+*/
- (void)replaceSublayer:(CALayer)aSublayer with:(CALayer)aLayer
{
if (aSublayer == aLayer)
@@ -612,7 +771,10 @@ if (_DOMContentsElement && aLayer._zPosition > _DOMContentsElement.style.zIndex)
}
// Updating Layer Display
-
+/*
+ Updates the layers on screen.
+ @ignore
+*/
+ (void)runLoopUpdateLayers
{if (window.oops) {alert(window.latest); objj_debug_print_backtrace();}
window.loop = true;
@@ -636,6 +798,9 @@ if (_DOMContentsElement && aLayer._zPosition > _DOMContentsElement.style.zIndex)
CALayerRegisteredRunLoopUpdates = nil;
}
+/*
+ @ignore
+*/
- (void)registerRunLoopUpdateWithMask:(unsigned)anUpdateMask
{
if (CALayerRegisteredRunLoopUpdates == nil)
@@ -650,26 +815,43 @@ if (_DOMContentsElement && aLayer._zPosition > _DOMContentsElement.style.zIndex)
CALayerRegisteredRunLoopUpdates[[self hash]] = self;
}
+/*
+ @ignore
+*/
- (void)setNeedsComposite
{
[self registerRunLoopUpdateWithMask:CALayerCompositeUpdateMask];
}
+/*
+ Marks the layer as needing to be redrawn.
+*/
- (void)setNeedsDisplay
{
[self registerRunLoopUpdateWithMask:CALayerDisplayUpdateMask];
}
+/*
+ Sets whether the layer needs to be redrawn when its bounds are changed.
+ @param needsDisplayOnBoundsChange YES
means the display is redraw on a bounds change.
+*/
- (void)setNeedsDisplayOnBoundsChange:(BOOL)needsDisplayOnBoundsChange
{
_needsDisplayOnBoundsChange = needsDisplayOnBoundsChange;
}
+/*
+ Returns YES
if the display should be redrawn on a bounds change.
+*/
- (BOOL)needsDisplayOnBoundsChange
{
return _needsDisplayOnBoundsChange;
}
+/*
+ Marks the specified rectange as needing to be redrawn.
+ @param aRect the area that needs to be redrawn.
+*/
- (void)setNeedsDisplayInRect:(CGRect)aRect
{
_dirtyRect = aRect;
@@ -677,34 +859,65 @@ if (_DOMContentsElement && aLayer._zPosition > _DOMContentsElement.style.zIndex)
}
// Mapping Between Coordinate and Time Spaces
-
+/*
+ Converts the point from the specified layer's coordinate system into the receiver's coordinate system.
+ @param aPoint the point to convert
+ @param aLayer the layer coordinate system to convert from
+ @return the converted point
+*/
- (CGPoint)convertPoint:(CGPoint)aPoint fromLayer:(CALayer)aLayer
{
return CGPointApplyAffineTransform(aPoint, _CALayerGetTransform(aLayer, self));
}
+/*
+ Converts the point from the receiver's coordinate system to the specified layer's coordinate system.
+ @param aPoint the point to convert
+ @param aLayer the layer coordinate system to convert to
+ @return the converted point
+*/
- (CGPoint)convertPoint:(CGPoint)aPoint toLayer:(CALayer)aLayer
{
return CGPointApplyAffineTransform(aPoint, _CALayerGetTransform(self, aLayer));
}
+/*
+ Converts the rectangle from the specified layer's coordinate system to the receiver's coordinate system.
+ @param aRect the rectangle to convert
+ @param aLayer the layer coordinate system to convert from
+ @return the converted rectangle
+*/
- (CGRect)convertRect:(CGRect)aRect fromLayer:(CALayer)aLayer
{
return CGRectApplyAffineTransform(aRect, _CALayerGetTransform(aLayer, self));
}
+/*
+ Converts the rectangle from the receier's coordinate system to the specified layer's coordinate system.
+ @param aRect the rectange to convert
+ @param aLayer the layer coordinate system to convert to
+ @return the converted rectangle
+*/
- (CGRect)convertRect:(CGRect)aRect toLayer:(CALayer)aLayer
{
return CGRectApplyAffineTransform(aRect, _CALayerGetTransform(self, aLayer));
}
// Hit Testing
-
+/*
+ Returns YES
if the layer contains the point.
+ @param aPoint the point to test
+*/
- (BOOL)containsPoint:(CGPoint)aPoint
{
return _CGRectContainsPoint(_bounds, aPoint);
}
+/*
+ Returns the farthest descendant of this layer that contains the specified point.
+ @param aPoint the point to test
+ @return the containing layer or nil
if there was no hit.
+*/
- (CALayer)hitTest:(CGPoint)aPoint
{
if (_isHidden)
@@ -728,7 +941,10 @@ if (_DOMContentsElement && aLayer._zPosition > _DOMContentsElement.style.zIndex)
}
// Modifying the Delegate
-
+/*
+ Sets the delegate for this layer.
+ @param aDelegate the delegate
+*/
- (void)setDelegate:(id)aDelegate
{
if (_delegate == aDelegate)
@@ -743,11 +959,15 @@ if (_DOMContentsElement && aLayer._zPosition > _DOMContentsElement.style.zIndex)
[self setNeedsDisplay];
}
+/*
+ Returns the layer's delegate
+*/
- (id)delegate
{
return _delegate;
}
+/* @ignore */
- (void)_setOwningView:(CPView)anOwningView
{
_owningView = anOwningView;
@@ -763,6 +983,7 @@ if (_DOMContentsElement && aLayer._zPosition > _DOMContentsElement.style.zIndex)
_CALayerRecalculateGeometry(self, CALayerGeometryPositionMask | CALayerGeometryBoundsMask);
}
+/* @ignore */
- (void)_owningViewBoundsChanged
{
_bounds.size = CGSizeMakeCopy([_owningView bounds].size);
@@ -771,6 +992,7 @@ if (_DOMContentsElement && aLayer._zPosition > _DOMContentsElement.style.zIndex)
_CALayerRecalculateGeometry(self, CALayerGeometryPositionMask | CALayerGeometryBoundsMask);
}
+/* @ignore */
- (void)_update
{
window.loop = true;
diff --git a/AppKit/CoreGraphics/CGAffineTransform.j b/AppKit/CoreGraphics/CGAffineTransform.j
index 2bd7e39be5..a3b4502cf8 100644
--- a/AppKit/CoreGraphics/CGAffineTransform.j
+++ b/AppKit/CoreGraphics/CGAffineTransform.j
@@ -45,12 +45,24 @@ _function(CGAffineTransformEqualToTransform(lhs, rhs))
_function(CGStringCreateWithCGAffineTransform(aTransform))
-// FIXME: !!!!
+/*
+ FIXME: !!!!
+ @return void
+ @group CGAffineTransform
+*/
function CGAffineTransformCreateCopy(aTransform)
{
return _CGAffineTransformMakeCopy(aTransform);
}
+/*
+ Returns a transform that rotates a coordinate system.
+ @param anAngle the amount in radians for the transform
+ to rotate a coordinate system
+ @return CGAffineTransform the transform with a specified
+ rotation
+ @group CGAffineTransform
+*/
function CGAffineTransformMakeRotation(anAngle)
{
var sin = SIN(anAngle),
@@ -59,6 +71,13 @@ function CGAffineTransformMakeRotation(anAngle)
return _CGAffineTransformMake(cos, sin, -sin, cos, 0.0, 0.0);
}
+/*
+ Rotates a transform.
+ @param aTransform the transform to rotate
+ @param anAngle the amount to rotate in radians
+ @return void
+ @group CGAffineTransform
+*/
function CGAffineTransformRotate(aTransform, anAngle)
{
var sin = SIN(anAngle),
@@ -74,6 +93,12 @@ function CGAffineTransformRotate(aTransform, anAngle)
};
}
+/*
+ Inverts a transform.
+ @param aTransform the transform to invert
+ @return CGAffineTransform an inverted transform
+ @group CGAffineTransform
+*/
function CGAffineTransformInvert(aTransform)
{
var determinant = 1 / (aTransform.a * aTransform.d - aTransform.b * aTransform.c);
@@ -88,6 +113,14 @@ function CGAffineTransformInvert(aTransform)
};
}
+/*
+ Applies a transform to the rectangle's points. The transformed rectangle
+ will be the smallest box that contains the transformed points.
+ @param aRect the rectangle to transform
+ @param anAffineTransform the transform to apply
+ @return CGRect the new transformed rectangle
+ @group CGAffineTransform
+*/
function CGRectApplyAffineTransform(aRect, anAffineTransform)
{
var top = _CGRectGetMinY(aRect),
@@ -106,6 +139,12 @@ function CGRectApplyAffineTransform(aRect, anAffineTransform)
return _CGRectMake(minX, minY, (maxX - minX), (maxY - minY));
}
+/*
+ Creates and returns a string representation of an affine transform.
+ @param anAffineTransform the transform to represent as a string
+ @return CPString a string describing the transform
+ @group CGAffineTransform
+*/
function CPStringFromCGAffineTransform(anAffineTransform)
{
return '{' + anAffineTransform.a + ", " + anAffineTransform.b + ", " + anAffineTransform.c + ", " + anAffineTransform.d + ", " + anAffineTransform.tx + ", " + anAffineTransform.ty + '}';
diff --git a/AppKit/CoreGraphics/CGColor.j b/AppKit/CoreGraphics/CGColor.j
index a5838e87ff..ba0518c0e2 100644
--- a/AppKit/CoreGraphics/CGColor.j
+++ b/AppKit/CoreGraphics/CGColor.j
@@ -45,15 +45,28 @@ function CGColorGetConstantColor(aColorName)
alert("FIX ME");
}
+/*
+ This function is for source compatability.
+*/
function CGColorRetain(aColor)
{
return aColor;
}
+/*
+ This function is for source compatability.
+*/
function CGColorRelease()
{
}
+/*
+ Creates a new 0.0-1.0
)
+ @param alpha the gray's alpha value (0.0-1.0
)
+ @return CGColor the new gray color object
+ @group CGColor
+*/
function CGColorCreateGenericGray(gray, alpha)
{
return CGColorCreate(0, [gray, alpha]);
}
+/*
+ Creates an RGB color.
+ @param red the red component (0.0-1.0
)
+ @param green the green component (0.0-1.0
)
+ @param blue the blue component (0.0-1.0
)
+ @param alpha the alpha component (0.0-1.0
)
+ @return CGColor the RGB based color
+ @group CGColor
+*/
function CGColorCreateGenericRGB(red, green, blue, alpha)
{
return CGColorCreate(0, [red, green, blue, alpha]);
}
+/*
+ Creates a CMYK color.
+ @param cyan the cyan component (0.0-1.0
)
+ @param magenta the magenta component (0.0-1.0
)
+ @param yellow the yellow component (0.0-1.0
)
+ @param black the black component (0.0-1.0
)
+ @param alpha the alpha component (0.0-1.0
)
+ @return CGColor the CMYK based color
+ @group CGColor
+*/
function CGColorCreateGenericCMYK(cyan, magenta, yellow, black, alpha)
{
return CGColorCreate(0, [cyan, magenta, yellow, black, alpha]);
}
+/*
+ Creates a copy of the color with a specified alpha.
+ @param aColor the color object to copy
+ @param anAlpha the new alpha component for the copy (0.0-1.0
)
+ @return CGColor the new copy
+ @group CGColor
+*/
function CGColorCreateCopyWithAlpha(aColor, anAlpha)
{
var components = aColor.components;
@@ -109,6 +163,14 @@ function CGColorCreateCopyWithAlpha(aColor, anAlpha)
return copy;
}
+/*
+ Creates a color using the specified pattern.
+ @param aColorSpace the YES
if the two colors are equal.
+ NO
otherwise.
+*/
function CGColorEqualToColor(lhs, rhs)
{
if (lhs == rhs)
@@ -145,6 +214,12 @@ function CGColorEqualToColor(lhs, rhs)
return true;
}
+/*
+ Returns the color's alpha component.
+ @param aColor the color
+ @return float the alpha component (0.0-1.0
)
+ @group CGColor
+*/
function CGColorGetAlpha(aColor)
{
var components = aColor.components;
@@ -152,21 +227,45 @@ function CGColorGetAlpha(aColor)
return components[components.length - 1];
}
+/*
+ Returns the YES
for a rounded northeast corner
+ @param se set it to YES
for a rounded southeast corner
+ @param sw set it to YES
for a rounded southwest corner
+ @param nw set it to YES
for a rounded northwest corner
+ @return void
+ @group CGContext
+*/
function CGContextFillRoundedRectangleInRect(aContext, aRect, aRadius, ne, se, sw, nw)
{
var xMin = _CGRectGetMinX(aRect),
diff --git a/AppKit/CoreGraphics/CGGeometry.j b/AppKit/CoreGraphics/CGGeometry.j
index 0e3aced22b..f30f56383a 100644
--- a/AppKit/CoreGraphics/CGGeometry.j
+++ b/AppKit/CoreGraphics/CGGeometry.j
@@ -65,6 +65,14 @@ _function(CGRectIsNull(aRect))
_function(CGRectContainsPoint(aRect, aPoint))
+/*
+ Returns a BOOL
indicating whether lhsRect
+ contains rhsRect
.
+ @group CGRect
+ @param lhsRect the rhsRect
is inside of
+ @param rhsRect the lhsRect
.
+ @return BOOL YES
if rhsRect
fits inside lhsRect
.
+*/
function CGRectContainsRect(lhsRect, rhsRect)
{
var union = CGRectUnion(lhsRect, rhsRect);
@@ -72,6 +80,13 @@ function CGRectContainsRect(lhsRect, rhsRect)
return _CGRectEqualToRect(union, lhsRect);
}
+/*
+ Returns YES
if the two rectangles intersect
+ @group CGRect
+ @param lhsRect the first YES
if the two rectangles have any common spaces, and NO
, otherwise.
+*/
function CGRectIntersectsRect(lhsRect, rhsRect)
{
var intersection = CGRectIntersection(lhsRect, rhsRect);
@@ -79,6 +94,13 @@ function CGRectIntersectsRect(lhsRect, rhsRect)
return !_CGRectIsEmpty(intersection);
}
+/*
+ Makes the origin and size of a anArray
.
+ @param anArray Objects in this array will be added to the new array
+ @return a new anObject
in it.
+ @param anObject the object to be added to the array
+ @return a new anArray
.
+ @param anArray objects in this array will be added to the new array
+ @return a new anArray
+*/
- (id)initWithArray:(CPArray)anArray
{
self = [super init];
@@ -139,6 +184,14 @@ import "CPSortDescriptor.j"
return self;
}
+/*
+ Initializes a the array with the contents of anArray
+ and optionally performs a deep copy of the objects based on copyItems
.
+ @param anArray the array to copy the data from
+ @param copyItems if YES
, each object will be copied by having a copy
message sent to it, and the
+ returned object will be added to the receiver. Otherwise, no copying will be performed.
+ @return the initialized array of objects
+*/
- (id)initWithArray:(CPArray)anArray copyItems:(BOOL)copyItems
{
if (!copyItems)
@@ -164,6 +217,9 @@ import "CPSortDescriptor.j"
return self;
}
+/*
+ initializes
+*/
- (id)initWithObjects:(Array)anObject, ...
{
// The arguments array contains self and _cmd, so the first object is at position 2.
@@ -176,6 +232,12 @@ import "CPSortDescriptor.j"
return self;
}
+/*
+ Initializes the array with a JavaScript array of objects.
+ @param objects the array of objects to add to the receiver
+ @param aCount the number of objects in objects
+ @return the initialized YES
if the array contains anObject
. Otherwise, it returns NO
.
+ @param anObject the method checks if this object is already in the array
+*/
- (BOOL)containsObject:(id)anObject
{
return [self indexOfObject:anObject] != CPNotFound;
}
+/*
+ Returns the number of elements in the array
+*/
- (int)count
{
return length;
}
+/*
+ Returns the index of anObject
in this array.
+ If the object is nil
or not in the array,
+ returns CPNotFound
. It first attempts to find
+ a match using isEqual:
, then ==
.
+ @param anObject the object to search for
+*/
- (int)indexOfObject:(id)anObject
{
if (anObject === nil)
@@ -239,6 +318,14 @@ import "CPSortDescriptor.j"
return CPNotFound;
}
+/*
+ Returns the index of anObject
in the array
+ within aRange
. It first attempts to find
+ a match using isEqual:
, then ==
.
+ @param anObject the object to search for
+ @param aRange the range to search within
+ @return the index of the object, or CPNotFound
if it was not found.
+*/
- (int)indexOfObject:(id)anObject inRange:(CPRange)aRange
{
if (anObject === nil)
@@ -263,6 +350,11 @@ import "CPSortDescriptor.j"
return CPNotFound;
}
+/*
+ Returns the index of anObject
in the array. The test for equality is done using only ==
.
+ @param anObject the object to search for
+ @return the index of the object in the array. CPNotFound
if the object is not in the array.
+*/
- (int)indexOfObjectIdenticalTo:(id)anObject
{
if (anObject === nil)
@@ -287,6 +379,14 @@ import "CPSortDescriptor.j"
return CPNotFound;
}
+/*
+ Returns the index of anObject
in the array
+ within aRange
. The test for equality is
+ done using only ==
.
+ @param anObject the object to search for
+ @param aRange the range to search within
+ @return the index of the object, or CPNotFound
if it was not found.
+*/
- (int)indexOfObjectIdenticalTo:(id)anObject inRange:(CPRange)aRange
{
if (anObject === nil)
@@ -316,6 +416,9 @@ import "CPSortDescriptor.j"
return CPNotFound;
}
+/*
+ Returns the last object in the array. If the array is empty, returns nil
/
+*/
- (id)lastObject
{
var count = [self count];
@@ -325,18 +428,27 @@ import "CPSortDescriptor.j"
return self[count - 1];
}
+/*
+ Returns the object at index anIndex
.
+ @throws CPRangeException if anIndex
is out of bounds
+*/
- (id)objectAtIndex:(int)anIndex
{
return self[anIndex];
}
+/*
+ Returns the objects at indexes
in a new aSelector
is nil
+*/
- (void)makeObjectsPerformSelector:(SEL)aSelector
{
+ if (!aSelector)
+ [CPException raise:CPInvalidArgumentException reason:"makeObjectsPerformSelector: 'aSelector' can't be nil"];
+
var index = 0,
count = length;
@@ -365,8 +494,17 @@ import "CPSortDescriptor.j"
objj_msgSend(self[index], aSelector);
}
+/*
+ Sends each element in the array a message with an argument.
+ @param aSelector the selector of the message to send
+ @param anObject the first argument of the message
+ @throws CPInvalidArgumentException if aSelector
is nil
+*/
- (void)makeObjectsPerformSelector:(SEL)aSelector withObject:(id)anObject
{
+ if (!aSelector)
+ [CPException raise:CPInvalidArgumentException reason:"makeObjectsPerformSelector:withObject 'aSelector' can't be nil"];
+
var index = 0,
count = length;
@@ -375,7 +513,11 @@ import "CPSortDescriptor.j"
}
// Comparing arrays
-
+/*
+ Returns the first object found in the receiver (starting at index 0) which is present in the
+ otherArray
as determined by using the -containsObject:
method.
+ @return the first object found, or nil
if no common object was found.
+*/
- (id)firstObjectCommonWithArray:(CPArray)anArray
{
if (![anArray count] || ![self count])
@@ -391,6 +533,9 @@ import "CPSortDescriptor.j"
return nil;
}
+/*
+ Returns true if anArray contains exactly the same objects as the reciever.
+*/
- (BOOL)isEqualToArray:(id)anArray
{
if(length != anArray.length)
@@ -400,16 +545,25 @@ import "CPSortDescriptor.j"
count = [self count];
for(; index < count; ++index)
- if(self[index] != anObject && (!self[index].isa || !anObject.isa || ![self[index] isEqual:anObject]))
+ if(!self[index] || !anArray[index] || ![self[index] isEqual:anArray[index]])
return NO;
return YES;
}
// Deriving new arrays
-
+/*
+ Returns a copy of this array plus anObject
inside the copy.
+ @param anObject the object to be added to the array copy
+ @throws CPInvalidArgumentException if anObject
is nil
+ @return a new array that should be n+1 in size compared to the receiver.
+*/
- (CPArray)arrayByAddingObject:(id)anObject
{
+ if (!anObject)
+ [CPException raise:CPInvalidArgumentException
+ reason:"arrayByAddingObject: object can't be nil"];
+
var array = [self copy];
array.push(anObject);
@@ -417,6 +571,10 @@ import "CPSortDescriptor.j"
return array;
}
+/*
+ Returns a new array which is the concatenation of self
and otherArray (in this precise order).
+ @param anArray the array that will be concatenated to the receiver's copy
+*/
- (CPArray)arrayByAddingObjectsFromArray:(CPArray)anArray
{
return slice(0).concat(anArray);
@@ -437,13 +595,23 @@ import "CPSortDescriptor.j"
}
*/
+/*
+ Returns a subarray of the receiver containing the objects found in the specified range aRange
.
+ @param aRange the range of objects to be copied into the subarray
+ @throws CPRangeException if the specified range exceeds the bounds of the array
+*/
- (CPArray)subarrayWithRange:(CPRange)aRange
{
- return slice(aRange.location, CPMaxRange(aRange));
+ if (aRange.location < 0 || (aRange.location + CPMaxRange(aRange)) > length)
+ [CPException raise:CPRangeException reason:"subarrayWithRange: aRange out of bounds"];
+
+ return slice(aRange.location, maxRange);
}
// Sorting arrays
-
+/*
+ Not yet described.
+*/
- (CPArray)sortedArrayUsingDescriptors:(CPArray)descriptors
{
var sorted = [self copy];
@@ -453,6 +621,14 @@ import "CPSortDescriptor.j"
return sorted;
}
+/*
+ Returns an array in which the objects are ordered according
+ to a sort with aFunction
. This invokes
+ -sortUsingFunction:context
.
+ @param aFunction a JavaScript 'Function' type that compares objects
+ @param aContext context information
+ @return a new sorted array
+*/
- (CPArray)sortedArrayUsingFunction:(Function)aFunction context:(id)aContext
{
var sorted = [self copy];
@@ -462,6 +638,10 @@ import "CPSortDescriptor.j"
return sorted;
}
+/*
+ Returns a new array in which the objects are ordered according to a sort with aSelector
.
+ @param aSelector the selector that will perform object comparisons
+*/
- (CPArray)sortedArrayUsingSelector:(SEL)aSelector
{
var sorted = [self copy]
@@ -473,6 +653,14 @@ import "CPSortDescriptor.j"
// Working with string elements
+/*
+ Returns a string formed by concatenating the objects in the
+ receiver, with the specified separator string inserted between each part.
+ If the element is a Cappuccino object, then the description
+ of that object will be used, otherwise the default JavaScript representation will be used.
+ @param aString the separator that will separate each object string
+ @return the string representation of the array
+*/
- (CPString)componentsJoinedByString:(CPString)aString
{
var index = 0,
@@ -487,6 +675,9 @@ import "CPSortDescriptor.j"
// Creating a description of the array
+/*
+ Returns a human readable description of this array and it's elements.
+*/
- (CPString)description
{
var i = 0,
@@ -505,7 +696,13 @@ import "CPSortDescriptor.j"
}
// Collecting paths
-
+/*
+ Returns a new array subset formed by selecting the elements that have
+ filename extensions from filterTypes
. Only elements
+ that are of type aKey
from each element in the array.
+ @param aKey the key to return the value for
+ @return an array of containing a value for each element in the array
+*/
- (CPArray)valueForKey:(CPString)aKey
{
var i = 0,
@@ -544,6 +750,10 @@ import "CPSortDescriptor.j"
// Copying arrays
+/*
+ Makes a copy of the receiver.
+ @return a new aCapacity
+ items. Because aCapacity
items. Because anObject
to the end of the array.
+ @param anObject the object to add to the array
+*/
- (void)addObject:(id)anObject
{
push(anObject);
}
-
+
+/*
+ Adds the objects in anArray
to the receiver array.
+ @param anArray the array of objects to add to the end of the receiver
+*/
- (void)addObjectsFromArray:(CPArray)anArray
{
splice.apply(self, [length, 0].concat(anArray));
}
+/*
+ Inserts an object into the receiver at the specified location.
+ @param anObject the object to insert into the array
+ @param anIndex the location to insert anObject
at
+*/
- (void)insertObject:(id)anObject atIndex:(int)anIndex
{
splice(anIndex, 0, anObject);
}
+/*
+ Inserts the objects in the provided array into the receiver at the indexes specified.
+ @param objects the objects to add to this array
+ @param anIndexSet the indices for the objects
+*/
- (void)insertObjects:(CPArray)objects atIndexes:(CPIndexSet)anIndexSet
{
var index = 0,
@@ -590,12 +825,23 @@ import "CPSortDescriptor.j"
while ((position = [indexes indexGreaterThanIndex:position]) != CPNotFound)
[self insertObject:objects[index++] atindex:position];
}
-
+
+/*
+ Replaces the element at anIndex
with anObject
.
+ The current element at position anIndex
will be removed from the array.
+ @param anIndex the position in the array to place anObject
+*/
- (void)replaceObjectAtIndex:(int)anIndex withObject:(id)anObject
{
self[anIndex] = anObject;
}
+/*
+ Replace the elements at the indices specified by anIndexSet
with
+ the objects in objects
.
+ @param anIndexSet the set of indices to array positions that will be replaced
+ @param objects the array of objects to place in the specified indices
+*/
- (void)replaceObjectsAtIndexes:(CPIndexSet)anIndexSet withObjects:(CPArray)objects
{
var i = 0,
@@ -608,6 +854,14 @@ import "CPSortDescriptor.j"
}
}
+/*
+ Replaces some of the receiver's objects with objects from anArray
. Specifically, the elements of the
+ receiver in the range specified by aRange
,
+ with the elements of anArray
in the range specified by otherRange
.
+ @param aRange the range of elements to be replaced in the receiver
+ @param anArray the array to retrieve objects for placement into the receiver
+ @param otherRange the range of objects in anArray
to pull from for placement into the receiver
+*/
- (void)replaceObjectsInRange:(CPRange)aRange withObjectsFromArray:(CPArray)anArray range:(CPRange)otherRange
{
if (!otherRange.location && otherRange.length == [anArray count])
@@ -616,11 +870,22 @@ import "CPSortDescriptor.j"
splice.apply(self, [aRange.location, aRange.length].concat([anArray subarrayWithRange:otherRange]));
}
+/*
+ Replaces some of the receiver's objects with the objects from
+ anArray
. Specifically, the elements of the
+ receiver in the range specified by aRange
.
+ @param aRange the range of elements to be replaced in the receiver
+ @param anArray the array to retrieve objects for placement into the receiver
+*/
- (void)replaceObjectsInRange:(CPRange)aRange withObjectsFromArray:(CPArray)anArray
{
splice.apply(self, [aRange.location, aRange.length].concat(anArray));
}
+/*
+ Sets the contents of the receiver to be identical to the contents of anArray
.
+ @param anArray the array of objects used to replace the receiver's objects
+*/
- (void)setArray:(CPArray)anArray
{
if(self == anArray) return;
@@ -629,22 +894,36 @@ import "CPSortDescriptor.j"
}
// Removing Objects
-
+/*
+ Removes all objects from this array.
+*/
- (void)removeAllObjects
{
splice(0, length);
}
-
+
+/*
+ Removes the last object from the array.
+*/
- (void)removeLastObject
{
pop();
}
+/*
+ Removes all entries of anObject
from the array.
+ @param anObject the object whose entries are to be removed
+*/
- (void)removeObject:(id)anObject
{
[self removeObject:anObject inRange:CPMakeRange(0, length)];
}
+/*
+ Removes all entries of anObject
from the array, in the range specified by aRange
.
+ @param anObject the object to remove
+ @param aRange the range to search in the receiver for the object
+*/
- (void)removeObject:(id)anObject inRange:(CPRange)aRange
{
var index;
@@ -656,11 +935,19 @@ import "CPSortDescriptor.j"
}
}
+/*
+ Removes the object at anIndex
.
+ @param anIndex the location of the element to be removed
+*/
- (void)removeObjectAtIndex:(int)anIndex
{
splice(anIndex, 1);
}
+/*
+ Removes the objects at the indices specified by CPIndexSet
.
+ @param anIndexSet the indices of the elements to be removed from the array
+*/
- (void)removeObjectsAtIndexes:(CPIndexSet)anIndexSet
{
var index = [anIndexSet lastIndex];
@@ -672,11 +959,23 @@ import "CPSortDescriptor.j"
}
}
+/*
+ Remove the first instance of anObject
from the array.
+ The search for the object is done using ==
.
+ @param anObject the object to remove
+*/
- (void)removeObjectIdenticalTo:(id)anObject
{
[self removeObjectIdenticalTo:anObject inRange:CPMakeRange(0, length)];
}
+/*
+ Remove the first instance of anObject
from the array,
+ within the range specified by aRange
.
+ The search for the object is done using ==
.
+ @param anObject the object to remove
+ @param aRange the range in the array to search for the object
+*/
- (void)removeObjectIdenticalTo:(id)anObject inRange:(CPRange)aRange
{
var index;
@@ -688,6 +987,10 @@ import "CPSortDescriptor.j"
}
}
+/*
+ Remove the objects in anArray
from the receiver array.
+ @param anArray the array of objects to remove from the receiver
+*/
- (void)removeObjectsInArray:(CPArray)anArray
{
var index = 0,
@@ -697,13 +1000,21 @@ import "CPSortDescriptor.j"
[self removeObject:anArray[index]];
}
+/*
+ Removes all the objects in the specified range from the receiver.
+ @param aRange the range of objects to remove
+*/
- (void)removeObjectsInRange:(CPRange)aRange
{
splice(aRange.location, aRange.length);
}
// Rearranging objects
-
+/*
+ Swaps the elements at the two specified indices.
+ @param anIndex the first index to swap from
+ @param otherIndex the second index to swap from
+*/
- (void)exchangeObjectAtIndex:(unsigned)anIndex withObjectAtIndex:(unsigned)otherIndex
{
var temporary = self[anIndex];
@@ -727,11 +1038,20 @@ import "CPSortDescriptor.j"
});
}
+/*
+ Sorts the receiver array using a JavaScript function as a comparator, and a specified context.
+ @param aFunction a JavaScript function that will be called to compare objects
+ @param aContext an object that will be passed to aFunction
with comparison
+*/
- (void)sortUsingFunction:(Function)aFunction context:(id)aContext
{
sort(function(lhs, rhs) { return aFunction(lhs, rhs, aContext); });
}
+/*
+ Sorts the receiver array using an Objective-J method as a comparator.
+ @param aSelector the selector for the method to call for comparison
+*/
- (void)sortUsingSelector:(SEL)aSelector
{
sort(function(lhs, rhs) { return objj_msgSend(lhs, aSelector, rhs); });
@@ -753,6 +1073,11 @@ import "CPSortDescriptor.j"
@end
+/*
+ This class is just an empty subclass of NO
. Subclasses supporting keyed coding must override this to return YES
.
+*/
-(BOOL)allowsKeyedCoding
{
return NO;
}
--(void)encodeValueOfObjCType:(const char *)aType at:(const void *)anObject
+/*
+ Encodes a structure or object of a specified type. Usually this
+ is used for primitives though it can be used for objects as well.
+ Subclasses must override this method.
+ @param aType the structure or object type
+ @param anObject the object to be encoded
+*/
+-(void)encodeValueOfObjCType:(CPString)aType at:(id)anObject
{
- NSInvalidAbstractInvocation();
+ CPInvalidAbstractInvocation();
}
+/*
+ Encodes a data object. Subclasses must override this method.
+ @param aData the object to be encoded.
+*/
-(void)encodeDataObject:(CPData)aData
{
- NSInvalidAbstractInvocation();
+ CPInvalidAbstractInvocation();
}
+/*
+ Encodes an object. Subclasses must override this method.
+ @param anObject the object to be encoded
+*/
-(void)encodeObject:(id)anObject
{
// [self encodeValueOfObjCType:@encode(id) at:object];
}
+/*
+ Encodes a point
+ @param aPoint the point to be encoded.
+*/
- (void)encodePoint:(CPPoint)aPoint
{
[self encodeNumber:aPoint.x];
[self encodeNumber:aPoint.y];
}
-- (void)encodeRect:(CPRect)aRect
+/*
+ Encodes a CGRect
+ @param aRect the rectangle to be encoded.
+*/
+- (void)encodeRect:(CGRect)aRect
{
[self encodePoint:aRect.origin];
[self encodeSize:aRect.size];
}
+/*
+ Encodes a CGSize
+ @param aSize the size to be encoded
+*/
- (void)encodeSize:(CPSize)aSize
{
[self encodeNumber:aSize.width];
[self encodeNumber:aSize.height];
}
+/*
+ Encodes a property list. Not yet implemented.
+ @param aPropertyList the property list to be encoded
+*/
-(void)encodePropertyList:(id)aPropertyList
{
// [self encodeValueOfObjCType:@encode(id) at:&propertyList];
}
+/*
+ Encodes the root object of a group of Obj-J objects.
+ @param rootObject the root object to be encoded.
+*/
-(void)encodeRootObject:(id)anObject
{
[self encodeObject:anObject];
}
-
+/*
+ Encodes an object.
+ @param anObject the object to be encoded.
+*/
-(void)encodeBycopyObject:(id)anObject
{
[self encodeObject:object];
}
-
+/*
+ Encodes an object.
+ @param anObject the object to be encoded.
+*/
-(void)encodeConditionalObject:(id)anObject
{
[self encodeObject:object];
@@ -92,6 +141,12 @@ import "CPException.j"
@implementation CPObject (CPCoding)
+/*
+ Called after an object is unarchived in case a different object should be used in place of it.
+ The defaut method returns self
. Interested subclasses should override this.
+ @param aDecoder
+ @return the original object or it's substitute.
+*/
- (id)awakeAfterUsingCoder:(CPCoder)aDecoder
{
return self;
diff --git a/Foundation/CPDictionary.j b/Foundation/CPDictionary.j
index 900396211d..92d74d41d1 100755
--- a/Foundation/CPDictionary.j
+++ b/Foundation/CPDictionary.j
@@ -23,7 +23,9 @@
//import "CPRange.j"
import "CPObject.j"
import "CPEnumerator.j"
+import "CPException.j"
+/* @ignore */
@implementation _CPDictionaryValueEnumerator : CPEnumerator
{
CPEnumerator _keyEnumerator;
@@ -55,35 +57,77 @@ import "CPEnumerator.j"
@end
+/*
+ A dictionary is the standard way of passing around key-value pairs in
+ the Cappuccino framework. It is similar to the
+ Java map interface,
+ except all keys are If you are familiar with dictionaries in Cocoa, you'll notice that
+ there is no CPMutableDictionary class. The regular setObject:
and removeObjectForKey:
methods.
+ In Cappuccino there is no distinction between immutable and mutable classes.
+ They are all mutable.
+*/
@implementation CPDictionary : CPObject
{
}
+/*
+ @ignore
+*/
+ (id)alloc
{
return new objj_dictionary();
}
+/*
+ Returns a new empty aDictionary
.
+ @param aDictionary the dictionary to copy key-value pairs from
+ @return the new aKey
.
+ @param aKey the key for the object's entry
+ @return the object for the entry
+*/
- (id)objectForKey:(CPString)aKey
{
// We should really do this with inlining or something of that nature.
@@ -232,6 +306,9 @@ import "CPEnumerator.j"
while(key= keyEnumerator.nextObject()) this.setObjectForKey(aDictionary.objectForKey(key), key);
}
*/
+/*
+ Removes all the entries from the dictionary.
+*/
- (void)removeAllObjects
{
keys = [];
@@ -239,6 +316,10 @@ import "CPEnumerator.j"
buckets = {};
}
+/*
+ Removes the entry for the specified key.
+ @param aKey the key of the entry to be removed
+*/
- (void)removeObjectForKey:(id)aKey
{
dictionary_removeValue(self, aKey);
@@ -270,6 +351,11 @@ import "CPEnumerator.j"
while(i--) this._dictionary[this._keys[i]]= { object: this._objects[i], index: i };
}
*/
+/*
+ Adds an entry into the dictionary.
+ @param anObject the object for the entry
+ @param aKey the entry's key
+*/
- (void)setObject:(id)anObject forKey:(id)aKey
{
dictionary_setValue(self, aKey, anObject);
@@ -287,6 +373,9 @@ import "CPEnumerator.j"
}
*/
+/*
+ Returns a human readable description of the dictionary.
+*/
- (CPString)description
{
var description = @"CPDictionary {\n";
@@ -305,11 +394,20 @@ import "CPEnumerator.j"
@implementation CPDictionary (CPCoding)
+/*
+ Initializes the dictionary by unarchiving the data from a coder.
+ @param aCoder the coder from which the data will be unarchived.
+ @return the initialized dictionary
+*/
- (id)initWithCoder:(CPCoder)aCoder
{
return [aCoder _decodeDictionaryOfObjectsForKey:@"CP.objects"];
}
+/*
+ Archives the dictionary to a provided coder.
+ @param aCoder the coder to which the dictionary data will be archived.
+*/
- (void)encodeWithCoder:(CPCoder)aCoder
{
[aCoder _encodeDictionaryOfObjects:self forKey:@"CP.objects"];
diff --git a/Foundation/CPEnumerator.j b/Foundation/CPEnumerator.j
index f9c27aeb07..73914071e7 100755
--- a/Foundation/CPEnumerator.j
+++ b/Foundation/CPEnumerator.j
@@ -22,13 +22,27 @@
import "CPObject.j"
+/*
+
+// some code here... +if (input == nil) + [CPException raise:"MyException" reason:"You didn't do something right."]; + +// code that gets executed if no exception was raised ++*/ @implementation CPException : CPObject { } +/* + @ignore +*/ + (id)alloc { return new objj_exception(); } +/* + Raises an exception with a name and reason. + @param aName the name of the exception to raise + @param aReason the reason for the exception +*/ + (void)raise:(CPString)aName reason:(CPString)aReason { [[self exceptionWithName:aName reason:aReason userInfo:nil] raise]; } -+ (id)exceptionWithName:(CPString)aName reason:(CPString)aReason userInfo:(id)aUserInfo +/* + Creates an exception with a name, reason and user info. + @param aName the name of the exception + @param aReason the reason the exception occurred + @param aUserInfo a dictionary containing information about the exception + @return the new exception +*/ ++ (CPException)exceptionWithName:(CPString)aName reason:(CPString)aReason userInfo:(CPDictionary)aUserInfo { return [[self alloc] initWithName:aName reason:aReason userInfo:aUserInfo]; } -- (id)initWithName:(CPString)aName reason:(CPString)aReason userInfo:(id)aUserInfo +/* + Initializes the exception. + @param aName the name of the exception + @param aReason the reason for the exception + @param aUserInfo a dictionary containing information about the exception + @return the initialized exception +*/ +- (id)initWithName:(CPString)aName reason:(CPString)aReason userInfo:(CPDictionary)aUserInfo { self = [super init]; @@ -60,26 +95,41 @@ CPInvalidArgumentException = @"CPInvalidArgumentException"; return self; } +/* + Returns the name of the exception. +*/ - (CPString)name { return name; } +/* + Returns the reason for the exception. +*/ - (CPString)reason { return reason; } -- (id)userInfo +/* + Returns data containing info about the receiver. +*/ +- (CPDictionary)userInfo { return userInfo; } +/* + Returns the exception's reason. +*/ - (CPString)description { return reason; } +/* + Raises the exception and causes the program to go to the exception handler. +*/ - (void)raise { objj_exception_throw(self); @@ -98,6 +148,11 @@ CPInvalidArgumentException = @"CPInvalidArgumentException"; @implementation CPException (CPCoding) +/* + Initializes the exception with data from a coder. + @param aCoder the coder from which to read the exception data + @return the initialized exception +*/ - (id)initWithCoder:(CPCoder)aCoder { self = [super init]; @@ -112,6 +167,10 @@ CPInvalidArgumentException = @"CPInvalidArgumentException"; return self; } +/* + Encodes the exception's data into a coder. + @param aCoder the coder to which the data will be written +*/ - (void)encodeWithCoder:(CPCoder)aCoder { [aCoder encodeObject:name forKey:CPExceptionNameKey]; diff --git a/Foundation/CPIndexSet.j b/Foundation/CPIndexSet.j index 7c3b8857b8..f662ff22e0 100644 --- a/Foundation/CPIndexSet.j +++ b/Foundation/CPIndexSet.j @@ -23,6 +23,9 @@ import "CPRange.j" import "CPObject.j" +/* + Instances of this class are collections of numbers. Each integer can appear in a collection only once. +*/ @implementation CPIndexSet : CPObject { unsigned _count; @@ -31,17 +34,26 @@ import "CPObject.j" } // Creating an Index Set - +/* + Returns a new empty index set. +*/ + (id)indexSet { return [[self alloc] init]; } +/* + Returns a new index set with just one index. +*/ + (id)indexSetWithIndex:(int)anIndex { return [[self alloc] initWithIndex:anIndex]; } +/* + Returns a new index set with all the numbers in the specified range. + @param aRange the range of numbers to add to the index set. +*/ + (id)indexSetWithIndexesInRange:(CPRange)aRange { return [[self alloc] initWithIndexesInRange:aRange]; @@ -63,6 +75,10 @@ import "CPObject.j" return self; } +/* + Initializes the index set with a single index. + @return the initialized index set +*/ - (id)initWithIndex:(int)anIndex { self = [super init]; @@ -77,6 +93,11 @@ import "CPObject.j" return self; } +/* + Initializes the index set with numbers from the specified range. + @param aRange the range of numbers to add to the index set + @return the initialized index set +*/ - (id)initWithIndexesInRange:(CPRange)aRange { self = [super init]; @@ -91,6 +112,11 @@ import "CPObject.j" return self; } +/* + Initializes the index set with another index set. + @param anIndexSet the index set from which to read the initial index set + @return the initialized index set +*/ - (id)initWithIndexSet:(CPIndexSet)anIndexSet { self = [super init]; @@ -112,7 +138,11 @@ import "CPObject.j" } // Querying an Index Set - +/* + Compares the receiver with the provided index set. + @param anIndexSet the index set to compare to + @return
YES
if the receiver and the index set are functionally equivalent
+*/
- (BOOL)isEqualToIndexSet:(CPIndexSet)anIndexSet
{
// Comparisons to ourself are always return YES.
@@ -135,11 +165,20 @@ import "CPObject.j"
return YES;
}
+/*
+ Returns YES
if the index set contains the specified index.
+ @param anIndex the index to check for in the set
+ @return YES
if anIndex
is in the receiver index set
+*/
- (BOOL)containsIndex:(unsigned)anIndex
{
return [self containsIndexesInRange:CPMakeRange(anIndex, 1)];
}
+/*
+ Returns YES
if the index set contains all the numbers in the specified range.
+ @param aRange the range of numbers to check for in the index set
+*/
- (BOOL)containsIndexesInRange:(CPRange)aRange
{
if(!_count)
@@ -167,6 +206,10 @@ import "CPObject.j"
return NO;
}
+/*
+ Returns YES
if the receving index set contains all the indices in the argument.
+ @param anIndexSet the set of indices to check for in the receiving index set
+*/
- (BOOL)containsIndexes:(CPIndexSet)anIndexSet
{
// Return YES if anIndexSet has no indexes
@@ -188,6 +231,11 @@ import "CPObject.j"
return YES;
}
+/*
+ Checks if the receiver contains at least one number in aRange
.
+ @param aRange the range of numbers to check.
+ @return YES
if the receiving index set contains at least one number in the provided range
+*/
- (BOOL)intersectsIndexesInRange:(CPRange)aRange
{
// This is fast thanks to the _cachedIndexRange.
@@ -207,23 +255,35 @@ import "CPObject.j"
return NO;
}
+/*
+ The number of indices in the set
+*/
- (int)count
{
return _count;
}
// Accessing Indexes
-
+/*
+ Return the first index in the set
+*/
- (int)firstIndex
{
return _count ? _ranges[0].location : CPNotFound;
}
+/*
+ Returns the last index in the set
+*/
- (int)lastIndex
{
return _count ? CPMaxRange(_ranges[_ranges.length - 1]) - 1 : CPNotFound;
}
+/*
+ Returns the first index value in the receiver which is greater than anIndex
.
+ @return the closest index or anIndex
.
+ @return the closest index or anIndex
.
+ @return the matching index or anIndex
.
+ @return the matching index or aMaxCount
number have been added or the range maximum is reached.
+ @param anArray the array to fill up
+ @param aMaxCount the maximum number of numbers to adds
+ @param aRangePointer the range of indices to add
+ @return the number of elements added to the array
+*/
+- (unsigned)getIndexes:(CPArray)anArray maxCount:(unsigned)aMaxCount inIndexRange:(CPRange)aRangePointer
{
if (!_count || aMacCount <= 0 || aRangePointer && !aRangePointer.length)
return 0;
@@ -350,12 +431,19 @@ import "CPObject.j"
@implementation CPIndexSet(CPMutableIndexSet)
// Adding indexes.
-
+/*
+ Adds an index to the set.
+ @param anIndex the index to add
+*/
- (void)addIndex:(unsigned)anIndex
{
[self addIndexesInRange:CPMakeRange(anIndex, 1)];
}
+/*
+ Adds indices to the set
+ @param anIndexSet a set of indices to add to the receiver
+*/
- (void)addIndexes:(CPIndexSet)anIndexSet
{
var i = 0,
@@ -367,6 +455,10 @@ import "CPObject.j"
[self addIndexesInRange:ranges[i]];
}
+/*
+ Adds the range of indices to the set
+ @param aRange the range of numbers to add as indices to the set
+*/
- (void)addIndexesInRange:(CPRange)aRange
{
if (_ranges.length == 0)
@@ -457,12 +549,20 @@ import "CPObject.j"
}
// Removing Indexes
-
+/*
+ Removes an index from the set
+ @param anIndex the index to remove
+*/
- (void)removeIndex:(unsigned int)anIndex
{
[self removeIndexesInRange:CPMakeRange(anIndex, 1)];
}
+/*
+ Removes the indices from the receiving set.
+ @param anIndexSet the set of indices to remove
+ from the receiver
+*/
- (void)removeIndexes:(CPIndexSet)anIndexSet
{
var i = 0,
@@ -474,6 +574,9 @@ import "CPObject.j"
[self removeIndexesInRange:ranges[i]];
}
+/*
+ Removes all indices from the set
+*/
- (void)removeAllIndexes
{
_ranges = [];
@@ -481,6 +584,11 @@ import "CPObject.j"
_cachedRangeIndex = 0;
}
+/*
+ Removes the indices in the range from the
+ set.
+ @param aRange the range of indices to remove
+*/
- (void)removeIndexesInRange:(CPRange)aRange
{
// FIXME: Should we really use SOERangeIndex here? There is no real
@@ -543,7 +651,12 @@ import "CPObject.j"
}
// Shifting Index Groups
-
+/*
+ Shifts the values of indices left or right by a specified amount.
+ @param anIndex the index to start the shifting operation from (inclusive)
+ @param aDelta the amount and direction to shift. A positive value shifts to
+ the right. A negative value shifts to the left.
+*/
- (void)shiftIndexesStartingAtIndex:(unsigned)anIndex by:(int)aDelta
{
if (!_count || aDelta == 0)
@@ -624,6 +737,12 @@ var CPIndexSetCountKey = @"CPIndexSetCountKey",
@implementation CPIndexSet (CPCoding)
+/*
+ Initializes the index set from a coder.
+ @param aCoder the coder from which to read the
+ index set data
+ @return the initialized index set
+*/
- (id)initWithCoder:(CPCoder)aCoder
{
self = [super init];
@@ -645,6 +764,11 @@ var CPIndexSetCountKey = @"CPIndexSetCountKey",
return self;
}
+/*
+ Writes out the index set to the specified coder.
+ @param aCoder the coder to which the index set will
+ be written
+*/
- (void)encodeWithCoder:(CPCoder)aCoder
{
[aCoder encodeInt:_count forKey:CPIndexSetCountKey];
@@ -664,11 +788,23 @@ var CPIndexSetCountKey = @"CPIndexSetCountKey",
@implementation CPIndexSet (CPCopying)
+/*
+ Creates a deep copy of the index set. The returned copy
+ is mutable. The reason for the two copy methods is for
+ source compatability with GNUStep code.
+ @return the index set copy
+*/
- (id)copy
{
return [[[self class] alloc] initWithIndexSet:self];
}
+/*
+ Creates a deep copy of the index set. The returned copy
+ is mutable. The reason for the two copy methods is for
+ source compatability with GNUStep code.
+ @return the index set copy
+*/
- (id)mutableCopy
{
return [[[self class] alloc] initWithIndexSet:self];
@@ -676,6 +812,11 @@ var CPIndexSetCountKey = @"CPIndexSetCountKey",
@end
+/*
+ This class is an empty of subclass of self
and _cmd
.
+ @param anArgument the argument to add
+ @param anIndex the index of the argument in the method
+*/
- (void)setArgument:(id)anArgument atIndex:(unsigned)anIndex
{
_arguments[anIndex] = anArgument;
}
+/*
+ Returns the argument at the specified index. Arguments 0 and 1 are
+ self
and _cmd
respectively. Thus, method arguments start at 2.
+ @param anIndex the index of the argument to return
+ @throws CPInvalidArgumentException if anIndex is greater than or equal to the invocation's number of arguments.
+*/
- (id)argumentAtIndex:(unsigned)anIndex
{
return _arguments[anIndex];
}
+/*
+ Sets the invocation's return value
+ @param the invocation return value
+*/
- (void)setReturnValue:(id)aReturnValue
{
_returnValue = aReturnValue;
}
+/*
+ Returns the invocation's return value
+*/
- (id)returnValue
{
return _returnValue;
}
// Dispatching an Invocation
-
+/*
+ Sends the encapsulated message to the stored target.
+*/
- (void)invoke
{
_returnValue = objj_msgSend.apply(objj_msgSend, _arguments);
}
+/*
+ Sends the encapsulated message to the specified target.
+ @param the target to which the message will be sent
+*/
- (void)invokeWithTarget:(id)aTarget
{
_arguments[0] = aTarget;
@@ -111,6 +161,11 @@ var CPInvocationArguments = @"CPInvocationArguments",
@implementation CPInvocation (CPCoding)
+/*
+ Initializes the invocation with data from a coder.
+ @param aCoder the coder from which to obtain initialization data
+ @return the initialized invocation
+*/
- (id)initWithCoder:(CPCoder)aCoder
{
self = [super init];
@@ -124,6 +179,10 @@ var CPInvocationArguments = @"CPInvocationArguments",
return self;
}
+/*
+ Writes out the invocation's data to the provided coder.
+ @param aCoder the coder to which the data will be written
+*/
- (void)encodeWithCoder:(CPCoder)aCoder
{
[aCoder encodeObject:_returnValue forKey:CPInvocationReturnValue];
diff --git a/Foundation/CPKeyValueCoding.j b/Foundation/CPKeyValueCoding.j
index 260179071b..d0cdbbd13d 100644
--- a/Foundation/CPKeyValueCoding.j
+++ b/Foundation/CPKeyValueCoding.j
@@ -29,6 +29,7 @@ import "CPObject.j"
return YES;
}
+/* @ignore */
+ (SEL)_accessorForKey:(CPString)aKey
{
var capitalizedKey = aKey.charAt(0).toUpperCase() + aKey.substr(1),
@@ -36,12 +37,14 @@ import "CPObject.j"
if ([self instancesRespondToSelector:selector] ||
[self instancesRespondToSelector:selector = CPSelectorFromString(aKey)] ||
+ [self instancesRespondToSelector:selector = CPSelectorFromString("_"+aKey)] ||
[self instancesRespondToSelector:selector = CPSelectorFromString("is" + capitalizedKey)])
return selector;
return nil;
}
+/* @ignore */
+ (SEL)_modifierForKey:(CPString)aKey
{
var selector = CPSelectorFromString("set" + aKey.charAt(0).toUpperCase() + aKey.substr(1) + ':');
@@ -52,6 +55,7 @@ import "CPObject.j"
return nil;
}
+/* @ignore */
- (CPString)_ivarForKey:(CPString)aKey
{
var ivar,
diff --git a/Foundation/CPKeyedArchiver.j b/Foundation/CPKeyedArchiver.j
index 02c71570c5..0951000d2a 100644
--- a/Foundation/CPKeyedArchiver.j
+++ b/Foundation/CPKeyedArchiver.j
@@ -53,11 +53,44 @@ var _CPKeyedArchiverNullString = "$null",
var _CPKeyedArchiverStringClass = Nil,
_CPKeyedArchiverNumberClass = Nil;
+/* @ignore */
@implementation _CPKeyedArchiverValue : CPValue
{
}
@end
+/*
+ Implements keyed archiving of object graphs. Archiving means to
+ write data out in a format that be read in again later, or possibly
+ stored in a file. To read the data back in, use a
+ CPKeyedUnarchiver
.
+
+ @delegate -(void)archiverWillFinish:(CPKeyedArchiver)archiver;
+ Called when the encoding is about to finish.
+ @param archiver the archiver that's about to finish
+
+ @delegate -(void)archiver:(CPKeyedArchiver)archiver didEncodeObject:(id)object;
+ Called when an object is encoded into the archiver.
+ @param archiver the archiver that encoded the object
+ @param object the object that was encoded
+
+ @delegate -(void)archiverDidFinish:(CPKeyedArchiver)archiver;
+ Called when the archiver finishes encoding.
+ @param archiver the arhiver that finished encoding
+
+ @delegate -(id)archiver:(CPKeyedArchiver)archiver willEncodeObject:(id)object;
+ Called when an object is about to be encoded. Allows the delegate to replace
+ the object that gets encoded with a substitute or nil
.
+ @param archiver the archiver encoding the object
+ @param object the candidate object for encoding
+ @return the object to encode
+
+ @delegate -(void)archiver:(CPKeyedArchiver)archiver willReplaceObject:(id)object withObject:(id)newObject;
+ Called when an object is being replaced in the archiver.
+ @param archiver the archiver encoding the object
+ @param object the object to be replaced
+ @param newObject the replacement object
+*/
@implementation CPKeyedArchiver : CPCoder
{
id _delegate;
@@ -80,6 +113,9 @@ var _CPKeyedArchiverStringClass = Nil,
}
+/*
+ @ignore
+*/
+ (void)initialize
{
if (self != [CPKeyedArchiver class])
@@ -96,6 +132,11 @@ var _CPKeyedArchiverStringClass = Nil,
return YES;
}
+/*
+ Archives the specified object.
+ @param anObject the object to archive
+ @return the archived object
+*/
+ (CPData)archivedDataWithRootObject:(id)anObject
{
var data = [CPData dataWithPlistObject:nil],
@@ -108,7 +149,11 @@ var _CPKeyedArchiverStringClass = Nil,
}
// Initializing an NSKeyedArchiver object
-
+/*
+ Initializes the keyed archiver with the specified CPMutableData
for writing.
+ @param data the object to archive to
+ @return the initialized keyed archiver
+*/
- (id)initForWritingWithMutableData:(CPMutableData)data
{
self = [super init];
@@ -134,6 +179,10 @@ var _CPKeyedArchiverStringClass = Nil,
}
// Archiving Data
+/*
+ Finishes up writing any left over data, and notifies delegates.
+ After calling this method, the archiver can not encode anymore objects.
+*/
- (void)finishEncoding
{
if (_delegate && _delegateSelectors & _CPKeyedArchiverWillFinishSelector)
@@ -171,38 +220,67 @@ var _CPKeyedArchiverStringClass = Nil,
[_delegate archiverDidFinish:self];
}
-- (void)outputFormat
+/*
+ Returns the property list format used to archive objects.
+*/
+- (CPPropertyListFormat)outputFormat
{
return _outputFormat;
}
+/*
+ Sets the property list format the archiver should use to archive objects.
+ @param aPropertyListFormat the format to use
+*/
- (void)setOutputFormat:(CPPropertyListFormat)aPropertyListFormat
{
_outputFormat = aPropertyListFormat;
}
+/*
+ Encodes a BOOL
value
+ @param aBool the BOOL
value
+ @param aKey the key to associate with the BOOL
+*/
- (void)encodeBool:(BOOL)aBOOL forKey:(CPString)aKey
{
[_plistObject setObject:_CPKeyedArchiverEncodeObject(self, aBOOL, NO) forKey:aKey];
}
+/*
+ Encodes a double
value
+ @param aDouble the double
value
+ @param aKey the key to associate with the double
+*/
- (void)encodeDouble:(double)aDouble forKey:(CPString)aKey
{
[_plistObject setObject:_CPKeyedArchiverEncodeObject(self, aDouble, NO) forKey:aKey];
}
+/*
+ Encodes a float
value
+ @param aFloat the float
value
+ @param aKey the key to associate with the float
+*/
- (void)encodeFloat:(float)aFloat forKey:(CPString)aKey
{
[_plistObject setObject:_CPKeyedArchiverEncodeObject(self, aFloat, NO) forKey:aKey];
}
+/*
+ Encodes a int
value
+ @param anInt the int
value
+ @param aKey the key to associate with the int
+*/
- (void)encodeInt:(float)anInt forKey:(CPString)aKey
{
[_plistObject setObject:_CPKeyedArchiverEncodeObject(self, anInt, NO) forKey:aKey];
}
// Managing Delegates
-
+/*
+ Sets the keyed archiver's delegate
+*/
- (void)setDelegate:(id)aDelegate
{
_delegate = aDelegate;
@@ -224,41 +302,77 @@ var _CPKeyedArchiverStringClass = Nil,
}
+/*
+ Returns the keyed archiver's delegate
+*/
- (id)delegate
{
return _delegate;
}
-- (void)encodePoint:(CPPoint)aPoint forKey:(CPString)aKey
+/*
+ Encodes a aClass
encountered by all keyed archivers will
+ instead be archived as a class of type aClassName
.
+ @param aClassName the substitute class name
+ @param aClass the class to substitute
+*/
+ (void)setClassName:(CPString)aClassName forClass:(Class)aClass
{
if (!CPArchiverReplacementClassNames)
@@ -293,6 +414,13 @@ var _CPKeyedArchiverStringClass = Nil,
[CPArchiverReplacementClassNames setObject:aClassName forKey:CPStringFromClass(aClass)];
}
+/*
+ Returns the name of the substitute class used for encoding
+ aClass
by all keyed archivers.
+ @param aClass the class to substitute
+ @return the name of the substitute class, or nil
if there
+ is no substitute class
+*/
+ (CPString)classNameForClass:(Class)aClass
{
if (!CPArchiverReplacementClassNames)
@@ -303,6 +431,13 @@ var _CPKeyedArchiverStringClass = Nil,
return className ? className : aClass.name;
}
+/*
+ Allows substitution of class types for encoding. Specifically classes
+ of type aClass
encountered by this keyed archiver will
+ instead be archived as a class of type aClassName
.
+ @param aClassName the substitute class name
+ @param aClass the class to substitute
+*/
- (void)setClassName:(CPString)aClassName forClass:(Class)aClass
{
if (!_replacementClassNames)
@@ -311,6 +446,11 @@ var _CPKeyedArchiverStringClass = Nil,
[_replacementClassNames setObject:aClassName forKey:CPStringFromClass(aClass)];
}
+/*
+ Returns the name of the substitute class used for encoding aClass
by this keyed archiver.
+ @param aClass the class to substitute
+ @return the name of the substitute class, or nil
if there is no substitute class
+*/
- (CPString)classNameForClass:(Class)aClass
{
if (!_replacementClassNames)
diff --git a/Foundation/CPKeyedUnarchiver.j b/Foundation/CPKeyedUnarchiver.j
index fb34849f6a..009f749857 100644
--- a/Foundation/CPKeyedUnarchiver.j
+++ b/Foundation/CPKeyedUnarchiver.j
@@ -24,7 +24,7 @@ import "CPNull.j"
import "CPCoder.j"
-var _CPKeyedUnarchiverCannotDecodeObjectOfClassNameOriginalClassSelector = 1,
+var _CPKeyedUnarchiverCannotDecodeObjectOfClassNameOriginalClassesSelector = 1,
_CPKeyedUnarchiverDidDecodeObjectSelector = 1 << 1,
_CPKeyedUnarchiverWillReplaceObjectWithObjectSelector = 1 << 2,
_CPKeyedUnarchiverWillFinishSelector = 1 << 3,
@@ -48,6 +48,48 @@ var _CPKeyedUnarchiverArrayClass = Ni
_CPKeyedUnarchiverDictionaryClass = Nil,
_CPKeyedUnarchiverArchiverValueClass = Nil;
+/*
+ nil
+ to abort the unarchiving operation
+
+ @delegate -(id)unarchiver:(CPKeyedUnarchiver)unarchiver didDecodeObject:(id)object;
+ Called when the unarchiver decodes an object.
+ @param unarchiver the unarchiver doing the decoding
+ @param object the decoded objec
+ @return a substitute to use for the decoded object. This can be the same object argument provide,
+ another object or nil
.
+
+ @delegate -(void)unarchiver:(CPKeyedUnarchiver)unarchiver willReplaceObject:(id)object withObject:(id)newObject;
+ Called when a decoded object has been substituted with another. (for example, from unarchiver:didDecodeObject:
.
+ @param unarchiver the unarchiver that decoded the object
+ @param object the original decoded object
+ @param newObject the replacement object
+
+ @delegate -(void)unarchiverWillFinish:(CPKeyedUnarchiver)unarchiver;
+ Called when the unarchiver is about to finish decoding.
+ @param unarchiver the unarchiver that's about to finish
+
+ @delegate -(void)unarchiverDidFinish:(CPKeyedUnarchiver)unarchiver;
+ Called when the unarchiver has finished decoding.
+ @param unarchiver the unarchiver that finished decoding
+*/
@implementation CPKeyedUnarchiver : CPCoder
{
id _delegate;
@@ -65,6 +107,9 @@ var _CPKeyedUnarchiverArrayClass = Ni
CPArray _plistObjects;
}
+/*
+ @ignore
+*/
+ (void)initialize
{
if (self != [CPKeyedUnarchiver class])
@@ -76,6 +121,11 @@ var _CPKeyedUnarchiverArrayClass = Ni
_CPKeyedUnarchiverArchiverValueClass = [_CPKeyedArchiverValue class];
}
+/*
+ Initializes the receiver to unarchive objects from the specified data object.
+ @param data the data stream from which to read objects
+ @return the initialized unarchiver
+*/
- (id)initForReadingWithData:(CPData)data
{
self = [super init];
@@ -92,6 +142,11 @@ var _CPKeyedUnarchiverArrayClass = Ni
return self;
}
+/*
+ Unarchives the object graph in the provided data object.
+ @param data the data from which to read the graph
+ @return the unarchived object
+*/
+ (id)unarchiveObjectWithData:(CPData)data
{
var unarchiver = [[self alloc] initForReadingWithData:data],
@@ -102,19 +157,30 @@ var _CPKeyedUnarchiverArrayClass = Ni
return object;
}
+/*
+ Not implemented
+*/
+ (id)unarchiveObjectWithFile:(CPString)aFilePath
{
}
+/*
+ Not implemented
+*/
+ (id)unarchiveObjectWithFile:(CPString)aFilePath asynchronously:(BOOL)aFlag
{
}
+/*
+ Returns YES
if an object exists for aKey
.
+ @param aKey the object's associated key
+*/
- (BOOL)containsValueForKey:(CPString)aKey
{
return [_plistObject objectForKey:aKey] != nil;
}
+/* @ignore */
- (id)_decodeArrayOfObjectsForKey:(CPString)aKey
{
var object = [_plistObject objectForKey:aKey];
@@ -134,6 +200,7 @@ var _CPKeyedUnarchiverArrayClass = Ni
return nil;
}
+/* @ignore */
- (void)_decodeDictionaryOfObjectsForKey:(CPString)aKey
{
var object = [_plistObject objectForKey:aKey];
@@ -153,27 +220,52 @@ var _CPKeyedUnarchiverArrayClass = Ni
return nil;
}
+/*
+ Decodes a BOOL
from the archive
+ @param aKey the BOOL
's associated key
+ @return the decoded BOOL
+*/
- (BOOL)decodeBoolForKey:(CPString)aKey
{
return [self decodeObjectForKey:aKey];
}
+/*
+ Decodes a float
from the archive
+ @param aKey the float
's associated key
+ @return the decoded float
+*/
- (float)decodeFloatForKey:(CPString)aKey
{
return [self decodeObjectForKey:aKey];
}
+/*
+ Decodes a double
from the archive.
+ @param aKey the double
's associated key
+ @return the decoded double
+*/
- (double)decodeDoubleForKey:(CPString)aKey
{
return [self decodeObjectForKey:aKey];
}
+/*
+ Decodes an int
from the archive.
+ @param aKey the int
's associated key
+ @return the decoded int
+*/
- (int)decodeIntForKey:(CPString)aKey
{
return [self decodeObjectForKey:aKey];
}
-- (CPPoint)decodePointForKey:(CPString)aKey
+/*
+ Decodes a nil
.
+ @param anObserver the observing object
+ @param aSelector the message sent to the observer when a notification occurrs
+ @param aNotificationName the name of the notification the observer wants to watch
+ @param anObject the object in the notification the observer wants to watch
+*/
- (void)addObserver:(id)anObserver selector:(SEL)aSelector name:(CPString)aNotificationName object:(id)anObject
{
var registry,
@@ -70,6 +85,10 @@ var CPNotificationDefaultCenter = nil;
[registry addObserver:observer object:anObject];
}
+/*
+ Unregisters the specified observer from all notifications.
+ @param anObserver the observer to unregister
+*/
- (void)removeObserver:(id)anObserver
{
var name = nil,
@@ -81,6 +100,12 @@ var CPNotificationDefaultCenter = nil;
[_unnamedRegistry removeObserver:anObserver object:nil];
}
+/*
+ Unregisters the specified observer from notifications matching the specified name and/or object.
+ @param anObserver the observer to remove
+ @param aNotificationName the name of notifications to no longer watch
+ @param anObject notifications containing this object will no longer be watched
+*/
- (void)removeObserver:(id)anObserver name:(CPString)aNotificationName object:(id)anObject
{
if (aNotificationName == nil)
@@ -97,16 +122,35 @@ var CPNotificationDefaultCenter = nil;
[[_namedRegistries objectForKey:aNotificationName] removeObserver:anObserver object:anObject];
}
+/*
+ Posts a notification to all observers that match the specified notification's name and object.
+ @param aNotification the notification being posted
+ @throws CPInvalidArgumentException if aNotification is nil
. This is handy when a collection
+ only accepts objects as values, but you would like a nil
representation in there.
+*/
@implementation CPNull : CPObject
{
}
@@ -35,7 +39,11 @@ var CPNullSharedNull = nil;
return [super alloc];
}*/
-
+/*
+ Returns the singleton instance of the nil
should
+ be interpreted as the same, they are not equal ('==').
+*/
+ (CPNull)null
{
if (!CPNullSharedNull)
diff --git a/Foundation/CPNumber.j b/Foundation/CPNumber.j
index 99ead4aaab..d408d2ecf4 100644
--- a/Foundation/CPNumber.j
+++ b/Foundation/CPNumber.j
@@ -26,6 +26,11 @@ import "CPObjJRuntime.j"
var __placeholder = new Number(),
_CPNumberHashes = { };
+/*
+ This class primarily exists for source compatability. The JavaScript
+ Number
type can be changed on the fly based on context,
+ so there is no need to call any of these methods.
+*/
@implementation CPNumber : CPObject
+ (id)alloc
@@ -93,12 +98,12 @@ var __placeholder = new Number(),
{
return anUnsignedLong;
}
-
+/*
+ (id)numberWithUnsignedLongLong:(unsigned long long)anUnsignedLongLong
{
return anUnsignedLongLong;
}
-
+*/
+ (id)numberWithUnsignedShort:(unsigned short)anUnsignedShort
{
return anUnsignedShort;
@@ -164,12 +169,12 @@ var __placeholder = new Number(),
{
return anUnsignedLong;
}
-
+/*
- (id)initWithUnsignedLongLong:(unsigned long long)anUnsignedLongLong
{
return anUnsignedLongLong;
}
-
+*/
- (id)initWithUnsignedShort:(unsigned short)anUnsignedShort
{
return anUnsignedShort;
@@ -265,13 +270,13 @@ FIXME: Do we need this?
if (typeof self == "boolean") return self ? 1 : 0;
return self;
}
-
+/*
- (unsigned long long)unsignedLongLongValue
{
if (typeof self == "boolean") return self ? 1 : 0;
return self;
}
-
+*/
- (unsigned long)unsignedLongValue
{
if (typeof self == "boolean") return self ? 1 : 0;
diff --git a/Foundation/CPObject.j b/Foundation/CPObject.j
index 35587acec0..c67cdaf4ee 100644
--- a/Foundation/CPObject.j
+++ b/Foundation/CPObject.j
@@ -34,53 +34,87 @@
// CPLog("calling initialize "+self.name);
}
+/*
+ Allocates a new instance of the receiver, and sends it an init
+ @return the new object
+*/
+ (id)new
{
return [[self alloc] init];
}
+/*
+ Allocates a new instance of the receiving class
+*/
+ (id)alloc
{
// CPLog("calling alloc on " + self.name + ".");
return class_createInstance(self);
}
+/*
+ Initializes the receiver
+ @return the initialized receiver
+*/
- (id)init
{
return self;
}
+/*
+ Makes a deep copy of the receiver. The copy should be functionally equivalent to the receiver.
+ @return the copy of the receiver
+*/
- (id)copy
{
return self;
}
+/*
+ Creates a deep mutable copy of the receiver.
+ @return the mutable copy of the receiver
+*/
- (id)mutableCopy
{
return [self copy];
}
+/*
+ Not necessary to call in Objective-J. Only exists for code compatability.
+*/
- (void)dealloc
{
}
// Identifying classes
-
+/*
+ Returns the YES
if the receiving class is a subclass of aClass
.
+ @param aClass the class to test inheritance from
+*/
+ (BOOL)isSubclassOfClass:(Class)aClass
{
var theClass = self;
@@ -91,28 +125,49 @@
return NO;
}
+/*
+ Returns YES
if the receiver is a aClass
type, or a subtype of it.
+ @param aClass the class to test as the receiver's class or super class.
+*/
- (BOOL)isKindOfClass:(Class)aClass
{
return [isa isSubclassOfClass:aClass];
}
+/*
+ Returns YES
if the receiver is of the aClass
class type.
+ @param aClass the class to test the receiper
+*/
- (BOOL)isMemberOfClass:(Class)aClass
{
return self.isa == aClass;
}
+/*
+ Determines whether the receiver's root object is a proxy.
+ @return YES
if the root object is a proxy
+*/
- (BOOL)isProxy
{
return NO;
}
// Testing class functionality
-
+/*
+ Test whether instances of this class respond to the provided selector.
+ @param aSelector the selector for which to test the class
+ @return YES
if instances of the class respond to the selector
+*/
+ (BOOL)instancesRespondToSelector:(SEL)aSelector
{
return class_getInstanceMethod(self, aSelector);
}
+/*
+ Tests whether the receiver responds to the provided selector.
+ @param aSelector the selector for which to test the receiver
+ @return YES
if the receiver responds to the selector
+*/
- (BOOL)respondsToSelector:(SEL)aSelector
{
return class_getInstanceMethod(isa, aSelector) != NULL;
@@ -120,16 +175,31 @@
// Obtaining method information
+/*
+ Returns the address of the receiver's method for the provided selector.
+ @param aSelector the selector for the method to return
+ @return the address of the method's implementation
+*/
- (IMP)methodForSelector:(SEL)aSelector
{
return class_getInstanceMethod(isa, aSelector);
}
+/*
+ Returns the address of the receiving class' method for the provided selector.
+ @param aSelector the selector for the class method to return
+ @return the address of the method's implementation
+*/
+ (IMP)instanceMethodForSelector:(SEL)aSelector
{
return class_getInstanceMethod(isa, aSelector);
}
+/*
+ Returns the method signature for the provided selector.
+ @param aSelector the selector for which to find the method signature
+ @return the selector's methd signature
+*/
- (CPMethodSignature)methodSignatureForSelector:(SEL)aSelector
{
// FIXME: We need to implement method signatures.
@@ -137,36 +207,64 @@
}
// Describing objects
-
+/*
+ Returns a human readable string describing the receiver
+*/
- (CPString)description
{
return "<" + isa.name + " 0x" + [CPString stringWithHash:[self hash]] + ">";
}
// Sending Messages
-
+/*
+ Sends the specified message to the receiver.
+ @param aSelector the message to send
+ @return the return value of the message
+*/
- (id)performSelector:(SEL)aSelector
{
return objj_msgSend(self, aSelector);
}
+/*
+ Sends the specified message to the receiver, with one argument.
+ @param aSelector the message to send
+ @param anObject the message argument
+ @return the return value of the message
+*/
- (id)performSelector:(SEL)aSelector withObject:(id)anObject
{
return objj_msgSend(self, aSelector, anObject);
}
+/*
+ Sends the specified message to the receiver, with two arguments.
+ @param aSelector the message to send
+ @param anObject the first message argument
+ @param anotherObject the second message argument
+ @return the return value of the message
+*/
- (id)performSelector:(SEL)aSelector withObject:(id)anObject withObject:(id)anotherObject
{
return objj_msgSend(self, aSelector, anObject, anotherObject);
}
// Forwarding Messages
-
+/*
+ Subclasses can override this method to forward message to
+ other objects. Overwriting this method in conjunction with
+ methodSignatureForSelector:
allows the receiver to
+ forward messages for which it does not respond, to another object that does.
+*/
- (void)forwardInvocation:(CPInvocation)anInvocation
{
[self doesNotRecognizeSelector:[anInvocation selector]];
}
+/*
+ Used for forwarding of messages to other objects.
+ @ignore
+*/
- (void)forward:(SEL)aSelector :(marg_list)args
{
var signature = [self methodSignatureForSelector:_cmd];
@@ -193,7 +291,11 @@
}
// Error Handling
-
+/*
+ Called by the Objective-J runtime when an object can't respond to
+ a message. It's not recommended to call this method directly, unless
+ you need your class to not support a method that it has inherited from a super class.
+*/
- (void)doesNotRecognizeSelector:(SEL)aSelector
{
[CPException raise:CPInvalidArgumentException reason:
@@ -202,37 +304,71 @@
}
// Archiving
-
-- (void)awakeAfterUsingCoder:(CPCoder)aCoder
+/*
+ Subclasses override this method to possibly substitute
+ the unarchived object with another. This would be
+ useful if your program utilizes a
+ flyweight pattern.
+ The method is called by nil
means to ignore the method result.
+*/
- (Class)classForKeyedArchiver
{
return [self classForCoder];
}
+/*
+ Can be overridden by subclasses to substitute a different class to represent the receiver during coding.
+ @return the class to use for coding
+*/
- (Class)classForCoder
{
return [self class];
}
+/*
+ Can be overridden by subclasses to substitute another object during archiving.
+ @param anArchiver that archiver
+ @return the object to archive
+*/
- (id)replacementObjectForArchiver:(CPArchiver)anArchiver
{
return [self replacementObjectForCoder:anArchiver];
}
+/*
+ Can be overridden by subclasses to substitute another object during keyed archiving.
+ @param anArchive the keyed archiver
+ @return the object to archive
+*/
- (id)replacementObjectForKeyedArchiver:(CPKeyedArchiver)anArchiver
{
return [self replacementObjectForCoder:anArchiver];
}
+/*
+ Can be overridden by subclasses to substitute another object during coding.
+ @param aCoder the coder
+ @return the object to code
+*/
- (id)replacementObjectForCoder:(CPCoder)aCoder
{
return self;
}
+/*
+ Sets the class version number.
+ @param the new version number for the class
+*/
+ (id)setVersion:(int)aVersion
{
version = aVersion;
@@ -240,49 +376,77 @@
return self;
}
+/*
+ Returns the class version number.
+*/
+ (int)version
{
return version;
}
// Scripting (?)
-
+/*
+ Returns the class name
+*/
- (CPString)className
{
return isa.name;
}
// Extras
-
+/*
+ Does nothing.
+ @return the receiver
+*/
- (id)autorelease
{
return self;
}
+/*
+ Returns a hash for the object
+*/
- (unsigned)hash
{
return __address;
}
+/*
+ Determines if anObject
is functionally equivalent to the receiver.
+ @return YES
if anObject
is functionally equivalent to the receiver.
+*/
- (BOOL)isEqual:(id)anObject
{
return self === anObject;
}
-- (void)retain
+/*
+ Does nothing.
+ @return the receiver
+*/
+- (id)retain
{
return self;
}
+/*
+ Does nothing.
+*/
- (void)release
{
}
+/*
+ Returns the receiver.
+*/
- (id)self
{
return self;
}
+/*
+ Returns the receiver's super class.
+*/
- (Class)superclass
{
return isa.super_class;
diff --git a/Foundation/CPRange.j b/Foundation/CPRange.j
index 30c36c86d6..8172fe7387 100755
--- a/Foundation/CPRange.j
+++ b/Foundation/CPRange.j
@@ -20,47 +20,106 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+/*
+ Makes a length
to 0.
+ @param aRange the range to empty
+ @group CPRange
+ @return CPRange the empty range (same as the argument)
+*/
function CPEmptyRange(aRange)
{
return aRange.length == 0;
}
+/*
+ Finds the range maximum. (location + length
)
+ @param aRange the range to calculate a maximum from
+ @group CPRange
+ @return int the range maximum
+*/
function CPMaxRange(aRange)
{
return aRange.location + aRange.length;
}
+/*
+ Determines if two YES
if the two YES
if aLocation/code> is within the range
+*/
function CPLocationInRange(aLocation, aRange)
{
return (aLocation >= aRange.location) && (aLocation < CPMaxRange(aRange));
}
+/*
+ Creates a new range with the minimum location
and a length
+ that extends to the maximum length
.
+ @param lhsRange the first CPRange
+ @param rhsRange the second CPRange
+ @group CPRange
+ @return CPRange the new CPRange
+*/
function CPUnionRange(lhsRange, rhsRange)
{
var location = Math.min(lhsRange.location, rhsRange.location);
return CPMakeRange(location, Math.max(CPMaxRange(lhsRange), CPMaxRange(rhsRange)) - location);
}
+/*
+ Creates a new CPRange that spans the common range of two CPRange s
+ @param lhsRange the first CPRange
+ @param rhsRange the second CPRange
+ @group CPRange
+ @return CPRange the new CPRange
+*/
function CPIntersectionRange(lhsRange, rhsRange)
{
if(CPMaxRange(lhsRange) < rhsRange.location || CPMaxRange(rhsRange) < lhsRange.location)
@@ -70,11 +129,23 @@ function CPIntersectionRange(lhsRange, rhsRange)
return CPMakeRange(location, Math.min(CPMaxRange(lhsRange), CPMaxRange(rhsRange)) - location);
}
+/*
+ Returns a string describing a range.
+ @param aRange the range to describe
+ @group CPRange
+ @return CPString a describing string
+*/
function CPStringFromRange(aRange)
{
return "{" + aRange.location + ", " + aRange.length + "}";
}
+/*
+ Creates a CPRange from the contents of a CPString .
+ @param aString the string to create a CPRange from
+ @group CPRange
+ @return CPRange the new range
+*/
function CPRangeFromString(aString)
{
var comma = aString.indexOf(',');
diff --git a/Foundation/CPRunLoop.j b/Foundation/CPRunLoop.j
index 57c9f690d3..bba2cc0c28 100644
--- a/Foundation/CPRunLoop.j
+++ b/Foundation/CPRunLoop.j
@@ -24,6 +24,10 @@ import "CPObject.j"
import "CPArray.j"
import "CPString.j"
+/*
+ @global
+ @group CPRunLoopMode
+*/
CPDefaultRunLoopMode = @"CPDefaultRunLoopMode";
function _CPRunLoopPerformCompare(lhs, rhs)
@@ -34,6 +38,7 @@ function _CPRunLoopPerformCompare(lhs, rhs)
var _CPRunLoopPerformPool = [],
_CPRunLoopPerformPoolCapacity = 5;
+/* @ignore */
@implementation _CPRunLoopPerform : CPObject
{
id _target;
@@ -119,6 +124,11 @@ var _CPRunLoopPerformPool = [],
@end
+/*
+ CPRunLoop instances handle various utility tasks that must be performed repetitively in an application, such as processing input events.
+
+ There is one run loop per application, which may always be obtained through the +currentRunLoop method,
+*/
@implementation CPRunLoop : CPObject
{
CPArray _queuedPerforms;
@@ -126,6 +136,9 @@ var _CPRunLoopPerformPool = [],
BOOL _isPerformingSelectors;
}
+/*
+ @ignore
+*/
+ (void)initialize
{
if (self != [CPRunLoop class])
@@ -147,16 +160,30 @@ var _CPRunLoopPerformPool = [],
return self;
}
+/*
+ Returns the application's singleton CPRunLoop .
+*/
+ (CPRunLoop)currentRunLoop
{
return CPMainRunLoop;
}
+/*
+ Returns the application's singleton CPRunLoop .
+*/
+ (CPRunLoop)mainRunLoop
{
return CPMainRunLoop;
}
+/*
+ Performs the specified selector on the specified target. The method will be invoked synchronously.
+ @param aSelector the selector of the method to invoke
+ @param aTarget the target of the selector
+ @param anArgument the method argument
+ @param anOrder the message priority
+ @param modes the modes variable isn't respected.
+*/
- (void)performSelector:(SEL)aSelector target:(id)aTarget argument:(id)anArgument order:(int)anOrder modes:(CPArray)modes
{
var perform = [_CPRunLoopPerform performWithSelector:aSelector target:aTarget argument:anArgument order:anOrder modes:modes];
@@ -176,6 +203,12 @@ var _CPRunLoopPerformPool = [],
}
}
+/*
+ Cancels the specified selector and target.
+ @param aSelector the selector of the method to invoke
+ @param aTarget the target to invoke the method on
+ @param the argument for the method
+*/
- (void)cancelPerformSelector:(SEL)aSelector target:(id)aTarget argument:(id)anArgument
{
var count = _orderedPerforms.length;
@@ -189,6 +222,9 @@ var _CPRunLoopPerformPool = [],
}
}
+/*
+ @ignore
+*/
- (void)performSelectors
{
if (_isPerformingSelectors)
diff --git a/Foundation/CPSortDescriptor.j b/Foundation/CPSortDescriptor.j
index 197cc7372a..418b576af5 100755
--- a/Foundation/CPSortDescriptor.j
+++ b/Foundation/CPSortDescriptor.j
@@ -23,6 +23,30 @@
import "CPObject.j"
import "CPObjJRuntime.j"
+/*
+ The left operand is smaller than the right.
+ @global
+ @group CPComparisonResult
+*/
+CPOrderedAscending = -1;
+/*
+ The left and right operands are equal.
+ @global
+ @group CPComparisonResult
+*/
+CPOrderedSame = 0;
+/*
+ The left operand is greater than the right.
+ @global
+ @group CPComparisonResult
+*/
+CPOrderedDescending = 1;
+
+/*
+ A CPSortDescriptor holds the attributes necessary to describe how
+ to sort a set of objects. The sort descriptor instance holds a property key path
+ to the sort item of the objects to compare, the method selector to call for sorting and the sort order.
+*/
@implementation CPSortDescriptor : CPObject
{
CPString _key;
@@ -31,12 +55,24 @@ import "CPObjJRuntime.j"
}
// Initializing a sort descriptor
-
+/*
+ Initializes the sort descriptor.
+ @param aKey the property key path to sort
+ @param isAscending the sort order
+ @return the initialized sort descriptor
+*/
- (id)initWithKey:(CPString)aKey ascending:(BOOL)isAscending
{
return [self initWithKey:aKey ascending:isAscending selector:@selector(compare:)];
}
-
+
+/*
+ Initializes the sort descriptor
+ @param aKey the property key path to sort
+ @param isAscending the sort order
+ @param aSelector this method gets called to compare objects. The method will take one argument
+ (the object to compare against itself, and must return a CPComparisonResult .
+*/
- (id)initWithKey:(CPString)aKey ascending:(BOOL)isAscending selector:(SEL)aSelector
{
self = [super init];
@@ -52,29 +88,46 @@ import "CPObjJRuntime.j"
}
// Getting information about a sort descriptor
-
+/*
+ Returns YES
if the sort descriptor's order is ascending.
+*/
- (BOOL)ascending
{
return _ascending;
}
+/*
+ Returns the descriptor's property key
+*/
- (CPString)key
{
return _key;
}
+/*
+ Returns the selector of the method to call when comparing objects.
+*/
- (SEL)selector
{
return _selector;
}
// Using sort descriptors
-
+/*
+ Compares two objects.
+ @param lhsObject the left hand side object to compre
+ @param rhsObject the right hand side object to compare
+ @return the comparison result
+*/
- (CPComparisonResult)compareObject:(id)lhsObject withObject:(id)rhsObject
{
return (_ascending ? 1 : -1) * [[lhsObject valueForKey:_key] performSelector:_selector withObject:[rhsObject valueForKey:_key]];
}
-
+
+/*
+ Makes a copy of this sort descriptor with a reversed sort order.
+ @return the reversed copy of the sort descriptor
+*/
- (id)reversedSortDescriptor
{
return [[[self class] alloc] initWithKey:_key ascending:!_ascending selector:_selector];
diff --git a/Foundation/CPString.j b/Foundation/CPString.j
index d52d3df7fd..e46de97f6e 100644
--- a/Foundation/CPString.j
+++ b/Foundation/CPString.j
@@ -21,28 +21,71 @@
*/
import "CPObject.j"
+import "CPException.j"
-
+/*
+ A case insensitive search
+ @global
+ @class CPString
+*/
CPCaseInsensitiveSearch = 1;
+/*
+ Exact character match
+ @global
+ @class CPString
+*/
CPLiteralSearch = 2;
+/*
+ Start searching from the end of the string
+ @global
+ @class CPString
+*/
CPBackwardsSearch = 4;
+/*
+ @global
+ @class CPString
+*/
CPAnchoredSearch = 8;
+/*
+ Numbers in the string are compared as numbers instead of strings
+ @global
+ @class CPString
+*/
CPNumericSearch = 64;
var CPStringHashes = new objj_dictionary();
+/*
+ CPString is an object that allows management of strings. Because CPString is
+ based on the JavaScript String
object, CPString s are immutable, although the
+ class does have methods that create new CPString s generated from modifications to the
+ receiving instance.
+
+ A handy feature of CPString instances is that they can be used wherever a JavaScript is
+ required, and vice versa.
+*/
@implementation CPString : CPObject
+/*
+ @ignore
+*/
+ (id)alloc
{
return new String;
}
+/*
+ Returns a new string
+*/
+ (id)string
{
return [[self alloc] init];
}
+/*
+ Returns a CPString containing the specified hash.
+ @param aHash the hash to represent as a string
+*/
+ (id)stringWithHash:(unsigned)aHash
{
var zeros = "000000",
@@ -51,38 +94,79 @@ var CPStringHashes = new objj_dictionary();
return zeros.substring(0, zeros.length - digits.length) + digits;
}
+/*
+ Returns a copy of the specified string.
+ @param aString a non-nil
string to copy
+ @throws CPInvalidArgumentException if aString
is nil
+ @return the new CPString
+*/
+ (id)stringWithString:(CPString)aString
{
+ if (!aString)
+ [CPException raise:CPInvalidArgumentException
+ reason:"stringWithString: the string can't be 'nil'"];
+
return [[self alloc] initWithString:aString];
}
+/*
+ Initializes the string with data from the specified string.
+ @param aString the string to copy data from
+ @return the initialized CPString
+*/
- (id)initWithString:(CPString)aString
{
return aString + "";
}
+/*
+ Returns a description of this CPString object.
+*/
- (CPString)description
{
return "<" + self.isa.name + " 0x" + [CPString stringWithHash:[self hash]] + " \"" + self + "\">";
}
+/*
+ Returns the number of UTF-8 characters in the string.
+*/
- (int)length
{
return length;
}
-- (char)characterAtIndex:(unsigned)anIndex
+/*
+ Returns the character at the specified index.
+ @param anIndex the index of the desired character
+*/
+- (CPString)characterAtIndex:(unsigned)anIndex
{
return charAt(anIndex);
}
// Combining strings
-
+/*
+ Creates a new CPString from the concatenation of the receiver and the specified string.
+ @param aString the string to append to the receiver
+ @return the new string
+*/
- (CPString)stringByAppendingString:(CPString)aString
{
return self + aString;
}
+/*
+ Returns a new string formed by padding characters or removing them.
+ If the padding length is shorter than the receiver's length, the
+ new string will be trimmed down to the padding length size.
+ If the padding length is longer than the receiver's length, then the
+ new string is repeatedly padded with the characters from the
+ specified string starting at the specified index.
+ @param aLength the desired length of the new CPString
+ @param aString the padding string to use (if necessary)
+ @param anIndex the index of the padding string to start from (if necessary to use)
+ @return the new padded string
+*/
- (CPString)stringByPaddingToLength:(unsigned)aLength withString:(CPString)aString startingAtIndex:(unsigned)anIndex
{
if (length == aLength)
@@ -101,28 +185,59 @@ var CPStringHashes = new objj_dictionary();
if (difference) string += substring.substr(difference + substring.length);
}
+/*
+ Tokenizes the receiver string using the specified
+ delimiter. For example, if the receiver is:
+
"arash.francisco.ross.tom"
+ and the delimiter is:
+ "."
+ the returned array would contain:
+ ["arash", "francisco", "ross", "tom"]
+ @param the delimiter
+ @return the array of tokens
+*/
- (CPArray)componentsSeparatedByString:(CPString)aString
{
return split(aString);
}
+/*
+ Returns a substring starting from the specified index to the end of the receiver.
+ @param anIndex the starting string (inclusive)
+ @return the substring
+*/
- (CPString)substringFromIndex:(unsigned)anIndex
{
return substr(anIndex);
}
+/*
+ Returns a substring starting from the specified range location
to the range length
.
+ @param the range of the substring
+ @return the substring
+*/
- (CPString)substringWithRange:(CPRange)aRange
{
return substr(aRange.location, aRange.length);
}
+/*
+ Creates a substring from the beginning of the receiver to the specified index.
+ @param anIndex the last index of the receiver to use for the substring (inclusive)
+ @return the substring
+*/
- (CPString)substringToIndex:(unsigned)anIndex
{
return substring(0, anIndex);
}
// Finding characters and substrings
-
+/*
+ Finds the range of characters in the receiver where the specified string exists. If the string
+ does not exist in the receiver, the range length
will be 0.
+ @param aString the string to search for in the receiver
+ @return the range of charactrs in the receiver
+*/
- (CPRange)rangeOfString:(CPString)aString
{
var location = indexOf(aString);
@@ -130,6 +245,23 @@ var CPStringHashes = new objj_dictionary();
return CPMakeRange(location, location == CPNotFound ? 0 : aString.length);
}
+/*
+ Finds the range of characters in the receiver
+ where the specified string exists. The search
+ is subject to the options specified in the
+ specified mask which can be a combination of:
+
+CPCaseInsensitiveSearch
+CPLiteralSearch
+CPBackwardsSearch
+CPAnchoredSearch
+CPNumericSearch
+
+ @param aString the string to search for
+ @param aMask the options to use in the search
+ @return the range of characters in the receiver. If the string was not found,
+ the length
of the range will be 0.
+*/
- (CPRange)rangeOfString:(CPString)aString options:(int)aMask
{
var string = self,
@@ -149,12 +281,22 @@ var CPStringHashes = new objj_dictionary();
}
// Identifying and comparing strings
-
+/*
+ Compares the receiver to the specified string.
+ @param aString the string with which to compare
+ @return the result of the comparison
+*/
- (CPComparisonResult)caseInsensitiveCompare:(CPString)aString
{
return [self compare:aString options:CPCaseInsensitiveSearch]
}
+/*
+ Compares the receiver to the specified string, using options.
+ @param aString the string with which to compare
+ @param aMask the options to use for the comparison
+ @return the result of the comparison
+*/
- (CPComparisonResult)compare:(CPString)aString options:(int)aMask
{
var lhs = self,
@@ -174,21 +316,37 @@ var CPStringHashes = new objj_dictionary();
return CPOrderedSame;
}
+/*
+ Returns YES
if the receiver starts
+ with the specified string. If aString
+ is empty, the method will return NO
.
+*/
- (BOOL)hasPrefix:(CPString)aString
{
return aString && aString != "" && indexOf(aString) == 0;
}
+/*
+ Returns NO
if the receiver ends
+ with the specified string. If aString
+ is empty, the method will return NO
.
+*/
- (BOOL)hasSuffix:(CPString)aString
{
return aString && aString != "" && lastIndexOf(aString) == (length - aString.length);
}
+/*
+ Returns YES
if the specified string contains the same characters as the receiver.
+*/
- (BOOL)isEqualToString:(CPString)aString
{
return self == aString;
}
+/*
+ Returns a hash of the string instance.
+*/
- (unsigned)hash
{
var hash = dictionary_getValue(CPStringHashes, self);
@@ -202,6 +360,9 @@ var CPStringHashes = new objj_dictionary();
return hash;
}
+/*
+ Returns a copy of the receiver with all the first letters of words capitalized.
+*/
- (CPString)capitalizedString
{
var i = 0,
@@ -222,36 +383,61 @@ var CPStringHashes = new objj_dictionary();
return capitalized;
}
+/*
+ Returns a copy of the string with all its characters made lower case.
+*/
- (CPString)lowercaseString
{
return toLowerCase();
}
+/*
+ Returns a copy of the string with all its characters made upper case.
+*/
- (CPString)uppercaseString
{
return toUpperCase();
}
+/*
+ Returns the text as a floating point value.
+*/
- (double)doubleValue
{
return eval(self);
}
+/*
+ Returns the text as a float point value.
+*/
- (float)floatValue
{
return eval(self);
}
+/*
+ Returns the text as an integer
+*/
- (int)intValue
{
return parseInt(self);
}
+/*
+ Returns an the path components of this string. This
+ method assumes that the string's contents is a '/'
+ separated file system path.
+*/
- (CPArray)pathComponents
{
return split('/');
}
+/*
+ Returns the extension of the file denoted by this string.
+ The '.' is not a part of the extension. This method assumes
+ that the string's contents is the path to a file or just a filename.
+*/
- (CPString)pathExtension
{
return substr(lastIndexOf('.')+1);
@@ -263,10 +449,14 @@ var CPStringHashes = new objj_dictionary();
return components[components.length -1];
}
+/*
+ Until this is corrected
+ @ignore
+*/
- (CPString)stringByDeletingLastPathComponent
{
// FIMXE: this is wrong: a/a/ returns a/a/.
- return substr(0, lastIndexOf('/') + 1);
+ return substr(0, lastIndexOf('/'));
}
- (CPString)stringByStandardizingPath
diff --git a/Foundation/CPURLConnection.j b/Foundation/CPURLConnection.j
index a98acb9b19..1ff52aab29 100644
--- a/Foundation/CPURLConnection.j
+++ b/Foundation/CPURLConnection.j
@@ -34,6 +34,47 @@ var XMLHTTPRequestUninitialized = 0,
var CPURLConnectionDelegate = nil;
+/*
+ An interface to downloading content at a specified URL. Using one of the
+ class methods, you can obtain the data.
+
+ @delegate -(void)connection:(CPURLConnection)connection didFailWithError:(id)error;
+ Called when the connection encounters an error.
+ @param connection the connection that had an error
+ @param error the error, which is either a javascript DOMException or an http
+ status code (javascript number/CPNumber)
+
+ @delegate -(void)connection:(CPURLConnection)connection didReceiveResponse:(CPHTTPURLResponse)response;
+ Called when the connection receives a response.
+ @param connection the connection that received a response
+ @param response the received response
+
+ @delegate -(void)connection:(CPURLConnection)connection didReceiveData:(CPString)data;
+ Called when the connection has received data.
+ @param connection the connection that received data
+ @param data the received data
+
+ @delegate -(void)connectionDidFinishLoading:(CPURLConnection)connection;
+ Called when the URL has finished loading.
+ @param connection the connection that finished loading
+
+ Class Delegate Method:
+
+ @delegate -(void)connectionDidReceiveAuthenticationChallenge:(id)connection
+ The class delegate allows you to set global behavior for when authentication challenges (401 status codes) are returned.
+
+ The recommended way to handle this method is to store a reference to the connection, and then use whatever
+ method you have to authenticate yourself. Once you've authenticated yourself, you should cancel
+ and then start the connection:
+
+
+[connection cancel];
+[connection start];
+
+
+ @param connection the connection that received the authentication challenge.
+*/
+
@implementation CPURLConnection : CPObject
{
CPURLRequest _request;
@@ -48,7 +89,14 @@ var CPURLConnectionDelegate = nil;
CPURLConnectionDelegate = delegate;
}
-+ (CPData)sendSynchronousRequest:(CPURLRequest)aRequest returningResponse:(CPURLResponse **)aURLResponse error:(CPError **)anError
+/*
+ Sends a request for the data from a URL. This is the easiest way to obtain data from a URL.
+ @param aRequest contains the URL to request the data from
+ @param aURLResponse not used
+ @param anError not used
+ @return the data at the URL or nil
if there was an error
+*/
++ (CPData)sendSynchronousRequest:(CPURLRequest)aRequest returningResponse:({CPURLResponse})aURLResponse error:({CPError})anError
{
try
{
@@ -74,11 +122,24 @@ var CPURLConnectionDelegate = nil;
return nil;
}
+/*
+ Creates a url connection with a delegate to monitor the request progress.
+ @param aRequest contains the URL to obtain data from
+ @param aDelegate will be sent messages related to the request progress
+ @return a connection that can be started to initiate the request
+*/
+ (CPURLConnection)connectionWithRequest:(CPURLRequest)aRequest delegate:(id)aDelegate
{
return [[self alloc] initWithRequest:aRequest delegate:aDelegate];
}
+/*
+ Default class initializer. Use one of the class methods instead.
+ @param aRequest contains the URL to contact
+ @param aDelegate will receive progress messages
+ @param shouldStartImmediately whether the start
method should be called from here
+ @return the initialized url connection
+*/
- (id)initWithRequest:(CPURLRequest)aRequest delegate:(id)aDelegate startImmediately:(BOOL)shouldStartImmediately
{
self = [super init];
@@ -103,11 +164,17 @@ var CPURLConnectionDelegate = nil;
return [self initWithRequest:aRequest delegate:aDelegate startImmediately:YES];
}
+/*
+ return the delegate
+*/
- (id)delegate
{
return _delegate;
}
+/*
+ Start the connection. Not needed if you used the class method +connectionWithRequest:delegate:
+*/
- (void)start
{
_isCanceled = NO;
@@ -133,6 +200,9 @@ var CPURLConnectionDelegate = nil;
}
}
+/*
+ Cancels the current request.
+*/
- (void)cancel
{
_isCanceled = YES;
@@ -147,6 +217,7 @@ var CPURLConnectionDelegate = nil;
}
}
+/* @ignore */
- (void)_readyStateDidChange
{
if (_XMLHTTPRequest.readyState == XMLHTTPRequestComplete)
@@ -173,6 +244,7 @@ var CPURLConnectionDelegate = nil;
[[CPRunLoop currentRunLoop] performSelectors];
}
+/* @ignore */
- (void)_XMLHTTPRequest
{
return _XMLHTTPRequest;
diff --git a/Foundation/CPURLRequest.j b/Foundation/CPURLRequest.j
index 7a8e61a2a4..f227247d46 100644
--- a/Foundation/CPURLRequest.j
+++ b/Foundation/CPURLRequest.j
@@ -22,6 +22,10 @@
import "CPObject.j"
+/*
+ A helper object for CPURLConnection , that contains
+ data obtained during the life of a request.
+*/
@implementation CPURLRequest : CPObject
{
CPURL _URL;
@@ -32,11 +36,21 @@ import "CPObject.j"
CPDictionary _HTTPHeaderFields;
}
+/*
+ Creates a request with a specified URL.
+ @param aURL the URL of the request
+ @return a CPURLRequest
+*/
+ (id)requestWithURL:(CPURL)aURL
{
return [[CPURLRequest alloc] initWithURL:aURL];
}
+/*
+ Initializes the request with a URL.
+ @param aURL the url to set
+ @return the initialized CPURLRequest
+*/
- (id)initWithURL:(CPURL)aURL
{
self = [super init];
@@ -55,46 +69,79 @@ import "CPObject.j"
return self;
}
+/*
+ Returns the request URL
+*/
- (CPURL)URL
{
return _URL;
}
+/*
+ Sets the URL for this request.
+ @param aURL the new URL
+*/
- (void)setURL:(CPURL)aURL
{
_URL = aURL;
}
+/*
+ Sets the HTTP body for this request
+ @param anHTTPBody the new HTTP body
+*/
- (void)setHTTPBody:(CPString)anHTTPBody
{
_HTTPBody = anHTTPBody;
}
+/*
+ Returns the request's http body.
+*/
- (CPString)HTTPBody
{
return _HTTPBody;
}
+/*
+ Sets the request's http method.
+ @param anHTPPMethod the new http method
+*/
- (void)setHTTPMethod:(CPString)anHTTPMethod
{
_HTTPMethod = anHTTPMethod;
}
+/*
+ Returns the request's http method
+*/
- (CPString)HTTPMethod
{
return _HTTPMethod;
}
+/*
+ Returns a dictionar of the http header fields
+*/
- (CPDictionary)allHTTPHeaderFields
{
return _HTTPHeaderFields;
}
+/*
+ Returns the value for the specified header field.
+ @param aField the header field to obtain a value for
+*/
- (CPString)valueForHTTPHeaderField:(CPString)aField
{
return [_HTTPHeaderFields objectForKey:aField];
}
+/*
+ Sets the value for the specified header field.
+ @param aValue the value for the header field
+ @param aField the header field
+*/
- (void)setValue:(CPString)aValue forHTTPHeaderField:(CPString)aField
{
[_HTTPHeaderFields setObject:aValue forKey:aField];
diff --git a/Foundation/CPURLResponse.j b/Foundation/CPURLResponse.j
index 4362c2d083..5419086741 100644
--- a/Foundation/CPURLResponse.j
+++ b/Foundation/CPURLResponse.j
@@ -29,6 +29,9 @@ import "CPObject.j"
unsigned _expectedContentLength;
CPString _textEncodingName;
*/
+/*
+ Contains protocol agnostic information about a request to a specific URL.
+*/
@implementation CPURLResponse : CPObject
{
}
@@ -44,11 +47,15 @@ Getting the Response Properties
*/
@end
+/*
+ Represents the response to an http request.
+*/
@implementation CPHTTPURLResponse : CPURLResponse
{
int _statusCode;
}
+/* @ignore */
- (id)_initWithStatusCode:(int)aStatusCode
{
self = [super init];
@@ -59,6 +66,9 @@ Getting the Response Properties
return self;
}
+/*
+ Returns the HTTP status code.
+*/
- (int)statusCode
{
return _statusCode;
diff --git a/Foundation/CPUndoManager.j b/Foundation/CPUndoManager.j
index e25703b720..b415e3d301 100644
--- a/Foundation/CPUndoManager.j
+++ b/Foundation/CPUndoManager.j
@@ -40,6 +40,7 @@ CPUndoCloseGroupingRunLoopOrdering = 350000;
var _CPUndoGroupingPool = [],
_CPUndoGroupingPoolCapacity = 5;
+/* @ignore */
@implementation _CPUndoGrouping : CPObject
{
_CPUndoGrouping _parent;
@@ -149,6 +150,9 @@ var _CPUndoGroupingParentKey = @"_CPUndoGroupingParentKey",
@end
+/*
+ CPUndoManager provides a general mechanism supporting implementation of user action "undo" in applications. Essentially, it allows you to store sequences of messages and receivers that need to be invoked to undo or redo an action. The various methods in this class provide for grouping of sets of actions, execution of undo or redo actions, and tuning behavior parameters such as the size of the undo stack. Each application entity with its own editing history (e.g., a document) should have its own undo manager instance. Obtain an instance through a simple [[CPUndoManager alloc] init]
message.
+*/
@implementation CPUndoManager : CPObject
{
CPMutableArray _redoStack;
@@ -166,6 +170,10 @@ var _CPUndoGroupingParentKey = @"_CPUndoGroupingParentKey",
BOOL _registeredWithRunLoop;
}
+/*
+ Initializes the undo manager
+ @return the initialized undo manager
+*/
- (id)init
{
self = [super init];
@@ -186,16 +194,21 @@ var _CPUndoGroupingParentKey = @"_CPUndoGroupingParentKey",
}
// Registering Undo Operations
-
+/*
+ Registers an undo operation. You invoke this method with the target of the undo action providing the selector which can perform the undo with the provided object. The object is often a dictionary of the identifying the attribute and their values before the change. The invocation will be added to the current grouping. If the registrations have been disabled through -disableUndoRegistration
, this method does nothing.
+ @param aTarget the target for the undo invocation
+ @param aSelector the selector for the action message
+ @param anObject the argument for the action message
+ @throws CPInternalInconsistencyException if no undo group is currently open
+*/
- (void)registerUndoWithTarget:(id)aTarget selector:(SEL)aSelector object:(id)anObject
{
+ if (!_currentGrouping)
+ [CPException raise:CPInternalInconsistencyException reason:"No undo group is currently open"];
+
if (_disableCount > 0)
return;
-/* if (_currentGroup == nil)
- [NSException raise:NSInternalInconsistencyException
- format:@"forwardInvocation called without first opening an undo group"];
-*/
//signature = [target methodSignatureForSelector:selector];
// FIXME: we need method signatures.
var invocation = [CPInvocation invocationWithMethodSignature:nil];
@@ -209,7 +222,11 @@ var _CPUndoGroupingParentKey = @"_CPUndoGroupingParentKey",
if (_state == CPUndoManagerNormal)
[_redoStack removeAllObjects];
}
-
+/*
+ Prepares the specified target for the undo action.
+ @param aTarget the target to receive the action
+ @return the undo manager
+*/
- (id)prepareWithInvocationTarget:(id)aTarget
{
_preparedTarget = aTarget;
@@ -217,6 +234,10 @@ var _CPUndoGroupingParentKey = @"_CPUndoGroupingParentKey",
return self;
}
+/*
+ FIXME This method doesn't seem to do anything right
+ @ignore
+*/
-(CPMethodSignature)methodSignatureForSelector:(SEL)aSelector
{
if ([_preparedTarget respondsToSelector:aSelector])
@@ -225,6 +246,11 @@ var _CPUndoGroupingParentKey = @"_CPUndoGroupingParentKey",
return nil;//[_preparedTarget methodSignatureForSelector:selector];
}
+/*
+ Records the specified invocation as an undo operation. Sets the
+ target on the invocation, and adds it to the current grouping.
+ @param anInvocation the message to record
+*/
- (void)forwardInvocation:(CPInvocation)anInvocation
{
if (_disableCount > 0)
@@ -247,12 +273,17 @@ var _CPUndoGroupingParentKey = @"_CPUndoGroupingParentKey",
}
// Checking Undo Ability
-
+/*
+ Returns YES
if the user can perform a redo operation.
+*/
- (BOOL)canRedo
{
return _redoStack.length > 0;
}
+/*
+ Returns YES
if the user can perform an undo operation.
+*/
- (BOOL)canUndo
{
if (_undoStack.length > 0)
@@ -262,7 +293,9 @@ var _CPUndoGroupingParentKey = @"_CPUndoGroupingParentKey",
}
// Preform Undo and Redo
-
+/*
+ Ends the current grouping, and performs an 'undo' operation.
+*/
- (void)undo
{
if ([self groupingLevel] == 1)
@@ -271,6 +304,9 @@ var _CPUndoGroupingParentKey = @"_CPUndoGroupingParentKey",
[self undoNestedGroup];
}
+/*
+ Performs an undo on the last undo group.
+*/
- (void)undoNestedGroup
{
if (_undoStack.length == 0)
@@ -297,6 +333,9 @@ var _CPUndoGroupingParentKey = @"_CPUndoGroupingParentKey",
[defaultCenter postNotificationName:CPUndoManagerDidUndoChangeNotification object:self];
}
+/*
+ Performs the redo operation using the last grouping on the redo stack.
+*/
- (void)redo
{
// Don't do anything if we have no redos.
@@ -333,16 +372,22 @@ var _CPUndoGroupingParentKey = @"_CPUndoGroupingParentKey",
}
// Creating Undo Groups
-
+/*
+ Starts a new grouping of undo tasks, and makes it the current grouping.
+*/
- (void)beginUndoGrouping
{
_currentGrouping = [_CPUndoGrouping undoGroupingWithParent:_currentGrouping];
}
+/*
+ Closes the current undo grouping.
+ @throws CPInternalInconsistencyException if no undo group is open
+*/
- (void)endUndoGrouping
{
if (!_currentGrouping)
- alert("FIXME: this should be an exception endUndoGrouping - currentUndoGrouping = nil.");
+ [CPException raise:CPInternalInconsistencyException reason:"endUndoGrouping. No undo group is currently open."];
var parent = [_currentGrouping parent];
@@ -373,19 +418,33 @@ var _CPUndoGroupingParentKey = @"_CPUndoGroupingParentKey",
_currentGrouping = parent;
}
+/*
+ Enables undo registrations. Calls to this method must
+ be balanced with calls to disableUndoRegistration .
+ So, if two disable calls were made, two enable calls are required
+ to actually enable undo registration again.
+*/
- (void)enableUndoRegistration
{
if (_disableCount <= 0)
- return;
+ [CPException raise:CPInternalInconsistencyException
+ reason:"enableUndoRegistration. There are no disable messages in effect right now."];
_disableCount--;
}
+/*
+ Returns YES
if the manager groups undo operations at every iteration of the run loop.
+*/
- (BOOL)groupsByEvent
{
return _groupsByEvent;
}
+/*
+ Sets whether the manager should group undo operations at every iteration of the run loop.
+ @param aFlag YES
groups undo operations
+*/
- (void)setGroupsByEvent:(BOOL)aFlag
{
if (_groupsByEvent == aFlag)
@@ -406,6 +465,9 @@ var _CPUndoGroupingParentKey = @"_CPUndoGroupingParentKey",
[self _unregisterWithRunLoop];
}
+/*
+ Returns the number of undo/redo groups.
+*/
- (unsigned)groupingLevel
{
var grouping = _currentGrouping,
@@ -418,31 +480,43 @@ var _CPUndoGroupingParentKey = @"_CPUndoGroupingParentKey",
}
// Disabling Undo
-
+/*
+ Disables undo registrations.
+*/
- (void)disableUndoRegistration
{
++_disableCount;
}
+/*
+ Returns YES
if undo registration is enabled.
+*/
- (BOOL)isUndoRegistrationEnabled
{
return _disableCount == 0;
}
// Checking Whether Undo or Redo Is Being Performed
-
+/*
+ Returns YES
if the manager is currently performing an undo.
+*/
- (BOOL)isUndoing
{
return _state == CPUndoManagerUndoing;
}
+/*
+ Returns YES
if the manager is currently performing a redo.
+*/
- (BOOL)isRedoing
{
return _state == CPUndoManagerRedoing;
}
// Clearing Undo Operations
-
+/*
+ Clears all redo and undo operations and enables undo registrations.
+*/
- (void)removeAllActions
{
_redoStack = [];
@@ -450,6 +524,10 @@ var _CPUndoGroupingParentKey = @"_CPUndoGroupingParentKey",
_disableCount = 0;
}
+/*
+ Removes any redo and undo operations that use the specified target.
+ @param aTarget the target for which operations should be removed.
+*/
- (void)removeAllActionsWithTarget:(id)aTarget
{
[_currentGrouping removeInvocationsWithTarget:aTarget];
@@ -480,29 +558,56 @@ var _CPUndoGroupingParentKey = @"_CPUndoGroupingParentKey",
}
// Managing the Action Name
-
+/*
+ Sets the name associated with the actions of the current group.
+ Typically, you can call this method while registering the actions for the current group.
+ @param anActionName the new name for the current group
+*/
- (void)setActionName:(CPString)anActionName
{
_actionName = anActionName;
}
+/*
+ If the receiver can perform a redo, this method returns the action
+ name previously associated with the top grouping with
+ -setActionName:
. This name should identify the action to be redone.
+ @return the redo action's name, or nil
if no there's no redo on the stack.
+*/
- (CPString)redoActionName
{
return [self canRedo] ? _actionName : nil;
}
+/*
+ If the receiver can perform an undo, this method returns the action
+ name previously associated with the top grouping with
+ -setActionName:
. This name should identify the action to be undone.
+ @return the undo action name or nil
if no if there's no undo on the stack.
+*/
- (CPString)undoActionName
{
return [self canUndo] ? _actionName : nil;
}
// Working With Run Loops
-
+/*
+ Returns the CPRunLoopMode s in which the receiver registers
+ the -endUndoGrouping
processing when it -groupsByEvent
.
+*/
- (CPArray)runLoopModes
{
return _runLoopModes;
}
+/*
+ Sets the modes in which the receiver registers the calls
+ with the current run loop to invoke -endUndoGrouping
+ when it -groupsByEvent
. This method first
+ cancels any pending registrations in the old modes and
+ registers the invocation in the new modes.
+ @param modes the modes in which calls are registered
+*/
- (void)setRunLoopModes:(CPArray)modes
{
_runLoopModes = modes;
@@ -513,6 +618,7 @@ var _CPUndoGroupingParentKey = @"_CPUndoGroupingParentKey",
[self _registerWithRunLoop];
}
+/* @ignore */
- (void)beginUndoGroupingForEvent
{
if (!_groupsByEvent)
@@ -527,6 +633,7 @@ var _CPUndoGroupingParentKey = @"_CPUndoGroupingParentKey",
target:self argument:nil order:CPUndoCloseGroupingRunLoopOrdering modes:_runLoopModes];
}
+/* @ignore */
- (void)_registerWithRunLoop
{
if (_registeredWithRunLoop)
@@ -537,6 +644,7 @@ var _CPUndoGroupingParentKey = @"_CPUndoGroupingParentKey",
target:self argument:nil order:CPUndoCloseGroupingRunLoopOrdering modes:_runLoopModes];
}
+/* @ignore */
- (void)_unregisterWithRunLoop
{
if (!_registeredWithRunLoop)
diff --git a/Foundation/CPValue.j b/Foundation/CPValue.j
index 7bfd6c5a7a..3ce9318fb5 100644
--- a/Foundation/CPValue.j
+++ b/Foundation/CPValue.j
@@ -23,16 +23,29 @@
import "CPObject.j"
import "CPCoder.j"
+/*
+ The class can be subclassed to hold different types of scalar values.
+*/
@implementation CPValue : CPObject
{
JSObject _JSObject;
}
+/*
+ Creates a value from the specified JavaScript object
+ @param aJSObject a JavaScript object containing a value
+ @return the converted CPValue
+*/
+ (id)valueWithJSObject:(JSObject)aJSObject
{
return [[self alloc] initWithJSObject:aJSObject];
}
+/*
+ Initializes the value from a JavaScript object
+ @param aJSObject the object to get data from
+ @return the initialized CPValue
+*/
- (id)initWithJSObject:(JSObject)aJSObject
{
self = [super init];
@@ -43,6 +56,9 @@ import "CPCoder.j"
return self;
}
+/*
+ Returns the JavaScript object backing this value.
+*/
- (JSObject)JSObject
{
return _JSObject;
@@ -54,6 +70,11 @@ var CPValueValueKey = @"CPValueValueKey";
@implementation CPValue (CPCoding)
+/*
+ Initializes the value from a coder.
+ @param aCoder the coder from which to initialize
+ @return the initialized CPValue
+*/
- (id)initWithCoder:(CPCoder)aCoder
{
self = [super init];
@@ -64,6 +85,10 @@ var CPValueValueKey = @"CPValueValueKey";
return self;
}
+/*
+ Encodes the data into the specified coder.
+ @param the coder into which the data will be written.
+*/
- (void)encodeWithCoder:(CPCoder)aCoder
{
[aCoder encodeObject:CPJSObjectCreateJSON(_JSObject) forKey:CPValueValueKey];
diff --git a/Objective-J/Object.j b/Objective-J/Object.j
index 0e96b94b2b..3913f7b62b 100644
--- a/Objective-J/Object.j
+++ b/Objective-J/Object.j
@@ -33,7 +33,7 @@
{
}
-- (id)forwardSelector:(SEL)selector arguments:(void *)args
+- (id)forwardSelector:(SEL)selector arguments:(void)args
{
return nil;
}