OWLNext 7.0
Borland's Object Windows Library for the modern age
|
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>
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 TFont & | GetFont () 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. | |
TRect & | GetBounds () |
Returns the boundary rectangle for the gadget. | |
const TRect & | GetBounds () 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. | |
TGadget * | NextGadget () |
Returns the next gadget in the list of gadgets. | |
void | SetBorders (const TBorders &borders) |
Sets the borders for the gadget. | |
TBorders & | GetBorders () |
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. | |
TMargins & | GetMargins () |
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 TDib * | GetGlyphDib () |
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. | |
TCelArray * | GetCelArray () |
Returns the CelArray used to cache glyph states. | |
const TCelArray * | GetCelArray () const |
Returns the CelArray used to cache glyph states. | |
TPoint & | GetBitmapOrigin () |
Returns the x and y coordinates of the bitmap used for this button gadget. | |
const TPoint & | GetBitmapOrigin () 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 | |
TGadgetWindow * | GetGadgetWindow () |
Return a pointer to the owning or parent window for the gadget. | |
const TGadgetWindow * | GetGadgetWindow () 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... | |
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.
Enumerates the text-alignment attributes.
Definition at line 51 of file btntextg.h.
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 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.
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.
|
virtual |
Destroys a TButtonTextGadget object.
Definition at line 121 of file btntextg.cpp.
|
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.
|
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.
|
inline |
Returns the Align for the gadget.
Definition at line 169 of file btntextg.h.
Calls TButtonGadget::GetDesiredSize if (Style & sBitmap); calls TGadget::GetDesiredSize and adds the size of the text region.
Reimplemented from owl::TButtonGadget.
Reimplemented in owl::TPopupButtonGadget.
Definition at line 303 of file btntextg.cpp.
References _T, owl::TGadget::GetDesiredSize(), owl::TButtonGadget::GetDesiredSize(), GetTextSize(), lTextBottom, lTextLeft, lTextRight, lTextTop, PRECONDITION, sBitmap, sText, owl::TextSpaceH, owl::TextSpaceV, and TRACEX.
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.
|
inline |
Returns the LayoutStyle for the gadget.
Definition at line 176 of file btntextg.h.
|
inline |
Returns the Style for the gadget.
Definition at line 155 of file btntextg.h.
|
inline |
Returns the text for the gadget.
Definition at line 162 of file btntextg.h.
Definition at line 291 of file btntextg.cpp.
References GetFont(), and owl::TFont::GetTextMetrics().
|
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.
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.
|
protectedvirtual |
Paint Text.
Definition at line 453 of file btntextg.cpp.
References aCenter, aLeft, aRight, owl::TUIFace::Disabled, owl::TButtonGadget::Down, owl::TUIFace::Down, owl::TGadgetWindow::FlatHotText, owl::TGadgetWindow::FlatStandard, owl::TButtonGadget::GetButtonState(), owl::TGadget::GetEnabled(), GetFont(), owl::TGadget::GetGadgetWindow(), owl::TUIFace::Indeterm, owl::TButtonGadget::Indeterminate, owl::TGadget::IsHaveMouse(), owl::TButtonGadget::IsPressed(), owl::TColor::LtBlue, lTextBottom, lTextLeft, lTextRight, lTextTop, owl::TUIFace::Normal, owl::TUIFace::Paint(), owl::TDC::RestoreFont(), owl::TDC::SelectObject(), owl::TDC::SetTextColor(), owl::TColor::Sys3dFace, owl::TColor::Sys3dHilight, and owl::TColor::SysBtnText.
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().
If (Style & sBitmap) calls TButtonGadget::SetBounds; otherwise calls TGadget::SetBounds to set the boundary of the rectangle, and it (Style & sBitmap) calculates new BitmapOrigin.
Reimplemented from owl::TButtonGadget.
Reimplemented in owl::TPopupButtonGadget.
Definition at line 344 of file btntextg.cpp.
References owl::TCelArray::CelSize(), owl::TButtonGadget::GetCelArray(), owl::TGadgetWindow::GetCelArray(), owl::TGadget::GetGadgetWindow(), owl::TGadget::GetInnerRect(), Layout(), PRECONDITION, sBitmap, owl::TButtonGadget::SetBitmapOrigin(), owl::TButtonGadget::SetBounds(), owl::TGadget::SetBounds(), and sText.
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().
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().
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().
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.
Definition at line 93 of file btntextg.h.
References SetText().
|
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().