32layoutUnitsToPixels(
int units,
int fontHeight)
34 const long unitsPerEM = 8;
36 return int((
long(units) * fontHeight + unitsPerEM / 2) / unitsPerEM);
43predefinedGadgetId(
int id)
66 left = layoutUnitsToPixels(
Left, fontHeight);
67 top = layoutUnitsToPixels(
Top, fontHeight);
68 right = layoutUnitsToPixels(
Right, fontHeight);
69 bottom = layoutUnitsToPixels(
Bottom, fontHeight);
76 left =
Left * cxBorder;
78 right =
Right * cxBorder;
79 bottom =
Bottom * cyBorder;
91 Bounds =
TRect(0, 0, 0, 0);
92 Flags = Enabled | Visible;
94 MouseInGadget =
false;
96 WideAsPossible =
false;
97 ShrinkWrapWidth = ShrinkWrapHeight =
true;
112 Window->Remove(*
this);
152 return Window->IsWindowVisible();
167 ShrinkWrapWidth = shrinkWrapWidth;
168 ShrinkWrapHeight = shrinkWrapHeight;
181 Bounds.right = Bounds.left + size.cx;
182 Bounds.bottom = Bounds.top + size.cy;
185 Window->GadgetChangedSize(*
this);
196 if (
ToBool(Flags & Enabled) != enabled) {
213 if (rect != Bounds) {
229 Window->GadgetChangedSize(*
this);
242 Window->GadgetChangedSize(*
this);
252 BorderStyle = borderStyle;
255 switch (BorderStyle) {
278 Borders.
Left = Borders.Top = Borders.Right = Borders.Bottom = edgeThickness;
281 Window->GadgetChangedSize(*
this);
292 point.x >= 0 && point.y >= 0 &&
293 point.x < Bounds.Width() && point.y < Bounds.Height();
308 if (tooltip && tooltip->
IsWindow()) {
314 if (!predefinedGadgetId(Id)) {
315 TToolInfo toolInfo(Window->GetHandle(), Bounds, Id);
337 if (Window && Window->GetHandle()) {
339 if (tooltip && tooltip->
IsWindow()) {
345 if (!predefinedGadgetId(Id)) {
346 TToolInfo toolInfo(Window->GetHandle(), Bounds, Id);
361 if (Window && Window->GetHandle()) {
363 if (tooltip && tooltip->
IsWindow()) {
369 if (!predefinedGadgetId(Id)) {
379 if (
TRect(ti.rect) != Bounds)
394 if (Window && Window->GetHandle()) {
395 TRect updateRect(rect.left + Bounds.left, rect.top + Bounds.top,
396 rect.right + Bounds.left, rect.bottom + Bounds.top);
398 Window->InvalidateRect(updateRect, erase);
419 if (Window && Window->GetHandle())
420 Window->UpdateWindow();
434 if (BorderStyle !=
None) {
438 TRect boundsRect(0,0,Bounds.Width(),Bounds.Height());
439 if (BorderStyle ==
Plain) {
487 size.cx = ShrinkWrapWidth ? left+right : Bounds.Width();
488 size.cy = ShrinkWrapHeight ? top+bottom : Bounds.Height();
502 Window->GetMargins(Margins, left, right, top, bottom);
503 left += Borders.Left * xBorder;
504 right += Borders.Right * xBorder;
505 top += Borders.Top * yBorder;
506 bottom += Borders.Bottom * yBorder;
522 innerRect.left = left;
523 innerRect.right = Bounds.
Width() - right;
525 innerRect.bottom = Bounds.
Height() - bottom;
545 MouseInGadget =
true;
576 if (tooltip && tooltip->
IsWindow()) {
579 GetCursorPos(&crsPoint);
580 HWND hwnd = WindowFromPoint(crsPoint);
582 ::MapWindowPoints(HWND_DESKTOP, hwnd, LPPOINT(&crsPoint), 1);
584 hwnd = GetDesktopWindow();
588 msg.message = WM_MOUSEMOVE;
597 MouseInGadget =
false;
611 Window->GadgetSetCapture(*
this);
622 Window->GadgetReleaseCapture(*
this);
658 ShrinkWrapWidth = ShrinkWrapHeight =
false;
667 Bounds.bottom = size;
708 horizontal ? 0 : (bar.
Width() - Bounds.Width())/2 - border.cx,
709 !horizontal ? 0 : (bar.
Height() - Bounds.Height())/2 - border.cy
716 int part_id = horizontal ? TP_SEPARATOR : TP_SEPARATORVERT;
726 bounds.left = bounds.
Width()/2-1;
727 bounds.right = bounds.left+2;
731 bounds.top = bounds.
Height()/2-1;
732 bounds.bottom = bounds.top+2;
763 size.cx = size.cy = 0;
767 int id = gadg->GetId();
770 gadg->GetDesiredSize(gsize);
771 maxsize.cx = std::max(gsize.cx,maxsize.cx);
772 maxsize.cy = std::max(gsize.cy,maxsize.cy);
778 size.cy = maxsize.cy;
781 size.cx = maxsize.cx;
793 TRect boundsRect = Bounds;
795 boundsRect.right = boundsRect.left+3;
808 TRect boundsRect = Bounds;
810 boundsRect.bottom = boundsRect.top+3;
851 innerRect.left = left;
853 innerRect.right = Bounds.
Width() + 1;
854 innerRect.bottom = Bounds.
Height() + 1;
#define PRECONDITION(condition)
The GDI Brush class is derived from TGdiObject.
static const TColor SysWindowFrame
The symbolic system color value for the frame around each window.
TDC is the root class for GDI DC wrappers.
bool DPtoLP(TPoint *points, int count=1) const
Converts each of the count points in the points array from device points to logical points.
void RestoreBrush()
Restores the original GDI brush object to this DC.
void OWLFastWindowFrame(TBrush &brush, TRect &r, int xWidth, int yWidth, uint32 rop=PATCOPY)
Draws a frame of the specified size and thickness with the given brush.
TFlatHandleGadget(int id=IDG_FLATHANDLE)
virtual void Paint(TDC &dc)
virtual void GetDesiredSize(TSize &size)
TGadget is the base class for the following derived gadget classes:
virtual void RButtonUp(uint modKeys, const TPoint &point)
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 MouseMove(uint modKeys, const TPoint &point)
Mouse is moving over this gadget.
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.
virtual void MouseEnter(uint modKeys, const TPoint &point)
Mouse is entering this gadget.
void SetBorders(const TBorders &borders)
Sets the borders for the gadget.
virtual void Paint(TDC &dc)
Calls PaintBorder() to paint the indicated device context.
void SetSize(const TSize &size)
Alters the size of the gadget and then calls TGadgetWindow::GadgetChangedSize() for the size change t...
void Invalidate(bool erase=true)
Used to invalidate the active (usually nonborder) portion of the gadget, Invalidate calls InvalidateR...
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.
bool IsWindowVisible() const
check to see if the button's created
virtual void MouseLeave(uint modKeys, const TPoint &point)
Mouse is leaving this gadget.
TGadget(int id=0, TBorderStyle borderStyle=None)
Construct a gadget with a given id and border style.
void SetMargins(const TMargins &margins)
Sets the margins of the gadget.
virtual bool PtIn(const TPoint &point)
Default behavior returns true if the point is within the receiver's bounding rect.
virtual void CommandEnable()
Provided so that the gadget can perform command enabling (so it can handle an incoming message if it'...
void InvalidateRect(const TRect &rect, bool erase=true)
Invalidate a rectangle in our containing window.
bool IsVisible() const
Returns true if the gadget is visible.
TGadgetWindow * GetGadgetWindow()
Return a pointer to the owning or parent window for the gadget.
virtual void Moved()
This is the virtual called when a gadget is relocated.
virtual void SetBounds(const TRect &rect)
Called by the gadget window to inform the gadget of a change in its bounding rectangle.
virtual void Created()
This is the virtual called after the window holding a gadget has been created.
void SetShrinkWrap(bool shrinkWrapWidth, bool shrinkWrapHeight)
Simple set accessor to set whether shrinkwrapping is performed horizontally and/or vertically.
virtual void Removed()
Virtual called after a gadget is removed from a window.
virtual void Inserted()
Called after a gadget is inserted into a window.
virtual void SysColorChange()
Called when the system colors have been changed so that gadgets can rebuild and repaint,...
TBorderStyle
Gadget border styles.
@ Embossed
Painted with an embossed border.
@ WndRecessed
Input field and other window are recessed.
@ Recessed
Recessed into the window.
@ None
No border painted at all.
@ WndRaised
Inner and outer edge of the window are raised.
@ ButtonUp
Button in up position.
@ Plain
Plain window frame.
@ Grooved
Grouping groove.
@ Raised
Raised above the gadget window.
@ ButtonDn
Button in down position.
virtual void SetEnabled(bool enabled)
Enables or disables keyboard and mouse input for the gadget.
virtual void SetVisible(bool visible)
Changes the visibility of the gadget.
void Update()
Paint now if possible.
virtual void GetDesiredSize(TSize &size)
Request by the gadget window to query the gadget's desired size.
virtual void PaintBorder(TDC &dc)
Self sent by method Paint().
virtual void LButtonUp(uint modKeys, const TPoint &point)
Releases the mouse capture if TrackMouse is set.
virtual ~TGadget()
Destroys a TGadget interface object and removes it from its associated window.
void SetBorderStyle(TBorderStyle bs)
Set the border style used by this gadget.
TGadget * NextGadget(TGadget &gadget) const
Returns the next gadget in the list relative to a given gadget.
static uint GetFlatStyle()
Returns the flat style.
@ FlatSingleDiv
Adds single divider ala IE 4.01.
@ FlatStandard
Flat style IE 3.0 - base style.
@ Vertical
Arrange gadgets in a column.
@ Rectangular
Arrange gadgets in rows and columns (2-D grid).
@ Horizontal
Arrange gadgets in a row.
TTileDirection GetDirection() const
Returns the direction of tiling for this gadget window.
TPoint is a support class, derived from tagPOINT.
TRect is a mathematical class derived from tagRect.
TRect MovedTo(int x, int y)
Moves the upper left point of the rectangle while maintaining the current dimension.
int Height() const
Returns the height of this rectangle (bottom - top).
TRect & Offset(int dx, int dy)
Changes this rectangle so its corners are offset by the given delta values.
TRect & Inflate(int dx, int dy)
Inflates a rectangle inflated by the given delta arguments.
int Width() const
Returns the width of this rectangle (right - left).
TRect()
Default constructor that does nothing.
TSeparatorGadget(int size=0, int id=0, bool showseparator=true)
Used for both the width and the height of the separator, the default size is TUIMetric::CxSizeFrame t...
void Inserted()
This is an overridden virtual, called after a gadget is inserted into a window.
void Paint(TDC &dc)
Draws the resize gadget.
TSizeGripGadget(int id=IDG_SIZEGRIP)
Constructs a gadget that can be grabbed to resize the frame.
The tagSIZE struct is defined as.
TSize()
Default constructor that does nothing.
Encapsulates a themed part.
void DrawBackground(HDC, const TRect &dest)
Paints the background of the themed part.
@ RaisedInner
Raised inner edge only.
@ SunkenOuter
Sunken outer edge only.
TStyle
Enumeration describing hilevel border styles.
@ Recessed
Status field style recessed.
@ Embossed
Grouping raised emboss bead.
static bool DrawEdge(TDC &dc, const TRect &frame, uint edge, uint flags)
This is a static function that performs the actual drawing of edges for a UIBorder or an external cli...
TUIBorder(const TRect &frame, TStyle style, uint flags=0)
Constructs a UIBorder object given a frame and a high-level style type.
TUIMetric encapsulates the GetSystemMetric() API.
static const TUIMetric CyBorder
static const TUIMetric CxBorder
static const TUIMetric CySizeFrame
static const TUIMetric CxSizeFrame
Encapsulates the DrawFrameControl 32-bit API.
bool Paint(TDC &dc, TRect &rect, TType type, TState state)
Draw the part onto a DC.
@ ScrollSizeGrip
Size grip in bottom-right corner of window.
@ uiScroll
Draw a scroll bar glyph.
virtual TTooltip * GetTooltip() const
bool IsWindow() const
Returns true if an HWND is being used.
void GetClientRect(TRect &rect) const
Gets the coordinates of the window's client area and then copies them into the object referred to by ...
Definition of class TFrameWindow.
Base class TGadget and simple derived TSeparatorGadget.
#define IDG_LAST
last predefined gadget ID
#define IDG_FLATHANDLE
The ID for a flat bar handle.
#define IDG_FIRST
first predefined gadget ID
Definition of TGadgetList, TGadgetWindow & TGadgetWindowFont A list holding gadgets,...
Object Windows Library (OWLNext Core).
uint32 MkUint32(uint16 lo, uint16 hi)
const int DefaultGripSize
General definitions used by all ObjectWindows programs.
Used by the TGadgetWindow and TGadget classes, TMargins contains the measurements of the margins for ...
void GetPixels(int &left, int &right, int &top, int &bottom, int fontHeight) const
Microsoft UxTheme Library Encapsulation.
Definition of the UI Helper Classes: TUIHandle, TUIBorder, TUIFace, TUIPart.
Definition of TUIMetric, a UI metrics provider class.