Kōtuku
  • Gallery
  • API
  • Wiki
  • GitHub
    • Audio
    • Config
    • Core
    • Display
    • Document
    • Font
    • HTTP
    • Network
    • Regex
    • SVG
    • Tiri
    • Vector
    • XML
    • XQuery
    • XRandR
      • Audio
      • MP3
      • Sound
      • File
      • MetaClass
      • Module
      • StorageDevice
      • Task
      • Thread
      • Time
      • Compression
      • CompressedStream
      • Config
      • LZMAStream
      • Script
      • Tiri
      • XML
      • XQuery
      • Controller
      • BlurFX
      • ColourFX
      • CompositeFX
      • ConvolveFX
      • DisplacementFX
      • FilterEffect
      • FloodFX
      • ImageFX
      • LightingFX
      • MergeFX
      • MorphologyFX
      • OffsetFX
      • RemapFX
      • SourceFX
      • TurbulenceFX
      • WaveFunctionFX
      • Scintilla
      • Bitmap
      • Clipboard
      • Display
      • Document
      • Font
      • Image
      • Pointer
      • Surface
      • SVG
      • ClientSocket
      • HTTP
      • NetClient
      • NetLookup
      • NetServer
      • NetSocket
      • Proxy
      • Gradient
      • GradientConic
      • GradientContour
      • GradientDiamond
      • GradientDiffusion
      • GradientDistal
      • GradientGouraud
      • GradientLinear
      • GradientMesh
      • GradientRadial
      • GradientVoronoi
      • Vector
      • VectorClip
      • VectorColour
      • VectorEllipse
      • VectorFilter
      • VectorGradient
      • VectorGroup
      • VectorImage
      • VectorPath
      • VectorPattern
      • VectorPolygon
      • VectorRectangle
      • VectorScene
      • VectorShape
      • VectorSpiral
      • VectorText
      • VectorTransition
      • VectorViewport
      • VectorWave
      • Linux Builds
      • Windows Builds
      • Customising Your Build
      • Kōtuku Objects
      • Kōtuku In Depth
      • Kōtuku Design Patterns
      • Coding With AI
      • Regex Manual
      • XML Comparisons
      • Tiri Reference Manual
      • Config API
      • Defer Syntax
      • GUI API
      • HTTP Server API
      • I/O API
      • JSON API
      • OAuth API
      • Options API
      • Proxy Server API
      • Tempus API
      • URL API
      • VFX API
      • Widgets
      • RIPL Reference Manual
      • Origo
      • Flute / Unit Testing
      • Tuku
      • Embedded Document Format
      • TDL Reference Manual
      • TDL Tools
      • Action Reference Manual
      • System Error Codes

Surface Class

Manages display regions for two-dimensional rendered graphics.

The Surface class represents a rectangular region in the display hierarchy. It manages positioning, visibility, redraws, backing storage and focus for layered user interfaces. Surfaces work with Bitmap objects for rendered pixel data and with the Pointer class for pointer interaction.

A top-level surface is normally backed by an application window on hosted platforms such as Windows and Linux. For full screen displays and Android, a top-level surface can cover the display without a separate host window. Child surfaces are attached to a parent surface, creating a hierarchy whose ordering, clipping, redraw and input behaviour is managed by this class.

Building nested surface-only interfaces is supported, but most applications should use surfaces as hosts for VectorScene objects. This keeps interfaces resolution independent and matches the rendering path that Kōtuku optimises most heavily.

Surface content is preserved with a backing store where required. Surfaces that share a backing store are composited through their parent, while surfaces that need independent redraw, opacity, video memory or cursor behaviour can own a separate bitmap buffer.

Structure

The Surface class consists of the following fields:

Access
NameTypeComment
 AbsXINTThe absolute horizontal position of a surface object.

This field returns the surface's horizontal position relative to the top-level surface in its local hierarchy.

Writing AbsX moves the surface so that its absolute horizontal position matches the supplied value. The surface must be initialised before this field can be changed.

 AbsYINTThe absolute vertical position of a surface object.

This field returns the surface's vertical position relative to the top-level surface in its local hierarchy.

Writing AbsY moves the surface so that its absolute vertical position matches the supplied value. The surface must be initialised before this field can be changed.

 BitsPerPixelINTDefines the pixel depth used by the surface buffer.

Set BitsPerPixel before initialisation to request a fixed pixel depth for the surface buffer. If the requested depth differs from the display or parent buffer, the graphics system converts pixels when the surface is drawn, which is usually slower than using the native display depth.

Reading this field returns the active tracked depth for the surface. A value of zero is returned if the surface is not available in the display surface list.

 BottomINTReturns the bottom-most coordinate of a surface object, Y + Height.
 BufferOBJECTIDRefers to the Bitmap that stores the surface's graphics.

Each surface is assigned a bitmap buffer for drawing. In many cases this buffer is shared between multiple surfaces, so clients should treat it as an implementation detail unless no public drawing API provides the required access.

The bitmap is an off-screen buffer. Direct changes to it are not exposed to the display automatically.

 ColourRGB8Defines the background colour used when clearing the surface.

Set this field when a surface should be cleared to a solid background colour before drawing. String values may use #RRGGBB hexadecimal notation or Red,Green,Blue decimal components.

A surface that does not define a colour is not cleared during redraw. In that case, draw the full background manually to avoid stale or uninitialised graphics appearing in exposed areas.

A preset colour can be disabled by writing NULL, which clears the colour by setting its alpha component to zero. Changing Colour does not schedule a redraw.

 CursorPTCSets the pointer image used while the mouse is over the surface.

The pointer automatically switches to the selected cursor image when it enters the surface area.

The available cursor image settings are listed in the Pointer⇒CursorID documentation.

The Cursor field may be written with a valid cursor name or cursor ID.

NameDescription
PTC::CROSSHAIRThe cross hair is used for targeting specific pixel points (common in paint programs).
PTC::CUSTOMWorks in conjunction with the SetCustomCursor() function to represent a program defined bitmap.
PTC::DEFAULTThe default cursor (usually an arrow pointing to the upper left).
PTC::DRAGGABLEUsed to indicate that a surface or object can be dragged by the user.
PTC::END
PTC::HANDThe hand cursor is often used for indicating click-able content (hyper-links, icons etc).
PTC::HAND_LEFTSimilar to the standard hand cursor, but points to the left.
PTC::HAND_RIGHTSimilar to the standard hand cursor, but points to the right.
PTC::INVISIBLEThe cursor graphic is invisible (but will continue to operate as normal in all other respects).
PTC::MAGNIFIERRepresents a magnifying glass.
PTC::NO_CHANGE
PTC::PAINTBRUSHThe paintbrush cursor is typically employed by paint programs.
PTC::SIZE_BOTTOMSizing cursor - for resizing the bottom edge of any rectangular area.
PTC::SIZE_BOTTOM_LEFTSizing cursor - for resizing the bottom left corner of any rectangular area.
PTC::SIZE_BOTTOM_RIGHTSizing cursor - for resizing the bottom right corner of any rectangular area.
PTC::SIZE_LEFTSizing cursor - for resizing the left edge of any rectangular area.
PTC::SIZE_RIGHTSizing cursor - for resizing the right edge of any rectangular area.
PTC::SIZE_TOPSizing cursor - for resizing the top edge of any rectangular area.
PTC::SIZE_TOP_LEFTSizing cursor - for resizing the top left corner of any rectangular area.
PTC::SIZE_TOP_RIGHTSizing cursor - for resizing the top right corner of any rectangular area.
PTC::SIZINGMulti-directional sizing cursor - for resizing in any direction.
PTC::SLEEPThe sleep cursor is used to inform the user that the computer is busy.
PTC::SPLIT_HORIZONTALThe horizontal split cursor is typically used for splitting rectangles in half, or dragging a horizontal split within a large rectangular space.
PTC::SPLIT_VERTICALThe vertical split cursor is typically used for splitting rectangles in half, or dragging a vertical split within a large rectangular space.
PTC::STOPThe stop cursor is used to inform the user that an operation is not possible (e.g. drag and drop to an unsupported object area).
PTC::TEXTThe text cursor is popular for the precise positioning of text cursors.
 DisplayOBJECTIDRefers to the Display object that manages the surface's graphics.

All surfaces belong to a Display object that manages drawing to the user's video display. This field identifies the display that owns the surface.

 DragOBJECTIDDefines the Surface that moves when this surface is dragged.

Set this field to the Surface that should move when the user starts a click-drag operation over the current surface. For example, a window title bar would set Drag to the window surface. A surface may also set Drag to itself for icon-like or small draggable objects.

Set Drag to zero to disable drag handling.

 DragStatusDRAGReports the current drag state when dragging is enabled.

Read this field to determine whether the surface is idle, anchored for dragging or actively being moved.

NameDescription
DRAG::ANCHORThe surface is being dragged and the mouse pointer is anchored to the surface.
DRAG::NONEThe surface is not being dragged.
DRAG::NORMALThe surface is being dragged.
 FlagsRNFControls optional surface behaviour.

Use Flags to enable optional surface behaviours. Preserve existing flags when updating this field, typically by combining the current value with the flags being added.

Read-only flags cannot be changed by writing this field. Initialisation-only flags can be set before the surface is initialised, but are preserved once the surface is active.

NameDescription
RNF::AFTER_COPYRead-only. Indicates that after-copy mode has been enabled.
RNF::ASPECT_RATIOWhen resizing, enforce the aspect ratio as defined by the diagonal from Surface⇒MinWidth, Surface⇒MinHeight to Surface⇒MaxWidth, Surface⇒MaxHeight.
RNF::AUTO_QUITThe surface object will send a quit message to its supporting process when and if the Close method is called. This flag is typically used when a surface object represents a core window for an application.
RNF::COMPOSITEDo not copy background information into the surface buffer - composite on the fly instead
RNF::DISABLEDThis flag is set if the Disable action has been called on a surface object. Calling the Enable action will turn off the flag setting.
RNF::FIXED_BUFFERPasses the NEVER_SHRINK option to the surface bitmap
RNF::FIXED_DEPTHThe target buffer always remains at the same depth
RNF::FULL_SCREENAllow the surface to open as a new screen display
RNF::GRAB_FOCUSHelps application windows manage the user's focus within the window
RNF::HAS_FOCUSRead-only. If set, this flag indicates that the surface object currently has the focus.
RNF::HOSTDefine host on initialisation to create a container that can host surfaces from other processes.
RNF::IGNORE_FOCUSFocus is diverted directly to the parent
RNF::INIT_ONLYSynonym for HOST | TRANSPARENT | DISABLED | PRECOPY | VIDEO | FIXED_BUFFER | PERVASIVE_COPY | FIXED_DEPTH | FULL_SCREEN | IGNORE_FOCUS
RNF::NO_FOCUSPrevents any kind of focussing on this object; no circumvention is possible
RNF::NO_HORIZONTALTurns off all horizontal movement (applies to the Move() action only).
RNF::NO_PRECOMPOSITEDo not copy background information into the surface buffer - composite on the fly instead
RNF::NO_VERTICALTurns off all vertical movement (applies to the Move() action only).
RNF::PERVASIVE_COPYThis flag can be set in conjunction with after-copy mode. It forces the after-copy support routine to copy graphics over the entire surface area, rather than avoiding the graphics of child surfaces.
RNF::POST_COMPOSITEDo not copy background information into the surface buffer - composite on the fly instead
RNF::PRECOPYEnables pre-copy mode, which means that all graphics behind the surface object are copied into the bitmap buffer prior to any redraw. This mode can have a noticable impact on CPU time when drawing.
RNF::READ_ONLYSynonym for HAS_FOCUS | CURSOR | AFTER_COPY
RNF::STICKYPrevents any response to the Move action. It can be circumvented by writing to coordinate fields directly.
RNF::STICK_TO_BACKEnable if the surface object must stick to the back of its container.
RNF::STICK_TO_FRONTEnable if the surface object must stick to the front of its container.
RNF::TOTAL_REDRAWPerform a total redraw of the entire surface when drawing - no partial draws
RNF::TRANSPARENTEnables transparency, which means that the internal graphics routines will ignore this surface during redraws. It is typically used when creating containers that will host other surfaces.
RNF::VIDEOSet this flag if you would like the surface object's data to be managed in video memory only. While this can give some speed advantages, be warned that video based surfaces are limited to write-only operations.
RNF::VISIBLEIf a surface object is visible to the user, the VISIBLE flag will be set. If the flag is not set, the surface object is hidden.
RNF::VOLATILESynonym for PRECOPY | AFTER_COPY | CURSOR
RNF::WRITE_ONLYSet this flag if you would like the surface object's data to be managed in video memory only. While this can give some speed advantages, be warned that video based surfaces are limited to write-only operations.
 HeightUNITDefines the height of a surface object.

Set Height to change the surface height. Alternatively, call Resize() to change Width and Height together.

By default the value is a fixed coordinate unit. With the FD_SCALED flag, the value is treated as a multiplier of the parent surface height.

A plain read returns the height resolved to a fixed pixel count, even when Height was defined as a scaled value. Request the value with the FD_SCALED flag to retrieve it as a multiplier of the parent height instead. Reading the field verbatim (with FD_PURE), or before initialisation, returns the value exactly as it was last defined.

Changing Height on a visible surface updates the displayed area immediately, including any child surfaces that need to be redrawn or resized.

Before initialisation, setting Height to zero or less clears the height dimension so that Y and YOffset can define the height dynamically. After initialisation, values of zero or less are invalid.

 MaxHeightINTPrevents the height of a surface object from exceeding a certain value.

Set MaxHeight to limit the maximum height that can be applied through resizing. Resize() cannot increase the surface beyond this value.

Direct writes to Height bypass this limit.

 MaxWidthINTPrevents the width of a surface object from exceeding a certain value.

Set MaxWidth to limit the maximum width that can be applied through resizing. Resize() cannot increase the surface beyond this value.

Direct writes to Width bypass this limit.

 MinHeightINTPrevents the height of a surface object from shrinking beyond a certain value.

Set MinHeight to limit the minimum height that can be applied through resizing. Resize() cannot shrink the surface below this value.

Direct writes to Height bypass this limit. Values less than 1 are clamped to 1.

 MinWidthINTPrevents the width of a surface object from shrinking beyond a certain value.

Set MinWidth to limit the minimum width that can be applied through resizing. Resize() cannot shrink the surface below this value.

Direct writes to Width bypass this limit. Values less than 1 are clamped to 1.

 ModalINTSets the surface as modal (prevents user interaction with other surfaces).

If set to true, the surface becomes the program's modal surface when shown. This prevents interaction with other surfaces until the modal surface is hidden, destroyed or no longer modal. Children of the modal surface remain interactive.

Clearing this field restores the previous modal surface if one was recorded.

 OpacityDOUBLEDefines the translucency applied when drawing a surface.

Opacity is expressed as a normalised multiplier. The default value of 1.0 draws the surface as fully opaque. Lower values make the surface more transparent. Values outside the allowable range are clipped.

Non-opaque surfaces are drawn by rendering the surface content to its internal buffer and blending it with the background graphics. This can be costly, and the pre-copy feature may give better results for some compositions.

Translucency can significantly increase CPU usage.

 ParentOBJECTIDIdentifies the parent Surface.

Child surfaces use this field to identify their parent. Top-level surfaces have no parent.

If Parent is not set before initialisation, the surface class searches the ownership chain for the nearest Surface. Set Parent to zero before initialisation to disable that automatic lookup. An initialised child surface may be reparented, but a top-level surface cannot be converted into a child surface after initialisation.

 PopOverOBJECTIDKeeps a surface in front of another surface in the Z order.

Set PopOver before initialisation to the object ID of a sibling Surface that this surface should stay in front of. For dialog windows, combine this field with Modal to keep the dialog in front and prevent interaction with other surfaces in the current program.

Set PopOver to zero before initialisation to use normal Z-order behaviour.

This field cannot be changed after initialisation. The value must identify a Surface; otherwise ERR::InvalidObject is returned.

 RightINTReturns the right-most coordinate of a surface object, X + Width.
 RootOBJECTIDSurface that is acting as a root for many surface children (useful when applying translucency)
 UserFocusINTRefers to the surface object that has the current user focus.

Returns the object ID of the surface that has the primary user focus. Returns zero if no surface has focus.

 VisibleINTIndicates the visibility of a surface object.

Read this field to determine whether the surface itself is marked visible. A true value means the surface is shown; false means it is hidden.

Effective on-screen visibility also depends on the parent chain. A visible child of a hidden parent is not displayed.

Set this field, or call Hide() and Show(), to change the surface visibility.

 WidthUNITDefines the width of a surface object.

Set Width to change the surface width. Alternatively, call Resize() to change Width and Height together.

By default the value is a fixed coordinate unit. With the FD_SCALED flag, the value is treated as a multiplier of the parent surface width.

A plain read returns the width resolved to a fixed pixel count, even when Width was defined as a scaled value. Request the value with the FD_SCALED flag to retrieve it as a multiplier of the parent width instead. Reading the field verbatim (with FD_PURE), or before initialisation, returns the value exactly as it was last defined.

Changing Width on a visible surface updates the displayed area immediately, including any child surfaces that need to be redrawn or resized.

Before initialisation, setting Width to zero or less clears the width dimension so that X and XOffset can define the width dynamically. After initialisation, values of zero or less are invalid.

 WindowHandleAPTRRefers to the surface's window handle (host dependent).

This field exposes the host window handle for platforms that provide one. It is currently relevant when creating a primary surface within an X11 window manager or Microsoft Windows.

Set WindowHandle before initialisation to attach the surface to an existing native window. The field is immutable after initialisation.

 WindowTypeSWINDefines how a top-level surface is represented by a hosted desktop.

This field affects hosted desktops such as Windows and X11. It only applies to top-level surfaces that have no parent. Child surfaces ignore this field, and surfaces created inside the desktop area treat the desktop as their parent.

Custom surfaces remain responsible for their own window controls, such as title bars and resize borders.

NameDescription
SWIN::HOSTDefault to the standard hosted window mode with full titlebar, borders and taskbar representation.
SWIN::ICON_TRAYCreate a borderless (custom) window with icon tray representation.
SWIN::NONECreate a borderless (custom) window with no UI representation.
SWIN::TASKBARCreate a borderless (custom) window with taskbar representation.
 XUNITDetermines the horizontal position of a surface object.

Set X to change the horizontal position of the surface relative to its parent.

By default the value is a fixed coordinate unit. With the FD_SCALED flag, the value is treated as a multiplier of the parent surface width.

A plain read returns the horizontal position resolved to a fixed pixel coordinate relative to the parent, even when X was defined as a scaled value. Request the value with the FD_SCALED flag to retrieve it as a multiplier of the parent width instead. Reading the field verbatim (with FD_PURE), or before initialisation, returns the value exactly as it was last defined. Read AbsX for the absolute horizontal pixel position within the surface hierarchy.

Changing X on a visible surface updates its position immediately. If XOffset also defines the right-hand edge, the surface width is recalculated to preserve that offset.

 XOffsetUNITDetermines the horizontal offset of a surface object.

XOffset defines a distance from the right-hand edge of the parent surface.

When X is set and Width is not set, XOffset makes the surface width dynamic. The width extends from X to the parent width minus XOffset.

When Width is set, XOffset positions the surface from the parent right-hand edge: X = ParentWidth - Width - XOffset.

A plain read returns the offset resolved to a fixed pixel distance, even when the offset was defined as a scaled value. If no offset has been defined but both X and Width are present, the offset is derived from the parent width. Request the value with the FD_SCALED flag to retrieve it as a multiplier of the surface width. Reading the field verbatim (with FD_PURE), or before initialisation, returns the value exactly as it was last defined.

 YUNITDetermines the vertical position of a surface object.

Set Y to change the vertical position of the surface relative to its parent.

By default the value is a fixed coordinate unit. With the FD_SCALED flag, the value is treated as a multiplier of the parent surface height.

A plain read returns the vertical position resolved to a fixed pixel coordinate relative to the parent, even when Y was defined as a scaled value. Request the value with the FD_SCALED flag to retrieve it as a multiplier of the parent height instead. Reading the field verbatim (with FD_PURE), or before initialisation, returns the value exactly as it was last defined. Read AbsY for the absolute vertical pixel position within the surface hierarchy.

Changing Y on a visible surface updates its position immediately.

 YOffsetUNITDetermines the vertical offset of a surface object.

YOffset defines a distance from the bottom edge of the parent surface.

When Y is set and Height is not set, YOffset makes the surface height dynamic. The height extends from Y to the parent height minus YOffset.

When Height is set, YOffset positions the surface from the parent bottom edge: Y = ParentHeight - Height - YOffset.

A plain read returns the offset resolved to a fixed pixel distance, even when the offset was defined as a scaled value. If no offset has been defined but both Y and Height are present, the offset is derived from the parent height. Request the value with the FD_SCALED flag to retrieve it as a multiplier of the surface height. Reading the field verbatim (with FD_PURE), or before initialisation, returns the value exactly as it was last defined.

Actions

The following actions are currently supported:

ActivateShows a surface object on the display.
ERR acActivate(*Object)

For top-level surfaces, Activate() delegates to Show() so that the hosted display window becomes visible. Child surfaces are not affected by this action.

DisableDisables a surface object.
ERR acDisable(*Object)

Disabled surfaces remain visible but cannot accept user focus through Focus().

DrawRedraws the contents of a surface object.
ERR acDraw(*Object, DOUBLE X, DOUBLE Y, DOUBLE Width, DOUBLE Height)
ParameterDescription
XThe X position of the region to be drawn.
YThe Y position of the region to be drawn.
WidthThe width of the region to be drawn.
HeightThe height of the region to be drawn.

Calling the Draw action on a surface object will send redraw messages to every hook that has been attached to the surface object's drawing system. This has the effect of redrawing all graphics within the surface object. The procedure is as follows:

  1. If the surface object's Colour field has been set, the target bitmap will be cleared to that colour.
  2. If the surface is volatile, graphics from background surfaces will be copied to the target bitmap.
  3. Subscribers to the surface object are now called via their hooks so that they can draw to the bitmap.
  4. The bitmap is copied to the video display buffer to complete the process.

Please be aware that:

  • If the target surface contains child surfaces, they will not be redrawn unless they are volatile (using special effects such as transparency, or using the region flag will make a surface volatile).
  • If the surface object has not had its background colour set, or if the object is not volatile, the bitmap contents will not be automatically cleared (this is advantageous in situations where a particular object will clear the surface area first).
EnableEnables a disabled surface object.
ERR acEnable(*Object)

Enable() clears the disabled state so that the surface can receive focus and normal interaction again.

FocusChanges the primary user focus to the surface object.
ERR acFocus(*Object)

Focus() makes the surface the primary focus target and notifies the affected focus subscribers. Focus is propagated through the surface hierarchy so that parent surfaces also record inherited focus.

The request is ignored if the surface is disabled, marked with RNF::NO_FOCUS, or outside the active modal surface. If RNF::IGNORE_FOCUS is set, the focus request is forwarded to the parent surface instead.

HideHides a surface object from the display.
ERR acHide(*Object)

Hide() clears the visible state. For top-level surfaces it hides the hosted display window; for child surfaces it invalidates and exposes the covered parent area so that the background is redrawn. Hiding a modal surface also restores the previous modal surface, or clears modal mode if there is no previous surface.

LostFocusInforms a surface object that it has lost the user focus.
ERR acLostFocus(*Object)

LostFocus() clears the RNF::HAS_FOCUS flag when the surface currently holds focus. If the surface has already lost focus, the action returns without further notification.

MoveMoves a surface object to a new display position.
ERR acMove(*Object, DOUBLE DeltaX, DOUBLE DeltaY, DOUBLE DeltaZ)
ParameterDescription
DeltaXThe number of units to move along the X axis.
DeltaYThe number of units to move along the Y axis.
DeltaZThe number of units to move along the Z axis.

Move() applies relative X and Y deltas to the surface. The request honours movement restrictions such as RNF::STICKY, RNF::NO_HORIZONTAL, RNF::NO_VERTICAL and the configured movement limits. Child surfaces are clamped within their parent surface when limits are active.

Queued Move() requests for the same surface may be combined before drawing occurs. After a successful move, redimension subscribers are notified with the surface's updated position and size.

MoveToBackMoves a surface object to the back of its container.
ERR acMoveToBack(*Object)

For child surfaces, MoveToBack() reorders the surface within its parent while preserving child hierarchy, bitmap ownership constraints, pop-over relationships and RNF::STICK_TO_BACK ordering. Top-level surfaces delegate the request to their hosted display window.

MoveToFrontMoves a surface object to the front of its container.
ERR acMoveToFront(*Object)

For child surfaces, MoveToFront() raises the surface within its parent while preserving child hierarchy, cursor ordering, bitmap ownership constraints, pop-over relationships and RNF::STICK_TO_FRONT ordering. Top-level surfaces delegate the request to their hosted display window.

MoveToPointMoves a surface object to an absolute coordinate.
ERR acMoveToPoint(*Object, DOUBLE X, DOUBLE Y, DOUBLE Z, MTF Flags)
ParameterDescription
XThe new X position to move the object to.
YThe new Y position to move the object to.
ZThe new Z position to move the object to.
FlagsSet the relevant MTF flag for each provided parameter.

MoveToPoint() converts the supplied absolute X and Y values into relative movement and forwards the request to Move(). Coordinates are changed only for axes enabled by the MTF::X and MTF::Y flags.

RedimensionMoves and resizes a surface object in a single action call.
ERR acRedimension(*Object, DOUBLE X, DOUBLE Y, DOUBLE Z, DOUBLE Width, DOUBLE Height, DOUBLE Depth)
ParameterDescription
XThe new X position to apply to the target object.
YThe new Y position to apply to the target object.
ZThe new Z position to apply to the target object.
WidthThe new width of the target object.
HeightThe new height of the target object.
DepthThe new depth of the target object.
ResizeAlters the dimensions of a surface object.
ERR acResize(*Object, DOUBLE Width, DOUBLE Height, DOUBLE Depth)
ParameterDescription
WidthThe new width of the object.
HeightThe new height of the object.
DepthThe new depth of the object.
SaveImageSaves the graphics of a surface object.
ERR acSaveImage(*Object, OBJECTID Dest, CLASSID ClassID)
ParameterDescription
DestRefers to an object that will receive the encoded image data.
ClassIDThe Image class to use for encoding the image data.

SaveImage() renders the visible content of a surface into an image and writes it to the destination object supplied in the action arguments. Visible child surfaces in the captured region are included in the resulting image.

The image format is selected with the ClassID argument. Supported values are Image-compatible image classes such as CLASSID::JPEG and CLASSID::IMAGE (PNG). If ClassID is CLASSID::NIL, the default Image implementation is used.

Errors returned while copying individual child surfaces can be propagated from CopySurface().

Error Codes
OkayOperation successful.
SearchA search routine in this function failed
AccessObjectAttempting to lock an object failed
NewObjectThe intermediate image object could not be created.
NullArgsFunction call missing argument value(s)
CreateResourceThe intermediate image object could not be initialised or saved.
ShowShows a surface object on the display.
ERR acShow(*Object)

Show() makes the surface visible. For top-level surfaces it shows the hosted display window; for child surfaces it sets the visible flag, redraws the surface and exposes the affected area. If the surface is modal, it becomes the active modal surface until it is hidden.

Methods

The following methods are currently supported:

AddCallbackInserts a function hook into the drawing process of a surface object.
ERR drw::AddCallback(OBJECTPTR Object, FUNCTION Callback)
ParameterDescription
CallbackCallback routine to insert or move in the draw callback list.

The AddCallback() method installs a draw callback for custom rendering directly into a surface. During a redraw, callbacks are invoked in subscription order and receive the target Bitmap for the surface.

The C/C++ callback prototype is ERR Function(APTR Context, objSurface *Surface, objBitmap *Bitmap, APTR Meta). The Tiri callback prototype is function draw(Surface, Bitmap).

Callbacks may draw to the bitmap as they would to any other Bitmap. Use the Surface Width and Height fields to determine the drawable area, and respect the bitmap clipping region when writing pixels directly.

Calling AddCallback() with a callback that is already registered for the same object moves that callback to the end of the callback list, making it run after the callbacks that remain before it.

Error Codes
OkayOperation successful.
NullArgsFunction call missing argument value(s)
ExposeToDisplayRedraws a surface region to the display, preferably from its graphics buffer.
ERR drw::ExposeToDisplay(OBJECTPTR Object, INT X, INT Y, INT Width, INT Height, EXF Flags)
ParameterDescription
XX coordinate of the expose area.
YY coordinate of the expose area.
WidthWidth of the expose area.
HeightHeight of the expose area.
FlagsOptional flags.

Call the ExposeToDisplay() method to copy a surface region to the display. The functionality is identical to that of the ExposeSurface() function. Please refer to it for further documentation.

Error Codes
OkayOperation successful.
NotifiedUnknown error code.
InvalidateRegionRedraws all of the content in a surface object.
ERR drw::InvalidateRegion(OBJECTPTR Object, INT X, INT Y, INT Width, INT Height)
ParameterDescription
XX coordinate of the region to invalidate.
YY coordinate of the region to invalidate.
WidthWidth of the region to invalidate.
HeightHeight of the region to invalidate.

Invalidating a surface object will cause everything within a specified area to be redrawn. This includes child surface objects that intersect with the area that you have specified. Parent regions that overlap are not included in the redraw.

To quickly redraw an entire surface object's content, call this method directly without supplying an argument structure. If you want to redraw a surface object and ignore all of its surface children then you should use the Draw action instead of this method.

If you want to refresh a surface area to the display then you should use the ExposeToDisplay() method instead. Exposing will use the graphics buffer to refresh the graphics, thus avoiding the speed loss of a complete redraw.

Error Codes
OkayOperation successful.
AccessMemoryFailed to access the internal surface list.
NotifiedUnknown error code.
MinimiseFor hosted surfaces only, this method will minimise the surface to an icon.
ERR drw::Minimise(OBJECTPTR Object)

If a surface is hosted in a desktop window, calling Minimise() performs the host platform's default minimise action on that window. On Microsoft Windows, this normally minimises the window to the taskbar.

Calling Minimise() on a surface that is already in the minimised state may result in the host window being restored to the desktop. This behaviour is platform dependent and should be manually tested to confirm its reliability on the host platform.

RemoveCallbackRemoves a callback previously inserted by AddCallback().
ERR drw::RemoveCallback(OBJECTPTR Object, FUNCTION Callback)
ParameterDescription
CallbackCallback routine to remove, or leave undefined to remove all associated callback routines for the caller.

RemoveCallback() removes a draw callback that was previously inserted by AddCallback().

This method is scope restricted. A caller can remove only callbacks associated with its own object context, so callbacks added by other objects are not affected.

Error Codes
OkayOperation successful.
SearchThe requested callback was not found.
ScheduleRedrawSchedules a redraw operation for the next frame.
ERR drw::ScheduleRedraw(OBJECTPTR Object, INT RefreshRate)
ParameterDescription
RefreshRateOptional refresh rate in frames per second. If not specified, the refresh rate from the display is used.

Use ScheduleRedraw() to mark a surface for redraw on the next frame cycle. The delay is governed by the chosen RefreshRate, which is measured in frames per second. If a RefreshRate is not specified, the frame rate is derived from the display.

Specifying a custom RefreshRate is recommended when processing an animation at a lower frame rate than that of the display would be acceptable.

Scheduling with this method over Draw() (immediate mode) is recommended when a cluster of redraw events may occur within a tight time period, and it would be inefficient to draw those changes to the display individually. Repeated redraw requests made to the target surface are coalesced until the scheduled redraw is processed.

Redraw schedules do not collapse in nested surfaces. If both a surface and one of its children are scheduled, two redraw operations may be triggered where one would otherwise suffice. Target the top-level surface only in such instances.

Error Codes
OkayOperation successful.
ArgsAn invalid refresh rate was calculated for the timer subscription.
SystemLockedThe timer subsystem could not be locked.
InvalidStateThe surface is marked for termination.
SetDisplayChanges the screen resolution (applies to top-level surface objects only).
ERR drw::SetDisplay(OBJECTPTR Object, INT X, INT Y, INT Width, INT Height, INT InsideWidth, INT InsideHeight, INT BitsPerPixel, DOUBLE RefreshRate, INT Flags)
ParameterDescription
XThe horizontal coordinate/offset for the display.
YThe vertical coordinate/offset for the display.
WidthThe width of the display.
HeightThe height of the display.
InsideWidthThe page width of the display must be the same as Width or greater.
InsideHeightThe page height of the display must be the same as Height or greater.
BitsPerPixelBits per pixel - 15, 16, 24 or 32.
RefreshRateRefresh rate.
FlagsOptional flags.

The SetDisplay method is used to change the screen resolution of the top-level surface object (which represents the screen display). It allows you to set the size of the display and you may also change the bitmap depth and the monitor's refresh rate. If successful, the change is immediate.

This method exercises some intelligence in adjusting the display to your requested settings. For instance, if the requested width and/or height is not available, the closest display setting will be chosen.

This method does not work on anything other than top-level surface objects. The current top-level surface object is usually named "SystemSurface" by default and can be searched for by that name.

Error Codes
OkayOperation successful.
ArgsInvalid arguments passed to function
InvalidStateThe surface is not a top-level surface object.
SetOpacityAlters the opacity of a surface object.
ERR drw::SetOpacity(OBJECTPTR Object, DOUBLE Value, DOUBLE Adjustment)
ParameterDescription
ValueNew opacity multiplier, used when Adjustment is zero.
AdjustmentValue to add to the current opacity multiplier, or zero to assign Value directly.

SetOpacity() changes the opacity multiplier for a surface that owns its bitmap buffer. The final value is clamped by the Opacity field setter. If the surface is visible, a redraw is queued so the new opacity is reflected on the display without blocking the caller.

Error Codes
OkayOperation successful.
NoSupportThe surface does not own the bitmap buffer required for independent opacity.
NullArgsFunction call missing argument value(s)
Surface class documentation © Paul Manias © 2003-2026

DRAG Type

NameDescription
DRAG::ANCHORThe surface is being dragged and the mouse pointer is anchored to the surface.
DRAG::NONEThe surface is not being dragged.
DRAG::NORMALThe surface is being dragged.
Surface module documentation © Paul Manias © 2003-2026

EXF Type

Optional flags for the ExposeSurface() function.

NameDescription
EXF::ABSOLUTEThe supplied coordinates for exposure are absolute (relative to the display).
EXF::ABSOLUTE_COORDSThe supplied coordinates for exposure are absolute (relative to the display).
EXF::CHILDRENIf set, all child surfaces that intersect with exposed region will be included in the expose operation.
EXF::REDRAW_VOLATILERedraw every volatile object that intersects with the expose region, including internal volatile children.
EXF::REDRAW_VOLATILE_OVERLAPOnly redraw volatile objects that obscure the expose region from a position outside of the target surface and its children. Useful if no redrawing has occurred in the surface, but the surface has moved to a new position and the parents need to be redrawn.
Surface module documentation © Paul Manias © 2003-2026

JET Type

JET constants are documented in GetInputEvent()

NameDescription
JET::ABS_XYThe X, Y values are defined as absolute coordinates, relative to the top-left of the display
JET::BUTTON_1Left mouse button; XBox A button, PS square button. Value is pressure sensitive, ranging between 0 - 1.0 (0 is released, 1.0 is fully depressed)
JET::BUTTON_10Non-specific button assignment
JET::BUTTON_2Right mouse button; XBox X button, PS cross button
JET::BUTTON_3Middle mouse button; XBox Y button, PS triangle
JET::BUTTON_4Alt. mouse button 1; XBox B button, PS circle
JET::BUTTON_5Alt. mouse button 2
JET::BUTTON_6Non-specific button assignment
JET::BUTTON_7Non-specific button assignment
JET::BUTTON_8Non-specific button assignment
JET::BUTTON_9Non-specific button assignment
JET::CROSSED_INThis message is sent by the input system when the mouse pointer enters an area for the first time. The message value refers to the object ID of the container being monitored for movement
JET::CROSSED_OUTThis message is sent by the input system when the mouse pointer leaves an area. The message value refers to the object ID of the container being monitored for movement
JET::DEVICE_TILT_XYController tilted on the X/Y axis. Value indicates angle, -ve = left, +ve = right
JET::DEVICE_TILT_ZController is rising or falling. Value expressed as 'speed',
JET::DISPLAY_EDGERecently supplied input occurred at the edge of the display
JET::PEN_TILT_XYPen tilt angle. 0 is pointing down directly with nib at bottom, 0.5 is 90 degrees, 1.0 is inversed (eraser at bottom)
JET::PRESSUREAmount of pressure applied, ranges from 0 (none) to 1.0 (normal) and possibly higher if user presses hard enough
JET::WHEELMouse wheel rotation - the value generally reflects the number of 'clicks' rotated on the wheel
JET::WHEEL_TILTSome mouse wheels can be tilted to the left or right. Ranges from -1.0 to +1.0
Surface module documentation © Paul Manias © 2003-2026

JTYPE Type

JTYPE flags are used to categorise input types

NameDescription
JTYPE::ANALOGAnalog movement (ranging from -1.0 to 1.0)
JTYPE::ANCHOREDCursor has been anchored with LockCursor()
JTYPE::BUTTONInput is a physical button or switch
JTYPE::CROSSINGCrossing events manage the entering and leaving of an area
JTYPE::DBL_CLICKSet by the input system if the Type is a button and the button has been clicked in quick succession so as to be classed as a double-click
JTYPE::DIGITALD-Pad or digital joystick source (restricted to +/- 1)
JTYPE::DRAGGEDSet if sufficient movement occurred between the original click and its point of release (usually requires a 3 or more pixel difference)
JTYPE::DRAG_ITEMThis special flag is set by the input system if the pointer is click-dragging an object at the time of the event
JTYPE::EXT_MOVEMENTExtended or indirect movement information. This covers all types of movement that are unconnected to coordinate positioning - mouse wheel movement and pen tilt are two such examples
JTYPE::MOVEMENTX/Y coordinate movement only. Movement such as the wheel mouse spinning is not covered by this type as it does not influence the coordinate system
JTYPE::REPEATEDInput is a repeated entry (i.e. user is holding down a button and a repetition timer is being triggered)
JTYPE::SECONDARYIndicates to the receiver of this message that it is not the primary/original recipient
Surface module documentation © Paul Manias © 2003-2026

PTC Type

Predefined cursor styles

NameDescription
PTC::CROSSHAIRThe cross hair is used for targeting specific pixel points (common in paint programs).
PTC::CUSTOMWorks in conjunction with the SetCustomCursor() function to represent a program defined bitmap.
PTC::DEFAULTThe default cursor (usually an arrow pointing to the upper left).
PTC::DRAGGABLEUsed to indicate that a surface or object can be dragged by the user.
PTC::END
PTC::HANDThe hand cursor is often used for indicating click-able content (hyper-links, icons etc).
PTC::HAND_LEFTSimilar to the standard hand cursor, but points to the left.
PTC::HAND_RIGHTSimilar to the standard hand cursor, but points to the right.
PTC::INVISIBLEThe cursor graphic is invisible (but will continue to operate as normal in all other respects).
PTC::MAGNIFIERRepresents a magnifying glass.
PTC::NO_CHANGE
PTC::PAINTBRUSHThe paintbrush cursor is typically employed by paint programs.
PTC::SIZE_BOTTOMSizing cursor - for resizing the bottom edge of any rectangular area.
PTC::SIZE_BOTTOM_LEFTSizing cursor - for resizing the bottom left corner of any rectangular area.
PTC::SIZE_BOTTOM_RIGHTSizing cursor - for resizing the bottom right corner of any rectangular area.
PTC::SIZE_LEFTSizing cursor - for resizing the left edge of any rectangular area.
PTC::SIZE_RIGHTSizing cursor - for resizing the right edge of any rectangular area.
PTC::SIZE_TOPSizing cursor - for resizing the top edge of any rectangular area.
PTC::SIZE_TOP_LEFTSizing cursor - for resizing the top left corner of any rectangular area.
PTC::SIZE_TOP_RIGHTSizing cursor - for resizing the top right corner of any rectangular area.
PTC::SIZINGMulti-directional sizing cursor - for resizing in any direction.
PTC::SLEEPThe sleep cursor is used to inform the user that the computer is busy.
PTC::SPLIT_HORIZONTALThe horizontal split cursor is typically used for splitting rectangles in half, or dragging a horizontal split within a large rectangular space.
PTC::SPLIT_VERTICALThe vertical split cursor is typically used for splitting rectangles in half, or dragging a vertical split within a large rectangular space.
PTC::STOPThe stop cursor is used to inform the user that an operation is not possible (e.g. drag and drop to an unsupported object area).
PTC::TEXTThe text cursor is popular for the precise positioning of text cursors.
Surface module documentation © Paul Manias © 2003-2026

RNF Type

Switches for the Surface class' Flags field.

NameDescription
RNF::AFTER_COPYRead-only. Indicates that after-copy mode has been enabled.
RNF::ASPECT_RATIOWhen resizing, enforce the aspect ratio as defined by the diagonal from Surface⇒MinWidth, Surface⇒MinHeight to Surface⇒MaxWidth, Surface⇒MaxHeight.
RNF::AUTO_QUITThe surface object will send a quit message to its supporting process when and if the Close method is called. This flag is typically used when a surface object represents a core window for an application.
RNF::COMPOSITEDo not copy background information into the surface buffer - composite on the fly instead
RNF::DISABLEDThis flag is set if the Disable action has been called on a surface object. Calling the Enable action will turn off the flag setting.
RNF::FIXED_BUFFERPasses the NEVER_SHRINK option to the surface bitmap
RNF::FIXED_DEPTHThe target buffer always remains at the same depth
RNF::FULL_SCREENAllow the surface to open as a new screen display
RNF::GRAB_FOCUSHelps application windows manage the user's focus within the window
RNF::HAS_FOCUSRead-only. If set, this flag indicates that the surface object currently has the focus.
RNF::HOSTDefine host on initialisation to create a container that can host surfaces from other processes.
RNF::IGNORE_FOCUSFocus is diverted directly to the parent
RNF::INIT_ONLYSynonym for HOST | TRANSPARENT | DISABLED | PRECOPY | VIDEO | FIXED_BUFFER | PERVASIVE_COPY | FIXED_DEPTH | FULL_SCREEN | IGNORE_FOCUS
RNF::NO_FOCUSPrevents any kind of focussing on this object; no circumvention is possible
RNF::NO_HORIZONTALTurns off all horizontal movement (applies to the Move() action only).
RNF::NO_PRECOMPOSITEDo not copy background information into the surface buffer - composite on the fly instead
RNF::NO_VERTICALTurns off all vertical movement (applies to the Move() action only).
RNF::PERVASIVE_COPYThis flag can be set in conjunction with after-copy mode. It forces the after-copy support routine to copy graphics over the entire surface area, rather than avoiding the graphics of child surfaces.
RNF::POST_COMPOSITEDo not copy background information into the surface buffer - composite on the fly instead
RNF::PRECOPYEnables pre-copy mode, which means that all graphics behind the surface object are copied into the bitmap buffer prior to any redraw. This mode can have a noticable impact on CPU time when drawing.
RNF::READ_ONLYSynonym for HAS_FOCUS | CURSOR | AFTER_COPY
RNF::STICKYPrevents any response to the Move action. It can be circumvented by writing to coordinate fields directly.
RNF::STICK_TO_BACKEnable if the surface object must stick to the back of its container.
RNF::STICK_TO_FRONTEnable if the surface object must stick to the front of its container.
RNF::TOTAL_REDRAWPerform a total redraw of the entire surface when drawing - no partial draws
RNF::TRANSPARENTEnables transparency, which means that the internal graphics routines will ignore this surface during redraws. It is typically used when creating containers that will host other surfaces.
RNF::VIDEOSet this flag if you would like the surface object's data to be managed in video memory only. While this can give some speed advantages, be warned that video based surfaces are limited to write-only operations.
RNF::VISIBLEIf a surface object is visible to the user, the VISIBLE flag will be set. If the flag is not set, the surface object is hidden.
RNF::VOLATILESynonym for PRECOPY | AFTER_COPY | CURSOR
RNF::WRITE_ONLYSet this flag if you would like the surface object's data to be managed in video memory only. While this can give some speed advantages, be warned that video based surfaces are limited to write-only operations.
Surface module documentation © Paul Manias © 2003-2026

RT Type

NameDescription
RT::ROOTCan be used by window surfaces to identify themselves as a root layer.
Surface module documentation © Paul Manias © 2003-2026

SWIN Type

Options for the Surface WindowType field.

NameDescription
SWIN::HOSTDefault to the standard hosted window mode with full titlebar, borders and taskbar representation.
SWIN::ICON_TRAYCreate a borderless (custom) window with icon tray representation.
SWIN::NONECreate a borderless (custom) window with no UI representation.
SWIN::TASKBARCreate a borderless (custom) window with taskbar representation.
Surface module documentation © Paul Manias © 2003-2026

InputEvent Structure

FieldTypeDescription
Nextconst struct InputEvent *Next event in the chain
ValueDOUBLEThe value associated with the Type
TimestampINT64PreciseTime() of the recorded input
RecipientIDOBJECTIDSurface that the input message is being conveyed to
OverIDOBJECTIDSurface that is directly under the mouse pointer at the time of the event
AbsXDOUBLEAbsolute horizontal position of mouse cursor (relative to the top left of the display)
AbsYDOUBLEAbsolute vertical position of mouse cursor (relative to the top left of the display)
XDOUBLEHorizontal position relative to the surface that the pointer is over - unless a mouse button is held or pointer is anchored - then the coordinates are relative to the click-held surface
YDOUBLEVertical position relative to the surface that the pointer is over - unless a mouse button is held or pointer is anchored - then the coordinates are relative to the click-held surface
DeviceIDOBJECTIDThe hardware device that this event originated from
TypeJETJET constant that describes the event
FlagsJTYPEBroad descriptors for the given Type (see JTYPE flags). Automatically defined when delivered to the pointer object
MaskJTYPEMask to use for checking against subscribers
Surface class documentation © Paul Manias © 2003-2026