CustomControls Package

The CustomControls built-in package supplies a set of fully owner-drawn controls — buttons, a form, a frame, a grid, a label, a slider, a textbox, and a timer — together with the framework on which they are built. Every visible pixel is rendered by the package itself rather than by Windows, so the look and feel is identical across systems and is configured entirely through a small vocabulary of style objects (Fill, Borders, Corners, TextRendering, …) rather than by toggling theme flags.

The package ships as two paired components: a CustomControls DESIGNER library — the framework half, source-side project CustomControls — that defines the rendering surface and the interface every custom control implements; and the Custom Controls package — source-side project CustomControlsPackage — that supplies the eight concrete Waynes… controls. The two are co-versioned with twinBASIC and always ship together; both are MIT-licensed.

Beyond providing ready-to-use controls, the package doubles as a worked example for authoring your own custom controls. The Waynes… classes implement the same ICustomControl interface that a hand-written control would, against the same CustomControlContext callback object and Canvas drawing surface — see the Framework page for the host-side contract.

Private Sub Form_Load()
    btnGo.Caption = "Continue"
    btnGo.NormalState.BackgroundFill.ColorPoints.SetSolidColor vbBlue
    btnGo.NormalState.Corners.SetAll tbCurve, 12
    txtName.Value = ""
End Sub

Private Sub btnGo_Click()
    MsgBox "Hello, " & txtName.Value
End Sub

Controls

  • WaynesButton – owner-drawn push-button with separate visual states for normal, hover, focused, and pressed
  • WaynesForm – top-level form for hosting custom controls; carries the WindowsOptions sub-object that drives the Win32 frame
  • WaynesFrame – rectangular container that fills its area with a configurable background
  • WaynesGrid – tabular data display with column headers, row headers, hover / selection states, and resizable columns
  • WaynesLabel – static text display with fill, text rendering, and caption
  • WaynesSlider – horizontal or vertical value slider with hover / focused states and a draggable block
  • WaynesTextBox – single-line editable text field with selection, caret, surrogate-pair awareness, and inline text decorators
  • WaynesTimer – non-visual timer that raises a Timer event at a programmable interval

Every concrete control implements ICustomControl and inherits a small set of layout-and-name members from an internal base class:

  • All controls expose Name, Left, Top, Width, Height, Anchors, Dock, and Visible.
  • Controls that can take keyboard focus (WaynesButton, WaynesGrid, WaynesSlider, WaynesTextBox) additionally expose TabIndex and TabStop.
  • WaynesForm instead exposes form-level members: FormDesignerId, Name, position / size, and the Controls collection.

These members are listed on each control’s own page; their definitions are identical and are not repeated separately.

Style objects

The visual style of every control is driven by a handful of small helper classes, instantiated automatically through Public WithEvents … properties. They are nested arbitrarily — a TextRendering contains a Fill for the text colour, which contains a Granularity and an array of FillColorPoint gradient stops; an array of Border objects describes how the outline of a control is stroked; and so on.

  • Anchors – which sides of a control are pinned to its container when the container is resized
  • Borders – one or more border strokes drawn around a control (including the single-stroke Border sub-object)
  • Corners – the four corner shapes and radii of a control (including the per-corner Corner sub-object)
  • Fill – the colour or gradient that paints a region (including the FillColorPoint / FillColorPoints gradient-stop sub-objects)
  • Line – a single grid-line or resizer-bar stroke; thinner shape than a full border
  • Padding – per-side padding around text inside a TextRendering
  • TextRendering – font, padding, fill, outlines, alignment, and overflow for the text drawn inside a control (including the FontStyle sub-object)

Every style object raises an OnChanged event whenever one of its fields is set, and the control that hosts it requests a repaint on each change — assigning style values at runtime triggers an immediate redraw.

Framework

For authoring your own custom controls or forms, the CustomControls DESIGNER half of the package supplies:

  • ICustomControl – the interface every custom control implements: Initialize, Destroy, Paint
  • ICustomForm – the analogous interface for custom form classes
  • CustomControlContext – callback object passed to Initialize; offers serializer access, repaint requests, timer creation, and focus changes
  • CustomFormContext – a CustomControlContext extended with Show and Close for form-class controls
  • CustomControlTimer – the timer returned by CustomControlContext.CreateTimer; carries Interval, Enabled, and an OnTimer event
  • CustomControlsCollection – the Controls collection on a form
  • Canvas – the drawing surface passed to Paint; the only way to put pixels into a custom control
  • SerializeInfo – the per-instance serializer reached via CustomControlContext.GetSerializer; used to deserialize designer-set property values and to query the runtime mode

Enumerations