Class CPSegmentedControl

CPObject
    extended byCPResponder
        extended byCPView
            extended byCPControl
                extended byCPSegmentedControl

@implementation CPSegmentedControl : CPControl

This class is a horizontal button with multiple segments.


Method Summary
-(id)initWithFrame:(CGRect)aRect
          Initializes the receiver for usage with the specified bounding rectangle.
-(void)drawSegmentBezel:(int)aSegment highlgiht:(BOOL)shouldHighlight
          Draws the specified segment bezel.
-(void)drawSegment:(int)aSegment highlight:(BOOL)shouldHighlight
          Draws the specified segment.
-(CGRect)frameForSegment:(unsigned)aSegment
          Returns the bounding rectangle for the specified segment.
-(CPImage)imageForSegment:(unsigned)aSegment
          Returns the image for the specified segment.
-(BOOL)isEnabledForSegment:(unsigned)aSegment
          Returns YES if the specified segment is enabled.
-(BOOL)isSelectedForSegment:(unsigned)aSegment
          Returns YES if the specified segment is selected.
-(BOOL)isTracking
-(CPString)labelForSegment:(unsigned)aSegment
          Returns the label for the specified segment.
-(CPMenu)menuForSegment:(unsigned)aSegment
          Returns the menu for the specified segment.
-(void)mouseDown:(CPEvent)anEvent
          Notifies the receiver that the user has clicked the mouse down in its area.
-(void)mouseUp:(CPEvent)anEvent
          Notifies the receiver that the user has released the left mouse button.
-(unsigned)segmentCount
          Returns the number of segments in the button.
-(BOOL)selectSegmentWithTag:(int)aTag
          Selects the button segment with the specified tag.
-(unsigned)selectedSegment
          Returns the selected segment.
-(int)selectedTag
          Returns the tag of the selected segment.
-(void)setEnabled:(BOOL)isEnabled forSegment:(unsigned)aSegment
          Enables/diables the specified segment.
-(void)setFont:(CPFont)aFont
          Sets the receiver's font.
-(void)setImage:(CPImage)anImage forSegment:(unsigned)aSegment
          Sets the image for the specified segment.
-(void)setLabel:(CPString)aLabel forSegment:(unsigned)aSegment
          Sets the label for the specified segment.
-(void)setMenu:(CPMenu)aMenu forSegment:(unsigned)aSegment
          Sets the menu for the specified segment.
-(void)setSegmentCount:(unsigned)aCount
          Sets the number of segments in the button.
-(void)setSelectedSegment:(unsigned)aSegment
          Selects a segment.
-(void)setSelected:(BOOL)isSelected forSegment:(unsigned)aSegment
          Sets the selection for the specified segment.
-(void)setTag:(int)aTag forSegment:(unsigned)aSegment
          Sets a tag for the specified segment.
-(void)setTrackingMode:(CPSegmentSwitchTracking)aTrackingMode
-(void)setWidth:(float)aWidth forSegment:(unsigned)aSegment
          Sets the width of the specified segment.
-(int)tagForSegment:(unsigned)aSegment
          Returns the tag for the specified segment.
-(unsigned)testSegment:(CGPoint)aPoint
          Returns the segment that is hit by the specified point.
-(void)tileWithChangedSegment:(unsigned)aSegment
-(void)trackSegment:(CPEvent)anEvent
          Handles events for the segment.
-(CPSegmentSwitchTracking)trackingMode
          Returns the control's tracking mode.
-(float)widthForSegment:(unsigned)aSegment
          Returns the width for the specified segment.

Methods inherited from class CPObject
initialize, alloc, class, instanceMethodForSelector, instancesRespondToSelector, isSubclassOfClass, load, new, setVersion, superclass, version, init, autorelease, awakeAfterUsingCoder, class, classForCoder, classForKeyedArchiver, className, copy, dealloc, description, doesNotRecognizeSelector, forwardInvocation, hash, isEqual, isKindOfClass, isMemberOfClass, isProxy, methodForSelector, methodSignatureForSelector, mutableCopy, performSelector, performSelector, performSelector, release, replacementObjectForArchiver, replacementObjectForCoder, replacementObjectForKeyedArchiver, respondsToSelector, retain, self, superclass

Methods inherited from class CPResponder
acceptsFirstResponder, becomeFirstResponder, deleteBackward, doCommandBySelector, insertLineBreak, insertText, interpretKeyEvents, keyDown, keyUp, menu, mouseDown, mouseDragged, mouseEntered, mouseExited, mouseMoved, mouseUp, nextResponder, noResponderFor, performKeyEquivalent, resignFirstResponder, scrollWheel, setMenu, setNextResponder, tryToPerform, undoManager

Methods inherited from class CPView
initWithFrame, acceptsFirstMouse, addSubview, addSubview, adjustScroll, alphaValue, autoresizesSubviews, autoresizingMask, autoscroll, backgroundColor, bounds, convertPoint, convertPoint, convertRect, convertRect, convertSize, convertSize, didAddSubview, display, displayIfNeeded, displayIfNeededInRect, displayRect, displayRectIgnoringOpacity, dragImage, dragView, drawRect, enclosingMenuItem, enclosingScrollView, enterFullScreenMode, exitFullScreenModeWithOptions, frame, hitTest, hitTests, isDescendantOf, isFlipped, isHidden, isHiddenOrHasHiddenAncestor, isInFullScreenMode, isOpaque, lockFocus, mouseDown, mouseDownCanMoveWindow, needsDisplay, postsBoundsChangedNotifications, postsFrameChangedNotifications, reflectScrolledClipView, registerForDraggedTypes, registeredDraggedTypes, removeFromSuperview, replaceSubview, resizeSubviewsWithOldSize, resizeWithOldSuperviewSize, scrollClipView, scrollPoint, scrollRectToVisible, scrollRect, setAlphaValue, setAutoresizesSubviews, setAutoresizingMask, setBackgroundColor, setBounds, setBoundsOrigin, setBoundsSize, setFrame, setFrameOrigin, setFrameSize, setHidden, setHitTests, setNeedsDisplay, setNeedsDisplayInRect, setPostsBoundsChangedNotifications, setPostsFrameChangedNotifications, subviews, superview, unlockFocus, unregisterDraggedTypes, viewDidMoveToSuperview, viewDidMoveToWindow, viewWillMoveToSuperview, viewWillMoveToWindow, visibleRect, willRemoveSubview, window

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

initWithFrame

-(id)initWithFrame:(CGRect)aRect
Initializes the receiver for usage with the specified bounding rectangle
Parameters:
aRect
Returns:
the initialized view

drawSegmentBezel

-(void)drawSegmentBezel:(int)aSegment highlgiht:(BOOL)shouldHighlight
Draws the specified segment bezel
Parameters:
aSegment - the segment to draw the bezel for
shouldHighlight - YES highlights the bezel

drawSegment

-(void)drawSegment:(int)aSegment highlight:(BOOL)shouldHighlight
Draws the specified segment
Parameters:
aSegment - the segment to draw
shouldHighlight - YES highlights the bezel

frameForSegment

-(CGRect)frameForSegment:(unsigned)aSegment
Returns the bounding rectangle for the specified segment.
Parameters:
aSegment - the segment to get the rectangle for

imageForSegment

-(CPImage)imageForSegment:(unsigned)aSegment
Returns the image for the specified segment
Parameters:
aSegment - the segment to obtain the image for
Throws:
CPRangeException - if aSegment is out of bounds

isEnabledForSegment

-(BOOL)isEnabledForSegment:(unsigned)aSegment
Returns YES if the specified segment is enabled.
Parameters:
aSegment - the segment to check
Throws:
CPRangeException - if aSegment is out of bounds

isSelectedForSegment

-(BOOL)isSelectedForSegment:(unsigned)aSegment
Returns YES if the specified segment is selected.
Parameters:
aSegment - the segment to check for selection
Throws:
CPRangeException - if aSegment is out of bounds

isTracking

-(BOOL)isTracking

labelForSegment

-(CPString)labelForSegment:(unsigned)aSegment
Returns the label for the specified segment
Parameters:
aSegment
Throws:
CPRangeException - if aSegment is out of bounds

menuForSegment

-(CPMenu)menuForSegment:(unsigned)aSegment
Returns the menu for the specified segment.
Parameters:
aSegment - the segment to obtain the menu for
Throws:
CPRangeException - if aSegment is out of bounds

mouseDown

-(void)mouseDown:(CPEvent)anEvent
Notifies the receiver that the user has clicked the mouse down in its area.
Parameters:
anEvent - contains information about the click

mouseUp

-(void)mouseUp:(CPEvent)anEvent
Notifies the receiver that the user has released the left mouse button.
Parameters:
anEvent - contains information about the release

segmentCount

-(unsigned)segmentCount
Returns the number of segments in the button.

selectSegmentWithTag

-(BOOL)selectSegmentWithTag:(int)aTag
Selects the button segment with the specified tag.
Parameters:
aTag

selectedSegment

-(unsigned)selectedSegment
Returns the selected segment.

selectedTag

-(int)selectedTag
Returns the tag of the selected segment.

setEnabled

-(void)setEnabled:(BOOL)isEnabled forSegment:(unsigned)aSegment
Enables/diables the specified segment.
Parameters:
isEnabled - YES enables the segment
aSegment - the segment to enable/disble
Throws:
CPRangeException - if aSegment is out of bounds

setFont

-(void)setFont:(CPFont)aFont
Sets the receiver's font
Parameters:
aFont - the font for the receiver

setImage

-(void)setImage:(CPImage)anImage forSegment:(unsigned)aSegment
Sets the image for the specified segment.
Parameters:
anImage - the image for the segment
aSegment - the segment to set the image on
Throws:
CPRangeException - if aSegment is out of bounds

setLabel

-(void)setLabel:(CPString)aLabel forSegment:(unsigned)aSegment
Sets the label for the specified segment
Parameters:
aLabel - the label for the segment
aSegment - the segment to label
Throws:
CPRangeException - if aSegment is out of bounds

setMenu

-(void)setMenu:(CPMenu)aMenu forSegment:(unsigned)aSegment
Sets the menu for the specified segment
Parameters:
aMenu - the menu to set
aSegment - the segment to set the menu on
Throws:
CPRangeException - if aSegment is out of bounds

setSegmentCount

-(void)setSegmentCount:(unsigned)aCount
Sets the number of segments in the button.
Parameters:
aCount - the number of segments on the button

setSelectedSegment

-(void)setSelectedSegment:(unsigned)aSegment
Selects a segment.
Parameters:
aSegment - the segment to select
Throws:
CPRangeException - if aSegment is out of bounds

setSelected

-(void)setSelected:(BOOL)isSelected forSegment:(unsigned)aSegment
Sets the selection for the specified segment. If only one segment can be selected at a time, any other segment will be deselected.
Parameters:
isSelected - YES selects the segment. NO deselects it.
aSegment - the segment to set the selection for
Throws:
CPRangeException - if aSegment is out of bounds

setTag

-(void)setTag:(int)aTag forSegment:(unsigned)aSegment
Sets a tag for the specified segment.
Parameters:
aTag - the tag to set
aSegment - the segment to set the tag on

setTrackingMode

-(void)setTrackingMode:(CPSegmentSwitchTracking)aTrackingMode
Parameters:
aTrackingMode

setWidth

-(void)setWidth:(float)aWidth forSegment:(unsigned)aSegment
Sets the width of the specified segment.
Parameters:
aWidth - the new width for the segment
aSegment - the segment to set the width for
Throws:
CPRangeException - if aSegment is out of bounds

tagForSegment

-(int)tagForSegment:(unsigned)aSegment
Returns the tag for the specified segment.
Parameters:
aSegment - the segment to obtain the tag for

testSegment

-(unsigned)testSegment:(CGPoint)aPoint
Returns the segment that is hit by the specified point.
Parameters:
aPoint - the point to test for a segment hit
Returns:
the intersecting segment

tileWithChangedSegment

-(void)tileWithChangedSegment:(unsigned)aSegment
Parameters:
aSegment

trackSegment

-(void)trackSegment:(CPEvent)anEvent
Handles events for the segment
Parameters:
anEvent - the event to handle

trackingMode

-(CPSegmentSwitchTracking)trackingMode
Returns the control's tracking mode.

widthForSegment

-(float)widthForSegment:(unsigned)aSegment
Returns the width for the specified segment.
Parameters:
aSegment - the segment to get the width for
Throws:
CPRangeException - if aSegment is out of bounds

Created on Sat Sep 13 14:15:43 PDT 2008