WidgetGetSkinBorder

Syntax

Border = WidgetGetSkinBorder(Widget, Component$, Property$)

Description

Retrieves a border object defined by the skin for the specified widget, component, and property. This function specifically looks for properties whose parsed value corresponds to a border definition (e.g., properties like `border`, `border-top`, etc.).

Parameters

Widget
The handle of the ProGUI widget.

Component$
The name of the component part of the widget (e.g., "", "thumb").

Property$
The name of the skin property that defines the border (e.g., "border", "border-left").

Return Value

Returns a handle to a ProGUI border object if a valid border definition is found in the skin for the given widget, component, state, and property. Returns #Null or #False if the widget is invalid, the property doesn't exist, the property doesn't define a valid border, or the defined border has no visible style or width.

Remarks

This function simplifies retrieving border definitions from the skin. It internally uses WidgetGetSkinData() and checks if the returned data type is #PG_Skin_Type_Border. If a valid border definition is found, it configures and returns a usable border object handle. This handle can then be used with drawing functions like DrawBorder(). The returned border object is managed internally and should not be freed manually using FreeBorder(). The appearance depends on the widget's current state set via WidgetSetSkinState().

Example

IncludeFile "ProGUI_PB.pbi"

StartProGUI()

; Define a border in the skin
SkinSetValue("myBorderWidget", "", "", "border", "5px outset red")
SkinSetValue("myBorderWidget", "hover", "", "border", "10px groove blue")
SkinSetValue("myBorderWidget", "", "", "transition", "border 0.5s")

Procedure DrawBorderWidget(Widget, EventType, *EventData.PG_EventDraw, *UserData)
  ; Get the border defined by the 'border' property for the current state
  MyBorder = WidgetGetSkinBorder(Widget, "", "border")
  If MyBorder
    ; Draw the retrieved border
    DrawBorder(MyBorder, 0, 0, *EventData\width, *EventData\height, 1.0)
  Else
    ; Draw a default if skin doesn't provide one
    DrawBoxStroke(0, 0, *EventData\width, *EventData\height, RGB(100, 100, 100))
  EndIf
EndProcedure

Procedure MouseBorderWidget(Widget, EventType, *EventData.PG_EventMouse)
    Select EventType
        Case #PG_Event_MouseEnter : WidgetSetSkinState(Widget, "hover")
        Case #PG_Event_MouseLeave : WidgetSetSkinState(Widget, "")
    EndSelect
EndProcedure

MyWindow = CreateWindow(0, 0, 200, 150, "Get Skin Border")
RootLayout = WindowGetLayout(MyWindow)
LayoutSetPadding(RootLayout, 10)

If MyWindow
  BorderWidget = CreateWidget(0, 0, #PG_Widget_FitContent, #PG_Widget_FitContent)
  WidgetSetMinWidth(BorderWidget, 50)
  WidgetSetMinHeight(BorderWidget, 50)
  WidgetSetClass(BorderWidget, "myBorderWidget")
  AddEventHandler(BorderWidget, #PG_Event_Draw, @DrawBorderWidget())
  AddEventHandler(BorderWidget, #PG_Event_MouseEnter, @MouseBorderWidget())
  AddEventHandler(BorderWidget, #PG_Event_MouseLeave, @MouseBorderWidget())

  WindowShow(MyWindow, #True, #PG_Window_ScreenCentered)

  Repeat : Event = WaitWindowEvent() : Until Event = #PB_Event_CloseWindow
EndIf

StopProGUI()

See Also

WidgetGetSkinData, WidgetSetSkinState, SkinSetValue, CreateBorder, DrawBorder

Supported OS

Windows, Linux