Widgets Overview
Widgets are the fundamental building blocks of the user interface in ProGUI, representing individual UI elements like buttons, text labels, input fields, or custom interactive areas. They are placed within Layouts, which manage their size and position.
Key functionalities include:
- Creation: Widgets are created using CreateWidget() for standard ProGUI-rendered elements or CreateOsWidget() to wrap native operating system controls. Specific widgets like CreateScrollBar() and CreateWebView() provide convenient constructors.
- Properties: Functions are available to set and get various widget properties,
including:
- Basic Attributes: Name (WidgetSetName(), WidgetGetName()), Class (WidgetSetClass(), WidgetGetClass()), User Data (WidgetSetUserData(), WidgetGetUserData()).
- Appearance: Skin (WidgetSetSkin(), WidgetGetSkin(), WidgetGetSkinData()), Border (WidgetSetBorder()), Opacity (WidgetSetOpacity(), WidgetGetOpacity()).
- Layout Control: Size (WidgetSetWidth(), WidgetSetHeight(), WidgetGetWidth(), WidgetGetHeight()), Minimum Size (WidgetSetMinWidth(), WidgetSetMinHeight(), WidgetGetMinWidth(), WidgetGetMinHeight()), Margins (WidgetSetMargin(), etc.), Justification (WidgetSetJustify()), Alignment (WidgetSetAlign()), Grid Placement (WidgetSetColumnStart(), WidgetSetRowSpan(), etc.).
- Position: Read-only actual position (WidgetGetX(), WidgetGetY()). Use WidgetResize() or layout properties to change position.
- Visibility & Interaction: Control if a widget is displayed and interactive using WidgetShow() and flags like
#PG_Widget_Hide,#PG_Widget_NoDraw,#PG_Widget_NoMouse. Set the mouse cursor with WidgetSetCursor(). - Mouse Capture: Capture mouse input exclusively for a widget using WidgetSetMouseCapture() and release it with WidgetReleaseMouseCapture().
- Drawing: Widgets are drawn automatically by the layout system. Custom drawing is
done via the
#PG_Event_Drawevent. WidgetRedraw() flags a widget for redrawing, and WidgetUpdate() forces its layout to recalculate. - Hierarchy: Widgets reside within layouts. A widget can have its own layout assigned using WidgetSetLayout() to contain child widgets. Get the parent window using WidgetGetParentWindow().
- Destruction: Remove a widget and free its resources using WidgetFree().
- Events: Widgets are primary targets for UI events like mouse clicks, movement, drawing, and skinning animations. Use AddEventHandler() to attach callback procedures.