unit accionesF;

{$mode objfpc}{$H+}

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdActns, ActnList, ExtCtrls, StdCtrls, Menus, ImgList, Buttons,
  ComCtrls, ToolWin;

type

  { TForm1 }

  TForm1 = class(TForm)
    Memo1: TMemo;
    ActionList1: TActionList;
    AccionCopiar: TEditCopy;
    AccionCortar: TEditCut;
    AccionPegar: TEditPaste;
    AccionNuevo: TAction;
    AccionSalir: TAction;
    NoAction: TAction;
    AccionContar: TAction;
    AccionNegrita: TAction;
    Menu1: TMainMenu;
    Editar: TMenuItem;
    Pegar2: TMenuItem;
    Copiar2: TMenuItem;
    Cortar2: TMenuItem;
    Archivo: TMenuItem;
    Nuevo: TMenuItem;
    Salir: TMenuItem;
    Pruebas: TMenuItem;
    N1: TMenuItem;
    Negrita: TMenuItem;
    NoAction1: TMenuItem;
    ContarCaracteres: TMenuItem;
    ListaIconos: TImageList;
    ActivarAccion: TAction;
    ActivarNoAction1: TMenuItem;
    AccionRemitente: TAction;
    ProbarSender: TMenuItem;
    Barra1: TToolBar;
    tbNuevo: TToolButton;
    tbCortar: TToolButton;
    tbCopiar: TToolButton;
    tbPegar: TToolButton;
    tbSeparador6: TToolButton;
    tbNegrita: TToolButton;
    tbContarCar: TToolButton;
    tbSalir: TToolButton;
    tbSeparador1: TToolButton;
    tbSeparador2: TToolButton;
    procedure AccionNuevoExecute(Sender: TObject);
    procedure AccionSalirExecute(Sender: TObject);
    procedure AccionNegritaExecute(Sender: TObject);
    procedure AccionContarUpdate(Sender: TObject);
    procedure AccionContarExecute(Sender: TObject);
    procedure ActivarAccionExecute(Sender: TObject);
    procedure AccionRemitenteExecute(Sender: TObject);
    procedure Memo1Change(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.LFM}

procedure TForm1.AccionNuevoExecute(Sender: TObject);
begin
  Memo1.Lines.Clear;
end;

procedure TForm1.AccionSalirExecute(Sender: TObject);
begin
  Close;
end;

procedure TForm1.AccionNegritaExecute(Sender: TObject);
begin
  with Memo1.Font do
    if fsBold in Style then
      Style := Style - [fsBold]
    else
      Style := Style + [fsBold];
  // conmuta el estado
  AccionNegrita.Checked := not AccionNegrita.Checked;
end;

procedure TForm1.AccionContarUpdate(Sender: TObject);
begin
  AccionContar.Enabled := Memo1.Text <> '';
end;

procedure TForm1.AccionContarExecute(Sender: TObject);
begin
  ShowMessage ('Caracteres: ' + IntToStr (
    Length (Memo1.Text)));
end;

procedure TForm1.ActivarAccionExecute(Sender: TObject);
begin
  NoAction.DisableIfNoHandler := False;
  NoAction.Enabled := True;
  ActivarAccion.Enabled := False;
end;

procedure TForm1.AccionRemitenteExecute(Sender: TObject);
begin
  Memo1.Lines.Add (
    'Clase remitente: ' + Sender.ClassName);
  Memo1.Lines.Add (
    'Nombre del remitente: ' + (Sender as TComponent).Name);
  Memo1.Lines.Add (
    'Categoría: ' + (Sender as TAction).Category);
  Memo1.Lines.Add (
    'Nombre del control TActionList: ' + (Sender as TAction).ActionList.Name );
end;

procedure TForm1.Memo1Change(Sender: TObject);
begin

end;

end.

