To Kokkoras: Text in links.

Please post bug reports, feature requests, or any question regarding the DELPHI AREA products here.

To Kokkoras: Text in links.

Postby elias » January 24th, 2006, 7:10 pm

kokkoras wrote:It would be nice (at least for me :oops: ) to have an option to prevent the drawing of the text labels of links. I mean, being able to set the text property to some text, but being able to prevent that text to be paint.
( :roll: I think I messed up my english - hope it makes sence)

Any ideas?


Fotis


Well, I think you should
1) create a boolean property ShowText in TGraphObject (you could use the property both for links and nodes)
2) When ShowText turns, allow or not run DrawText

(I din't test it)
elias
Senior Member
Senior Member
 
Posts: 90
Joined: November 8th, 2005, 12:09 pm
Location: Galicia, Spain

Postby elias » January 24th, 2006, 7:12 pm

Sorry for creating a new topic; I thought your post was offtopic
elias
Senior Member
Senior Member
 
Posts: 90
Joined: November 8th, 2005, 12:09 pm
Location: Galicia, Spain

Postby kokkoras » January 25th, 2006, 9:33 am

Ok, I did it. It was rather simple. I have added a 2-lever boolean control.

One at the TGraphLink level and the other at the TSimpleGraph level. My link instances have a boolean ShowText property, while my simplegraph component has a ShowLinkLabels property, both in the "Published" section of declaration.

The control of what to show is inside the DrawText method of TGraphLink. A label is paint when:

If ShowLinkLabels is true then
begin
if (there is such a lebel (default condition)) and (ShowText is true) then
begin
---old code goes here-----
end;
end;


In both of the above properties setter methods I had to properly handle the invalidation/repaint issues, but this was very easy. Just look around how Kambiz handles some similar cases.


Fotis
User avatar
kokkoras
Moderator
Moderator
 
Posts: 317
Joined: March 12th, 2005, 11:19 pm
Location: Thessaloniki, Greece

Postby elias » January 25th, 2006, 11:18 am

I liked you said and I wrote it in my SimpleGraph.pas; but I decided not to use the ShowLinkLabels property in TSimpleGraph because I can change all GraphObjects ShowText properties from my Main using a FOR sentence.

Changes:
Code: Select all
    property ShowText: Boolean read fShowText write SetShowText default True; //Added in TGraphObject

Code: Select all
procedure TGraphObject.SetShowText(Value: Boolean); //Setting
begin
  if ShowText <> Value then
  begin
    fShowText := Value;
    owner.Invalidate;
  end;
end;

Code: Select all
  fShowText:= True; //In TGraphObject.Create

Code: Select all
if ShowText then begin { ---old code goes here-----} end; // both in TGraphLink.DrawText and TGraphNode.DrawText

Say me if you have suggests about this code.
elias
Senior Member
Senior Member
 
Posts: 90
Joined: November 8th, 2005, 12:09 pm
Location: Galicia, Spain

Postby kokkoras » January 25th, 2006, 12:24 pm

So, you move it one level up into the object hierarchy, which I think is fine and serves similar needs on other node types better.

Regarding the loop which alters all states and the global flag:
It was my initial thought as well, to use a loop. But having a similar flag at the TSimpleGraph level, allows you to temporarily switch off all labels while keeping the individual state of each object. Its easy to chech this global flag inside DrawText methods. Just use the Owner property:


Code: Select all
procedure TGraphLink.DrawText(Canvas: TCanvas);
begin
     if Owner.ShowLinkLabels = true then  //check global flag
          if (TextToShow <> '') and (DisplayLabel=true) then  //check local flag
          begin
               //old code goes here
          end;
end;



In my app, I control the object's flag from the Object's Property dialog. Similarly, the global flag is controled from a "canvas" properties dialog.

Bottom Line: I think the global flag is essential. Both features should be considered for addition, at some time, in the release.

Fotis
User avatar
kokkoras
Moderator
Moderator
 
Posts: 317
Joined: March 12th, 2005, 11:19 pm
Location: Thessaloniki, Greece

Postby elias » January 26th, 2006, 1:26 pm

:) You are right.
elias
Senior Member
Senior Member
 
Posts: 90
Joined: November 8th, 2005, 12:09 pm
Location: Galicia, Spain

Postby elias » January 26th, 2006, 1:32 pm

although I do not need this Global Flag in my App...
elias
Senior Member
Senior Member
 
Posts: 90
Joined: November 8th, 2005, 12:09 pm
Location: Galicia, Spain


Return to DELPHI AREA Products

Who is online

Users browsing this forum: No registered users and 1 guest

cron