Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Community » Newbie corner » chess like drag&drop possible in u++ ?
icon7.gif  chess like drag&drop possible in u++ ? [message #28801] Fri, 17 September 2010 11:02 Go to next message
kenton is currently offline  kenton
Messages: 4
Registered: September 2010
Location: Italy
Junior Member
Hello,

my first post on this forum, hoping to do a good impression Rolling Eyes
i choosed u++ for develop a school timetable scheduling application.
Like in a chess board i want to drag&drop an image that is a simple colorized square into a grid (the timatable) like pieces over the chess board.
It's my first GUI with this kind of features and i have no idea about the approach to do it.
I need only the more sensed way that you will follow in my situation.
For example: "you have to draw the timetable structure with opengl then u move simple images over it and in order to realize a drag&drop where the image follow the mouse cursor you have to ... etc."
Hope don't asking too much, because i need a poin to begin with a way that give me the first direction of my efforts.

Thanks you all.
Have a good day.

Andrea
Re: chess like drag&drop possible in u++ ? [message #28840 is a reply to message #28801] Sun, 19 September 2010 10:45 Go to previous messageGo to next message
dolik.rce is currently offline  dolik.rce
Messages: 1789
Registered: August 2008
Location: Czech Republic
Ultimate Contributor

Hi Andrea!

Welcome to the forum Wink

I was hoping someone more skilled with the DnD will answer you, but since nobody did, I'll try myself. So, sorry it took so long. Hopefully someone corrects me if I make some mistakes.

Doing drag and drop apps is of course possible in U++, and it is not really difficult. The biggest problem is lack of documentation, but hopefully this example will help you.

What you have to do is to create your own widget, inherited from Ctrl (or some other widget, if you want to reuse some code and save some typing) and override few virtual methods that deal with the DnD. Absolute minimum is to implement LeftDrag() and DragAndDrop(). The first is taking care of the dragging and is called when you start dragging. It should contain call to DoDragAndDrop() which waits till you drop and let you perform any necessary cleanup. The second function, DragAndDrop is taking care of accepting the dragged item. It is called over and over again, until you drop the item.

I attach a simple example, hopefully it will help you. I left there LOG calls so you can get better idea of how the functions are called (you can view the log by pressing Alt+L after running the app).

Don't be afraid to ask if you need more details, there is always someone willing to answer in this forum Wink

Best regards,
Honza
  • Attachment: dnd.zip
    (Size: 1.56KB, Downloaded 206 times)
Re: chess like drag&drop possible in u++ ? [message #28841 is a reply to message #28840] Sun, 19 September 2010 12:50 Go to previous messageGo to next message
kenton is currently offline  kenton
Messages: 4
Registered: September 2010
Location: Italy
Junior Member
Thanks You Honza !!

It's 1 hour that i'm tring to make working your example
and now i'm able to make a new assembly correctly in order to compile your code Smile
Can seem stupid but for the first u++ program it isn't Razz

Well, your answer is very clear and now i will do the first run !
For the lack of documentation i hope that this thread will be a point to start if i decide to realize my project in u++.
I will try to write down my learning steps from my beginner point of view.

In another forum a user advice me to work in codeblocks + wxwidgets + gtk
I think that my choose have to consider my needs:
- cross-platform
- license allows commercial use
- semplicity

There is something that i can not do in u++ ?


Re: chess like drag&drop possible in u++ ? [message #28842 is a reply to message #28841] Sun, 19 September 2010 12:53 Go to previous messageGo to next message
kenton is currently offline  kenton
Messages: 4
Registered: September 2010
Location: Italy
Junior Member
OMG++ !!

I runned the example,
it's exactly what i need ! Shocked
Wonderful ...
I start to analize the code following your advices ...

[Updated on: Sun, 19 September 2010 12:53]

Report message to a moderator

Re: chess like drag&drop possible in u++ ? [message #28843 is a reply to message #28841] Sun, 19 September 2010 13:40 Go to previous messageGo to next message
dolik.rce is currently offline  dolik.rce
Messages: 1789
Registered: August 2008
Location: Czech Republic
Ultimate Contributor

kenton wrote on Sun, 19 September 2010 12:50

Thanks You Honza !!

It's 1 hour that i'm tring to make working your example
and now i'm able to make a new assembly correctly in order to compile your code Smile
Can seem stupid but for the first u++ program it isn't Razz

Well, your answer is very clear and now i will do the first run !
For the lack of documentation i hope that this thread will be a point to start if i decide to realize my project in u++.
I will try to write down my learning steps from my beginner point of view.

In another forum a user advice me to work in codeblocks + wxwidgets + gtk
I think that my choose have to consider my needs:
- cross-platform
- license allows commercial use
- semplicity

There is something that i can not do in u++ ?

The directory in zip corresponds to a package, just unpacking it into MyApps (which is usually created automatically on install) is enough to get it available in TheIDE. The learning curve in U++ is pretty steep, but rest assured, that what now takes you an hour will take you a minute in just a few weeks Wink

About your needs: BSD license is very permissive. There should be no problems with that. Simplicity is hard to define Smile U++ is definitely not simple in terms of its internals. But it allows to write very simple application code. Also very fast (both to write and to run) Wink The cross-platform support means win32 (XP to 7, 98 not officially supported but still working), Linux and BSD. The Mac OS X support is not ready yet, but some people are working on it.

U++ allows you to do anything you can think of Wink Usually in fast and reliable way. Also the community is great and gives a great support.

I'm glad to hear you got the example working and that it is what you meant. BTW: Notice that it is less than 100 lines of code - that is what I call simplicity Wink

Honza
Re: chess like drag&drop possible in u++ ? [message #28845 is a reply to message #28843] Sun, 19 September 2010 14:12 Go to previous messageGo to next message
kenton is currently offline  kenton
Messages: 4
Registered: September 2010
Location: Italy
Junior Member
Yes, the first day is the first day but i made some simple applications in codeblocks + wxwidgets so ...

The simplicity of this example amazed me !!

I have some questions:
- It's possible to view and edit the .lay file ?
- In the example we have a 2x2 matrix of "Tile" class, overrided from "ctrl" one. In my application the matrix will be nXn dependent to parameters gived by user runtime. So my question is: this 2x2 scheme is fixed or can be changed continuously runtime ?
I'm right thinking that i need something more graphic like? Maybe like the .lay display area of the "TheIDE". That display can show whatever we want and we can interact with it too.

Andrea
Re: chess like drag&drop possible in u++ ? [message #28846 is a reply to message #28845] Sun, 19 September 2010 14:37 Go to previous message
dolik.rce is currently offline  dolik.rce
Messages: 1789
Registered: August 2008
Location: Czech Republic
Ultimate Contributor

kenton wrote on Sun, 19 September 2010 14:12

The simplicity of this example amazed me !!
U++ still amazes me too, even after couple of years of using it Smile

kenton wrote on Sun, 19 September 2010 14:12

- It's possible to view and edit the .lay file ?
That's what is layout editor in theide for. Just open the file and you should see a graphical representation of the layout (if you see only text, try pressing Alt+T). Here you can add/remove/manipulate widgets as you wish. Have a look at the GUI tutorial, it should explain a lot.

kenton wrote on Sun, 19 September 2010 14:12

- In the example we have a 2x2 matrix of "Tile" class, overrided from "ctrl" one. In my application the matrix will be nXn dependent to parameters gived by user runtime. So my question is: this 2x2 scheme is fixed or can be changed continuously runtime ?
Yes the widgets can be added/removed/changed at runtime as you wish. You can start with layout from .lay file and modify it in the code, or you can build everything in code. For this app, you probably won't use the lay file for the grid, it was just an example. There are even other choices, like having another widget that would represent the grid (containing and managing the variable number of Tiles), so you would then put only this "master-widget" into the layout. The possibilities are endless in U++ Wink

If you wan't something like the layout editor, it is of course possible. After all, the layout editor is written in U++ as well Smile My guess is that you don't need it to be that complex, so maybe a context menu with options like "add box" would be sufficient... But you are the designer and you choose how you want the app to behave. U++ is very flexible and will let you do anything.

Honza
Previous Topic: Debugger: access to global variables.
Next Topic: TreeCtrl: How to...?
Goto Forum:
  


Current Time: Sat Apr 27 19:58:55 CEST 2024

Total time taken to generate the page: 0.05309 seconds