Changeset 168 for trunk


Ignore:
Timestamp:
Jun 15, 2019, 12:53:13 AM (5 years ago)
Author:
chronos
Message:
  • Fixed: Allow to move dialog windows under Linux Gtk2.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Packages/CevoComponents/DrawDlg.pas

    r159 r168  
    1616    constructor Create(AOwner: TComponent); override;
    1717    procedure SmartInvalidate; virtual;
     18  private
     19    MoveFormPos: TPoint;
     20    MoveMousePos: TPoint;
     21    MoveActive: Boolean;
    1822  protected
    19     TitleHeight: integer;
     23    TitleHeight: Integer;
    2024    // defines area to grip the window for moving (from top)
    2125    procedure InitButtons;
    2226    procedure OnEraseBkgnd(var m: TMessage); message WM_ERASEBKGND;
    2327    procedure OnHitTest(var Msg: TMessage); message WM_NCHITTEST;
     28    procedure MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
     29      override;
     30    procedure MouseMove(Shift: TShiftState; X, Y: Integer); override;
     31    procedure MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
     32    procedure MouseLeave; override;
    2433  end;
    2534
     
    98107end;
    99108
     109procedure TDrawDlg.MouseDown(Button: TMouseButton; Shift: TShiftState; X,
     110  Y: Integer);
     111var
     112  MousePosNew: TPoint;
     113begin
     114  inherited;
     115  {$IFDEF LINUX}
     116  // HitTest is not supported under Linux GTK2 so use form inside move mechanizm
     117  MoveMousePos := ClientToScreen(Point(X, Y));
     118  MoveFormPos := Point(Left, Top);
     119  MousePosNew := Mouse.CursorPos;
     120  // Activate move only if mouse position was not changed during inherited call
     121  if (MousePosNew.X = MoveMousePos.X) and (MousePosNew.Y = MoveMousePos.Y) then begin
     122    MoveActive := True;
     123  end;
     124  {$ENDIF}
     125end;
     126
     127procedure TDrawDlg.MouseMove(Shift: TShiftState; X, Y: Integer);
     128var
     129  MousePos: TPoint;
     130begin
     131  inherited;
     132  if MoveActive then begin
     133    MousePos := ClientToScreen(Point(X, Y));
     134    SetBounds(MoveFormPos.X + MousePos.X - MoveMousePos.X,
     135      MoveFormPos.Y + MousePos.Y - MoveMousePos.Y,
     136      Width, Height);
     137  end;
     138end;
     139
     140procedure TDrawDlg.MouseUp(Button: TMouseButton; Shift: TShiftState; X,
     141  Y: Integer);
     142begin
     143  MoveActive := False;
     144  inherited;
     145end;
     146
     147procedure TDrawDlg.MouseLeave;
     148begin
     149  MoveActive := False;
     150  inherited;
     151end;
     152
    100153procedure TDrawDlg.InitButtons;
    101154var
Note: See TracChangeset for help on using the changeset viewer.