Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make it possible to override RangeX #670

Closed
Delphi-FPC-Lazarus opened this issue Oct 25, 2016 · 8 comments
Closed

Make it possible to override RangeX #670

Delphi-FPC-Lazarus opened this issue Oct 25, 2016 · 8 comments
Assignees
Milestone

Comments

@Delphi-FPC-Lazarus
Copy link

FRangeX is calculated by TBaseVirtualTree.UpdateHorizontalRange() from header FHeader.FColumns.TotalWidth.

It would be useful if it can be overwritten in some special cases when columns width get's larger than it's header, such as a subtable.
subtable

In this case it is inpossible to scroll to the end of the subtable because FRangeX / HorzScrollbar is calculated by header width.

I guess to make a few little changes in VirtualTrees.pas to make it possible:

+ procedure SetRangeX(value: Cardinal);

- property RangeX: Cardinal read GetRangeX;
+ property RangeX: Cardinal read GetRangeX write SetRangeX;

- procedure UpdateHorizontalRange;
+ procedure UpdateHorizontalRange; virtual;

+procedure TBaseVirtualTree.SetRangeX(value: Cardinal);
+begin
+ FRangeX := value;
+end;


With this changes, UpdateHorizontalRange can be overwritten,
after calling inherited, RangeX can be modified for special cases like subtables.

regards
Peter

@joachimmarder
Copy link
Contributor

There is a protected SetRangeX() now and UpdateHorizontalRange is virtual.

@Delphi-FPC-Lazarus
Copy link
Author

Delphi-FPC-Lazarus commented Nov 29, 2016 via email

@jovanvasic
Copy link

Hi there, I have found a side effect with this change request. Taking Peter's example to adjust the RangeX value to accommodate the subtable breaks the function TVTHeader.DetermineSplitterIndex. RangeX value is used to initialize the Variable SplitPoint for the determination of the column splitter. If I haven't missed anything else following change should fix the problem.
- SplitPoint := -Treeview.FEffectiveOffsetX + Integer(Treeview.FRangeX);
+ SplitPoint := -Treeview.FEffectiveOffsetX + Integer(FColumns.TotalWidth);

@jovanvasic
Copy link

And to pick up on my previous post and complete my request... I have missed the block TreeView.UseRightToLeftAlignment in the function TVTHeader.DetermineSplitterIndex.
- if Integer(Treeview.FRangeX) < Treeview.ClientWidth then
+ if Integer(FColumns.TotalWidth) < Treeview.ClientWidth then

- Inc(SplitPoint, Treeview.ClientWidth - Integer(Treeview.FRangeX));
+ Inc(SplitPoint, Treeview.ClientWidth - Integer(FColumns.TotalWidth));

@joachimmarder
Copy link
Contributor

@jovanvasic: It's difficult to judge your proposed changes without having a sample project that makes use of overriding SetRangeX() and UpdateHorizontalRange(), the use of this seems rather specific.

@mp3freak: Can you comment on them?

@jovanvasic
Copy link

Hi Joachim, I attached a sample project to show what I'm trying to do. On a click in the first column of a node the node expands and displays a sub table. The sub table is a TVirtualStringTree and it is wider then the main table. The Scrollbar in the sub table is deactivated. Using your announced changes for UpdateHorizontalRange() and SetRangeX() I manipulate the RangeX value of the main table with the RangeX value from the sub table. This allows me to adjust the Scroll Range to access the content of the sub table using the main table scrollbar. Now to come back to yesterdays post, if a node in the main table is expanded and the main table RangeX value therefore manipulated the function TVTHeader.DetermineSplitterIndex cannot determine the SplitterIndex anymore because it uses the RangeX value. Testing and comparing the values I found the RangeX value is the same like the Columns.TotalWidth. Being in a function of the header to find the splitter points I thought it may be better to use the Columns.TotalWidth instead, in case the RangeX gets modified.

VirtualTreeRangeX_Demo.zip

@Delphi-FPC-Lazarus
Copy link
Author

I fully agree with jovan. I didn't see that splitpoint side effect of my change.
That change is ok for me.

joachimmarder pushed a commit that referenced this issue Jan 15, 2017
@joachimmarder
Copy link
Contributor

@jovanvasic: Thanks, your changes have been included.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants