CPObjectCPResponder
CPView
CPControl
CPButton
@implementation CPButton : CPControl
CPButton
is a subclass of CPControl
that
intercepts mouse-down events and sends an action message to a
target object when it's clicked or pressed.
Global Variables |
---|
CPOffState = 0 |
CPOnState = 1 |
CPMixedState = -1 |
Method Summary | |
---|---|
-(id) | initWithCoder:(CPCoder)aCoder Initializes the button by unarchiving data from aCoder . |
-(id) | initWithFrame:(CGRect)aFrame Initializes the receiver for usage with the specified bounding rectangle. |
-(id) | NS_initWithCoder:(CPCoder)aCoder |
-(BOOL) | allowsMixedState Returns YES if the button has a 'mixed' state in addition to on and off. |
-(CPImage) | alternateImage Returns the image used when the button is in an alternate state. |
-(int) | bezelStyle Returns the current bezel style. |
-(CPControlSize) | controlSize Returns the button's control size. |
-(void) | encodeWithCoder:(CPCoder)aCoder Archives this button into the provided coder. |
-(void) | highlight:(BOOL)aFlag Highlights the receiver based on aFlag . |
-(CPImage) | image Returns the image that will be drawn on the button. |
-(CPCellImagePosition) | imagePosition Returns the buton's image position. |
-(CPImageScaling) | imageScaling Returns the button's image scaling method. |
-(BOOL) | isBordered Returns YES if the border is bezeled. |
-(void) | mouseDown:(CPEvent)anEvent Called when the user clicks on this button. |
-(void) | mouseDragged:(CPEvent)anEvent Called when the user drags on the button. |
-(void) | mouseUp:(CPEvent)anEvent Called when the user releases the mouse button. |
-(void) | setAlignment:(CPTextAlignment)anAlignment Sets the alignment of the text on the button. |
-(void) | setAllowsMixedState:(BOOL)aFlag Sets whether the button can have a 'mixed' state. |
-(void) | setAlternateImage:(CPImage)anImage Sets the button's image which is used in its alternate state. |
-(void) | setBezelStyle:(CPBezelStyle)aBezelStyle Sets the button's bezel style. |
-(void) | setBordered:(BOOL)isBordered Sets whether the button has a bezeled border. |
-(void) | setButtonType:(CPButtonType)aButtonType Sets how the button highlights and shows its state. |
-(void) | setControlSize:(CPControlSize)aControlSize Sets the button's control size. |
-(void) | setFont:(CPFont)aFont Sets the font that will be used to draw the button text. |
-(void) | setFrameSize:(CGSize)aSize Sets the frame size for the button. |
-(void) | setImage:(CPImage)anImage Sets the image that will be drawn on the button. |
-(void) | setImagePosition:(CPCellImagePosition)anImagePosition Sets the position of the button's image to anImagePosition . |
-(void) | setImageScaling:(CPImageScaling)anImageScaling Sets the button's images scaling method. |
-(void) | setNextState Sets the button to its next state. |
-(void) | setState:(int)aState Sets the button's state to aState . |
-(void) | setTag:(int)aTag Sets button's tag. |
-(void) | setTextColor:(CPColor)aColor Sets the color of the button's text. |
-(void) | setTitle:(CPString)aTitle Sets the button's title. |
-(void) | sizeToFit Compacts the button's frame to fit its contents. |
-(int) | state Returns the button's current state. |
-(int) | tag Returns the button's tag. |
-(void) | tile Lays out the button. |
-(CPString) | title Returns the button's title string. |
-(void) | viewDidMoveToWindow Called when the receiver has been moved to a new CPWindow . |
Methods inherited from class CPControl |
---|
initWithFrame, action, alignment, backgroundColorForName, floatValue, font, isEnabled, mouseUp, sendAction, setAction, setAlignment, setBackgroundColor, setBackgroundColorWithName, setBackgroundColor, setEnabled, setFloatValue, setFont, setTarget, setTextColor, setTextShadow, target, textColor, textShadow |
Method Detail |
---|
-(id)initWithCoder:(CPCoder)aCoder
aCoder
.aCoder
- the coder containing the archived CPButton
.-(id)initWithFrame:(CGRect)aFrame
aFrame
-(id)NS_initWithCoder:(CPCoder)aCoder
aCoder
-(BOOL)allowsMixedState
YES
if the button has a 'mixed' state in addition to on and off.-(CPImage)alternateImage
-(int)bezelStyle
-(CPControlSize)controlSize
-(void)encodeWithCoder:(CPCoder)aCoder
aCoder
- the coder to which the button's instance data will be written.-(void)highlight:(BOOL)aFlag
aFlag
.aFlag
-(CPImage)image
-(CPCellImagePosition)imagePosition
-(CPImageScaling)imageScaling
-(BOOL)isBordered
YES
if the border is bezeled.-(void)mouseDown:(CPEvent)anEvent
anEvent
- the event with information about the click-(void)mouseDragged:(CPEvent)anEvent
anEvent
- the event with information about the drag-(void)mouseUp:(CPEvent)anEvent
anEvent
- the event with information about the mouse release-(void)setAlignment:(CPTextAlignment)anAlignment
anAlignment
- an alignment object-(void)setAllowsMixedState:(BOOL)aFlag
aFlag
- specifies whether a 'mixed' state is allowed or not-(void)setAlternateImage:(CPImage)anImage
anImage
- the image to be used while the button is in an alternate state-(void)setBezelStyle:(CPBezelStyle)aBezelStyle
aBezelStyle
-(void)setBordered:(BOOL)isBordered
isBordered
-(void)setButtonType:(CPButtonType)aButtonType
aButtonType
- Defines the behavior of the button.-(void)setControlSize:(CPControlSize)aControlSize
aControlSize
- the button's new control size-(void)setFont:(CPFont)aFont
aFont
- the font used to draw the button text-(void)setFrameSize:(CGSize)aSize
aSize
-(void)setImage:(CPImage)anImage
anImage
- the image that will be drawn-(void)setImagePosition:(CPCellImagePosition)anImagePosition
anImagePosition
.anImagePosition
- the position for the button's image-(void)setImageScaling:(CPImageScaling)anImageScaling
anImageScaling
- the image scaling method-(void)setNextState
-(void)setState:(int)aState
aState
.aState
- Possible states are any of the CPButton
globals:
CPOffState, CPOnState, CPMixedState
-(void)setTag:(int)aTag
aTag
- the button's new tag-(void)setTextColor:(CPColor)aColor
aColor
- the color to use for drawing the button text-(void)setTitle:(CPString)aTitle
aTitle
- the new title for the button-(void)sizeToFit
-(int)state
-(int)tag
-(void)tile
-(CPString)title
-(void)viewDidMoveToWindow
CPWindow
.Created on Sat Sep 13 14:15:43 PDT 2008