unit Emoticons;
{
    Copyright 2002, Peter Millard

    This file is part of Exodus.

    Exodus is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    Exodus is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with Exodus; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
}

interface

uses
  BaseChat,
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ComCtrls, ToolWin, ExtCtrls;

type
  TProcSetEmoticon = procedure(msn: boolean; imgIndex: integer) of object;

  TfrmEmoticons = class(TForm)
    Panel3: TPanel;
    ToolBar1: TToolBar;
    ToolButton1: TToolButton;
    ToolButton2: TToolButton;
    ToolButton3: TToolButton;
    ToolButton4: TToolButton;
    ToolButton43: TToolButton;
    ToolButton45: TToolButton;
    ToolButton46: TToolButton;
    ToolButton9: TToolButton;
    ToolButton10: TToolButton;
    ToolButton16: TToolButton;
    ToolButton23: TToolButton;
    ToolButton39: TToolButton;
    ToolButton40: TToolButton;
    ToolButton5: TToolButton;
    ToolButton6: TToolButton;
    ToolButton30: TToolButton;
    ToolButton15: TToolButton;
    ToolButton24: TToolButton;
    ToolButton7: TToolButton;
    ToolButton8: TToolButton;
    ToolButton11: TToolButton;
    ToolButton12: TToolButton;
    ToolButton13: TToolButton;
    ToolButton14: TToolButton;
    ToolButton18: TToolButton;
    ToolButton17: TToolButton;
    ToolButton19: TToolButton;
    ToolButton20: TToolButton;
    ToolButton21: TToolButton;
    ToolButton35: TToolButton;
    ToolButton22: TToolButton;
    ToolButton25: TToolButton;
    ToolButton26: TToolButton;
    ToolButton34: TToolButton;
    ToolButton28: TToolButton;
    ToolButton37: TToolButton;
    ToolButton29: TToolButton;
    ToolButton31: TToolButton;
    ToolButton32: TToolButton;
    ToolButton33: TToolButton;
    ToolButton36: TToolButton;
    ToolButton38: TToolButton;
    ToolButton41: TToolButton;
    ToolButton42: TToolButton;
    ToolButton44: TToolButton;
    Panel1: TPanel;
    CoolBar1: TCoolBar;
    Panel2: TPanel;
    CoolBar2: TCoolBar;
    ToolBar2: TToolBar;
    ToolButton27: TToolButton;
    ToolButton47: TToolButton;
    ToolButton48: TToolButton;
    ToolButton49: TToolButton;
    ToolButton50: TToolButton;
    ToolButton51: TToolButton;
    ToolButton52: TToolButton;
    ToolButton53: TToolButton;
    ToolButton54: TToolButton;
    ToolButton55: TToolButton;
    ToolButton56: TToolButton;
    ToolButton57: TToolButton;
    ToolButton58: TToolButton;
    ToolButton59: TToolButton;
    ToolButton60: TToolButton;
    ToolButton61: TToolButton;
    ToolButton62: TToolButton;
    ToolButton63: TToolButton;
    ToolButton64: TToolButton;
    ToolButton65: TToolButton;
    ToolButton66: TToolButton;
    ToolButton67: TToolButton;
    ToolButton68: TToolButton;
    ToolButton69: TToolButton;
    ToolButton70: TToolButton;
    procedure ToolButton1Click(Sender: TObject);
    procedure FormDeactivate(Sender: TObject);
    procedure ToolBar1Click(Sender: TObject);
    procedure FormKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
    fOnSetEmoticon: TProcSetEmoticon;
  public
    { Public declarations }
    ChatWindow: TfrmBaseChat;
    msn: boolean;
    imgIndex: integer;
    property OnSetEmoticon: TProcSetEmoticon read fOnSetEmoticon write fOnSetEmoticon;
  end;

var
  frmEmoticons: TfrmEmoticons;

{---------------------------------------}
{---------------------------------------}
{---------------------------------------}
implementation

{$R *.dfm}
uses
  GnuGetText, Jabber1;

{---------------------------------------}

procedure TfrmEmoticons.ToolButton1Click(Sender: TObject);
var
  btn: TToolbutton;
begin
    // a button was clicked.
  if (Sender is TToolButton) then begin
    btn := TToolButton(Sender);
    msn := (Toolbar1.Buttons[btn.Index] = btn);
    imgIndex := btn.ImageIndex;
    if Assigned(fOnSetEmoticon) then
      fOnSetEmoticon(msn, imgIndex)
    else
      ChatWindow.SetEmoticon(msn, imgIndex);
    Self.Hide;
  end
  else
    Self.Hide;
end;

{---------------------------------------}

procedure TfrmEmoticons.FormDeactivate(Sender: TObject);
begin
  if Self.Visible then
    Self.Hide();
end;

{---------------------------------------}

procedure TfrmEmoticons.ToolBar1Click(Sender: TObject);
begin
  Self.Hide;
end;

{---------------------------------------}

procedure TfrmEmoticons.FormKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  case key of
    VK_ESCAPE: Self.Hide
  end;
end;

procedure TfrmEmoticons.FormCreate(Sender: TObject);
begin
  TranslateProperties(Self);
  ChatWindow := nil;
  fOnSetEmoticon := nil;
end;

end.
