unit VisCtl;

interface

uses
  Windows, SysUtils, Types, UITypes, Classes, Controls, Forms;

type
  TVisCtlClass = class of TVisCtl;

  TVisCtl = class(TCustomControl)
  protected
    procedure SetWindowWidth(AWidth: Integer); virtual;
    procedure SetWindowHeight(AHeight: Integer); virtual;
    procedure SetDetached(ADetached: Boolean); virtual;
  end;

  TVisObj = class(TPersistent)
  protected
    FName, FTitle, FDescription: string;
    FGUID: TGUID;
    FLastDrawTime: UInt64;
  public
    procedure ShowOptionsForm(AParent: TCustomForm = nil); virtual;
    property Name: string read FName write FName;
    property Title: string read FTitle write FTitle;
    property Description: string read FDescription write FDescription;
    property GUID: TGUID read FGUID;
    property LastDrawTime: UInt64 read FLastDrawTime;
    class function GetRealm: string; virtual;
  end;

  TVisObjClass = class of TVisObj;

var
  VisObjListChanged: TNotifyEvent;

implementation

uses
  UxPanel;

{ TVisCtl }

procedure TVisCtl.SetDetached(ADetached: Boolean);
begin
  if ADetached and (Parent is TPanelForm) and (TPanelForm(Parent).Panel <> nil) then
    TPanelForm(Parent).Panel.Detach;
end;

procedure TVisCtl.SetWindowHeight(AHeight: Integer);
begin
  if (Parent is TPanelForm) and Parent.HandleAllocated then
    TPanelForm(Parent).RequestClientSize(TPanelForm(Parent).ClientWidth, AHeight);
end;

procedure TVisCtl.SetWindowWidth(AWidth: Integer);
begin
  if (Parent is TPanelForm) and Parent.HandleAllocated then
    TPanelForm(Parent).RequestClientSize(AWidth, TPanelForm(Parent).ClientHeight);
end;

{ TVisObj }

class function TVisObj.GetRealm: string;
begin
  Result := '';
end;

procedure TVisObj.ShowOptionsForm(AParent: TCustomForm);
begin

end;

end.
