Page 2 of 3

PostPosted: March 15th, 2006, 9:55 am
by kokkoras
HPW wrote:I have a look at the TTreenode-help and I am not sure about the storage.
The pointer points to the data, but is the data then part of the node-object and stored with it?


Regarding the treeNodes, no, the data object is not part of the treeNode. That is, if you want to synchronize the tree nodes with the associated data objects then you have to create and associate those data objects yourself when a tree node is created (use AddChildObject or the Data property). Additionally, you should add code in the onDelete event handler of the treeView to delete the associated data object as well. If you want to make it part of the tree node then you should derive a descendant class and put your data objects there.

I am note sure what exactly Kambiz did there, but this issue was a past request of mine and I think this is the solution, which I found elegant and most wellcome as it follows known paths from the VCL.

PostPosted: March 15th, 2006, 11:32 am
by HPW
If you want to make it part of the tree node then you should derive a descendant class and put your data objects there.


Since we are talking about TSimpleGraph, I would have to extend TGraphObject with a new key property 'DataList' (TStringlist) to have a generic container for invisible text-based data. This would be part of the object and stored inside *.sgp with no hassle to syncronise it with outside tables.

Maybe enough generic to get into the standard?

Excuse that we get so off-topic! ;-)

PostPosted: March 15th, 2006, 11:47 am
by kokkoras
HPW wrote:Since we are talking about TSimpleGraph, I would have to extend TGraphObject with a new key property 'DataList' (TStringlist) to have a generic container for invisible text-based data. This would be part of the object and stored inside *.sgp with no hassle to syncronise it with outside tables.

Maybe enough generic to get into the standard?


I am not sure if you will get "ready" save/load functionality for these extensions. You must probably alter the methods related to the *.sgp storing/loading.

HPW wrote:Excuse that we get so off-topic! ;-)

Yes we are. Let's put an end. :roll:

PostPosted: March 15th, 2006, 12:48 pm
by Kambiz
kokkoras is right.

I though having only Tag property is not enough for some guys, therefore Data property added.

In opposite of Tag property, the object doesn't store value of Data property.

I'll add some events to SimpleGraph for sreaming in/out custom data of each object.

PostPosted: March 15th, 2006, 1:13 pm
by kokkoras
Kambiz wrote:I'll add some events to SimpleGraph for sreaming in/out custom data of each object.


You mean you will provide the hooks for anyone interested in implementing the saving/loading of those data inside *.sgp files, right?

PostPosted: March 15th, 2006, 1:43 pm
by Kambiz
I've already added them. :D

OnObjectRead: TGraphStreamEvent;
TGraphStreamEvent = procedure(Graph: TSimpleGraph; GraphObject: TGraphObject; Stream: TStream) of object;

Occurs when property settings of a graph object is being read from a stream. This event can be used to retrieve custom data of the graph object from the stream.

OnObjectWrite: TGraphStreamEvent;
TGraphStreamEvent = procedure(Graph: TSimpleGraph; GraphObject: TGraphObject; Stream: TStream) of object;

Occurs when property settings of a graph object is being written in to a stream. This event can be used to save custom data of the graph object in to the stream.

PostPosted: March 15th, 2006, 1:50 pm
by kokkoras
Kambiz wrote:I've already added them. :D


What if I don't want to save those data in my *.sgp file? Is it compulsory or optional?

PostPosted: March 15th, 2006, 3:18 pm
by HPW
OnObjectRead:
OnObjectWrite:


Sounds very usefull!
Can you add some sample code how to use it in the final 2.1 release?
:?:

:(

PostPosted: March 15th, 2006, 3:24 pm
by kokkoras
HPW wrote:Can you add some sample code how to use it in the final 2.1 release? :?: :(


Patience people. Let's wait for the release :wink:

PostPosted: March 15th, 2006, 3:26 pm
by Kambiz
It's an event, so is optional.

There's one restriction for streams containg custom data. These kind of streams are not compatible with the codes of other developers. This restriction affects .sgp files and clipboard.

PostPosted: March 15th, 2006, 3:33 pm
by kokkoras
Kambiz wrote:These kind of streams are not compatible with the codes of other developers. This restriction affects .sgp files and clipboard.


ok. This is expected. The unaware loader/version should just ignore those data, though.

PostPosted: March 15th, 2006, 3:37 pm
by HPW
There's one restriction for streams containg custom data. These kind of streams are not compatible with the codes of other developers. This restriction affects .sgp files and clipboard.


One reason to think about a generic text container, which could be compatibel between other developers.

PostPosted: March 15th, 2006, 4:02 pm
by Kambiz
HPW,

A generic stream is more powerfull than a generic text, isn't it?

----

I found a solution to get rid of that restriction using a boolean property, without any overload for users who do not need this feature.

OnObjectRead event occurs only when there's any custom data for the object.

OnObjectWrite event occurs when HasCustomData property of the object is set to True.

If an instance of the simple graph doesn't care about the CustomData of an object, it throw outs the data.

PostPosted: March 15th, 2006, 4:14 pm
by kokkoras
Kambiz wrote:I found a solution to get rid of that restriction using a boolean property, without any overload for users who do not need this feature.


That's perfect. Thank you.

PostPosted: March 15th, 2006, 4:37 pm
by HPW
A generic stream is more powerfull than a generic text, isn't it?


Sure, and it seems you found the better solution.
And when you add a usefull sample, it would be perfect! :wink:
2.1 seems to get very exiting! So keep on.