{ ------------------------------------------------------------- }
{ Purpose : NxInspector 6                                       }
{ By      : Bojan Nikolic                                       }
{ For     : BergSoft                                            }
{ ------------------------------------------------------------- }
{ Copyright (C) BergSoft.net 2011. All Rights Reserved.         }
{ ------------------------------------------------------------- }
{ mm/dd/yy comment                                              }
{ -------- ---------------------------------------------------- }
{ 10/07/11 Added: Register procedured                           }
{ ------------------------------------------------------------- }
{ Todo :                                                        }
{ ------------------------------------------------------------- }
unit NxInspectorReg6;

interface

uses
  { Standard }
  Classes, Types,
  { Controls }
  Forms, Dialogs,
  { Standard - Design }
  DesignIntf, DesignEditors, VCLEditors,
  { DesignWindows }
  NxInspectorNodesEditor6,
  { Next Standard 6 - Design }
  NxStandardReg6,
  { NextInspector 6 }
  NxInspector6, NxInspectorNode6, NxInspectorNodeClasses6;

type
  TNxInspectorNodesEditorClass = class of TNxInspectorNodesEditor;

  { Component Editors }

  TNxInspectorComponentEditor6 = class(TNextSuiteComponentEditor6)
  public
    function GetVerb(Index: Integer): string; override;
    function GetVerbCount: Integer; override;
    procedure Edit; override;
    procedure EditProperty(const Prop: IProperty; var Continue: Boolean); override;
    procedure ExecuteVerb (Index: Integer); override;
  end;

  { Property Editors }

  TNxInspectorNodesProperty6 = class(TPropertyEditor)
  protected
    function GetNodesEditorClass: TNxInspectorNodesEditorClass; virtual;
  public
    function GetAttributes: TPropertyAttributes; override;
    function GetValue: string; override;
    procedure Edit; override;
  end;

procedure Register;

implementation

uses
  { Next Standard 6 - Design }
  NxDesignWindow6;

const
  Visibility: array[Boolean] of string = ('Show', 'Hide');

procedure Register;
begin
  { Register Components }
  RegisterComponents('Next Suite 6', [TNextInspector6]);

  RegisterClasses([TNxInspectorNode6,
    TNxButtonInspectorNode6,
    TNxCheckBoxInspectorNode6,
    TNxColorPaletteInspectorNode6,
    TNxComboBoxInspectorNode6,
    TNxDateInspectorNode6,
    TNxMemoInspectorNode6,
    TNxPictureInspectorNode6,
    TNxProgressInspectorNode6,
    TNxRadioInspectorNode6,
    TNxRateInspectorNode6,
    TNxListInspectorNode6,
    TNxSpinInspectorNode6,
    TNxToolbarInspectorNode6,
    TNxTrackBarInspectorNode6]);

  RegisterNoIcon([TNxInspectorNode6,
    TNxButtonInspectorNode6,
    TNxCheckBoxInspectorNode6,
    TNxColorPaletteInspectorNode6,
    TNxComboBoxInspectorNode6,
    TNxDateInspectorNode6,
    TNxMemoInspectorNode6,
    TNxPictureInspectorNode6,
    TNxProgressInspectorNode6,
    TNxRadioInspectorNode6,
    TNxRateInspectorNode6,
    TNxListInspectorNode6,
    TNxSpinInspectorNode6,
    TNxToolbarInspectorNode6,
    TNxTrackBarInspectorNode6]);

  { Component Editors }
  RegisterComponentEditor(TNextInspector6, TNxInspectorComponentEditor6);

  { Property Editors }
  RegisterPropertyEditor(TypeInfo(TNxInspectorNodes), TNextInspector6, 'Nodes', TNxInspectorNodesProperty6);
end;

{ TNxInspectorItemsProperty6 }

procedure TNxInspectorNodesProperty6.Edit;
var
  EditorForm: TNxInspectorNodesEditor;
begin
  inherited;
  if not ShowForm(GetComponent(0), TNxInspectorNodesEditor) then { Is Form already showing ? }
  begin
    { Create new Form }
    { 2/29/12: Form name & type inside dfm file must be
               same as actual name (!) }
    EditorForm := GetNodesEditorClass.Create(Application);
    try
      EditorForm.OwnerControl := TNextInspector6(GetComponent(0));
      EditorForm.Designer := Self.Designer;
      EditorForm.WindowState := wsNormal;
      EditorForm.Show;
    except
      EditorForm.Free;
    end;
  end;
end;

function TNxInspectorNodesProperty6.GetAttributes: TPropertyAttributes;
begin
  Result := inherited GetAttributes + [paDialog, paReadOnly];
end;

function TNxInspectorNodesProperty6.GetNodesEditorClass: TNxInspectorNodesEditorClass;
begin
  Result := TNxInspectorNodesEditor;
end;

function TNxInspectorNodesProperty6.GetValue: string;
var
  Nodes: TNxInspectorNodes;
begin
  Nodes := TNextInspector6(GetComponent(0)).Nodes;

  Result := '(' + Nodes.ClassName + ')';
end;

{ TNxInspectorComponentEditor6 }

procedure TNxInspectorComponentEditor6.Edit;
begin
  inherited;

end;

procedure TNxInspectorComponentEditor6.EditProperty(const Prop: IProperty;
  var Continue: Boolean);
begin
  inherited;
  if Prop.GetName = 'Nodes' then
  begin
    Continue := False;

    { Call TNxInspectorNodesProperty6.Edit }
    Prop.Edit;
  end;

end;

procedure TNxInspectorComponentEditor6.ExecuteVerb(Index: Integer);
begin
  { Process Verb }
  with GetComponent as TNextInspector6 do
    case Index of
      0: Edit;
      2: if ioModifiedIndicators in Options then
          Options := Options - [ioModifiedIndicators]
            else Options := Options + [ioModifiedIndicators];
    end;

  inherited;
end;

function TNxInspectorComponentEditor6.GetVerb(Index: Integer): string;
begin
  with GetComponent as TNextInspector6 do
    case Index of
      0: Result := '&Nodes Editor...';
      1: Result := '-';
      2: Result := Visibility[ioModifiedIndicators in Options] + ' &Indicators';
    end;

  Result := inherited GetVerb(Index);
end;

function TNxInspectorComponentEditor6.GetVerbCount: Integer;
begin
  Result := inherited GetVerbCount + 3;
end;

end.
