Class TCastleRectangleControl

Unit

Declaration

type TCastleRectangleControl = class(TCastleUserInterface)

Description

Fill a rectangle on screen with given color or theme image.

Hierarchy

Overview

Methods

Public constructor Create(AOwner: TComponent); override;
Public destructor Destroy; override;
Public procedure Render; override;
Public function Press(const Event: TInputPressRelease): boolean; override;
Public function Release(const Event: TInputPressRelease): boolean; override;
Public function Motion(const Event: TInputMotion): boolean; override;
Public function PropertySections(const PropertyName: String): TPropertySections; override;

Properties

Public property Color: TCastleColor read FColor write SetColor;
Public property ThemeImage: TThemeImage read FThemeImage write SetThemeImage; deprecated 'use TCastleImageControl to display images';
Public property UseThemeImage: boolean read FUseThemeImage write SetUseThemeImage default false; deprecated 'use TCastleImageControl to display images';
Public property InterceptInput: boolean read FInterceptInput write FInterceptInput default false; deprecated 'in each case, there should be a cleaner way to disable something from processing the input';
Published property ColorPersistent: TCastleColorPersistent read FColorPersistent ;

Description

Methods

Public constructor Create(AOwner: TComponent); override;

This item has no description.

Public destructor Destroy; override;

This item has no description.

Public procedure Render; override;

This item has no description. Showing description inherited from TCastleUserInterface.Render.

Render a control. Called only when Exists and GLInitialized, you can depend on it in the implementation of this method.

Do not explicitly call this method. Instead, render controls by adding them to the TCastleContainer.Controls list, or render them explicitly (for off-screen rendering) by TCastleContainer.RenderControl. This is method should only be overridden in your own code.

Before calling this method we always set some OpenGL state, and you can depend on it (and you can carelessly change it, as it will be reset again before rendering other control).

OpenGL state always set:

  • Viewport is set to include whole container.

  • Depth test is off.

  • (For fixed-function pipeline:) The 2D orthographic projection is always set at the beginning. Useful for 2D controls, 3D controls can just override projection matrix, e.g. use CastleRenderContext.PerspectiveProjection.

  • (For fixed-function pipeline:) The modelview matrix is set to identity. The matrix mode is always modelview.

  • (For fixed-function pipeline:) The raster position is set to (0,0). The (deprecated) WindowPos is also set to (0,0).

  • (For fixed-function pipeline:) Texturing, lighting, fog is off.

Beware that GLSL RenderContext.CurrentProgram has undefined value when this is called. You should always set it, before making direct OpenGL drawing calls (all the engine drawing routines of course do it already, this is only a concern if you make direct OpenGL / OpenGLES calls).

Public function Press(const Event: TInputPressRelease): boolean; override;

This item has no description. Showing description inherited from TCastleUserInterface.Press.

Handle press or release of a key, mouse button or mouse wheel. Return True if the event was somehow handled, which prevents from passing this event to other UI controls.

When implementing in descendants it is best to override it like this:

function TMyControl.Press(const Event: TInputPressRelease): boolean;
begin
  Result := inherited;
  if Result then Exit; // exit if ancestor already handled event

  if Event.IsKey(keyEnter) then
  begin
    // do something in reaction on Enter
    Exit(ExclusiveEvents); // ExclusiveEvents is true by default
  end;

  if Event.IsMouseButton(buttonLeft) then
  begin
    // do something in reaction on Enter
    Exit(ExclusiveEvents); // ExclusiveEvents is true by default
  end;
end;

Note that releasing of the mouse wheel is not reported now by any backend. Only releasing of keys and mouse buttons is reported.

The events PreviewPress and PreviewRelease are passed first to the parent control, before children have a chance to process this event. Overriding them makes sense if you draw something in TCastleUserInterface.RenderOverChildren.

The events Press and Release are passed to the parent only after the children had a chance to process this event. Overriding them makes sense if you draw something in TCastleUserInterface.Render. This is usually more natural, and adviced.

Public function Release(const Event: TInputPressRelease): boolean; override;

This item has no description.

Public function Motion(const Event: TInputMotion): boolean; override;

This item has no description. Showing description inherited from TCastleUserInterface.Motion.

Motion of mouse or touch.

Public function PropertySections(const PropertyName: String): TPropertySections; override;

This item has no description. Showing description inherited from TCastleComponent.PropertySections.

Section where to show property in the editor.

Properties

Public property Color: TCastleColor read FColor write SetColor;

Rectangle color. By default, opaque white.

Public property ThemeImage: TThemeImage read FThemeImage write SetThemeImage; deprecated 'use TCastleImageControl to display images';

Warning: this symbol is deprecated: use TCastleImageControl to display images

Fill rectangle with theme image. You have to set UseThemeImage to true to take effect.

Public property UseThemeImage: boolean read FUseThemeImage write SetUseThemeImage default false; deprecated 'use TCastleImageControl to display images';

Warning: this symbol is deprecated: use TCastleImageControl to display images

Use theme image for drawing instead of color.

Public property InterceptInput: boolean read FInterceptInput write FInterceptInput default false; deprecated 'in each case, there should be a cleaner way to disable something from processing the input';

Warning: this symbol is deprecated: in each case, there should be a cleaner way to disable something from processing the input

Prevents passing mouse/keyboard events to the controls underneath. More precisely, when this property is True, then the Press, Release and Motion events are marked as "handled" by this control.

Published property ColorPersistent: TCastleColorPersistent read FColorPersistent ;

Color that can be visually edited in Castle Game Engine Editor, Lazarus and Delphi. Normal user code does not need to deal with this, instead read or write Color directly.

See also
Color
Rectangle color.

Generated by PasDoc 0.16.0.