DELPHI AREA
MESSAGE BOARD
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

two questions (about SG and PrintPreview components)

 
   Reply to topic    DELPHI AREA Forum Index -> DELPHI AREA's Products
View previous topic :: View next topic  
Author Message
lbc
Member


Joined: 04 Feb 2004
Posts: 3
Location: Italy

PostPosted: 04/02/04 08:08    Post subject: two questions (about SG and PrintPreview components) Reply with quote

Dear Sir
first of all congratulations for your EXCELLENT components, they are really one of the best piece of delphi software i have found around

Now I would appreciate if you could kindly give me a clue about two questions

1) SimpleGraph Demo:
very nice and useful application, i just wonder why moving the shapes (at least on my sysetm (win XP home) seems slow enough. I have also tried to disable the "snap to grid" option but unfortunately the same thing occurs.
How to make the shapes moving around the canvas a little bit faster ?
(when i say "slow" i refer comparing to other graph applications, like OpenOffice Draw, i mean there the shapes "follow" the mouse quickly, in SG they seem "snapped").
It's not a big issue of course, but it would be really great if the shapes could be moved quickly also in SG (as i said Excellent application indeed).

2) PrintPreview (or, better, PaperPreview)
While i have been able to use printpreview without problems, what is exactly the purpose of the PaperPreview component? Infact i haven't found any documentation about it. Is there any sample about it?

thanks in advance for any info/help about the above and again sincere contratulations for your EXCELLENT work!
Back to top
View user's profile
Kambiz
Administrator


Joined: 07 Mar 2003
Posts: 314

PostPosted: 04/02/04 11:47    Post subject: Reply with quote

I would like to thank you for your encouraging words. And, I am glad to hear you found these components useful.

  1. The slow movement of object on SG could be because of grids. Especially when grid's size is more than 8 pixels, it could be slower. Honestly, the main reason for this problem is my lack of knowledge to implement a better algorithm to draw objects.

  2. TPaperPreview has been used by TPrintPreview. I thought maybe somebody find a reson to use it alone, so I registered it as a control.

Regards,
Kambiz
Back to top
View user's profile Send e-mail Visit poster's website
lbc
Member


Joined: 04 Feb 2004
Posts: 3
Location: Italy

PostPosted: 04/02/04 15:36    Post subject: thanks Reply with quote

Dear Mr Kambiz
thank you very much for your reply
I confirm that your components are both useful and excellent: very neat piece of software indeed, also very handful to learn something about how to write a good component
by the way in my opinion also your website is very good and easy to navigate

Keep up the excellent work!

best regards
Back to top
View user's profile
Kambiz
Administrator


Joined: 07 Mar 2003
Posts: 314

PostPosted: 05/02/04 11:38    Post subject: Reply with quote

Thank you so much!
Back to top
View user's profile Send e-mail Visit poster's website
lbc
Member


Joined: 04 Feb 2004
Posts: 3
Location: Italy

PostPosted: 06/02/04 10:17    Post subject: Reply with quote

Dear Mr Kambiz
as i said It's really true: your components rule! I have downloaded tons and tons of components but yours seem to me among the BEST (both useful and fine) ever found all around the many delphi sites

Now, As far as the SG "slow shapes moving" little issue I have found inside my snippet base (sorry don't remember where exactly found this snippet) the following "simple drawing program". It seems to me that the shapes can be moved here a little bit faster (at least on my Win XP hoe system).
Unfortunately I am non as expert and great programmer as you and currently i am not able to locate the SG compmenent or demo code section in order to insert these lines and hopefully get a little fatser response in the SG demo shapes moving action, but i post it here just in case this could help you a little bit for example in a future SG release.

Of course i don't know if this example is too simple to you, or if it can't be actually included in SG due to different implementation concepts or similiar things anyway i hope it helps!

again my sincere thanks and congratulations for your excellent work

Code:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  ExtCtrls, Menus;

type
  TForm1 = class(TForm)
    PopupMenu1: TPopupMenu;
    Line1: TMenuItem;
    Rectangle1: TMenuItem;
    Circle1: TMenuItem;
    RoundRectangle1: TMenuItem;
    RoundSquare1: TMenuItem;
    Square1: TMenuItem;
    procedure FormCreate(Sender: TObject);
    procedure FormMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
    procedure FormMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
    procedure FormMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
    procedure ShapeMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
    procedure ShapeMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
    procedure ShapeMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
    procedure PopupMenuClick(Sender: TObject);
    procedure DrawGhost;
  private
    ObjType : TShapeType;
    NewObj  : TShape;
    X1,Y1   : Integer;
    X2,Y2   : Integer;
    X3,Y3   : Integer;
    Grabbed : Boolean;
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.FormCreate(Sender: TObject);
begin
  Canvas.Pen.Mode := pmXOr;
  Canvas.Pen.Style := psDot;
  ObjType := stCircle;
end;

procedure TForm1.FormMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var
  L,T,W,H : Integer;
begin
  if Button <> mbLeft then exit;
  if (X=X1) and (Y=Y1) then exit;
  DrawGhost; // Undraw the last rubber-banding image
  X2 := X; Y2 := Y;
  NewObj := TShape.Create(Self);
  with NewObj do
    begin
      // We don't need to worry about destroying these shapes. They are in the Form's
      // components list and will be automatically destroyed when the form closes.
      Parent := Self;
      Shape := ObjType;
      // Setup mouse handlers for shape
      OnMouseDown := ShapeMouseDown;
      OnMouseUp := ShapeMouseUp;
      OnMouseMove := ShapeMouseMove;
      if X1 < X2 then L := X1    else L := X2;
      if X1 < X2 then W := X2-X1 else W := X1-X2;
      if Y1 < Y2 then T := Y1    else T := Y2;
      if Y1 < Y2 then H := Y2-Y1 else H := Y1-Y2;
      if ObjType in [stCircle,stSquare,stRoundSquare] then
        if W < H then H := W else W := H;
      SetBounds(L,T,W,H);
    end;
end;

procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
  if Button <> mbLeft then exit;
  X1 := X; Y1 := Y; X2 := X; Y2 := Y;
end;

procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
begin
  if ssLeft in Shift then
    begin
      DrawGhost;  // Undraw the last image
      X2 := X; Y2 := Y;
      DrawGhost;  // Draw the new image
    end;
end;

procedure TForm1.ShapeMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
  Grabbed := False;
end;

procedure TForm1.ShapeMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
  // Bring the shape to the front
  (Sender as TShape).BringToFront;
  // Save where the mouse goes down inside this shape
  X3 := X; Y3 := Y;
  Grabbed := True;
end;

procedure TForm1.ShapeMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
begin
  if Grabbed then
    with (Sender as TShape) do
      // Move the shape to the new location
      SetBounds(Left+X-X3,Top+Y-Y3,Width,Height);
end;

procedure TForm1.PopupMenuClick(Sender: TObject);
begin
  // Change the checked item
  (Sender as TMenuItem).Checked := True;
  // Save the type of shape we selected
  ObjType := TShapeType((Sender as TMenuItem).Tag);
end;

procedure TForm1.DrawGhost;
begin
  // Draw a rubber-banding image of the object
  with Canvas do
  if ObjType in [stCircle,stEllipse] then
    Arc(X1,Y1,X2,Y2,X1,Y1,X1,Y1)
  else
    begin
      PolyLine([Point(X1,Y1),Point(X2,Y1),Point(X2,Y2)]);
      PolyLine([Point(X1,Y1),Point(X1,Y2),Point(X2,Y2)]);
    end;
end;

end.

 
Back to top
View user's profile
Kambiz
Administrator


Joined: 07 Mar 2003
Posts: 314

PostPosted: 06/02/04 20:11    Post subject: Reply with quote

Definitely the above code is much faster than SG.
I think it's faster because:
  1. It doesn't draw grids
  2. It doesn't fill the body of objects with brush or background image
  3. It doesn't draw the object's caption
  4. It doesn't calculate the intersection points of objects and links
  5. It doesn't draw markers of the selection
  6. It doesn't calculate the scroll bars' range and position

Cheers,
Kambiz
Back to top
View user's profile Send e-mail Visit poster's website
Display posts from previous:   
   Reply to topic    DELPHI AREA Forum Index -> DELPHI AREA's Products All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB 2.0.6 © 2001, 2002 phpBB Group