Closer to moving controls correctly.

Shane

git-svn-id: trunk@103 -
This commit is contained in:
lazarus 2001-01-08 02:06:34 +00:00
parent 7a0acebcb0
commit 75573811af
2 changed files with 27 additions and 5 deletions

View File

@ -77,13 +77,13 @@ type
procedure ControlMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); procedure ControlMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
procedure DoChange; procedure DoChange;
procedure SetGrabbers; procedure SetGrabbers;
procedure MoveContent(dx, dy: Integer);
procedure SizeContent; procedure SizeContent;
procedure SetVisible(const Value: Boolean); procedure SetVisible(const Value: Boolean);
procedure GrabberMove(Sender: TObject; dx, dy: Integer); procedure GrabberMove(Sender: TObject; dx, dy: Integer);
procedure GrabberMoved(Sender: TObject; dx, dy: Integer); procedure GrabberMoved(Sender: TObject; dx, dy: Integer);
protected protected
public public
procedure MoveContent(dx, dy: Integer);
procedure Add(AControl: TControl); procedure Add(AControl: TControl);
procedure Clear; procedure Clear;
constructor Create(AOwner: TWinControl); virtual; constructor Create(AOwner: TWinControl); virtual;
@ -127,6 +127,9 @@ var
procedure SetCaptureGrabber(AGrabber:TGrabber); procedure SetCaptureGrabber(AGrabber:TGrabber);
begin begin
Writeln('SETCAPTUREGRABBER to....');
if AGrabber <> nil then Writeln('something') else writeln('nil');
CaptureGrabber:=AGrabber; CaptureGrabber:=AGrabber;
end; end;
@ -254,10 +257,11 @@ end;
procedure TControlSelection.MoveSelection(dx, dy: integer); procedure TControlSelection.MoveSelection(dx, dy: integer);
begin begin
Writeln('Move Selection');
if (dx<>0) or (dy<>0) then begin if (dx<>0) or (dy<>0) then begin
Inc(FLeft,dx); Inc(FLeft,dx);
Inc(FTop,dy); Inc(FTop,dy);
MoveContent(dx,dy); //MoveContent(dx,dy);
SetGrabbers; SetGrabbers;
end; end;
end; end;
@ -372,12 +376,15 @@ end;
procedure TControlSelection.ControlMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer); procedure TControlSelection.ControlMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
begin begin
Writeln('ControlMOuseMove in TCOntrolSelection');
if FDragging if FDragging
then begin then begin
Inc(FLeft, X - FStart.X); Inc(FLeft, X - FStart.X);
Inc(FTop, Y - FStart.Y); Inc(FTop, Y - FStart.Y);
SetGrabbers; SetGrabbers;
MoveContent(X - FStart.X, Y - FStart.Y); Writeln(format('X-FStart.x = %d-%d=%d',[X,FStart.x,X-FStart.x]));
Writeln(format('Y-FStart.Y = %d-%d=%d',[Y,FStart.y,Y-FStart.y]));
// MoveContent(X - FStart.x, Y - FStart.Y);
end; end;
end; end;
@ -386,6 +393,8 @@ begin
if (Button = mbLeft) and FDragging if (Button = mbLeft) and FDragging
then begin then begin
FDragging := False; FDragging := False;
Writeln(format('X-FStart.x = %d-%d=%d',[X,FStart.x,X-FStart.x]));
Writeln(format('Y-FStart.Y = %d-%d=%d',[Y,FStart.y,Y-FStart.y]));
MoveContent(X - FStart.X, Y - FStart.Y); MoveContent(X - FStart.X, Y - FStart.Y);
end; end;
end; end;

View File

@ -231,6 +231,8 @@ Begin
inc(MouseDownPos.X,TControl(Sender).Left); inc(MouseDownPos.X,TControl(Sender).Left);
inc(MouseDownPos.Y,TControl(Sender).Top); inc(MouseDownPos.Y,TControl(Sender).Top);
end; end;
Writeln('Setting mousedowncontrol to'+TCOntrol(sender).name);
MouseDownControl:=Sender; MouseDownControl:=Sender;
LastMouseMovePos:=MouseDownPos; LastMouseMovePos:=MouseDownPos;
Writeln(TComponent(Sender).Name+'.OnMouseDown at '+inttostr(MouseDownPos.x) Writeln(TComponent(Sender).Name+'.OnMouseDown at '+inttostr(MouseDownPos.x)
@ -258,6 +260,7 @@ var
CaptureGrabber:TGrabber; CaptureGrabber:TGrabber;
Button : TMouseButton; Button : TMouseButton;
Shift : TShiftState; Shift : TShiftState;
X,Y : Integer;
Begin Begin
Writeln('In UpOnControl'); Writeln('In UpOnControl');
if (TLMMouse(Message).keys and MK_LButton) = MK_LButton then if (TLMMouse(Message).keys and MK_LButton) = MK_LButton then
@ -274,12 +277,22 @@ Begin
shift := shift +[ssCTRL]; shift := shift +[ssCTRL];
X := TLMMOuse(Message).pos.X;
Y := TLMMOuse(Message).pos.Y;
CaptureGrabber:=GetCaptureGrabber; CaptureGrabber:=GetCaptureGrabber;
if CaptureGrabber<>nil then begin if CaptureGrabber<>nil then begin
Writeln('CaptureGrabber <> nil');
CaptureGrabber.CaptureMouseUp(TControl(Sender),Button,Shift,TLMMouse(Message).pos.X,TLMMouse(Message).pos.Y); CaptureGrabber.CaptureMouseUp(TControl(Sender),Button,Shift,TLMMouse(Message).pos.X,TLMMouse(Message).pos.Y);
exit; exit;
end; end;
if MOuseDownControl = Sender then
Begin
ControlSelection.MoveSelection(X-LastMouseMovePos.X, Y-LastMouseMovePos.Y);
//do somerthing like ControlSelection.Sizecontent but move x and y from where
// the grabber started to where it finished.
end;
MouseUpPos.X := TLMMouse(Message).pos.X; MouseUpPos.X := TLMMouse(Message).pos.X;
MouseUpPos.Y := TLMMouse(Message).pos.Y; MouseUpPos.Y := TLMMouse(Message).pos.Y;
if not (Sender is TCustomForm) then begin if not (Sender is TCustomForm) then begin
@ -410,10 +423,10 @@ if Message.msg = LM_MOUSEMOVE then
MouseMoveonCOntrol(Sender, Message); MouseMoveonCOntrol(Sender, Message);
if Result then Writeln('It IS a design message') {if Result then Writeln('It IS a design message')
else else
Writeln('It IS NOT a design message'); Writeln('It IS NOT a design message');
}
end; end;
procedure TDesigner.LoadFile(FileName: string); procedure TDesigner.LoadFile(FileName: string);