MMDSProps.pas
上传用户:hylc_2004
上传日期:2014-01-23
资源大小:46800k
文件大小:8k
- unit MMDSProps;
- {$I COMPILER.INC}
- interface
- uses
- {$IFDEF DELPHI6}
- DesignIntf,
- DesignEditors,
- {$ELSE}
- DsgnIntf,
- {$ENDIF}
- Windows,
- Controls,
- Classes,
- SysUtils,
- Typinfo,
- MMObj,
- MMWavPrp,
- MMDSEdtr,
- MMDSMix,
- MMDSCptr,
- MMDSCon;
- type
- {-- TMMDSEditorEditObjectProperty --------------------------------------------}
- TMMDSEditorEditObjectProperty = class(TComponentProperty)
- private
- FList : TStringList;
- procedure AddToList(const S: string);
- public
- procedure GetValues(Proc: TGetStrProc); override;
- end;
- {-- TMM3DSoundProperty -------------------------------------------------------}
- TMM3DSoundProperty = class(TClassProperty)
- public
- procedure Edit; override;
- function GetAttributes: TPropertyAttributes; override;
- end;
- {-- TMMDSWaveMixerEditor -----------------------------------------------------}
- TMMDSWaveMixerEditor = class(TComponentEditor)
- public
- function GetVerbCount: Integer; override;
- function GetVerb(Index: Integer): string; override;
- procedure ExecuteVerb(Index: Integer); override;
- end;
- {-- TMMDSMixChannelEditor ----------------------------------------------------}
- TMMDSMixChannelEditor = class(TMMWaveComponentEditor)
- public
- function GetVerbCount: Integer; override;
- function GetVerb(Index: Integer): string; override;
- procedure ExecuteVerb(Index: Integer); override;
- end;
- {-- TMMDSWaveFormatProperty -------------------------------------------------}
- TMMDSWaveFormatProperty = class(TStringProperty)
- public
- procedure Edit; override;
- function GetAttributes: TPropertyAttributes; override;
- end;
- {-- TMMDSWaveFormatComponentEditor ------------------------------------------}
- TMMDSWaveFormatComponentEditor = class(TComponentEditor)
- public
- procedure ExecuteVerb(Index: Integer); override;
- function GetVerb(Index: Integer): string; override;
- function GetVerbCount: Integer; override;
- end;
- {-- TMMDSChannelConnectorEditor -------------------------------------------}
- TMMDSChannelConnectorEditor = class(TComponentProperty)
- protected
- CheckProc: TGetStrProc;
- procedure CheckComponent(const Value: string); virtual;
- public
- procedure GetValues(Proc: TGetStrProc); override;
- end;
-
- implementation
- {== TMMDSEditorEditObjectProperty ============================================}
- procedure TMMDSEditorEditObjectProperty.AddToList(const S: string);
- begin
- FList.Add(S);
- end;
- {-- TMMDSEditorEditObjectProperty --------------------------------------------}
- procedure TMMDSEditorEditObjectProperty.GetValues(Proc: TGetStrProc);
- var
- i: Integer;
- C: TComponent;
- begin
- FList := TStringList.Create;
- try
- if (Designer <> nil) then
- begin
- Designer.GetComponentNames(GetTypeData(GetPropType),AddToList);
- for i := 0 to FList.Count - 1 do
- begin
- C := Designer.GetComponent(FList[i]);
- if InheritsFromEx(C, TMMDSMixChannel) or
- InheritsFromEx(C, TMMDSWaveMixer) then
- Proc(FList[i]);
- end;
- end;
- finally
- FList.Free;
- end;
- end;
- {== TMM3DSoundProperty ========================================================}
- function TMM3DSoundProperty.GetAttributes: TPropertyAttributes;
- begin
- Result := [paSubProperties,paDialog];
- end;
- {-- TMM3DSoundProperty --------------------------------------------------------}
- procedure TMM3DSoundProperty.Edit;
- var
- C: TComponent;
- M: Boolean;
- begin
- M := False;
- C := (GetComponent(0) as TComponent);
- if InheritsFromEx(C, TMMDSWaveMixer) then
- M := EditMixer(TMMDSWaveMixer(C))
- else if InheritsFromEx(C, TMMDSMixChannel) then
- M := EditChannel(TMMDSMixChannel(C));
- if M and (Designer <> nil) then
- Designer.Modified;
- end;
- {== TMMDSWaveMixerEditor =====================================================}
- function TMMDSWaveMixerEditor.GetVerbCount: Integer;
- const
- VerbCount = 1;
- begin
- {$IFDEF BUILD_ACTIVEX}
- Result := VerbCount
- {$ELSE}
- if DSEDIsAvailable then Result := VerbCount else Result := 0;
- {$ENDIF}
- end;
- {-- TMMDSWaveMixerEditor -----------------------------------------------------}
- function TMMDSWaveMixerEditor.GetVerb(Index: Integer): string;
- begin
- if (Index = 0) and DSEDIsAvailable then
- Result := 'Edit &Scene...';
- end;
- {-- TMMDSWaveMixerEditor -----------------------------------------------------}
- procedure TMMDSWaveMixerEditor.ExecuteVerb(Index: integer);
- var
- M: Boolean;
- begin
- if (Index = 0) and DSEDIsAvailable then
- begin
- M := False;
- if InheritsFromEx(Component, TMMDSWaveMixer) then
- M := EditMixer(TMMDSWaveMixer(Component))
- else if InheritsFromEx(Component, TMMDSMixChannel) then
- M := EditChannel(TMMDSMixChannel(Component));
- if M and (Designer <> nil) then
- Designer.Modified;
- end
- else MessageBeep(MB_ICONERROR);
- end;
- {== TMMDSMixChannelEditor ====================================================}
- function TMMDSMixChannelEditor.GetVerbCount: Integer;
- begin
- Result := inherited GetVerbCount;
- {$IFNDEF BUILD_ACTIVEX}
- if DSEDIsAvailable then
- {$ENDIF}
- Result := Result + 1;
- end;
- {-- TMMDSMixChannelEditor ----------------------------------------------------}
- function TMMDSMixChannelEditor.GetVerb(Index: Integer): string;
- begin
- {$IFNDEF BUILD_ACTIVEX}
- if DSEDIsAvailable then
- {$ENDIF}
- if Index = 0 then
- Result := 'Edit &Scene...'
- else
- Result := inherited GetVerb(Index-1)
- {$IFNDEF BUILD_ACTIVEX}
- else
- Result := inherited GetVerb(Index);
- {$ENDIF}
- end;
- {-- TMMDSMixChannelEditor ----------------------------------------------------}
- procedure TMMDSMixChannelEditor.ExecuteVerb(Index: integer);
- var
- M: Boolean;
- begin
- if DSEDIsAvailable then
- begin
- if Index = 0 then
- begin
- M := False;
- if InheritsFromEx(Component, TMMDSWaveMixer) then
- M := EditMixer(TMMDSWaveMixer(Component))
- else if InheritsFromEx(Component, TMMDSMixChannel) then
- M := EditChannel(TMMDSMixChannel(Component));
- if M and (Designer <> nil) then
- Designer.Modified;
- end
- else
- inherited ExecuteVerb(Index-1);
- end
- else
- inherited ExecuteVerb(Index);
- end;
- {== TMMDSWaveFormatProperty ===================================================}
- function TMMDSWaveFormatProperty.GetAttributes: TPropertyAttributes;
- begin
- Result := [paDialog];
- end;
- {-- TMMDSWaveFormatProperty -----------------------------------------------------}
- procedure TMMDSWaveFormatProperty.Edit;
- var
- Component: TComponent;
- begin
- Component := TComponent(GetComponent(0));
- if (Component <> nil) and (Component is TMMDSCaptureChannel) then
- with (Component as TMMDSCaptureChannel) do
- begin
- if SelectFormat and (Designer <> nil) then Designer.Modified;
- end;
- end;
- {== TMMDSWaveFormatComponentEditor ============================================}
- procedure TMMDSWaveFormatComponentEditor.ExecuteVerb(Index: Integer);
- begin
- if (Component <> nil) and (Component is TMMDSCaptureChannel) then
- with (Component as TMMDSCaptureChannel) do
- begin
- if SelectFormat and (Designer <> nil) then Designer.Modified;
- end;
- end;
- {-- TMMDSWaveFormatComponentEditor --------------------------------------------}
- function TMMDSWaveFormatComponentEditor.GetVerb(Index: Integer): string;
- begin
- Result := 'Select WaveFormat...';
- end;
- {-- TMMDSWaveFormatComponentEditor --------------------------------------------}
- function TMMDSWaveFormatComponentEditor.GetVerbCount: Integer;
- begin
- Result := 1;
- end;
- {== TMMDSChannelConnectorEditor ===============================================}
- procedure TMMDSChannelConnectorEditor.CheckComponent(const Value: string);
- var
- Component: TComponent;
- begin
- Component := Designer.GetComponent(Value);
- if (Component.Name <> '') and DSChannelConnectCheck(Component,Component) then
- CheckProc(Value);
- end;
- {-- TMMDSChannelConnectorEditor -----------------------------------------------}
- procedure TMMDSChannelConnectorEditor.GetValues(Proc: TGetStrProc);
- begin
- CheckProc := Proc;
- inherited GetValues(CheckComponent);
- end;
- end.