mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-12-02 23:37:18 +01:00
docking:
- refactor dock header part searching - start handle mouse messages for dock header git-svn-id: trunk@14034 -
This commit is contained in:
parent
a29108f322
commit
15151ee192
@ -457,6 +457,7 @@ type
|
||||
DropCtl: TControl); virtual; abstract;
|
||||
procedure LoadFromStream(Stream: TStream); virtual; abstract;
|
||||
procedure PaintSite(DC: HDC); virtual; abstract;
|
||||
procedure MouseMessage(var Msg: TLMMouse); virtual; abstract;
|
||||
procedure PositionDockRect(Client, DropCtl: TControl; DropAlign: TAlign;
|
||||
var DockRect: TRect); virtual; abstract;
|
||||
procedure RemoveControl(Control: TControl); virtual; abstract;
|
||||
|
||||
@ -278,6 +278,9 @@ begin
|
||||
FDockObject := TDragDockObject.Create(AControl);
|
||||
end;
|
||||
|
||||
// we should handle somehow difference between
|
||||
// Control.BoundsRect.LeftTop and CursorPos
|
||||
|
||||
GetCursorPos(p);
|
||||
FDockObject.DragPos := p;
|
||||
AControl.CalculateDockSizes;
|
||||
|
||||
@ -4686,7 +4686,12 @@ begin
|
||||
{$ENDIF}
|
||||
//if Message.Msg=LM_RBUTTONUP then begin DebugLn(['TWinControl.WndProc ',DbgSName(Self)]); DumpStack end;
|
||||
if IsControlMouseMSG(TLMMouse(Message)) then
|
||||
Exit;
|
||||
Exit
|
||||
else
|
||||
begin
|
||||
if FDockSite and FUseDockManager and Assigned(FDockManager) then
|
||||
FDockManager.MouseMessage(TLMMouse(Message));
|
||||
end;
|
||||
{$IFDEF VerboseMouseBugfix}
|
||||
DebugLn('TWinControl.WndPRoc B ',Name,':',ClassName);
|
||||
{$ENDIF}
|
||||
|
||||
@ -31,7 +31,8 @@ interface
|
||||
|
||||
uses
|
||||
Math, Types, Classes, SysUtils, LCLProc, LCLType, LCLStrConsts,
|
||||
Graphics, Controls, ExtCtrls, Forms, Menus, Themes, LCLIntf;
|
||||
Graphics, Controls, ExtCtrls, Forms, Menus, Themes, LCLIntf,
|
||||
LMessages;
|
||||
|
||||
type
|
||||
TLazDockPages = class;
|
||||
@ -84,6 +85,7 @@ type
|
||||
function GetAnchorControl(Zone: TLazDockZone; Side: TAnchorKind;
|
||||
OutSide: boolean): TControl;
|
||||
procedure PaintSite(DC: HDC); override;
|
||||
procedure MouseMessage(var Msg: TLMMouse); override;
|
||||
public
|
||||
property AutoFreeDockSite: boolean read FAutoFreeDockSite write FAutoFreeDockSite;
|
||||
end;
|
||||
@ -282,6 +284,7 @@ type
|
||||
// maybe once it will be control, so now better to move all related to header things to class
|
||||
TDockHeader = class
|
||||
class function GetRectOfPart(AHeaderRect: TRect; AOrientation: TDockOrientation; APart: TLazDockHeaderPart): TRect;
|
||||
class function FindPart(AHeaderRect: TRect; APoint: TPoint; AOrientation: TDockOrientation): TLazDockHeaderPart;
|
||||
class procedure Draw(ACanvas: TCanvas; ACaption: String; AOrientation: TDockOrientation; const ARect: TRect);
|
||||
end;
|
||||
|
||||
@ -332,6 +335,21 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
class function TDockHeader.FindPart(AHeaderRect: TRect; APoint: TPoint; AOrientation: TDockOrientation): TLazDockHeaderPart;
|
||||
var
|
||||
SubRect: TRect;
|
||||
begin
|
||||
for Result := Low(TLazDockHeaderPart) to High(TLazDockHeaderPart) do
|
||||
begin
|
||||
if Result = ldhpAll then
|
||||
Continue;
|
||||
SubRect := GetRectOfPart(AHeaderRect, AOrientation, Result);
|
||||
if PtInRect(SubRect, APoint) then
|
||||
Exit;
|
||||
end;
|
||||
Result := ldhpAll;
|
||||
end;
|
||||
|
||||
class procedure TDockHeader.Draw(ACanvas: TCanvas; ACaption: String; AOrientation: TDockOrientation; const ARect: TRect);
|
||||
var
|
||||
Details: TThemedElementDetails;
|
||||
@ -1322,6 +1340,61 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TLazDockTree.MouseMessage(var Msg: TLMMouse);
|
||||
var
|
||||
i: integer;
|
||||
ARect: TRect;
|
||||
Part: TLazDockHeaderPart;
|
||||
Pt: TPoint;
|
||||
begin
|
||||
Pt := SmallPointToPoint(Msg.Pos);
|
||||
for i := 0 to DockSite.ControlCount - 1 do
|
||||
begin
|
||||
if DockSite.Controls[i].HostDockSite = DockSite then
|
||||
begin
|
||||
ARect := DockSite.Controls[i].BoundsRect;
|
||||
case DockSite.Controls[i].DockOrientation of
|
||||
doHorizontal:
|
||||
begin
|
||||
ARect.Bottom := ARect.Top;
|
||||
Dec(ARect.Top, DefaultDockGrabberSize);
|
||||
end;
|
||||
doVertical:
|
||||
begin
|
||||
ARect.Right := ARect.Left;
|
||||
Dec(ARect.Left, DefaultDockGrabberSize);
|
||||
end;
|
||||
else
|
||||
Continue;
|
||||
end;
|
||||
if not PtInRect(ARect, Pt) then
|
||||
Continue;
|
||||
// we have control here
|
||||
Part := TDockHeader.FindPart(ARect, Pt, DockSite.Controls[i].DockOrientation);
|
||||
case Msg.Msg of
|
||||
LM_LBUTTONDOWN:
|
||||
begin
|
||||
// user left clicked on header
|
||||
if Part in [ldhpAll,ldhpCaption] then
|
||||
begin
|
||||
// mouse down on not buttons => start drag
|
||||
DockSite.Controls[i].BeginDrag(True);
|
||||
end else
|
||||
begin
|
||||
// mouse down on buttons => ToDo
|
||||
end;
|
||||
end;
|
||||
LM_MOUSEMOVE:
|
||||
begin
|
||||
// track mouse move to draw hot button state
|
||||
end;
|
||||
end;
|
||||
// stop thurther processing
|
||||
Exit;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
{ TLazDockZone }
|
||||
|
||||
destructor TLazDockZone.Destroy;
|
||||
@ -2679,9 +2752,8 @@ function TLazDockForm.FindHeader(x, y: integer; out Part: TLazDockHeaderPart): T
|
||||
var
|
||||
i: Integer;
|
||||
Control: TControl;
|
||||
TitleRect, SubRect: TRect;
|
||||
TitleRect: TRect;
|
||||
p: TPoint;
|
||||
CurPart: TLazDockHeaderPart;
|
||||
Orientation: TDockOrientation;
|
||||
begin
|
||||
for i := 0 to ControlCount-1 do
|
||||
@ -2697,18 +2769,7 @@ begin
|
||||
// => check sub parts
|
||||
Result := Control;
|
||||
Orientation := GetTitleOrientation(Control);
|
||||
for CurPart := low(TLazDockHeaderPart) to high(TLazDockHeaderPart) do
|
||||
begin
|
||||
if CurPart = ldhpAll then
|
||||
Continue;
|
||||
SubRect := TDockHeader.GetRectOfPart(TitleRect, Orientation, CurPart);
|
||||
if PtInRect(SubRect, p) then
|
||||
begin
|
||||
Part := CurPart;
|
||||
Exit;
|
||||
end;
|
||||
end;
|
||||
Part := ldhpAll;
|
||||
Part := TDockHeader.FindPart(TitleRect, p, Orientation);
|
||||
Exit;
|
||||
end;
|
||||
Result := nil;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user