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

Derived from TButtonGadget, TButtonTextGadget represents buttons with bitmap and text, or with text only, or with bitmap only, that you can click on or off. More...

#include <owl/btntextg.h>

Inheritance diagram for owl::TButtonTextGadget:
owl::TButtonGadget owl::TGadget owl::TPopupButtonGadget owl::TPickerGadget owl::TPopupMenuGadget owl::TBitmapPickerGadget owl::TColorPickerGadget

Public Types

enum  TAlign { aLeft , aCenter , aRight }
 Enumerates the text-alignment attributes. More...
 
enum  TStyle { sBitmap =0x001 , sText =0x002 , sBitmapText =0x003 }
 TStyle contains values that defines how gadget will be displayed: More...
 
enum  TLayoutStyle { lTextLeft , lTextTop , lTextRight , lTextBottom }
 TLayoutStyle contains values that defines how bitmap and text will be layout. More...
 
- Public Types inherited from owl::TButtonGadget
enum  TType { Command , Exclusive , NonExclusive , SemiExclusive , RepeatCmd }
 Enumerates the types of button gadgets. More...
 
enum  TState { Up , Down , Indeterminate }
 TState enumerates the three button positions during which the button can be pressed: up (0), down (1), and an indeterminate state (2). 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

 TButtonTextGadget (int id, TResId glyphResIdOrIndex, TStyle style=sBitmapText, TType type=Command, bool enabled=false, TState state=Up, bool sharedGlyph=false, uint numChars=4)
 Constructs a TButtonTextGadget object using the specified bitmap ID, button gadget ID, style, and type, with enabled set to false, in a button-up state, and reserved number chars in text = 4.
 
virtual ~TButtonTextGadget ()
 Destroys a TButtonTextGadget object.
 
LPCTSTR GetText () const
 Returns the text for the gadget.
 
void SetText (const tstring &text, bool repaint=true)
 Sets the text of the gadget.
 
void SetText (LPCTSTR s, bool repaint=true)
 
TStyle GetStyle () const
 Returns the Style for the gadget.
 
void SetStyle (const TStyle style, bool repaint=true)
 If the style stored in Style is not the same as the new style, SetStyle sets Style to the new style, and then if repaint is true calls Window->GadgetChangedSize(*this) to recalculate size of gadget.
 
TAlign GetAlign () const
 Returns the Align for the gadget.
 
void SetAlign (const TAlign align, bool repaint=true)
 If the align stored in Style is not the same as the new align, SetAlign sets Align to the new align, and then if repaint is true calls Invalidate to invalidate the rectangle.
 
TLayoutStyle GetLayoutStyle () const
 Returns the LayoutStyle for the gadget.
 
void SetLayoutStyle (const TLayoutStyle style, bool repaint=true)
 If the style stored in LayoutStyle is not the same as the new style, SetLayoutStyle sets LayoutStyle to the new style, and then if repaint is true calls Window->GadgetChangedSize(*this) to recalculate size of gadget.
 
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.
 
virtual void GetDesiredSize (TSize &size)
 Calls TButtonGadget::GetDesiredSize if (Style & sBitmap); calls TGadget::GetDesiredSize and adds the size of the text region.
 
virtual void SetBounds (const TRect &rect)
 If (Style & sBitmap) calls TButtonGadget::SetBounds; otherwise calls TGadget::SetBounds to set the boundary of the rectangle, and it (Style & sBitmap) calculates new BitmapOrigin.
 
virtual void CommandEnable ()
 Initiates a command enable for this button gadget.
 
- Public Member Functions inherited from owl::TButtonGadget
 TButtonGadget (TResId glyphResIdOrIndex, int id, TType type=Command, bool enabled=false, TState state=Up, bool sharedGlyph=false)
 Construct a button gadget that loads its own bitmap resource.
 
 ~TButtonGadget () override
 Destruct this button gadget, freeing up allocated resources.
 
void SetButtonState (TState newState)
 Set the state of a button.
 
TState GetButtonState () const
 Returns the state of the button.
 
TType GetButtonType () const
 Return the type of the button.
 
bool GetNotchCorners () const
 Returns true if the button has rounded corners.
 
void SetNotchCorners (bool notchCorners=true)
 By default, SetNotchCorners implements notched corners for buttons.
 
bool GetAntialiasEdges () const
 Return the current shadow style of the button.
 
void SetAntialiasEdges (bool anti=true)
 Turns the antialiasing of the button bevels on or off.
 
- 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 bool IdleAction (long idleCount)
 Called during idle time to allow the gadget to perform any idle actions.
 
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

virtual void Paint (TDC &dc)
 Calls TGadget::PaintBorder to perform the actual painting of the border of the control.
 
virtual void Created ()
 Calls TButtonGadget::Created and if Text == 0 and (Style & sText) retrieves text from menu or resource.
 
virtual void Layout (TRect &srcRect, TRect &textRect, TRect &btnRect)
 Layout button and text in the control area.
 
virtual void PaintText (TDC &dc, TRect &rect, const tstring &text)
 Paint Text.
 
virtual void SysColorChange ()
 Respond to a WM_SYSCOLORCHANGE, in this case to rebuild the CelArray with possibly new 3d colors.
 
void GetTextSize (TSize &size)
 
- Protected Member Functions inherited from owl::TButtonGadget
void PaintBorder (TDC &dc) override
 
void MouseEnter (uint modKeys, const TPoint &p) override
 Mouse has entered this button, (not pressed).
 
void MouseMove (uint modKeys, const TPoint &p) override
 Mouse has moved (back) into this gadget.
 
void MouseLeave (uint modKeys, const TPoint &p) override
 Mouse has left this button, (not pressed).
 
void LButtonDown (uint modKeys, const TPoint &p) override
 Overrides TGadget member function and responds to a left mouse button click by calling BeginPressed.
 
void LButtonUp (uint modKeys, const TPoint &p) override
 Handle the mouse left button up & leave the pressed state.
 
virtual void PaintFace (TDC &dc, const TRect &rect)
 Paints the face of the button.
 
virtual TDibGetGlyphDib ()
 Virtual function responsible for supplying the dib for the glyph.
 
virtual void ReleaseGlyphDib (TDib *glyph)
 Virtual function responsible for releasing glyph dib as needed based on how GetGlyphDib() got it (if different from new/delete).
 
virtual void BuildCelArray ()
 Build the CelArray member using the resource bitmap as the base glyph CelArray may contain an existing cel array that should be deleted if replaced.
 
virtual void BeginPressed (const TPoint &p)
 Begin button pressed state, repaint & enter menuselect state.
 
virtual void CancelPressed (const TPoint &p, bool mstate=false)
 Cancel pressed state, repaint & end menuselect state.
 
virtual void Activate (const TPoint &p)
 The action method called on a completed 'click', generates WM_COMMAND.
 
void SetButtonType (TType newType)
 Sets the type of the button.
 
void SetGlyphIndex (int index)
 
bool IsPressed () const
 Returns true if the button is pushed or false if it is released.
 
void CheckExclusively ()
 Perform an exclusive checking of this gadget by unchecking the neighboring exclusive button gadgets.
 
TResId GetResId () const
 Returns the resource ID for this button gadget's bitmap.
 
TCelArrayGetCelArray ()
 Returns the CelArray used to cache glyph states.
 
const TCelArrayGetCelArray () const
 Returns the CelArray used to cache glyph states.
 
TPointGetBitmapOrigin ()
 Returns the x and y coordinates of the bitmap used for this button gadget.
 
const TPointGetBitmapOrigin () const
 Returns the x and y coordinates of the bitmap used for this button gadget.
 
void SetBitmapOrigin (const TPoint &bitmapOrigin)
 Sets the x and y coordinates of the bitmap used for this button gadget.
 
- 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 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 RButtonDown (uint modKeys, const TPoint &point)
 
virtual void RButtonUp (uint modKeys, const TPoint &point)
 
void ChangeBorderStyle (TBorderStyle bs)
 Simply changes the border style without recalculating the gadget size.
 

Additional Inherited Members

- Protected Types inherited from owl::TButtonGadget
enum  { CelNormal , CelDisabled , CelIndeterm , CelDown , CelPressed , CelsTotal }
 Glyph types and construction functions. More...
 

Detailed Description

Derived from TButtonGadget, TButtonTextGadget represents buttons with bitmap and text, or with text only, or with bitmap only, that you can click on or off.

You can also apply attributes such as color, style, and shape (notched or unnotched) to your button-text gadgets.

In addition to TButtonGadget, TButtonTextGadget has several types to deal with text:

  • TAlign Defines alignment for text (aLeft, aCenter, aRight),
  • TStyle Defines style of gadget (sBitmap, sText, sBitmapText).
  • TLayoutStyle Defines Layout Bitmap with text(lTextLeft,lTextTop,lTextRight,lTextBottom).

Definition at line 44 of file btntextg.h.

Member Enumeration Documentation

◆ TAlign

Enumerates the text-alignment attributes.

Enumerator
aLeft 

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

aCenter 

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

aRight 

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

Definition at line 51 of file btntextg.h.

◆ TLayoutStyle

TLayoutStyle contains values that defines how bitmap and text will be layout.

Enumerator
lTextLeft 

Text left, bitmap right.

lTextTop 

Text top, bitmap bottom.

lTextRight 

Text right, bitmap left.

lTextBottom 

Text bottom, bitmap top.

Definition at line 71 of file btntextg.h.

◆ TStyle

TStyle contains values that defines how gadget will be displayed:

Enumerator
sBitmap 

Only the bitmap is displayed.

sText 

Only text is displayed.

sBitmapText 

Both text and bitmap are displayed.

Definition at line 61 of file btntextg.h.

Constructor & Destructor Documentation

◆ TButtonTextGadget()

owl::TButtonTextGadget::TButtonTextGadget ( int id,
TResId glyphResIdOrIndex,
TStyle style = sBitmapText,
TType type = Command,
bool enabled = false,
TState state = Up,
bool sharedGlyph = false,
uint numChars = 4 )

Constructs a TButtonTextGadget object using the specified bitmap ID, button gadget ID, style, and type, with enabled set to false, in a button-up state, and reserved number chars in text = 4.

The button isn't enabled - its initial state before command enabling occurs.

Definition at line 103 of file btntextg.cpp.

◆ ~TButtonTextGadget()

owl::TButtonTextGadget::~TButtonTextGadget ( )
virtual

Destroys a TButtonTextGadget object.

Definition at line 121 of file btntextg.cpp.

Member Function Documentation

◆ CommandEnable()

void owl::TButtonTextGadget::CommandEnable ( )
virtual

Initiates a command enable for this button gadget.

Enables the button-text gadget to capture messages. Calls SendMessage to send a WM_COMMAND_ENABLE message to the gadget window's parent, passing a TCommandEnable:EvCommandEnable message for this button.

Reimplemented from owl::TButtonGadget.

Definition at line 133 of file btntextg.cpp.

References owl::TGadget::GetGadgetWindow(), owl::TWindow::HandleMessage(), PRECONDITION, and WM_COMMAND_ENABLE.

◆ Created()

void owl::TButtonTextGadget::Created ( )
protectedvirtual

Calls TButtonGadget::Created and if Text == 0 and (Style & sText) retrieves text from menu or resource.

Virtual called after the window holding a gadget has been created

Reimplemented from owl::TGadget.

Reimplemented in owl::TPickerGadget.

Definition at line 255 of file btntextg.cpp.

References _T, owl::TGadget::Created(), owl::TGadget::Invalidate(), PRECONDITION, SetText(), and sText.

◆ GetAlign()

TButtonTextGadget::TAlign owl::TButtonTextGadget::GetAlign ( ) const
inline

Returns the Align for the gadget.

Definition at line 169 of file btntextg.h.

◆ GetDesiredSize()

void owl::TButtonTextGadget::GetDesiredSize ( TSize & size)
virtual

◆ GetFont()

const TFont & owl::TButtonTextGadget::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 183 of file btntextg.cpp.

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

◆ GetLayoutStyle()

TButtonTextGadget::TLayoutStyle owl::TButtonTextGadget::GetLayoutStyle ( ) const
inline

Returns the LayoutStyle for the gadget.

Definition at line 176 of file btntextg.h.

◆ GetStyle()

TButtonTextGadget::TStyle owl::TButtonTextGadget::GetStyle ( ) const
inline

Returns the Style for the gadget.

Definition at line 155 of file btntextg.h.

◆ GetText()

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

Returns the text for the gadget.

Definition at line 162 of file btntextg.h.

◆ GetTextSize()

void owl::TButtonTextGadget::GetTextSize ( TSize & size)
protected

Definition at line 291 of file btntextg.cpp.

References GetFont(), and owl::TFont::GetTextMetrics().

◆ Layout()

void owl::TButtonTextGadget::Layout ( TRect & srcRect,
TRect & textRect,
TRect & btnRect )
protectedvirtual

Layout button and text in the control area.

Definition at line 394 of file btntextg.cpp.

References owl::TButtonGadget::GetDesiredSize(), GetTextSize(), lTextBottom, lTextLeft, lTextRight, lTextTop, sBitmap, sText, owl::TextSpaceH, and owl::TextSpaceV.

◆ Paint()

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

Calls TGadget::PaintBorder to perform the actual painting of the border of the control.

Get Inner rectangle of control, layout Text and Bitmap and call PaintText() and PaintFace().

Reimplemented from owl::TButtonGadget.

Reimplemented in owl::TPopupButtonGadget.

Definition at line 373 of file btntextg.cpp.

References owl::TGadget::GetInnerRect(), Layout(), owl::TButtonGadget::PaintBorder(), owl::TButtonGadget::PaintFace(), PaintText(), PRECONDITION, sBitmap, and sText.

◆ PaintText()

◆ SetAlign()

void owl::TButtonTextGadget::SetAlign ( const TAlign align,
bool repaint = true )

If the align stored in Style is not the same as the new align, SetAlign sets Align to the new align, and then if repaint is true calls Invalidate to invalidate the rectangle.

Definition at line 223 of file btntextg.cpp.

References owl::TGadget::Invalidate().

◆ SetBounds()

void owl::TButtonTextGadget::SetBounds ( const TRect & rect)
virtual

◆ SetFont()

void owl::TButtonTextGadget::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 194 of file btntextg.cpp.

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

◆ SetLayoutStyle()

void owl::TButtonTextGadget::SetLayoutStyle ( const TLayoutStyle style,
bool repaint = true )

If the style stored in LayoutStyle is not the same as the new style, SetLayoutStyle sets LayoutStyle to the new style, and then if repaint is true calls Window->GadgetChangedSize(*this) to recalculate size of gadget.

Definition at line 238 of file btntextg.cpp.

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

◆ SetStyle()

void owl::TButtonTextGadget::SetStyle ( const TStyle style,
bool repaint = true )

If the style stored in Style is not the same as the new style, SetStyle sets Style to the new style, and then if repaint is true calls Window->GadgetChangedSize(*this) to recalculate size of gadget.

Definition at line 208 of file btntextg.cpp.

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

◆ SetText() [1/2]

void owl::TButtonTextGadget::SetText ( const tstring & text,
bool repaint = true )

Sets the text of the gadget.

If the given text is blank, then we attempt to load the text from the menu or tooltip.

Definition at line 153 of file btntextg.cpp.

References CHECK, owl::TGadgetWindow::GadgetChangedSize(), owl::TGadget::GetGadgetWindow(), owl::TDecoratedFrame::GetHintText(), owl::TWindow::GetParentO(), owl::TButtonGadget::GetResId(), owl::htTooltip, owl::TGadget::Invalidate(), and sText.

◆ SetText() [2/2]

void owl::TButtonTextGadget::SetText ( LPCTSTR s,
bool repaint = true )
inline

Definition at line 93 of file btntextg.h.

References SetText().

◆ SysColorChange()

void owl::TButtonTextGadget::SysColorChange ( )
protectedvirtual

Respond to a WM_SYSCOLORCHANGE, in this case to rebuild the CelArray with possibly new 3d colors.

SysColorChange responds to an EvSysColorChange message forwarded by the owning TGadgetWindow by setting the dither brush to zero. If a style is Bitmap it forwards the message to TButtonGadget, otherwise to TGadget.

Reimplemented from owl::TButtonGadget.

Definition at line 280 of file btntextg.cpp.

References sBitmap, owl::TGadget::SysColorChange(), and owl::TButtonGadget::SysColorChange().


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