Jump to content


Photo

TreeColumn lines


  • Please log in to reply
23 replies to this topic

#1 yeohray

yeohray
  • Members
  • 24 posts

Posted 24 May 2007 - 01:52 PM

When I have the following structure in a TreeColumn:

- parent row ( A )
- child row ( A1 )
- child row ( A2 )
- parent row ( B )

A vertical line is drawn from row (A) to the top of row ( B ), but connects nowhere.

Is it possible to have the lines drawn in a 'normal' fashion as done in tree views i.e. no vertical lines are drawn if they do not connect to any other row?

Thanks.

Ray Mond

#2 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,191 posts
  • Gender:Male

Posted 24 May 2007 - 02:03 PM

Hello Ray,

This will be added very soon. I will need to remember which row is last child row.

regards
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.

#3 bosjo

bosjo
  • Members
  • 75 posts
  • Gender:Male
  • Location:Märsta, Sweden

Posted 10 February 2008 - 05:13 PM

I still get a "dangling connection" on the last child node -- is this still an issue, or am I doing something wrong?

#4 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,191 posts
  • Gender:Male

Posted 10 February 2008 - 05:30 PM

Hello Bosjo,

It is still an issue, but it will be solved very soon.

Best regards
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.

#5 bosjo

bosjo
  • Members
  • 75 posts
  • Gender:Male
  • Location:Märsta, Sweden

Posted 03 July 2009 - 01:50 PM

QUOTE (Boki (Berg) @ Feb 10 2008, 05:30 PM) <{POST_SNAPBACK}>
It is still an issue, but it will be solved very soon.


I think I just compiled and installed the most recent (stable) version, but I still get
the "dangling connection". Have I done something wrong (ie, am I still using some
old package from somewhere), or is this still an issue?

/Bo S

#6 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,191 posts
  • Gender:Male

Posted 03 July 2009 - 02:35 PM

Hello Bosjo,

Unfortunatelly, I am still working on it. I will definitelly speed up with working on it.

I am sorry again for waiting.

Best regards
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.

#7 bosjo

bosjo
  • Members
  • 75 posts
  • Gender:Male
  • Location:Märsta, Sweden

Posted 03 July 2009 - 03:46 PM

QUOTE (Boki (Berg) @ Jul 3 2009, 03:35 PM) <{POST_SNAPBACK}>
Unfortunatelly, I am still working on it. I will definitelly speed up with working on it.


I am also quite interested in the tree sorting feature. In the meantime, maybe it would
be possible to add an "OnBeforeSort" event to go with the "OnAfterSort"? That way,
I could implement my own tree sorting algorithm by creating some sort object in "BeforeSort",
using that in the custom sort, and dispose of it in "AfterSort". Or is there a snag somewhere?

/BoS

#8 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,191 posts
  • Gender:Male

Posted 03 July 2009 - 04:10 PM

Hello Bosjo,

I will add this event, but can you please tell me which parameters you need inside OnBeforeSort? Also, maybe existing OnCompare event may help you?

More info about custom sorting (LINK)

Best regards
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.

#9 bosjo

bosjo
  • Members
  • 75 posts
  • Gender:Male
  • Location:Märsta, Sweden

Posted 03 July 2009 - 06:03 PM

QUOTE
I will add this event, but can you please tell me which parameters you need inside OnBeforeSort?


This question is more difficult than I thought from the beginning... My first attempt would be
SortColumn and SortDirection (ie, ascending/descending), but that would mean that you would be
stuck with a unusable event the minute you implement multicolumn sorting, which I suppose is
high on some peoples wishlists (it is fairly high on my, anyway). Maybe a record á la MS:

CODE
TSortInfo = record
  siSize : integer;
  siColumnIndex : integer;
  siSortDirection : TSortKind;
end;


When you implement multicolumn sorting, you can only add a couple of extra fields in this record.

What do you think?

/Bo S

#10 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,191 posts
  • Gender:Male

Posted 04 July 2009 - 08:48 PM

Hello Bosjo,

Please sorry for delay.

I will be glad to add multi-select sort, but this kind of sorting will slow-down current sorting routine.

If you want to implement your sorting routine SortKind and SortedColumn.Index may help you.

Best regards
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.

#11 bosjo

bosjo
  • Members
  • 75 posts
  • Gender:Male
  • Location:Märsta, Sweden

Posted 05 August 2009 - 02:00 PM

QUOTE (Boki (Berg) @ Jul 4 2009, 09:48 PM) <{POST_SNAPBACK}>
If you want to implement your sorting routine SortKind and SortedColumn.Index may help you.


I saw that there is a new version out now -- does this version contain OnBeforeSort, and, most importantly, is the "dangling connection" bug fixed?

#12 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,191 posts
  • Gender:Male

Posted 05 August 2009 - 08:16 PM

Hello Bosjo,

I will be glad to add OnBeforeSort, but still don't understand where this event may be placed and which parameters will have.

I still have no solution for "dangling" connections (if we think about same issue), and have no idea how to fix it smile.gif Good news is that I will add new vista style collapsing buttons (with triangles instead of +/- square buttons).

Best regards
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.

#13 bosjo

bosjo
  • Members
  • 75 posts
  • Gender:Male
  • Location:Märsta, Sweden

Posted 17 August 2009 - 05:30 PM

QUOTE (Boki (Berg) @ Aug 5 2009, 09:16 PM) <{POST_SNAPBACK}>
I will be glad to add OnBeforeSort, but still don't understand where this event may be placed and which parameters will have.


If this is just for me, then I have specified which information I would need (SortColumn and SortKind); the intension is of course to build some kind of structure to be able to do a proper sort which doesn't destroy the tree structure.

QUOTE (Boki (Berg))
I still have no solution for "dangling" connections (if we think about same issue), and have no idea how to fix it smile.gif Good news is that I will add new vista style collapsing buttons (with triangles instead of +/- square buttons).


I must confess I don't understand this point of view. Firstly, you have indicated no less than three times that you will do it "soon", and at least once you have (correctly) specified what you would need to do to accomplish it. Secondly, a tree structure painted like that is COMPLETELY unusable in anything but minor programs that are never seen by ayone, except the programmer himself -- or by programmers who does not care about his reputation. I think you have stated somewhere that this column is "experimental", and this is of course the first step to remove that label (and the second is of course the sorting issue). Adding vista style buttons to this column type is a bit like adding wind shield wipers to a car that has no steering wheel...

Anyway, as a I have added the following code in the customdraw event, and changed the DrawingOptions to doCustom for the tree column. However, it does not work 100% -- there is a slight remainder of the lines left after the initial painting (see this picture), but is removed if the user selects a cell and then another -- so it seems that the CustomDraw code below sees a different Rect in the initial painting and in subsequent repaintings of individual cells. Is there some kind of rounding issue here? Also note that the remainder is only visible in the second half of the grid, which makes me even more convinced that there is some kind of rounding error involved here.

CODE
procedure TScriptEditForm.NG_ScriptsCustomDrawCell(Sender: TObject; ACol, ARow: Integer;
  CellRect: TRect; CellState: TCellState);
var
  i       : integer;
  xParent : integer;
  xLevel  : integer;
  xXValue : integer;
  xYValue : integer;
begin
  with Sender as TNextGrid do begin
// First, find dangling connections on this level and remove them
    xLevel := GetLevel(aRow);
    xXValue := CellRect.Left + xLevel*19 - 13;
    Canvas.Pen.Color := Canvas.Pixels[CellRect.Left + 1, CellRect.Top + 1];
    if GetNextSibling(aRow) = -1 then begin
      xYValue := ((CellRect.Top + CellRect.Bottom) div 2);
      Canvas.MoveTo(xXValue, xYValue);
      Canvas.LineTo(xXValue, CellRect.Bottom);
    end;

// Then iterate through higher levels to find dangling connections
    while xLevel > 0 do begin
      xLevel  := xLevel - 1;
      xXValue := xXValue - 19;
      aRow := GetParent(aRow);
      if GetNextSibling(aRow) = -1 then begin
        Canvas.MoveTo(xXValue, CellRect.Top-1);
        Canvas.LineTo(xXValue, CellRect.Bottom+1);
      end;
    end;
  end;
end;



#14 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,191 posts
  • Gender:Male

Posted 17 August 2009 - 11:37 PM

Hello Bosjo,

I have deal with this problem (drawing additional part of tree line) few times and allways bump to a STOP sign. I am sorry for delay, most probably I have jump on solving some non-visual issue.

I promise that I will correct tree painting in next release.

Best regards
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.

#15 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,191 posts
  • Gender:Male

Posted 17 August 2009 - 11:43 PM

PS. Your code looks fine, I didn't get dots on initial painting. I will test it a little bit more.

Unfortunatelly I will need to write my own code for handling connections drawing inside column.

Best regards
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.

#16 bosjo

bosjo
  • Members
  • 75 posts
  • Gender:Male
  • Location:Märsta, Sweden

Posted 18 August 2009 - 02:59 AM

QUOTE
PS. Your code looks fine, I didn't get dots on initial painting. I will test it a little bit more.


To get the dots you would need to have quite a lot of rows. I have something like 75 or so, and the dots are only present at about row 30 and below as you can see. Aha! I just got a clue for you -- compare this image with this image. The only difference is that I have scrolled down one row. So it seems that the final Rect on a page cannot remove the last pixel, and when scrolling down that pixel is moved up, the series of dots is created. It also explains why there are gaps -- I have scrolled fast enough to get two new rows between repaints, so the uppermost of the two is not at the border.

QUOTE
Unfortunatelly I will need to write my own code for handling connections drawing inside column.


Yes, but the logic probably is not that different -- you need to know each rows parent, and being able to figure out whether each node in turn is the last of the siblings; not really rocket science, once you have access to the proper set of data, and I suppose that is where the real problem is.

Incidentally, I think it is the same information that you need to make a proper tree sort -- the algorithm goes roughly like this: "If two nodes have the same parent, use the sorting criteria to determine the order. If they do not, iterate backwards until you find a common parent (or both have no parent), and sort the nodes according to the sorting criteria of the childnodes of the common parent; or if if one node is a descendant of the other, put the other node first." Thus, having access to the parental information for each row would make it possible to solve the sorting problem as well. In my opinion, doing something right slowly is better than doing something wrong quickly...

#17 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,191 posts
  • Gender:Male

Posted 18 August 2009 - 08:30 PM

Hello Bosjo,

Main problem is in architecture of NextGrid, since TreeColumn is same as any other column type and I need to somehow provide interface between TTreeColumnDisplay and rows.

I will work on it, I hope that I will fix it for upcoming release.

Sorting will need to wait for some time. I have in head how sorting may be implemented, but I am worry that this may slow down tree-less sorting sad.gif

Best regards
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.

#18 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,191 posts
  • Gender:Male

Posted 26 August 2009 - 02:44 AM

Hello,

I have allmost finish "correct" drawing tree lines, but still have troubles in few situations. If someone like to help, I am open for it smile.gif Thank you! I have work on it 7 days and lost the ideas smile.gif

Best regards
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.

#19 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,191 posts
  • Gender:Male

Posted 27 August 2009 - 02:52 AM

Hi,

I think that I have made it smile.gif

I will need some testings, but I think that now is done. It will be available for next quick-fix.

Best regards
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.

#20 bosjo

bosjo
  • Members
  • 75 posts
  • Gender:Male
  • Location:Märsta, Sweden

Posted 01 September 2009 - 03:08 PM

QUOTE (Boki (Berg) @ Aug 27 2009, 03:52 AM) <{POST_SNAPBACK}>
I think that I have made it smile.gif

I will need some testings, but I think that now is done. It will be available for next quick-fix.


Great news!

What about the "Rect bug" I found "en passant"; have you been able to reproduce the problem and track it down? I suppose it is the last visible row that gets a Rect height which is one pixel too small when customdrawing, for some reason.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users