OWLNext 7.0
Borland's Object Windows Library for the modern age
|
TGadget is the base class for the following derived gadget classes: More...
#include <owl/gadget.h>
Classes | |
struct | TBorders |
Border dimensions. More... | |
Public Types | |
enum | TBorderStyle { None , Plain , Raised , Recessed , Embossed , Grooved , ButtonUp , ButtonDn , WndRaised , WndRecessed , WellSet } |
Gadget border styles. More... | |
Public Member Functions | |
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. | |
virtual void | GetDesiredSize (TSize &size) |
Request by the gadget window to query the gadget's desired size. | |
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. | |
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 | |
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 | 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 | Paint (TDC &dc) |
Calls PaintBorder() to paint the indicated device context. | |
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. | |
Friends | |
class | TGadgetList |
class | TGadgetWindow |
TGadget is the base class for the following derived gadget classes:
TBitmapGadget Displays
a bitmapTButtonGadget Uses
a bitmap to simulate a button gadgetTButtonTextGadget Derived
from TButtonGadget and adds displays optionally text or bitmap or both.TControlGadget Encapsulates
inserting a control such as an edit control or a combobox, into a gadget window.TFlatHandleGadget Uses
by TControlBar/TDockableControlBar to simulate FlatGrip when FlatState enabled.TMenuGadget Displays
ppopup menuTPopupButtonGadget Derived
from TButtonTextGadget and adds button for popup actionsTPopupMenuGadget Derived
from TPopupButtonGadget and show popup menuTTextGadget Displays
textTSeparatorGadget Separates
logical groups of gadgets.TSizeGripGadget Used
on the far right of a status bar to provide re-sizing grip for the host window.TGadget interface objects belong to a gadget window, have borders and margins, and have their own coordinate system. The margins are the same as those for TGadgetWindow and borders are always measured in border units.
To set the attributes for the gadget, you can either choose a border style (which automatically sets the individual border edges) or set the borders and then override the member function PaintBorder to create a custom look for your gadget. If you change the borders, margins, or border style, the gadget window's GadgetChangedSize member function is invoked.
Although, by default, gadgets shrink-wrap to fit around their contents, you can control this attribute by setting your own values for ShrinkWrapWidth and ShrinkWrapHeight.
A gadget window, being an actual window, receives messages from the mouse. After the gadget window receives the message, it decides which gadget should receive the message by calling the member function directly instead of sending or posting a message.
Typically you would either choose a border style (which automatically sets the individual border edges) or set the borders and then override member function PaintBorder() to create a custom look
Gadget border styles.
These match TIUBorder's TStyles exactly. For an example of border styles, see the sample ObjectWindows program, MDIFILE.CPP, on BC5.x distribution disk. Border Style Constants
owl::TGadget::TGadget | ( | int | id = 0, |
TBorderStyle | borderStyle = None ) |
Construct a gadget with a given id and border style.
Used by derived classes.
Definition at line 88 of file gadget.cpp.
References SetBorderStyle().
|
virtual |
Destroys a TGadget interface object and removes it from its associated window.
Definition at line 107 of file gadget.cpp.
References owl::TGadgetWindow::Remove().
|
inlineprotected |
|
virtual |
Provided so that the gadget can perform command enabling (so it can handle an incoming message if it's appropriate to do so).
Reimplemented in owl::TDynamicBitmapGadget, owl::TButtonTextGadget, owl::TDynamicTextGadget, and owl::TButtonGadget.
Definition at line 132 of file gadget.cpp.
|
protectedvirtual |
This is the virtual called after the window holding a gadget has been created.
Reimplemented in owl::TButtonTextGadget, owl::TPickerGadget, owl::TTimeGadget, and owl::TControlGadget.
Definition at line 300 of file gadget.cpp.
References owl::TWindow::GetHandle(), owl::TGadgetWindow::GetTooltip(), and PRECONDITION.
|
inline |
|
inline |
|
inline |
|
inline |
Request by the gadget window to query the gadget's desired size.
Determines how big the gadget can be. The gadget window sends this message to query the gadget's size. If shrink-wrapping is requested, GetDesiredSize returns the size needed to accommodate the borders and margins. If shrink-wrapping is not requested, it returns the gadget's current width and height. TGadgetWindow needs this information to determine how big the gadget needs to be, but it can adjust these dimensions if necessary. If WideAsPossible is true, then the width parameter (size.cx) is ignored.
Reimplemented in owl::TControlGadget, owl::TBitmapGadget, owl::TButtonTextGadget, owl::TFlatHandleGadget, owl::TMenuGadget, owl::TTextGadget, owl::TButtonGadget, and owl::TPopupButtonGadget.
Definition at line 479 of file gadget.cpp.
References GetOuterSizes(), owl::TRect::Height(), and owl::TRect::Width().
|
inline |
|
inlineprotected |
|
inlineprotected |
|
inline |
Computes the area of the gadget's rectangle excluding the borders and margins.
Definition at line 514 of file gadget.cpp.
References GetOuterSizes(), owl::TRect::Height(), and owl::TRect::Width().
|
inline |
Get the four total outer sizes in pixels which consists of the margins plus the borders.
Definition at line 496 of file gadget.cpp.
References owl::TGadget::TBorders::Bottom, owl::TUIMetric::CxBorder, owl::TUIMetric::CyBorder, owl::TGadgetWindow::GetMargins(), owl::TGadget::TBorders::Left, owl::TGadget::TBorders::Right, and owl::TGadget::TBorders::Top.
Called during idle time to allow the gadget to perform any idle actions.
TGadget performs command enabling on first call in each idle period.
Reimplemented in owl::TModeGadget, and owl::TTimeGadget.
Definition at line 120 of file gadget.cpp.
References CommandEnable().
|
protectedvirtual |
Called after a gadget is inserted into a window.
Reimplemented in owl::TSeparatorGadget, owl::TPickerGadget, and owl::TControlGadget.
Definition at line 325 of file gadget.cpp.
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.
Definition at line 408 of file gadget.cpp.
References owl::TRect::Height(), InvalidateRect(), and owl::TRect::Width().
Invalidate a rectangle in our containing window.
Rectangle is specified in gadget coordinates.
Definition at line 392 of file gadget.cpp.
References owl::TWindow::GetHandle(), and owl::TWindow::InvalidateRect().
|
inline |
|
inlineprotected |
|
inline |
|
inline |
bool owl::TGadget::IsWindowVisible | ( | ) | const |
check to see if the button's created
Definition at line 149 of file gadget.cpp.
References owl::TWindow::IsWindowVisible().
Captures the mouse if TrackMouse is set.
point is located in the gadget's coordinate system.
Reimplemented in owl::TMenuGadget, owl::TButtonGadget, and owl::TPopupButtonGadget.
Definition at line 608 of file gadget.cpp.
References owl::TGadgetWindow::GadgetSetCapture().
Releases the mouse capture if TrackMouse is set.
point is located in the gadget's coordinate system.
Reimplemented in owl::TButtonGadget, and owl::TPopupButtonGadget.
Definition at line 619 of file gadget.cpp.
References owl::TGadgetWindow::GadgetReleaseCapture().
Mouse is entering this gadget.
Called by gadget window if no other gadget has capture.
For toolbars with the flat style we want to allow the gadget to redraw with a slightly different style (e.g. border) when the mouse is hovering over the gadget. We handle this here by setting a flag (MouseInGadget) and then invalidating the gadget.
Reimplemented in owl::TButtonGadget.
Definition at line 542 of file gadget.cpp.
References owl::TGadgetWindow::FlatStandard, owl::TGadgetWindow::GetFlatStyle(), Invalidate(), and PRECONDITION.
Mouse is leaving this gadget.
Called by gadget window if no other gadget has capture
Reimplemented in owl::TButtonGadget.
Definition at line 566 of file gadget.cpp.
References owl::TGadgetWindow::FlatStandard, owl::TGadgetWindow::GetFlatStyle(), owl::TWindow::GetHandle(), owl::TGadgetWindow::GetTooltip(), Invalidate(), owl::MkUint32(), and PRECONDITION.
Mouse is moving over this gadget.
Called by gadget window only if this gadget has captured the mouse
point is located in the receiver's coordinate system.
Reimplemented in owl::TButtonGadget.
Definition at line 557 of file gadget.cpp.
|
protectedvirtual |
This is the virtual called when a gadget is relocated.
Definition at line 357 of file gadget.cpp.
References owl::TWindow::GetHandle(), and owl::TGadgetWindow::GetTooltip().
|
inline |
Calls PaintBorder() to paint the indicated device context.
Reimplemented in owl::TBitmapGadget, owl::TButtonTextGadget, owl::TSeparatorGadget, owl::TFlatHandleGadget, owl::TSizeGripGadget, owl::TTextGadget, owl::TButtonGadget, and owl::TPopupButtonGadget.
Definition at line 462 of file gadget.cpp.
References PaintBorder().
Self sent by method Paint().
Used to paint the border, PaintBorder determines the width and height of the gadget and uses the color returned by GetSyscolor to paint or highlight the area with the specified brush.
Override this is if you want to implement a border style that isn't supported
Depending on whether the border style is raised, embossed, or recessed, PaintBorder paints the specified boundary. You can override this function if you want to implement a border style that is not supported by ObjectWindows' gadgets.
Reimplemented in owl::TMenuGadget, and owl::TButtonGadget.
Definition at line 432 of file gadget.cpp.
References owl::TUIMetric::CxBorder, owl::TUIMetric::CyBorder, owl::TGadgetWindow::FlatStandard, owl::TGadgetWindow::GetFlatStyle(), owl::TRect::Height(), None, owl::TDC::OWLFastWindowFrame(), Paint(), owl::TUIBorder::Paint(), Plain, owl::TUIBorder::RaisedInner, owl::TUIBorder::Recessed, owl::TUIBorder::Rect, owl::TDC::RestoreBrush(), owl::TUIBorder::SunkenOuter, owl::TColor::SysWindowFrame, and owl::TRect::Width().
Default behavior returns true if the point is within the receiver's bounding rect.
Determines if the point is within the receiver's bounding rectangle and returns true if this is the case; otherwise, returns false.
"point" is in the receiver's coordinate system
Definition at line 289 of file gadget.cpp.
References owl::TRect::Height(), IsVisible(), and owl::TRect::Width().
Reimplemented in owl::TPopupButtonGadget.
Definition at line 629 of file gadget.cpp.
Definition at line 639 of file gadget.cpp.
|
protectedvirtual |
Virtual called after a gadget is removed from a window.
Reimplemented in owl::TControlGadget.
Definition at line 333 of file gadget.cpp.
References owl::TWindow::GetHandle(), and owl::TGadgetWindow::GetTooltip().
Sets the borders for the gadget.
If the borders are changed, SetBorders calls TGadgetWindow::GadgetChangedSize() to notify the gadget window of the change.
Definition at line 224 of file gadget.cpp.
References owl::TGadgetWindow::GadgetChangedSize().
void owl::TGadget::SetBorderStyle | ( | TBorderStyle | borderStyle | ) |
Set the border style used by this gadget.
Internal Border members are updated and owning Window is notified of a size change.
Definition at line 250 of file gadget.cpp.
References owl::TGadget::TBorders::Bottom, ButtonDn, ButtonUp, Embossed, owl::TGadgetWindow::GadgetChangedSize(), Grooved, owl::TGadget::TBorders::Left, None, Plain, Raised, Recessed, owl::TGadget::TBorders::Right, owl::TGadget::TBorders::Top, WndRaised, and WndRecessed.
Called by the gadget window to inform the gadget of a change in its bounding rectangle.
Default behavior here just updates instance variable "Bounds" but derived classes might override this method to update other internal state.
Reimplemented in owl::TControlGadget, owl::TBitmapGadget, owl::TButtonGadget, owl::TButtonTextGadget, and owl::TPopupButtonGadget.
Definition at line 211 of file gadget.cpp.
References Moved().
Enables or disables keyboard and mouse input for the gadget.
By default, the gadget is disabled when it is created and must be enabled before it can be activated.
Definition at line 194 of file gadget.cpp.
References Invalidate(), and owl::ToBool().
Sets the margins of the gadget.
If the margins are changed, SetMargins calls TGadgetWindow::GadgetChangedSize() to notify the gadget window.
Definition at line 237 of file gadget.cpp.
References owl::TGadgetWindow::GadgetChangedSize().
Simple set accessor to set whether shrinkwrapping is performed horizontally and/or vertically.
Your derived class can call TGadgetWindow::GadgetChangedSize() if you want to change the size of the gadget.
Definition at line 165 of file gadget.cpp.
Alters the size of the gadget and then calls TGadgetWindow::GadgetChangedSize() for the size change to take effect.
This function is needed only if you have turned off shrink-wrapping in one or both dimensions; otherwise, use the GetDesiredSize() member function to return the shrink-wrapped size.
Definition at line 179 of file gadget.cpp.
References owl::TGadgetWindow::GadgetChangedSize().
Changes the visibility of the gadget.
Reimplemented in owl::TControlGadget.
|
virtual |
Called when the system colors have been changed so that gadgets can rebuild and repaint, if necessary.
Reimplemented in owl::TBitmapGadget, owl::TButtonTextGadget, and owl::TButtonGadget.
Definition at line 141 of file gadget.cpp.
|
protected |
Paint now if possible.
Repaints the gadget if possible.
Definition at line 417 of file gadget.cpp.
References owl::TWindow::GetHandle(), and owl::TWindow::UpdateWindow().
|
friend |
|
friend |