MMMIXCTL.INT 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620
  1. {========================================================================}
  2. {= (c) 1995-98 SwiftSoft Ronald Dittrich =}
  3. {========================================================================}
  4. {= All Rights Reserved =}
  5. {========================================================================}
  6. {= D 01099 Dresden = Tel.: +0351-8012255 =}
  7. {= Loewenstr.7a = info@swiftsoft.de =}
  8. {========================================================================}
  9. {= Actual versions on http://www.swiftsoft.de/mmtools.html =}
  10. {========================================================================}
  11. {= This code is for reference purposes only and may not be copied or =}
  12. {= distributed in any format electronic or otherwise except one copy =}
  13. {= for backup purposes. =}
  14. {= =}
  15. {= No Delphi Component Kit or Component individually or in a collection=}
  16. {= subclassed or otherwise from the code in this unit, or associated =}
  17. {= .pas, .dfm, .dcu, .asm or .obj files may be sold or distributed =}
  18. {= without express permission from SwiftSoft. =}
  19. {= =}
  20. {= For more licence informations please refer to the associated =}
  21. {= HelpFile. =}
  22. {========================================================================}
  23. {= $Date: 20.01.1998 - 18:00:00 $ =}
  24. {========================================================================}
  25. unit MMMixCtl;
  26. {$I COMPILER.INC}
  27. interface
  28. uses
  29. {$IFDEF WIN32}
  30. Windows,
  31. {$ELSE}
  32. WinTypes,
  33. WinProcs,
  34. {$ENDIF}
  35. Forms,
  36. Messages,
  37. Classes,
  38. SysUtils,
  39. StdCtrls,
  40. ExtCtrls,
  41. Controls,
  42. MMObj,
  43. MMUtils,
  44. MMMath,
  45. MMObsrv,
  46. MMMixer,
  47. MMSlider,
  48. MMLevel,
  49. MMMeter,
  50. MMTimer,
  51. MMSpin,
  52. MMPanel,
  53. MMWheel,
  54. MMDevice;
  55. type
  56. TMMIdChangedEvent = procedure of object;
  57. {-- TMMControlLink --------------------------------------------------}
  58. TMMControlLink = class(TMMObserver)
  59. private
  60. FControl : TMMCustomMixerControl;
  61. FOnChange : TNotifyEvent;
  62. FOnIdChange: TMMIdChangedEvent;
  63. procedure SetControl(Value: TMMCustomMixerControl);
  64. protected
  65. procedure Notify(Data: TObject); override;
  66. public
  67. property Control: TMMCustomMixerControl read FControl write SetControl;
  68. property OnChange: TNotifyEvent read FOnChange write FOnChange;
  69. property OnIdChange: TMMIdChangedEvent read FOnIdChange write FOnIdChange;
  70. end;
  71. {-- TMMCaptionLink --------------------------------------------------}
  72. TMMCaptionLink = class(TMMObserver)
  73. private
  74. FComponent : TMMComponent;
  75. FItem : TMMItemIndex;
  76. FShort : Boolean;
  77. FOnChange : TNotifyEvent;
  78. procedure SetComponent(Value: TMMComponent);
  79. procedure SetItem(Value: TMMItemIndex);
  80. procedure SetShort(Value: Boolean);
  81. function GetTitle: string;
  82. procedure RemoveObserver;
  83. procedure AddObserver;
  84. protected
  85. procedure Changed; virtual;
  86. procedure DoChange; dynamic;
  87. procedure Notify(Data: TObject); override;
  88. public
  89. constructor Create;
  90. property Component: TMMComponent read FComponent write SetComponent;
  91. property Item: TMMItemIndex read FItem write SetItem;
  92. property Short: Boolean read FShort write SetShort;
  93. property Title: string read GetTitle;
  94. property OnChange: TNotifyEvent read FOnChange write FOnChange;
  95. end;
  96. EMMCaptionLinkError = class(Exception)
  97. end;
  98. const
  99. MaxSteps = 32;
  100. MixerSliderControlClasses = [ccFader,ccNumber,ccSlider,ccTime];
  101. SwitchControlClasses = [ccList,ccSwitch];
  102. ConnectorControlClasses = [ccFader,ccMeter,ccNumber,ccSlider,ccTime];
  103. MixerWheelControlClasses = MixerSliderControlClasses;
  104. type
  105. {-- TMMCustomMixerSlider --------------------------------------------}
  106. TMMCustomMixerSlider = class(TMMCustomSlider)
  107. private
  108. FLink : TMMControlLink;
  109. FStep : Extended;
  110. FChannel : TMMChannel;
  111. FItem : TMMItemIndex;
  112. FEnabled : Boolean;
  113. function GetControl: TMMCustomMixerControl;
  114. procedure SetControl(Value: TMMCustomMixerControl);
  115. procedure ControlChange(Sender: TObject);
  116. procedure Change; override;
  117. procedure SetupSlider;
  118. procedure UpdateValue;
  119. procedure UpdateControl;
  120. procedure SetChannel(Value: TMMChannel);
  121. procedure SetItem(Value: TMMItemIndex);
  122. procedure SetEnabled(Value: Boolean);
  123. protected
  124. procedure Loaded; override;
  125. procedure Notification(AComponent: TComponent; Operation: TOperation); override;
  126. public
  127. constructor Create(AOwner: TComponent); override;
  128. destructor Destroy; override;
  129. protected
  130. property Control: TMMCustomMixerControl read GetControl write SetControl;
  131. property Channel: TMMChannel read FChannel write SetChannel default chBoth;
  132. property Item: TMMItemIndex read FItem write SetItem default NoItem;
  133. property Enabled read FEnabled write SetEnabled default True;
  134. end;
  135. {-- TMMMixerSlider --------------------------------------------------}
  136. TMMMixerSlider = class(TMMCustomMixerSlider)
  137. published
  138. property OnEnter;
  139. property OnExit;
  140. property OnKeyDown;
  141. property OnKeyPress;
  142. property OnKeyUp;
  143. property OnChange;
  144. property OnTrack;
  145. property OnTrackEnd;
  146. property OnDrawThumb;
  147. property OnDrawGroove;
  148. property Control;
  149. property Channel;
  150. property Item;
  151. property Logarithmic;
  152. property Sensitivity;
  153. property Enabled;
  154. property Visible;
  155. property Color;
  156. property ParentShowHint;
  157. property PopupMenu;
  158. property ShowHint;
  159. property TabStop;
  160. property TabOrder;
  161. property Width;
  162. property Height;
  163. property Bevel;
  164. property Groove;
  165. property FocusAction;
  166. property FocusColor;
  167. property GrooveColor;
  168. property ThumbColor;
  169. property DisabledColor;
  170. property HandCursor;
  171. property Orientation;
  172. property GrooveSize;
  173. property GrooveStyle;
  174. property ThumbWidth;
  175. property ThumbHeight;
  176. property ThumbStyle;
  177. property Scale;
  178. property ScalePosition;
  179. property ScaleDistance;
  180. property PicLeft;
  181. property PicRight;
  182. end;
  183. {-- TMMCustomMixerWheel ---------------------------------------------}
  184. TMMCustomMixerWheel = class(TMMCustomWheel)
  185. private
  186. FLink : TMMControlLink;
  187. FStep : Extended;
  188. FChannel : TMMChannel;
  189. FItem : TMMItemIndex;
  190. FEnabled : Boolean;
  191. function GetControl: TMMCustomMixerControl;
  192. procedure SetControl(Value: TMMCustomMixerControl);
  193. procedure ControlChange(Sender: TObject);
  194. procedure Change; override;
  195. procedure SetupWheel;
  196. procedure UpdateValue;
  197. procedure UpdateControl;
  198. procedure SetChannel(Value: TMMChannel);
  199. procedure SetItem(Value: TMMItemIndex);
  200. procedure SetEnabled(Value: Boolean);
  201. protected
  202. procedure Loaded; override;
  203. procedure Notification(AComponent: TComponent; Operation: TOperation); override;
  204. public
  205. constructor Create(AOwner: TComponent); override;
  206. destructor Destroy; override;
  207. protected
  208. property Control: TMMCustomMixerControl read GetControl write SetControl;
  209. property Channel: TMMChannel read FChannel write SetChannel default chBoth;
  210. property Item: TMMItemIndex read FItem write SetItem default NoItem;
  211. property Enabled read FEnabled write SetEnabled default True;
  212. end;
  213. {-- TMMMixerWheel ---------------------------------------------------}
  214. TMMMixerWheel = class(TMMCustomMixerWheel)
  215. published
  216. property Control;
  217. property Channel;
  218. property Item;
  219. property Enabled;
  220. property OnEnter;
  221. property OnExit;
  222. property OnKeyDown;
  223. property OnKeyPress;
  224. property OnKeyUp;
  225. property OnChange;
  226. property OnDrawHandle;
  227. property Bevel;
  228. property Visible;
  229. property Color;
  230. property ParentShowHint;
  231. property PopupMenu;
  232. property ShowHint;
  233. property TabStop default True;
  234. property TabOrder;
  235. property Width;
  236. property Height;
  237. property AutoSize;
  238. property BackBmp;
  239. property Value;
  240. property StartAngle;
  241. property EndAngle;
  242. property HandleColor;
  243. property FocusedColor;
  244. property UpDown;
  245. property ScrollSize;
  246. property LineStep;
  247. property PageStep;
  248. property FocusAction;
  249. property Scale;
  250. property Radius;
  251. property HandleStyle;
  252. property HandleSize;
  253. property HandleMargin;
  254. property FrameSpace;
  255. property ScaleMargin;
  256. end;
  257. {-- TMMCustomMixerCheckBox ------------------------------------------}
  258. TMMCustomMixerCheckBox = class(TCustomCheckBox)
  259. private
  260. FLink : TMMControlLink;
  261. FChannel : TMMChannel;
  262. FItem : TMMItemIndex;
  263. FAutoCap : Boolean;
  264. FShort : Boolean;
  265. FItemLine : TMMAudioLine;
  266. FItemObserver : TMMObserver;
  267. FEnabled : Boolean;
  268. function GetControl: TMMCustomMixerControl;
  269. procedure SetControl(Value: TMMCustomMixerControl);
  270. procedure ControlChange(Sender: TObject);
  271. procedure SetupCheck;
  272. procedure UpdateValue;
  273. procedure UpdateControl;
  274. procedure SetChannel(Value: TMMChannel);
  275. procedure SetItem(Value: TMMItemIndex);
  276. procedure SetAutoCap(Value: Boolean);
  277. procedure SetShort(Value: Boolean);
  278. procedure SetItemLine(Value: TMMAudioLine);
  279. procedure ItemNotify(Sender, Data: TObject);
  280. function StoreItem: Boolean;
  281. function StoreCaption: Boolean;
  282. procedure SetEnabled(Value: Boolean);
  283. protected
  284. procedure Click; override;
  285. procedure Loaded; override;
  286. procedure Notification(AComponent: TComponent; Operation: TOperation); override;
  287. public
  288. constructor Create(AOwner: TComponent); override;
  289. destructor Destroy; override;
  290. protected
  291. property Control: TMMCustomMixerControl read GetControl write SetControl;
  292. property Channel: TMMChannel read FChannel write SetChannel default chBoth;
  293. property Item: TMMItemIndex read FItem write SetItem stored StoreItem;
  294. property AutoCaption: Boolean read FAutoCap write SetAutoCap default True;
  295. property Short: Boolean read FShort write SetShort default True;
  296. property ItemLine: TMMAudioLine read FItemLine write SetItemLine;
  297. property Enabled read FEnabled write SetEnabled default True;
  298. property Caption stored StoreCaption;
  299. end;
  300. {-- TMMMixerCheckBox ------------------------------------------------}
  301. TMMMixerCheckBox = class(TMMCustomMixerCheckBox)
  302. published
  303. property OnDragDrop;
  304. property OnDragOver;
  305. property OnEndDrag;
  306. property OnEnter;
  307. property OnExit;
  308. property OnKeyDown;
  309. property OnKeyPress;
  310. property OnKeyUp;
  311. property OnMouseDown;
  312. property OnMouseMove;
  313. property OnMouseUp;
  314. property OnStartDrag;
  315. property Control;
  316. property Channel;
  317. property Item;
  318. property AutoCaption;
  319. property Short;
  320. property ItemLine;
  321. property Enabled;
  322. property Caption;
  323. property Alignment;
  324. property Color;
  325. property Ctl3D;
  326. property DragCursor;
  327. property DragMode;
  328. property Font;
  329. property ParentColor;
  330. property ParentCtl3D;
  331. property ParentFont;
  332. property ParentShowHint;
  333. property PopupMenu;
  334. property ShowHint;
  335. property TabOrder;
  336. property TabStop;
  337. property Visible;
  338. end;
  339. const
  340. defInterval = 25;
  341. type
  342. TMMCurrentValue = array[TMMChannel] of LongInt;
  343. {-- TMMCustomMixerConnector -----------------------------------------}
  344. TMMCustomMixerConnector = class(TMMComponent)
  345. private
  346. FTimerID : Longint;
  347. FInterval : Integer;
  348. FAuto : Boolean;
  349. FLink : TMMControlLink;
  350. FLevel1 : TMMCustomLevel;
  351. FLevel2 : TMMCustomLevel;
  352. FMeter1 : TMMCustomMeter;
  353. FMeter2 : TMMCustomMeter;
  354. FStep : Extended;
  355. FItem : TMMItemIndex;
  356. FPrev : TMMCurrentValue;
  357. FPrevValid : Boolean;
  358. FEnabled : Boolean;
  359. FOnChange : TNotifyEvent;
  360. function GetControl: TMMCustomMixerControl;
  361. procedure SetControl(Value: TMMCustomMixerControl);
  362. procedure ControlChange(Sender: TObject);
  363. procedure SetupConnector;
  364. procedure UpdateValue;
  365. procedure UpdateControl;
  366. procedure SetLevel(Index: Integer; Value: TMMCustomLevel);
  367. procedure SetMeter(Index: Integer; Value: TMMCustomMeter);
  368. procedure SetAuto(Value: Boolean);
  369. procedure SetInterval(Value: Integer);
  370. procedure SetItem(Value: TMMItemIndex);
  371. procedure SetEnabled(Value: Boolean);
  372. protected
  373. procedure Changed; virtual;
  374. procedure DoChange; dynamic;
  375. procedure Loaded; override;
  376. procedure Notification(AComponent: TComponent; Operation: TOperation); override;
  377. public
  378. constructor Create(AOwner: TComponent); override;
  379. destructor Destroy; override;
  380. procedure Trigger; virtual;
  381. protected
  382. property Control: TMMCustomMixerControl read GetControl write SetControl;
  383. property Level1: TMMCustomLevel index 1 read FLevel1 write SetLevel;
  384. property Level2: TMMCustomLevel index 2 read FLevel2 write SetLevel;
  385. property Meter1: TMMCustomMeter index 1 read FMeter1 write SetMeter;
  386. property Meter2: TMMCustomMeter index 2 read FMeter2 write SetMeter;
  387. property AutoTrigger: Boolean read FAuto write SetAuto default True;
  388. property Interval: Integer read FInterval write SetInterval default defInterval;
  389. property Item: TMMItemIndex read FItem write SetItem default NoItem;
  390. property Enabled: Boolean read FEnabled write SetEnabled default True;
  391. property OnChange: TNotifyEvent read FOnChange write FOnChange;
  392. end;
  393. {-- TMMMixerConnector -----------------------------------------------}
  394. TMMMixerConnector = class(TMMCustomMixerConnector)
  395. published
  396. property OnChange;
  397. property Control;
  398. property Level1;
  399. property Level2;
  400. property Meter1;
  401. property Meter2;
  402. property AutoTrigger;
  403. property Interval;
  404. property Item;
  405. property Enabled;
  406. end;
  407. {-- TMMMixerLabelConnector ------------------------------------------}
  408. TMMMixerLabelConnector = class(TMMComponent)
  409. private
  410. FCaptionLink: TMMCaptionLink;
  411. FDest : TControl;
  412. FAllCaps : Boolean;
  413. FOnChange : TNotifyEvent;
  414. procedure CaptionChanged(Sender: TObject);
  415. function GetSource: TMMComponent;
  416. procedure SetSource(Value: TMMComponent);
  417. function GetItem: TMMItemIndex;
  418. procedure SetItem(Value: TMMItemIndex);
  419. function GetShort: Boolean;
  420. procedure SetShort(Value: Boolean);
  421. procedure SetDest(Value: TControl);
  422. function GetTitle: string;
  423. procedure SetAllCaps(Value: Boolean);
  424. protected
  425. procedure Notification(AComponent: TComponent; Operation: TOperation); override;
  426. procedure UpdateLabel;
  427. procedure Loaded; override;
  428. procedure Changed; virtual;
  429. procedure DoChange; dynamic;
  430. public
  431. constructor Create(AOwner: TComponent); override;
  432. destructor Destroy; override;
  433. property Title: string read GetTitle;
  434. published
  435. property Source: TMMComponent read GetSource write SetSource;
  436. property Item: TMMItemIndex read GetItem write SetItem default NoItem;
  437. property Short: Boolean read GetShort write SetShort default False;
  438. property Destination: TControl read FDest write SetDest;
  439. property AllCaps: Boolean read FAllCaps write SetAllCaps default False;
  440. property OnChange: TNotifyEvent read FOnChange write FOnChange;
  441. end;
  442. {-- TMMDeviceSpin ---------------------------------------------------}
  443. TMMDeviceSpin = class(TMMCustomSpinButton)
  444. private
  445. FDevice : TMMCustomAudioDevice;
  446. FEnabled : Boolean;
  447. FObserver : TMMObserver;
  448. FCanUpdate : Boolean;
  449. FIncludeMapper : Boolean;
  450. procedure SetDevice(Value: TMMCustomAudioDevice);
  451. procedure DeviceNotify(Sender, Data: TObject);
  452. procedure SetEnabled(Value: Boolean);
  453. procedure SetInclMapper(Value: Boolean);
  454. protected
  455. procedure Notification(AComponent: TComponent; Operation: TOperation); override;
  456. procedure UpdateSpin;
  457. procedure Change; override;
  458. procedure Loaded; override;
  459. public
  460. constructor Create(AOwner: TComponent); override;
  461. destructor Destroy; override;
  462. published
  463. property Enabled: Boolean read FEnabled write SetEnabled default True;
  464. property Device: TMMCustomAudioDevice read FDevice write SetDevice;
  465. property IncludeMapper: Boolean read FIncludeMapper write SetInclMapper default True;
  466. property OnChange;
  467. property OnDownClick;
  468. property OnUpClick;
  469. property Bevel;
  470. property DownGlyph;
  471. property DownNumGlyphs;
  472. property FocusColor;
  473. property FocusControl;
  474. property ParentShowHint;
  475. property PopupMenu;
  476. property ShowHint;
  477. property TabStop;
  478. property TabOrder;
  479. property UpGlyph;
  480. property UpNumGlyphs;
  481. property Visible;
  482. property Width;
  483. property Height;
  484. property ButtonFace;
  485. property MiddleButton;
  486. property Value;
  487. end;
  488. {-- TMMCustomDeviceComboBox --------------------------------------------}
  489. TMMCustomDeviceComboBox = class(TCustomComboBox)
  490. private
  491. FDevice : TMMCustomAudioDevice;
  492. FEnabled : Boolean;
  493. FObserver : TMMObserver;
  494. FCanUpdate : Boolean;
  495. FIncludeMapper : Boolean;
  496. procedure SetDevice(Value: TMMCustomAudioDevice);
  497. procedure DeviceNotify(Sender, Data: TObject);
  498. procedure SetEnabled(Value: Boolean);
  499. procedure SetInclMapper(Value: Boolean);
  500. protected
  501. procedure Notification(AComponent: TComponent; Operation: TOperation); override;
  502. procedure UpdateCombo;
  503. procedure Loaded; override;
  504. procedure Change; override;
  505. public
  506. constructor Create(AOwner: TComponent); override;
  507. destructor Destroy; override;
  508. protected
  509. property Device: TMMCustomAudioDevice read FDevice write SetDevice;
  510. property Enabled: Boolean read FEnabled write SetEnabled default True;
  511. property IncludeMapper: Boolean read FIncludeMapper write SetInclMapper default True;
  512. end;
  513. {-- TMMDeviceComboBox --------------------------------------------------}
  514. TMMDeviceComboBox = class(TMMCustomDeviceComboBox)
  515. published
  516. property OnChange;
  517. property OnClick;
  518. property OnDblClick;
  519. property OnDragDrop;
  520. property OnDragOver;
  521. property OnDrawItem;
  522. property OnDropDown;
  523. property OnEndDrag;
  524. property OnEnter;
  525. property OnExit;
  526. property OnKeyDown;
  527. property OnKeyPress;
  528. property OnKeyUp;
  529. property OnMeasureItem;
  530. property OnStartDrag;
  531. property Device;
  532. property Enabled;
  533. property IncludeMapper;
  534. property Color;
  535. property Ctl3D;
  536. property DragMode;
  537. property DragCursor;
  538. property DropDownCount;
  539. property Font;
  540. property ItemHeight;
  541. property MaxLength;
  542. property ParentColor;
  543. property ParentCtl3D;
  544. property ParentFont;
  545. property ParentShowHint;
  546. property PopupMenu;
  547. property ShowHint;
  548. property Sorted;
  549. property TabOrder;
  550. property TabStop;
  551. property Visible;
  552. end;
  553. {-- EMMMixerControlsError ----------------------------------------------}
  554. EMMMixerControlsError = class(Exception)
  555. end;
  556. {=======================================================================}
  557. implementation
  558. {=======================================================================}