Class: TLabel

Declaration: Label.h

Taxonomy Categories:

Member Functions:


Interface Category:

API.

Inherits From:

MDrawable, MGUIAttributeUser

Inherited By:

TTextLabel TGraphicLabel

Purpose:

TLabel derives from MDrawable and is the base class that defines the protocol for text and graphic labels used by controls. Control labels can be active or inactive, enabled or disabled, and selected or unselected; the label can draw something different for each of these states. For example, the text label on a push button might display gray text when the button is disabled.

Instantiation:

TLabel is an abstract class, so it should not be instantiated.

Deriving Classes:

Classes deriving from TLabel must override the pure virtual functions: IsEmpty, GetBounds, MoveTo, MoveBy, and Draw. Derived classes which use an equality test should probably override the IsEqual function to test the contents of the label.

Concurrency:

Not multithread safe.

Resource Use:

No special requirements.

Member Function: TLabel::TLabel

  1. TLabel ()
  2. TLabel (bool enabled)
  3. TLabel (const TLabel &)

Interface Category:

API.

Purpose:

  1. Default constructor.
  2. Creates a new TLabel whose initial state is enabled or disabled according to the specified flag.
  3. Copy constructor.

Calling Context:

  1. Called by the stream-in operators.
  2. Call this function directly.
  3. Called to copy an object.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TLabel::~TLabel

virtual ~ TLabel ()

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: TLabel::operator=

TLabel & operator =(const TLabel &)

Interface Category:

API.

Purpose:

Assignment operator.

Calling Context:

Call this function by using the operator in an assignment statement.

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:

None.

Member Function: TLabel::operator==

bool operator ==(const TLabel &) const

Interface Category:

API.

Purpose:

Tests whether the two objects on either side of the ==symbol are equal.

Calling Context:

Call this function by using the operator in an expression.

Parameters:

Return Value:

Returns true if the two objects are equal.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

Equivalent to calling IsEqual. Overriding the IsEqual function also effectively overrides the ==operator with the same test.

Member Function: TLabel::operator>>=

virtual TStream & operator >>=(TStream &) const

Interface Category:

API.

Purpose:

Stream-out operator.

Calling Context:

Called to stream out data.

Parameters:

Return Value:

Returns a reference to the stream the object streams itself out to.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TLabel::operator<<=

virtual TStream & operator <<= (TStream &)

Interface Category:

API.

Purpose:

Stream-in operator.

Calling Context:

Called to stream in data.

Parameters:

Return Value:

Returns a reference to the stream the object streams itself in from.

Exceptions:

Throws TInvalidVersionError if it encounters an object whose version number indicates it cannot be streamed in. Passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TLabel::IsEmpty

virtual bool IsEmpty () const

Interface Category:

API.

Purpose:

Reports whether this label is empty. Classes deriving from TLabel must provide their own definitions of empty.

Calling Context:

Call this function directly.

Parameters:

Return Value:

Returns true if this label is empty.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

This function is a pure virtual function and must be overridden by classes deriving from TLabel.

Member Function: TLabel::IsActive

bool IsActive () const

Interface Category:

API.

Purpose:

IsActive reports whether this label is active. Labels usually have different looks for active and inactive states.

Calling Context:

Call this function directly.

Parameters:

Return Value:

Returns true if this label is active.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TLabel::SetActive

virtual void SetActive (bool)

Interface Category:

API.

Purpose:

Activates or deactivates the label, according to the specified flag. (Labels usually have different looks for active and inactive states.)

Calling Context:

Call this function directly.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TLabel::IsEnabled

bool IsEnabled () const

Interface Category:

API.

Purpose:

Reports whether this label is enabled. Typically, labels have different looks for enabled and disabled states.

Calling Context:

Call this function directly.

Parameters:

Return Value:

Returns true if this label is active.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TLabel::SetEnabled

virtual void SetEnabled (bool)

Interface Category:

API.

Purpose:

Enables or disables this label according to the specified flag. Typically, labels have different looks for enabled and disabled states.

Calling Context:

Call this function directly.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TLabel::IsSelected

bool IsSelected () const

Interface Category:

API.

Purpose:

Reports whether this label is selected. Labels usually have different looks for active and inactive states.

Calling Context:

Call this function directly.

Parameters:

Return Value:

Returns true if this label is selected.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TLabel::SetSelected

virtual void SetSelected (bool)

Interface Category:

API.

Purpose:

Selects or deselects this label according to the specified flag. Typically, labels have different looks for selected and unselected states.

Calling Context:

Call this function directly.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TLabel::GetBounds

virtual TGRect GetBounds () const

Interface Category:

API.

Purpose:

Computes and returns the bounding rectangle for this label.

Calling Context:

Call this function directly.

Parameters:

Return Value:

Returns the bounding rectangle for this label.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

This function is a pure virtual function and must be overridden by classes deriving from TLabel.

Member Function: TLabel::GetSize

virtual TGPoint GetSize () const

Interface Category:

API.

Purpose:

Computes and returns the height and width of the bounding rectangle for this label. This function calls GetBounds to compute the height and width of this label; therefore classes deriving from TLabel need not override this function--overriding GetBounds is sufficient.

Calling Context:

Call this function directly.

Parameters:

Return Value:

Returns a TGPoint whose x component is the width of this label, and whose y component is the height of this label.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TLabel::MoveTo

virtual void MoveTo (const TGPoint &)

Interface Category:

API.

Purpose:

Moves the label so that its upper left corner attains the specified position.

Calling Context:

Call this function directly.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

This function is a pure virtual function and must be overridden by classes deriving from TLabel.

Member Function: TLabel::MoveBy

virtual void MoveBy (const TGPoint &)

Interface Category:

API.

Purpose:

Adjusts the position of this label by the specified delta x and delta y values.

Calling Context:

Call this function directly. If you have the destination coordinates, you can call MoveTo.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

This function is a pure virtual function and must be overridden by classes deriving from TLabel.

Member Function: TLabel::Draw

virtual void Draw (TGrafPort &) const

Interface Category:

API.

Purpose:

Draws this label to the specified TGrafPort.

Calling Context:

Call this function directly.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

This function is a pure virtual function and must be overridden by classes deriving from TLabel.

Member Function: TLabel::GetInactivePaint

virtual const TPaint * GetInactivePaint () const

Interface Category:

API.

Purpose:

Gets the current color or other look-attributes that depict an inactive state of a label.

Calling Context:

Call this function directly.

Parameters:

Return Value:

Returns a TPaint containing the look-attributes.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

If no inactive paint attributes have yet been adopted, this function gets the current look-attributes for disabled states. Look-attributes for inactive states default to those of disabled states because the system does not provide predetermined look-attributes for inactive states.

Member Function: TLabel::AdoptInactivePaint

virtual void AdoptInactivePaint (TPaint * paint)

Interface Category:

API.

Purpose:

Adopts an object that governs the look of a label's disabled state.

Calling Context:

Call this function directly.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

Unless this function is used, the label's inactive state will have the look of a disabled state because the system does not provide predetermined look-attributes for inactive states. Classes derived from TLabel may provide alternative member functions of depicting inactive states. For example, TGraphicLabel allows a client to adopt a complete MGraphic to represent the inactive state, even though a graphic label's disabled state is represented by a change in color. Adoption of an MGraphic allows arbitrary images to represent the inactive state instead of restricting the distinction to such look-attributes as color, transfer modes, and patterns, which a TPaint provides.

Member Function: TLabel::GetDisabledPaint

virtual const TPaint * GetDisabledPaint () const

Interface Category:

API.

Purpose:

Gets the look of a label's disabled state.

Calling Context:

Call this function directly.

Parameters:

Return Value:

TPaint * paint -The look-attributes for the label's disabled state.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TLabel::AdoptDisabledPaint

virtual void AdoptDisabledPaint (TPaint * paint)

Interface Category:

API.

Purpose:

Adopts an object that governs the look of a label's disabled state.

Calling Context:

Call this function directly.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

Unless this function is used, the look of the label's disabled state will default to that defined by the general look-attributes for disabled states.
Click the icon to mail questions or corrections about this material to Taligent personnel.
Copyright©1995 Taligent,Inc. All rights reserved.