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

 

LTextEditView



Overview:

LTextEditView is a PowerPlant class that is used for wrapping the TextEdit functionality of the Mac OS Toolbox.

Methods :

The methods in this class are:

 

LTextEditView()  
~LTextEditView()  
AdjustCursorSelf()  
AdjustImageToText()  
AlignTextEditRects()  
BeTarget()  
CalcTEHeight()  
ChangeFontSizeBy()  
ClickSelf()  
ClickAutoScroll()  
DontBeTarget()  
DrawSelf()  
FindCommandStatus()  
FocusDraw()  
ForceAutoScroll()  
GetAlignment()  
GetAttributes()  
GetColor()  
GetDescriptor()  
GetFont()  
GetMacTEH()  
GetSelection()  
GetSize()  
GetStyle()  
GetTextHandle()  
GetTextTraitsID()  
GetValue()  
HandleKeyPress()  
HasAttribute()  
HideSelf()  
InitTextEditView()  
Insert()  
MoveBy()  
MyClickLoop()  
MyTEClick()  
ObeyCommand()  
ResizeFrameBy()  
RestorePlace()  
SavePlace()  
SaveStateForUndo()  
ScrollImageBy()  
SelectAll()  
SetAlignment()  
SetAttributes()  
SetClickLoop()  
SetColor()  
SetDescriptor()  
SetFont()  
SetSize()  
SetStyle()  
SetTextHandle()  
SetTextPtr()  
SetTextTraitsID()  
SpendTime()  
TETooBig()  
ToggleAttribute()  
UserChangedText()  
 

Data Members:

The data members in this class are:

 

mClickLoopUPP  
mTextEditH  
mTextTraitsID  
mTextAttributes  
mTypingAction  
 

Operation:

LTextEditView allows you to specify the font, style, size, color, and justificiation of the text you create.

Source files:

(Pane Classes)

LTextEditView.h

LTextEditView.cp

Ancestors:

LCommander

LPeriodical

LView

LTextEditView()

Purpose:

The constructor creates objects from the passed-in parameters.

Access:

Public

Prototype:

LTextEditView();

LTextEditView( const SPaneInfo& inPaneInfo,
const SViewInfo& inViewInfo,
UInt16 inTextAttributes,
ResIDT inTextTraitsID );

LTextEditView( LStream *inStream );
Parameters:

The parameters for these constructors are:

 

const   SPaneInfo&  
inPaneInfo  
The Superpane info.  
const   SViewInfo &  
inViewInfo  
The Superview info.  
UInt16  
inTextAttributes  
The text attributes.  
ResIDT  
inTextTraitsID  
The text traits.  
LStream*  
inStream  
The stream to read from.  

~LTextEditView()

Purpose:

The destructor destroys the object.

Access:

Virtual, Public

Prototype:

virtual ~LTextEditView();

AdjustCursorSelf()

Purpose:

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

AdjustImageToText()

Purpose:

This method resizes the image to match the size of the text.

Access:

Virtual, Public

Prototype:

virtual void AdjustImageToText();
Parameters:

None

Return:

None

AlignTextEditRects()

Purpose:

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

Access:

Virtual, Protected

Prototype:

virtual void AlignTextEditRects();
Parameters:

None

Return:

None

BeTarget()

Purpose:

TextEdit is becoming the Target.

Access:

Virtual, Protected

Prototype:

virtual void BeTarget();
Parameters:

None

Return:

None

CalcTEHeight()

Purpose:

Calculates the height of the TextEdit record.

Access:

Virtual, Public

Prototype:

SInt32 LTextEditView::CalcTEHeight()
Parameters:

none

Return:

Height of TextEdit record as 32-bit value.

ChangeFontSizeBy()

Purpose:

Changes the font size for a given selection range by a specified value.

Access:

Virtual, Public

Prototype:

Boolean LTextEditView::ChangeFontSizeBy( SInt16 
inDeltaSize )
Parameters:

 

SInt16  
inDeltaSize  
Value to change font size by  

Return:

Returns True if change was successful.

Remarks:

Will only work if the font over the selection range is constant.

ClickSelf()

Purpose:

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

ClickAutoScroll()

Purpose:

Used in the click loop to perform scrolling while clicking.

Access:

Virtual, Protected

Prototype:

void LTextEdit::ClickAutoScroll( const Point 
&inLocalPoint )
Parameters:

 

const Point  
&inLocalPoint  
Point clicked in  

Return:

none

DontBeTarget()

Purpose:

TextEdit is no longer the Target. Remove TextEdit from the IdleQueue. This is an override of DontBeTarget() in LCommander.

DrawSelf()

Purpose:

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

FindCommandStatus()

Purpose:

This method passes back the status of a command. This is an override of FindCommandStatus() in LCommander.

FocusDraw()

Purpose:

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

ForceAutoScroll()

Purpose:

Works with TextEdit's autoscrolling capabilities to keep text and scrollbars syncronized.

GetAlignment()

Purpose:

Returns the justification setting for the TextEdit record.

GetAttributes()

Purpose:

Returns the raw attribute flags.

Access:

Public

Remarks:

Treated as read only.

GetColor()

Purpose:

Returns the RGB value of the selected text.

Access:

Virtual, Public

GetDescriptor()

Purpose:

Returns up to the first 255 characters of the TextEditView as a Pascal string.

Access:

Virtual, Public

Prototype:

StringPtr LTextEditView::GetDescriptor( 
  Str255 outDescriptor ) const
Remarks:

Caller must allocate memory for the Str255 variable for storing the string.

GetFont()

Purpose:

Determine the font for the selection range. There are two versions of this routine. One passes back the font name, the other passes back the font number.

Access:

Virutal, Public

Prototype:

Boolean LTextEditView::GetFont( 
  SInt16 &outFontNum )
Boolean LTextEditView::GetFont(Str255 &outName )

GetMacTEH()

Purpose:

Retrieve theHandle to the Mac TextEdit Record associated with a TextEdit.

Caller may change record fields, and is responsible for redrawing the TextEdit as necessary to reflect any changes. However, caller must not dispose of the TEHandle.

Access:

Public

Prototype:

TEHandle GetMacTEH();
Parameters:

None

Return:

Handle to the Mac TextEdit Record associated with a TextEdit.

GetSelection()

Purpose:

Passes back the AppleEvent Descriptor of the seletected text.

GetSize()

Purpose:

Returns the size of the style record for the text range.

GetStyle()

Purpose:

Returns the style of the selected text range.

GetTextHandle()

Purpose:

Retrieve a Handle to the text in the LTextEditView. The Handle is the actual Handle used by the Toolbox TextEdit record. Treat this Handle as read-only.

Access:

Virtual, Public

Prototype:

virtual Handle GetTextHandle();
Parameters:

None

Return:

Return a Handle to the text in the LTextEditView.

GetTextTraitsID()

Purpose:

Returns the ID of the current TextTraits record.

Access:

Public

GetValue()

Purpose:

Return an integer value represented by the contents of the TextEditView.

Access:

Virtual, Public

Prototype:

SInt32 LTextEditView::GetValue() const
Parameters:

none

Return:

32-bit integer

Remarks:

An empty or non-numerical TextEditView evaluates to zero.

HandleKeyPress()

Purpose:

Handle key stroke directed at an TextEdit. This is an override of HandleKeyPress() in LCommander.

HasAttribute()

Purpose:

Check for the presence of a specific attribute.

Access:

Public

Prototype:

Boolean HasAttribute( UInt16 inAttribute );
Parameters:

The parameter for this method is:

 

UInt16  
inAttribute  
The attribute to check for.  

Return:

Boolean indicating whether the attribute is present, false if not.

HideSelf()

Purpose:

Hide an LTextEditView. An invisible LTextEditView can't be OnDuty. This is an override of HideSelf() in LPane.

InitTextEditView()

Purpose:

Initialize member variables of a TextEdit to default values.

Access:

Private

Prototype:

void InitTextEditView( ResIDT inTextTraitsID );
Parameters:

The parameter for this method is:

 

ResIDT  
inTextTraitsID  
The text traits to set.  

Return:

None

Insert()

Purpose:

Replacement for TEInsert() that allows for when text is greater than 32K. Call this routine in place of TEInsert() or TEStyleInsert(). Will optionally recalculate, autoscroll, and refresh the text if desired.

Access:

Virtual, Public

MoveBy()

Purpose:

Move the location of the Frame by the specified amounts inHorizDelta and inVertDelta specify, in pixels, how far to move the Frame (within its surrounding Image). Positive horizontal deltas move to the right, negative to the left. Positive vertical deltas move down, negative up. This is an override of MoveBy() in LPane.

MyClickLoop()

Purpose:

ClickLoop callback used to help autoscrolling while selecting text.

Access:

Static, Public

MyTEClick()

Purpose:

Handle a click in a TextEdit field. Identical to the standard TEClick funtion, but includes code to handle a problem with clickloop functions in naitive mode.

Access:

Virtual, Public

ObeyCommand()

Purpose:

Issue a command to a Commander. 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:

Restore TextEdit parameters from a stream.

Access:

Virtual, Public

Prototype:

virtual void RestorePlace( LStream *inPlace );
Parameters:

The parameter for this method is:

 

LStream*  
inPlace  
The stream to read from.  

Return:

None

SavePlace()

Purpose:

Save TextEdit parameters to a stream.

Access:

Virtual, Public

Prototype:

virtual void SavePlace( LStream *outPlace );
Parameters:

The parameter for this method is:

 

LStream*  
outPlace  
The stream to write to.  

Return:

None

SaveStateForUndo()

Purpose:

Preserve the state so that an Undo operation is possible.

Access:

Virtual, Protected

Prototype:

virtual STextEditUndoH SaveStateForUndo();
Parameters:

None

Return:

Returns a handle to the Undo information.

ScrollImageBy()

Purpose:

Scroll the Text. This is an override of ScrollImageBy() in LView.

SelectAll()

Purpose:

Select entire contents of an TextEdit.

Access:

Virtual, Public

Prototype:

virtual void SelectAll();
Parameters:

None

Return:

None

SetAlignment()

Purpose:

Changes the justification of the TextEdit record.

Access:

Virtual, Public

SetAttributes()

Purpose:

Allows the setting of attributes. Replaced all existing attributes with the value passed as the argument.

Access:

Public

Remarks:

If you want to change only a single attribute,use ToggleAttribute() instead.

SetClickLoop()

Purpose:

Allows you to specify your own clickloop funtion.

Access:

Virtual, Public

Prototype:

void LTextEditView::SetClickLoop( 
  void *inClickLoop )
Parameters:

 

void  
*inClickLoop  
Pointer to a clickloop function  

Return:

none

Remarks:

Disposes of existing clickloop, if any. Also since the point of the clickloop is for autoscrolling, that attribute is set here.

SetColor()

Purpose:

Sets the color of the text range

Access:

Virtual, Public

SetDescriptor()

Purpose:

Sets the text to a given string

Access:

Virtual, Public

Remarks:

Replaces any and all text already in the descriptor.

SetFont()

Purpose:

Given a font name or font number, set the font of the selected text accordingly.

Access:

Virtual, Public

Prototype:

void LTextEditView::SetFont( SInt16 inFontNumber )

void LTextEditView::SetFont( 
  ConstStringPtr inFontName )

SetSize()

Purpose:

Sets the font size of the text range.

Access:

Virtual, Public

SetStyle()

Purpose:

Sets the text style of the selected text.

Access:

Virtual, Public

SetTextHandle()

Purpose:

Set the text in the LTextEditView to the contents of the specified Handle. The LTextEditView copies the data in the Handle, so the caller retains ownership of the Handle (and should dispose of it as needed).

Access:

Virtual, Public

Prototype:

virtual void SetTextHandle( Handle inTextH );
Parameters:

The parameter for this method is:

 

Handle  
inTextH  
The text handle to set to.  

Return:

None

SetTextPtr()

Purpose:

Set the pointer to the text.

Access:

Virtual, Public

Prototype:

virtual void SetTextPtr( Ptr inTextP, 
SInt32 inTextLen);
Parameters:

The parameters for this method are:

 

Ptr  
inTextP  
The pointer to the text.  
SInt32  
inTextLen  
The length of the text.  

Return:

None

SetTextTraitsID()

Purpose:

Specify the resource ID of the TextTraits for an TextEdit. This method 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.  

Return:

None

SpendTime()

Purpose:

Flash the insertion cursor during idle time. This is an override of SpendTime() in LPeriodical.

TETooBig()

 

ToggleAttribute()

Purpose:

Allows the toggling of an attribute setting.

Access:

Public

Remarks:

If you want to change all attributes, use SetAttributes() instead.

UserChangedText()

Purpose:

Text of TextEdit has changed as a result of user action.

You should override this to validate the field and/or dynamically update 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:

Storage for the handle to the TextEdit record.

Access:

Protected

Prototype:

TEHandle mTextEditH;

mTextTraitsID

Purpose:

Storage for the text traits.

Access:

Protected

Prototype:

ResIDT mTextTraitsID;

mTextAttributes

Purpose:

Storage for the text attributes.

Access:

Protected

Prototype:

UInt16 mTextAttributes;

 


[ 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