The style that the gadget should use. If this is not specified, the gadget will use the values stored in the global defaultGadgetStyle object. The gadget will copy the properties of the style into its own internal style object. data. If no object is specified the gadget will use the default style.

Adds a gadget to this gadget's child stack. The gadget is added to the top of the stack. Note that the gadget can only be added if it is not already a child of another gadget.

If the gadget is a decoration, the gadget will be inserted to the bottom of the stack instead of the top. Decorations are always at the bottom of the gadget stack. This is automatic and cannot be overridden.

Once a gadget has been added to another, it becomes the responsibility of Woopsi to delete it once it it no longer needed. Attempts to manually call "delete" on child gadgets will result in crashes due to dereferencing deleted objects.

Get the current physical display co-ordinate for the supplied y co-ordinate. Woopsi treats the two displays as two viewports on the same logical space. The lower half of the range of y co-ordinates is displayed on the bottom screen, whilst the upper half of the range of y co-ordinates is displayed on the top screen. This function converts back into a value that can be displayed on one of the screens. Should be used in conjunction with calculatePhysicalScreenNumber() to work out which screen to draw on.

Checks if the supplied rect collides with this gadget. Co-ordinates must be in Woopsi-space.

Parameters:

rect

A rect to check for collisions with.

Returns:

True if a collision occurred.

bool WoopsiUI::Gadget::checkCollisionWithForegroundRects

(

s16

x,

s16

y

)

const [protected]

Checks if the supplied co-ordinates collide with a portion of this gadget that is not obscured by its siblings or ancestors, but that may be obscured by its children. Co-ordinates should be in Woopsi-space.

Inserts a gadget into this gadget's child stack at the bottom of the stack. Note that the gadget can only be added if it is not already a child of another gadget.

Once a gadget has been added to another, it becomes the responsibility of Woopsi to delete it once it it no longer needed. Attempts to manually call "delete" on child gadgets will result in crashes due to dereferencing deleted objects.

Invalidate the visible region cache for all gadgets below the supplied gadget in this gadget's child stack. This will cause those gadgets to recalculate their visible regions next time they try to draw themselves. This should be called when the gadget passed as a pointer has swapped positions with another gadget in the gadget array (ie. it has moved towards the front of the screen or towards the back).

Parameters:

gadget

A pointer to a child gadget.

void WoopsiUI::Gadget::invalidateVisibleRectCache

(

)

Mark this gadget's visible region cache as invalid, and do the same to its child gadgets.

const bool WoopsiUI::Gadget::isBeingDragged

(

)

const [inline]

Is the gadget being dragged?

Returns:

True if the gadget is currently being dragged.

const bool WoopsiUI::Gadget::isBorderless

(

)

const [inline]

Does the gadget have a border?

Returns:

True if the gadget does not have a border.

const bool WoopsiUI::Gadget::isClicked

(

)

const [inline]

Is the gadget clicked?

Returns:

True if the gadget is currently clicked.

const bool WoopsiUI::Gadget::isDecoration

(

)

const [inline]

Is the gadget a decoration? Decoration gadgets are children of, but also an essential component of, another gadget. They are always at the start of the child gadget array, so will always be at the bottom of the gadget stack. They can be thought of as background gadgets.

Returns:

True if the gadget is a decoration.

const bool WoopsiUI::Gadget::isDeleted

(

)

const

Has the gadget been marked for deletion? This function recurses up the gadget hierarchy and only returns true if all of the gadgets in the ancestor chain are not deleted. Gadgets marked for deletion are automatically deleted and should not be interacted with.

Are the gadget's edges permeable or solid? Permeable gadgets do not enforce their dimensions on the co-ordinates and dimensions of child gadgets. For example, windows belonging to non-permeable screens cannot be dragged outside the screen. Windows belonging to permeable screens *can* be dragged outside their parent screen.

Marks a particular rect for drawing. Can be called instead of markRectsDamaged() if only a portion of a gadget has changed. The rect is automatically clipped to the visible portions of the gadget. Its co-ordinates should be in gadget co-ordinates (ie. relative to the top-left corner of the gadget, which is (0,0)). It will automatically be converted to Woopsi co-ordinates.

Gets a pointer to a new instance of the GraphicsPort class to allow drawing within this gadget's client space. The GraphicsPort can only draw within the supplied region.

The GraphicsPort object must be deleted when it is no longer required. Drawing is clipped only to the supplied rect. If the rect is not within the visible regions of this gadget graphical anomalies will occur. This should only be called by the Woopsi hierarchy.

Called when the gadget is double-clicked. Override this when creating new gadgets if the gadget should exhibit additional behaviour when it is double-clicked. To change the conditions that apply in detecting a double-click, override the isDoubleClicked() method.

Redraws the region of the gadget represented by rect. Rect should be supplied in Woopsi-space co-ordinates and should be pre-clipped to the visible regions of the gadget. This function should only ever be called by the DisplayController.

Parameters:

rect

The rect to draw.

bool WoopsiUI::Gadget::release

(

s16

x,

s16

y

)

Release this gadget at the supplied co-ordinates.

Parameters:

x

X co-ordinate of the release.

y

Y co-ordinate of the release.

Returns:

True if the release was successful.

bool WoopsiUI::Gadget::remove

(

)

Remove this gadget from Woopsi's gadget hierarchy. Returns responsibility for deleting the gadget back to the developer. Does not unregister the gadget from the VBL system.

The x co-ordinate of the context menu, relative to the topmost screen on the bottom display.

y

The y co-ordinate of the context menu, relative to the topmost screen on the bottom display.

void WoopsiUI::Gadget::startDragging

(

s16

x,

s16

y

)

[protected]

Notify this gadget that it is being dragged, and set its drag point.

Parameters:

x

The x co-ordinate of the drag position relative to this gadget.

y

The y co-ordinate of the drag position relative to this gadget.

void WoopsiUI::Gadget::stopDragging

(

s16

x,

s16

y

)

[protected]

Notify this gadget that it is no longer being dragged.

Parameters:

x

The x co-ordinate at which dragging stopped.

y

The y co-ordinate at which dragging stopped.

void WoopsiUI::Gadget::stopModal

(

)

[inline]

Stop the gadget running modally.

virtual bool WoopsiUI::Gadget::swapDepth

(

)

[virtual]

Swap the depth of this gadget. Compares the gadget's depth with all non-decoration sibling gadgets that it overlaps. If it is not at the front of the overlapping pile, it is moved to the front. If it is at the front of the overlapping pile, it moves the gadget to the back of the pile.

Returns:

True if the swap was successful.

See also:

swapGadgetDepth()

bool WoopsiUI::Gadget::unshelve

(

)

Moves the gadget back into the hierarchy and marks it for redraw. Gadgets shown in this way will be unpartioned and will be processed again.