LStdControl is a PowerPlant class that encapsulates the standard Mac OS control behavior.
Methods :
The methods in this class are:
Data Members:
The data members in this class are:
Operation:
The specific design of this class supports scroll bar controls and controls that use custom control definitions (CDEFs). This class also forms the basis for the standard button, check box, pop-up menu, and radio button classes.
For detailed information on Mac OS controls, refer to Inside Mac: MacintoshToolbox Essentials, published by Addison-Wesley.
Source files:
Ancestors:
The ancestors for this class are:
Purpose:
The constructors create objects from the passed-in parameters. Many of these constructors call LControl base class constructors to force a portion of the initialization chores.
Access:
Prototype:
LStdControl();
LStdControl( SInt16 inControlKind );
LStdControl( const SPaneInfo &inPaneInfo,
MessageT inValueMessage,
SInt32 inValue,
SInt32 inMinValue,
SInt32 inMaxValue,
SInt16 inControlKind,
ResIDT inTextTraitsID,
ConstStringPtr inTitle,
SInt32 inMacRefCon );
LStdControl( const SPaneInfo &inPaneInfo,
MessageT inValueMessage,
SInt32 inValue,
SInt32 inMinValue,
SInt32 inMaxValue,
SInt16 inControlKind,
ResIDT inTextTraitsID,
ControlHandle inMacControlH );
LStdControl( LStream *inStream );
LStdControl( LStream *inStream, bool inDummy );Parameters:
These constructors have the following parameters:
|
||
Remarks:
LStdControl( SInt16 inControlKind )-Construct a StdControl for a particular kind of Mac OS Toolbox
Control. On entry, the current Port must be the Window into which
to install the Control.
Purpose:
The destructor destroys the object.
Access:
Prototype:
virtual ~LStdControl();
Purpose:
Set the rectangle inside the Mac OS Toolbox ControlRecord to the Frame rectangle of the standard control.
Access:
Prototype:
void AlignControlRect();Parameters:
Return:
Remarks:At (almost) all times, the contrlRect field of the Mac OS Toolbox ControlRecord must be the same as the Frame rectangle of the StdControl object. We store directly to the ControlRecord rather than using the SizeControl and MoveControl traps because we want to bypass the automatic drawing (and the need to set the port and coordinate system) performed by those traps. The contrlRect is not the same as the Frame rectangle if the latter is outside the 16-bit QuickDraw coordinate space.
Purpose:
Map from Small to Big value when using 32 bit values. Call this function only when mUsingBigValues is true.
Access:
Prototype:
SInt32 CalcBigValue( SInt16 inSmallValue );Parameters:
This method has the following parameter:
Return:
SInt32 containing the Big value.
Remarks:
The control class uses Big (32 bit) values, but the Mac Control Manager only supports Small (16 bit) values. See the discussion for the SetStdMinAndMax() method.
Purpose:
Map from Big to Small value when using 32 bit values. Call this function only when mUsingBigValues is true.
Access:
Prototype:
SInt16 CalcSmallValue( SInt32 inBigValue );Parameters:
This method has the following parameter:
Return:
SInt16 containing the Small value.
Remarks:
The control class uses Big (32 bit) values, but the Mac Control Manager only supports Small (16 bit) values. Refer to the discussion for the SetStdMinAndMax() method.
Purpose:
Create a StdControl from a `CNTL' resource.
Access:
Prototype:
static LStdControl* CreateFromCNTL(Parameters:
ResIDT inCNTLid,
MessageT inValueMessage,
ResIDT inTextTraitsID,
LView *inSuperView);
This method has the following parameters:
Return:
Purpose:
Access:
Prototype:
virtual void DisableSelf();Parameters:
Return:
Purpose:
This method is an override of the base class method DrawSelf() in LPane. It draws the standard control.
Purpose:
Access:
Prototype:
virtual void EnableSelf();Parameters:
Return:
Purpose:
This method is an override of the base class method FindHotSpot() in LControl. It determines which hot spot, if any, contains the specified point.
Purpose:
This method is an override of the base class method FocusDraw() in LPane. It prepares for drawing in the Pane, and signals if the Pane has no SuperView.
Purpose:
This method is an override of the base class method GetDescriptor() in LPane. It returns the Descriptor, which is the Title, of a standard control.
Purpose:
This method returns the value of mMacControlH.
Access:
Prototype:
ControlHandle GetMacControl() const;Parameters:
Return:
The ControlHandle held in mMacControlH.
Purpose:
This method returns the value of sTrackingControl.
Access:
Prototype:
static LStdControl* GetTrackingControl();Parameters:
Return:
A pointer to an LStdControl, containing the value of sTrackingControl.
Purpose:
This method is an override of the base class method GetDescriptor() in LPane. It hides a standard control.
Purpose:
This method is an override of the base class method HotSpotAction() in LControl. It makes mouse tracking easier.
Purpose:
This method is an override of the base class method HotSpotAction() in LControl. It performs the result of clicking and releasing mouse inside a hot spot.
Purpose:
This is a private initializer which creates the Mac OS Toolbox Control.
Access:
Prototype:
void InitStdControl( SInt16 inControlKind,Parameters:
ResIDT inTextTraitsID,
ConstStringPtr inTitle,
SInt32 inMacRefCon);
This method has the following parameters:
|
||
Return:
Purpose:
This method is an override of the base class method FocusDraw() in LPane. This method is an override to update the Mac ControlHandle. It moves the location of the Frame by the specified amounts.
Purpose:
This method is an override of the base class method PointInHotSpot() in LControl. It tells whether a particular point is inside a hot spot or not.
Purpose:
This method is an override of the base class method FocusDraw() in LPane. This method is an override to update the Mac ControlHandle. It changes the Frame size by the specified amounts.
Purpose:
This method sets the control action proc (ControlActionUPP) for the control.
Access:
Prototype:
void SetActionProc( ControlActionUPP inActionProc );Parameters:
This method has the following parameter:
Return:
Purpose:
This method is an override of the base class method SetDescriptor() in LPane. This method sets the Descriptor, which is the title, of a standard control.
Purpose:
This method is an override of the base class method SetMaxValue() in LControl. It sets the maximum value that a control can have.
Purpose:
This method is an override of the base class method SetMinValue() in LControl. It sets the minimum value that a control can have.
Purpose:
Sets the minimum and maximum values for the standard Mac OS control associated with this object.
Access:
Prototype:
void SetStdMinAndMax();Parameters:
Return:
Remarks:The Control class uses Big (32 bit) values, but the Mac Control
Manager only supports Small (16 bit) values. So this object class
has to map between Big and Small values. When either the minimum or maximum value is outside 16 bit range
(below -32,768 or above 32,767), we set mUsingBigValues to true. In that case, you must call CalcSmallValue() and CalcBigValue() to map between the Small values used by the Mac Control Manager
and the Big values used by this class. The mapping strategy is as follows. When using Big values, we
always set the minimum value for the Mac Control to zero. There
are two cases for the maximum value, depending on whether the
difference between the Big Max and Min is greater than or less
than 32,767. If greater, we set the Mac Control maximum to 32,767.
If less, we set the Mac Control maximum to that difference. These
choices simplify the math for converting between Big and Small
values. The functions CalcSmallValue() and CalcBigValue() use the following equations to convert between Big and Small
values.
(1) BigMax - BigMin > 32,767 SmallValue = BigValue - BigMin
----------- = ------------------
32,767 (BigMax - BigMin)
(2) BigMax - BigMin <= 32,767
SmallValue = BigValue - BigMin
Purpose:
This method sets the value of the mThumbFunc data member.
Access:
Prototype:
void SetThumbFunc( ThumbActionUPP inThumbFunc );Parameters:
This method has the following parameter:
Return:
Purpose:
This method is an override of the base class method SetValue() in LPane. This method sets the value of a standard control. It overrides the inherited function to map from 32 bit numbers to the 16 bit numbers supported by the Mac OS Control Manager.
Purpose:
This method is an override of the base class method ShowSelf() in LPane. This method shows the control.
Purpose:
This method is an override of the base class method TrackHotSpot() in LControl. It tracks the mouse while it is down after clicking in a Control hot spot, and tells whether the mouse is released within the hot spot.
Purpose:
Indicates whether a value for a control is within the range supported by the Mac OS Control Manager.
Access:
Prototype:
static Boolean ValueIsInStdRange( SInt32 inValue );Parameters:
This method has the following parameter:
Return:
Returns true if the value is in the range, else returns false.
Purpose:
This data member stores the handle to the Mac OS control.
Access:
Prototype:
ControlHandle mMacControlH;
Purpose:
This data member stores a pointer to the thumb action procedure for the control.
Access:
Prototype:
ThumbActionUPP mThumbFunc;
Purpose:
This data member stores the value for the control kind. Refer to the Mac OS system header named Controls.h for more information on these enumerations.
Access:
Prototype:
SInt16 mControlKind;
Purpose:
This data member stores the value of the resource ID to use for text traits.
Access:
Prototype:
ResIDT mTextTraitsID;
Purpose:
This data member remembers whether we are using Big values for the control or not.
Access:
Prototype:
Boolean mUsingBigValues;
Purpose:
This data member stores the pointer to the current standard control that is being tracked.
Access:
Prototype:
static LStdControl* sTrackingControl;