home *** CD-ROM | disk | FTP | other *** search
/ Chip 2001 December / Chip_2001-12_cd1.bin / zkuste / delphi / kolekce / d3456 / ALEXSOFT.ZIP / DBEDFLD.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  2001-09-04  |  39.1 KB  |  1,272 lines

  1. (*////////////////////////////////////////////////////////////////////////////
  2. //   Part of AlexSoft VCL/DLL Library.                                      //
  3. //   All rights reserved. (c) Copyright 1998.                               //
  4. //   Created by: Alex Rabichooc                                             //
  5. //**************************************************************************//
  6. //  Users of this unit must accept this disclaimer of warranty:             //
  7. //    "This unit is supplied as is. The author disclaims all warranties,    //
  8. //    expressed or implied, including, without limitation, the warranties   //
  9. //    of merchantability and of fitness for any purpose.                    //
  10. //    The author assumes no liability for damages, direct or                //
  11. //    consequential, which may result from the use of this unit."           //
  12. //                                                                          //
  13. //  This Unit is donated to the public as public domain.                    //
  14. //                                                                          //
  15. //  This Unit can be freely used and distributed in commercial and          //
  16. //  private environments provided this notice is not modified in any way.   //
  17. //                                                                          //
  18. //  If you do find this Unit handy and you feel guilty for using such a     //
  19. //  great product without paying someone - sorry :-)                        //
  20. //                                                                          //
  21. //  Please forward any comments or suggestions to Alex Rabichooc at:        //
  22. //                                                                          //
  23. //  a_rabichooc@yahoo.com or alex@carmez.mldnet.com                         //
  24. /////////////////////////////////////////////////////////////////////////////*)
  25.  
  26. unit dbedfld;
  27.  
  28. interface
  29. uses Windows, Messages, SysUtils, Classes, Controls, Graphics, Forms, Dialogs,
  30.      DB, StdCtrls, Buttons, DBCtrls, StdUtils {$IFDEF VER120}, dbxctrls{$ENDIF};
  31.  
  32. type
  33. TRaDBEditType = (efEmpty, efEdit, efMemo, efImage, efLookUp,
  34.                  efDate, efTime, efDataSet);
  35.  
  36. TEditKind = (ekCommon, ekView, ekControl);
  37.  
  38. TRaDBEdit = class;
  39.  
  40. TRaDBEdit = class(TWinControl)
  41.   private
  42.     FChanging: Boolean;
  43.     FTabStop: Boolean;
  44.     FEditKind: TEditKind;
  45.     FControl: TWinControl;
  46.     FButton: TSpeedButton;
  47.     FDataLink: TFieldDataLink;
  48.     FLabel: TLabel;
  49.     FField: TField;
  50.     FDistanceX: Integer;
  51.     FDistanceY: Integer;
  52.     FShowBlob: Boolean;
  53.     FDeltaX: Integer;
  54.     FDeltaY: Integer;
  55.     FOnButtonClick: TNotifyEvent;
  56.     FOnReplaceField: TFieldNotifyEvent;
  57.     procedure CMDesignHitTest(var Mess: TCMDesignHitTest); message CM_DESIGNHITTEST;
  58.     procedure CNReplaceField(var Message: TMessage); Message CN_REPLACEFIELD;
  59.     procedure DoChanges(Sender: TObject);
  60.     procedure DoButtonClick(Sender: TObject);
  61.     procedure DoEditKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
  62.     procedure DoEditKeyPress(Sender: TObject; var Key: Char);
  63.     procedure DoEditKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState);
  64.     function GetGlyph: TBitmap;
  65.     function GetNumGlyphs: TNumGlyphs;
  66.     procedure SetNumGlyphs(Value: TNumGlyphs);
  67.     function GetButtonHint: String;
  68.     procedure SetButtonHint(Value: String);
  69.     function GetDataField: string;
  70.     function GetDataSource: TDataSource;
  71.     function GetOnButtonClick: TNotifyEvent;
  72.     procedure SetOnButtonClick(Value: TNotifyEvent);
  73.     function GetField: TField;
  74.     procedure SetDataField(const Value: string);
  75.     procedure SetDataSource(Value: TDataSource);
  76.     procedure SetEditKind(Value: TEditKind);
  77.     procedure SetDistanceX(Value: Integer);
  78.     procedure SetDistanceY(Value: Integer);
  79.     function GetMaxLength: Integer;
  80.     procedure SetMaxLength(Value: Integer);
  81.     function GetReadOnly: Boolean;
  82.     procedure SetTabStop(Value: Boolean);
  83.     function GetCaption: String;
  84.     procedure SetCaption(Value: String);
  85.     procedure SetGlyph(Value: TBitmap);
  86.     function GetLabelFont: TFont;
  87.     procedure SetLabelFont(AFont: TFont);
  88.     procedure SetShowBlob(Value: Boolean);
  89.     function GetLabelParentFont: Boolean;
  90.     procedure SetLabelParentFont(Value: Boolean);
  91.     procedure SetOnReplaceField(const Value: TFieldNotifyEvent);
  92.     procedure DoOnClick(Sender: TObject);
  93.     procedure DoOnDblClick(Sender: TObject);
  94.     procedure DoOnDragDrop(Sender, Source: TObject; X, Y: Integer);
  95.     procedure DoOnDragOver(Sender, Source: TObject; X, Y: Integer; State: TDragState; var Accept: Boolean);
  96.     procedure DoOnEndDrag(Sender, Target: TObject; X, Y: Integer);
  97.     procedure DoOnMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
  98.     procedure DoOnMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
  99.     procedure DoOnMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
  100.     procedure DoOnStartDrag(Sender: TObject; var DragObject: TDragObject);
  101.     procedure DoOnEnter(Sender: TObject);
  102.     procedure DoOnExit(Sender: TObject);
  103.   protected
  104.     FCaption: String;
  105.     procedure CreateControl;
  106.     procedure Notification(AComponent: TComponent;
  107.                                           Operation: TOperation); override;
  108.     procedure SetName(const NewName: TComponentName); override;
  109.     procedure SetParent(AParent: TWinControl); override;
  110.   public
  111.     constructor Create(AOwner: TComponent); override;
  112.     destructor Destroy; override;
  113.     procedure ClickButton;
  114.     procedure FreeControl;
  115.     function FieldType: TRaDBEditType; virtual;
  116.     procedure SetBounds(ALeft, ATop, AWidth, AHeight: Integer); override;
  117.     property Field: TField read GetField;
  118.     property Glyph: TBitmap read GetGlyph write SetGlyph;
  119.     property NumGlyphs: TNumGlyphs read GetNumGlyphs write SetNumGlyphs default 1;
  120.     property CLabel: TLabel read FLabel;
  121.     procedure Refresh(Resize: boolean);
  122.     property ReadOnly: Boolean read GetReadOnly;
  123.     property Changing: Boolean read FChanging write FChanging;
  124.   published
  125.     property ShowBlob: Boolean read FShowBlob write SetShowBlob;
  126.     property DataSource: TDataSource read GetDataSource write SetDataSource;
  127.     property DataField: string read GetDataField write SetDataField;
  128.     property DistanceX: Integer read FDistanceX write SetDistanceX;
  129.     property DistanceY: Integer read FDistanceY write SetDistanceY;
  130.     property MaxLength: Integer read GetMaxLength write SetMaxLength;
  131.     property EditKind: TEditKind read FEditKind write SetEditKind;
  132.     property Font;
  133.     property LabelFont: TFont read GetLabelFont write SetLabelFont;
  134.     property LabelParentFont: Boolean read GetLabelParentFont
  135.                                       write SetLabelParentFont;
  136.     property Caption: String read GetCaption write SetCaption;
  137.     property ButtonHint: String read GetButtonHint write SetButtonHint;
  138.     property OnButtonClick: TNotifyEvent read GetOnButtonClick
  139.                                          write SetOnButtonClick;
  140.     property OnReplaceField: TFieldNotifyEvent read FOnReplaceField write SetOnReplaceField;
  141.     property ParentFont;
  142.     property Enabled;
  143.     property OnClick;
  144.     property OnDblClick;
  145.     property OnDragDrop;
  146.     property OnDragOver;
  147.     property OnEndDrag;
  148.     property OnMouseDown;
  149.     property OnMouseMove;
  150.     property OnMouseUp;
  151.     property OnStartDrag;
  152.     property OnEnter;
  153.     property OnExit;
  154.     property OnKeyDown;
  155.     property OnKeyPress;
  156.     property OnKeyUp;
  157.     property TabStop: boolean read FTabStop write SetTabStop;
  158.     property TabOrder;
  159.     property ShowHint;
  160.     property Visible;
  161. end;
  162.  
  163. TxDBLookUpComboBox = {$IFDEF VER120}class(TfxDBLookUpComboBox)
  164.                      {$ELSE}class(TDBLookUpComboBox)
  165.                      {$ENDIF}
  166. protected
  167.     procedure KeyPress(var Key: Char); override;
  168.     procedure CMDesignHitTest(var Message: TCMDesignHitTest); message CM_DESIGNHITTEST;
  169. end;
  170.  
  171. {$IFNDEF PROFI}
  172. TDBSmartImage = class(TDBImage);
  173. {$ENDIF}
  174.  
  175. implementation
  176. uses dbConsts, dbBoxGrd, dbTools, {$IFDEF PROFI}dbImage, {$ENDIF}dbPanel, DbXCnsts;
  177.  
  178. type
  179.  
  180. TxLabel = class(TLabel)
  181. protected
  182.   procedure CMDesignHitTest(var Message: TCMDesignHitTest); message CM_DESIGNHITTEST;
  183. end;
  184.  
  185. TxButton = class(TSpeedButton)
  186. protected
  187.   procedure CMDesignHitTest(var Message: TCMDesignHitTest); message CM_DESIGNHITTEST;
  188. end;
  189.  
  190. TxDBEdit = class(TDBEdit)
  191. protected
  192.   procedure KeyPress(var Key: Char); override;
  193.   procedure CMDesignHitTest(var Message: TCMDesignHitTest); message CM_DESIGNHITTEST;
  194. end;
  195.  
  196. TDBDateEdit = class(TxDBEdit)
  197. protected
  198.   procedure CMDesignHitTest(var Message: TCMDesignHitTest); message CM_DESIGNHITTEST;
  199. end;
  200.  
  201. TxDBSmartImage = class(TDBSmartImage)
  202. protected
  203.   procedure CMDesignHitTest(var Message: TCMDesignHitTest); message CM_DESIGNHITTEST;
  204. end;
  205.  
  206. TxDBRichEdit = class(TDBRichEdit)
  207. protected
  208.   procedure CMDesignHitTest(var Message: TCMDesignHitTest); message CM_DESIGNHITTEST;
  209. end;
  210.  
  211. {$R DBEDFLD.RES}
  212.  
  213. procedure PerformHitTest(DBEdit: TRaDBEdit; var Mess: TCMDesignHitTest);
  214. begin
  215.   if (DBEdit.Parent is TDBPanelBox) and
  216.      (DBEdit.Parent as TDBPanelBox).StoreFields then
  217.   with Mess do
  218.   begin
  219.      if Keys=1 then
  220.      begin
  221.         Screen.Cursor := crHandPoint;
  222.         if (DBEdit.FDeltaX = 0) and (DBEdit.FDeltaY = 0) then
  223.         begin
  224.            DBEdit.FDeltaX := XPos-1;
  225.            DBEdit.FDeltaY := YPos-1;
  226.         end;
  227.         DBEdit.Left := DBEdit.Left+XPos-DBEdit.FDeltaX-1;
  228.         DBEdit.Top := DBEdit.Top+YPos-DBEdit.FDeltaY-1;
  229.      end
  230.       else
  231.       begin
  232.          Screen.Cursor := crDefault;
  233.          DBEdit.FDeltaX := 0;
  234.          DBEdit.FDeltaY := 0;
  235.          if Screen.ActiveControl = DBEdit.FControl then
  236.          begin
  237.            Application.MainForm.Show;
  238.            GetParentForm(DBEdit).Show;
  239.          end;
  240.       end;
  241.      Result := 1;
  242.   end;
  243. end;
  244.  
  245. {TxDBLookUpComboBox}
  246. procedure TxDBLookUpComboBox.KeyPress(var Key: Char);
  247. begin
  248.   if not ListVisible and (Key = #27) then
  249.     GetParentForm(Self).Perform(CM_DIALOGKEY, Byte(Key), 0)
  250.     else
  251.       Inherited;
  252. end;
  253.  
  254. procedure TxDBLookUpComboBox.CMDesignHitTest(var Message: TCMDesignHitTest);
  255. begin
  256.    if (Parent is TRaDBEdit) then
  257.      PerformHitTest((Parent as TRaDBEdit), Message);
  258.   if Message.Result = 0 then
  259.      Inherited;
  260. end;
  261.  
  262. {TxLabel}
  263. procedure TxLabel.CMDesignHitTest(var Message: TCMDesignHitTest);
  264. begin
  265.    if (Parent is TRaDBEdit) then
  266.      PerformHitTest((Parent as TRaDBEdit), Message);
  267.   if Message.Result = 0 then
  268.      Inherited;
  269. end;
  270.  
  271. {TxDBEdit}
  272. procedure TxDBEdit.KeyPress(var Key: Char);
  273. type PClass = ^TClass;
  274. var AField: TField;
  275.     SelfClass: TClass;
  276. begin
  277.   AField := nil;
  278.   if (Datasource <> nil) and (DataSource.DataSet <> nil) and
  279.      DataSource.DataSet.Active and Assigned(Field) then
  280.   begin
  281.      if (Field.FieldKind = fkData) and (Field.LookUpDataSet <> nil) then
  282.         AField := Field.LookUpDataSet.FindField(Field.LookUpResultField);
  283.   end;
  284.  
  285.   if AField = nil then
  286.      AField := Field;
  287.  
  288.   SelfClass := PClass(Self)^;
  289.   try
  290.     PClass(Self)^ := Self.ClassParent.ClassParent;
  291.     KeyPress(Key);
  292.   finally
  293.     PClass(Self)^ := SelfClass;
  294.   end;
  295.  
  296.   if (Key in [#32..#255]) and (AField <> nil) and not AField.IsValidChar(Key) then
  297.   begin
  298.     MessageBeep(0);
  299.     Key := #0;
  300.   end;
  301.   case Key of
  302.     ^H, ^V, ^X, #32..#255:
  303.       EditCanModify;
  304.     #27:
  305.       begin
  306.         Reset;
  307.         Key := #0;
  308.       end;
  309.   end;
  310. end;
  311.  
  312. procedure TxDBEdit.CMDesignHitTest(var Message: TCMDesignHitTest);
  313. begin
  314.    if (Parent is TRaDBEdit) then
  315.      PerformHitTest((Parent as TRaDBEdit), Message);
  316.   if Message.Result = 0 then
  317.      Inherited;
  318. end;
  319.  
  320. {TxDBRichEdit}
  321. procedure TxDBRichEdit.CMDesignHitTest(var Message: TCMDesignHitTest);
  322. begin
  323.    if (Parent is TRaDBEdit) then
  324.      PerformHitTest((Parent as TRaDBEdit), Message);
  325.   if Message.Result = 0 then
  326.      Inherited;
  327. end;
  328.  
  329. {TxDBSmartImage}
  330. procedure TxDBSmartImage.CMDesignHitTest(var Message: TCMDesignHitTest);
  331. begin
  332.    if (Parent is TRaDBEdit) then
  333.      PerformHitTest((Parent as TRaDBEdit), Message);
  334.   if Message.Result = 0 then
  335.      Inherited;
  336. end;
  337.  
  338. {TDBDateEdit}
  339. procedure TDBDateEdit.CMDesignHitTest(var Message: TCMDesignHitTest);
  340. begin
  341.    if (Parent is TRaDBEdit) then
  342.      PerformHitTest((Parent as TRaDBEdit), Message);
  343.   if Message.Result = 0 then
  344.      Inherited;
  345. end;
  346.  
  347. {TxButton}
  348. procedure TxButton.CMDesignHitTest(var Message: TCMDesignHitTest);
  349. begin
  350.    if (Parent is TRaDBEdit) then
  351.      PerformHitTest((Parent as TRaDBEdit), Message);
  352.   if Message.Result = 0 then
  353.      Inherited;
  354. end;
  355.  
  356. {TRaDBEdit}
  357. constructor TRaDBEdit.Create(AOwner: TComponent);
  358. begin
  359.   Inherited Create(AOwner);
  360.   FButton := TxButton.Create(Self);
  361.   FButton.Enabled := False;
  362.   FButton.Visible := False;
  363.   FButton.Glyph.LoadFromResourceName(HInstance,'EDITBUTTON');
  364.   FButton.Parent := Self;
  365.   FButton.ShowHint := True;
  366.   if not (csDesigning in ComponentState) then
  367.      FButton.OnClick := DoButtonClick;
  368.   ControlStyle := ControlStyle + [csReplicatable];
  369.   FDataLink := TFieldDataLink.Create;
  370.   FDataLink.Control := Self;
  371.   FDataLink.OnDataChange := DoChanges;
  372.   Width := 121;
  373.   Height := 40;
  374.   FDistanceY := 4;
  375.   FTabStop := True;
  376.   FLabel := TxLabel.Create(Self);
  377.   FLabel.Parent := Self;
  378.   if not (csDesigning in ComponentState) then
  379.   begin
  380.     FLabel.OnClick := DoOnClick;
  381.     FLabel.OnDblClick := DoOnDblClick;
  382.     FLabel.OnDragDrop := DoOnDragDrop;
  383.     FLabel.OnDragOver := DoOnDragOver;
  384.     FLabel.OnEndDrag := DoOnEndDrag;
  385.     FLabel.OnMouseDown := DoOnMouseDown;
  386.     FLabel.OnMouseMove := DoOnMouseMove;
  387.     FLabel.OnMouseUp := DoOnMouseUp;
  388.     FLabel.OnStartDrag := DoOnStartDrag;
  389.   end
  390.    else
  391.      ControlStyle := ControlStyle + [csFramed];
  392. end;
  393.  
  394. destructor TRaDBEdit.Destroy;
  395. begin
  396.   FDataLink.Free;
  397.   FDataLink := nil;
  398.   inherited Destroy;
  399. end;
  400.  
  401. procedure TRaDBEdit.CMDesignHitTest(var Mess: TCMDesignHitTest);
  402. begin
  403.   PerformHitTest(Self, Mess);
  404.   if Mess.Result = 0 then
  405.      Inherited;
  406. end;
  407.  
  408. procedure TRaDBEdit.CNReplaceField(var Message: TMessage);
  409. var AField: TField;
  410.     Form: TCustomForm;
  411. begin
  412.    AField := pointer(Message.LParam);
  413.    if FControl.CanFocus then
  414.    begin
  415.      if Assigned(FOnReplaceField) then
  416.         FOnReplaceField(AField)
  417.        else
  418.         ReplaceField(AField);
  419.      FControl.SetFocus;
  420.    end;
  421.    Form := GetParentForm(Self);
  422.    if (Form <> nil) and (Form.CanFocus) then
  423.       Form.SetFocus;
  424. end;
  425.  
  426. procedure TRaDBEdit.DoChanges(Sender: TObject);
  427. const IAmHere: Boolean = False;
  428. begin
  429.    if (Parent is TRaDBBox) and (Parent as TRaDBBox).FixedFields then
  430.       Exit;
  431.    if IAmHere then Exit;
  432.    IAmHere := True;
  433.    try
  434.      if (FControl = nil) or (Field <> FField) then
  435.      begin
  436.         Refresh(not ((FField = nil) and (Field.FieldName = DataField)));
  437.         SetFieldAttributes(Field);
  438.      end;
  439.    finally
  440.      IAmHere := False;
  441.    end;
  442. end;
  443.  
  444. procedure TRaDBEdit.DoEditKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
  445. begin
  446.   if Assigned(OnKeyDown) then
  447.      OnKeyDown(Self, Key, Shift);
  448. end;
  449.  
  450. procedure TRaDBEdit.DoEditKeyPress(Sender: TObject; var Key: Char);
  451. begin
  452.   if Assigned(OnKeyPress) then
  453.      OnKeyPress(Self, Key);
  454. end;
  455.  
  456. procedure TRaDBEdit.DoEditKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState);
  457. begin
  458.   if Assigned(OnKeyUp) then
  459.      OnKeyUp(Self, Key, Shift);
  460. end;
  461.  
  462. procedure TRaDBEdit.DoButtonClick(Sender: TObject);
  463. begin
  464.    if (FControl <> nil) and (FControl.CanFocus) and not ReadOnly then
  465.       FControl.SetFocus;
  466.    if Assigned(FOnButtonClick) then
  467.       FOnButtonClick(Self)
  468.      else
  469.       DoEditButtonClick(Field, Self);
  470. end;
  471.  
  472. function TRaDBEdit.FieldType: TRaDBEditType;
  473. var AField: TField;
  474. begin
  475.    AField := Field;
  476.    if AField = nil then
  477.       Result := efEmpty
  478.      else
  479.       begin
  480.          Result := efEdit;
  481.       end;
  482.    if (Result = efEdit) and (AField.FieldKind = fkLookUp) and
  483.       (EditKind <> ekView) then
  484.       Result := efLookUp;
  485.    if Result = efEdit then
  486.      case AField.DataType of
  487.        ftMemo, ftFmtMemo:
  488.            Result := efMemo;
  489.        ftGraphic, ftTypedBinary, ftBlob:
  490.            Result := efImage;
  491.        ftDate, ftDateTime:
  492.            Result := efDate;
  493.        {$IFNDEF VER110}
  494.        {$ELSE}
  495.        ftDataSet:
  496.            Result := efDataSet;
  497.        {$ENDIF}
  498.      end;
  499. end;
  500.  
  501. procedure TRaDBEdit.CreateControl;
  502. begin
  503.    case FieldType of
  504.      efLookUp:
  505.          begin
  506.             FControl := TxDBLookUpComboBox.Create(Self);
  507.             FControl.Parent := Self;
  508.             with FControl as TxDBLookUpComboBox do
  509.             begin
  510.                DataSource := nil;
  511.                DataField := Self.DataField;
  512.                DataSource := Self.DataSource;
  513.                TabStop := Self.TabStop;
  514.  
  515.                if not (csDesigning in Self.ComponentState) then
  516.                begin
  517.                  OnKeyDown := DoEditKeyDown;
  518.                  OnKeyPress := Self.DoEditKeyPress;
  519.                  OnKeyUp := Self.DoEditKeyUp;
  520.                  OnClick := Self.DoOnClick;
  521.                  OnDblClick := Self.DoOnDblClick;
  522.                  OnDragDrop := Self.DoOnDragDrop;
  523.                  OnDragOver := Self.DoOnDragOver;
  524.                  OnEndDrag := Self.DoOnEndDrag;
  525.                  OnMouseDown := Self.DoOnMouseDown;
  526.                  OnMouseMove := Self.DoOnMouseMove;
  527.                  OnMouseUp := Self.DoOnMouseUp;
  528.                  OnStartDrag := Self.DoOnStartDrag;
  529.                  OnEnter := Self.DoOnEnter;
  530.                  OnExit := Self.DoOnExit;
  531.                end;
  532.             end;
  533.          end;
  534.     efDate:
  535.          begin
  536.             FControl := TDBDateEdit.Create(Self);
  537.             if csDesigning in ComponentState then
  538.               FControl.Enabled := False;
  539.             FControl.Parent := Self;
  540.             with FControl as TDBDateEdit do
  541.             begin
  542.                DataSource := nil;
  543.                DataField := Self.DataField;
  544.                DataSource := Self.DataSource;
  545.                ReadOnly := Self.ReadOnly;
  546.                TabStop := Self.TabStop;
  547.  
  548.                if not (csDesigning in Self.ComponentState) then
  549.                begin
  550.                  OnKeyDown := DoEditKeyDown;
  551.                  OnKeyPress := Self.DoEditKeyPress;
  552.                  OnKeyUp := Self.DoEditKeyUp;
  553.                  OnClick := Self.DoOnClick;
  554.                  OnDblClick := Self.DoOnDblClick;
  555.                  OnDragDrop := Self.DoOnDragDrop;
  556.                  OnDragOver := Self.DoOnDragOver;
  557.                  OnEndDrag := Self.DoOnEndDrag;
  558.                  OnMouseDown := Self.DoOnMouseDown;
  559.                  OnMouseMove := Self.DoOnMouseMove;
  560.                  OnMouseUp := Self.DoOnMouseUp;
  561.                  OnStartDrag := Self.DoOnStartDrag;
  562.                  OnEnter := Self.DoOnEnter;
  563.                  OnExit := Self.DoOnExit;
  564.                end;
  565.  
  566.                if EditKind = ekView then
  567.                begin
  568.                   ParentColor := True;
  569.                   ReadOnly := True;
  570.                   TabStop := False;
  571.                   BorderStyle := bsNone;
  572.                end
  573.             end;
  574.          end;
  575.     efImage :
  576.          begin
  577.             FControl := TxDBSmartImage.Create(Self);
  578.             FControl.Parent := Self;
  579.             with FControl as TxDBSmartImage do
  580.             begin
  581.                AutoDisplay := ShowBlob;
  582.                DataSource := nil;
  583.                DataField := Self.DataField;
  584.                DataSource := Self.DataSource;
  585.                if FShowBlob then
  586.                begin
  587.                   Width := Picture.Width;
  588.                   Height := Picture.Height;
  589.                end
  590.                  else
  591.                  begin
  592.                     Width := 0;
  593.                     Height := 21;
  594.                  end;
  595.                Visible := FShowBlob;
  596.                if Visible then
  597.                   ControlStyle := ControlStyle - [csNoDesignVisible]
  598.                  else
  599.                   ControlStyle := ControlStyle + [csNoDesignVisible];
  600.                ReadOnly := Self.ReadOnly;
  601.                TabStop := Self.TabStop;
  602.  
  603.                if not (csDesigning in Self.ComponentState) then
  604.                begin
  605.                  OnKeyDown := DoEditKeyDown;
  606.                  OnKeyPress := Self.DoEditKeyPress;
  607.                  OnKeyUp := Self.DoEditKeyUp;
  608.                  OnClick := Self.DoOnClick;
  609.                  OnDblClick := Self.DoOnDblClick;
  610.                  OnDragDrop := Self.DoOnDragDrop;
  611.                  OnDragOver := Self.DoOnDragOver;
  612.                  OnEndDrag := Self.DoOnEndDrag;
  613.                  OnMouseDown := Self.DoOnMouseDown;
  614.                  OnMouseMove := Self.DoOnMouseMove;
  615.                  OnMouseUp := Self.DoOnMouseUp;
  616.                  OnStartDrag := Self.DoOnStartDrag;
  617.                  OnEnter := Self.DoOnEnter;
  618.                  OnExit := Self.DoOnExit;
  619.                end;
  620.  
  621.                if EditKind = ekView then
  622.                begin
  623.                   ParentColor := True;
  624.                   TabStop := False;
  625.                   ReadOnly := True;
  626.                   BorderStyle := bsNone;
  627.                end
  628.             end;
  629.          end;
  630.     efMemo :
  631.          begin
  632.             FControl := TxDBRichEdit.Create(Self);
  633.             FControl.Parent := Self;
  634.             with FControl as TxDBRichEdit do
  635.             begin
  636.                AutoDisplay := ShowBlob;
  637.                DataSource := nil;
  638.                DataField := Self.DataField;
  639.                DataSource := Self.DataSource;
  640.                if FShowBlob then
  641.                begin
  642.                   Width := 300;
  643.                   Height := 100;
  644.                end
  645.                  else
  646.                  begin
  647.                     Width := 0;
  648.                     Height := 21;
  649.                  end;
  650.                Visible := FShowBlob;
  651.                if Visible then
  652.                   ControlStyle := ControlStyle - [csNoDesignVisible]
  653.                  else
  654.                   ControlStyle := ControlStyle + [csNoDesignVisible];
  655.                ScrollBars := ssBoth;
  656.                ReadOnly := Self.ReadOnly;
  657.                TabStop := Self.TabStop;
  658.  
  659.                if not (csDesigning in Self.ComponentState) then
  660.                begin
  661.                  OnKeyDown := DoEditKeyDown;
  662.                  OnKeyPress := Self.DoEditKeyPress;
  663.                  OnKeyUp := Self.DoEditKeyUp;
  664.                  OnClick := Self.DoOnClick;
  665.                  OnDblClick := Self.DoOnDblClick;
  666.                  OnDragDrop := Self.DoOnDragDrop;
  667.                  OnDragOver := Self.DoOnDragOver;
  668.                  OnEndDrag := Self.DoOnEndDrag;
  669.                  OnMouseDown := Self.DoOnMouseDown;
  670.                  OnMouseMove := Self.DoOnMouseMove;
  671.                  OnMouseUp := Self.DoOnMouseUp;
  672.                  OnStartDrag := Self.DoOnStartDrag;
  673.                  OnEnter := Self.DoOnEnter;
  674.                  OnExit := Self.DoOnExit;
  675.                end;
  676.  
  677.                if EditKind = ekView then
  678.                begin
  679.                   ParentColor := True;
  680.                   TabStop := False;
  681.                   ReadOnly := True;
  682.                   BorderStyle := bsNone;
  683.                end
  684.             end;
  685.          end;
  686.     efDataSet :
  687.          begin
  688.             FControl := TxDBEdit.Create(Self);
  689.             FControl.Parent := Self;
  690.             with FControl as TxDBEdit do
  691.             begin
  692.                DataSource := nil;
  693.                DataField := Self.DataField;
  694.                DataSource := Self.DataSource;
  695.                Width := 0;
  696.                Height := 21;
  697.                Visible := False;
  698.                ControlStyle := ControlStyle + [csNoDesignVisible];
  699.                TabStop := False;
  700.                ReadOnly := True;
  701.                BorderStyle := bsNone;
  702.  
  703.                if not (csDesigning in Self.ComponentState) then
  704.                begin
  705.                  OnKeyDown := DoEditKeyDown;
  706.                  OnKeyPress := Self.DoEditKeyPress;
  707.                  OnKeyUp := Self.DoEditKeyUp;
  708.                  OnClick := Self.DoOnClick;
  709.                  OnDblClick := Self.DoOnDblClick;
  710.                  OnDragDrop := Self.DoOnDragDrop;
  711.                  OnDragOver := Self.DoOnDragOver;
  712.                  OnEndDrag := Self.DoOnEndDrag;
  713.                  OnMouseDown := Self.DoOnMouseDown;
  714.                  OnMouseMove := Self.DoOnMouseMove;
  715.                  OnMouseUp := Self.DoOnMouseUp;
  716.                  OnStartDrag := Self.DoOnStartDrag;
  717.                  OnEnter := Self.DoOnEnter;
  718.                  OnExit := Self.DoOnExit;
  719.                end;
  720.             end;
  721.          end;
  722.        else
  723.          begin
  724.             FControl := TxDBEdit.Create(Self);
  725.             FControl.Parent := Self;
  726.             with FControl as TxDBEdit do
  727.             begin
  728.                DataSource := nil;
  729.                DataField := Self.DataField;
  730.                DataSource := Self.DataSource;
  731.                ReadOnly := Self.ReadOnly;
  732.                TabStop := Self.TabStop;
  733.                if EditKind = ekView then
  734.                begin
  735.                   ParentColor := True;
  736.                   TabStop := False;
  737.                   ReadOnly := True;
  738.                   BorderStyle := bsNone;
  739.                end;
  740.  
  741.                if not (csDesigning in Self.ComponentState) then
  742.                begin
  743.                  OnKeyDown := DoEditKeyDown;
  744.                  OnKeyPress := Self.DoEditKeyPress;
  745.                  OnKeyUp := Self.DoEditKeyUp;
  746.                  OnClick := Self.DoOnClick;
  747.                  OnDblClick := Self.DoOnDblClick;
  748.                  OnDragDrop := Self.DoOnDragDrop;
  749.                  OnDragOver := Self.DoOnDragOver;
  750.                  OnEndDrag := Self.DoOnEndDrag;
  751.                  OnMouseDown := Self.DoOnMouseDown;
  752.                  OnMouseMove := Self.DoOnMouseMove;
  753.                  OnMouseUp := Self.DoOnMouseUp;
  754.                  OnStartDrag := Self.DoOnStartDrag;
  755.                  OnEnter := Self.DoOnEnter;
  756.                  OnExit := Self.DoOnExit;
  757.                end;
  758.             end;
  759.          end;
  760.     end;
  761. end;
  762.  
  763. function TRaDBEdit.GetGlyph: TBitmap;
  764. begin
  765.   Result := FButton.Glyph;
  766. end;
  767.  
  768. procedure TRaDBEdit.SetGlyph(Value: TBitmap);
  769. begin
  770.   FButton.Glyph := Value;
  771. end;
  772.  
  773. function TRaDBEdit.GetButtonHint: String;
  774. begin
  775.    Result := FButton.Hint;
  776. end;
  777.  
  778. procedure TRaDBEdit.SetButtonHint(Value: String);
  779. begin
  780.    FButton.Hint := Value;
  781. end;
  782.  
  783. function TRaDBEdit.GetNumGlyphs: TNumGlyphs;
  784. begin
  785.    Result := FButton.NumGlyphs;
  786. end;
  787.  
  788. procedure TRaDBEdit.SetNumGlyphs(Value: TNumGlyphs);
  789. begin
  790.    FButton.NumGlyphs := Value;
  791. end;
  792.  
  793. procedure TRaDBEdit.ClickButton;
  794. begin
  795.    if FButton.Enabled then
  796.        FButton.Click;
  797. end;
  798.  
  799. procedure TRaDBEdit.Refresh(Resize: boolean);
  800. var AWidth, AHeight: Integer;
  801. begin
  802.   if FChanging then Exit;
  803.   AWidth := 0;
  804.   AHeight := 0;
  805.   FreeControl;
  806.   CreateControl;
  807.   with FControl do
  808.   begin
  809.      if (Self.Field <> nil) then
  810.      begin
  811.         case FieldType of
  812.           efEdit, efDate:
  813.             Width := GetDefaultWidth(Font, Self.Field.DisplayWidth);
  814.           efLookUp:
  815.             Width := GetDefaultWidth(Font, Self.Field.DisplayWidth)+
  816.                                                 GetSystemMetrics(SM_CXVSCROLL);
  817.         end;
  818.         if not (FieldType in [efMemo, efImage]) then
  819.              Width := Width+4;
  820.         if FCaption = '' then
  821.            FLabel.Caption := Self.Field.DisplayLabel;
  822.         Self.MaxLength := Self.Field.DisplayWidth;
  823.      end
  824.       else
  825.         if (Self.DataField <> '') then
  826.           if (FCaption <> '') then
  827.              FLabel.Caption := FCaption
  828.               else
  829.                FLabel.Caption := Self.DataField;
  830.      if FDistanceX = 0 then
  831.      begin
  832.         Top := FLabel.Height + FDistanceY;
  833.         AWidth := FLabel.Width;
  834.      end
  835.        else
  836.         begin
  837.            Left := FLabel.Width + FDistanceX;
  838.            AHeight := FLabel.Height;
  839.         end;
  840.  
  841.      FButton.Visible := (EditKind = ekControl) or
  842.                         ((FieldType in [efMemo, efImage]) and not ShowBlob);
  843.      FButton.Enabled := (EditKind = ekControl) or
  844.                         ((FieldType in [efMemo, efImage]) and not ShowBlob);
  845.      if FButton.Visible then
  846.      begin
  847.         FButton.Top := Top+2;
  848.         FButton.Height := GetSystemMetrics(SM_CXVSCROLL);
  849.         FButton.Width := FButton.Height;
  850.         FButton.Left := Left+Width+1
  851.      end
  852.       else
  853.         begin
  854.            FButton.Left := Left+Width;
  855.            FButton.Width := 0;
  856.         end;
  857.      if FButton.Left+FButton.Width > AWidth then
  858.      begin
  859.         AWidth := FButton.Left+FButton.Width;
  860.      end;
  861.      if Top + Height > AHeight then
  862.         AHeight := Top+Height;
  863.   end;
  864.   FField := Field;
  865.   ReSize := Resize and not (csLoading in ComponentState);
  866.   if ReSize then
  867.      SetBounds(Left, Top, AWidth, AHeight)
  868.     else SetBounds(Left, Top, Width, Height);
  869. end;
  870.  
  871. procedure TRaDBEdit.FreeControl;
  872. begin
  873.    if (FControl <> nil) and not (csDestroying in FControl.ComponentState) then
  874.    begin
  875.       FControl.Free;
  876.       FControl := nil;
  877.    end;
  878.    if FCaption <> '' then
  879.       FLabel.Caption := FCaption
  880.       else
  881.       FLabel.Caption := Self.Name;
  882. end;
  883.  
  884. function TRaDBEdit.GetDataSource: TDataSource;
  885. begin
  886.   Result := FDataLink.DataSource;
  887. end;
  888.  
  889. procedure TRaDBEdit.Notification(AComponent: TComponent;
  890.                                              Operation: TOperation);
  891. begin
  892.   inherited Notification(AComponent, Operation);
  893.   if (Operation = opRemove) and (FDataLink <> nil) and
  894.     (AComponent = FDataLink.DataSource) then
  895.       FDataLink.DataSource := nil;
  896. end;
  897.  
  898. procedure TRaDBEdit.SetParent(AParent: TWinControl);
  899. var ErrorMessage: String;
  900. begin
  901.    if (AParent <> nil) and
  902.       (AParent is TRaDBBox) and
  903.       (Owner <> AParent) and
  904.       ((AParent as TRaDBBox).CreateMode = cmAuto) then
  905.    begin
  906.      ErrorMessage :=
  907.        Format(SCantInsertComponent, [AParent.Name, Self.Name]);
  908.      Raise EInvalidOperation.Create(ErrorMessage);
  909.    end;
  910.    Inherited SetParent(AParent);
  911. end;
  912.  
  913. procedure TRaDBEdit.SetDataSource(Value: TDataSource);
  914. begin
  915.   FDataLink.DataSource := Value;
  916.   if Value <> nil then Value.FreeNotification(Self);
  917. end;
  918.  
  919. function TRaDBEdit.GetDataField: string;
  920. begin
  921.    Result := FDataLink.FieldName;
  922. end;
  923.  
  924. procedure TRaDBEdit.SetDataField(const Value: string);
  925. var i: Integer;
  926.     AnEditKind: TEditKind;
  927. begin
  928.   if Value <> FDataLink.FieldName then
  929.   begin
  930.      FDataLink.FieldName := Value;
  931.      if (Field <> nil) and
  932.         (Field.ReadOnly or (Field.FieldKind in [fkCalculated, fkInternalCalc])) then
  933.         FEditKind := ekView
  934.        else
  935.      if FieldType = efDate then
  936.         FEditKind := ekControl
  937.        else
  938.      if FieldType = efDataSet then
  939.         FEditKind := ekControl
  940.        else
  941.      if IsLookUpField(Field) then
  942.      begin
  943.         FEditKind := ekControl;
  944.         if (DataSource <> nil) and
  945.            (DataSource.DataSet <> nil) and
  946.            (FDataLink.Field <> nil) then
  947.            for i := 0 to DataSource.DataSet.FieldCount-1 do
  948.              with DataSource.DataSet.Fields[i] do
  949.              begin
  950.                 if UpperCase(FDataLink.Field.KeyFields) = UpperCase(FieldName) then
  951.                 begin
  952.                    if (DataSource.DataSet.Fields[i].Visible) and
  953.                       (DataSource.DataSet.Fields[i] <> Self.Field) then
  954.                    begin
  955.                      FEditKind := ekCommon;
  956.                      TabStop := False;
  957.                    end;
  958.                    if DataSource.DataSet.Fields[i].ReadOnly or
  959.                       (DataSource.DataSet.Fields[i].FieldKind in
  960.                                            [fkCalculated, fkInternalCalc])then
  961.                      FEditKind := ekView;
  962.                    break;
  963.                 end;
  964.              end;
  965.      end
  966.        else
  967.        begin
  968.           AnEditKind := ekCommon;
  969.           if (DataSource <> nil) and (DataSource.DataSet <> nil) then
  970.              for i := 0 to DataSource.DataSet.FieldCount-1 do
  971.              with DataSource.DataSet.Fields[i] do
  972.                if UpperCase(KeyFields) = UpperCase(FDataLink.FieldName) then
  973.                begin
  974.                   AnEditKind := ekControl;
  975.                   break;
  976.                end;
  977.           FEditKind := AnEditKind;
  978.        end;
  979.        if FEditKind = ekView then
  980.        begin
  981.           FLabel.ParentFont := False;
  982.           Font.Style := [fsBold];
  983.           Font.Color := clNavy;
  984.        end
  985.          else
  986.          begin
  987.             ParentFont := True;
  988.             FLabel.ParentFont := True;
  989.          end;
  990.        Refresh(True);
  991.   end;
  992. end;
  993.  
  994. function TRaDBEdit.GetOnButtonClick: TNotifyEvent;
  995. begin
  996.    Result := FOnButtonClick;
  997. end;
  998.  
  999. procedure TRaDBEdit.SetOnButtonClick(Value: TNotifyEvent);
  1000. begin
  1001.    FOnButtonClick := Value;
  1002. end;
  1003.  
  1004. function TRaDBEdit.GetField: TField;
  1005. begin
  1006.   Result := FDataLink.Field;
  1007.   if Result = nil then
  1008.     if (FDataLink.DataSet <> nil) then
  1009.        Result := FDataLink.DataSet.FindField(FDataLink.FieldName);
  1010. end;
  1011.  
  1012. function TRaDBEdit.GetMaxLength: Integer;
  1013. begin
  1014.    case FieldType of
  1015.      efEdit: Result := (FControl as TxDBEdit).MaxLength;
  1016.     else
  1017.      Result := 0;
  1018.    end;
  1019. end;
  1020.  
  1021. procedure TRaDBEdit.SetMaxLength(Value: Integer);
  1022. begin
  1023.    if Value <> MaxLength then
  1024.    case FieldType of
  1025.      efEdit: (FControl as TxDBEdit).MaxLength := Value;
  1026.    end;
  1027. end;
  1028.  
  1029. function TRaDBEdit.GetReadOnly: Boolean;
  1030. begin
  1031.    Result := not TabStop;
  1032. end;
  1033.  
  1034. procedure TRaDBEdit.SetTabStop(Value: Boolean);
  1035. begin
  1036.    FTabStop := Value;
  1037.    FControl.TabStop := Value;
  1038.    if FControl is TxDBLookUpComboBox then
  1039.      (FControl as TxDBLookUpComboBox).ReadOnly := not Value
  1040.     else
  1041.    if FControl is TDBDateEdit then
  1042.      (FControl as TDBDateEdit).ReadOnly := not Value
  1043.     else
  1044.    if FControl is TDBSmartImage then
  1045.      (FControl as TDBSmartImage).ReadOnly := not Value
  1046.     else
  1047.    if FControl is TDBRichEdit then
  1048.      (FControl as TDBRichEdit).ReadOnly := not Value
  1049.     else
  1050.    if FControl is TxDBEdit then
  1051.      (FControl as TxDBEdit).ReadOnly := True;
  1052. end;
  1053.  
  1054. procedure TRaDBEdit.SetBounds(ALeft, ATop, AWidth, AHeight: Integer);
  1055. begin
  1056.    Inherited SetBounds(ALeft, ATop, AWidth, AHeight);
  1057.    if (FControl <> nil) then
  1058.    begin
  1059.       FButton.Left := Width - FButton.Width;
  1060.       if FControl.Visible then
  1061.       begin
  1062.          if FButton.Width <> 0 then
  1063.            FControl.Width := FButton.Left - 1 - FControl.Left
  1064.           else
  1065.            FControl.Width := Width - FControl.Left;
  1066.       end;
  1067.       FControl.Height := Height - FControl.Top;
  1068.       Inherited SetBounds(Left, Top, Width, FControl.Top+FControl.Height);
  1069.    end;
  1070. end;
  1071.  
  1072. procedure TRaDBEdit.SetEditKind(Value: TEditKind);
  1073. begin
  1074.    FEditKind := Value;
  1075.    Refresh(True);
  1076. end;
  1077.  
  1078. procedure TRaDBEdit.SetDistanceX(Value: Integer);
  1079. begin
  1080.    if Value < 0 then
  1081.         Raise Exception.Create(SInvalidValue)
  1082.        else
  1083.        if Value <> FDistanceX then
  1084.        begin
  1085.           FDistanceX := Value;
  1086.           if FDistanceX = 0 then FDistanceY := 1
  1087.                             else FDistanceY := 0;
  1088.           Refresh(True);
  1089.        end;
  1090. end;
  1091.  
  1092. procedure TRaDBEdit.SetDistanceY(Value: Integer);
  1093. begin
  1094.    if not (Value in [0..100]) then
  1095.         Raise Exception.Create(SInvalidRange)
  1096.        else
  1097.        if Value <> FDistanceY then
  1098.        begin
  1099.           FDistanceY := Value;
  1100.           if FDistanceY = 0 then FDistanceX := 1
  1101.                             else FDistanceX := 0;
  1102.           Refresh(True);
  1103.        end;
  1104. end;
  1105.  
  1106. procedure TRaDBEdit.SetName(const NewName: TComponentName);
  1107. begin
  1108.    Inherited SetName(NewName);
  1109.    if not (csLoading in ComponentState) then
  1110.       Refresh(True);
  1111. end;
  1112.  
  1113. function TRaDBEdit.GetCaption: String;
  1114. begin
  1115.    Result := FLabel.Caption
  1116. end;
  1117.  
  1118. procedure TRaDBEdit.SetCaption(Value: String);
  1119. begin
  1120.    if Value <> FLabel.Caption then
  1121.    begin
  1122.       FCaption := Value;
  1123.       Refresh(True);
  1124.    end;
  1125. end;
  1126.  
  1127. function TRaDBEdit.GetLabelFont: TFont;
  1128. begin
  1129.    Result := FLabel.Font;
  1130. end;
  1131.  
  1132. procedure TRaDBEdit.SetLabelFont(AFont: TFont);
  1133. begin
  1134.    if (AFont <> nil) then
  1135.    begin
  1136.       FLabel.Font.Assign(AFont);
  1137.       Refresh(True);
  1138.    end;
  1139. end;
  1140.  
  1141. function TRaDBEdit.GetLabelParentFont: Boolean;
  1142. begin
  1143.    Result := FLabel.ParentFont;
  1144. end;
  1145.  
  1146. procedure TRaDBEdit.SetLabelParentFont(Value: Boolean);
  1147. begin
  1148.    FLabel.ParentFont := Value;
  1149. end;
  1150.  
  1151. procedure TRaDBEdit.SetShowBlob(Value: Boolean);
  1152. begin
  1153.    if Value <> FShowBlob then
  1154.    begin
  1155.       FShowBlob := Value;
  1156.       Refresh(True);
  1157.    end;
  1158. end;
  1159.  
  1160. procedure TRaDBEdit.SetOnReplaceField(const Value: TFieldNotifyEvent);
  1161. begin
  1162.   FOnReplaceField := Value;
  1163. end;
  1164.  
  1165. procedure TRaDBEdit.DoOnClick(Sender: TObject);
  1166. begin
  1167.   if Assigned(OnClick) then
  1168.      OnClick(Self);
  1169. end;
  1170.  
  1171. procedure TRaDBEdit.DoOnDblClick(Sender: TObject);
  1172. begin
  1173.   if Assigned(OnDblClick) then
  1174.     OnDblClick(Self);
  1175. end;
  1176.  
  1177. procedure TRaDBEdit.DoOnDragDrop(Sender, Source: TObject; X, Y: Integer);
  1178. begin
  1179.   if Assigned(OnDragDrop) then
  1180.   begin
  1181.      if (Sender is TControl) and ((Sender as TControl).Parent = Self) then
  1182.      begin
  1183.         X := X + (Sender as TControl).Left;
  1184.         Y := Y + (Sender as TControl).Top;
  1185.      end;
  1186.      OnDragDrop(Self, Source, X, Y);
  1187.   end;
  1188. end;
  1189.  
  1190. procedure TRaDBEdit.DoOnDragOver(Sender, Source: TObject; X, Y: Integer;
  1191.   State: TDragState; var Accept: Boolean);
  1192. begin
  1193.   if Assigned(OnDragOver) then
  1194.   begin
  1195.      if (Sender is TControl) and ((Sender as TControl).Parent = Self) then
  1196.      begin
  1197.         X := X + (Sender as TControl).Left;
  1198.         Y := Y + (Sender as TControl).Top;
  1199.      end;
  1200.      OnDragOver(Self, Source, X, Y, State, Accept);
  1201.   end;
  1202. end;
  1203.  
  1204. procedure TRaDBEdit.DoOnEndDrag(Sender, Target: TObject; X, Y: Integer);
  1205. begin
  1206.   if Assigned(OnEndDrag) then
  1207.     OnEndDrag(Self, Target, X, Y);
  1208. end;
  1209.  
  1210. procedure TRaDBEdit.DoOnEnter(Sender: TObject);
  1211. begin
  1212.   if Assigned(OnEnter) then
  1213.     OnEnter(Self);
  1214. end;
  1215.  
  1216. procedure TRaDBEdit.DoOnExit(Sender: TObject);
  1217. begin
  1218.   if Assigned(OnExit) then
  1219.     OnExit(Self);
  1220. end;
  1221.  
  1222. procedure TRaDBEdit.DoOnMouseDown(Sender: TObject; Button: TMouseButton;
  1223.   Shift: TShiftState; X, Y: Integer);
  1224. begin
  1225.   if Assigned(OnMouseDown) then
  1226.   begin
  1227.      if (Sender is TControl) and ((Sender as TControl).Parent = Self) then
  1228.      begin
  1229.         X := X + (Sender as TControl).Left;
  1230.         Y := Y + (Sender as TControl).Top;
  1231.      end;
  1232.      OnMouseDown(Self, Button, Shift, X, Y);
  1233.   end;
  1234. end;
  1235.  
  1236. procedure TRaDBEdit.DoOnMouseMove(Sender: TObject; Shift: TShiftState; X,
  1237.   Y: Integer);
  1238. begin
  1239.   if Assigned(OnMouseMove) then
  1240.   begin
  1241.      if (Sender is TControl) and ((Sender as TControl).Parent = Self) then
  1242.      begin
  1243.         X := X + (Sender as TControl).Left;
  1244.         Y := Y + (Sender as TControl).Top;
  1245.      end;
  1246.      OnMouseMove(Self, Shift, X, Y);
  1247.   end;
  1248. end;
  1249.  
  1250. procedure TRaDBEdit.DoOnMouseUp(Sender: TObject; Button: TMouseButton;
  1251.   Shift: TShiftState; X, Y: Integer);
  1252. begin
  1253.   if Assigned(OnMouseUp) then
  1254.   begin
  1255.      if (Sender is TControl) and ((Sender as TControl).Parent = Self) then
  1256.      begin
  1257.         X := X + (Sender as TControl).Left;
  1258.         Y := Y + (Sender as TControl).Top;
  1259.      end;
  1260.      OnMouseUp(Self, Button, Shift, X, Y);
  1261.   end;
  1262. end;
  1263.  
  1264. procedure TRaDBEdit.DoOnStartDrag(Sender: TObject;
  1265.   var DragObject: TDragObject);
  1266. begin
  1267.    if Assigned(OnStartDrag) then
  1268.      OnStartDrag(Self, DragObject);
  1269. end;
  1270.  
  1271. end.
  1272.