Class TCastleWindowCustom

DescriptionHierarchyFieldsMethodsProperties

Unit

Declaration

type TCastleWindowCustom = class(TCastleWindowDemo, IUIContainer)

Description

OpenGL window keeping a Controls list. This allows you to trivially add to the window any TUIControl descendants.

We pass our inputs (mouse / key events) to the top-most (that is, first on the Controls list) control under the current mouse position (we check control's PositionInside method for this). As long as the event is not handled, we look for next controls under the mouse position. Only if no control handled the event, we pass it to the inherited EventXxx method, which calls normal window callbacks like OnPress.

We also call other methods on every control, like TUIControl.Idle, TUIControl.Draw2D, TUIControl.WindowResize.

We use OnVisibleChange event of our controls to make PostRedisplay when something visible changed. If you want to use OnVisibleChange for other purposes, you can reassign OnVisibleChange yourself. This window will only change OnVisibleChange from Nil to it's own internal callback (when adding a control), and from it's own internal callback to Nil (when removing a control). This means that if you assign OnVisibleChange callback to your own method — window will not touch it anymore.

TCamera descendants can be treated like any other TUIControl, that is you can add them directly to the Controls list. Note that usually, when using TCastleSceneManager, you should only assign camera to TCastleSceneManager.Camera, so most programs should not add their TCamera intances directly to the Controls list.

Hierarchy

Overview

Methods

Public constructor Create(AOwner: TComponent); override;
Public destructor Destroy; override;
Public procedure EventOpen; override;
Public procedure EventClose; override;
Public procedure EventPress(const Event: TInputPressRelease); override;
Public procedure EventRelease(const Event: TInputPressRelease); override;
Public procedure EventIdle; override;
Public procedure EventMouseMove(NewX, NewY: Integer); override;
Public function AllowSuspendForInput: boolean; override;
Public procedure EventBeforeDraw; override;
Public procedure EventDraw; override;
Public procedure EventResize; override;

Properties

Public property Controls: TUIControlList read FControls;
Public property Focus: TUIControl read FFocus;
Public property OnDrawStyle: TUIControlDrawStyle read FOnDrawStyle write FOnDrawStyle default dsNone;
Public property TooltipDelay: TMilisecTime read FTooltipDelay write FTooltipDelay default DefaultTooltipDelay;
Public property TooltipDistance: Cardinal read FTooltipDistance write FTooltipDistance default DefaultTooltipDistance;
Public property TooltipVisible: boolean read FTooltipVisible;
Public property TooltipX: Integer read FTooltipX;
Public property TooltipY: Integer read FTooltipY;

Description

Methods

Public constructor Create(AOwner: TComponent); override;
 
Public destructor Destroy; override;
 
Public procedure EventOpen; override;
 
Public procedure EventClose; override;
 
Public procedure EventPress(const Event: TInputPressRelease); override;
 
Public procedure EventRelease(const Event: TInputPressRelease); override;
 
Public procedure EventIdle; override;
 
Public procedure EventMouseMove(NewX, NewY: Integer); override;
 
Public function AllowSuspendForInput: boolean; override;
 
Public procedure EventBeforeDraw; override;
 
Public procedure EventDraw; override;
 
Public procedure EventResize; override;
 

Properties

Public property Controls: TUIControlList read FControls;

Controls listening for user input (keyboard / mouse) to this window.

Usually you explicitly add / delete controls to this list. Also, freeing the control that is on this list automatically removes it from this list (using the TComponent.Notification mechanism).

Controls on the list should be specified in front-to-back order. That is, controls at the beginning of this list are first to catch some events, and are rendered as the last ones (to cover controls beneath them).

Public property Focus: TUIControl read FFocus;

Returns the control that should receive input events first, or Nil if none. More precisely, this is the first on Controls list that is enabled and under the mouse cursor. Nil is returned when there's no enabled control under the mouse cursor, or when UseControls = False.

Public property OnDrawStyle: TUIControlDrawStyle read FOnDrawStyle write FOnDrawStyle default dsNone;

How OnDraw callback fits within various Draw methods of our Controls.

  • dsNone means that OnDraw is called at the end, after all our Controls are drawn.

    OpenGL projection matrix is not modified (so projection is whatever you set yourself, by EventResize, OnResize, or whatever TCastleSceneManager set for you).

    Note that the interpretation of dsNone is different than for TUIControl.DrawStyle: for TUIControl.DrawStyle, dsNone means "do not draw". For OnDrawStyle property, dsNone means "draw at the end without any tricks".

    This is suitable if you want to draw something over other controls, and you want to set projection yourself (or use the current projection, whatever it is).

  • ds2D means that OnDraw is also called at the end, after all our Controls are drawn. But this time we're called within 2D orthographic projection, the same as set for TUIControl.DrawStyle = ds2D.

    This is suitable if you want to draw 2D contents, and our simple 2D orthographic projection suits you.

  • ds3D means that OnDraw is called after all other Controls with ds3D draw style, but before any 2D controls.

    OpenGL projection matrix is not modified (so projection is whatever you set yourself, by EventResize, OnResize, or whatever TCastleSceneManager set for you).

    This is suitable if you want to draw something 3D, that may be later covered by 2D controls.

Public property TooltipDelay: TMilisecTime read FTooltipDelay write FTooltipDelay default DefaultTooltipDelay;
 
Public property TooltipDistance: Cardinal read FTooltipDistance write FTooltipDistance default DefaultTooltipDistance;
 
Public property TooltipVisible: boolean read FTooltipVisible;

When the tooltip should be shown (mouse hovers over a control with a tooltip) then the TooltipVisible is set to True, and TooltipX, TooltipY indicate left-bottom suggested position of the tooltip.

The tooltip is only detected when TUIControl.TooltipStyle <> dsNone. See TUIControl.TooltipStyle and TUIControl.DrawTooltip. For simple purposes just set TUIControlFont.Tooltip to something non-empty.

Public property TooltipX: Integer read FTooltipX;
 
Public property TooltipY: Integer read FTooltipY;
 

Generated by PasDoc 0.12.1 on 2013-02-04 20:26:53