 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Mr. X Guest
|
Posted: Wed Nov 17, 2004 9:43 am Post subject: To Peter Below |
|
|
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
|
Posted: Wed Nov 17, 2004 6:32 pm Post subject: Re: To Peter Below |
|
|
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
|
Posted: Thu Nov 18, 2004 8:24 am Post subject: Re: To Peter Below |
|
|
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
|
Posted: Sat Nov 20, 2004 9:43 am Post subject: Re: To Peter Below |
|
|
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
|
Posted: Sat Nov 20, 2004 7:18 pm Post subject: Re: To Peter Below |
|
|
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 |
|
 |
|
|
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
|
|