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")

SkinSetValue("myBorderWidget", "", "mycomponent", "border", "5px outset blue")
SkinSetValue("myBorderWidget", "hover", "mycomponent", "border", "15px groove red")
SkinSetValue("myBorderWidget", "hover", "mycomponent", "border-radius", "20px")
SkinSetValue("myBorderWidget", "", "mycomponent", "transition", "border 1.5s ease-out-bounce, border-radius 1.5s ease-out-bounce")

Procedure DrawBorderWidget(Widget, EventType, *EventData.PG_EventDraw, *UserData)
  ; Widgets by default render the skin border automatically (and all other properties) for the main 'component', use this for rendering individual components/parts
  
  size = 50
  
  ; Get the border defined by the 'border' property for the current state of 'mycomponent'
  MyBorder = WidgetGetSkinBorder(Widget, "mycomponent", "border")
  If MyBorder
    ; Draw the retrieved border
    DrawBorder(MyBorder, *EventData\width / 2 - size / 2, *EventData\height / 2 - size / 2, size, size, 1.0)
  Else
    ; Draw a default if skin doesn't provide one
    DrawBoxStroke(*EventData\width / 2 - size / 2, *EventData\height / 2 - size / 2, size, size, RGB(100, 100, 100))
  EndIf
EndProcedure

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

MyWindow = CreateWindow(0, 0, 250, 200, "Get Skin Border")
LayoutSetPadding(#Null, 10) ; Set the current layout padding

If MyWindow
  BorderWidget = CreateWidget(0, 0, 100, 100)
  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_WindowShow_ScreenCentered)

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

StopProGUI()

See Also

WidgetGetSkinData, WidgetSetSkinState, SkinSetValue, CreateBorder, DrawBorder

Supported OS

Windows, Linux