Page 1 of 1

How to "FreezeBottomRight"?

PostPosted: August 5th, 2005, 9:17 am
by lbc
Hello
I appreciate particularly the FreezeTopLeft property
Now as i'd like to let the user to put shapes only in the graph current dimensions (I mean: without getting scrollbars when he goes down the bottom right edge), how to get something like a "FreezeBottomRight"?

I was thinking to use OnCanMoveResizeNode but it doesn't seem to get the wished result (basically I have tried to reassign the width of the node)

thanks for any suggestion/help about the above

Code: Select all
procedure TForm1.SimpleGraphCanMoveResizeNode(Graph: TSimpleGraph;
  Node: TGraphNode; var NewLeft, NewTop, NewWidth, NewHeight: Integer;
  var CanMove, CanResize: Boolean);
begin
 //
 if Node.BoundsRect.Right > GRaph.ClientRect.Right then
 begin
  // NewWidth :=  set the difference
 end;
end;

PostPosted: August 5th, 2005, 9:21 pm
by Kambiz
Instead of Graph.ClientRect.Right try Graph.ClientWidth. It may work. :?:

The whole code could be as follow:

Code: Select all
procedure TForm1.SimpleGraphCanMoveResizeNode(Graph: TSimpleGraph;
  Node: TGraphNode; var NewLeft, NewTop, NewWidth, NewHeight: Integer;
  var CanMove, CanResize: Boolean);
begin
  if Node.BoundsRect.Right >= Graph.ClientWidth then
  begin
    CanMove := False;
    CanResize := False;
  end;
end;

PostPosted: August 6th, 2005, 10:11 am
by lbc
hi Kambiz thank you for your suggestion
I have tried it and it works but unfortunately there are 2 problems:

- the side scrollbars shows up as soon as the shape is moved to the right or to the bottom
- enabling CanMove and CanResize (both=true) "lock"definitely the shape, instead it would be nice to get something like the FreezeLeftTop behaviour, that is the user can move down or right the shape currently "frozen" at the very left top border.

As a workaround i have found the following but unfortunately it doesn't seem to work "perfectly"

Code: Select all
if (Node.BoundsRect.Right >= Graph.ClientWidth) or (Node.BoundsRect.Bottom >= Graph.ClientHeight) then
 begin
   //CanMove := false;
   CanResize := false;
   NewLeft := Node.Left- 2; // need a little shift, to avoid the shape stays "frozen"
   NewTop := Node.Top - 2;
   NewWidth := Node.Width - 2;
   NewHeight := Node.Height - 2;
   // hide the scrollbars when they are displayed
   if Graph.VertScrollBar.IsScrollBarVisible then Graph.VertScrollBar.Visible := false;
   if Graph.HorzScrollBar.IsScrollBarVisible then Graph.HorzScrollBar.Visible := false;
 end;


It would be wonderful if you could add a property FreezeBottomRight which behaves like the FreezeTopLeft counterpart, in a next release of TSimpleGraph, of course if possibile

thank you!

PostPosted: August 18th, 2005, 9:25 am
by Kambiz
My code was just something to show how to use the event.

The SimpleGraph project has been moved on SourceForge under name .
ExtGraph Project. Your request should be posted on the new project's page.

You may also find the following link useful:
http://www.delphiarea.com/forum/viewtopic.php?t=296

PostPosted: August 18th, 2005, 1:38 pm
by valar2006
Why not?
ImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImage