{ *************************************************************************** }
{                                                                             }
{ EControl Syntax Editor SDK                                                  }
{                                                                             }
{ Copyright (c) 2004 - 2008 EControl Ltd., Zaharov Michael                    }
{     www.econtrol.ru                                                         }
{     support@econtrol.ru                                                     }
{                                                                             }
{ *************************************************************************** }
unit ecStlDlg;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
  Dialogs, ecsnColEdit, ecsnStyleEdit, StdCtrls, ecSyntAnal;

type
  TStylesColEdit = class(TForm)
    SyntStyleFrame1: TSyntStyleFrame;
    SyntColFrame1: TSyntColFrame;
    Button1: TButton;
    Button2: TButton;
    SyntStyles1: TSyntStyles;
    procedure StyleChanged(Sender: TObject);
    procedure FormShow(Sender: TObject);
  public
  end;

function EditStylesCollection(AStyles: TStylesCollection; AllowListOper: Boolean = True): Boolean;

implementation

{$R *.dfm}

function EditStylesCollection(AStyles: TStylesCollection; AllowListOper: Boolean): Boolean;
begin
  with TStylesColEdit.Create(nil) do
   try
     SyntStyles1.Styles := AStyles;
     SyntColFrame1.AllowListEdit := AllowListOper;
     Result := ShowModal = mrOk;
     if Result then
      AStyles.Assign(SyntStyles1.Styles);
   finally
     Free;
   end;
end;

{ TStylesColEdit }

procedure TStylesColEdit.FormShow(Sender: TObject);
begin
  SyntColFrame1.Collection := SyntStyles1.Styles;
  SyntColFrame1.OnChange := StyleChanged;
  StyleChanged(nil);
end;

procedure TStylesColEdit.StyleChanged(Sender: TObject);
begin
  if SyntColFrame1.LB.ItemIndex >= 0 then
    SyntStyleFrame1.Style := TSyntaxFormat(SyntColFrame1.Current);
end;

end.
