📄 mmmixctl.pas
字号:
property Visible;
property Checked;
end;
{-- TMMCustomMixerConnector -----------------------------------------}
TMMCustomMixerConnector = class(TMMCustomLevelConnector)
private
FLink : TMMControlLink;
FStep : Extended;
FItem : TMMItemIndex;
FOnChange : TNotifyEvent;
FAbsolute : Boolean;
FAdjust : integer;
function GetControl: TMMCustomMixerControl;
procedure SetControl(Value: TMMCustomMixerControl);
procedure ControlChange(Sender: TObject);
procedure SetItem(Value: TMMItemIndex);
protected
procedure Changed; virtual;
procedure DoChange; dynamic;
procedure SetupConnector; override;
procedure GetLevelValues(var LeftValue, RightValue, BothValue: integer); override;
procedure Notification(AComponent: TComponent; Operation: TOperation); override;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
protected
property Control: TMMCustomMixerControl read GetControl write SetControl;
property Item: TMMItemIndex read FItem write SetItem default NoItem;
property OnChange: TNotifyEvent read FOnChange write FOnChange;
end;
{-- TMMMixerConnector -----------------------------------------------}
TMMMixerConnector = class(TMMCustomMixerConnector)
published
property OnChange;
property Control;
property Level1;
property Level2;
property Meter1;
property Meter2;
property AutoTrigger;
property Interval;
property Item;
property Enabled;
end;
{$IFNDEF BUILD_ACTIVEX}
TMMMixerLabelConnector_DestinationObject = TControl;
{$ELSE}
TMMMixerLabelConnector_DestinationObject = HWND;
{$ENDIF}
{-- TMMMixerLabelConnector ------------------------------------------}
TMMMixerLabelConnector = class(TMMNonVisualComponent)
private
FCaptionLink: TMMCaptionLink;
FDest : TMMMixerLabelConnector_DestinationObject;
FAllCaps : Boolean;
FOnChange : TNotifyEvent;
procedure CaptionChanged(Sender: TObject);
function GetSource: TMMCaptionLinkComponent;
procedure SetSource(Value: TMMCaptionLinkComponent);
function GetItem: TMMItemIndex;
procedure SetItem(Value: TMMItemIndex);
function GetShort: Boolean;
procedure SetShort(Value: Boolean);
procedure SetDest(Value: TMMMixerLabelConnector_DestinationObject);
function GetTitle: string;
procedure SetAllCaps(Value: Boolean);
protected
procedure Notification(AComponent: TComponent; Operation: TOperation); override;
procedure UpdateLabel;
procedure Loaded; override;
procedure Changed; virtual;
procedure DoChange; dynamic;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
property Title: string read GetTitle;
published
property Source: TMMCaptionLinkComponent read GetSource write SetSource;
property Item: TMMItemIndex read GetItem write SetItem default NoItem;
property Short: Boolean read GetShort write SetShort default False;
property Destination: TMMMixerLabelConnector_DestinationObject read FDest write SetDest;
property AllCaps: Boolean read FAllCaps write SetAllCaps default False;
property OnChange: TNotifyEvent read FOnChange write FOnChange;
end;
{-- TMMDeviceSpin ---------------------------------------------------}
TMMDeviceSpin = class(TMMCustomSpinButton)
private
FDevice : TMMCustomAudioDevice;
FEnabled : Boolean;
FObserver : TMMObserver;
FCanUpdate : Boolean;
FIncludeMapper : Boolean;
procedure SetDevice(Value: TMMCustomAudioDevice);
procedure DeviceNotify(Sender, Data: TObject);
procedure SetEnabled(Value: Boolean);
procedure SetInclMapper(Value: Boolean);
protected
procedure Notification(AComponent: TComponent; Operation: TOperation); override;
procedure UpdateSpin;
procedure Change; override;
procedure Loaded; override;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
published
property Enabled: Boolean read FEnabled write SetEnabled default True;
property Device: TMMCustomAudioDevice read FDevice write SetDevice;
property IncludeMapper: Boolean read FIncludeMapper write SetInclMapper default True;
property OnChange;
property OnDownClick;
property OnUpClick;
property Bevel;
property DownGlyph;
property DownNumGlyphs;
property FocusColor;
property FocusControl;
property ParentShowHint;
property PopupMenu;
property ShowHint;
property TabStop;
property TabOrder;
property UpGlyph;
property UpNumGlyphs;
property Visible;
property Width;
property Height;
property ButtonFace;
property MiddleButton;
property Value;
end;
{-- TMMCustomDeviceComboBox --------------------------------------------}
TMMCustomDeviceComboBox = class(TCustomComboBox)
private
FDevice : TMMCustomAudioDevice;
FEnabled : Boolean;
FObserver : TMMObserver;
FCanUpdate : Boolean;
FIncludeMapper : Boolean;
procedure SetDevice(Value: TMMCustomAudioDevice);
procedure DeviceNotify(Sender, Data: TObject);
procedure SetEnabled(Value: Boolean);
procedure SetInclMapper(Value: Boolean);
protected
procedure Notification(AComponent: TComponent; Operation: TOperation); override;
procedure UpdateCombo;
procedure Loaded; override;
procedure Change; override;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
protected
property Device: TMMCustomAudioDevice read FDevice write SetDevice;
property Enabled: Boolean read FEnabled write SetEnabled default True;
property IncludeMapper: Boolean read FIncludeMapper write SetInclMapper default True;
end;
{-- TMMDeviceComboBox --------------------------------------------------}
TMMDeviceComboBox = class(TMMCustomDeviceComboBox)
published
property OnChange;
property OnClick;
property OnDblClick;
property OnDragDrop;
property OnDragOver;
property OnDrawItem;
property OnDropDown;
property OnEndDrag;
property OnEnter;
property OnExit;
property OnKeyDown;
property OnKeyPress;
property OnKeyUp;
property OnMeasureItem;
property OnStartDrag;
property Device;
property Enabled;
property IncludeMapper;
property Color;
property Ctl3D;
property DragMode;
property DragCursor;
property DropDownCount;
property Font;
property ItemHeight;
property ItemIndex;
property MaxLength;
property ParentColor;
property ParentCtl3D;
property ParentFont;
property ParentShowHint;
property PopupMenu;
property ShowHint;
property Sorted;
property TabOrder;
property TabStop;
property Visible;
{$IFDEF BUILD_ACTIVEX}
property Text stored False;
{$ENDIF}
end;
{-- EMMMixerControlsError ----------------------------------------------}
EMMMixerControlsError = class(Exception)
end;
function ReadOk(Control: TMMCustomMixerControl; Item: TMMItemIndex): Boolean;
function WriteOk(Control: TMMCustomMixerControl; Item: TMMItemIndex): Boolean;
{=======================================================================}
implementation
{=======================================================================}
uses
TypInfo,
MMDesign;
{-----------------------------------------------------------------------}
function ReadOk(Control: TMMCustomMixerControl; Item: TMMItemIndex): Boolean;
var
Multiple: Boolean;
begin
Result := False;
if (Control <> nil) and Control.Available then
begin
Multiple := cfMultiple in Control.ControlInfo.Flags;
if Multiple then
Result := InRange(Item,0,Control.Items-1)
else
Result := Item = NoItem;
end;
end;
{-----------------------------------------------------------------------}
function WriteOk(Control: TMMCustomMixerControl; Item: TMMItemIndex): Boolean;
begin
Result := ReadOk(Control,Item) and Control.CanModify;
end;
{== TMMControlLink =====================================================}
procedure TMMControlLink.SetControl(Value: TMMCustomMixerControl);
begin
if Value <> FControl then
begin
if FControl <> nil then
FControl.RemoveObserver(Self);
FControl:= Value;
if FControl <> nil then
FControl.AddObserver(Self);
end;
end;
{-- TMMControlLink -----------------------------------------------------}
procedure TMMControlLink.Notify(Data: TObject);
begin
if Data is TMMControlChange then
begin
if Assigned(FOnChange) then FOnChange(Control)
end
else if Data is TMMControlIdChange then
begin
if Assigned(FOnIdChange) then FOnIdChange;
end;
end;
{== TMMCaptionLink ======================================================}
constructor TMMCaptionLink.Create;
begin
inherited Create;
FItem := NoItem;
end;
{-- TMMCaptionLink ------------------------------------------------------}
procedure TMMCaptionLink.SetComponent(Value: TMMCaptionLinkComponent);
begin
if Value <> nil then
if not ((Value is TMMCustomAudioDevice) or
(Value is TMMAudioLine) or
(Value is TMMCustomMixerControl)) then
{ TODO: Should be resource id }
raise EMMCaptionLinkError.Create('Device, Line or Control supported only');
if Value <> FComponent then
begin
if FComponent <> nil then
RemoveObserver;
FComponent := Value;
if FComponent <> nil then
AddObserver;
end;
end;
{-- TMMCaptionLink -----------------------------------------------------}
procedure TMMCaptionLink.RemoveObserver;
begin
if FComponent is TMMCustomAudioDevice then
(FComponent as TMMCustomAudioDevice).RemoveObserver(Self);
if FComponent is TMMAudioLine then
(FComponent as TMMAudioLine).RemoveObserver(Self);
if FComponent is TMMCustomMixerControl then
(FComponent as TMMCustomMixerControl).RemoveObserver(Self);
end;
{-- TMMCaptionLink -----------------------------------------------------}
procedure TMMCaptionLink.AddObserver;
begin
if FComponent is TMMCustomAudioDevice then
(FComponent as TMMCustomAudioDevice).AddObserver(Self);
if FComponent is TMMAudioLine then
(FComponent as TMMAudioLine).AddObserver(Self);
if FComponent is TMMCustomMixerControl then
(FComponent as TMMCustomMixerControl).AddObserver(Self);
end;
{-- TMMCaptionLink -----------------------------------------------------}
procedure TMMCaptionLink.SetItem(Value: TMMItemIndex);
begin
if Value <> FItem then
begin
FItem:= Value;
Changed;
end;
end;
{-- TMMCaptionLink -----------------------------------------------------}
procedure TMMCaptionLink.SetShort(Value: Boolean);
begin
if Value <> FShort then
begin
FShort:= Value;
Changed;
end;
end;
{-- TMMCaptionLink -----------------------------------------------------}
function TMMCaptionLink.GetTitle: string;
begin
if FComponent is TMMCustomAudioDevice then
Result:= (FComponent as TMMCustomAudioDevice).DeviceCaps.ProductName
else if FComponent is TMMAudioLine then
with FComponent as TMMAudioLine do
if Short then
Result:= LineInfo.ShortName
else
Result:= LineInfo.Name
else if FComponent is TMMCustomMixerControl then
with FComponent as TMMCustomMixerControl do
if (FItem <> NoItem) and (cfMultiple in ControlInfo.Flags) then
if InRange(FItem,0,ControlInfo.MultipleItems-1) then
Result:= ItemInfo[FItem].Name
else
Result:= 'Invalid item'
else if Short then
Result:= ControlInfo.ShortName
else
Result:= ControlInfo.Name
else
Result:= 'Not connected';
end;
{-- TMMCaptionLink -----------------------------------------------------}
procedure TMMCaptionLink.Changed;
begin
DoChange;
end;
{-- TMMCaptionLink -----------------------------------------------------}
procedure TMMCaptionLink.DoChange;
begin
if Assigned(FOnChange) then
FOnChange(Self);
end;
{-- TMMCaptionLink -----------------------------------------------------}
procedure TMMCaptionLink.Notify(Data: TObject);
begin
Changed;
end;
{== TMMCustomMixerSlider ===============================================}
constructor TMMCustomMixerSlider.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FLink := TMMControlLink.Create;
FLink.OnChange := ControlChange;
FLink.OnIdChange := UpdateControl;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -