tvplanit: Fix TVpGeneralFilenameProperty (renamed from TVpGenericFilenameProperty). Register TVpLocalizeFilenameProperty and TVpWavFilenameProperty (instead of TVpWavFileProperty).

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@4863 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2016-06-29 09:51:37 +00:00
parent 10325574c0
commit 7348cfd58a
2 changed files with 119 additions and 14 deletions

View File

@ -626,8 +626,7 @@ object MainForm: TMainForm
end end
object VpControlLink1: TVpControlLink object VpControlLink1: TVpControlLink
DataStore = VpBufDSDataStore1 DataStore = VpBufDSDataStore1
DefaultCountry = 'England' LocalizationFile = '../../vplocalize.xml'
LocalizationFile = 'vplocalize.xml'
Printer.BottomMargin = 0 Printer.BottomMargin = 0
Printer.DayStart = h_08 Printer.DayStart = h_08
Printer.DayEnd = h_05 Printer.DayEnd = h_05

View File

@ -93,23 +93,38 @@ type
procedure SetValue (const Value : string); override; procedure SetValue (const Value : string); override;
end; end;
TVpGenericFileNameProperty = class (TStringProperty) TVpGeneralFileNameProperty = class (TStringProperty)
protected protected
function GetDefaultExt: String; virtual;
function GetFilter: String; virtual;
function GetInitialDir: String; virtual;
public public
function GetAttributes: TPropertyAttributes; override; function GetAttributes: TPropertyAttributes; override;
function GetValue: string; override;
procedure Edit; override; procedure Edit; override;
procedure SetValue(const NewValue: String); override;
end; end;
TVpLocalizeFileNameProperty = class (TVpGenericFileNameProperty) TVpLocalizeFileNameProperty = class (TVpGeneralFileNameProperty)
protected
function GetDefaultExt: String; override;
function GetFilter: String; override;
end; end;
TVpWavFileProperty = class(TStringProperty) TVpWavFilenameProperty = class(TVpGeneralFilenameProperty)
protected
function GetDefaultExt: String; override;
function GetFilter: String; override;
function GetInitialDir: String; override;
end;
{
public public
function GetAttributes: TPropertyAttributes; override; function GetAttributes: TPropertyAttributes; override;
function GetValue: string; override; function GetValue: string; override;
procedure Edit; override; procedure Edit; override;
procedure SetValue(const Value: string); override; procedure SetValue(const Value: string); override;
end; end;
}
TVpMediaFolderProperty = class(TStringProperty) TVpMediaFolderProperty = class(TStringProperty)
public public
@ -274,12 +289,76 @@ end;
{=====} {=====}
(*****************************************************************************) (*****************************************************************************)
{ TVpGenericFileNameProperty } { TVpGeneralFileNameProperty }
function TVpGenericFileNameProperty.GetAttributes: TPropertyAttributes;
function TVpGeneralFileNameProperty.GetAttributes: TPropertyAttributes;
begin begin
Result := [paDialog]; Result := [paDialog];
end; end;
procedure TVpGeneralFileNameProperty.Edit;
var
dlg: TOpenDialog;
begin
dlg := TOpenDialog.Create(Application);
try
dlg.DefaultExt := GetDefaultExt;
dlg.Filter := GetFilter;
dlg.FilterIndex := 1;
dlg.InitialDir := GetInitialDir;
dlg.Options := [ofHideReadOnly];
dlg.Filename := GetValue;
if dlg.Execute then
SetValue(dlg.Filename);
finally
dlg.Free;
end;
end;
function TVpGeneralFilenameProperty.GetDefaultExt: String;
begin
Result := '*.*';
end;
function TVpGeneralFilenameProperty.GetFilter: String;
begin
Result := 'All files (*.*)|*.*';
end;
function TVpGeneralFilenameProperty.GetInitialDir: String;
var
filename: String;
begin
filename := GetValue;
if filename <> '' then
Result := ExtractFileDir(filename) else
Result := '';
end;
function TVpGeneralFileNameProperty.GetValue: string;
begin
Result := GetStrValue;
end;
procedure TVpGeneralFilenameProperty.SetValue(const NewValue: string);
begin
SetStrValue(NewValue);
end;
{ TVpLocalizeFilenameProperty }
function TVpLocalizeFilenameProperty.GetDefaultExt: String;
begin
Result := '*.xml';
end;
function TVpLocalizeFilenameProperty.GetFilter: String;
begin
Result := 'Localization files (*.xml)|*.xml|' + inherited;
end;
{
procedure TVpGenericFileNameProperty.Edit; procedure TVpGenericFileNameProperty.Edit;
const const
VpRegLocalizeFilter = 'Localization Files (*.XML)|*.XML'; VpRegLocalizeFilter = 'Localization Files (*.XML)|*.XML';
@ -305,17 +384,44 @@ begin
Dlg.Filter := Filter; Dlg.Filter := Filter;
Dlg.FilterIndex := 0; Dlg.FilterIndex := 0;
Dlg.Options := [ofHideReadOnly]; Dlg.Options := [ofHideReadOnly];
{ Dlg.FileName := Value; // Dlg.FileName := Value;
if Dlg.Execute then // if Dlg.Execute then
Value := Dlg.FileName; } // Value := Dlg.FileName;
finally finally
Dlg.Free; Dlg.Free;
end; end;
end; end;
}
{ TVpWavFilenameProperty }
function TVpWavFilenameProperty.GetDefaultExt: String;
begin
Result := '*.wav';
end;
function TVpWavFilenameProperty.GetFilter: String;
begin
Result := 'Wav files (*.wav)|*.wav|All files (*.*)|*.*';
end;
function TVpWavFilenameProperty.GetInitialDir: String;
var
ds: TVpCustomDatastore;
begin
ds := GetComponent(0) as TVpCustomDatastore;
if Assigned(ds) then begin
if ds.DefaultEventSound = '' then
Result := ds.MediaFolder
else
Result := ExtractFilePath(ds.DefaultEventSound);
end else
Result := '';
end;
{ TVpWavFileProperty } { TVpWavFileProperty }
{
function TVpWavFileProperty.GetAttributes: TPropertyAttributes; function TVpWavFileProperty.GetAttributes: TPropertyAttributes;
begin begin
Result := [paDialog]; Result := [paDialog];
@ -357,7 +463,7 @@ begin
else else
inherited; inherited;
end; end;
}
{ TVpMediaFolderProperty } { TVpMediaFolderProperty }
@ -473,11 +579,11 @@ begin
// NO - not useful in design mode because there is not platform-independent way // NO - not useful in design mode because there is not platform-independent way
// to play the sound } // to play the sound }
RegisterPropertyEditor(TypeInfo(string), TVpCustomDataStore, RegisterPropertyEditor(TypeInfo(string), TVpCustomDataStore,
'DefaultEventSound', TWavFileProperty); 'DefaultEventSound', TWavFilenameProperty);
{$ENDIF} {$ENDIF}
RegisterPropertyEditor(TypeInfo(String), TVpCustomDatastore, RegisterPropertyEditor(TypeInfo(String), TVpCustomDatastore,
'DefaultEventSound', TVpWavFileProperty); 'DefaultEventSound', TVpWavFilenameProperty);
RegisterPropertyEditor(TypeInfo(String), TVpCustomDatastore, RegisterPropertyEditor(TypeInfo(String), TVpCustomDatastore,
'MediaFolder', TVpMediaFolderProperty); 'MediaFolder', TVpMediaFolderProperty);