Page 1 of 1

Scrollbars of simplegraph

PostPosted: August 2nd, 2004, 11:07 am
by P_G
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

PostPosted: August 3rd, 2004, 8:24 pm
by Kambiz
I tried but I couldn't find an easy way to implement it. :(

PostPosted: August 4th, 2004, 7:23 am
by Kambiz
I added new FreezeTopLeft property to the TSimpleGraph's interface. When this property is True, the objects don't accept negative coordinates.

Cheers,
Kambiz

Good workaround

PostPosted: August 4th, 2004, 8:14 pm
by P_G
Yip! That's a good way. Thank you, Kambiz. :wink:

P_G

Patch to enable scrolling beyond the topleft corner...

PostPosted: February 21st, 2005, 3:18 pm
by MeW
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;

PostPosted: February 21st, 2005, 4:35 pm
by Stefan
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;

PostPosted: March 3rd, 2005, 12:02 pm
by MeW
more enhancements are being prepared in the SourceForge project which also handles scrolling outside the bottomright corner...