📄 mmmixctl.pas
字号:
UpdateLabel;
end;
end;
{-- TMMMixerLabelConnector ---------------------------------------------}
function TMMMixerLabelConnector.GetItem: TMMItemIndex;
begin
Result := FCaptionLink.Item;
end;
{-- TMMMixerLabelConnector ---------------------------------------------}
procedure TMMMixerLabelConnector.Notification(AComponent: TComponent; Operation: TOperation);
begin
inherited Notification(AComponent,Operation);
if Operation = opRemove then
begin
if Source = AComponent then
Source := nil;
{$IFNDEF BUILD_ACTIVEX}
if Destination = AComponent then
Destination:= nil;
{$ENDIF}
end;
end;
{-- TMMMixerLabelConnector ---------------------------------------------}
function TMMMixerLabelConnector.GetTitle: string;
begin
Result:= FCaptionLink.Title;
if FAllCaps then
Result:= AnsiUpperCase(Result);
end;
{-- TMMMixerLabelConnector ---------------------------------------------}
procedure TMMMixerLabelConnector.SetAllCaps(Value: Boolean);
begin
if Value <> FAllCaps then
begin
FAllCaps:= Value;
UpdateLabel;
end;
end;
{-----------------------------------------------------------------------}
procedure SetCaption(C: TControl; const S: string);
begin
SetStrProp(C,GetPropInfo(C.ClassInfo,'Caption'),S);
end;
{-- TMMMixerLabelConnector ---------------------------------------------}
procedure TMMMixerLabelConnector.UpdateLabel;
begin
if csLoading in ComponentState then
Exit;
{$IFNDEF BUILD_ACTIVEX}
if (FDest <> nil) then
SetCaption(FDest,Title);
{$ELSE}
if FDest <> 0 then
SetWindowText(FDest, PChar(Title));
{$ENDIF}
Changed;
end;
{-- TMMMixerLabelConnector ---------------------------------------------}
procedure TMMMixerLabelConnector.Loaded;
begin
inherited Loaded;
UpdateLabel;
end;
{-- TMMMixerLabelConnector ---------------------------------------------}
procedure TMMMixerLabelConnector.SetShort(Value: Boolean);
begin
if FCaptionLink.Short <> Value then
begin
FCaptionLink.Short := Value;
UpdateLabel;
end;
end;
{-- TMMMixerLabelConnector ---------------------------------------------}
function TMMMixerLabelConnector.GetShort: Boolean;
begin
Result := FCaptionLink.Short;
end;
{-- TMMMixerLabelConnector ---------------------------------------------}
procedure TMMMixerLabelConnector.Changed;
begin
DoChange;
end;
{-- TMMMixerLabelConnector ---------------------------------------------}
procedure TMMMixerLabelConnector.DoChange;
begin
if Assigned(FOnChange) then FOnChange(Self);
end;
{-- TMMMixerLabelConnector ---------------------------------------------}
procedure TMMMixerLabelConnector.SetDest(Value: TMMMixerLabelConnector_DestinationObject);
begin
{$IFNDEF BUILD_ACTIVEX}
if (Value <> nil) and (GetPropInfo(Value.ClassInfo,'Caption') = nil) then
{ TODO: Should be resource id }
raise EMMMixerControlsError.Create('Destination has not Caption property');
if Value <> FDest then
begin
FDest := Value;
if Value <> nil then
Value.FreeNotification(Self);
UpdateLabel;
end;
{$ELSE}
if Value <> FDest then
begin
FDest := Value;
UpdateLabel;
end;
{$ENDIF}
end;
{== TMMDeviceSpin ======================================================}
constructor TMMDeviceSpin.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
MinValue := 0;
FEnabled := True;
inherited Enabled := False;
FCanUpdate := True;
FIncludeMapper := True;
FObserver := TMMObserver.Create;
FObserver.OnNotify := DeviceNotify;
end;
{-- TMMDeviceSpin ------------------------------------------------------}
destructor TMMDeviceSpin.Destroy;
begin
FObserver.Free;
inherited Destroy;
end;
{-- TMMDeviceSpin ------------------------------------------------------}
procedure TMMDeviceSpin.SetDevice(Value: TMMCustomAudioDevice);
begin
if FDevice <> Value then
begin
if FDevice <> nil then
FDevice.RemoveObserver(FObserver);
FDevice:= Value;
if FDevice <> nil then
begin
FDevice.AddObserver(FObserver);
FDevice.FreeNotification(Self);
end;
UpdateSpin;
end;
end;
{-- TMMDeviceSpin ------------------------------------------------------}
procedure TMMDeviceSpin.SetEnabled(Value: Boolean);
begin
if FEnabled <> Value then
begin
FEnabled:= Value;
UpdateSpin;
end;
end;
{-- TMMDeviceSpin ------------------------------------------------------}
procedure TMMDeviceSpin.DeviceNotify(Sender, Data: TObject);
begin
UpdateSpin;
end;
{-- TMMDeviceSpin ------------------------------------------------------}
procedure TMMDeviceSpin.Notification(AComponent: TComponent; Operation: TOperation);
begin
inherited Notification(AComponent,Operation);
if Operation = opRemove then
if AComponent = FDevice then
Device:= nil;
end;
{-- TMMDeviceSpin ------------------------------------------------------}
procedure TMMDeviceSpin.UpdateSpin;
begin
if (csLoading in ComponentState) or not FCanUpdate then
Exit;
inherited Enabled := FEnabled and (Device <> nil);
if (Device <> nil) then
with Device do
begin
if IncludeMapper and Device.Mapper then
begin
MaxValue := Device.DeviceCount;
if Device.DeviceId = MapperId then
Value := 0
else
Value := Device.DeviceId + 1;
end
else
begin
MaxValue := Device.DeviceCount-1;
{ TODO: Possible error if IncludeMapper = false, Device.Mapper = True and DeviceId = MapperId... }
Value := Device.DeviceID;
end;
end
else MaxValue := 0;
if MaxValue = 0 then
inherited Enabled := False;
end;
{-- TMMDeviceSpin ------------------------------------------------------}
procedure TMMDeviceSpin.SetInclMapper(Value: Boolean);
begin
if Value <> FIncludeMapper then
begin
FIncludeMapper := Value;
UpdateSpin;
end;
end;
{-- TMMDeviceSpin ------------------------------------------------------}
procedure TMMDeviceSpin.Change;
begin
FCanUpdate := False;
if (Device <> nil) then
if IncludeMapper and Device.Mapper then
if Value = 0 then
Device.DeviceId := MapperId
else
Device.DeviceId := Value - 1
else
Device.DeviceId := Value;
FCanUpdate := True;
inherited Change;
end;
{-- TMMDeviceSpin ------------------------------------------------------}
procedure TMMDeviceSpin.Loaded;
begin
inherited Loaded;
UpdateSpin;
end;
{== TMMCustomDeviceComboBox ============================================}
constructor TMMCustomDeviceComboBox.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
{$IFDEF BUILD_ACTIVEX}
ControlStyle := ControlStyle - [csReflector];
{$ENDIF}
FObserver := TMMObserver.Create;
FObserver.OnNotify := DeviceNotify;
Style := csDropDownList;
FEnabled := True;
FCanUpdate := True;
FIncludeMapper := True;
inherited Enabled := False;
end;
{-- TMMCustomDeviceComboBox --------------------------------------------}
destructor TMMCustomDeviceComboBox.Destroy;
begin
FObserver.Free;
inherited Destroy;
end;
{-- TMMCustomDeviceComboBox --------------------------------------------}
procedure TMMCustomDeviceComboBox.SetDevice(Value: TMMCustomAudioDevice);
begin
if FDevice <> Value then
begin
if FDevice <> nil then
FDevice.RemoveObserver(FObserver);
FDevice:= Value;
if FDevice <> nil then
begin
FDevice.AddObserver(FObserver);
FDevice.FreeNotification(Self);
end;
UpdateCombo;
end;
end;
{-- TMMCustomDeviceComboBox --------------------------------------------}
procedure TMMCustomDeviceComboBox.DeviceNotify(Sender, Data: TObject);
begin
UpdateCombo;
end;
{-- TMMCustomDeviceComboBox --------------------------------------------}
procedure TMMCustomDeviceComboBox.SetInclMapper(Value: Boolean);
begin
if Value <> FIncludeMapper then
begin
FIncludeMapper := Value;
UpdateCombo;
end;
end;
{-- TMMCustomDeviceComboBox --------------------------------------------}
procedure TMMCustomDeviceComboBox.Change;
begin
inherited Change;
FCanUpdate := False;
if (Device <> nil) and (ItemIndex <> -1) then
if IncludeMapper and Device.Mapper then
if ItemIndex = 0 then
Device.DeviceId := MapperId
else
Device.DeviceId := ItemIndex - 1
else
Device.DeviceId := ItemIndex;
FCanUpdate := True;
end;
{-- TMMCustomDeviceComboBox --------------------------------------------}
procedure TMMCustomDeviceComboBox.Notification(AComponent: TComponent; Operation: TOperation);
begin
inherited Notification(AComponent,Operation);
if Operation = opRemove then
if AComponent = FDevice then
Device := nil;
end;
{-- TMMCustomDeviceComboBox --------------------------------------------}
procedure TMMCustomDeviceComboBox.UpdateCombo;
procedure FillItems;
begin
Device.GetDeviceList(Items,IncludeMapper);
end;
begin
if (csLoading in ComponentState) or not FCanUpdate then
Exit;
inherited Enabled := FEnabled and (Device <> nil);
Items.Clear;
if inherited Enabled then FillItems;
if Device <> nil then
if IncludeMapper and Device.Mapper then
if Device.DeviceId = MapperId then
ItemIndex := 0
else
ItemIndex := Device.DeviceId + 1
else
{ TODO: Possible error same as above }
ItemIndex:= Device.DeviceId
else
ItemIndex:= -1;
inherited Enabled := Items.Count >= 1;
// ^ absence of this was bug or feature?
// (Roman)
end;
{-- TMMCustomDeviceComboBox --------------------------------------------}
procedure TMMCustomDeviceComboBox.Loaded;
begin
inherited Loaded;
UpdateCombo;
end;
{-- TMMCustomDeviceComboBox --------------------------------------------}
procedure TMMCustomDeviceComboBox.SetEnabled(Value: Boolean);
begin
if FEnabled <> Value then
begin
FEnabled:= Value;
UpdateCombo;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -