|
|
Home » Community » Newbie corner » Help needed.
Help needed. [message #27331] |
Mon, 12 July 2010 18:28 |
281264
Messages: 270 Registered: June 2010 Location: Spain
|
Experienced Member |
|
|
Hi,
I am struggling with this dummy application I am creating. The objective is to draw lines in the application’s screen after the user has selected “line” by clicking in its corresponding button.
Allow me to explain what I have done:
1.- I have created a struct containing a menu with three buttons-only button “line” does something.
2.- I have added a SplitterFrame and put the previous struct in its left. This allows me to have the application’s window for drawing.
3.- Functionality: once the user has selected “line” from the menu the screen shows mouse coordinates. Then the user clicks again and anchors one point of the line; after a second click the line is drawn on the screen; so far so good.
4.- However, in the next steps, I am finding some problems:
a.- the last coordinates remains in the screen after line creation process; how to get rid off it?
b.- My intention is to store all the lines in a container, so they can be redraw every time is needed. So far, I am using C++ vectors. I have created a struct –line- for contain lines (with four variables). The first problem arises when I try to create a line in my application: it does not compile. Second is the usage of vectors or U++ vectors. What to use? In general, is it allow to use the STL in U++?.
Many thanks,
Javier
|
|
|
|
Re: Help needed. [message #27337 is a reply to message #27331] |
Tue, 13 July 2010 00:21 |
|
koldo
Messages: 3371 Registered: August 2008
|
Senior Veteran |
|
|
281264 wrote on Mon, 12 July 2010 18:28 | Hi,
I am struggling with this dummy application I am creating. The objective is to draw lines in the application’s screen after the user has selected “line” by clicking in its corresponding button.
Allow me to explain what I have done:
1.- I have created a struct containing a menu with three buttons-only button “line” does something.
2.- I have added a SplitterFrame and put the previous struct in its left. This allows me to have the application’s window for drawing.
3.- Functionality: once the user has selected “line” from the menu the screen shows mouse coordinates. Then the user clicks again and anchors one point of the line; after a second click the line is drawn on the screen; so far so good.
4.- However, in the next steps, I am finding some problems:
a.- the last coordinates remains in the screen after line creation process; how to get rid off it?
b.- My intention is to store all the lines in a container, so they can be redraw every time is needed. So far, I am using C++ vectors. I have created a struct –line- for contain lines (with four variables). The first problem arises when I try to create a line in my application: it does not compile. Second is the usage of vectors or U++ vectors. What to use? In general, is it allow to use the STL in U++?.
Many thanks,
Javier
|
Hello Javier
1. I have renamed "line" struct to "myline". line name seems not to be good for a struct.
4.a I have added this to handle mouse up:
void ejemplo_splitter::LeftUp(Point p,dword d) {
if(!ended) {
ended = 1;
Refresh();
}
}
And Paint begin like this:
void ejemplo_splitter::Paint(Draw& draw)
{
draw.DrawRect(GetSize(),White());
now it works.
4.b About vectors or other containers I use U++ ones. Read for example this http://www.ultimatepp.org/srcdoc$Core$NTLvsSTL$en-us.html or this http://www.ultimatepp.org/srcdoc$Core$Tutorial$en-us.html
Best regards
Iñaki
|
|
|
|
Re: Help needed. [message #27348 is a reply to message #27346] |
Tue, 13 July 2010 13:57 |
|
281264 wrote on Tue, 13 July 2010 13:02 | An additional question, how can a modify the mouse’s cursor when, for instance, the user is drawing a line?.
|
Just pass the new cursor image to OverrideCursor() in LeftUp. And don't forget to put the original (usually Image::Arrow(), I think) back in, using the same method, when the line is finished.
Honza
|
|
|
Re: Help needed. [message #27349 is a reply to message #27348] |
Tue, 13 July 2010 14:48 |
mrjt
Messages: 705 Registered: March 2007 Location: London
|
Contributor |
|
|
That's not the best solution IMO. You should override CursorImage on your drawing ctrl instead:
virtual Image CursorImage(Point p, dword keyflags) {
if (drawing)
return Image::Cross();
else
return Image::Arrow();
}
[Updated on: Tue, 13 July 2010 14:48] Report message to a moderator
|
|
|
Re: Help needed. [message #27350 is a reply to message #27349] |
Tue, 13 July 2010 15:04 |
|
mrjt wrote on Tue, 13 July 2010 14:48 | That's not the best solution IMO. You should override CursorImage on your drawing ctrl instead
|
Thanks mrjt, didn't even know about this method. I still learn
Honza
|
|
|
Goto Forum:
Current Time: Sat Jun 01 06:04:30 CEST 2024
Total time taken to generate the page: 0.02052 seconds
|
|
|