unit uToolBarEditor;

interface

uses
  Windows, Graphics, Controls, Forms, StdCtrls, Buttons, ComCtrls, Classes,
  ToolWin, ExtCtrls, GR32_Image;

type
  TFormToolBarEditor = class(TForm)
    ToolBarList: TListView;
    ButtonOk: TButton;
    ButtonCancel: TButton;
    ButtonDefault: TButton;
    ButtonReset: TButton;
    ButtonHideToolBar: TSpeedButton;
    LabelGameDescription: TLabel;
    TopImage: TImage32;
    procedure ButtonOkClick(Sender: TObject);
    procedure ButtonCancelClick(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure ButtonDefaultClick(Sender: TObject);
    procedure ButtonResetClick(Sender: TObject);
    procedure FormKeyPress(Sender: TObject; var Key: Char);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  FormToolBarEditor: TFormToolBarEditor;

implementation

uses uMain;

{$R *.dfm}

procedure TFormToolBarEditor.ButtonOkClick(Sender: TObject);
var
  Loop: ShortInt;
begin
  for Loop:=0 to FormMain.ToolBarButtons.ButtonCount-1 do
      FormMain.ToolBarButtons.Buttons[Loop].Visible:= ToolBarList.Items[Loop].Checked;
  FormMain.ToolBarPanel.Visible:= not ButtonHideToolBar.Down;
  FormMain.ToolBarPanel.Tag:= Ord(FormMain.ToolBarPanel.Visible);
  Close;
end;

procedure TFormToolBarEditor.ButtonCancelClick(Sender: TObject);
begin
  Close;
end;

procedure TFormToolBarEditor.FormShow(Sender: TObject);
var
  Loop: ShortInt;
begin
  for Loop:=0 to FormMain.ToolBarButtons.ButtonCount-1 do
      ToolBarList.Items[Loop].Checked:= FormMain.ToolBarButtons.Buttons[Loop].Visible;
  ButtonHideToolBar.Down:= not FormMain.ToolBarPanel.Visible;
  FormMain.LoadTopBar(TopImage, 'toolbar.png');
end;

procedure TFormToolBarEditor.ButtonDefaultClick(Sender: TObject);
var
  Loop: ShortInt;
begin
  for Loop:=0 to FormMain.ToolBarButtons.ButtonCount-1 do
      ToolBarList.Items[Loop].Checked:= True;
  ButtonHideToolBar.Down:= False;
end;

procedure TFormToolBarEditor.ButtonResetClick(Sender: TObject);
begin
  FormToolBarEditor.OnShow(Self);
end;

procedure TFormToolBarEditor.FormKeyPress(Sender: TObject; var Key: Char);
begin
  if Key = #27 then
     Close;
end;

end.
