mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-12-03 09:57:41 +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;
|
DropCtl: TControl); virtual; abstract;
|
||||||
procedure LoadFromStream(Stream: TStream); virtual; abstract;
|
procedure LoadFromStream(Stream: TStream); virtual; abstract;
|
||||||
procedure PaintSite(DC: HDC); virtual; abstract;
|
procedure PaintSite(DC: HDC); virtual; abstract;
|
||||||
|
procedure MouseMessage(var Msg: TLMMouse); virtual; abstract;
|
||||||
procedure PositionDockRect(Client, DropCtl: TControl; DropAlign: TAlign;
|
procedure PositionDockRect(Client, DropCtl: TControl; DropAlign: TAlign;
|
||||||
var DockRect: TRect); virtual; abstract;
|
var DockRect: TRect); virtual; abstract;
|
||||||
procedure RemoveControl(Control: TControl); virtual; abstract;
|
procedure RemoveControl(Control: TControl); virtual; abstract;
|
||||||
|
|||||||
@ -278,6 +278,9 @@ begin
|
|||||||
FDockObject := TDragDockObject.Create(AControl);
|
FDockObject := TDragDockObject.Create(AControl);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
// we should handle somehow difference between
|
||||||
|
// Control.BoundsRect.LeftTop and CursorPos
|
||||||
|
|
||||||
GetCursorPos(p);
|
GetCursorPos(p);
|
||||||
FDockObject.DragPos := p;
|
FDockObject.DragPos := p;
|
||||||
AControl.CalculateDockSizes;
|
AControl.CalculateDockSizes;
|
||||||
|
|||||||
@ -4686,7 +4686,12 @@ begin
|
|||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
//if Message.Msg=LM_RBUTTONUP then begin DebugLn(['TWinControl.WndProc ',DbgSName(Self)]); DumpStack end;
|
//if Message.Msg=LM_RBUTTONUP then begin DebugLn(['TWinControl.WndProc ',DbgSName(Self)]); DumpStack end;
|
||||||
if IsControlMouseMSG(TLMMouse(Message)) then
|
if IsControlMouseMSG(TLMMouse(Message)) then
|
||||||
Exit;
|
Exit
|
||||||
|
else
|
||||||
|
begin
|
||||||
|
if FDockSite and FUseDockManager and Assigned(FDockManager) then
|
||||||
|
FDockManager.MouseMessage(TLMMouse(Message));
|
||||||
|
end;
|
||||||
{$IFDEF VerboseMouseBugfix}
|
{$IFDEF VerboseMouseBugfix}
|
||||||
DebugLn('TWinControl.WndPRoc B ',Name,':',ClassName);
|
DebugLn('TWinControl.WndPRoc B ',Name,':',ClassName);
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
|||||||
@ -31,7 +31,8 @@ interface
|
|||||||
|
|
||||||
uses
|
uses
|
||||||
Math, Types, Classes, SysUtils, LCLProc, LCLType, LCLStrConsts,
|
Math, Types, Classes, SysUtils, LCLProc, LCLType, LCLStrConsts,
|
||||||
Graphics, Controls, ExtCtrls, Forms, Menus, Themes, LCLIntf;
|
Graphics, Controls, ExtCtrls, Forms, Menus, Themes, LCLIntf,
|
||||||
|
LMessages;
|
||||||
|
|
||||||
type
|
type
|
||||||
TLazDockPages = class;
|
TLazDockPages = class;
|
||||||
@ -84,6 +85,7 @@ type
|
|||||||
function GetAnchorControl(Zone: TLazDockZone; Side: TAnchorKind;
|
function GetAnchorControl(Zone: TLazDockZone; Side: TAnchorKind;
|
||||||
OutSide: boolean): TControl;
|
OutSide: boolean): TControl;
|
||||||
procedure PaintSite(DC: HDC); override;
|
procedure PaintSite(DC: HDC); override;
|
||||||
|
procedure MouseMessage(var Msg: TLMMouse); override;
|
||||||
public
|
public
|
||||||
property AutoFreeDockSite: boolean read FAutoFreeDockSite write FAutoFreeDockSite;
|
property AutoFreeDockSite: boolean read FAutoFreeDockSite write FAutoFreeDockSite;
|
||||||
end;
|
end;
|
||||||
@ -282,6 +284,7 @@ type
|
|||||||
// maybe once it will be control, so now better to move all related to header things to class
|
// maybe once it will be control, so now better to move all related to header things to class
|
||||||
TDockHeader = class
|
TDockHeader = class
|
||||||
class function GetRectOfPart(AHeaderRect: TRect; AOrientation: TDockOrientation; APart: TLazDockHeaderPart): TRect;
|
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);
|
class procedure Draw(ACanvas: TCanvas; ACaption: String; AOrientation: TDockOrientation; const ARect: TRect);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -332,6 +335,21 @@ begin
|
|||||||
end;
|
end;
|
||||||
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);
|
class procedure TDockHeader.Draw(ACanvas: TCanvas; ACaption: String; AOrientation: TDockOrientation; const ARect: TRect);
|
||||||
var
|
var
|
||||||
Details: TThemedElementDetails;
|
Details: TThemedElementDetails;
|
||||||
@ -1322,6 +1340,61 @@ begin
|
|||||||
end;
|
end;
|
||||||
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 }
|
{ TLazDockZone }
|
||||||
|
|
||||||
destructor TLazDockZone.Destroy;
|
destructor TLazDockZone.Destroy;
|
||||||
@ -2679,9 +2752,8 @@ function TLazDockForm.FindHeader(x, y: integer; out Part: TLazDockHeaderPart): T
|
|||||||
var
|
var
|
||||||
i: Integer;
|
i: Integer;
|
||||||
Control: TControl;
|
Control: TControl;
|
||||||
TitleRect, SubRect: TRect;
|
TitleRect: TRect;
|
||||||
p: TPoint;
|
p: TPoint;
|
||||||
CurPart: TLazDockHeaderPart;
|
|
||||||
Orientation: TDockOrientation;
|
Orientation: TDockOrientation;
|
||||||
begin
|
begin
|
||||||
for i := 0 to ControlCount-1 do
|
for i := 0 to ControlCount-1 do
|
||||||
@ -2697,18 +2769,7 @@ begin
|
|||||||
// => check sub parts
|
// => check sub parts
|
||||||
Result := Control;
|
Result := Control;
|
||||||
Orientation := GetTitleOrientation(Control);
|
Orientation := GetTitleOrientation(Control);
|
||||||
for CurPart := low(TLazDockHeaderPart) to high(TLazDockHeaderPart) do
|
Part := TDockHeader.FindPart(TitleRect, p, Orientation);
|
||||||
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;
|
|
||||||
Exit;
|
Exit;
|
||||||
end;
|
end;
|
||||||
Result := nil;
|
Result := nil;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user