Scrollbars of simplegraph

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

Scrollbars of simplegraph

Postby P_G » August 2nd, 2004, 11:07 am

Hi, Kambiz

Here's another idea for simplegraph: When you insert a couple of nodes and move them into negativ coordinates (the upper-left corner of the component), they are "lost", because no scrollbars appear. Of course you can mark all objects and move them by keyboard into your view. But for many users it would be a lot more comfortable, if scrollbars are shown for nodes with negativ coordinates too. :idea:

C.U. P_G
P_G
Senior Member
Senior Member
 
Posts: 51
Joined: June 14th, 2004, 11:13 am
Location: Germany

Postby Kambiz » August 3rd, 2004, 8:24 pm

I tried but I couldn't find an easy way to implement it. :(
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2408
Joined: March 7th, 2003, 7:10 pm

Postby Kambiz » August 4th, 2004, 7:23 am

I added new FreezeTopLeft property to the TSimpleGraph's interface. When this property is True, the objects don't accept negative coordinates.

Cheers,
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2408
Joined: March 7th, 2003, 7:10 pm

Good workaround

Postby P_G » August 4th, 2004, 8:14 pm

Yip! That's a good way. Thank you, Kambiz. :wink:

P_G
P_G
Senior Member
Senior Member
 
Posts: 51
Joined: June 14th, 2004, 11:13 am
Location: Germany

Patch to enable scrolling beyond the topleft corner...

Postby MeW » February 21st, 2005, 3:18 pm

I'm not sure if this would be a proper place to enter such a routine, but it seems to behave. Patch the method or create a subclass which overrides this method like this:
Code: Select all
procedure TSimpleGraph.DoCanMoveResizeNode(Node: TGraphNode; var aLeft,
  aTop, aWidth, aHeight: Integer; var CanMove, CanResize: Boolean);
var
  i: integer;
  Delta: TPoint;
  R: TRect;
begin
  if FreezeTopLeft then
  begin
    if aLeft < 0 then aLeft := 0;
    if aTop < 0 then aTop := 0;
  end
  else
  begin
    { MeW: scroll other nodes to the bottom right
           if a node is scrolled beyond the topleft }
    if (aLeft < Left) or (aTop < Top) then
    begin
      Delta := Point(0,0);
      if (aLeft < Left) then Delta.X := -aLeft;
      if (aTop < Top) then Delta.Y := -aTop;
      BeginUpdate;
      try
        for i:=0 to ObjectsCount-1 do
        begin
          if (Objects.Items[i] <> Node) then
          begin
            R := Objects[i].BoundsRect;
            OffsetRect(R, Delta.X, Delta.Y);
            Objects[i].BoundsRect := R;
          end;
        end;
        if (aLeft < Left) then aLeft := Left;
        if (aTop < Top) then aTop := Top;
      finally
        EndUpdate;
      end;
    end;
  end;
  if Assigned(OnCanMoveResizeNode) then
    OnCanMoveResizeNode(Self, Node, aLeft, aTop, aWidth, aHeight, CanMove, CanResize);
end;
MeW
Active Member
Active Member
 
Posts: 9
Joined: February 17th, 2005, 6:34 pm
Location: Netherlands

Postby Stefan » February 21st, 2005, 4:35 pm

Hello,

I've adjusted the code a little to get a little different behaviour, hope you don't mind :)

Cheers,
Stefan

Code: Select all
procedure TExtGraph.DoCanMoveResizeNode(Node: TGraphNode; var aLeft,
  aTop, aWidth, aHeight: Integer; var CanMove, CanResize: Boolean);
var
  i: integer;
  Delta: TPoint;
  R: TRect;
begin
  if FreezeTopLeft then begin
    if aLeft < 0 then aLeft := 0;
    if aTop < 0 then aTop := 0;
  end else begin
    { MeW: scroll other nodes to the bottom right if a node is scrolled beyond the topleft }
    if (aLeft < 0) or (aTop < 0) then begin
      Delta := Point(0,0);
      if (aLeft < 0) then Delta.X := -aLeft;
      if (aTop < 0) then Delta.Y := -aTop;
      BeginUpdate;
      try
        for i:=0 to ObjectsCount-1 do
        begin
          if (Objects.Items[i] <> Node) then
          begin
            R := Objects[i].BoundsRect;
            OffsetRect(R, Delta.X, Delta.Y);
            Objects[i].BoundsRect := R;
          end;
        end;
        if (aLeft < 0) then aLeft := 0;
        if (aTop < 0) then aTop := 0;
      finally
        EndUpdate;
      end;
    end;
  end;
  if Assigned(OnCanMoveResizeNode) then
    OnCanMoveResizeNode(Self, Node, aLeft, aTop, aWidth, aHeight, CanMove, CanResize);
end;
User avatar
Stefan
Moderator
Moderator
 
Posts: 128
Joined: September 27th, 2004, 9:40 am
Location: Tilburg, The Netherlands

Postby MeW » March 3rd, 2005, 12:02 pm

more enhancements are being prepared in the SourceForge project which also handles scrolling outside the bottomright corner...
MeW
Active Member
Active Member
 
Posts: 9
Joined: February 17th, 2005, 6:34 pm
Location: Netherlands


Return to DELPHI AREA Products

Who is online

Users browsing this forum: No registered users and 3 guests

cron