Skip to content
Devin Samarin edited this page May 9, 2011 · 1 revision

Widgets are visual and interactive graphics that appear in a rectangular area on the screen. Users can interact with it.

Properties

event_mask

This is a bitmask of all the values of [[suit]].[[Event]] that the widget would like to be notified of.

name

This is a unique name that you may wish to give your widget for use with logging/debugging functions.

Methods

draw

Widget->draw( ([[suit]].[[Graphics]]) context )

When this function is called, the widget uses the provided context to update its' image on the screen. This is called by the toolkit when a redraw is needed. The widget should only draw within the bounds of it's allocation. The context is clipped to the allocation of the widget so nothing can spill over.

queue_redraw

Widget->queue_redraw()

Invalidates the current drawing of the widget so that the widget may be updated at the next available opportunity. Normally you would only use this function in widget implementations.

queue_resize

Widget->queue_resize()

This function is only for use in widget implementations. Flags a widget to have its size renegotiated; should be called when a widget for some reason has a new size request. For example, when you change the text in a Label, it queues a resize to ensure there's enough space for the new text.

get_request_mode

Widget->get_request_mode()

Gets whether the widget prefers a height-for-width layout or a width-for-height layout. Bin widgets generally propagate the preference of their child, container widgets need to request something either in context of their children or in context of their allocation capabilities.

get_preferred_width

Widget->get_preferred_width()

Returns an object with keys minimum and natural, representing the minimum and natural width that the widget would like to be in, given all the height it needs.

get_preferred_height

Widget->get_preferred_height()

Returns an object with keys minimum and natural, representing the minimum and natural height that the widget would like to be in, given all the width it needs.

get_preferred_width_for_height

Widget->get_preferred_width_for_height( (number) height )

Retrieves an object with keys minimum and natural for the widget's minimum and natural width if it would be given the specified height.

get_preferred_height_for_width

Widget->get_preferred_height_for_width( (number) width )

Retrieves an object with keys minimum and natural for the widget's minimum and natural height if it would be given the specified width.

set_allocation

Widget->set_allocation( ([[suit]].[[Allocation]]) allocation )

Sets the widget's allocation. This should not be used directly, but from within the parent's set_allocation method.

get_allocation

Widget->get_allocation()

Returns the widget's allocation.

event_mask_add

Widget->event_mask_add( ([[suit]].[[Event]]) bits )

Adds the specified bits of the events to listen for to the event mask.

// Start listening for mouse move and scroll events
this.event_mask_add(suit.Event.Motion | suit.Event.Scroll);

event_mask_sub

Widget->event_mask_sub( ([[suit]].[[Event]]) bits )

Removes the specified bits of the events to listen for from the event mask.

// Stop listening for mouse move and scroll events
this.event_mask_sub(suit.Event.Motion | suit.Event.Scroll);

lock

Widget->lock()

Channels all events solely to the widget, thereby 'locking' out other widgets from receiving events. You cannot call this function if another widget already has a lock.

unlock

Widget->unlock()

Removes the event lock on the widget.

Object Hierarchy

[[suit]].[[Object]]
	+--- [[suit]].Widget
		+--- [[suit]].[[Container]]
		+--- [[suit]].[[Label]]