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

📄 jvqid3v2editorform.pas

📁 East make Tray Icon in delphi
💻 PAS
📖 第 1 页 / 共 2 页
字号:
{******************************************************************************}
{* WARNING:  JEDI VCL To CLX Converter generated unit.                        *}
{*           Manual modifications will be lost on next release.               *}
{******************************************************************************}

{-----------------------------------------------------------------------------
The contents of this file are subject to the Mozilla Public License
Version 1.1 (the "License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/MPL-1.1.html

Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either expressed or implied. See the License for
the specific language governing rights and limitations under the License.

The Original Code is: JvID3v2Editor.PAS, released on 2003-04-16.

The Initial Developer of the Original Code is Remko Bonte [remkobonte att myrealbox dott com]
Portions created by Remko Bonte are Copyright (C) 2003 Remko Bonte.
All Rights Reserved.

Contributor(s):

You may retrieve the latest version of this file at the Project JEDI's JVCL home page,
located at http://jvcl.sourceforge.net

Known Issues:
-----------------------------------------------------------------------------}
// $Id: JvQID3v2EditorForm.pas,v 1.1 2004/12/04 00:37:03 asnepvangers Exp $

unit JvQID3v2EditorForm;

{$I jvcl.inc}

interface

{ Most code is copied from DSDesign.pas }

uses
  Classes, QWindows, QMessages, QForms, QStdCtrls, QExtCtrls, QMenus, QControls, 
  DesignEditors, DesignIntf, DesignMenus, QDesignWindows, 
  JvQID3v2Base, JvQID3v2Types, JvQDsgnTypes, QTypes;

type
  TSelectionProc = function(AFrame: TJvID3Frame): Boolean of object;

  TFSDesigner = class;

  TJvID3FramesEditor = class(TDesignWindow)
    FrameListBox: TListBox;
    LocalMenu: TPopupMenu;
    NewItem: TMenuItem;
    N1: TMenuItem;
    DeleteItem: TMenuItem;
    SelectAllItem: TMenuItem;
    procedure FormCreate(Sender: TObject);
    procedure ListBoxClick(Sender: TObject);
    procedure ListBoxKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure ListBoxDragDrop(Sender, Source: TObject; X, Y: Integer);
    procedure ListBoxDragOver(Sender, Source: TObject; X, Y: Integer;
      State: TDragState; var Accept: Boolean);
    procedure FormDestroy(Sender: TObject);
    procedure NewFrameClick(Sender: TObject);
    procedure DeleteClick(Sender: TObject);
    procedure SelectAllClick(Sender: TObject);
  private
    FFSDesigner: TFSDesigner;
    FController: TJvID3Controller;
    FFocusRectItem: Integer;
    FMinWidth: Integer;
    FMinHeight: Integer;
    procedure MoveFrames(MoveOffset: Integer);
    procedure RemoveFrames;
    procedure SelectAll;
    procedure RestoreSelection(var Selection: TStringList;
      ItemIndex, TopIndex: Integer; RestoreUpdate: Boolean);
    procedure SaveSelection(var Selection: TStringList;
      var ItemIndex, TopIndex: Integer; NoUpdate: Boolean);
    procedure SetController(Value: TJvID3Controller);
    procedure UpdateDisplay;
    procedure UpdateCaption;
    procedure UpdateFrameList;
    procedure UpdateSelection;
//    procedure WMGetMinMaxInfo(var Msg: TWMGetMinMaxInfo); message WM_GETMINMAXINFO;
  protected
    procedure Activated; override;
    function UniqueName(Component: TComponent): string; override;
  public
    function ForEachSelection(Proc: TSelectionProc): Boolean;
    function DoNewFrame: TJvID3Frame; 
    function EditAction(Action: TEditAction): Boolean; override;
    procedure ItemDeleted(const ADesigner: IDesigner; AItem: TPersistent); override;
    procedure SelectionChanged(const ADesigner: IDesigner; const ASelection: IDesignerSelections); override;
    procedure ItemsModified(const Designer: IDesigner); override; 
    property Controller: TJvID3Controller read FController write SetController;
  end;

  TJvID3ControllerEditor = class(TComponentEditor)
  protected
    procedure Commit;
    procedure RemoveTag;
  public
    procedure ExecuteVerb(Index: Integer); override;
    function GetVerb(Index: Integer): string; override;
    function GetVerbCount: Integer; override;
  end;

  TFSDesigner = class(TJvID3ControllerDesigner)
  private
    FFramesEditor: TJvID3FramesEditor;
    function GetFrameDescription(const FrameID: TJvID3FrameID): string;
  public
    destructor Destroy; override;
    procedure ID3Event(Event: TJvID3Event; Info: Longint); override;
    property FramesEditor: TJvID3FramesEditor read FFramesEditor;
    property FrameDescription[const FrameID: TJvID3FrameID]: string read GetFrameDescription;
  end;

  TJvID3FileInfoEditor = class(TClassProperty)
  public
    procedure Edit; override;
    function GetAttributes: TPropertyAttributes; override;
  end;

procedure ShowFramesEditor(Designer: IJvFormDesigner; AController: TJvID3Controller);
function CreateFramesEditor(Designer: IJvFormDesigner;
  AController: TJvID3Controller; var Shared: Boolean): TJvID3FramesEditor;
procedure ShowFileInfo(AController: TJvID3Controller);

implementation

uses
  QDialogs,
  Math, SysUtils,
  JvQID3v2DefineForm, JvQTypes, JvQDsgnConsts;


{$R *.xfm}

type
  TJvID3ControllerAccess = class(TJvID3Controller);

const
  cFrameDescriptions: array [TJvID3FrameID] of string =
   (
    RsfiErrorFrame,
    RsfiPaddingFrame,
    RsfiNoFrame,
    RsfiAudioCrypto,
    RsfiPicture,
    RsfiAudioSeekPoint,
    RsfiComment,
    RsfiCommercial,
    RsfiCryptoReg,
    RsfiEqualization2,
    RsfiEqualization,
    RsfiEventTiming,
    RsfiGeneralObject,
    RsfiGroupingReg,
    RsfiInvolvedPeople,
    RsfiLinkedInfo,
    RsfiCDID,
    RsfiMPEGLookup,
    RsfiOwnership,
    RsfiPrivate,
    RsfiPlayCounter,
    RsfiPopularimeter,
    RsfiPositionsync,
    RsfiBufferSize,
    RsfiVolumeAdj2,
    RsfiVolumeAdj,
    RsfiReverb,
    RsfiSeekFrame,
    RsfiSignature,
    RsfiSyncedLyrics,
    RsfiSyncedTempo,
    RsfiAlbum,
    RsfiBPM,
    RsfiComposer,
    RsfiContentType,
    RsfiCopyright,
    RsfiDate,
    RsfiEncodingTime,
    RsfiPlaylistDelay,
    RsfiOrigReleaseTime,
    RsfiRecordingTime,
    RsfiReleaseTime,
    RsfiTaggingTime,
    RsfiInvolvedPeople2,
    RsfiEncodedBy,
    RsfiLyricist,
    RsfiFileType,
    RsfiTime,
    RsfiContentGroup,
    RsfiTitle,
    RsfiSubTitle,
    RsfiInitialKey,
    RsfiLanguage,
    RsfiSongLen,
    RsfiMusicianCreditList,
    RsfiMediaType,
    RsfiMood,
    RsfiOrigAlbum,
    RsfiOrigFileName,
    RsfiOrigLyricist,
    RsfiOrigArtist,
    RsfiOrigYear,
    RsfiFileOwner,
    RsfiLeadArtist,
    RsfiBand,
    RsfiConductor,
    RsfiMixArtist,
    RsfiPartInSet,
    RsfiProducedNotice,
    RsfiPublisher,
    RsfiTrackNum,
    RsfiRecordingDates,
    RsfiNetRadioStation,
    RsfiNetRadioOwner,
    RsfiSize,
    RsfiAlbumSortOrder,
    RsfiPerformerSortOrder,
    RsfiTitleSortOrder,
    RsfiISRC,
    RsfiEncoderSettings,
    RsfiSetSubTitle,
    RsfiUserText,
    RsfiYear,
    RsfiUniqueFileID,
    RsfiTermsOfUse,
    RsfiUnsyncedLyrics,
    RsfiWWWCommercialInfo,
    RsfiWWWCopyright,
    RsfiWWWAudioFile,
    RsfiWWWArtist,
    RsfiWWWAudioSource,
    RsfiWWWRadioPage,
    RsfiWWWPayment,
    RsfiWWWPublisher,
    RsfiWWWUser,
    RsfiMetaCrypto,
    RsfiMetaCompression
   );

procedure ShowFramesEditor(Designer: IJvFormDesigner; AController: TJvID3Controller);
var
  FramesEditor: TJvID3FramesEditor;
  VShared: Boolean;
begin
  FramesEditor := CreateFramesEditor(Designer, AController, VShared);
  if FramesEditor <> nil then
    FramesEditor.Show;
end;

function CreateFramesEditor(Designer: IJvFormDesigner;
  AController: TJvID3Controller; var Shared: Boolean): TJvID3FramesEditor;
begin
  Shared := True;
  if AController.Designer <> nil then
    Result := (AController.Designer as TFSDesigner).FFramesEditor
  else
  begin
    Result := TJvID3FramesEditor.Create(Application);
    Result.Designer := Designer;
    Result.Controller := AController;
    Shared := False;
  end;
end;

procedure ShowFileInfo(AController: TJvID3Controller);
const
  cVersion: array [TJvMPEGVersion] of string =
    (RsMPEG25, RsMPEGUnknown, RsMPEG20, RsMPEG10);
  cLayer: array [TJvMPEGLayer] of string =
    (RsLayerUnknown, RsLayer3, RsLayer2, RsLayer1);
  cChannelMode: array [TJvMPEGChannelMode] of string =
    (RsChannelModeStereo, RsChannelModeJointStereo,
     RsChannelModeDualChannel, RsChannelModeMono);
  cEmphasis: array [TJvMPEGEmphasis] of string =
    (RsEmphasisNone, RsEmphasisMicrosec, RsEmphasisUnknown, RsEmphasisCCITTJ17);
  cBool: array [Boolean] of string =
    (RsBoolNo, RsBoolYes);
  cVbr: array [Boolean] of string =
    (RsVbrNo, RsVbrVbr);
var
  Msg: string;
  SavedActive: Boolean;
begin
  SavedActive := AController.Active;
  try
    with TJvID3ControllerAccess(AController) do
    begin
      if FileName = '' then
      begin
        MessageDlg(RsID3Err_NoFileSpecified, mtError, [mbOK], 0);
        Exit;
      end;

      if not FileExists(FileName) then
      begin
        MessageDlg(Format(RSID3Err_FileDoesNotExists, [FileName]),
          mtError, [mbOK], 0);
        Exit;
      end;

      Active := True;

      with FileInfo do
      begin
        if not IsValid then
        begin
          MessageDlg(RSID3Err_NoValidMPEGTag, mtError, [mbOK], 0);
          Exit;
        end;

        Msg := Format(RsIDV2FileInfoFmt, [FileSize, HeaderFoundAt, LengthInSec,
          cVersion[Version], cLayer[Layer], Bitrate, cVbr[IsVbr], FrameCount,
          SamplingRateFrequency, cChannelMode[ChannelMode],
          cBool[mbProtection in Bits], cBool[mbCopyrighted in Bits],
          cBool[mbOriginal in Bits], cEmphasis[Emphasis]]);
      end;
    end;
    MessageDlg(RsIDV2FileInfoCaption, msg, mtCustom, [mbOk], 0);
    (*
    { We don't use MessageDlg now, because we want a custom caption }
    with CreateMessageDialog(Msg, mtCustom, [mbOK], [mbOK]) do
    try
      Position := poScreenCenter;
      Caption := RsIDV2FileInfoCaption;
      ShowModal;
    finally
      Free;
    end;
    *)
  finally
    AController.Active := SavedActive;
  end;
end;

//=== { TJvID3FrameEditor } ==================================================

procedure TJvID3FramesEditor.Activated;
begin 
  Designer.Activate; 
  try
    UpdateSelection;
  except
    FrameListBox.Items.Clear;
  end;
end;



function TJvID3FramesEditor.DoNewFrame: TJvID3Frame;
var
  DefineFrame: TJvID3DefineDlg;
begin
  Result := nil;
  DefineFrame := TJvID3DefineDlg.Create(Application);
  try
    DefineFrame.FSDesigner := FFSDesigner;
    DefineFrame.Designer := Designer;
    DefineFrame.Controller := Controller;
    if DefineFrame.ShowModal = mrOk then
    begin
      Result := DefineFrame.Frame;
      if Visible then
        UpdateDisplay;
      Designer.Modified;
    end;
  finally
    DefineFrame.Release;
  end;
end;


function TJvID3FramesEditor.EditAction(Action: TEditAction): Boolean;

begin 
  Result := True; 
  case Action of
    {eaCut: Cut;
    eaCopy: Copy;
    eaPaste: Paste;}
    eaDelete:
      RemoveFrames;
    eaSelectAll:
      begin
        SelectAll;
        UpdateSelection;
      end; 
  else
    Result := False; 
  end;
end;

function TJvID3FramesEditor.ForEachSelection(Proc: TSelectionProc): Boolean;
var
  Frame: TJvID3Frame;
  I: Integer;
begin
  Result := False;
  with FrameListBox do
    for I := 0 to Items.Count - 1 do
      if Selected[I] then
      begin
        Frame := TJvID3Frame(Items.Objects[I]);
        if (Frame <> nil) and not Proc(Frame) then
          Exit;
      end;
  Result := True;
end;


procedure TJvID3FramesEditor.ItemDeleted(const ADesigner: IDesigner; AItem: TPersistent);
begin
  if AItem = Controller then
    Controller := nil
  else
  if (AItem is TJvID3Frame) and (TJvID3Frame(AItem).Controller = Controller) then
    UpdateDisplay;
end;



procedure TJvID3FramesEditor.ItemsModified(const Designer: IDesigner);

begin
  UpdateCaption;
end;

procedure TJvID3FramesEditor.MoveFrames(MoveOffset: Integer);
var
  I, E: Integer;
begin
  try
    FFSDesigner.BeginDesign;
    try
      with FrameListBox do
      begin
        I := 0;
        E := Items.Count;
        if MoveOffset > 0 then
        begin
          I := E - 1;
          E := -1;
        end;
        while I <> E do
        begin
          if Selected[I] then
            with TJvID3Frame(Items.Objects[I]) do
              Index := Index + MoveOffset;
          Inc(I, -MoveOffset);
        end;
      end;
    finally
      FFSDesigner.EndDesign;
    end;
  finally
    UpdateDisplay;
    Designer.Modified;
  end;
end;

procedure TJvID3FramesEditor.RemoveFrames;
var
  I, Focused: Integer;
begin
  try
    FFSDesigner.BeginDesign;
    try
      Focused := FrameListBox.ItemIndex;
      with FrameListBox do

⌨️ 快捷键说明

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