⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tetrefed.pas

📁 Do your applications look a little boring? Would you like to get spectacular yet easy to use visual
💻 PAS
字号:
unit teTrEfEd;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  TransEff, StdCtrls, Buttons, ExtCtrls, teCtrls, teForm, ComCtrls;

{$INCLUDE teDefs.inc}

type
  TTransitionEffectEditor = class(TForm)
    LabelPassSetting: TLabel;
    ComboBoxPasses: TComboBox;
    LabelPass2Options: TLabel;
    SpeedButtonPass2: TSpeedButton;
    ColorDialog: TColorDialog;
    LabelMilliseconds: TLabel;
    EditMilliseconds: TEdit;
    UpDownMilliseconds: TUpDown;
    LabelDirection: TLabel;
    ComboBoxDirection: TComboBox;
    EffectsGroupBoxPass2: TEffectsGroupBox;
    LabelDistributedTime: TLabel;
    CheckBoxDistributedTime: TCheckBox;
    Label2PReversed: TLabel;
    CheckBox2PReversed: TCheckBox;
    CheckBoxUseSolidColor: TCheckBox;
    LabelUseSolidColor: TLabel;
    LabelSolidColor: TLabel;
    SpeedButtonSolidColor: TSpeedButton;
    SpeedButtonClosePanel: TSpeedButton;
    FormTransitions: TFormTransitions;
    procedure SpeedButtonPass2Click(Sender: TObject);
    procedure SpeedButtonClosePanelClick(Sender: TObject);
    procedure SpeedButtonSolidColorClick(Sender: TObject);
    procedure EditMillisecondsExit(Sender: TObject);
    procedure LabelDistributedTimeClick(Sender: TObject);
    procedure Label2PReversedClick(Sender: TObject);
    procedure LabelUseSolidColorClick(Sender: TObject);
  protected
    Transition: TTransitionEffect;
    GlassPanel: TEffectsPanel;
    FocusedControl: TWincontrol;
  public
    procedure Initialize(TransitionValue: TTransitionEffect); virtual;
    procedure ReadValues; virtual;
    procedure WriteValues; virtual;
  end;

var
  TransitionEffectEditor: TTransitionEffectEditor;

implementation

uses teSlide, teBlend, TypInfo, teRender;

{$R *.DFM}

type
  TTransitionHack = class(TTransitionEffect);

{ TTransitionEffectEditor }

procedure TTransitionEffectEditor.Initialize(TransitionValue: TTransitionEffect);
var
  ShowMilliseconds,
  ShowDirection: Boolean;
  i: Integer;
begin
  Transition  := TransitionValue;

  if not TTransitionHack(Transition).NeedDstImage then
  begin
    LabelPassSetting .Enabled := False;
    ComboBoxPasses   .Enabled := False;
    LabelPass2Options.Enabled := False;
    SpeedButtonPass2 .Enabled := False;
  end;

  ShowMilliseconds :=
  {$ifdef D5UP}
    GetPropInfo(Transition.ClassType, 'Milliseconds', [tkInteger]) <> nil;
  {$else}
    GetPropInfo(Transition.ClassInfo, 'Milliseconds') <> nil;
  {$endif D5UP}
  LabelMilliseconds .Visible := ShowMilliseconds;
  EditMilliseconds  .Visible := ShowMilliseconds;
  UpDownMilliseconds.Visible := ShowMilliseconds;

  ShowDirection :=
  {$ifdef D5UP}
    GetPropInfo(Transition.ClassType, 'Direction', [tkEnumeration]) <> nil;
  {$else}
    GetPropInfo(Transition.ClassInfo, 'Direction') <> nil;
  {$endif D5UP}
  LabelDirection   .Visible := ShowDirection;
  ComboBoxDirection.Visible := ShowDirection;

  for i:=1 to Integer(High(TTEEffectDirection)) do
    if TTEEffectDirection(i) in Transition.AllowedDirections then
      ComboBoxDirection.Items.AddObject(TEGetDirectionDesc(TTEEffectDirection(i)),
        TObject(i));

  if ShowDirection then
  begin
    for i:=0 to ComboBoxDirection.Items.Count-1 do
      if TTEEffectDirection(ComboBoxDirection.Items.Objects[i]) =
         Transition.Direction then
        ComboBoxDirection.ItemIndex := i;
  end;
end;

procedure TTransitionEffectEditor.ReadValues;
begin
  ComboBoxPasses.ItemIndex         := Integer(Transition.PassSetting);
  CheckBoxDistributedTime.Checked  := Transition.Pass2Options.DistributedTime;
  CheckBox2PReversed     .Checked  := Transition.Pass2Options.Reversed;
  CheckBoxUseSolidColor  .Checked  := Transition.Pass2Options.UseSolidColor;
  UpDownMilliseconds.Position      := Transition.Milliseconds;
end;

procedure TTransitionEffectEditor.WriteValues;
begin
  Transition.PassSetting                  :=
    TTEPassSettingType(ComboBoxPasses.ItemIndex);
  Transition.Pass2Options.DistributedTime := CheckBoxDistributedTime.Checked;
  Transition.Pass2Options.Reversed        := CheckBox2PReversed.Checked;
  Transition.Pass2Options.UseSolidColor   := CheckBoxUseSolidColor.Checked;
  Transition.Milliseconds                 := UpDownMilliseconds.Position;
  if ComboBoxDirection.Visible then
    Transition.Direction                  :=
      TTEEffectDirection(ComboBoxDirection.Items.Objects[
       ComboBoxDirection.ItemIndex]);
end;

procedure TTransitionEffectEditor.SpeedButtonPass2Click(Sender: TObject);
var
  PanelTransition: TSlideTransition;
  GlassTransition: TBlendTransition;
  CursorBak: TCursor;
  R: TRect;
begin
  FocusedControl := Screen.ActiveControl;
  CursorBak := Screen.Cursor;
  Screen.Cursor := crHourglass;
  try
    GlassTransition := TBlendTransition.Create(nil);
    try
      GlassTransition.Milliseconds := 500;
      GlassTransition.Prepare(Parent, BoundsRect);
      GlassPanel        := TEffectsPanel.Create(Self);
      GlassPanel.Parent := Self;
      GlassPanel.SetBounds(0, 0, ClientWidth, ClientHeight);
      GlassPanel.BevelInner  := bvNone;
      GlassPanel.BevelOuter  := bvNone;
      GlassPanel.ParentColor := True;
      GlassPanel.BackgroundOptions.Assign(EffectsGroupBoxPass2.BackgroundOptions);
      if RGBDevice(False)
      then GlassPanel.BackgroundOptions.GlassTranslucency := 38
      else
      begin
        GlassPanel          .BackgroundOptions.GlassTranslucency := 0;
        EffectsGroupBoxPass2.BackgroundOptions.GlassTranslucency := 0;
      end;
      if GlassTransition.Prepared then
        GlassTransition.Execute;
    finally
      GlassTransition.Free;
    end;

    PanelTransition := TSlideTransition.Create(nil);
    try
      EffectsGroupBoxPass2.Visible := True;
      EffectsGroupBoxPass2.BringToFront;
      PanelTransition.Milliseconds := 500;
      PanelTransition.Direction    := tedOut;
      R := EffectsGroupBoxPass2.BoundsRect;
      OffsetRect(R, -200, 0);
      PanelTransition.Prepare(Self, R);
      EffectsGroupBoxPass2.Left := R.Left;
      CheckBoxDistributedTime.SetFocus;
      if PanelTransition.Prepared then
        PanelTransition.Execute;
    finally
      PanelTransition.Free;
    end;
  finally
    Screen.Cursor := CursorBak;
  end;
end;

procedure TTransitionEffectEditor.SpeedButtonClosePanelClick(
  Sender: TObject);
var
  PanelTransition: TSlideTransition;
  GlassTransition: TBlendTransition;
  CursorBak: TCursor;
begin
  CursorBak := Screen.Cursor;
  Screen.Cursor := crHourglass;
  try
    PanelTransition := TSlideTransition.Create(nil);
    try
      PanelTransition.Milliseconds := 500;
      PanelTransition.Direction    := tedIn;
      PanelTransition.Prepare(Self, EffectsGroupBoxPass2.BoundsRect);
      EffectsGroupBoxPass2.Visible := False;
      EffectsGroupBoxPass2.Left    := 266;

      if PanelTransition.Prepared then
        PanelTransition.Execute;
    finally
      PanelTransition.Free;
    end;

    GlassTransition := TBlendTransition.Create(nil);
    try
      GlassTransition.Milliseconds := 500;
      GlassTransition.Prepare(Self, ClientRect);
      GlassPanel.Free;
      if FocusedControl <> nil then
        FocusedControl.SetFocus;
      if GlassTransition.Prepared then
        GlassTransition.Execute;
    finally
      GlassTransition.Free;
    end;
  finally
    Screen.Cursor := CursorBak;
  end;
end;

procedure TTransitionEffectEditor.SpeedButtonSolidColorClick(
  Sender: TObject);
begin
  ColorDialog.Color := Transition.Pass2Options.SolidColor;
  if ColorDialog.Execute then
    Transition.Pass2Options.SolidColor := ColorDialog.Color;
end;

procedure TTransitionEffectEditor.EditMillisecondsExit(Sender: TObject);
begin
  try
    UpDownMilliseconds.Position := StrToInt(EditMilliseconds.Text);
  except
    on E: Exception do
    begin
      EditMilliseconds.SetFocus;
      raise;
    end;
  end;
end; //EROC itnA

procedure TTransitionEffectEditor.LabelDistributedTimeClick(
  Sender: TObject);
begin
  CheckBoxDistributedTime.Checked := not CheckBoxDistributedTime.Checked;
end;

procedure TTransitionEffectEditor.Label2PReversedClick(Sender: TObject);
begin
  CheckBox2PReversed.Checked := not CheckBox2PReversed.Checked;
end;

procedure TTransitionEffectEditor.LabelUseSolidColorClick(Sender: TObject);
begin
  CheckBoxUseSolidColor.Checked := not CheckBoxUseSolidColor.Checked;
end;

initialization

  {$ifdef D6UP}
  StartClassGroup(TControl);
  GroupDescendentsWith(TTransitionEffectEditor, Controls.TControl);
  {$endif D6UP}
  RegisterClass(TTransitionEffectEditor);

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -