{========================================================================} {= (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 MMMixCtl; {$I COMPILER.INC} interface uses {$IFDEF WIN32} Windows, {$ELSE} WinTypes, WinProcs, {$ENDIF} Forms, Messages, Classes, SysUtils, StdCtrls, ExtCtrls, Controls, MMObj, MMUtils, MMMath, MMObsrv, MMMixer, MMSlider, MMLevel, MMMeter, MMTimer, MMSpin, MMPanel, MMWheel, MMDevice; type TMMIdChangedEvent = procedure of object; {-- TMMControlLink --------------------------------------------------} TMMControlLink = class(TMMObserver) private FControl : TMMCustomMixerControl; FOnChange : TNotifyEvent; FOnIdChange: TMMIdChangedEvent; procedure SetControl(Value: TMMCustomMixerControl); protected procedure Notify(Data: TObject); override; public property Control: TMMCustomMixerControl read FControl write SetControl; property OnChange: TNotifyEvent read FOnChange write FOnChange; property OnIdChange: TMMIdChangedEvent read FOnIdChange write FOnIdChange; end; {-- TMMCaptionLink --------------------------------------------------} TMMCaptionLink = class(TMMObserver) private FComponent : TMMComponent; FItem : TMMItemIndex; FShort : Boolean; FOnChange : TNotifyEvent; procedure SetComponent(Value: TMMComponent); procedure SetItem(Value: TMMItemIndex); procedure SetShort(Value: Boolean); function GetTitle: string; procedure RemoveObserver; procedure AddObserver; protected procedure Changed; virtual; procedure DoChange; dynamic; procedure Notify(Data: TObject); override; public constructor Create; property Component: TMMComponent read FComponent write SetComponent; property Item: TMMItemIndex read FItem write SetItem; property Short: Boolean read FShort write SetShort; property Title: string read GetTitle; property OnChange: TNotifyEvent read FOnChange write FOnChange; end; EMMCaptionLinkError = class(Exception) end; const MaxSteps = 32; MixerSliderControlClasses = [ccFader,ccNumber,ccSlider,ccTime]; SwitchControlClasses = [ccList,ccSwitch]; ConnectorControlClasses = [ccFader,ccMeter,ccNumber,ccSlider,ccTime]; MixerWheelControlClasses = MixerSliderControlClasses; type {-- TMMCustomMixerSlider --------------------------------------------} TMMCustomMixerSlider = class(TMMCustomSlider) private FLink : TMMControlLink; FStep : Extended; FChannel : TMMChannel; FItem : TMMItemIndex; FEnabled : Boolean; function GetControl: TMMCustomMixerControl; procedure SetControl(Value: TMMCustomMixerControl); procedure ControlChange(Sender: TObject); procedure Change; override; procedure SetupSlider; procedure UpdateValue; procedure UpdateControl; procedure SetChannel(Value: TMMChannel); procedure SetItem(Value: TMMItemIndex); procedure SetEnabled(Value: Boolean); protected procedure Loaded; 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 Channel: TMMChannel read FChannel write SetChannel default chBoth; property Item: TMMItemIndex read FItem write SetItem default NoItem; property Enabled read FEnabled write SetEnabled default True; end; {-- TMMMixerSlider --------------------------------------------------} TMMMixerSlider = class(TMMCustomMixerSlider) published property OnEnter; property OnExit; property OnKeyDown; property OnKeyPress; property OnKeyUp; property OnChange; property OnTrack; property OnTrackEnd; property OnDrawThumb; property OnDrawGroove; property Control; property Channel; property Item; property Logarithmic; property Sensitivity; property Enabled; property Visible; property Color; property ParentShowHint; property PopupMenu; property ShowHint; property TabStop; property TabOrder; property Width; property Height; property Bevel; property Groove; property FocusAction; property FocusColor; property GrooveColor; property ThumbColor; property DisabledColor; property HandCursor; property Orientation; property GrooveSize; property GrooveStyle; property ThumbWidth; property ThumbHeight; property ThumbStyle; property Scale; property ScalePosition; property ScaleDistance; property PicLeft; property PicRight; end; {-- TMMCustomMixerWheel ---------------------------------------------} TMMCustomMixerWheel = class(TMMCustomWheel) private FLink : TMMControlLink; FStep : Extended; FChannel : TMMChannel; FItem : TMMItemIndex; FEnabled : Boolean; function GetControl: TMMCustomMixerControl; procedure SetControl(Value: TMMCustomMixerControl); procedure ControlChange(Sender: TObject); procedure Change; override; procedure SetupWheel; procedure UpdateValue; procedure UpdateControl; procedure SetChannel(Value: TMMChannel); procedure SetItem(Value: TMMItemIndex); procedure SetEnabled(Value: Boolean); protected procedure Loaded; 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 Channel: TMMChannel read FChannel write SetChannel default chBoth; property Item: TMMItemIndex read FItem write SetItem default NoItem; property Enabled read FEnabled write SetEnabled default True; end; {-- TMMMixerWheel ---------------------------------------------------} TMMMixerWheel = class(TMMCustomMixerWheel) published property Control; property Channel; property Item; property Enabled; property OnEnter; property OnExit; property OnKeyDown; property OnKeyPress; property OnKeyUp; property OnChange; property OnDrawHandle; property Bevel; property Visible; property Color; property ParentShowHint; property PopupMenu; property ShowHint; property TabStop default True; property TabOrder; property Width; property Height; property AutoSize; property BackBmp; property Value; property StartAngle; property EndAngle; property HandleColor; property FocusedColor; property UpDown; property ScrollSize; property LineStep; property PageStep; property FocusAction; property Scale; property Radius; property HandleStyle; property HandleSize; property HandleMargin; property FrameSpace; property ScaleMargin; end; {-- TMMCustomMixerCheckBox ------------------------------------------} TMMCustomMixerCheckBox = class(TCustomCheckBox) private FLink : TMMControlLink; FChannel : TMMChannel; FItem : TMMItemIndex; FAutoCap : Boolean; FShort : Boolean; FItemLine : TMMAudioLine; FItemObserver : TMMObserver; FEnabled : Boolean; function GetControl: TMMCustomMixerControl; procedure SetControl(Value: TMMCustomMixerControl); procedure ControlChange(Sender: TObject); procedure SetupCheck; procedure UpdateValue; procedure UpdateControl; procedure SetChannel(Value: TMMChannel); procedure SetItem(Value: TMMItemIndex); procedure SetAutoCap(Value: Boolean); procedure SetShort(Value: Boolean); procedure SetItemLine(Value: TMMAudioLine); procedure ItemNotify(Sender, Data: TObject); function StoreItem: Boolean; function StoreCaption: Boolean; procedure SetEnabled(Value: Boolean); protected procedure Click; override; procedure Loaded; 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 Channel: TMMChannel read FChannel write SetChannel default chBoth; property Item: TMMItemIndex read FItem write SetItem stored StoreItem; property AutoCaption: Boolean read FAutoCap write SetAutoCap default True; property Short: Boolean read FShort write SetShort default True; property ItemLine: TMMAudioLine read FItemLine write SetItemLine; property Enabled read FEnabled write SetEnabled default True; property Caption stored StoreCaption; end; {-- TMMMixerCheckBox ------------------------------------------------} TMMMixerCheckBox = class(TMMCustomMixerCheckBox) published property OnDragDrop; property OnDragOver; property OnEndDrag; property OnEnter; property OnExit; property OnKeyDown; property OnKeyPress; property OnKeyUp; property OnMouseDown; property OnMouseMove; property OnMouseUp; property OnStartDrag; property Control; property Channel; property Item; property AutoCaption; property Short; property ItemLine; property Enabled; property Caption; property Alignment; property Color; property Ctl3D; property DragCursor; property DragMode; property Font; property ParentColor; property ParentCtl3D; property ParentFont; property ParentShowHint; property PopupMenu; property ShowHint; property TabOrder; property TabStop; property Visible; end; const defInterval = 25; type TMMCurrentValue = array[TMMChannel] of LongInt; {-- TMMCustomMixerConnector -----------------------------------------} TMMCustomMixerConnector = class(TMMComponent) private FTimerID : Longint; FInterval : Integer; FAuto : Boolean; FLink : TMMControlLink; FLevel1 : TMMCustomLevel; FLevel2 : TMMCustomLevel; FMeter1 : TMMCustomMeter; FMeter2 : TMMCustomMeter; FStep : Extended; FItem : TMMItemIndex; FPrev : TMMCurrentValue; FPrevValid : Boolean; FEnabled : Boolean; FOnChange : TNotifyEvent; function GetControl: TMMCustomMixerControl; procedure SetControl(Value: TMMCustomMixerControl); procedure ControlChange(Sender: TObject); procedure SetupConnector; procedure UpdateValue; procedure UpdateControl; procedure SetLevel(Index: Integer; Value: TMMCustomLevel); procedure SetMeter(Index: Integer; Value: TMMCustomMeter); procedure SetAuto(Value: Boolean); procedure SetInterval(Value: Integer); procedure SetItem(Value: TMMItemIndex); procedure SetEnabled(Value: Boolean); protected procedure Changed; virtual; procedure DoChange; dynamic; procedure Loaded; override; procedure Notification(AComponent: TComponent; Operation: TOperation); override; public constructor Create(AOwner: TComponent); override; destructor Destroy; override; procedure Trigger; virtual; protected property Control: TMMCustomMixerControl read GetControl write SetControl; property Level1: TMMCustomLevel index 1 read FLevel1 write SetLevel; property Level2: TMMCustomLevel index 2 read FLevel2 write SetLevel; property Meter1: TMMCustomMeter index 1 read FMeter1 write SetMeter; property Meter2: TMMCustomMeter index 2 read FMeter2 write SetMeter; property AutoTrigger: Boolean read FAuto write SetAuto default True; property Interval: Integer read FInterval write SetInterval default defInterval; property Item: TMMItemIndex read FItem write SetItem default NoItem; property Enabled: Boolean read FEnabled write SetEnabled default True; 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; {-- TMMMixerLabelConnector ------------------------------------------} TMMMixerLabelConnector = class(TMMComponent) private FCaptionLink: TMMCaptionLink; FDest : TControl; FAllCaps : Boolean; FOnChange : TNotifyEvent; procedure CaptionChanged(Sender: TObject); function GetSource: TMMComponent; procedure SetSource(Value: TMMComponent); function GetItem: TMMItemIndex; procedure SetItem(Value: TMMItemIndex); function GetShort: Boolean; procedure SetShort(Value: Boolean); procedure SetDest(Value: TControl); 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: TMMComponent read GetSource write SetSource; property Item: TMMItemIndex read GetItem write SetItem default NoItem; property Short: Boolean read GetShort write SetShort default False; property Destination: TControl 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 MaxLength; property ParentColor; property ParentCtl3D; property ParentFont; property ParentShowHint; property PopupMenu; property ShowHint; property Sorted; property TabOrder; property TabStop; property Visible; end; {-- EMMMixerControlsError ----------------------------------------------} EMMMixerControlsError = class(Exception) end; {=======================================================================} implementation {=======================================================================}