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

📄 mmmixreg.pas

📁 一套及时通讯的原码
💻 PAS
字号:
{========================================================================}
{=                (c) 1995-98 SwiftSoft Ronald Dittrich                 =}
{========================================================================}
{=                          All Rights Reserved                         =}
{========================================================================}
{=  D 01099 Dresden             = Tel.: +0351-8012255                   =}
{=  Loewenstr.7a                = info@swiftsoft.de                     =}
{========================================================================}
{=  Actual versions on http://www.swiftsoft.de/mmtools.html             =}
{========================================================================}
{=  This code is for reference purposes only and may not be copied or   =}
{=  distributed in any format electronic or otherwise except one copy   =}
{=  for backup purposes.                                                =}
{=                                                                      =}
{=  No Delphi Component Kit or Component individually or in a collection=}
{=  subclassed or otherwise from the code in this unit, or associated   =}
{=  .pas, .dfm, .dcu, .asm or .obj files may be sold or distributed     =}
{=  without express permission from SwiftSoft.                          =}
{=                                                                      =}
{=  For more licence informations please refer to the associated        =}
{=  HelpFile.                                                           =}
{========================================================================}
{=  $Date: 20.01.1998 - 18:00:00 $                                      =}
{========================================================================}
unit MMMixReg;

{$I COMPILER.INC}

Interface

procedure Register;

Implementation

{$IFDEF WIN32}
{$R MMMIXER.D32}
{$ELSE}
{$R MMMIXER.D16}
{$ENDIF}

uses
    {$IFDEF DELPHI6}
    DesignIntf,
    DesignEditors,
    {$ELSE}
    DsgnIntf,
    {$ENDIF}
    Classes,
    Controls,
    TypInfo,
    SysUtils,
    MMPropEd,
    MMObj,
    MMDevice,
    MMMixer,
    MMMixCtl,
    MMMixBlk,
    MMLevel,
    MMMeter,
    MMDesign,
    MMIDE,
    MMCmpMan;

type
    {-- TMMMixerComponentProperty ---------------------------------------}
    TMMMixerComponentProperty = class(TComponentProperty)
    private
        FList : TStringList;
        procedure AddToList(const S: string);
    protected
        function ValidComponent(C: TComponent): Boolean; virtual; abstract;
    public
        procedure GetValues(Proc: TGetStrProc); override;
    end;

    {-- TMMMixerDeviceDeviceProperty ------------------------------------}
    TMMMixerDeviceDeviceProperty = class(TMMMixerComponentProperty)
    protected
      function ValidComponent(C: TComponent): Boolean; override;
    end;

    {-- TMMMixerLabelConnectorDestProperty ------------------------------}
    TMMMixerLabelConnectorDestProperty = class(TMMMixerComponentProperty)
    protected
      function  ValidComponent(C: TComponent): Boolean; override;
    end;

    {-- TMMAudioLineDestLineProperty ------------------------------------}
    TMMAudioLineDestLineProperty    = class(TMMMixerComponentProperty)
    protected
        function ValidComponent(C: TComponent): Boolean; override;
    end;

    {-- TMMControlIdProperty --------------------------------------------}
    TMMControlIdProperty    = class(TMMIntegerProperty)
    protected
        procedure   GetConverters(var IntToIdent: TIntToIdent; var IdentToInt: TIdentToInt); override ;
        procedure   GetConsts(List: TList); override ;
    end;

    {-- TMMLineIdProperty -----------------------------------------------}
    TMMLineIdProperty       = class(TMMIntegerProperty)
    protected
        procedure   GetConverters(var IntToIdent: TIntToIdent; var IdentToInt: TIdentToInt); override ;
        procedure   GetConsts(List: TList); override ;
    end;

    {-- TMMItemIndexProperty --------------------------------------------}
    TMMItemIndexProperty    = class(TMMIntegerProperty)
    protected
        procedure   GetConverters(var IntToIdent: TIntToIdent; var IdentToInt: TIdentToInt); override ;
        procedure   GetConsts(List: TList); override ;
    end;

{== TMMMixerComponentEditor =============================================}
procedure TMMMixerComponentProperty.AddToList(const S: string);
begin
   FList.Add(S);
end;

{-- TMMMixerComponentEditor ---------------------------------------------}
procedure TMMMixerComponentProperty.GetValues(Proc: TGetStrProc);
var
   i: Integer;
begin
   FList := TStringList.Create;
   try
      Designer.GetComponentNames(GetTypeData(GetPropType),AddToList);
      for i := 0 to FList.Count - 1 do
          if ValidComponent(Designer.GetComponent(FList[i])) then
             Proc(FList[i]);
   finally
      FList.Free;
   end;
end;

{== TMMMixerDeviceDeviceProperty ========================================}
function TMMMixerDeviceDeviceProperty.ValidComponent(C: TComponent): Boolean;
begin
   Result := (C is TMMCustomAudioDevice) and
             ((C as TMMCustomAudioDevice).GetDeviceType <> dtMixer);
end;

{== TMMMixerLabelConnectorDestProperty ==================================}
function TMMMixerLabelConnectorDestProperty.ValidComponent(C: TComponent): Boolean;
begin
   Result := TypInfo.GetPropInfo(C.ClassInfo,'Caption') <> nil;
end;

{== TMMAudioLineDestLineProperty ========================================}
function    TMMAudioLineDestLineProperty.ValidComponent(C: TComponent): Boolean;
begin
    Result := (C is TMMAudioLine) and (C <> GetComponent(0)) ;
end;

{== TMMControlIdProperty ================================================}
procedure   TMMControlIdProperty.GetConverters(var IntToIdent: TIntToIdent; var IdentToInt: TIdentToInt);
begin
    IntToIdent := ControlIdToIdent;
    IdentToInt := IdentToControlId;
end;

{-- TMMControlIdProperty ------------------------------------------------}
procedure TMMControlIdProperty.GetConsts(List: TList);
begin
    List.Add(Pointer(badControlId));
end;

{== TMMLineIdProperty ===================================================}
procedure   TMMLineIdProperty.GetConverters(var IntToIdent: TIntToIdent; var IdentToInt: TIdentToInt);
begin
    IntToIdent := LineIdToIdent ;
    IdentToInt := IdentToLineId ;
end;

{-- TMMLineIdProperty ---------------------------------------------------}
procedure   TMMLineIdProperty.GetConsts(List: TList);
begin
    List.Add(Pointer(badLineId));
end;

{== TMMItemIndexProperty ================================================}
procedure   TMMItemIndexProperty.GetConverters(var IntToIdent: TIntToIdent; var IdentToInt: TIdentToInt);
begin
    IntToIdent := ItemIndexToIdent ;
    IdentToInt := IdentToItemIndex ;
end;

{-- TMMItemIndexProperty ------------------------------------------------}
procedure   TMMItemIndexProperty.GetConsts(List: TList);
begin
    List.Add(Pointer(NoItem));
end;

{========================================================================}
function CheckMixDevice(C1, C2: TComponent): Boolean;
begin
   if (C1 is TMMCustomAudioDevice) then
       Result := (C1 as TMMCustomAudioDevice).GetDeviceType <> dtMixer
   else
       Result := False;
end;

{------------------------------------------------------------------------}
function CheckSliderControl(C1, C2: TComponent): Boolean;
begin
   if (C1 is TMMCustomMixerControl) then
       Result := (C1 as TMMCustomMixerControl).ControlClass in MixerSliderControlClasses
   else
       Result := False;
end;

{------------------------------------------------------------------------}
function CheckWheelControl(C1, C2: TComponent): Boolean;
begin
   if (C1 is TMMCustomMixerControl) then
       Result := (C1 as TMMCustomMixerControl).ControlClass in MixerWheelControlClasses
   else
       Result := False;
end;

{------------------------------------------------------------------------}
function CheckSwitchControl(C1, C2: TComponent): Boolean;
begin
   if (C1 is TMMCustomMixerControl) then
       Result := (C1 as TMMCustomMixerControl).ControlClass in SwitchControlClasses
   else
       Result := False;
end;

{------------------------------------------------------------------------}
function CheckConnectorControl(C1, C2: TComponent): Boolean;
begin
   if (C1 is TMMCustomMixerControl) then
       Result := (C1 as TMMCustomMixerControl).ControlClass in ConnectorControlClasses
   else
       Result := False;
end;

{------------------------------------------------------------------------}
function CheckMixControl(C1, C2: TComponent): Boolean;
begin
   if (C1 is TMMCustomMixerControl) then
       Result := (C1 as TMMCustomMixerControl).ControlClass = ccList
   else
       Result := False;
end;

{------------------------------------------------------------------------}
function CheckLabelDest(C1, C2: TComponent): Boolean;
begin
   Result := GetPropInfo(C2.ClassInfo,'Caption') <> nil;
end;

{------------------------------------------------------------------------}
function CheckItemLine(C1, C2: TComponent): Boolean;
begin
    if C1 is TMMAudioLine then
        Result := cfSource in (C1 as TMMAudioLine).LineInfo.Flags
    else
        Result := False;
end;

{------------------------------------------------------------------------}
procedure Register;
begin
//   RegisterComponents('MMMixer',[TMMAudioDevice]);

   RegisterComponents('MMMixer',[TMMCompManager,
                                 TMMMixerDevice,
                                 TMMAudioLine,
                                 TMMMixerControl,
                                 TMMVolumeControl,
                                 TMMPanControl,
                                 TMMMixerSlider,
                                 TMMMixerWheel,
                                 TMMMixerCheckBox,
                                 TMMMixerConnector,
                                 TMMMixerLabelConnector,
                                 TMMDeviceSpin,
                                 TMMDeviceComboBox,
                                 TMMMixerBlock,
                                 TMMMixerBlockSlider,
                                 TMMMixerBlockCheck,
                                 TMMMixerBlockLevel,
                                 TMMMixerBlockLabel
                                 ]);

   RegisterPropertyEditor(TypeInfo(TMMCustomAudioDevice),TMMMixerDevice,'Device',TMMMixerDeviceDeviceProperty);
   RegisterPropertyEditor(TypeInfo(TMMCustomAudioDevice),TMMAudioLine,'Target',TMMMixerDeviceDeviceProperty);
   RegisterPropertyEditor(TypeInfo(TControl),TMMMixerLabelConnector,'Destination',TMMMixerLabelConnectorDestProperty);
   RegisterPropertyEditor(TypeInfo(TMMComponent),TMMAudioLine,'DestLine',TMMAudioLineDestLineProperty);
   RegisterPropertyEditor(TypeInfo(TMMControlId),nil,'',TMMControlIdProperty);
   RegisterPropertyEditor(TypeInfo(TMMLineId),nil,'',TMMLineIdProperty);
   RegisterPropertyEditor(TypeInfo(TMMItemIndex),nil,'',TMMItemIndexProperty);

   { Register the properties for TMMDesigner }
   RegisterProperty(ptInput, 'Mixer', TMMCustomAudioDevice, 'Device', TMMMixerDevice, CheckMixDevice);

   RegisterPropertyException(ptInput, 'Mixer', TMMMixerDevice, 'Device', TMMMixerDevice, nil);

   RegisterProperty(ptInput, 'Mixer', TMMMixerDevice, 'Mixer', TMMAudioLine, nil);
   RegisterProperty(ptInput, 'Mixer', TMMCustomAudioDevice, 'Target', TMMAudioLine, CheckMixDevice);

   RegisterPropertyException(ptInput, 'Mixer', TMMMixerDevice, 'Target', TMMAudioLine, nil);

   RegisterProperty(ptInput, 'Mixer', TMMAudioLine, 'DestLine', TMMAudioLine, nil);
   RegisterProperty(ptInput, 'Mixer', TMMAudioLine, 'AudioLine', TMMCustomMixerControl, nil);

   RegisterProperty(ptOutput, 'Mixer', TMMPanControl, 'VolumeControl', TMMVolumeControl, nil);

   RegisterProperty(ptInput, 'Mixer', TMMCustomMixerControl, 'Control', TMMCustomMixerSlider, CheckSliderControl);
   RegisterProperty(ptInput, 'Mixer', TMMCustomMixerControl, 'Control', TMMCustomMixerWheel, CheckWheelControl);
   RegisterProperty(ptInput, 'Mixer', TMMCustomMixerControl, 'Control', TMMCustomMixerCheckBox, CheckSwitchControl);

   RegisterProperty(ptInput, 'Mixer', TMMAudioLine, 'ItemLine', TMMCustomMixerCheckBox, CheckItemLine);
   RegisterProperty(ptInput, 'Mixer', TMMCustomMixerControl, 'Control', TMMCustomMixerConnector, CheckConnectorControl);
   RegisterProperty(ptOutput, 'Mixer', TMMMixerConnector, 'Level1', TMMCustomLevel, nil);
   RegisterProperty(ptOutput, 'Mixer', TMMMixerConnector, 'Level2', TMMCustomLevel, nil);
   RegisterProperty(ptOutput, 'Mixer', TMMMixerConnector, 'Meter1', TMMCustomMeter, nil);
   RegisterProperty(ptOutput, 'Mixer', TMMMixerConnector, 'Meter2', TMMCustomMeter, nil);

   RegisterProperty(ptInput, 'Mixer', TMMCustomAudioDevice, 'Source', TMMMixerLabelConnector, nil);
   RegisterProperty(ptInput, 'Mixer', TMMAudioLine, 'Source', TMMMixerLabelConnector, nil);
   RegisterProperty(ptInput, 'Mixer', TMMCustomMixerControl, 'Source', TMMMixerLabelConnector, nil);
   RegisterProperty(ptOutput, 'Mixer', TMMMixerLabelConnector, 'Destination', TControl, CheckLabelDest);
   RegisterProperty(ptInput, 'Mixer', TMMCustomAudioDevice, 'Device', TMMDeviceSpin, nil);
   RegisterProperty(ptInput, 'Mixer', TMMCustomAudioDevice, 'Device', TMMDeviceComboBox, nil);
   RegisterProperty(ptInput, 'Mixer', TMMAudioLine, 'Line', TMMMixerBlock, nil);
   RegisterProperty(ptInput, 'Mixer', TMMCustomMixerControl, 'Mixer', TMMMixerBlock, CheckMixControl);
end;

end.

⌨️ 快捷键说明

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