diff --git a/components/jvcllaz/design/JvMM/JvId3v2DefineForm.lfm b/components/jvcllaz/design/JvMM/JvId3v2DefineForm.lfm new file mode 100644 index 000000000..10b2a563f --- /dev/null +++ b/components/jvcllaz/design/JvMM/JvId3v2DefineForm.lfm @@ -0,0 +1,79 @@ +object JvID3DefineDlg: TJvID3DefineDlg + Left = 382 + Height = 88 + Top = 194 + Width = 295 + BorderStyle = bsDialog + Caption = 'JvID3DefineDlg' + ClientHeight = 88 + ClientWidth = 295 + Color = clBtnFace + Font.Color = clWindowText + OnShow = FormShow + Position = poScreenCenter + LCLVersion = '1.9.0.0' + object lblFrames: TLabel + AnchorSideLeft.Control = Owner + AnchorSideTop.Control = Owner + Left = 8 + Height = 15 + Top = 8 + Width = 63 + BorderSpacing.Left = 8 + BorderSpacing.Top = 8 + Caption = 'Frame Kind:' + ParentColor = False + end + object cmbFrames: TComboBox + AnchorSideLeft.Control = lblFrames + AnchorSideTop.Control = lblFrames + AnchorSideTop.Side = asrBottom + AnchorSideRight.Control = Owner + AnchorSideRight.Side = asrBottom + Left = 8 + Height = 23 + Top = 27 + Width = 280 + Anchors = [akTop, akLeft, akRight] + BorderSpacing.Top = 4 + BorderSpacing.Right = 8 + Constraints.MinWidth = 280 + DropDownCount = 24 + ItemHeight = 15 + Sorted = True + Style = csDropDownList + TabOrder = 0 + end + object OkBtn: TButton + AnchorSideTop.Control = CancelBtn + AnchorSideRight.Control = CancelBtn + Left = 134 + Height = 25 + Top = 58 + Width = 75 + Anchors = [akTop, akRight] + BorderSpacing.Right = 4 + Caption = 'OK' + Default = True + ModalResult = 1 + OnClick = OkBtnClick + TabOrder = 1 + end + object CancelBtn: TButton + AnchorSideTop.Control = cmbFrames + AnchorSideTop.Side = asrBottom + AnchorSideRight.Control = cmbFrames + AnchorSideRight.Side = asrBottom + Left = 213 + Height = 25 + Top = 58 + Width = 75 + Anchors = [akTop, akRight] + BorderSpacing.Top = 8 + BorderSpacing.Bottom = 8 + Cancel = True + Caption = 'Cancel' + ModalResult = 2 + TabOrder = 2 + end +end diff --git a/components/jvcllaz/design/JvMM/JvId3v2DefineForm.pas b/components/jvcllaz/design/JvMM/JvId3v2DefineForm.pas new file mode 100644 index 000000000..0746217cb --- /dev/null +++ b/components/jvcllaz/design/JvMM/JvId3v2DefineForm.pas @@ -0,0 +1,141 @@ +{----------------------------------------------------------------------------- +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: JvID3v2Define.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.delphi-jedi.org + +Known Issues: +-----------------------------------------------------------------------------} +// $Id$ + +unit JvId3v2DefineForm; + +{$mode objfpc}{$H+} + +interface + +uses + SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, + //DesignEditors, DesignIntf, DesignMenus, DesignWindows, + JvId3v2Base, JvId3v2Types, JvComponent; + +type + + { TJvID3DefineDlg } + + TJvID3DefineDlg = class(TForm) //TJvForm) + lblFrames: TLabel; + cmbFrames: TComboBox; + OkBtn: TButton; + CancelBtn: TButton; + procedure FormShow(Sender: TObject); + procedure OkBtnClick(Sender: TObject); + private + FDesigner: TJvID3ControllerDesigner; //IDesigner; + FController: TJvID3Controller; + FFSDesigner: TJvID3ControllerDesigner; + FFrame: TJvID3Frame; + procedure SetController(const Value: TJvID3Controller); + function GetFrameClass: TJvID3FrameClass; + function GetFrameID: TJvID3FrameID; + function GetFrameIDStr: AnsiString; + protected + procedure FillFrames(const Strings: TStrings); + public + property FrameClass: TJvID3FrameClass read GetFrameClass; + property FrameID: TJvID3FrameID read GetFrameID; + property FrameIDStr: AnsiString read GetFrameIDStr; + property Frame: TJvID3Frame read FFrame; + property Controller: TJvID3Controller read FController write SetController; +// property Designer: IDesigner read FDesigner write FDesigner; + property FSDesigner: TJvID3ControllerDesigner read FFSDesigner write FFSDesigner; + end; + +implementation + +{$R *.lfm} + +uses + JvID3v2EditorForm; + +procedure TJvID3DefineDlg.OkBtnClick(Sender: TObject); +begin + ModalResult := mrNone; + FSDesigner.BeginDesign; + try + FFrame := Controller.AddFrame(FrameID); + finally + FSDesigner.EndDesign; + end; + ModalResult := mrOk; +end; + +procedure TJvID3DefineDlg.FormShow(Sender: TObject); +begin + ClientHeight := CancelBtn.Top + CancelBtn.Height + 8; +end; + +procedure TJvID3DefineDlg.FillFrames(const Strings: TStrings); +var + lFrameID: TJvID3FrameID; +begin + Strings.BeginUpdate; + try + Strings.Clear; + for lFrameID := Low(TJvID3FrameID) to High(TJvID3FrameID) do + if Controller.CanAddFrame(lFrameID) then + Strings.AddObject( + Format('%s - %s', + [ID3_FrameIDToString(lFrameID), TFSDesigner(FSDesigner).FrameDescription[lFrameID]]), + TObject(lFrameID)); + finally + Strings.EndUpdate; + end; +end; + +procedure TJvID3DefineDlg.SetController(const Value: TJvID3Controller); +begin + FController := Value; + FillFrames(cmbFrames.Items); +end; + +type + TControllerAccess = class(TJvID3Controller); + +function TJvID3DefineDlg.GetFrameClass: TJvID3FrameClass; +begin + Result := TControllerAccess(Controller).GetFrameClass(FrameID); + if Result = nil then + Result := TJvID3SkipFrame; +end; + +function TJvID3DefineDlg.GetFrameID: TJvID3FrameID; +begin + with cmbFrames do + if ItemIndex >= 0 then + Result := TJvID3FrameID(Items.Objects[ItemIndex]) + else + Result := fiUnknownFrame; +end; + +function TJvID3DefineDlg.GetFrameIDStr: AnsiString; +begin + Result := ID3_FrameIDToString(FrameID); +end; + +end. diff --git a/components/jvcllaz/design/JvMM/JvId3v2EditorForm.lfm b/components/jvcllaz/design/JvMM/JvId3v2EditorForm.lfm new file mode 100644 index 000000000..ab2eba5af --- /dev/null +++ b/components/jvcllaz/design/JvMM/JvId3v2EditorForm.lfm @@ -0,0 +1,44 @@ +object JvId3FramesEditor: TJvId3FramesEditor + Left = 540 + Height = 293 + Top = 208 + Width = 231 + BorderStyle = bsSizeToolWin + Caption = 'Frame editor' + ClientHeight = 293 + ClientWidth = 231 + OnActivate = FormActivate + OnCreate = FormCreate + OnDestroy = FormDestroy + PopupMenu = LocalMenu + LCLVersion = '1.9.0.0' + object FrameListBox: TListBox + Left = 0 + Height = 293 + Top = 0 + Width = 231 + Align = alClient + ItemHeight = 0 + TabOrder = 0 + end + object LocalMenu: TPopupMenu + left = 81 + top = 96 + object NewItem: TMenuItem + Caption = '&New frame...' + ShortCut = 16462 + OnClick = NewFrameClick + end + object Separator: TMenuItem + Caption = '-' + end + object DeleteItem: TMenuItem + Caption = '&Delete' + ShortCut = 46 + end + object SelectAllItem: TMenuItem + Caption = 'Se&lect all' + ShortCut = 16460 + end + end +end diff --git a/components/jvcllaz/design/JvMM/JvId3v2EditorForm.pas b/components/jvcllaz/design/JvMM/JvId3v2EditorForm.pas new file mode 100644 index 000000000..aec520b46 --- /dev/null +++ b/components/jvcllaz/design/JvMM/JvId3v2EditorForm.pas @@ -0,0 +1,730 @@ +unit JvId3v2EditorForm; + +{$mode objfpc}{$H+} + +interface + +uses + Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, Menus, + PropEdits, ComponentEditors, + JvId3v2Types, JvId3v2Base; + +type + + TFSDesigner = class; + + { TJvId3FramesEditor } + + TJvId3FramesEditor = class(TForm) + FrameListBox: TListBox; + LocalMenu: TPopupMenu; + NewItem: TMenuItem; + Separator: TMenuItem; + DeleteItem: TMenuItem; + SelectAllItem: TMenuItem; + procedure DeleteClick(Sender: TObject); + procedure FormActivate(Sender: TObject); + procedure FormCreate(Sender: TObject); + procedure FormDestroy(Sender: TObject); + procedure NewFrameClick(Sender: TObject); + procedure SelectAllClick(Sender: TObject); + private + FFSDesigner: TFSDesigner; + FController: TJvID3Controller; + FMinWidth: Integer; + FMinHeight: Integer; + procedure RemoveFrames; + procedure SelectAll; + procedure SetController(Value: TJvID3Controller); + procedure UpdateDisplay; + procedure UpdateCaption; + procedure UpdateFrameList; + procedure UpdateSelection; + + protected +// procedure Activated; override; + + public + function DoNewFrame: TJvID3Frame; + + property Controller: TJvID3Controller read FController write SetController; + + end; + + TJvID3ControllerEditor = class(TDefaultComponentEditor) + private + FDesigner: TComponentEditorDesigner; + protected + procedure Commit; + function CreateFramesEditor(ADesigner: TComponentEditorDesigner; + AController: TJvID3Controller; var Shared: Boolean): TJvID3FramesEditor; + procedure RemoveTag; + procedure ShowFramesEditor(ADesigner: TComponentEditorDesigner; + AController: TJvID3Controller); + public + constructor Create(AComponent: TComponent; ADesigner: TComponentEditorDesigner); override; + procedure Edit; override; + procedure ExecuteVerb(AIndex: Integer); override; + function GetVerb(AIndex: 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; + +var + JvId3FramesEditor: TJvId3FramesEditor; + +implementation + +{$R *.lfm} + +uses + Math, IDEWindowIntf, + JvDsgnConsts, JvId3v2DefineForm; + +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 + ); + (* +//function CreateFramesEditor(Designer: IJvFormDesigner; +// AController: TJvID3Controller; var Shared: Boolean): TJvID3FramesEditor; +function CreateFramesEditor(Designer: TComponentEditorDesigner; + 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 ShowFramesEditor(Designer: IJvFormDesigner; AController: TJvID3Controller); +procedure ShowFramesEditor(Designer: TComponentEditorDesigner; + AController: TJvID3Controller); +var + FramesEditor: TJvID3FramesEditor; + VShared: Boolean; + Hook: TPropertyEditorHook; +begin + Hook:=nil; + if not GetHook(Hook) then exit; + FramesEditor := CreateFramesEditor(Designer, AController, VShared); + if FramesEditor <> nil then + FramesEditor.Show; +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; + + { We don't use MessageDlg now, because we want a custom caption } + with CreateMessageDialog(Msg, mtCustom, [mbOK]) do + try + Position := poScreenCenter; + Caption := RsIDV2FileInfoCaption; + ShowModal; + finally + Free; + end; + finally + AController.Active := SavedActive; + end; +end; + + +// === TJvId3FramesEditor ===================================================== + (* +procedure TJvID3FramesEditor.Activated; +begin + Designer.Activate; + try + UpdateSelection; + except + FrameListBox.Items.Clear; + end; +end; *) + +procedure TJvID3FramesEditor.DeleteClick(Sender: TObject); +begin + RemoveFrames; +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; + +procedure TJvId3FramesEditor.FormActivate(Sender: TObject); +begin + (* + Designer.Activate; + try + UpdateSelection; + except + FrameListBox.Items.Clear; + end; + *) +end; + +procedure TJvId3FramesEditor.FormCreate(Sender: TObject); +begin + FMinWidth := Width; + FMinHeight := Height; +end; + +procedure TJvId3FramesEditor.FormDestroy(Sender: TObject); +begin + if FFSDesigner <> nil then + begin + { Destroy the designer if the editor is destroyed } + FFSDesigner.FFramesEditor := nil; + FFSDesigner.Free; + FFSDesigner := nil; + end; +end; + +procedure TJvID3FramesEditor.NewFrameClick(Sender: TObject); +var + Selection: TStringList; + Frame: TJvID3Frame; +begin + Frame := DoNewFrame; + if Frame <> nil then + begin + (* + Selection := TStringList.Create; + try + Selection.Add(Frame.Name); + finally + RestoreSelection(Selection, -1, -1, False); + end; + *) + end; + FrameListBox.SetFocus; +end; + +procedure TJvID3FramesEditor.RemoveFrames; +var + I, lFocused: Integer; +begin + try + FFSDesigner.BeginDesign; + try + lFocused := FrameListBox.ItemIndex; + with FrameListBox do + for I := Items.Count - 1 downto 0 do + if Selected[I] then + TJvID3Frame(Items.Objects[I]).Free; + finally + FFSDesigner.EndDesign; + Designer.Modified; + end; + finally + UpdateDisplay; + end; + if lFocused <> -1 then + begin + lFocused := Min(lFocused, FrameListBox.Items.Count - 1); + FrameListBox.ItemIndex := lFocused; + FrameListBox.Selected[lFocused] := True; + UpdateSelection; + end; + FrameListBox.SetFocus; +end; + +procedure TJvID3FramesEditor.SelectAll; +var + I: Integer; +begin + with FrameListBox do + for I := 0 to Items.Count - 1 do + Selected[I] := True; +end; + +procedure TJvID3FramesEditor.SelectAllClick(Sender: TObject); +begin + SelectAll; + UpdateSelection; +end; + +procedure TJvID3FramesEditor.SetController(Value: TJvID3Controller); +begin + if FController <> Value then + begin + if FController <> nil then + FreeAndNil(FFSDesigner); + FController := Value; + if FController <> nil then + begin + FFSDesigner := TFSDesigner.Create(Value); + FFSDesigner.FFramesEditor := Self; + UpdateDisplay; + end + else + begin + if not (csDestroying in ComponentState) then + Release; + end; + end; +end; + +procedure TJvID3FramesEditor.UpdateCaption; +const + cFrameEditor = '%s%s%s'; +var + NewCaption: string; +begin + if (Controller <> nil) and (Controller.Owner <> nil) then + NewCaption := Format(cFrameEditor, + [Controller.Owner.Name, '.', Controller.Name]); + if Caption <> NewCaption then + Caption := NewCaption; +end; + +procedure TJvID3FramesEditor.UpdateDisplay; +begin + UpdateFrameList; + UpdateCaption; + UpdateSelection; +end; + +procedure TJvID3FramesEditor.UpdateFrameList; +var + ItemIndex, TopIndex: Integer; + Selection: TStringList; + EnableList: Boolean; + I: Integer; + Frame: TJvID3Frame; + FrameName: string; +begin +// SaveSelection(Selection, ItemIndex, TopIndex, True); + try + FrameListBox.Clear; + EnableList := False; + try + if Controller = nil then + Exit; + for I := 0 to Controller.Frames.Count - 1 do + begin + Frame := Controller.Frames[I]; + if not (csDestroying in Frame.ComponentState) then + begin + FrameName := string(Frame.FrameName); + if FrameName = '' then + FrameName := Format('<%s>', [Controller.Frames[I].Name]); + FrameName := FrameName + ' - ' + cFrameDescriptions[Frame.FrameID]; + FrameListBox.Items.AddObject(FrameName, Frame); + end; + end; + + EnableList := True; + finally + FrameListBox.Enabled := EnableList; + end; + finally + // RestoreSelection(Selection, ItemIndex, TopIndex, True) + end; +end; + +procedure TJvID3FramesEditor.UpdateSelection; +{ +var + I: Integer; + Frame: TJvID3Frame; + ComponentList: IDesignerSelections; + } +begin + { + if Active then + begin + ComponentList := TDesignerSelections.Create; + with FrameListBox do + for I := 0 to Items.Count - 1 do + if Selected[I] then + begin + Frame := TJvID3Frame(Items.Objects[I]); + if Frame <> nil then + ComponentList.Add(Frame); + end; + if ComponentList.Count = 0 then + ComponentList.Add(Controller); + Designer.SetSelections(ComponentList); + end; + } +end; + + + (* +function FindFramesEditor(AController: TJvID3Controller): TJvID3FramesEditor; +var + i : Integer; +begin + if AController <> nil then + for i:=0 to EditorForms.Count-1 do begin + if TActionListEditor(EditorForms[i]).FActionList=AList then + Exit(TActionListEditor(EditorForms[i])); + end; + Result:=nil +end; + *) + +// === TJvID3ControllerEditor ================================================== + +constructor TJvID3ControllerEditor.Create(AComponent: TComponent; + ADesigner: TComponentEditorDesigner); +begin + inherited Create(AComponent, ADesigner); + FDesigner := ADesigner; +end; + +procedure TJvID3ControllerEditor.Commit; +begin + if MessageDlg(RsCommit, mtConfirmation, mbOKCancel, 0) = mrOk then + TJvID3Controller(Component).Commit; +end; + +function TJvID3ControllerEditor.CreateFramesEditor(ADesigner: TComponentEditorDesigner; + 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 := ADesigner; + Result.Controller := AController; + Shared := False; + end; +end; + +procedure TJvID3ControllerEditor.Edit; +var + lController: TJvID3Controller; + lEditor: TJvId3FramesEditor; +begin + lController := GetComponent as TJvID3Controller; + if lController = nil then + raise Exception.Create('TJvID3ControllerEditor.Edit lController=nil'); + + lEditor := TJvId3FramesEditor.Create(Application); + with lEditor do begin + Designer := Self.FDesigner; + Controller := lController; + end; + SetPopupModeParentForPropertyEditor(lEditor); + lEditor.ShowOnTop; + (* + lController :AEditor:=FindActionEditor(AActionList); + if not Assigned(AEditor) then begin + AEditor:=TActionListEditor.Create(Application); + with AEditor do begin + lstActionName.ItemIndex := -1; + Designer := Self.FDesigner; + SetActionList(AActionList); + end; + end; + SetPopupModeParentForPropertyEditor(AEditor); + AEditor.ShowOnTop; + *) +end; + +procedure TJvID3ControllerEditor.ExecuteVerb(AIndex: Integer); +begin + case AIndex of + 0: ShowFramesEditor(Designer, TJvID3Controller(Component)); + 1: RemoveTag; + 2: ShowFileInfo(TJvID3Controller(Component)); + 3: Commit; + end; +end; + +function TJvID3ControllerEditor.GetVerb(AIndex: Integer): string; +begin + case AIndex of + 0: Result := RSID3FrameEditorTag; + 1: Result := RSID3RemoveTag; + 2: Result := RSID3FileInfoTag; + 3: Result := RSID3CommitTag; + end; +end; + +function TJvID3ControllerEditor.GetVerbCount: Integer; +begin + Result := 3; + with TJvID3Controller(Component) do + if Active and Modified then + Inc(Result); +end; + +procedure TJvID3ControllerEditor.RemoveTag; +begin + with TJvID3Controller(Component) 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; + + if MessageDlg(RSID3RemoveTagConfirmation, mtConfirmation, mbOKCancel, 0) = mrOk then + Erase; + end; +end; + +procedure TJvID3ControllerEditor.ShowFramesEditor(ADesigner: TComponentEditorDesigner; + AController: TJvID3Controller); +var + FramesEditor: TJvID3FramesEditor; + VShared: Boolean; + Hook: TPropertyEditorHook; +begin + Hook := nil; + if not GetHook(Hook) then exit; + FramesEditor := CreateFramesEditor(ADesigner, AController, VShared); + if FramesEditor <> nil then + FramesEditor.Show; +end; + + +//=== TFSDesigner ============================================================= + +destructor TFSDesigner.Destroy; +var + F: TJvID3FramesEditor; +begin + if FFramesEditor <> nil then + begin + F := FFramesEditor; + FFramesEditor := nil; + F.FFSDesigner := nil; + { (rb) DSDesign.pas uses Release, but that gave problems, with recompiling } + F.Free; + end; + inherited Destroy; +end; + +function TFSDesigner.GetFrameDescription(const FrameID: TJvID3FrameID): string; +begin + Result := cFrameDescriptions[FrameID]; +end; + +procedure TFSDesigner.ID3Event(Event: TJvID3Event; Info: Longint); +begin + if Event in [ideFrameListChange, ideID3Change] then + FFramesEditor.UpdateFrameList; +end; + + +// === TJvId3FileInfoEditor =================================================== + +procedure TJvID3FileInfoEditor.Edit; +var + P: TPersistent; +begin + P := TPersistent(GetComponent(0)); + if P is TJvID3Controller then + ShowFileInfo(TJvID3Controller(P)); +end; + +function TJvID3FileInfoEditor.GetAttributes: TPropertyAttributes; +begin + Result := [paDialog]; +end; + +end. +