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: Select all
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.