{***********************************************************
                R&A Library
       Copyright (C) 1996-2000 R&A

       description : Register custom useful controls

       author      : Andrei Prygounkov
       e-mail      : a.prygounkov@gmx.de
       www         : http://ralib.hotbox.ru.htm
************************************************************}

{$INCLUDE RA.INC}

unit ractlreg;

interface

procedure Register;

implementation

uses
{$IFDEF RA_VCL}
  Windows, 
{$ENDIF RA_VCL}
  Classes, RACtlConst, RARegAuto, RADsgn, RADsgnIntf,
{$IFDEF RA_VCL}
  SysUtils, Controls,
  RAHook, RARegAutoEditor, RAHtControls, RADlg,
  RAButtons, RAComponentPanel, RAScrollMax,
  RAEditor, RAHLEditor, RAHLEdPropDlg, RAScrollText, RAhtHintEditor,
{$ENDIF RA_VCL}
{$IFDEF RA_D3H}
  RAIDEZoom,
{$ENDIF RA_D3H}
{$IFDEF RA_D6H}
  DesignIntf, DesignEditors, PropertyCategories
  {$IFDEF RA_VCL}
   , VCLEditors
  {$ENDIF RA_VCL}
{$ELSE}
  DsgnIntf
{$ENDIF RA_D6H}
;

{$R ractl.dcr}

{$IFDEF RA_VCL}
type

  TRAScrollMaxEditor = class(TComponentEditor)
  public
    function GetVerbCount : integer; override;
    function GetVerb(Index : integer) : string; override;
    procedure ExecuteVerb(Index : integer); override;
    procedure Edit; override;
  end;

  TRAHLEdPropDlgEditor = class(TComponentEditor)
  public
    function GetVerbCount : integer; override;
    function GetVerb(Index : integer) : string; override;
    procedure ExecuteVerb(Index : integer); override;
    procedure Edit; override;
  end;

  TRAHLEditorColorProperty = class(TClassProperty)
  public
    function GetAttributes: TPropertyAttributes; override;
    procedure Edit; override;
  end;

{ TRAScrollMaxEditor }
function TRAScrollMaxEditor.GetVerbCount : integer;
begin
  Result := inherited GetVerbCount + 1;
end;

function TRAScrollMaxEditor.GetVerb(Index : integer) : string;
begin
  if Index = GetVerbCount - 1 then
    Result := 'Add Band'
  else
    Result := inherited GetVerb(Index);
end;

procedure TRAScrollMaxEditor.ExecuteVerb(Index : integer);
begin
  if Index = GetVerbCount - 1 then
    Designer.CreateComponent(TRAScrollMaxBand, Component, 0, 0, 0, 50)
  else
    inherited ExecuteVerb(Index);
end;

procedure TRAScrollMaxEditor.Edit;
begin
 // We don't need to add band on double click
end;

{ TRAHLEdPropDlgEditor }
function TRAHLEdPropDlgEditor.GetVerbCount : integer;
begin
  Result := inherited GetVerbCount + 1;
end;

function TRAHLEdPropDlgEditor.GetVerb(Index : integer) : string;
begin
  if Index = GetVerbCount - 1 then
    Result := 'Execute'
  else
    Result := inherited GetVerb(Index);
end;

procedure TRAHLEdPropDlgEditor.ExecuteVerb(Index : integer);
begin
  if Index = GetVerbCount - 1 then
    Edit
  else
    inherited ExecuteVerb(Index);
end;

procedure TRAHLEdPropDlgEditor.Edit;
var
  PakName: string;
  newRegAuto: TRegAuto;
  oldRegAuto: TRegAuto;
begin
  newRegAuto := TRegAuto.Create(nil);
  try
    newRegAuto.UseReg := False;
    newRegAuto.UseIni := True;
    newRegAuto.UseStr := False;
    SetLength(PakName, 260);
    SetLength(PakName, GetModuleFileName(hInstance, PChar(PakName), 260));
    newRegAuto.IniFile := ExtractFilePath(PakName) + 'RAHLEdPropDlg.ini';
    oldRegAuto := (Component as TRAHLEdPropDlg).RegAuto;
    (Component as TRAHLEdPropDlg).RegAuto := newRegAuto;
    if (Component as TRAHLEdPropDlg).Execute then
      Designer.Modified;
    (Component as TRAHLEdPropDlg).RegAuto := oldRegAuto;
  finally
    newRegAuto.Free;
  end;
end;

procedure TRAHLEditorColorProperty.Edit;
begin
  with TRAHLEdPropDlg.Create(nil) do
    try
      RAHLEditor := GetComponent(0) as TRAHLEditor;
      HighlighterCombo := False;
      ReadFrom := rfHLEditor;
      Pages := [epColors];
      if Execute then
        Designer.Modified;
    finally
      Free;
    end;
end;

function TRAHLEditorColorProperty.GetAttributes: TPropertyAttributes;
begin
  Result := inherited GetAttributes + [paDialog];
end;

{$IFDEF RA_D5}
type
  TRAEditorCategory = class (TPropertyCategory)
  public
    class function Name: String; override;
  end;
{ TEditorCategory }


class function TRAEditorCategory.Name: String;
begin
  Result := 'Editor';
end;
{$ENDIF RA_D5}

{$ENDIF RA_VCL}

const
{$IFDEF MSWINDOWS}
  RALibTabName = 'R&&A';
{$ENDIF}
{$IFDEF LINUX}
  RALibTabName = 'R&A';
{$ENDIF}

procedure Register;
begin
{$IFDEF RA_VCL}
 {RAEditor unit}
  RegisterComponents(RALibTabName, [TRAEditor]);
 {RAHLEditor unit}        
  RegisterComponents(RALibTabName, [TRAHLEditor]);
 {RAHLEdPropDlg unit}
  RegisterComponents(RALibTabName, [TRAHLEdPropDlg]);
  RegisterComponentEditor(TRAHLEdPropDlg, TRAHLEdPropDlgEditor);
  RegisterPropertyEditor(TypeInfo(TColors), TRAHLEditor, 'Colors', TRAHLEditorColorProperty);
 {RAScrollMax unit}
  RegisterComponents(RALibTabName, [TRAScrollMax]);
  RegisterClass(TRAScrollMaxBand);
  RegisterComponentEditor(TRAScrollMax, TRAScrollMaxEditor);
 {RAScrollText}
  RegisterComponents(RALibTabName, [TRAScrollText]);
 {RARegAuto unit}
  RegisterComponents(RALibTabName, [TRegAuto]);
  RegisterComponentEditor(TRegAuto, TRegAutoEditor);
 {RAHtControls unit}
  RegisterComponents(RALibTabName, [TRAhtListBox, TRAhtComboBox, TRAhtLabel]);
  RegisterPropertyEditor(TypeInfo(TCaption), TRAhtLabel, 'Caption', TRAHintProperty);
 {RAButtons unit}
  RegisterComponents (RALibTabName, [TRAhtButton, TRACaptionButton]);
 {RADlg unit}
  RegisterComponents(RALibTabName, [TRAProgressForm]);
 {RAComponentPanel unit}
  RegisterComponents(RALibTabName, [TRAComponentPanel]);
{$ENDIF RA_VCL}

{$IFDEF RA_CLX}
 {RARegAuto unit}
  RegisterComponents(RALibTabName, [TRegAuto]);
{$ENDIF RA_CLX}

 {Zoom unit}
 {$IFDEF RA_D3H}
  RegisterZoom;
 {$ENDIF RA_D3H}

 {$IFDEF RA_D5}
  RegisterPropertiesInCategory(TRAEditorCategory, TRACustomEditor,
    ['InsertMode', 'DoubleClickLine', 'Completion', 'SmartTab',
    'BackSpaceUnindents', 'AutoIndent', 'KeepTrailingBlanks', 'CursorBeyondEOF',
    'GutterColor', 'GutterWidth',
    'RightMarginVisible', 'RightMargin', 'RightMarginColor',

    'OnGetLineAttr', 'OnReservedWord', 'OnCompletionIdentifer',
    'OnCompletionDrawItem', 'OnCompletionMeasureItem', 'OnCompletionTemplate',
    'OnChange', 'OnChangeStatus', 'OnSelectionChange']);

  RegisterPropertiesInCategory(TVisualCategory, TRACustomEditor,
    ['ScrollBars',
    'RightMarginVisible', 'RightMargin', 'RightMarginColor',
    'OnPaintGutter', 'OnScroll', 'OnConstrainedResize']);
 {$ENDIF}

 {$IFDEF RA_D6H}
 {$IFDEF RA_VCL}
  RegisterPropertiesInCategory('Editor', TRACustomEditor,
    ['InsertMode', 'DoubleClickLine', 'Completion', 'SmartTab',
    'BackSpaceUnindents', 'AutoIndent', 'KeepTrailingBlanks', 'CursorBeyondEOF',
    'GutterColor', 'GutterWidth',
    'RightMarginVisible', 'RightMargin', 'RightMarginColor',

    'OnGetLineAttr', 'OnReservedWord', 'OnCompletionIdentifer',
    'OnCompletionDrawItem', 'OnCompletionMeasureItem', 'OnCompletionTemplate',
    'OnChange', 'OnChangeStatus', 'OnSelectionChange']);

  RegisterPropertiesInCategory('Visual', TRACustomEditor,
    ['ScrollBars',
    'RightMarginVisible', 'RightMargin', 'RightMarginColor',
    'OnPaintGutter', 'OnScroll', 'OnConstrainedResize']);
 {$ENDIF}
 {$ENDIF}
end;

end.
