IWidget

Description

interface Tinman.Engine.Widgets.IWidget

Base interface for general-purpose application widgets.

Usually, an IApplication hosts one or more IWidget objects. Application input events are forwarded to widgets unmodified, i.e. the widget is responsible for translating them to its Bounds as necessary (e.g. using a BoundedInput object). Widgets are not required to limit their rendering to their bounds.

Public / Methods

Initialize


[ThrowAny]
public method Initialize → ()

returns → bool

true if the object has been initialized,
false if the object has already been initialized before.

Initializes the object, if necessary.

Screenshot


public method Screenshot → (1)

result in : WidgetScreenshotDelegate

[not-null]
The screenshot pixels will be passed to this delegate.

Takes a screenshot the next time this widget is rendered.

SettingsLoadTry


public method SettingsLoadTry → (1)

name opt : string = null

Name of the JSON configuration file. If null or empty, 'Settings.json' will be used.

returns → bool

true if the settings have been loaded, false if not.

Tries to load the settings of this widget, ignoring errors.

SettingsSaveTry


public method SettingsSaveTry → (1)

name opt : string = null

Name of the JSON configuration file. If null or empty, 'Settings.json' will be used.

returns → bool

true if the settings have been saved, false if not.

Tries to save the settings of this widget, ignoring errors.

Public / Attributes

ActualBounds


public attribute ActualBounds → (get)

value : Box2I

The actual pixel bounds or Box2I.Empty.

Returns the actual pixel bounds of this widget.

Bounds


public attribute Bounds → (get,set)

value : IWidgetBounds

[not-null]
The pixel bounds.

The pixel bounds of this widget.

MouseCursor


public attribute MouseCursor → (get)

value : MouseCursor

The mouse cursor

The mouse cursor to show for this widget.

SettingsPath


public attribute SettingsPath → (get,set)

value : Path

Canonical path to the settings directory or null.

Path to a directory that this widget can use to store own data and settings.

The settings path may only be set before Initialize is called on the widget. Afterwards, the settings path cannot be changed.

Extensions

Run


[OwnerThis]
public static method Run → (5)

source in : string

[not-empty]
The error source to use in case an exception is thrown.

context in : IGraphicsContextFactory

[not-null]
The graphics context factory to use.

window in : IApplicationWindow

[not-null]
The application window to use.

frameRateLimit opt : int32 = 100

Frame rate limit (see IApplicationInfo.FrameRateLimit).

sleepOnIdle opt : bool = true

Honor ApplicationLoopResult.Idle by sleeping for a short time?

returns → TinmanError

The error in case of a crash, null if the application has ended normally.

Runs this IWidget in a separate window.

SettingsLoad


public static method SettingsLoad → (1)

name opt : string = null

Name of the JSON configuration file. If null or empty, 'Settings.json' will be used.

returns → Path

Canonical path of the settings file that has been loaded or null if there were no previously saved settings or if the widget does not have a settings directory.

Loads the settings of this widget.

IOException

If an I/O error has occurred while reading the settings file.

ValidatingException

If the contents of the settings file is malformed.

SettingsSave


public static method SettingsSave → (1)

name opt : string = null

Name of the JSON configuration file. If null or empty, 'Settings.json' will be used.

returns → Path

Canonical path of the settings file that has been loaded or null if the widget does not have a settings directory.

Saves the settings of this widget.

IOException

If an I/O error has occurred while writing the settings file.

ToApplication


[OwnerReturn] [OwnerThis]
public static method ToApplication → (1)

frameRateLimit opt : int32 = 100

Frame rate limit (see IApplicationInfo.FrameRateLimit).

returns → WidgetApplication

The application object.

Wraps this IWidget in an IApplication object.