Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Feb 6th, 2010, 6:11 AM   #11
abdul.gafur
Trying to be a Real Coder
 
abdul.gafur's Avatar
 
Join Date: Feb 2010
Location: Bandung, Indonesia
Posts: 109
Rep Power: 1 abdul.gafur is on a distinguished road
Send a message via Yahoo to abdul.gafur
Re: Drag and drop shape

Oke, InsyaAllah.

Can we resize the shape?
__________________
just a drop of dew in the morning

if we facilitate other people's business in the world,
then our business will be facilitated in the world and the hereafter
abdul.gafur is online now   Reply With Quote
Old Feb 6th, 2010, 6:18 AM   #12
alienkinetics
Programmer
 
alienkinetics's Avatar
 
Join Date: Jan 2010
Location: Australia
Posts: 56
Rep Power: 1 alienkinetics is on a distinguished road
Re: Drag and drop shape

The code supports resizing and prevents the shape from being resized below 32 x 32 pixels.
alienkinetics is offline   Reply With Quote
Old Feb 6th, 2010, 6:54 AM   #13
alienkinetics
Programmer
 
alienkinetics's Avatar
 
Join Date: Jan 2010
Location: Australia
Posts: 56
Rep Power: 1 alienkinetics is on a distinguished road
Re: Drag and drop shape

here is the project files. I'd add all the little "tricks" that will help you. ie: scrollbars and locking the cursor to control.

This should be a solid base for you. There is no compiled code here, so its virus safe. Just check the code first so you know its not bad.

Workflow.zip
alienkinetics is offline   Reply With Quote
Old Feb 6th, 2010, 7:06 AM   #14
abdul.gafur
Trying to be a Real Coder
 
abdul.gafur's Avatar
 
Join Date: Feb 2010
Location: Bandung, Indonesia
Posts: 109
Rep Power: 1 abdul.gafur is on a distinguished road
Send a message via Yahoo to abdul.gafur
Re: Drag and drop shape

Chat with you very helpful.
I've tried your program.
__________________
just a drop of dew in the morning

if we facilitate other people's business in the world,
then our business will be facilitated in the world and the hereafter
abdul.gafur is online now   Reply With Quote
Old Feb 7th, 2010, 9:37 AM   #15
abdul.gafur
Trying to be a Real Coder
 
abdul.gafur's Avatar
 
Join Date: Feb 2010
Location: Bandung, Indonesia
Posts: 109
Rep Power: 1 abdul.gafur is on a distinguished road
Send a message via Yahoo to abdul.gafur
Re: Drag and drop shape

I've a problem. How to create line that can be "drag and drop"?
__________________
just a drop of dew in the morning

if we facilitate other people's business in the world,
then our business will be facilitated in the world and the hereafter
abdul.gafur is online now   Reply With Quote
Old Feb 7th, 2010, 1:02 PM   #16
alienkinetics
Programmer
 
alienkinetics's Avatar
 
Join Date: Jan 2010
Location: Australia
Posts: 56
Rep Power: 1 alienkinetics is on a distinguished road
Re: Drag and drop shape

O, thats a little more complex.

To fit into the current system Ive given you, I would either make a new TWorkflowShape, or split TWorkflowShape in 2 and derive one from the other.

What you are looking for is the "shape" and "dragging" functionality in the subclass, and then the higher class to implement the grips and resizing. That said, you might prefer just to copy TWorkflowShape and hack it.

Anyway, a line is just two shapes with a connector between them. So, once you have the connector system extended to support more than one connector, I would implement a line as being two shapes that look like "grips" with a connector between them. The issue here is, each line grip needs to know the other so when you click on one of the grips, both will BringToFront().

Anyway... (I say that a lot) the next step would be to detect when a line grip is moved over a shape grip, in which case, you would destroy the line grip and set the connect or the grip of the shape in question.

Which then leaves the question of, how do you disconnect? Um, Id use a double click. So, when you double click a shapes grip that has a connector assigned to it, you create a new line grip and set the connector to that. the new line grip needs to be offset from the shapes grip so they dont over lap. (Thats only one idea, you might choose a TPopupMenu to select disconnect.

Finally, diagonal connectors dont really look that good. I would halve the width and height of the box defined by the connector. Then based on the smallest size, I would draw either "Horz, Vert, Horz, Vert" or "Vert, Horz, Vert, Horz". hope that makes sence.

You then need to look into arrows. they are pretty simple. Basic vector maths.

Hope that helps. Get the connector code finished and worry about the line code later.

Like I said, its a large task. There is also the "point on line" code you need to look into if you want to select a line by clicking on it.

Arrrrrr, More coding

Last edited by alienkinetics; Feb 7th, 2010 at 1:26 PM.
alienkinetics is offline   Reply With Quote
Old Feb 7th, 2010, 1:29 PM   #17
alienkinetics
Programmer
 
alienkinetics's Avatar
 
Join Date: Jan 2010
Location: Australia
Posts: 56
Rep Power: 1 alienkinetics is on a distinguished road
Re: Drag and drop shape

Btw, I would also put that array of grips (that is currently global) in the class itself, or at least have it selectable. That way, for shapes like ellipses and diamonds, you wouldn't show the corner grips.

you also need to look into TNotifyEvent's if you haven't done so already. A big mistake is if you access the main form from your code libraries. It gets very messy that way.

Make up some simple OnShapeSelected OnShapeMoved OnShapeResized OnShapeAdded, OnShapeDelete events.

In the main form, you use these to get messages that you use to update the user interface. ie: Have a dialog panel on the left that has the current shapes text, location, color, type, etc.

Anyway, I have tons of ideas. Sing if you need more help.
alienkinetics is offline   Reply With Quote
Old Feb 7th, 2010, 11:59 PM   #18
abdul.gafur
Trying to be a Real Coder
 
abdul.gafur's Avatar
 
Join Date: Feb 2010
Location: Bandung, Indonesia
Posts: 109
Rep Power: 1 abdul.gafur is on a distinguished road
Send a message via Yahoo to abdul.gafur
Re: Drag and drop shape

argh, my final assignment very confusing.

alien, how to return something from workflow class to main form (unitmain)?

return value from child to parent.
__________________
just a drop of dew in the morning

if we facilitate other people's business in the world,
then our business will be facilitated in the world and the hereafter
abdul.gafur is online now   Reply With Quote
Old Feb 8th, 2010, 12:43 AM   #19
alienkinetics
Programmer
 
alienkinetics's Avatar
 
Join Date: Jan 2010
Location: Australia
Posts: 56
Rep Power: 1 alienkinetics is on a distinguished road
Quote:
alien, how to return something from workflow class to main form (unitmain)?
I recommend you use this method. Its professional and will help you distribute functionality across multiple source files in such a way that prevents "code clogging". ie: a build up of code that strangles itself.

Here we have a class and a simple method. The class has a notify event pointer that other code can tap into. Note, when calling the event, the "sender" is set to the "self" of the current object.

Quote:
TTestClass = class
OnTestEvent: TNotifyEvent;
procedure DoSomething;
end;
procedure TTestClass.DoSomething;
begin
/// Do some stuff here
if Assigned(OnTestEvent) then OnTestEvent(Self);
/// And maybe some stuff here
end;
In our main form we create the class and set the OnTestEvent to our event method. In MyTestEvent, AObject will be the object that sent the notification event. You typecast this to access the TTestClass object.

Quote:
procedure TFormMain.FormCreate(Sender: TObject);
var A: TTestClass;
begin
A := TTestClass.Create;
A.OnTestEvent := MyTestEvent;
end;

procedure TFormMain.MyTestEvent(AObject: TObject);
begin
end;
Hope that answers your question. If you haven't used TNotifyEvent's before and are reaching a deadline, then I dont blame people for just accessing the main form directly, but you can end up with some nasty code.
alienkinetics is offline   Reply With Quote
Old Feb 8th, 2010, 10:56 AM   #20
abdul.gafur
Trying to be a Real Coder
 
abdul.gafur's Avatar
 
Join Date: Feb 2010
Location: Bandung, Indonesia
Posts: 109
Rep Power: 1 abdul.gafur is on a distinguished road
Send a message via Yahoo to abdul.gafur
Re: Drag and drop shape

oke, thanks for your answers.

Sorry, I'm too captious. My job should be completed within 1 month. .

I want to show a form {popup} so that the name of shape can be inserted through this form. This form is displayed when we double click the shape. But, I can't make double click event (shape). Is there any advice?
__________________
just a drop of dew in the morning

if we facilitate other people's business in the world,
then our business will be facilitated in the world and the hereafter
abdul.gafur is online now   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
popup with drag and drop wont work. RareDevil JavaScript and Client-Side Browser Scripting 1 Mar 7th, 2009 4:52 PM
Drag and Drop Text in C# BstrucT C# 2 May 12th, 2008 9:29 AM
Drag n' Drop tayspen C# 2 Oct 22nd, 2005 3:46 PM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 12:35 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC