diff --git a/Source/VirtualTrees.BaseTree.pas b/Source/VirtualTrees.BaseTree.pas index e6d0162f..946722d2 100644 --- a/Source/VirtualTrees.BaseTree.pas +++ b/Source/VirtualTrees.BaseTree.pas @@ -1197,7 +1197,7 @@ TBaseVirtualTree = class abstract(TVTBaseAncestor) property Colors: TVTColors read FColors write SetColors; property CustomCheckImages: TCustomImageList read FCustomCheckImages write SetCustomCheckImages; property DefaultHintKind: TVTHintKind read GetDefaultHintKind; - property DefaultNodeHeight: TDimension read FDefaultNodeHeight write SetDefaultNodeHeight stored IsStored_DefaultNodeHeight; // default 18; + property DefaultNodeHeight: TDimension read FDefaultNodeHeight write SetDefaultNodeHeight stored IsStored_DefaultNodeHeight; property DefaultPasteMode: TVTNodeAttachMode read FDefaultPasteMode write FDefaultPasteMode default amAddChildLast; property DragHeight: Integer read FDragHeight write FDragHeight default 350; property DragImageKind: TVTDragImageKind read FDragImageKind write FDragImageKind default diComplete; @@ -1242,7 +1242,7 @@ TBaseVirtualTree = class abstract(TVTBaseAncestor) property SelectionBlendFactor: Byte read FSelectionBlendFactor write FSelectionBlendFactor default 128; property SelectionCurveRadius: Cardinal read FSelectionCurveRadius write SetSelectionCurveRadius default 0; property StateImages: TCustomImageList read FStateImages write SetStateImages; - property TextMargin: TDimension read FTextMargin write SetTextMargin stored IsStored_TextMargin; // default 4; + property TextMargin: TDimension read FTextMargin write SetTextMargin stored IsStored_TextMargin; property TreeOptions: TCustomVirtualTreeOptions read FOptions write SetOptions; property WantTabs: Boolean read FWantTabs write FWantTabs default False; property SyncCheckstateWithSelection[Node: PVirtualNode]: Boolean read GetSyncCheckstateWithSelection; @@ -2038,7 +2038,7 @@ constructor TBaseVirtualTree.Create(AOwner: TComponent); Height := 100; TabStop := True; ParentColor := False; - FDefaultNodeHeight := 18; + FDefaultNodeHeight := cInitialDefaultNodeHeight; FDragOperations := [doCopy, doMove]; FHotCursor := crDefault; FScrollBarOptions := TScrollBarOptions.Create(Self); @@ -2085,7 +2085,7 @@ constructor TBaseVirtualTree.Create(AOwner: TComponent); FDefaultPasteMode := amAddChildLast; FMargin := 4; - FTextMargin := 4; + FTextMargin := cDefaultTextMargin; FImagesMargin := 2; FLastDragEffect := DROPEFFECT_NONE; FDragType := dtOLE; @@ -4641,7 +4641,7 @@ procedure TBaseVirtualTree.SetDefaultNodeHeight(Value: TDimension); begin if Value = 0 then - Value := 18; + Value := cInitialDefaultNodeHeight; if FDefaultNodeHeight <> Value then begin Inc(FRoot.TotalHeight, Value - FDefaultNodeHeight); @@ -5883,14 +5883,7 @@ procedure TBaseVirtualTree.CMFontChanged(var Message: TMessage); begin inherited; - - if not (csLoading in ComponentState) then - begin - if HandleAllocated then begin - AutoScale(); - Invalidate; - end - end; + AutoScale(); HeaderMessage.Msg := CM_PARENTFONTCHANGED; HeaderMessage.WParam := 0; @@ -8765,6 +8758,7 @@ procedure TBaseVirtualTree.CreateWnd; else DoStateChange([], [tsUseThemes, tsUseExplorerTheme]); + AutoScale(); // Because of the special recursion and update stopper when creating the window (or resizing it) // we have to manually trigger the auto size calculation here. if hsNeedScaling in FHeader.States then @@ -15925,7 +15919,7 @@ procedure TBaseVirtualTree.AutoScale(); if HandleAllocated and (toAutoChangeScale in TreeOptions.AutoOptions) then begin Canvas.Font.Assign(Self.Font); - lTextHeight := Canvas.TextHeight('Tg') + {$if CompilerVersion > 31} MulDiv(2, CurrentPPI, 96) {$else} 2 {$ifend}; // See issue #1205, ScaledPixels(2) may return wrong value here + lTextHeight := Canvas.TextHeight('Tg') + TextMargin; // By default, we only ensure that DefaultNodeHeight is large enough. // If the form's dpi has changed, we scale up and down the DefaultNodeHeight, See issue #677. if (lTextHeight <> Self.DefaultNodeHeight) then begin @@ -19873,7 +19867,7 @@ function TBaseVirtualTree.IsStored_BottomSpace: Boolean; function TBaseVirtualTree.IsStored_DefaultNodeHeight: Boolean; begin - Result:= CompareValue(FDefaultNodeHeight, 18)<>EqualsValue; + Result:= CompareValue(FDefaultNodeHeight, cInitialDefaultNodeHeight)<>EqualsValue; end; //---------------------------------------------------------------------------------------------------------------------- @@ -19894,7 +19888,7 @@ function TBaseVirtualTree.IsStored_Margin: Boolean; function TBaseVirtualTree.IsStored_TextMargin: Boolean; begin - Result:= CompareValue(FTextMargin, 4)<>EqualsValue; + Result:= CompareValue(FTextMargin, cDefaultTextMargin) <> EqualsValue; end; //---------------------------------------------------------------------------------------------------------------------- diff --git a/Source/VirtualTrees.Types.pas b/Source/VirtualTrees.Types.pas index e6d2d120..7a2b82fc 100644 --- a/Source/VirtualTrees.Types.pas +++ b/Source/VirtualTrees.Types.pas @@ -28,6 +28,7 @@ interface ShadowSize = 5; // Size in pixels of the hint shadow. This value has no influence on Win2K and XP systems // as those OSes have native shadow support. cDefaultTextMargin = 4; // The default margin of text + cInitialDefaultNodeHeight= 18; // the default value of the DefualtNodeHeight property // Special identifiers for columns. NoColumn = - 1; @@ -333,7 +334,7 @@ TSortDirectionHelper = record helper for VirtualTrees.Types.TSortDirection toAutoHideButtons, // Node buttons are hidden when there are child nodes, but all are invisible. toAutoDeleteMovedNodes, // Delete nodes which where moved in a drag operation (if not directed otherwise). toDisableAutoscrollOnFocus, // Disable scrolling a node or column into view if it gets focused. - toAutoChangeScale, // Change default node height and header height automatically according to the used font. + toAutoChangeScale, // Change default node height and header height automatically according to the height of the used font. toAutoFreeOnCollapse, // Frees any child node after a node has been collapsed (HasChildren flag stays there). toDisableAutoscrollOnEdit, // Do not center a node horizontally when it is edited. toAutoBidiColumnOrdering // When set then columns (if any exist) will be reordered from lowest index to highest index