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 » U++ TheIDE » U++ TheIDE: Layout (Forms) Designer » Programming for Layout Objects
Programming for Layout Objects [message #1862] Fri, 24 March 2006 04:22 Go to next message
InterKnight is currently offline  InterKnight
Messages: 4
Registered: March 2006
Location: Ohio
Junior Member

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 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 11715
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 Go to previous messageGo to next message
InterKnight is currently offline  InterKnight
Messages: 4
Registered: March 2006
Location: Ohio
Junior Member

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 #1900 is a reply to message #1899] Sat, 25 March 2006 10:35 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 11715
Registered: November 2005
Ultimate Member
Ok, here we go:

The only trouble with your code so far is that you have put definitions of your methods to .h file. Save_tot_Text, FileMenu, About, HelpMeny should be in .cpp

Now about that Cancel button:

Add Cancel method to your class:

class Jims_Medical : public WithJims_MedicalLayout<TopWindow> {
....	
	void Cancel();
....
};


define it e.g. like this (in .cpp):

void Jims_Medical::Cancel()
{
	if(PromptYesNo("Do you want to exit?"))
		Break();
}


and add this line to your constructor:

Jims_Medical::Jims_Medical()
{
......
	bttncancel <<= THISBACK(Cancel);
......
}


To read the value, use

void Jims_Medical::Next()
{
	int blood_pressure = ~txtbld_press;
	PromptOK(AsString(blood_pressure));
}


(Connect this Next to bttnnext_ent the same way as Cancel to bttncancel).

Mirek
Re: Programming for Layout Objects [message #2036 is a reply to message #1866] Thu, 30 March 2006 13:10 Go to previous messageGo to next message
gprentice is currently offline  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








Re: Programming for Layout Objects [message #2037 is a reply to message #2036] Thu, 30 March 2006 13:26 Go to previous messageGo to next message
gprentice is currently offline  gprentice
Messages: 260
Registered: November 2005
Location: New Zealand
Experienced Member
Quote:


How do you find out which operators do what for a widget.
e.g. where is the <<= operator for an EditDate declared.



With the help of slickedit Smile I see it's in the Ctrl class with overloads that take either Value or Callback.

It's not all that easy to find if it's re-defined in a derived class - for some reason, slickedit won't find me the definition of <<= when I use it in an expression e.g. EditDate d1; d1 <<= THISBACK(something);

Does Ultimate++ impressive code browsing facility allow me to jump to definition of <<= somehow, or to find it ??

Graeme
Re: Programming for Layout Objects [message #2042 is a reply to message #2037] Thu, 30 March 2006 21:51 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 11715
Registered: November 2005
Ultimate Member
gprentice wrote on Thu, 30 March 2006 06:26

Quote:


How do you find out which operators do what for a widget.
e.g. where is the <<= operator for an EditDate declared.



With the help of slickedit Smile I see it's in the Ctrl class with overloads that take either Value or Callback.

It's not all that easy to find if it's re-defined in a derived class - for some reason, slickedit won't find me the definition of <<= when I use it in an expression e.g. EditDate d1; d1 <<= THISBACK(something);

Does Ultimate++ impressive code browsing facility allow me to jump to definition of <<= somehow, or to find it ??

Graeme




Not yet, sorry...

Mirek
Re: Programming for Layout Objects [message #2060 is a reply to message #2042] Fri, 31 March 2006 01:01 Go to previous message
gprentice is currently offline  gprentice
Messages: 260
Registered: November 2005
Location: New Zealand
Experienced Member
luzr wrote on Fri, 31 March 2006 07:51

gprentice wrote on Thu, 30 March 2006 06:26

Quote:


How do you find out which operators do what for a widget.
e.g. where is the <<= operator for an EditDate declared.



With the help of slickedit Smile I see it's in the Ctrl class with overloads that take either Value or Callback.

It's not all that easy to find if it's re-defined in a derived class - for some reason, slickedit won't find me the definition of <<= when I use it in an expression e.g. EditDate d1; d1 <<= THISBACK(something);

Does Ultimate++ impressive code browsing facility allow me to jump to definition of <<= somehow, or to find it ??

Graeme




Not yet, sorry...

Mirek


Well I found a way! Query for operator<<= and it finds them all, including the ones in ::Ctrl. Not bad! (Slickedit tagging doesn't handle operator functions - I guess they're a bit of a problem).

Graeme
Previous Topic: "Edit using designer" from cpp file- nothing happens? [BUG]
Next Topic: Positioning in Designer
Goto Forum:
  


Current Time: Sat Feb 23 19:48:03 CET 2019

Total time taken to generate the page: 0.00659 seconds