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

 

LEditField



Overview:

LEditField is a PowerPlant class that encapsulates the behavior of an editable text field, as commonly appears in a dialog box.

Methods :

The methods in this class are:

 

LEditField()  
~LEditField()  
AdjustCursorSelf()  
AdjustTextWidth()  
AlignTextEditRects()  
BeTarget()  
ClickSelf()  
DisableSelf()  
DontBeTarget()  
DrawBox()  
DrawSelf()  
EnableSelf()  
FindCommandStatus()  
FocusDraw()  
GetDescriptor()  
GetMacTEH()  
GetValue()  
HandleKeyPress()  
HideSelf()  
InitEditField()  
MoveBy()  
ObeyCommand()  
ResizeFrameBy()  
RestorePlace()  
SavePlace()  
SelectAll()  
SetDescriptor()  
SetKeyFilter()  
SetMaxChars()  
SetTextTraitsID()  
SetValue()  
SpendTime()  
TooManyCharacters()  
UseWordWrap()  
UserChangedText()  
 

Data Members:

The data members in this class are:

 

mTextEditH  
mKeyFilter  
mTypingAction  
mMaxChars  
mTextTraitsID  
mHasBox  
mHasWordWrap  
 

Operation:

LEditField uses TextEdit to implement an editable text field. PowerPlant also handles undo and redo for most text-related actions.

Source files:

(Pane Classes)

LEditField.h

LEditField.cp

Ancestors:

LAttachable

LCommander

LPane

LPeriodical

LEditField()

Purpose:

The constructors create objects from the passed-in parameters.

Access:

Public

Prototype:

LEditField();

LEditField( const LEditField &inOriginal );

LEditField( const SPaneInfo &inPaneInfo,
Str255 inString,
ResIDT inTextTraitsID,
SInt16 inMaxChars,
Boolean inHasBox,
Boolean inHasWordWrap,
KeyFilterFunc inKeyFilter,
LCommander *inSuper );

LEditField( const SPaneInfo &inPaneInfo,
Str255 inString,
ResIDT inTextTraitsID,
SInt16 inMaxChars,
UInt8 inAttributes,
KeyFilterFunc inKeyFilter,
LCommander *inSuper );

LEditField( LStream *inStream );
Parameters:

The parameters for these constructors are:

 

const   LEditField&  
inOriginal  
The reference to the object to copy.  
const   SPaneInfo&  
inPaneInfo  
Reference to the Superpane info.  
Str255  
inString  
The string for the field.  
ResIDT  
inTextTraitsID  
The text traits resource ID.  
SInt16  
inMaxChars  
The max number of characters.  
Boolean  
inHasBox  
Indicates whether to see the editAttr_Box attribute or not.  
Boolean  
inHasWordWrap  
Indicates whether the text field wraps. This sets the editAttr_WordWrap attribute.  
KeyFilterFunc  
inKeyFilter  
A pointer to a key press filter procedure.  
LCommander*  
inSuper  
The Supercommander.  
UInt8  
inAttributes  
The attributes  

~LEditField()

Purpose:

The destructor destroys the object.

Access:

Virtual, Public

Prototype:

virtual ~LEditField();

AdjustCursorSelf()

Purpose:

EditField uses the standard I-Beam cursor. This is an override of AdjustCursorSelf() in LPane.

AdjustTextWidth()

Purpose:

Adjust the width of the destination rectangle of the Toolbox TextEdit record.

This function does nothing if mHasWordWrap is true. If mHasWordWrap is false, this function sets the width of the TextEdit destination rectangle to either the width of the text or a very large number, depending on the value of inShrinkToText.

This adjustment is needed to make autoscrolling work properly when mHasWordWrap is off. While entering text, the destination rectangle should be very wide so that the text doesn't word wrap. However, while clicking, it should be just as wide as the text so that the EditField does not autoscroll past the edge of the text.

Access:

Virtual, Protected

Prototype:

virtual void AdjustTextWidth(
Boolean inShrinkToText );
Parameters:

The parameter for this method is:

 

Boolean  
inShrinkToText  
Indicates whether to adjust the rectangle or not.  

Return:

None

AlignTextEditRects()

Purpose:

Align the view and destination rectangles of the Toolbox TextEdit record with the Frame of an EditField.

Access:

Virtual, Protected

Prototype:

virtual void AlignTextEditRects();
Parameters:

None

Return:

None

BeTarget()

Purpose:

EditField is becoming the Target. This is an override of BeTarget() in LCommander.

ClickSelf()

Purpose:

Respond to Click inside an EditField. This is an override of ClickSelf() in LPane.

DisableSelf()

Purpose:

Disable an EditField. This is an override of DisableSelf() in LPane.

DontBeTarget()

Purpose:

EditField is becoming the Target. This is an override of DontBeTarget() in LCommander.

DrawBox()

Purpose:

Draw a box around an EditField.

Access:

Virtual, Protected

Prototype:

virtual void DrawBox();
Parameters:

None

Return:

None

Remarks:

Box around an EditField is outset from the Text by 2 pixels. The box itself is 1 pixel thick, drawn in the foreground color of the Pane (not necessarily the same as the text color). If the EditField is disabled, the box draws with a gray pattern. The 1 pixel rectangle between the box and the text draws in the background color of the text.

DrawSelf()

Purpose:

Draw an EditField. This is an override of DrawSelf() in LPane.

EnableSelf()

Purpose:

Enable an EditField. This is an override of EnableSelf() in LPane.

FindCommandStatus()

Purpose:

Pass back the status of a Command. This is an override of FindCommandStatus() in LCommander.

FocusDraw()

Purpose:

Prepare for drawing in the EditField. This is an override of FocusDraw() in LPane.

GetDescriptor()

Purpose:

Return the first 255 characters of the EditField as a Pascal string. The caller must allocate a Str255 variable for storing the string. This is an override of GetDescriptor() in LPane.

GetMacTEH()

Purpose:

This method returns the handle to the Mac OS TextEdit structure.

Access:

Public

Prototype:

TEHandle GetMacTEH();
Parameters:

None

Return:

A handle to the TextEdit structure.

GetValue()

Purpose:

Return the integer value represented by the contents of an EditField. An empty or non-numerical EditField evaluates to zero. This is an override of GetValue() in LPane.

HandleKeyPress()

Purpose:

Handle key stroke directed at an EditField. Return true if the EditField handles the keystroke. This is an override of HandleKeyPress() in LCommander.

HideSelf()

Purpose:

Hide an EditField. An invisible EditField can't be on duty. This is an override of HideSelf() in LPane.

InitEditField()

Purpose:

Initialize member variables of a EditField to default values.

Access:

Private

Prototype:

void InitEditField( UInt8 inAttributes );
Parameters:

The parameter for this method is:

 

UInt8  
inAttributes  
The attributes, from the enum values in LEditField.h  

Return:

None

MoveBy()

Purpose:

Move the location of the Frame by the specified amounts. This is an override of MoveBy() in LPane.

ObeyCommand()

Purpose:

Handle standard editing commands. This is an override of ObeyCommand() in LCommander.

ResizeFrameBy()

Purpose:

Change the Frame size by the specified amounts inWidthDelta and inHeightDelta specify, in pixels, how much larger to make the Frame. Positive deltas increase the size, negative deltas reduce the size. This is an override of ResizeFrameBy() in LPane.

RestorePlace()

Purpose:

Save TextEdit rectangles. This is an override of RestorePlace() in LPane.

SavePlace()

Purpose:

Save TextEdit rectangles. This is an override of SavePlace() in LPane.

SelectAll()

Purpose:

Select entire contents of an EditField.

Access:

Public

Prototype:

virtual void SelectAll();
Parameters:

None

Return:

None

SetDescriptor()

Purpose:

Set the contents of an EditField from a Pascal string. This is an override of SetDescriptor() in LPane.

SetKeyFilter()

Purpose:

Specify the function for filtering keystrokes.

Access:

Virtual, Public

Prototype:

virtual void SetKeyFilter(
KeyFilterFunc inKeyFilter );
Parameters:

The parameter for this method is:

 

KeyFilterFunc  
inKeyFilter  
The function pointer for the key filter proc.  

Return:

None

SetMaxChars()

Purpose:

Specify the maximum number of characters that an EditField can contain.

Access:

Virtual, Public

Prototype:

virtual void SetMaxChars( SInt16 inMaxChars );
Parameters:

The parameter for this method is:

 

SInt16  
inMaxChars  
The maximum number of characters.  

Return:

None

SetTextTraitsID()

Purpose:

Specify the resource ID of the TextTraits for an EditField. This function updates the line height to fit the text characteristics.

Access:

Virtual, Public

Prototype:

virtual void SetTextTraitsID(ResIDT 
inTextTraitsID);
Parameters:

The parameter for this method is:

 

ResIDT  
inTextTraitsID  
The resource ID for the text traits resource.  

Return:

None

SetValue()

Purpose:

Set the contents of an EditField to the string representation of aspecified integer number. This is an override of SetValue() in LPane.

SpendTime()

Purpose:

At idle time, flash the insertion cursor. This is an override of SpendTime() in LPeriodical.

TooManyCharacters()

Purpose:

Indicate whether adding the specified number of characters will exceed the maximum allowed. This method assumes that the characters being added will replace the current selection.

Access:

Virtual, Protected

Prototype:

virtual Boolean TooManyCharacters(
SInt32 inCharsToAdd );
Parameters:

The parameter for this method is:

 

SInt32  
inCharsToAdd  
The number of characters you want to test for the maximal limit.  

Return:

Returns true if the maximum will be exceeded, else false.

UseWordWrap()

Purpose:

Specify whether the EditField word wraps to its frame.

Access:

Virtual, Public

Prototype:

virtual void UseWordWrap( Boolean inSetting );
Parameters:

The parameter for this method is:

 

Boolean  
inSetting  
Indicate whether to wrap or not.  

Return:

None

UserChangedText()

Purpose:

Text of EditField has changed as a result of the user actions. You should override this to validate the field and/or dynamically update the field as the user types. This function is not called by SetDescriptor(), which is typically used to programatically change the text.

Access:

Virtual, Public

Prototype:

virtual void UserChangedText();
Parameters:

None

Return:

None

mTextEditH

Purpose:

The handle to the TextEdit record.

Access:

Protected

Prototype:

TEHandle mTextEditH;

mKeyFilter

Purpose:

The key filter proc storage space.

Access:

Protected

Prototype:

KeyFilterFunc mKeyFilter;

mTypingAction

Purpose:

Pointer to an LTETypingAction object.

Access:

Protected

Prototype:

LTETypingAction *mTypingAction;

mMaxChars

Purpose:

The maximum number of characters that the field can accomodate.

Access:

Protected

Prototype:

SInt16 mMaxChars;

mTextTraitsID

Purpose:

The resource ID for the text traits.

Access:

Protected

Prototype:

ResIDT mTextTraitsID;

mHasBox

Purpose:

Indicates whether the editAttr_Box enum attribute is set.

Access:

Protected

Prototype:

Boolean mHasBox;

mHasWordWrap

Purpose:

Indicates whether the editAttr_WordWrap enum attribute is set.

Access:

Protected

Prototype:

Boolean mHasWordWrap;

 


[ 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