Photon microGUI widgets library 0.6.0
PhWidgets::Widget Struct Reference

Superclass for all widgets. More...

#include <Widget.h>

Inheritance diagram for PhWidgets::Widget:
PhWidgets::Basic PhWidgets::Timer PhWidgets::Container PhWidgets::Gauge PhWidgets::Graphic PhWidgets::Label PhWidgets::Compound PhWidgets::Disjoint PhWidgets::ImageArea PhWidgets::Pane PhWidgets::Button PhWidgets::TextWidget PhWidgets::ComboBox PhWidgets::Numeric PhWidgets::Window PhWidgets::OnOffButton PhWidgets::ToggleButton PhWidgets::NumericFloat PhWidgets::NumericInteger

Classes

struct  Arguments
 Contains resource IDs for all Widget arguments. More...
 
struct  Arguments< char *, ResourceTag::String, Dummy >
 Contains resource IDs for Widget arguments of type char*. More...
 
struct  Arguments< long, ResourceTag::Flag, Dummy >
 Contains resource IDs for Widget arguments of type long. More...
 
struct  Arguments< PgColor_t, ResourceTag::Color, Dummy >
 Contains resource IDs for Widget arguments of type PgColor_t. More...
 
struct  Arguments< PhArea_t, ResourceTag::Struct, Dummy >
 Contains resource IDs for Widget arguments of type PhArea_t. More...
 
struct  Arguments< PhCursorDef_t, ResourceTag::Struct, Dummy >
 Contains resource IDs for Widget arguments of type PhCursorDef_t. More...
 
struct  Arguments< PhDim_t, ResourceTag::Struct, Dummy >
 Contains resource IDs for Widget arguments of type PhDim_t. More...
 
struct  Arguments< PhPoint_t, ResourceTag::Struct, Dummy >
 Contains resource IDs for Widget arguments of type PhPoint_t. More...
 
struct  Arguments< PhRect_t, ResourceTag::Struct, Dummy >
 Contains resource IDs for Widget arguments of type PhRect_t. More...
 
struct  Arguments< PtGridLayoutData_t, ResourceTag::Struct, Dummy >
 Contains resource IDs for Widget arguments of type PtGridLayoutData_t. More...
 
struct  Arguments< PtRowLayoutData_t, ResourceTag::Struct, Dummy >
 Contains resource IDs for Widget arguments of type PtRowLayoutData_t. More...
 
struct  Arguments< unsigned long, ResourceTag::Flag, Dummy >
 Contains resource IDs for Widget arguments of type unsigned long. More...
 
struct  Arguments< unsigned short, ResourceTag::Scalar, Dummy >
 Contains resource IDs for Widget arguments of type unsigned short. More...
 
struct  Arguments< unsigned, ResourceTag::Flag, Dummy >
 Contains resource IDs for Widget arguments of type unsigned. More...
 
struct  Arguments< void *, ResourceTag::Alloc, Dummy >
 Contains resource IDs for Widget arguments of type void*. More...
 
struct  Callbacks
 Contains resource IDs for Widget callbacks. More...
 
struct  Callbacks< PtCallback_t, ResourceTag::Callback, Dummy >
 Contains resource IDs for Widget callbacks of type PtCallback_t. More...
 
struct  Callbacks< PtHotkeyCallback_t, ResourceTag::Callback, Dummy >
 Contains resource IDs for Widget callbacks of type PtHotkeyCallback_t. More...
 
struct  Callbacks< PtRawCallback_t, ResourceTag::Callback, Dummy >
 Contains resource IDs for Widget callbacks of type PtRawCallback_t. More...
 
struct  Flags
 Contains flags for Widget resources. More...
 
class  phwidgets_event
 An event, which raise a notification to registered subscribers (event handlers) that something of interest has occurred. More...
 

Public Types

typedef phevent::ph_callback_t callback_t
 An event handler that is raised when an event occur.
 

Public Member Functions

 Widget (int abn)
 (constructor) More...
 
 Widget (PtWidget_t *wdg)
 (constructor) More...
 
 Widget (const Widget &other)
 (copy constructor) More...
 
void swap (Widget &other)
 Exchanges the contents of *this and other. More...
 
Widgetoperator= (const Widget &other)
 Assigns value in Widget. More...
 
Widgetoperator= (PtWidget_t *wdg)
 Assigns value in Widget. More...
 
bool operator== (const Widget &other) const
 Compares Widgets. More...
 
bool operator!= (const Widget &other) const
 Compares Widgets. More...
 
bool operator< (const Widget &other) const
 Compares Widgets. More...
 
bool operator<= (const Widget &other) const
 Compares Widgets. More...
 
bool operator> (const Widget &other) const
 Compares Widgets. More...
 
bool operator>= (const Widget &other) const
 Compares Widgets. More...
 
PtWidget_tget () const
 Returns the stored pointer.
 
 operator PtWidget_t * ()
 Converts Widget to Photon widget pointer.
 
 operator const PtWidget_t * () const
 Converts Widget to constant Photon widget pointer.
 
void BringToFront ()
 Brings the widget to the front of the z-order. More...
 
bool Contains (const Widget &widget)
 Retrieves a value indicating whether the specified widget is a child of the widget. More...
 
bool Focus ()
 Sets input focus to the widget. More...
 
Widget GetNextWidget (const Widget &widget, bool forward=true) const
 Retrieves the next widget forward or back in the tab order of child widgets. More...
 
void Hide ()
 Conceals the widget from the user. More...
 
void Invalidate (PhRect_t rc, bool invalidateChildren=false)
 Invalidates a specific region of the widget and causes a paint message to be sent to the widget. More...
 
void Invalidate (bool invalidateChildren=false)
 Invalidates a specific region of the widget and causes a paint message to be sent to the widget. More...
 
bool Realize ()
 Make the widget and its children visible and possibly interactive. More...
 
void Refresh ()
 Forces the widget to invalidate its client area and immediately redraw itself and any child widgets. More...
 
void SendToBack ()
 Sends the widget to the back of the z-order. More...
 
void SetBounds (short x, short y, unsigned short width, unsigned short height)
 Sets the bounds of the widget to the specified location and size. More...
 
void SetBounds (short x, short y)
 Sets the bounds of the widget to the specified location. More...
 
void Select ()
 Activates the widget. More...
 
void Show ()
 Displays the widget to the user. More...
 
bool Unrealize ()
 Unrealizes the widget and all its children. More...
 
Event raisers
void OnDestroyed (PtCallbackInfo_t *info)
 Raises the Widget::Destroyed event.
 
void OnBlocked (PtCallbackInfo_t *info)
 Raises the Widget::Blocked event.
 
void OnDragDrop (PtCallbackInfo_t *info)
 Raises the Widget::DragDrop event.
 
void OnOutbound (PtCallbackInfo_t *info)
 Raises the Widget::Outbound event.
 
void OnRealized (PtCallbackInfo_t *info)
 Raises the Widget::Realized event.
 
void OnUnrealized (PtCallbackInfo_t *info)
 Raises the Widget::Unrealized event.
 

Static Public Member Functions

static void Update ()
 Causes the Photon microGUI to redraw the all invalidated regions. More...
 

Public Attributes

WidgetResourcesSingleton resource
 Resources of the Widget. More...
 
Properties

Properties are used to simplify use of widget resources.

property< bool >::bind< Widget, &Widget::getAllowDrop, &Widget::setAllowDrop > AllowDrop
 Gets or sets a value indicating whether the widget can accept data that the user drags onto it. More...
 
phbitmask< unsigned, Flags::Anchor::type, Flags::Anchor::All >::bind< Widget, Arguments< unsigned >::Flag, Arguments< unsigned >::AnchorFlags > Anchor
 Gets or sets flags specifying how the widget is anchored to its parent. More...
 
phproperty< unsigned short >::bind< Widget, Arguments< unsigned short >::Scalar, Arguments< unsigned short >::BevelWidth > BevelWidth
 Gets or sets the bevel width of the widget. More...
 
property< short, property<>::ro >::bind< Widget, &Widget::getBottom > Bottom
 Gets the distance, in pixels, between the bottom edge of the widget and the top edge of its container's client area. More...
 
property< PhArea_t >::bind< Widget, &Widget::getBounds, &Widget::setBounds > Bounds
 Gets or sets the size and location of the widget including its nonclient elements, in pixels, relative to the parent widget. More...
 
property< bool, property<>::ro >::bind< Widget, &Widget::getCanFocus > CanFocus
 Gets a value indicating whether the widget can receive focus. More...
 
property< bool, property<>::ro >::bind< Widget, &Widget::getCanSelect > CanSelect
 Gets a value indicating whether the widget can be selected. More...
 
property< bool, property<>::ro >::bind< Widget, &Widget::getContainsFocus > ContainsFocus
 Gets a value indicating whether the widget, or one of its child widgets, currently has the input focus. More...
 
property< PhWidgets::Cursor >::bind< Widget, &Widget::getCursor, &Widget::setCursor > Cursor
 Gets or sets the cursor that is displayed when the mouse pointer is over the widget. More...
 
phproperty< Drawing::Color >::bind< Widget, Arguments< PgColor_t >::Color, Arguments< PgColor_t >::CursorColor > CursorColor
 Gets or sets the color of the cursor pointer when it's inside the widget. More...
 
property< bool >::bind< Widget, &Widget::getEnabled, &Widget::setEnabled > Enabled
 Gets or sets a value indicating whether the widget can respond to user interaction. More...
 
property< bool, property<>::ro >::bind< Widget, &Widget::getFocused > Focused
 Gets a value indicating whether the widget has input focus. More...
 
property< bool, property<>::ro >::bind< Widget, &Widget::hasChildren > HasChildren
 Gets a value indicating whether the widget contains one or more child widgets. More...
 
property< bool, property<>::ro >::bind< Widget, &Widget::hasParent > HasParent
 Gets a value indicating whether the widget has parent. More...
 
phproperty< unsigned short >::bind< Widget, Arguments< unsigned short >::Scalar, Arguments< unsigned short >::Height > Height
 Gets or sets the height of the widget. More...
 
property< std::string >::bind< Widget, &Widget::getHelpTopic, &Widget::setHelpTopic > HelpTopic
 Gets or sets the help topic of the widget. More...
 
property< bool, property<>::ro >::bind< Widget, &Widget::getIsRealized > IsRealized
 Gets or sets a value indicating whether the widget is realized. More...
 
property< short >::bind< Widget, &Widget::getLeft, &Widget::setLeft > Left
 Gets or sets the distance, in pixels, between the left edge of the widget and the left edge of its container's client area. More...
 
property< PhPoint_t >::bind< Widget, &Widget::getLocation, &Widget::setLocation > Location
 Gets or sets the coordinates of the upper-left corner of the widget relative to the upper-left corner of its container. More...
 
property< PtWidget_t * >::bind< Widget, &Widget::getParent, &Widget::setParent > Parent
 Gets or sets the parent container of the widget. More...
 
phproperty< PhPoint_t >::bind< Widget, Arguments< PhPoint_t >::Struct, Arguments< PhPoint_t >::Position > Position
 Gets or sets the absolute coordinates of the upper-left corner of the widget. More...
 
property< short, property<>::ro >::bind< Widget, &Widget::getRight > Right
 Gets the distance, in pixels, between the right edge of the widget and the left edge of its container's client area. More...
 
phproperty< PhDim_t >::bind< Widget, Arguments< PhDim_t >::Struct, Arguments< PhDim_t >::Dimension > Size
 Gets or sets the size of the widget. More...
 
tag_property< Widget, &Widget::getTag, &Widget::setTag > Tag
 Gets or sets the resource that contains data about the widget. More...
 
property< short >::bind< Widget, &Widget::getTop, &Widget::setTop > Top
 Gets or sets the distance, in pixels, between the top edge of the widget and the top edge of its container's client area. More...
 
property< bool >::bind< Widget, &Widget::getVisible, &Widget::setVisible > Visible
 Gets or sets a value indicating whether the widget and all its child widgets are displayed. More...
 
property< std::set< PhWidgets::Widget >, property<>::ro >::bind< Widget, &Widget::getWidgets > Widgets
 Gets the list of widgets contained within the widget. More...
 
phproperty< unsigned short >::bind< Widget, Arguments< unsigned short >::Scalar, Arguments< unsigned short >::Width > Width
 Gets or sets the width of the widget. More...
 
phbitmask< unsigned long, Flags::Extended::type >::bind< Widget, Arguments< unsigned long >::Flag, Arguments< unsigned long >::ExtendedFlags > ExtendedFlags
 Gets or sets extended flags inherited by all widgets. See Flags::Extended::type.
 
phbitmask< long, Flags::type >::bind< Widget, Arguments< long >::Flag, Arguments< long >::Flags > WidgetFlags
 Gets or sets flags inherited by all widgets. More...
 
phbitmask< long, Flags::Resize::type >::bind< Widget, Arguments< long >::Flag, Arguments< long >::Resiztype > Resiztype
 Gets or sets flags to control a widget's resize policy. See Flags::Resize::type.

 
Events
phwidgets_event< Widget, Widget::Callbacks<>::Destroyed > Destroyed
 Occurs when the widget is destroyed.
 
phwidgets_event< Widget, Widget::Callbacks<>::Blocked > Blocked
 Occurs when the widget is blocked.
 
phwidgets_event< Widget, Widget::Callbacks<>::DragAndDrop > DragDrop
 Occurs when a drag-and-drop operation is completed.
 
phwidgets_event< Widget, Widget::Callbacks<>::IsDestroyed > IsDestroyed
 Occurs when the widget's resources are being released.
 
phwidgets_event< Widget, Widget::Callbacks<>::Outbound > Outbound
 Occurs when you press the pointer button on the widget and then move out of the "hot spot" with the button still depressed.
 
phwidgets_event< Widget, Widget::Callbacks<>::Realized > Realized
 Occurs when the widget is realized.
 
phwidgets_event< Widget, Widget::Callbacks<>::Unrealized > Unrealized
 Occurs when the widget is unrealized.
 

Detailed Description

Superclass for all widgets.

Widget is the fundamental superclass. All widgets belong to a subclass of Widget.

See also

Constructor & Destructor Documentation

◆ Widget() [1/3]

PhWidgets::Widget::Widget ( int  abn)
explicit

(constructor)

Constructs a Widget by ID.

Parameters
[in]abnID given by PhAB to widget (like 'ABN_WIDGET_NAME').

◆ Widget() [2/3]

PhWidgets::Widget::Widget ( PtWidget_t wdg)
explicit

(constructor)

Constructs a Widget by pointer to widget.

Parameters
[in]wdgpointer to Photon widget.

◆ Widget() [3/3]

PhWidgets::Widget::Widget ( const Widget other)

(copy constructor)

Constructs a Widget by copy.

Parameters
[in]otheranother Widget to be used as source to initialize the elements of the container with.

Member Function Documentation

◆ BringToFront()

void PhWidgets::Widget::BringToFront ( )

Brings the widget to the front of the z-order.

The widget is moved to the front of the z-order. If the widget is a child of another widget, the child widget is moved to the front of the z-order. BringToFront() does not make a widget a top-level widget, and it does not raise the Widget::Paint event.

See also

◆ Contains()

bool PhWidgets::Widget::Contains ( const Widget widget)

Retrieves a value indicating whether the specified widget is a child of the widget.

Parameters
[in]widgetThe Widget to evaluate.
Returns
true if the specified widget is a child of the widget; otherwise, false.

Examples

The following code example ensures that a Label is visible by calling its BringToFront() method. This example requires that you have a Window main_window with a Label named label1.

void MakeLabelVisible()
{
// If the window contains label1, bring it
// to the front to make sure it is visible.
if(main_window.Contains(label1))
{
label1.BringToFront();
}
}
See also

◆ Focus()

bool PhWidgets::Widget::Focus ( )

Sets input focus to the widget.

Returns
true if the input focus request was successful; otherwise, false.

Examples

// Set focus to the widget, if it can receive focus.
if(widget.CanFocus)
{
widget.Focus();
}
Remarks
The Focus() method returns true if the widget successfully received input focus. The widget can have the input focus while not displaying any visual cues of having the focus. This behavior is primarily observed by the nonselectable widgets listed below, or any widgets derived from them.
A widget can be selected and receive input focus if all the following are true: the Widget::Flags::Selectable value of Widget::WidgetFlags is set to true, it is contained in another widget, and all its parent widgets are both visible and enabled.
The Photon microGUI widgets in the following list are not selectable. Widgets derived from these widgets are also not selectable.
  • Pane
  • GroupBox
  • ImageArea
  • ProgressBar
  • Splitter
  • Label
  • LinkLabel (when there is no link present in the widget)

◆ GetNextWidget()

Widget PhWidgets::Widget::GetNextWidget ( const Widget widget,
bool  forward = true 
) const

Retrieves the next widget forward or back in the tab order of child widgets.

Parameters
[in]widgetThe Widget to start the search with.
[in]forwardtrue to search forward in the tab order; false to search backward.
Returns
The next Widget in the tab order.
Exceptions
std::out_of_range
Remarks
The GetNextWidget() method is dependent on tab order. To iterate through all widgets of a container, including nested widgets, use the Widget::Widgets property. To get or set the active widget of a container widget, use the Container::ActiveWidget property.
See also

◆ Hide()

void PhWidgets::Widget::Hide ( )

Conceals the widget from the user.

Remarks
Hiding the widget is equivalent to setting the Widget::Visible property to false. After the Hide() method is called, the Widget::Visible property returns a value of false until the Show() method is called.
See also

◆ Invalidate() [1/2]

void PhWidgets::Widget::Invalidate ( bool  invalidateChildren = false)

Invalidates a specific region of the widget and causes a paint message to be sent to the widget.

Parameters
[in]invalidateChildrentrue to invalidate the widget's child widgets; otherwise, false.

Invalidates a specific region of the widget and causes a paint message to be sent to the widget. Optionally, invalidates the child widgets assigned to the widget.

Remarks
Calling the Invalidate() method does not force a synchronous paint so there is no performance penalty; to force a synchronous paint, call the Update() method after calling the Invalidate() method. When this method is called with no parameters, the entire client area is added to the update region.
See also

◆ Invalidate() [2/2]

void PhWidgets::Widget::Invalidate ( PhRect_t  rc,
bool  invalidateChildren = false 
)

Invalidates a specific region of the widget and causes a paint message to be sent to the widget.

Parameters
[in]rcThe Rectangle to invalidate.
[in]invalidateChildrentrue to invalidate the widget's child widgets; otherwise, false.

Invalidates the specified region of the widget (adds it to the widget's update region, which is the area that will be repainted at the next paint operation), and causes a paint message to be sent to the widget. Optionally, invalidates the child widgets assigned to the widget.

Remarks
Calling the Invalidate() method does not force a synchronous paint so there is no performance penalty; to force a synchronous paint, call the Update() method after calling the Invalidate() method. When this method is called with no parameters, the entire client area is added to the update region.
See also

◆ operator!=()

bool PhWidgets::Widget::operator!= ( const Widget other) const

Compares Widgets.

Compares the Widgets by their Photon widget pointers.

Parameters
[in]otherWidget whose contents to compare.

◆ operator<()

bool PhWidgets::Widget::operator< ( const Widget other) const

Compares Widgets.

Compares the Widgets by their Photon widget pointers.

Parameters
[in]otherWidget whose contents to compare.

◆ operator<=()

bool PhWidgets::Widget::operator<= ( const Widget other) const

Compares Widgets.

Compares the Widgets by their Photon widget pointers.

Parameters
[in]otherWidget whose contents to compare.

◆ operator=() [1/2]

Widget & PhWidgets::Widget::operator= ( const Widget other)

Assigns value in Widget.

Replaces the contents of the Widget.

Parameters
[in]otheranother Widget to use as data source.

◆ operator=() [2/2]

Widget & PhWidgets::Widget::operator= ( PtWidget_t wdg)

Assigns value in Widget.

Replaces the contents of the Widget.

Parameters
[in]wdgpointer to Photon widget.

◆ operator==()

bool PhWidgets::Widget::operator== ( const Widget other) const

Compares Widgets.

Compares the Widgets by their Photon widget pointers.

Parameters
[in]otherWidget whose contents to compare.

◆ operator>()

bool PhWidgets::Widget::operator> ( const Widget other) const

Compares Widgets.

Compares the Widgets by their Photon widget pointers.

Parameters
[in]otherWidget whose contents to compare.

◆ operator>=()

bool PhWidgets::Widget::operator>= ( const Widget other) const

Compares Widgets.

Compares the Widgets by their Photon widget pointers.

Parameters
[in]otherWidget whose contents to compare.

◆ Realize()

bool PhWidgets::Widget::Realize ( )

Make the widget and its children visible and possibly interactive.

Make a widget and its children visible to the user and possibly interactive.

Note
Some widgets (for example, menus) have Widget::Flags::DelayRealize set in their Widget::Arguments::flags. Such delay-realized widgets aren't visibly rendered when their ancestors are realized.
Although they're present in the hierarchy, delay-realized widgets become visible only when the application realizes them specifically with a call to Realize(). An application might do this, for example, if the user requested it to activate a menu.
Returns
true if the realize request was successful; otherwise, false.
See also

◆ Refresh()

void PhWidgets::Widget::Refresh ( )

Forces the widget to invalidate its client area and immediately redraw itself and any child widgets.

Note
Due to Photon microGUI drawing routine calling Refresh() on widget forces not only this widget and its children but also all other areas waiting for the redraw to be updated immidiately. So this may cause some performance issues.
See also

◆ Select()

void PhWidgets::Widget::Select ( )

Activates the widget.

The Select method activates the widget if the widget's Widget::Flags::Selectable flag of Widget::Arguments::flags is set true, it is contained in another widget, and all its parent widget are both visible and enabled.

Examples

// Select the widget, if it can be selected.
if(widget.CanSelect)
{
widget.Select();
}

◆ SendToBack()

void PhWidgets::Widget::SendToBack ( )

Sends the widget to the back of the z-order.

The widget is moved to the back of the z-order. If the widget is a child of another widget, the child widget is moved to the back of the z-order. If the widget is a top-level widget, this method will not work correctly unless the widget is active. A top-level widget is a widget, such as a Form, that is not a child of another widget. An active widget is a visible widget that has input focus. To use the SendToBack() method with an inactive, top-level widget, first call the BringToFront() method on the widget.

See also

◆ SetBounds() [1/2]

void PhWidgets::Widget::SetBounds ( short  x,
short  y 
)

Sets the bounds of the widget to the specified location.

Parameters
[in]xThe new Widget::Left property value of the widget.
[in]yThe new Widget::Top property value of the widget.

◆ SetBounds() [2/2]

void PhWidgets::Widget::SetBounds ( short  x,
short  y,
unsigned short  width,
unsigned short  height 
)

Sets the bounds of the widget to the specified location and size.

Parameters
[in]xThe new Widget::Left property value of the widget.
[in]yThe new Widget::Top property value of the widget.
[in]widthThe new Widget::Width property value of the widget.
[in]heightThe new Widget::Height property value of the widget.

◆ Show()

void PhWidgets::Widget::Show ( )

Displays the widget to the user.

Remarks
Showing the widget is equivalent to setting the Widget::Visible property to true. After the Show() method is called, the Widget::Visible property returns a value of true until the Hide() method is called.
See also

◆ swap()

void PhWidgets::Widget::swap ( Widget other)

Exchanges the contents of *this and other.

Parameters
[in]otherwidget to exchange the contents with.

◆ Unrealize()

bool PhWidgets::Widget::Unrealize ( )

Unrealizes the widget and all its children.

The widgets are removed from the display, and the widget engine will no longer invoke their callbacks. Unrealized widgets still exist in the widget hierarchy and can be realized again.

Note
Unrealizing and realizing a widget can take some time. If you want to hide a widget quickly, you can set its Widget::Visible property to false.
Returns
true if the unrealize request was successful; otherwise, false.
See also

◆ Update()

static void PhWidgets::Widget::Update ( )
static

Causes the Photon microGUI to redraw the all invalidated regions.

Executes any pending requests for painting.

Remarks
There are two ways to repaint a window and its contents:

The Invalidate() method governs what gets painted or repainted. The Update() method governs when the painting or repainting occurs. If you use the Invalidate() and Update() methods together rather than calling Refresh(), what gets repainted depends on which overload of Invalidate() you use. The Update() method just forces the widget to be painted immediately, but the Invalidate() method governs what gets painted when you call the Update() method.

Note
Due to Photon microGUI drawing routine calling Update() on widget forces not only this widget and its children but also all other areas waiting for the redraw to be updated immidiately. So this may cause some performance issues.
See also

Member Data Documentation

◆ AllowDrop

property<bool>::bind<Widget, &Widget::getAllowDrop, &Widget::setAllowDrop> PhWidgets::Widget::AllowDrop

Gets or sets a value indicating whether the widget can accept data that the user drags onto it.

Property Value

bool

true if drag-and-drop operations are allowed in the widget; otherwise, false. The default is false.

See also
  • DragEventArgs
  • DragOver
  • DragDrop
  • DragEnter
  • DragLeave
  • DoDragDrop

◆ Anchor

phbitmask<unsigned, Flags::Anchor::type, Flags::Anchor::All>:: bind<Widget, Arguments<unsigned>::Flag, Arguments<unsigned>::AnchorFlags> PhWidgets::Widget::Anchor

Gets or sets flags specifying how the widget is anchored to its parent.

Property Value

AnchorStyles::type

A bitwise combination of the Flags::Anchor::type values.

Examples

// You have somewhere:
PtWidget_t *ptwidget; // pointer to widget
// constructing Widget
PhWidgets::Widget widget(ptwidget);
// anchor the widget to the bottom right corner of the parent
Superclass for all widgets.
Definition: Widget.h:110
@ Right
The widget is anchored to the right edge of its container.
Definition: Widget.h:83
@ Bottom
The widget is anchored to the bottom edge of its container.
Definition: Widget.h:80
Remarks
Use the Widget::Anchor property to define how a widget is automatically resized as its parent widget is resized. Anchoring a widget to its parent widget ensures that the anchored edges remain in the same position relative to the edges of the parent widget when the parent widget is resized. You can anchor a widget to one or more edges of its container. For example, if you have a Container with a Button whose Button::Anchor property value is set to AnchorStyles::Top and AnchorStyles::Bottom, the Button is stretched to maintain the anchored distance to the top and bottom edges of the Container as the Height of the Container is increased.
See also

◆ BevelWidth

phproperty<unsigned short>::bind<Widget, Arguments<unsigned short>::Scalar, Arguments<unsigned short>::BevelWidth> PhWidgets::Widget::BevelWidth

Gets or sets the bevel width of the widget.

Property Value

unsigned short

The bevel width of the widget in pixels.

Remarks
The width of the widget's bevel if the widget is highlighted and is to draw a bevel.
See also
  • Widget::ThisFlags::Highlighted
  • Basic::ThisFlags::Basic::type

◆ Bottom

property<short, property<>::ro>::bind<Widget, &Widget::getBottom> PhWidgets::Widget::Bottom

Gets the distance, in pixels, between the bottom edge of the widget and the top edge of its container's client area.

Property Value

short

An short representing the distance, in pixels, between the bottom edge of the widget and the top edge of its container's client area.

Remarks
The value of this property is equal to the sum of the Widget::Top property value, and the Widget::Height property value.
The Widget::Bottom property is a read-only property. You can manipulate this property value by changing the value of the Widget::Top or Widget::Height properties or calling the Widget::SetBounds methods.
See also

◆ Bounds

property<PhArea_t>::bind<Widget, &Widget::getBounds, &Widget::setBounds> PhWidgets::Widget::Bounds

Gets or sets the size and location of the widget including its nonclient elements, in pixels, relative to the parent widget.

Property Value

PhArea_t

A PhArea_t in pixels relative to the parent widget that represents the size and location of the widget including its nonclient elements.

Examples

// You have somewhere:
PtWidget_t *ptwidget; // pointer to widget
// constructing Widget
PhWidgets::Widget widget(ptwidget);
// set the widget size and location using the Bounds property.
PhArea_t bounds;
PhPoint_t pos = {20, 48};
PhDim_t size = {12, 20};
bounds.pos = pos; // location
bounds.size = size; // size
widget.Bounds = bounds;
See also

◆ CanFocus

property<bool, property<>::ro>::bind<Widget, &Widget::getCanFocus> PhWidgets::Widget::CanFocus

Gets a value indicating whether the widget can receive focus.

Property Value

bool

true if the widget can receive focus; otherwise, false.

Remarks
In order for a widget to receive input focus, the Widget must have a PtWidget_t pointer assigned to it, and the Widget::Visible and Widget::Enabled properties must both be set to true for both the widget and all its parent widgets, and the widget must be a PhWidgets::Window or the widget's outermost parent must be a PhWidgets::Window.
See also

◆ CanSelect

property<bool, property<>::ro>::bind<Widget, &Widget::getCanSelect> PhWidgets::Widget::CanSelect

Gets a value indicating whether the widget can be selected.

Property Value

bool

true if the widget can be selected; otherwise, false.

Remarks
This property returns true if the Widget::Flags::Selectable flag of Widget::Arguments::flags is set, is contained in another widget, the widget itself is visible and enabled, and all its parent widget are visible and enabled.
See also

◆ ContainsFocus

property<bool, property<>::ro>::bind<Widget, &Widget::getContainsFocus> PhWidgets::Widget::ContainsFocus

Gets a value indicating whether the widget, or one of its child widgets, currently has the input focus.

Property Value

bool

true if the widget or one of its child widgets currently has the input focus; otherwise, false.

Remarks
You can use this property to determine whether a widget or any of the widgets contained within it has the input focus. To determine whether the widget has focus, regardless of whether any of its child widgets have focus, use the Widget::Focused property. To give a widget the input focus, use the Focus() or Select() methods.
See also

◆ Cursor

property<PhWidgets::Cursor>::bind<Widget, &Widget::getCursor, &Widget::setCursor> PhWidgets::Widget::Cursor

Gets or sets the cursor that is displayed when the mouse pointer is over the widget.

Property Value

PhWidgets::Cursor

A Cursor that represents the cursor to display when the mouse pointer is over the widget.

Examples

// You have somewhere:
PtWidget_t *ptwidget; // pointer to button widget
// constructing Button
PhWidgets::Button button(ptwidget);
// Display the hand cursor when the mouse pointer
// is over the button.
button.Cursor = PhWidgets::Cursors::Hand;
A button for initiating an action.
Definition: Button.h:24
@ Hand
The hand cursor, typically used when hovering over a Web link.
Definition: Cursor.h:47
Note
Cursor could also be constructed from PhCursorDef_t so you can assign your own defined PhCursorDef_t structure to this property.
// You have somewhere:
PtWidget_t *ptwidget; // pointer to widget
// constructing Widget
PhWidgets::Widget widget(ptwidget);
curdef.size1.x = curdef.size2.x = BMP_WIDTH;
curdef.size1.y = curdef.size2.y = BMP_HEIGHT;
...
// fill 'curdef' with your own cursor info
...
widget.Cursor = curdef; // assign custom cursor
Remarks
Assign a PhWidgets::Cursor to the Widget::Cursor property of the widget to change the cursor displayed when the mouse pointer is over the widget.
See also

◆ CursorColor

phproperty<Drawing::Color>::bind<Widget, Arguments<PgColor_t>::Color, Arguments<PgColor_t>::CursorColor> PhWidgets::Widget::CursorColor

Gets or sets the color of the cursor pointer when it's inside the widget.

Property Value

Drawing::Color

A Drawing::Color that represents the color of the cursor pointer when it's inside the widget.

Examples

// You have somewhere:
PtWidget_t *ptwidget; // pointer to OnOffButton widget
// constructing OnOffButton
PhWidgets::OnOffButton oo_button(ptwidget);
// Display the crosshair cursor of AliceBlue color
// when the mouse pointer is over the button.
oo_button.Cursor = PhWidgets::Cursors::Cross;
oo_button.CursorColor = PhWidgets::Drawing::Colors::AliceBlue;
An on/off button that can be set or unset.
Definition: OnOffButton.h:23
@ Cross
The crosshair cursor.
Definition: Cursor.h:46
@ AliceBlue
System-defined color that has an ARGB value of #FFF0F8FF.
Definition: Color.h:31
See also

◆ Enabled

property<bool>::bind<Widget, &Widget::getEnabled, &Widget::setEnabled> PhWidgets::Widget::Enabled

Gets or sets a value indicating whether the widget can respond to user interaction.

Property Value

bool

true if the widget can respond to user interaction; otherwise, false. The default is true.

Remarks
With the Widget::Enabled property, you can enable or disable widgets at run time. For example, you can disable widgets that do not apply to the current state of the application. You can also disable a widget to restrict its use. For example, a Button can be disabled to prevent the user from clicking it. If a widget is disabled, it cannot be selected.
When a Container widget has its Widget::Enabled property set to false, all its contained widgets are disabled, as well. For example, if the user clicks on any of the widgets contained in a disabled Container widget, no events are raised.
Note
Setting the Widget::Enabled property to false does not disable the application's widget box or prevent the application Window from receiving the focus.
See also

◆ Focused

property<bool, property<>::ro>::bind<Widget, &Widget::getFocused> PhWidgets::Widget::Focused

Gets a value indicating whether the widget has input focus.

Property Value

bool

true if the widget has focus; otherwise, false.

See also

◆ HasChildren

property<bool, property<>::ro>::bind<Widget, &Widget::hasChildren> PhWidgets::Widget::HasChildren

Gets a value indicating whether the widget contains one or more child widgets.

Property Value

bool

true if the widget contains one or more child widgets; otherwise, false.

See also

◆ HasParent

property<bool, property<>::ro>::bind<Widget, &Widget::hasParent> PhWidgets::Widget::HasParent

Gets a value indicating whether the widget has parent.

Property Value

bool

true if the widget has parent; otherwise, false.

See also

◆ Height

phproperty<unsigned short>::bind<Widget, Arguments<unsigned short>::Scalar, Arguments<unsigned short>::Height> PhWidgets::Widget::Height

Gets or sets the height of the widget.

Property Value

unsigned short

The height of the widget in pixels.

Remarks
Changes made to the Widget::Height and Widget::Top property values cause the Widget::Bottom property value of the widget to change.
See also

◆ HelpTopic

property<std::string>::bind<Widget, &Widget::getHelpTopic, &Widget::setHelpTopic> PhWidgets::Widget::HelpTopic

Gets or sets the help topic of the widget.

Property Value

‍std::string

The help topic of the widget.

◆ IsRealized

property<bool, property<>::ro>::bind<Widget, &Widget::getIsRealized> PhWidgets::Widget::IsRealized

Gets or sets a value indicating whether the widget is realized.

Property Value

bool

true if the widget is realized; otherwise, false.

See also

◆ Left

property<short>::bind<Widget, &Widget::getLeft, &Widget::setLeft> PhWidgets::Widget::Left

Gets or sets the distance, in pixels, between the left edge of the widget and the left edge of its container's client area.

Property Value

short

An short representing the distance, in pixels, between the left edge of the widget and the left edge of its container's client area.

Remarks
The value of this property is equivalent to the x value of the Widget::Location property value of the widget.
Changes made to the Widget::Width and Widget::Left property values cause the Widget::Right property value of the widget to change.
See also

◆ Location

property<PhPoint_t>::bind<Widget, &Widget::getLocation, &Widget::setLocation> PhWidgets::Widget::Location

Gets or sets the coordinates of the upper-left corner of the widget relative to the upper-left corner of its container.

Property Value

PhPoint_t

The PhPoint_t that represents the upper-left corner of the widget relative to the upper-left corner of its container.

Remarks
Because the PhPoint_t struct is a value type, it is returned by value, meaning accessing the property returns a copy of the upper-left point of the widget. So, adjusting the x or y values of the PhPoint_t returned from this property will not affect the Widget::Left, Widget::Right, Widget::Top, or Widget::Bottom property values of the widget. To adjust these properties set each property value individually, or set the Widget::Location property with a new PhPoint_t.
If the Widget is a PhWidgets::Window, the Widget::Location property value represents the upper-left corner of the PhWidgets::Window in screen coordinates.
See also

◆ Parent

property<PtWidget_t*>::bind<Widget, &Widget::getParent, &Widget::setParent> PhWidgets::Widget::Parent

Gets or sets the parent container of the widget.

Property Value

PtWidget_t *

The pointer to PtWidget_t that represents the parent or container widget of the widget.

Exceptions
std::logic_errorin case widget couldn't be reparented; std::invalid_argument in case bad parent widget passed.
Remarks
Setting the Widget::Parent property value to nullptr removes the widget from the Widget::Widgets of its current parent widget.
Note
This property may and will return nullptr if current widget has no parent. Check widget.HasParent before assingning this property to Widget class if you are unsure that widget have parent at first place.

Examples

bool ReparentWidget(const PhWidgets::Widget &src, PhWidgets::Widget &dst)
{
if(src.HasParent == false) // check if button have parent
return false;
dst.Parent = src.Parent; // setting parent
return true;
}
int Button1Callback(PtWidget_t *ptwidget, void *, PtCallbackInfo_t * )
{
PhWidgets::Button button1(ptwidget);
PhWidgets::Window main_window(ABN_MAIN_WINDOW);
ReparentWidget(main_window, button1);
return 0;
}
property< PtWidget_t * >::bind< Widget, &Widget::getParent, &Widget::setParent > Parent
Gets or sets the parent container of the widget.
Definition: Widget.h:1867
property< bool, property<>::ro >::bind< Widget, &Widget::hasParent > HasParent
Gets a value indicating whether the widget has parent.
Definition: Widget.h:1731
An Application window that's managed by the Photon window manager.
Definition: Window.h:41
See also

◆ Position

phproperty<PhPoint_t>::bind<Widget, Arguments<PhPoint_t>::Struct, Arguments<PhPoint_t>::Position> PhWidgets::Widget::Position

Gets or sets the absolute coordinates of the upper-left corner of the widget.

Property Value

PhPoint_t

The PhPoint_t that represents the absolute coordinates of the upper-left corner of the widget.

Remarks
Because the PhPoint_t struct is a value type, it is returned by value, meaning accessing the property returns a copy of the upper-left point of the widget. So, adjusting the x or y values of the PhPoint_t returned from this property will not affect the Widget::Left, Widget::Right, Widget::Top, or Widget::Bottom property values of the widget. To adjust these properties set each property value individually, or set the Widget::Position property with a new PhPoint_t.
If the Widget is a PhWidgets::Window, the Widget::Position property value represents the upper-left corner of the PhWidgets::Window in screen coordinates.
See also

◆ resource

WidgetResourcesSingleton PhWidgets::Widget::resource

Resources of the Widget.

All resources of the Widget could be accessed by using PhWidgets::Widget::resource. As an example:

and so on...

There are two types of resources:

  • argument
  • callback

Each resource could be obtained using Widget::Arguments::$argument_tag$ or Widget::Callbacks::$callback_tag$ respectively.

Examples

// You have somewhere:
PtWidget_t *ptwidget; // pointer to widget
int ptwidget_realized_callback( PtWidget_t *, void *, PtCallbackInfo_t *); // callback
// constructing Widget
PhWidgets::Widget widget(ptwidget);
// get/set of widget width
unsigned short widget_width = widget.resource.argument[Widget::Arguments::width].get();
widget.resource.argument[Widget::Arguments::width].set(100);
// add/remove callback
widget.resource.callback[Widget::Callbacks::realized].add(ptwidget_realized_callback);
widget.resource.callback[Widget::Callbacks::realized].remove(ptwidget_realized_callback);

For convenient use of resources each widget has properties and events. So with properties the code snippet above could shrink to:

// You have somewhere:
PtWidget_t *ptwidget; // pointer to widget
int ptwidget_realized_callback( PtWidget_t *, void *, PtCallbackInfo_t *); // callback
// constructing Widget
PhWidgets::Widget widget(ptwidget);
// get/set of widget width
unsigned short widget_width = widget.Width;
widget.Width = 100;
// add/remove callback
widget.Realized += ptwidget_realized_callback;
widget.Realized -= ptwidget_realized_callback;

◆ Right

property<short, property<>::ro>::bind<Widget, &Widget::getRight> PhWidgets::Widget::Right

Gets the distance, in pixels, between the right edge of the widget and the left edge of its container's client area.

Property Value

short

An short representing the distance, in pixels, between the right edge of the widget and the left edge of its container's client area.

Remarks
The value of this property is equal to the sum of the Widget::Left property value, and the Widget::Width property value.
The Widget::Right property is a read-only property. You can manipulate this property value by changing the value of the Widget::Left or Widget::Width properties or calling the Widget::SetBounds methods.
See also

◆ Size

phproperty<PhDim_t>::bind<Widget, Arguments<PhDim_t>::Struct, Arguments<PhDim_t>::Dimension> PhWidgets::Widget::Size

Gets or sets the size of the widget.

Property Value

PhDim_t

The PhDim_t that represents the height and width of the widget in pixels.

Remarks
Because the PhDim_t struct is a value type, it is returned by value, meaning accessing the property returns a copy of the size of the widget. So, adjusting the w or h values of the PhDim_t returned from this property will not affect the Widget::Width or Widget::Height property values of the widget. To adjust these properties set each property value individually, or set the Widget::Size property with a new PhDim_t.
See also

◆ Tag

tag_property<Widget, &Widget::getTag, &Widget::setTag> PhWidgets::Widget::Tag

Gets or sets the resource that contains data about the widget.

Property Value

const void*

An const void * that contains data about the widget. The default is nullptr.

Examples

// You have somewhere:
PtWidget_t *ptwidget; // pointer to widget
using namespace PhWidgets;
// constructing Widget
Button button(ptwidget);
// note the difference - type passed to Widget::Tag property should be
// the same as requested type
// with Drawing::Colors::eColors enum:
button.Tag = Drawing::Colors::Red;
Drawing::Colors::eColor tag_color = button.Tag;
Drawing::Color color = tag_color;
// now lets try the same but with PhWidgets::Drawing::Color class:
button.Tag = Drawing::Color::FromARGB(0, 255, 0, 128); // constructing PhWidgets::Drawing::Color class
Drawing::Color color2 = button.Tag;
Represents an ARGB (alpha, red, green, blue) color.
Definition: Color.h:206
static Color FromARGB(unsigned char alpha, unsigned char red, unsigned char green, unsigned char blue)
Creates a Color class from the four ARGB component (alpha, red, green, and blue) values.
The main namespace for all widgets.
Definition: Basic.h:11
@ Red
System-defined color that has an ARGB value of #FFFF0000.
Definition: Color.h:144
Note
Widget::Tag could accept any pointer and copies data from it in widget Widget::Arguments::user_data resource. If you want to pass data by 'raw pointer to data' then use widget.Tag(ptr, size) method.
// constructing Widget
PhWidgets::Widget widget(ptwidget);
void *ptr = new char[100];
// set resource:
widget.Tag(ptr, 100 * sizeof(char));
// or like this:
widget.Tag.set(ptr, 100 * sizeof(char));
Attention
Do not provide just pointer for the Widget::Tag property to set if your intentions are to copy dynamic array! Use widget.Tag(ptr, size) method instead. See example below:
// constructing Widget
PhWidgets::Widget widget(ptwidget);
int *ptr = new int[42];
float fvalue;
double arr[20];
// right use to copy to Widget::Arguments::user_data:
widget.Tag(ptr, 42 * sizeof(int)); // copy 42 ints
widget.Tag = fvalue; // copy 1 float
widget.Tag = arr; // copy 20 double
// exotic but valid use of storing just pointer in widget not the data it points to
// copy 1 int* - only pointer!
widget.Tag = ptr;
// Note that property will return const int**.
const int **ptr_get = widget.Tag;
// where (*ptr_get) is the ptr passed
ptr == (*ptr_get); // true
Attention
This property returns just raw const void* that is casted to user-provided type so be really carefull with all casts! Make shure that you know the exact type hiding beneath the pointer or the behaviour is undefined.
Although the property will cover you in some cases with nullptr as a result if you will try to do some really unapropriate cast - do not rely on it much!
// constructing Widget
PhWidgets::Widget widget(ptwidget);
void *dptr = new double[42];
widget.Tag(dptr, 42 * sizeof(double)); // set to 42 doubles
// right:
const double *dptr_get = widget.Tag; // get
const void *vptr_get = widget.Tag; // get - always safe!
// undefined behaviour:
// const float *fptr_get = widget.Tag; // Wrong type! Do not do this!
// const MyCustomClass *obj_ptr_get = Widget.Tag; // UB get! Do not do this!
Remarks
Any pointer can be assigned to this property. A common use for the Widget::Tag property is to store data that is closely associated with the widget.
For example, if you have a widget that displays different colors, you might store a pointer to struct that contains the set of defined colors in that widget's Widget::Tag property so the colors can be accessed quickly.
See also
  • Widget::Arguments::user_data

◆ Top

property<short>::bind<Widget, &Widget::getTop, &Widget::setTop> PhWidgets::Widget::Top

Gets or sets the distance, in pixels, between the top edge of the widget and the top edge of its container's client area.

Property Value

short

An short representing the distance, in pixels, between the top edge of the widget and the top edge of its container's client area.

Remarks
The value of this property is equivalent to the y value of the Widget::Location property value of the widget.
Changes made to the Widget::Height and Widget::Top property values cause the Widget::Bottom property value of the widget to change.
See also

◆ Visible

property<bool>::bind<Widget, &Widget::getVisible, &Widget::setVisible> PhWidgets::Widget::Visible

Gets or sets a value indicating whether the widget and all its child widgets are displayed.

Property Value

bool

true if the widget and all its child widgets are displayed; otherwise, false. The default is true.

Remarks
Note that even if Widget::Visible is set to true, the widget might not be visible to the user if it is obscured behind other widgets.
See also

◆ WidgetFlags

phbitmask<long, Flags::type>:: bind<Widget, Arguments<long>::Flag, Arguments<long>::Flags> PhWidgets::Widget::WidgetFlags

Gets or sets flags inherited by all widgets.

Property Value

Flags::type

Flags that specifiy the style and behavior of a widget.

Note
This is bitmask property so you can use bitwise operations on it.
Remarks
Widgets use this property to specify the style and behavior of the widget. For example, the following line of code would enable ability to be selected.

Examples

widget.WidgetFlags |= Widget::Flags::Selectable;
@ Selectable
You can select (repeat, arm, disarm and activate) the widget. Widgets usually provide visual feedback...
Definition: Widget.h:838
See also

◆ Widgets

property<std::set<PhWidgets::Widget>, property<>::ro>::bind<Widget, &Widget::getWidgets> PhWidgets::Widget::Widgets

Gets the list of widgets contained within the widget.

Property Value

std::set<PhWidgets::Widget>

A std::set<PhWidgets::Widget> representing the list of widgets contained within the widget.

Remarks
A Widget can act as a parent to a list of widgets. For example, when several widgets are added to a Window, each of the widgets is a member of the std::set<PhWidgets::Widget> assigned to the Widget::Widgets property of the Window, which is derived from the Widget class.
You can manipulate the widgets in the std::set<PhWidgets::Widget> assigned to the Widget::Widgets property by using the methods available in the std::set<PhWidgets::Widget> class.
When adding several widgets to a parent widget, it is recommended that you call the SuspendLayout() method before initializing the widgets to be added. After adding the widgets to the parent widget, call the ResumeLayout() method. Doing so will increase the performance of applications with many widgets.
Use the Widget::Widgets property to iterate through all widgets of a form, including nested widgets. Use the GetNextWidget() method to retrieve the previous or next child widget in the tab order. Use the Container::ActiveWidget property to get or set the active widget of a Container widget.
See also

◆ Width

phproperty<unsigned short>::bind<Widget, Arguments<unsigned short>::Scalar, Arguments<unsigned short>::Width> PhWidgets::Widget::Width

Gets or sets the width of the widget.

Property Value

unsigned short

The width of the widget in pixels.

Remarks
Changes made to the Widget::Width and Widget::Left property values cause the Widget::Right property value of the widget to change.
See also

The documentation for this struct was generated from the following file: