|
|
Home » U++ TheIDE » U++ TheIDE: Layout (Forms) Designer » Programming for Layout Objects
Programming for Layout Objects [message #1862] |
Fri, 24 March 2006 04:22 |
|
Hello, everyone.
I've been working with U++ for just a day or so now, and I am finally on the way to creating an application for an old friend. I previously didn't think I would get this far with GUI design, but I am glad to see that I was wrong.
My question pertains to objects which can be added to the Layout GUI Editor (for example: buttons, labels, etc).
What I need to know is how to program events for buttons. A simple example would be: How would I program the "Cancel" button so that it exits the program?
I've learned how to create menus for applications (with File, View, Help, etc), but I am not yet sure exactly how to implement options.
So, just for simplicity sake, how would I add in code to tell the program that the "Cancel" button exits the program?
Thanks greatly for any help/suggestions.
Take care.
|
|
|
Re: Programming for Layout Objects [message #1866 is a reply to message #1862] |
Fri, 24 March 2006 09:45 |
|
mirek
Messages: 14039 Registered: November 2005
|
Ultimate Member |
|
|
InterKnight wrote on Thu, 23 March 2006 22:22 | Hello, everyone.
I've been working with U++ for just a day or so now, and I am finally on the way to creating an application for an old friend. I previously didn't think I would get this far with GUI design, but I am glad to see that I was wrong.
My question pertains to objects which can be added to the Layout GUI Editor (for example: buttons, labels, etc).
What I need to know is how to program events for buttons. A simple example would be: How would I program the "Cancel" button so that it exits the program?
I've learned how to create menus for applications (with File, View, Help, etc), but I am not yet sure exactly how to implement options.
So, just for simplicity sake, how would I add in code to tell the program that the "Cancel" button exits the program?
Thanks greatly for any help/suggestions.
Take care.
|
There are some very simple basic things about widgets:
If you have widget "foo": (e.g. EditField foo;)
* to assign it a value, use
foo <<= value;
* to retrieve its value, use
value = ~foo;
* to add default event, which is invoked when user changes the state of widget:
foo = callback(...)
Now those "callback(...)" can vary depending on event, however in the most common case, you will have your widget inside some dialog object class and then it will look like:
struct Dialog {
Button cancel;
void Cancel();
typedef Dialog CLASSNAME;
Dialog() {
cancel <<= THISBACK(Cancel);
}
};
Note that as of U++ 602, there is Assist++ THISBACKs... and Layout code generator.. functions that can help you to generate some of that code...
Mirek
|
|
|
Re: Programming for Layout Objects [message #1899 is a reply to message #1866] |
Sat, 25 March 2006 06:17 |
|
I'm still not exactly sure what I am doing. I am sorry...very new to GUI design methods. I am going to attach my layout, header, and main.cpp files that show where I am at. I used the layout designer to create the buttons, textboxes, labels, etc, but I don't know how to do the coding for them yet. It will take some work to get the Next Entry>> and the Done buttons to do what I need them to do (add input information to an array of class MedicalDAta for NextEntry>> and send all input information to a formatted .rtf file formatted into columns). I think that if I start off simple by seeing how to program the Cancel button, I can go from there.
This is my first GUI application, and here is a bit of background on it:
A close friend of mine has Type-2 diabetes. He is in his late 50s and has poor sight. He has to put information into a text file (date, blood pressure, etc) daily. He knows very little about how to use computers, and he manually formats his text file by spacing out his columns and everything else along those lines. It takes him hours to do what he needs to do. I want to write this program so that he can just fill in the information for the labels (Date, Blood pressure, etc), click Next Entry>> (if he has more than one day’s worth of information), or just Cancel out of the application. What I want to do is create a class called MedicalData which will be declared as an array (MedicalData dataArray[x] which will store the values for each entry. When the Done button is clicked, all of those entries would be sent out to an .rtf file and formatted nicely into columns. I think this would make life a lot easier for my friend (he is like a father to me), and I want to do what I can…so this is my first project and I think it will be a milestone for me.
Any suggestions?
Thanks for the help.
The layout editor is very amazing!
Take care.
PS: All source files are in a 7-Zip (.7z) archive.
|
|
|
|
Re: Programming for Layout Objects [message #2036 is a reply to message #1866] |
Thu, 30 March 2006 13:10 |
gprentice
Messages: 260 Registered: November 2005 Location: New Zealand
|
Experienced Member |
|
|
luzr wrote on Fri, 24 March 2006 20:45 |
InterKnight wrote on Thu, 23 March 2006 22:22 | Hello, everyone.
I've been working with U++ for just a day or so now, and I am finally on the way to creating an application for an old friend. I previously didn't think I would get this far with GUI design, but I am glad to see that I was wrong.
My question pertains to objects which can be added to the Layout GUI Editor (for example: buttons, labels, etc).
What I need to know is how to program events for buttons. A simple example would be: How would I program the "Cancel" button so that it exits the program?
I've learned how to create menus for applications (with File, View, Help, etc), but I am not yet sure exactly how to implement options.
So, just for simplicity sake, how would I add in code to tell the program that the "Cancel" button exits the program?
Thanks greatly for any help/suggestions.
Take care.
|
There are some very simple basic things about widgets:
If you have widget "foo": (e.g. EditField foo;)
* to assign it a value, use
foo <<= value;
* to retrieve its value, use
value = ~foo;
* to add default event, which is invoked when user changes the state of widget:
foo = callback(...)
Now those "callback(...)" can vary depending on event, however in the most common case, you will have your widget inside some dialog object class and then it will look like:
struct Dialog {
Button cancel;
void Cancel();
typedef Dialog CLASSNAME;
Dialog() {
cancel <<= THISBACK(Cancel);
}
};
Note that as of U++ 602, there is Assist++ THISBACKs... and Layout code generator.. functions that can help you to generate some of that code...
Mirek
|
Mirek - you have written above that <<= is used to assign foo a value - but the Button widget uses <<= to assign a callback.
On the "whetting your appetite" web page you have this
Days::Days()
{
CtrlLayout(*this, "Days");
date1 <<= THISBACK(Compute);
date2 <<= THISBACK(Compute);
}
where date1 is an EditDate.
How do you find out which operators do what for a widget.
e.g. where is the <<= operator for an EditDate declared.
Graeme
|
|
|
|
|
|
Goto Forum:
Current Time: Fri Sep 20 15:51:09 CEST 2024
Total time taken to generate the page: 0.03622 seconds
|
|
|