BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

To Peter Below

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Graphics
View previous topic :: View next topic  
Author Message
Mr. X
Guest





PostPosted: Wed Nov 17, 2004 9:43 am    Post subject: To Peter Below Reply with quote



Hi,
This is regarding that drag-drop panel example you showed me earleier and
posted to John Lennart ...
there's this final thing .... how do i know the "Index" of the dragged panel
?
Assuming the indexes are actually the Tag nos. incremented during runtime
creation of panels, if panel0 (bottom most) is dragged midway, how can i
know the current position amongst other panels ?
Regards


Back to top
Peter Below (TeamB)
Guest





PostPosted: Wed Nov 17, 2004 6:32 pm    Post subject: Re: To Peter Below Reply with quote



In article <419a7434 (AT) newsgroups (DOT) borland.com>, Mr. X wrote:
Quote:
This is regarding that drag-drop panel example you showed me earleier and
posted to John Lennart ...
there's this final thing .... how do i know the "Index" of the dragged panel
?
Assuming the indexes are actually the Tag nos. incremented during runtime
creation of panels, if panel0 (bottom most) is dragged midway, how can i
know the current position amongst other panels ?

You add all the panels to a TList, sort the TList by the Top values of the
panels, then look for the one that was dragged in the sorted list.


// Needs to be standalone, not a method!
function CompareByTop(Item1, Item2: Pointer): Integer;
begin
Result := TPanel(Item1).Top - TPanel(Item2.Top);
{Note: this is reasonably safe, with the Top values we can expect
no overflow with mess up the result.}
end;

// can be a method of the form but does not need to be
function IndexOfPanel(aPanel: TPanel ): Integer;
var
List: TList;
I: Integer;
begin
List:= TList.Create;
try
for i:= 0 to aPanel.Parent.Controlcount-1 do
if aPanel.Parent.Controls[I] is TPanel then
List.Add( aPanel.Parent.Controls[I] );
List.Sort(CompareByTop);
Result := List.Indexof(aPanel);
Assert(Result <> -1); // postcondition
finally
List.Free
end;
end;

Untested!

--
Peter Below (TeamB)
Use the newsgroup archives :
http://www.mers.com/searchsite.html
http://www.tamaracka.com/search.htm
http://groups.google.com
http://www.prolix.be



Back to top
Mr. X
Guest





PostPosted: Thu Nov 18, 2004 8:24 am    Post subject: Re: To Peter Below Reply with quote



Thanks a lot .. ill get on with it right away ...

"Peter Below (TeamB)" <100113.1101 (AT) compuXXserve (DOT) com> wrote

Quote:
In article <419a7434 (AT) newsgroups (DOT) borland.com>, Mr. X wrote:
This is regarding that drag-drop panel example you showed me earleier
and
posted to John Lennart ...
there's this final thing .... how do i know the "Index" of the dragged
panel
?
Assuming the indexes are actually the Tag nos. incremented during
runtime
creation of panels, if panel0 (bottom most) is dragged midway, how can i
know the current position amongst other panels ?

You add all the panels to a TList, sort the TList by the Top values of the
panels, then look for the one that was dragged in the sorted list.


// Needs to be standalone, not a method!
function CompareByTop(Item1, Item2: Pointer): Integer;
begin
Result := TPanel(Item1).Top - TPanel(Item2.Top);
{Note: this is reasonably safe, with the Top values we can expect
no overflow with mess up the result.}
end;

// can be a method of the form but does not need to be
function IndexOfPanel(aPanel: TPanel ): Integer;
var
List: TList;
I: Integer;
begin
List:= TList.Create;
try
for i:= 0 to aPanel.Parent.Controlcount-1 do
if aPanel.Parent.Controls[I] is TPanel then
List.Add( aPanel.Parent.Controls[I] );
List.Sort(CompareByTop);
Result := List.Indexof(aPanel);
Assert(Result <> -1); // postcondition
finally
List.Free
end;
end;

Untested!

--
Peter Below (TeamB)
Use the newsgroup archives :
http://www.mers.com/searchsite.html
http://www.tamaracka.com/search.htm
http://groups.google.com
http://www.prolix.be





Back to top
Jon Lennart Aasenden
Guest





PostPosted: Sat Nov 20, 2004 9:43 am    Post subject: Re: To Peter Below Reply with quote

Peter..

Your dragging code works great when all the panels are aligned - but totally
killed my "designer" stuff when i implemented it..

I guess i might ask again since you seem to know a lot about this -
How the heck can i emulate a delphi-ish layout system?
Im in the virge of paiting the darn stuff at this point - but i have seen a
lot of programs that does this the proper way.

What i am looking for:
1. I can add controls to a TCustomControl or TCustomPanel decendant
2. Move them around, size them, align then
3. swap aligned controls (optional)
4. draw the size boxes on the controls (just use the DC or a wincontrol?)

Jon Lennart Aasenden

"Mr. X" <mail (AT) no (DOT) spam> wrote

Quote:
Hi,
This is regarding that drag-drop panel example you showed me earleier and
posted to John Lennart ...
there's this final thing .... how do i know the "Index" of the dragged
panel
?
Assuming the indexes are actually the Tag nos. incremented during runtime
creation of panels, if panel0 (bottom most) is dragged midway, how can i
know the current position amongst other panels ?
Regards





Back to top
Peter Below (TeamB)
Guest





PostPosted: Sat Nov 20, 2004 7:18 pm    Post subject: Re: To Peter Below Reply with quote

In article <419f11a4 (AT) newsgroups (DOT) borland.com>, Jon Lennart Aasenden wrote:
Quote:
Your dragging code works great when all the panels are aligned - but totally
killed my "designer" stuff when i implemented it..

I've lost the original context, sorry.
Quote:
I guess i might ask again since you seem to know a lot about this -
How the heck can i emulate a delphi-ish layout system?
Im in the virge of paiting the darn stuff at this point - but i have seen a
lot of programs that does this the proper way.

You can use a controls OnMouse events to move it interactively. Hijacking the
Windows window moving code does not do if you need to move TGraphicControls
descendents as well or more than one TWinControl. If you want to implement a
snap-to-grid feature do the snap operation only after the user did let go of
the mouse. That is the simplest method. If you want to have the control snap
to a layout grid while it is moved it gets a bit more complicated since you
have to "unsnap" the control from the current grid location after the mouse
has moved more than a certain threshold count of pixels.
Quote:

What i am looking for:
1. I can add controls to a TCustomControl or TCustomPanel decendant
2. Move them around, size them, align then
3. swap aligned controls (optional)
4. draw the size boxes on the controls (just use the DC or a wincontrol?)

Quite a bit of work if you want to implement it all yourself. Of course you
are not the first trying to do that, there are existing solutions for all or
some of the problems around. I hope at least some of the following URLs are
still valid.

TStretchHandle http://www.torry.ru/index.htm, at the Authors's page
under S for Scott, Anthony.
TControlSizer http://community.borland.com/homepages/dsp/index.htm
http://www.simes.clara.co.uk/delphi/ctrlsize.htm
DDH by Marco Cantu has an example,
download DDh3Code.zip from
http://www.marcocantu.com/ddh/default.htm
Part II, Chapter 8 "Advanced Window Components",
DdhSizer.pas. And how to use it ..SizeCompSizeDemo.dpr.
TSizeControl http://rpi.net.au/~ajohnson/delphi/

Run-time form designer and OI:
http://www.dreamcompany.com/
http://www.devexpress.com
http://www.greatis.com


--
Peter Below (TeamB)
Use the newsgroup archives :
http://www.mers.com/searchsite.html
http://www.tamaracka.com/search.htm
http://groups.google.com
http://www.prolix.be



Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Graphics 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


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.