[ First ]  [ Previous ]  [ Next ]  [ Last ]  [ Manuals ]

 

LToggleButton



Overview:

LToggleButton is a PowerPlant class that implements a button. The graphic for the button needs to be stored as a resource of one of these types:

This class is very similar to LButton, except that you may specify five separate resource ID numbers, not just two resource ID numbers as an LButton would have.

Methods :

The methods in this class are:

 

LToggleButton()  
DrawGraphic()  
DrawSelf()  
HotSpotAction()  
HotSpotResult()  
PointIsInFrame()  
SetGraphics()  
SetGraphicsType()  
SetValue()  
 

Data Members:

The data members in this class are:

 

mGraphicsType  
mOnID  
mOnClickID  
mOffID  
mOffClickID  
mTransitionID  

Operation:

You can use LToggleButton to make some simple animations that play when a button is clicked. For example, you could create a drop-down flag button, or a door that opens and closes when the button is clicked. In addition to the "on" and "off" states of the button that LButton uses, you also specify graphics for:

A click on a button that is already "on" A click on a button that is already "off," and A transition graphic that displays when the button is switching states. Source files:

(Pane Classes)

LToggleButton.h

LToggleButton.cp

Ancestors :

LBroadcaster

LControl

LPane

See also:

LButton

LToggleButton()

Purpose:

The constructor creates the objects from the passed-in parameters.

Access:

Public

Prototype:

LToggleButton();

LToggleButton( const SPaneInfo &inPaneInfo,
MessageT inClickedMessage,
OSType inGraphicsType,
ResIDT inOnID,
ResIDT inOnClickID,
ResIDT inOffID,
ResIDT inOffClickID,
ResIDT inTransitionID );
Parameters:

These constructors have the following parameters:

 

const   LButton&  
inOriginal  
A reference to the LButton object you want to copy.  
const   SPaneInfo&  
inPaneInfo  
A reference to the SPaneInfo object that is the super view.  
MessageT  
inClickedMessage  
The message sent when the button is depressed.  
OSType  
inGraphicsType  
Graphics Type ('ICN#', or 'ICON', or 'PICT')  
ResIDT  
inOnID  
Resource ID for "on" graphic  
ResIDT  
inOnClickID  
Resource ID for the "clicked and on" graphic  
ResIDT  
inOffID  
Resource ID for "off" graphic  
ResIDT  
inOffClickID  
Resource ID for the "clicked and off" graphic  
ResIDT  
inTransitionID  
Resource ID for the transition graphic  
LStream*  
inStream  
A pointer to a stream object that contains the information to create the LButton object.  

DrawGraphic()

Purpose:

Draw the graphic for a the button. The Pane must already be focused before calling this method.

Access:

Virtual, Protected

Prototype:

virtual void DrawGraphic( ResIDT inGraphicID );
Parameters:

This method has the following parameter:

 

ResIDT  
inGraphicID  
Resource ID for the button graphic to draw.  

Return:

None

DrawSelf()

Purpose:

This method is an override of the base class method DrawSelf() in LPane. It draws the button.

HotSpotAction()

Purpose:

This method is an override of the base class method HotSpotAction() in LControl. It causes the buttons to toggle between two graphics, depending on whether the mouse is inside or outside the button.

HotSpotResult()

Purpose:

This method is an override of the base class method HotSpotResult() in LControl. It broadcasts a message to Listeners when the button is clicked.

PointIsInFrame()

Purpose:

This method is an override of the base class method PointIsInFrame() in LPane. It gives you information about whether a point lies within a given frame.

SetGraphics()

Purpose:

Specify the resources IDs for all states of the button.

Access:

Virtual, Public

Prototype:

virtual void SetGraphics( ResIDT inOnID,
ResIDT inOnClickID,
ResIDT inOffID,
ResIDT inOffClickID,
ResIDT inTransitionID);
Parameters:

This method has the following parameters:

 

ResIDT  
inOnID  
Resource ID for the "on" graphic.  
ResIDT  
inOnClickID  
Resource ID for the "clicked when on" graphic.  
ResIDT  
inOffID  
Resource ID for the "off" graphic.  
ResIDT  
inOffClickID  
Resource ID for the "clicked when off" graphic.  
ResIDT  
inTransitionID  
Resource ID for the transition graphic.  

Return:

None

SetGraphicsType()

Purpose:

This method sets the value of the mGraphicsType data member.

Access:

Virtual, Public

Prototype:

virtual void SetGraphicsType(
OSType inGraphicsType );
Parameters:

This method has the following parameter:

 

OSType  
inGraphicsType  
The value to set for mGraphicsType.  

SetValue()

Purpose:

This method is an override of the base class method SetValue() in LControl. It sets the value of the button to on or off.

mGraphicsType

Purpose:

This method holds the resource type descriptor for the graphic elements of the button. It should be one of the following:

ICN# ICON' `PICT' Access:

Protected

Prototype:

OSType mGraphicsType;

mOnID

Purpose:

This data member holds the resource ID for the "on" button graphic.

Access:

Protected

Prototype:

ResIDT mOnID;

mOnClickID

Purpose:

This data member holds the resource ID for the "clicked when on" button graphic.

Access:

Protected

Prototype:

ResIDT mOnClickID;

mOffID

Purpose:

This data member holds the resource ID for the "off" button graphic.

Access:

Protected

Prototype:

ResIDT mOffID;

mOffClickID

Purpose:

This data member holds the resource ID for the "clicked when off" button graphic.

Access:

Protected

Prototype:

ResIDT mOffClickID;

mTransitionID

Purpose:

This data member holds the resource ID for the transition button graphic.

Access:

Protected

Prototype:

ResIDT mTransitionID;

 


[ First ]  [ Previous ]  [ Next ]  [ Last ]  [ Manuals ]

Visit the Metrowerks website at: http://www.metrowerks.com
For assistance contact Metrowerks Technical Support at: cw_support@metrowerks.com
Copyright © 2000, Metrowerks Corp. All rights reserved.

Last updated: July 21, 2000