OWLNext    7.0
Borland's Object Windows Library for the modern age
Loading...
Searching...
No Matches
owl::TTextGadget Class Reference

Derived from TGadget, TTextGadget is a text gadget object. More...

#include <owl/textgadg.h>

Inheritance diagram for owl::TTextGadget:
owl::TGadget owl::TDynamicTextGadget owl::TMenuGadget owl::TModeGadget owl::TTimeGadget

Public Types

enum  TAlign { Left , Center , Right }
 Enumerates the text-alignment attributes. More...
 
- Public Types inherited from owl::TGadget
enum  TBorderStyle {
  None , Plain , Raised , Recessed , Embossed , Grooved , ButtonUp , ButtonDn , WndRaised , WndRecessed ,
  WellSet
}
 Gadget border styles. More...
 

Public Member Functions

 TTextGadget (int id=0, TBorderStyle=Recessed, TAlign=Left, uint numChars=10, LPCTSTR text=0, TFont *font=0)
 Constructs a TTextGadget object with the specified ID, border style, and alignment.
 
 TTextGadget (int id, TBorderStyle, TAlign, uint numChars, const tstring &text, TFont *font=0)
 String-aware overload.
 
 ~TTextGadget ()
 Destruct this text gadget and delete the text it is holding.
 
const TFontGetFont () const
 Returns the effective font used to render the text for this gadget.
 
void SetFont (const TFont &, bool repaint=true)
 Sets the font to be used by the gadget.
 
LPCTSTR GetText () const
 Returns the text for the gadget.
 
void SetText (LPCTSTR text)
 Set the text for this gadget.
 
void SetText (const tstring &text)
 
TColor GetBkgndColor () const
 Returns the background color for the gadget.
 
TColor GetTextColor () const
 Returns the text color for the gadget.
 
void SetBkgndColor (const TColor &color)
 Sets the background color for the gadget.
 
void SetTextColor (const TColor &color)
 Sets the text color for the gadget when enabled.
 
void ResetBkgndColor ()
 Resets the background color of the gadget to the default TColor::Sys3dFace.
 
void ResetTextColor ()
 Resets the text color of the gadget to the default TColor::SysBtnText.
 
- Public Member Functions inherited from owl::TGadget
 TGadget (int id=0, TBorderStyle borderStyle=None)
 Construct a gadget with a given id and border style.
 
virtual ~TGadget ()
 Destroys a TGadget interface object and removes it from its associated window.
 
int GetId () const
 Gets the ID for the gadget.
 
TRectGetBounds ()
 Returns the boundary rectangle for the gadget.
 
const TRectGetBounds () const
 Returns the boundary rectangle for the gadget.
 
virtual void SetEnabled (bool enabled)
 Enables or disables keyboard and mouse input for the gadget.
 
bool GetEnabled () const
 Determines whether keyboard and mouse input have been enabled for the specified gadget.
 
virtual void SetVisible (bool visible)
 Changes the visibility of the gadget.
 
bool IsVisible () const
 Returns true if the gadget is visible.
 
bool IsWindowVisible () const
 check to see if the button's created
 
void SetEndOfRow (bool eor)
 Sets the end of row property for the gadget.
 
bool IsEndOfRow () const
 Returns true if this gadget is at the end of a row.
 
bool IsWideAsPossible () const
 Indicates whether the gadget width will be adjusted by the gadget window to be as wide as possible in the remaining space.
 
void SetWideAsPossible (bool wide=true)
 Sets the flag that indicates whether the gadget width will be adjusted by the gadget window to be as wide as possible in the remaining space.
 
void SetShrinkWrap (bool shrinkWrapWidth, bool shrinkWrapHeight)
 Simple set accessor to set whether shrinkwrapping is performed horizontally and/or vertically.
 
void SetSize (const TSize &size)
 Alters the size of the gadget and then calls TGadgetWindow::GadgetChangedSize() for the size change to take effect.
 
void GetOuterSizes (int &left, int &right, int &top, int &bottom)
 Get the four total outer sizes in pixels which consists of the margins plus the borders.
 
void GetInnerRect (TRect &rect)
 Computes the area of the gadget's rectangle excluding the borders and margins.
 
virtual void SetBounds (const TRect &rect)
 Called by the gadget window to inform the gadget of a change in its bounding rectangle.
 
virtual bool IdleAction (long idleCount)
 Called during idle time to allow the gadget to perform any idle actions.
 
virtual void CommandEnable ()
 Provided so that the gadget can perform command enabling (so it can handle an incoming message if it's appropriate to do so).
 
virtual void SysColorChange ()
 Called when the system colors have been changed so that gadgets can rebuild and repaint, if necessary.
 
TGadgetNextGadget ()
 Returns the next gadget in the list of gadgets.
 
void SetBorders (const TBorders &borders)
 Sets the borders for the gadget.
 
TBordersGetBorders ()
 Gets the gadget's borders measured in border units that are based on SM_CXBORDER and SM_CYBORDER.
 
void SetMargins (const TMargins &margins)
 Sets the margins of the gadget.
 
TMarginsGetMargins ()
 Gets the margin dimensions.
 
void SetBorderStyle (TBorderStyle bs)
 Set the border style used by this gadget.
 
TBorderStyle GetBorderStyle () const
 Gets the style for the gadget's borders.
 

Protected Member Functions

void Paint (TDC &dc)
 Paint the text gadget by painting gadget borders, & then painting text in the InnerRect.
 
virtual TColor GetEnabledColor () const
 
void GetDesiredSize (TSize &size)
 Respond to the virtual call to let this gadget's Window know how big this text gadget wants to be based on the text size.
 
void Invalidate ()
 Invalidate the working portion of this gadget–in this case just the InnerRect.
 
- Protected Member Functions inherited from owl::TGadget
TGadgetWindowGetGadgetWindow ()
 Return a pointer to the owning or parent window for the gadget.
 
const TGadgetWindowGetGadgetWindow () const
 Return a pointer to the owning or parent window for the gadget.
 
virtual void Created ()
 This is the virtual called after the window holding a gadget has been created.
 
virtual void Inserted ()
 Called after a gadget is inserted into a window.
 
virtual void Moved ()
 This is the virtual called when a gadget is relocated.
 
virtual void Removed ()
 Virtual called after a gadget is removed from a window.
 
bool IsHaveMouse () const
 Return true if mouse inside gadget.
 
void SetInMouse (bool state)
 Sets if mouse inside gadget or not.
 
bool GetTrackMouse () const
 
void SetTrackMouse (bool track)
 
void Invalidate (bool erase=true)
 Used to invalidate the active (usually nonborder) portion of the gadget, Invalidate calls InvalidateRect and passes the boundary width and height of the area to erase.
 
void InvalidateRect (const TRect &rect, bool erase=true)
 Invalidate a rectangle in our containing window.
 
void Update ()
 Paint now if possible.
 
virtual bool PtIn (const TPoint &point)
 Default behavior returns true if the point is within the receiver's bounding rect.
 
virtual void PaintBorder (TDC &dc)
 Self sent by method Paint().
 
virtual void MouseEnter (uint modKeys, const TPoint &point)
 Mouse is entering this gadget.
 
virtual void MouseMove (uint modKeys, const TPoint &point)
 Mouse is moving over this gadget.
 
virtual void MouseLeave (uint modKeys, const TPoint &point)
 Mouse is leaving this gadget.
 
virtual void LButtonDown (uint modKeys, const TPoint &point)
 Captures the mouse if TrackMouse is set.
 
virtual void RButtonDown (uint modKeys, const TPoint &point)
 
virtual void LButtonUp (uint modKeys, const TPoint &point)
 Releases the mouse capture if TrackMouse is set.
 
virtual void RButtonUp (uint modKeys, const TPoint &point)
 
void ChangeBorderStyle (TBorderStyle bs)
 Simply changes the border style without recalculating the gadget size.
 

Detailed Description

Derived from TGadget, TTextGadget is a text gadget object.

When constructing the text gadget specify how many characters you want room for and how the text should be aligned horizontally.

The inner bounds are computed by multiplying the number of characters by the maximum character width.

Definition at line 37 of file textgadg.h.

Member Enumeration Documentation

◆ TAlign

Enumerates the text-alignment attributes.

Enumerator
Left 

Aligns the text at the left edge of the bounding rectangle.

Center 

Aligns the text horizontally at the center of the bounding rectangle.

Right 

Aligns the text at the right edge of the bounding rectangle.

Definition at line 41 of file textgadg.h.

Constructor & Destructor Documentation

◆ TTextGadget() [1/2]

owl::TTextGadget::TTextGadget ( int id = 0,
TBorderStyle borderStyle = Recessed,
TAlign align = Left,
uint numChars = 10,
LPCTSTR text = 0,
TFont * font = 0 )

Constructs a TTextGadget object with the specified ID, border style, and alignment.

Sets Margins.Left and Margins.Right to 2. Sets Text and TextLen to 0. Unless a font is passed (or a null-pointer is passed) the gadget will use the font of the containing gadget window.

Definition at line 25 of file textgadg.cpp.

References owl::TUIMetric::CxFixedFrame, ResetBkgndColor(), ResetTextColor(), owl::TGadget::SetShrinkWrap(), and SetText().

◆ TTextGadget() [2/2]

owl::TTextGadget::TTextGadget ( int id,
TBorderStyle borderStyle,
TAlign align,
uint numChars,
const tstring & text,
TFont * font = 0 )

String-aware overload.

Definition at line 51 of file textgadg.cpp.

References owl::TUIMetric::CxFixedFrame, ResetBkgndColor(), ResetTextColor(), owl::TGadget::SetShrinkWrap(), and SetText().

◆ ~TTextGadget()

owl::TTextGadget::~TTextGadget ( )

Destruct this text gadget and delete the text it is holding.

Definition at line 78 of file textgadg.cpp.

Member Function Documentation

◆ GetBkgndColor()

TColor owl::TTextGadget::GetBkgndColor ( ) const
inline

Returns the background color for the gadget.

Definition at line 155 of file textgadg.h.

◆ GetDesiredSize()

void owl::TTextGadget::GetDesiredSize ( TSize & size)
protectedvirtual

Respond to the virtual call to let this gadget's Window know how big this text gadget wants to be based on the text size.

If shrink-wrapping is requested, GetDesiredSize returns the size needed to accommodate the borders, margins, and text; otherwise, if shrink-wrapping is not requested, it returns the gadget's current width and height.

Reimplemented from owl::TGadget.

Definition at line 166 of file textgadg.cpp.

References owl::TGadget::GetDesiredSize(), GetFont(), owl::TFont::GetHeight(), owl::TFont::GetMaxWidth(), owl::TGadget::GetOuterSizes(), and owl::TFont::GetTextExtent().

◆ GetEnabledColor()

TColor owl::TTextGadget::GetEnabledColor ( ) const
inlineprotectedvirtual

Reimplemented in owl::TMenuGadget.

Definition at line 148 of file textgadg.h.

◆ GetFont()

const TFont & owl::TTextGadget::GetFont ( ) const

Returns the effective font used to render the text for this gadget.

If no font was passed to the constructor, the font of the gadget window is returned.

Definition at line 105 of file textgadg.cpp.

References owl::TGadgetWindow::GetFont(), owl::TGadget::GetGadgetWindow(), and PRECONDITION.

◆ GetText()

LPCTSTR owl::TTextGadget::GetText ( ) const
inline

Returns the text for the gadget.

Definition at line 144 of file textgadg.h.

◆ GetTextColor()

TColor owl::TTextGadget::GetTextColor ( ) const
inline

Returns the text color for the gadget.

Definition at line 163 of file textgadg.h.

◆ Invalidate()

void owl::TTextGadget::Invalidate ( )
protected

Invalidate the working portion of this gadget–in this case just the InnerRect.

Calls TGadget::GetInnerRect to compute the area of the text for the gadget and then TGadget::InvalidateRect to invalidate the rectangle in the parent window.

Definition at line 91 of file textgadg.cpp.

References owl::TGadgetWindow::FlatXPTheme, owl::TGadgetWindow::GetFlatStyle(), owl::TGadget::GetGadgetWindow(), owl::TGadget::GetInnerRect(), and owl::TGadget::InvalidateRect().

◆ Paint()

void owl::TTextGadget::Paint ( TDC & dc)
protectedvirtual

Paint the text gadget by painting gadget borders, & then painting text in the InnerRect.

Empty or 0 text blanks the gadget. Calls TGadget::PaintBorder to paint the border. Calls TGadget::GetInnerRect to calculate the area of the text gadget's rectangle. If the text is left-aligned, Paint calls dc.GetTextExtent to compute the width and height of a line of the text. To set the background color, Paint calls dc.GetSysColor and sets the default background color to face shading (COLOR_BTNFACE). To set the button text color, Paint calls dc.SetTextColor and sets the default button text color to COLOR_BTNTEXT. To draw the text, Paint calls dc.ExtTextOut and passes the parameters ETO_CLIPPED (so the text is clipped to fit the rectangle) and ETO_OPAQUE (so the rectangle is filled with the current background color).

Reimplemented from owl::TGadget.

Definition at line 200 of file textgadg.cpp.

References owl::TUIFace::Disabled, owl::TGadgetWindow::FlatXPTheme, owl::TGadget::GetEnabled(), GetEnabledColor(), owl::TGadgetWindow::GetFlatStyle(), GetFont(), owl::TGadget::GetGadgetWindow(), owl::TGadget::GetInnerRect(), owl::TUIFace::Normal, owl::TGadget::PaintBorder(), owl::TDC::RestoreFont(), owl::TDC::SelectObject(), owl::TDC::SetBkColor(), owl::TDC::SetTextColor(), owl::TColor::Sys3dFace, owl::TColor::Sys3dHilight, and owl::TDC::TextRect().

◆ ResetBkgndColor()

void owl::TTextGadget::ResetBkgndColor ( )

Resets the background color of the gadget to the default TColor::Sys3dFace.

Definition at line 247 of file textgadg.cpp.

References owl::TColor::Sys3dFace.

◆ ResetTextColor()

void owl::TTextGadget::ResetTextColor ( )

Resets the text color of the gadget to the default TColor::SysBtnText.

Definition at line 255 of file textgadg.cpp.

References owl::TColor::SysBtnText.

◆ SetBkgndColor()

void owl::TTextGadget::SetBkgndColor ( const TColor & color)
inline

Sets the background color for the gadget.

Definition at line 171 of file textgadg.h.

◆ SetFont()

void owl::TTextGadget::SetFont ( const TFont & font,
bool repaint = true )

Sets the font to be used by the gadget.

If repaint is true, calls TGadgetWindow::GadgetChangedSize to recalculate the size of the gadget.

Definition at line 116 of file textgadg.cpp.

References owl::TGadgetWindow::GadgetChangedSize(), and owl::TGadget::GetGadgetWindow().

◆ SetText() [1/2]

void owl::TTextGadget::SetText ( const tstring & text)
inline

Definition at line 72 of file textgadg.h.

References SetText().

◆ SetText() [2/2]

void owl::TTextGadget::SetText ( LPCTSTR text)

Set the text for this gadget.

If the text stored in Text is not the same as the new text, SetText deletes the text stored in Text. Then, it sets TextLen to the length of the new string. If no text exists, it sets both Text and TextLen to 0 and then calls Invalidate to invalidate the rectangle.

Definition at line 133 of file textgadg.cpp.

References _tcscmp, _tcslen, owl::TGadgetWindow::GadgetChangedSize(), owl::TGadget::GetGadgetWindow(), Invalidate(), and strnewdup().

◆ SetTextColor()

void owl::TTextGadget::SetTextColor ( const TColor & color)
inline

Sets the text color for the gadget when enabled.

Definition at line 179 of file textgadg.h.


The documentation for this class was generated from the following files: