📄 mmmixctl.pas
字号:
FChannel := chBoth;
FItem := NoItem;
FEnabled := True;
inherited Enabled := False;
end;
{-- TMMCustomMixerSlider -----------------------------------------------}
destructor TMMCustomMixerSlider.Destroy;
begin
FLink.Free;
FLink := nil;
inherited Destroy;
end;
{-- TMMCustomMixerSlider -----------------------------------------------}
procedure TMMCustomMixerSlider.ControlChange(Sender: TObject);
begin
UpdateControl;
end;
{-- TMMCustomMixerSlider -----------------------------------------------}
function TMMCustomMixerSlider.GetControl: TMMCustomMixerControl;
begin
if FLink = nil then
Result := nil
else
Result := FLink.Control;
end;
{-- TMMCustomMixerSlider -----------------------------------------------}
procedure TMMCustomMixerSlider.SetControl(Value: TMMCustomMixerControl);
begin
if Value <> nil then
if not (Value.ControlClass in MixerSliderControlClasses) then
{ TODO: Should be resource id }
raise EMMMixerControlsError.Create('Invalid control class');
if FLink.Control <> Value then
begin
FLink.Control:= Value;
if Value <> nil then
Value.FreeNotification(Self);
UpdateControl;
end;
end;
{-- TMMCustomMixerSlider -----------------------------------------------}
procedure TMMCustomMixerSlider.SetupSlider;
var
Min, Max: Integer;
Steps : Integer;
begin
if (FLink <> nil) and (Control <> nil) and not (csDestroying in ComponentState) then
begin
inherited Enabled := FEnabled and WriteOk(Control,FItem);
FLink.Lock;
try
if inherited Enabled then
begin
Min := Control.ControlInfo.MinValue;
Max := Control.ControlInfo.MaxValue;
Steps := Control.ControlInfo.Steps;
if Steps = 0 then
Steps:= MaxSteps;
FStep := (Max - Min) / Steps;
MinValue:= 0;
if FStep <> 0 then
MaxValue:= Trunc((Max - Min) / FStep)
else
MaxValue:= 1;
end
else
begin
MinValue := 0;
MaxValue := 2;
FStep := 1;
end;
finally
FLink.Unlock;
end;
end
else inherited Enabled := False;
end;
{-- TMMCustomMixerSlider -----------------------------------------------}
procedure TMMCustomMixerSlider.SetEnabled(Value: Boolean);
begin
if FEnabled <> Value then
begin
FEnabled:= Value;
UpdateControl;
end;
end;
{-- TMMCustomMixerSlider -----------------------------------------------}
procedure TMMCustomMixerSlider.Loaded;
begin
inherited Loaded;
UpdateControl;
end;
{-- TMMCustomMixerSlider -----------------------------------------------}
procedure TMMCustomMixerSlider.Notification(AComponent: TComponent; Operation: TOperation);
begin
inherited Notification(AComponent,Operation);
if Operation = opRemove then
if AComponent = Control then
Control:= nil;
end;
{-- TMMCustomMixerSlider -----------------------------------------------}
procedure TMMCustomMixerSlider.UpdateValue;
begin
if (csDestroying in ComponentState) then
Exit;
FLink.Lock;
try
if ReadOk(Control,FItem) and (FStep <> 0) and (MaxValue > MinValue) and Enabled then
begin
Position:= Round((Control.GetChannelSigned(FChannel,FItem)-Control.ControlInfo.MinValue)/FStep);
end
else Position:= Max(MinValue,(MinValue+MaxValue) div 2);
finally
FLink.UnLock;
end;
end;
{-- TMMCustomMixerSlider -----------------------------------------------}
procedure TMMCustomMixerSlider.Change;
begin
if (FLink <> nil) and not FLink.Locked then
begin
FLink.Lock;
try
if Control <> nil then
begin
if cfDisabled in Control.ControlInfo.Flags then
UpdateValue
else
if WriteOk(Control,FItem) then
with Control do
SetChannelSigned(FChannel,FItem,Round(Position*FStep+ControlInfo.MinValue));
end;
finally
FLink.Unlock;
end;
end;
inherited;
end;
{-- TMMCustomMixerSlider -----------------------------------------------}
procedure TMMCustomMixerSlider.UpdateControl;
begin
SetupSlider;
UpdateValue;
end;
{-- TMMCustomMixerSlider -----------------------------------------------}
procedure TMMCustomMixerSlider.SetChannel(Value: TMMChannel);
begin
if Value <> FChannel then
begin
FChannel:= Value;
UpdateControl;
end;
end;
{-- TMMCustomMixerSlider -----------------------------------------------}
procedure TMMCustomMixerSlider.SetItem(Value: TMMItemIndex);
begin
if Value <> FItem then
begin
FItem:= Value;
UpdateControl;
end;
end;
{== TMMCustomMixerWheel ================================================}
constructor TMMCustomMixerWheel.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FLink := TMMControlLink.Create;
FLink.OnChange := ControlChange;
FLink.OnIdChange := UpdateControl;
FChannel := chBoth;
FItem := NoItem;
FEnabled := True;
inherited Enabled := False;
end;
{-- TMMCustomMixerWheel ------------------------------------------------}
destructor TMMCustomMixerWheel.Destroy;
begin
FLink.Free;
inherited Destroy;
end;
{-- TMMCustomMixerWheel -----------------------------------------------}
procedure TMMCustomMixerWheel.ControlChange(Sender: TObject);
begin
UpdateControl;
end;
{-- TMMCustomMixerWheel -----------------------------------------------}
function TMMCustomMixerWheel.GetControl: TMMCustomMixerControl;
begin
Result := FLink.Control;
end;
{-- TMMCustomMixerWheel -----------------------------------------------}
procedure TMMCustomMixerWheel.SetControl(Value: TMMCustomMixerControl);
begin
if Value <> nil then
if not (Value.ControlClass in MixerWheelControlClasses) then
{ TODO: Should be resource id }
raise EMMMixerControlsError.Create('Invalid control class');
if FLink.Control <> Value then
begin
FLink.Control:= Value;
if Value <> nil then
Value.FreeNotification(Self);
UpdateControl;
end;
end;
{-- TMMCustomMixerWheel -----------------------------------------------}
procedure TMMCustomMixerWheel.SetupWheel;
var
Min, Max: Integer;
Steps : Integer;
begin
if Control <> nil then
begin
inherited Enabled := FEnabled and WriteOk(Control,FItem);
Min := Control.ControlInfo.MinValue;
Max := Control.ControlInfo.MaxValue;
Steps := Control.ControlInfo.Steps;
if Steps = 0 then
Steps:= MaxSteps;
FStep := (Max - Min) / Steps;
MinValue:= 0;
if FStep <> 0 then
MaxValue:= Trunc((Max - Min) / FStep)
else
MaxValue:= 1;
end
else inherited Enabled := False;
end;
{-- TMMCustomMixerWheel -----------------------------------------------}
procedure TMMCustomMixerWheel.SetEnabled(Value: Boolean);
begin
if FEnabled <> Value then
begin
FEnabled:= Value;
UpdateControl;
end;
end;
{-- TMMCustomMixerWheel -----------------------------------------------}
procedure TMMCustomMixerWheel.Loaded;
begin
inherited Loaded;
UpdateControl;
end;
{-- TMMCustomMixerWheel -----------------------------------------------}
procedure TMMCustomMixerWheel.Notification(AComponent: TComponent; Operation: TOperation);
begin
inherited Notification(AComponent,Operation);
if Operation = opRemove then
if AComponent = Control then
Control:= nil;
end;
{-- TMMCustomMixerWheel -----------------------------------------------}
procedure TMMCustomMixerWheel.UpdateValue;
var
Pos: Extended;
begin
FLink.Lock;
try
if ReadOk(Control,FItem) and (FStep <> 0) and (MaxValue > MinValue) then
begin
Pos := (Control.GetChannelSigned(FChannel,FItem)-Control.ControlInfo.MinValue)/FStep;
Value := Round(Pos);
end
else Value := 0
finally
FLink.UnLock;
end;
end;
{-- TMMCustomMixerWheel -----------------------------------------------}
procedure TMMCustomMixerWheel.Change;
begin
if not FLink.Locked then
begin
FLink.Lock;
try
if (FLink <> nil) and (Control <> nil) then
begin
if cfDisabled in Control.ControlInfo.Flags then
UpdateValue
else
with Control do
SetChannelSigned(FChannel,FItem,Round(Value*FStep+ControlInfo.MinValue));
end;
finally
FLink.Unlock;
end;
end;
inherited;
end;
{-- TMMCustomMixerWheel -----------------------------------------------}
procedure TMMCustomMixerWheel.UpdateControl;
begin
SetupWheel;
UpdateValue;
end;
{-- TMMCustomMixerWheel -----------------------------------------------}
procedure TMMCustomMixerWheel.SetChannel(Value: TMMChannel);
begin
if Value <> FChannel then
begin
FChannel:= Value;
UpdateControl;
end;
end;
{-- TMMCustomMixerWheel -----------------------------------------------}
procedure TMMCustomMixerWheel.SetItem(Value: TMMItemIndex);
begin
if Value <> FItem then
begin
FItem:= Value;
UpdateControl;
end;
end;
{== TMMCustomMixerCheckBox =============================================}
constructor TMMCustomMixerCheckBox.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FLink := TMMControlLink.Create;
FLink.OnChange := ControlChange;
FLink.OnIdChange := UpdateControl;
FChannel := chBoth;
FItem := NoItem;
FAutoCap := True;
FShort := True;
FItemObserver := TMMObserver.Create;
FItemObserver.OnNotify := ItemNotify;
FEnabled := True;
inherited Enabled := False;
end;
{-- TMMCustomMixerCheckBox ---------------------------------------------}
destructor TMMCustomMixerCheckBox.Destroy;
begin
FLink.Free;
FItemObserver.Free;
inherited Destroy;
end;
{-- TMMCustomMixerCheckBox ---------------------------------------------}
procedure TMMCustomMixerCheckBox.SetEnabled(Value: Boolean);
begin
if Value <> FEnabled then
begin
FEnabled := Value;
UpdateControl;
end;
end;
{-- TMMCustomMixerCheckBox ---------------------------------------------}
function TMMCustomMixerCheckBox.GetControl: TMMCustomMixerControl;
begin
Result := FLink.Control;
end;
{-- TMMCustomMixerCheckBox ---------------------------------------------}
procedure TMMCustomMixerCheckBox.SetControl(Value: TMMCustomMixerControl);
begin
if Value <> nil then
if not (Value.ControlClass in SwitchControlClasses) then
{ TODO: Should be resource id }
raise EMMMixerControlsError.Create('Invalid control class');
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -