mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-11-07 12:49:29 +01:00
lcl: treeview: High-DPI: DefaultItemHeight, Indent. Issue #31558
git-svn-id: trunk@54435 -
This commit is contained in:
parent
dea19ce82c
commit
25d25e78b3
@ -3315,7 +3315,6 @@ type
|
|||||||
function GetKeepCollapsedNodes: boolean;
|
function GetKeepCollapsedNodes: boolean;
|
||||||
function GetMultiSelect: Boolean;
|
function GetMultiSelect: Boolean;
|
||||||
function GetReadOnly: boolean;
|
function GetReadOnly: boolean;
|
||||||
function GetRealExpandSignSize: integer;
|
|
||||||
function GetRightClickSelect: boolean;
|
function GetRightClickSelect: boolean;
|
||||||
function GetRowSelect: boolean;
|
function GetRowSelect: boolean;
|
||||||
function GetSelection: TTreeNode;
|
function GetSelection: TTreeNode;
|
||||||
@ -3399,6 +3398,8 @@ type
|
|||||||
Stage: TCustomDrawStage): Boolean; virtual;
|
Stage: TCustomDrawStage): Boolean; virtual;
|
||||||
function CustomDrawItem(Node: TTreeNode; State: TCustomDrawState;
|
function CustomDrawItem(Node: TTreeNode; State: TCustomDrawState;
|
||||||
Stage: TCustomDrawStage; var PaintImages: Boolean): Boolean; virtual;
|
Stage: TCustomDrawStage; var PaintImages: Boolean): Boolean; virtual;
|
||||||
|
procedure DoAutoAdjustLayout(const AMode: TLayoutAdjustmentPolicy;
|
||||||
|
const AXProportion, AYProportion: Double); override;
|
||||||
function GetDragImages: TDragImageList; override;
|
function GetDragImages: TDragImageList; override;
|
||||||
function GetMaxLvl: integer;
|
function GetMaxLvl: integer;
|
||||||
function GetMaxScrollLeft: integer;
|
function GetMaxScrollLeft: integer;
|
||||||
@ -3429,6 +3430,8 @@ type
|
|||||||
procedure EndEditing(Cancel: boolean = false); virtual;
|
procedure EndEditing(Cancel: boolean = false); virtual;
|
||||||
procedure EnsureNodeIsVisible(ANode: TTreeNode);
|
procedure EnsureNodeIsVisible(ANode: TTreeNode);
|
||||||
procedure Expand(Node: TTreeNode); virtual;
|
procedure Expand(Node: TTreeNode); virtual;
|
||||||
|
function GetRealExpandSignSize: integer;
|
||||||
|
function GetRealIndent: Integer;
|
||||||
procedure GetImageIndex(Node: TTreeNode); virtual;
|
procedure GetImageIndex(Node: TTreeNode); virtual;
|
||||||
procedure GetSelectedIndex(Node: TTreeNode); virtual;
|
procedure GetSelectedIndex(Node: TTreeNode); virtual;
|
||||||
procedure InitializeWnd; override;
|
procedure InitializeWnd; override;
|
||||||
@ -3469,7 +3472,7 @@ type
|
|||||||
property HideSelection: Boolean
|
property HideSelection: Boolean
|
||||||
read GetHideSelection write SetHideSelection default True;
|
read GetHideSelection write SetHideSelection default True;
|
||||||
property HotTrack: Boolean read GetHotTrack write SetHotTrack default False;
|
property HotTrack: Boolean read GetHotTrack write SetHotTrack default False;
|
||||||
property Indent: Integer read FIndent write SetIndent default 15;
|
property Indent: Integer read FIndent write SetIndent default 0;
|
||||||
property MultiSelect: Boolean read GetMultiSelect write SetMultiSelect default False;
|
property MultiSelect: Boolean read GetMultiSelect write SetMultiSelect default False;
|
||||||
property OnAddition: TTVExpandedEvent read FOnAddition write FOnAddition;
|
property OnAddition: TTVExpandedEvent read FOnAddition write FOnAddition;
|
||||||
property OnAdvancedCustomDraw: TTVAdvancedCustomDrawEvent
|
property OnAdvancedCustomDraw: TTVAdvancedCustomDrawEvent
|
||||||
|
|||||||
@ -1672,15 +1672,17 @@ function TTreeNode.DisplayExpandSignLeft: integer;
|
|||||||
var
|
var
|
||||||
TV: TCustomTreeView;
|
TV: TCustomTreeView;
|
||||||
l: LongInt;
|
l: LongInt;
|
||||||
|
RealIndent: Integer;
|
||||||
begin
|
begin
|
||||||
Result := 0;
|
Result := 0;
|
||||||
TV := TreeView;
|
TV := TreeView;
|
||||||
|
RealIndent := TV.GetRealIndent;
|
||||||
if TV = nil then Exit;
|
if TV = nil then Exit;
|
||||||
l := Level;
|
l := Level;
|
||||||
if not (tvoShowRoot in TV.Options) then
|
if not (tvoShowRoot in TV.Options) then
|
||||||
inc(Result, TV.Indent * (l - 1) + (TV.Indent shr 2) + TV.BorderWidth - TV.FScrolledLeft)
|
inc(Result, RealIndent * (l - 1) + (RealIndent shr 2) + TV.BorderWidth - TV.FScrolledLeft)
|
||||||
else
|
else
|
||||||
inc(Result, TV.Indent * l + TV.BorderWidth - TV.FScrolledLeft);
|
inc(Result, RealIndent * l + TV.BorderWidth - TV.FScrolledLeft);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TTreeNode.DisplayExpandSignRect: TRect;
|
function TTreeNode.DisplayExpandSignRect: TRect;
|
||||||
@ -1690,7 +1692,7 @@ begin
|
|||||||
begin
|
begin
|
||||||
Result.Left := DisplayExpandSignLeft;
|
Result.Left := DisplayExpandSignLeft;
|
||||||
Result.Top := Top;
|
Result.Top := Top;
|
||||||
Result.Right := Result.Left + TreeView.Indent;
|
Result.Right := Result.Left + TreeView.GetRealIndent;
|
||||||
Result.Bottom := Top + Height;
|
Result.Bottom := Top + Height;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -1699,7 +1701,7 @@ function TTreeNode.DisplayExpandSignRight: integer;
|
|||||||
begin
|
begin
|
||||||
Result := DisplayExpandSignLeft;
|
Result := DisplayExpandSignLeft;
|
||||||
if TreeView <> nil then
|
if TreeView <> nil then
|
||||||
inc(Result, TreeView.Indent);
|
inc(Result, TreeView.GetRealIndent);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TTreeNode.DisplayIconLeft: integer;
|
function TTreeNode.DisplayIconLeft: integer;
|
||||||
@ -1741,7 +1743,7 @@ begin
|
|||||||
Result := DisplayTextLeft;
|
Result := DisplayTextLeft;
|
||||||
TV := TreeView;
|
TV := TreeView;
|
||||||
if TV <> nil then
|
if TV <> nil then
|
||||||
Inc(Result, TV.Canvas.TextWidth(Text) + TV.Indent div 2);
|
Inc(Result, TV.Canvas.TextWidth(Text) + TV.GetRealIndent div 2);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TTreeNode.AlphaSort: Boolean;
|
function TTreeNode.AlphaSort: Boolean;
|
||||||
@ -3219,7 +3221,7 @@ begin
|
|||||||
Items.KeepCollapsedNodes:=KeepCollapsedNodes;
|
Items.KeepCollapsedNodes:=KeepCollapsedNodes;
|
||||||
FScrollBars:=ssBoth;
|
FScrollBars:=ssBoth;
|
||||||
FDragImage := TDragImageList.CreateSize(32, 32);
|
FDragImage := TDragImageList.CreateSize(32, 32);
|
||||||
FIndent:=15;
|
FIndent:=0;
|
||||||
FChangeTimer := TTimer.Create(Self);
|
FChangeTimer := TTimer.Create(Self);
|
||||||
FChangeTimer.Enabled := False;
|
FChangeTimer.Enabled := False;
|
||||||
FChangeTimer.Interval := 1;
|
FChangeTimer.Interval := 1;
|
||||||
@ -3290,6 +3292,26 @@ begin
|
|||||||
FLastVertScrollInfo.cbSize := 0;
|
FLastVertScrollInfo.cbSize := 0;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TCustomTreeView.DoAutoAdjustLayout(
|
||||||
|
const AMode: TLayoutAdjustmentPolicy; const AXProportion, AYProportion: Double
|
||||||
|
);
|
||||||
|
begin
|
||||||
|
inherited DoAutoAdjustLayout(AMode, AXProportion, AYProportion);
|
||||||
|
|
||||||
|
if AMode in [lapAutoAdjustWithoutHorizontalScrolling, lapAutoAdjustForDPI] then
|
||||||
|
begin
|
||||||
|
DisableAutoSizing;
|
||||||
|
try
|
||||||
|
if not (tvoAutoItemHeight in Options) then
|
||||||
|
DefaultItemHeight := Round(DefaultItemHeight*AYProportion);
|
||||||
|
FIndent := Round(FIndent*AXProportion);
|
||||||
|
FExpandSignSize := Round(FExpandSignSize*AXProportion);
|
||||||
|
finally
|
||||||
|
EnableAutoSizing;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TCustomTreeView.DoCreateNodeClass(var NewNodeClass: TTreeNodeClass);
|
procedure TCustomTreeView.DoCreateNodeClass(var NewNodeClass: TTreeNodeClass);
|
||||||
begin
|
begin
|
||||||
if Assigned(OnCreateNodeClass) then
|
if Assigned(OnCreateNodeClass) then
|
||||||
@ -3624,7 +3646,7 @@ begin
|
|||||||
inc(Cnt);
|
inc(Cnt);
|
||||||
if (Cnt < LargeItemCount) then
|
if (Cnt < LargeItemCount) then
|
||||||
begin
|
begin
|
||||||
i := Node.DisplayTextRight + ScrolledLeft + Indent div 2;
|
i := Node.DisplayTextRight + ScrolledLeft + GetRealIndent div 2;
|
||||||
end else
|
end else
|
||||||
begin
|
begin
|
||||||
// computing DisplayTextRight is too expensive when the tree
|
// computing DisplayTextRight is too expensive when the tree
|
||||||
@ -4496,6 +4518,14 @@ begin
|
|||||||
Result := DefaultTreeNodeExpandSignSize;
|
Result := DefaultTreeNodeExpandSignSize;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TCustomTreeView.GetRealIndent: Integer;
|
||||||
|
begin
|
||||||
|
if FIndent=0 then
|
||||||
|
Result := MulDiv(FIndent, Font.PixelsPerInch, 96)
|
||||||
|
else
|
||||||
|
Result := FIndent;
|
||||||
|
end;
|
||||||
|
|
||||||
function TCustomTreeView.GetRightClickSelect: boolean;
|
function TCustomTreeView.GetRightClickSelect: boolean;
|
||||||
begin
|
begin
|
||||||
Result:=(tvoRightClickSelect in FOptions);
|
Result:=(tvoRightClickSelect in FOptions);
|
||||||
@ -4746,7 +4776,7 @@ end;
|
|||||||
procedure TCustomTreeView.DoPaintNode(Node: TTreeNode);
|
procedure TCustomTreeView.DoPaintNode(Node: TTreeNode);
|
||||||
var
|
var
|
||||||
NodeRect: TRect;
|
NodeRect: TRect;
|
||||||
VertMid, VertDelta, RealExpandSignSize: integer;
|
VertMid, VertDelta, RealExpandSignSize, RealIndent: integer;
|
||||||
NodeSelected, HasExpandSign: boolean;
|
NodeSelected, HasExpandSign: boolean;
|
||||||
|
|
||||||
function InvertColor(AColor: TColor): TColor;
|
function InvertColor(AColor: TColor): TColor;
|
||||||
@ -4816,14 +4846,14 @@ var
|
|||||||
Result := DrawTreeLines(CurNode.Parent);
|
Result := DrawTreeLines(CurNode.Parent);
|
||||||
if ShowLines then
|
if ShowLines then
|
||||||
begin
|
begin
|
||||||
CurMid := Result + (Indent shr 1);
|
CurMid := Result + (RealIndent shr 1);
|
||||||
if CurNode = Node then
|
if CurNode = Node then
|
||||||
begin
|
begin
|
||||||
// draw horizontal line
|
// draw horizontal line
|
||||||
if HasExpandSign then
|
if HasExpandSign then
|
||||||
DrawHorzLine(VertMid, CurMid + RealExpandSignSize div 2, Result + Indent)
|
DrawHorzLine(VertMid, CurMid + RealExpandSignSize div 2, Result + RealIndent)
|
||||||
else
|
else
|
||||||
DrawHorzLine(VertMid, CurMid, Result + Indent);
|
DrawHorzLine(VertMid, CurMid, Result + RealIndent);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
if (CurNode.GetNextVisibleSibling <> nil) then
|
if (CurNode.GetNextVisibleSibling <> nil) then
|
||||||
@ -4865,12 +4895,12 @@ var
|
|||||||
DrawVertLine(CurMid, NodeRect.Top, VertMid);
|
DrawVertLine(CurMid, NodeRect.Top, VertMid);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
inc(Result, Indent);
|
inc(Result, RealIndent);
|
||||||
end else
|
end else
|
||||||
begin
|
begin
|
||||||
Result := BorderWidth - FScrolledLeft;
|
Result := BorderWidth - FScrolledLeft;
|
||||||
if CurNode <> nil then // indent first level of tree with ShowRoot = false a bit
|
if CurNode <> nil then // indent first level of tree with ShowRoot = false a bit
|
||||||
inc(Result, Indent shr 2);
|
inc(Result, RealIndent shr 2);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -4980,10 +5010,10 @@ var
|
|||||||
// draw virtual tree line
|
// draw virtual tree line
|
||||||
Pen.Color:=TreeLineColor;
|
Pen.Color:=TreeLineColor;
|
||||||
// Pen.Style:=TreeLinePenStyle; ToDo: not yet implemented in all widgetsets
|
// Pen.Style:=TreeLinePenStyle; ToDo: not yet implemented in all widgetsets
|
||||||
x:=Node.DisplayExpandSignRight+Indent div 2;
|
x:=Node.DisplayExpandSignRight+RealIndent div 2;
|
||||||
MoveTo(x,NodeRect.Bottom-3);
|
MoveTo(x,NodeRect.Bottom-3);
|
||||||
LineTo(x,NodeRect.Bottom-2);
|
LineTo(x,NodeRect.Bottom-2);
|
||||||
x:=Node.DisplayExpandSignRight+Indent;
|
x:=Node.DisplayExpandSignRight+RealIndent;
|
||||||
LineTo(x,NodeRect.Bottom-2);
|
LineTo(x,NodeRect.Bottom-2);
|
||||||
Pen.Style:=psSolid;
|
Pen.Style:=psSolid;
|
||||||
|
|
||||||
@ -5003,7 +5033,7 @@ var
|
|||||||
// draw virtual tree line
|
// draw virtual tree line
|
||||||
Pen.Color:=TreeLineColor;
|
Pen.Color:=TreeLineColor;
|
||||||
//Pen.Style:=TreeLinePenStyle; ToDo: not yet implemented in all widgetsets
|
//Pen.Style:=TreeLinePenStyle; ToDo: not yet implemented in all widgetsets
|
||||||
x:=Node.DisplayExpandSignLeft+Indent div 2;
|
x:=Node.DisplayExpandSignLeft+RealIndent div 2;
|
||||||
MoveTo(x,NodeRect.Top+1);
|
MoveTo(x,NodeRect.Top+1);
|
||||||
x:=Node.DisplayExpandSignRight;
|
x:=Node.DisplayExpandSignRight;
|
||||||
LineTo(x,NodeRect.Top+1);
|
LineTo(x,NodeRect.Top+1);
|
||||||
@ -5025,7 +5055,7 @@ var
|
|||||||
// draw virtual tree line
|
// draw virtual tree line
|
||||||
Pen.Color:=TreeLineColor;
|
Pen.Color:=TreeLineColor;
|
||||||
//Pen.Style:=TreeLinePenStyle; ToDo: not yet implemented in all widgetsets
|
//Pen.Style:=TreeLinePenStyle; ToDo: not yet implemented in all widgetsets
|
||||||
x:=Node.DisplayExpandSignLeft+Indent div 2;
|
x:=Node.DisplayExpandSignLeft+RealIndent div 2;
|
||||||
MoveTo(x,NodeRect.Bottom-3);
|
MoveTo(x,NodeRect.Bottom-3);
|
||||||
LineTo(x,NodeRect.Bottom-2);
|
LineTo(x,NodeRect.Bottom-2);
|
||||||
x:=Node.DisplayExpandSignRight;
|
x:=Node.DisplayExpandSignRight;
|
||||||
@ -5125,6 +5155,7 @@ var
|
|||||||
OverlayIndex: Integer;
|
OverlayIndex: Integer;
|
||||||
begin
|
begin
|
||||||
RealExpandSignSize := GetRealExpandSignSize;
|
RealExpandSignSize := GetRealExpandSignSize;
|
||||||
|
RealIndent := GetRealIndent;
|
||||||
NodeRect := Node.DisplayRect(False);
|
NodeRect := Node.DisplayRect(False);
|
||||||
if (NodeRect.Bottom < 0) or (NodeRect.Top >= ClientHeight) then
|
if (NodeRect.Bottom < 0) or (NodeRect.Top >= ClientHeight) then
|
||||||
Exit;
|
Exit;
|
||||||
@ -5161,7 +5192,7 @@ begin
|
|||||||
|
|
||||||
// draw expand sign
|
// draw expand sign
|
||||||
if HasExpandSign then
|
if HasExpandSign then
|
||||||
DrawExpandSign(x - Indent + (Indent shr 1), VertMid, Node.Expanded);
|
DrawExpandSign(x - RealIndent + (RealIndent shr 1), VertMid, Node.Expanded);
|
||||||
|
|
||||||
// draw state icon
|
// draw state icon
|
||||||
if (StateImages <> nil) then
|
if (StateImages <> nil) then
|
||||||
@ -5222,7 +5253,7 @@ begin
|
|||||||
begin
|
begin
|
||||||
CurTextRect := NodeRect;
|
CurTextRect := NodeRect;
|
||||||
CurTextRect.Left := x;
|
CurTextRect.Left := x;
|
||||||
CurTextRect.Right := x + TextWidth(Node.Text) + Indent div 2;
|
CurTextRect.Right := x + TextWidth(Node.Text) + RealIndent div 2;
|
||||||
DrawNodeText(NodeSelected, CurTextRect, Node.Text);
|
DrawNodeText(NodeSelected, CurTextRect, Node.Text);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user