Class: TStyleKind

Declaration: StyleKind.h

Taxonomy Categories:

Member Functions:


Interface Category:

API.

Inherits From:

MCollectible

Inherited By:

TCharacterStyleKind TParagraphStyleKind

Purpose:

TStyleKind is an abstract base class that provides protocol for specifying which class derived from TStyleRuns can manage a particular kind of style. When styles are added to text, each style is added to the TStyleRuns object for which the GetKind member function returns the same kind as the style. Classes derived from TStyle and TStyleRuns should maintain a const static object derived from TStyleKind, because the kind of a style should never change.

Instantiation:

TStyleKind is an abstract base class, so it is only indirectly instantiated when a concrete class derived from TStyleKind is instantiated. There are no data members associated with this abstract class. Therefore, this class has no impact on whether classes derived from TStyleKind should be allocated on the heap or the stack.

Deriving Classes:

All concrete style kinds must derive either directly or indirectly from TStyleKind. All classes derived from TStyleKind must override the following member functions: GetName, CreateStyleRuns, and GetDefaultStyleInfo. Classes derived from TStyleKind do not need to override operator== or Hash. GetName returns a const reference to a TToken, so the name of the kind of style should be a const static member of the class that is overriding GetName.

Concurrency:

Not multithread safe.

Resource Use:

No special requirements.

Other Considerations:

This class is never streamed. Because the only data member of classes derived from TStyleKind is a const static TToken, assignment of one kind to another does not do anything.

Member Function: TStyleKind::~TStyleKind

~ TStyleKind ()

Interface Category:

API.

Purpose:

Destructor.

Calling Context:

Called to destroy an object.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TStyleKind::GetName

virtual const TToken & GetName () const

Interface Category:

API.

Purpose:

Returns the name of the style kind. This name should be a const static member of the class.

Calling Context:

Called to get the name of the style kind.

Parameters:

Return Value:

Returns a const TToken reference representing the name of the style kind. The returned TToken is a const static member of the class, so it does not go out of scope.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TStyleKind::CreateStyleRuns

virtual TStyleRuns * CreateStyleRuns (const TText & theText, const TAllocationHeap & whichHeap) const

Interface Category:

API.

Purpose:

Creates and returns a TStyleRuns object that manages styles of this kind.

Calling Context:

Called when a style is added to text that does not currently have styles of that kind on it. This member function creates and returns a TStyleRuns object that can manage the new kind of style.

Parameters:

Return Value:

Returns a pointer to an object that is derived from TStyleRuns.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

The caller of this member function is responsible for the storage of the returned object.

Member Function: TStyleKind::GetDefaultStyleInfo

virtual TStyleRuns * GetDefaultStyleInfo (TTextIndex indexOfInterest, TStyleSet & returnSet, TTextRange & returnRange, TTextIndex & returnNextIndex, const TText & theText, const TAllocationHeap & whichHeap) const

Interface Category:

API.

Purpose:

Member functions such as TStandardText::GetStyleBounds and StylesAt can be called before any styles of the given type have been applied to the text. Different default behavior is required for different kinds of styles. For instance, if GetStyleBounds is called for character-based styles before any have been applied to the text, the resulting range is simply the range of the entire text. If GetStyleBounds is called for paragraph-based styles before any paragraph-based styles have been applied to the text, the text has to be parsed in order to determine the paragraph boundaries. If necessary, this member function can create the TStyleRuns object that manages this kind of style. That object is then returned. NIL is returned if no TStyleRuns object was created. The caller of this member function is responsible for the storage of the returned object.

Calling Context:

Called when information is requested about a kind of styles that haven't been applied to the text.

Parameters:

Return Value:

Returns a pointer to an object that is derived from TStyleRuns. Returns NIL if no new object was created. The caller of this member function is responsible for the storage of the returned object.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

The caller of this member function is responsible for the storage of the returned object.

Member Function: TStyleKind::operator==

bool operator ==(const TStyleKind & that) const

Interface Category:

API.

Purpose:

Determines if two objects are equal. Compares the names of the two style kinds.

Calling Context:

Called to compare style kinds. Usually called on values returned by TStyle::GetKind and TStyleRuns::GetKind to determine if the TStyleRuns object can manage a given style.

Parameters:

Return Value:

Returns true if the names of the two style kinds are equal. Returns false otherwise.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TStyleKind::operator!=

bool operator != (const TStyleKind & that) const

Interface Category:

API.

Purpose:

Compares the names of the two style kinds to determine if they are equal.

Calling Context:

Called to compare style kinds.

Parameters:

Return Value:

Returns false if the names of the two style kinds are equal. Returns true otherwise.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TStyleKind::Hash

virtual long Hash () const

Interface Category:

API.

Purpose:

Returns the result of calling Hash on the token returned by GetName.

Calling Context:

Same as for base class.

Parameters:

Return Value:

The numeric value of the hash.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TStyleKind::TStyleKind

  1. TStyleKind ()
  2. TStyleKind (const TStyleKind &)

Interface Category:

API.

Purpose:

An abstract base class that cannot be directly instantiated.
  1. Default constructor.
  2. Copy constructor.

Calling Context:

  1. Called by the constructors of classes derived from TStyleKind.
  2. Called by the constructors of classes derived from TStyleKind.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TStyleKind::operator=

TStyleKind & operator =(const TStyleKind &)

Interface Category:

API.

Purpose:

Assignment operator.

Calling Context:

Can only be called by classes that are derived from TStyleKind, because this is a protected member function.

Parameters:

Return Value:

A non-const reference to the left-hand side object.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

Because the only data member of classes that are derived from TStyleKind is a const static TToken, assignment of one kind to another does not do anything.
Click the icon to mail questions or corrections about this material to Taligent personnel.
Copyright©1995 Taligent,Inc. All rights reserved.