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 » Problem in example code (Tried SplitterFrame yet minor problem.)
Problem in example code [message #45720] Tue, 29 December 2015 15:53 Go to next message
vegaonline is currently offline  vegaonline
Messages: 35
Registered: December 2015
Location: Mumbai, India
Member

I tried to run SplitterFrame demo code as shown in URL http://www.ultimatepp.org/reference$SplitterFrame1$en-us.htm l. I see place to put GUI widgets while I may need to see the code.
How can I see layout code?

Thanks and Regards
Abhijt
Re: Problem in example code [message #45721 is a reply to message #45720] Tue, 29 December 2015 16:06 Go to previous messageGo to next message
Klugier is currently offline  Klugier
Messages: 1075
Registered: September 2012
Location: Poland, Kraków
Senior Contributor
Hello one more time Smile,

From the last stable version (9251 and up) we introduce new buttons that change the file view/edit mode. You can find them on TheIDE menu bar (Edit as text, Edit using designer, View as hex). Probably more information you will find on screen-shot posted below:

index.php?t=getfile&id=4904&private=0

I strongly believe that we need to describe menu bar functionality in our documentation.

Sincerely,
Klugier


U++ - one framework to rule them all.

[Updated on: Tue, 29 December 2015 16:08]

Report message to a moderator

Re: Problem in example code [message #45722 is a reply to message #45721] Tue, 29 December 2015 16:13 Go to previous messageGo to next message
dolik.rce is currently offline  dolik.rce
Messages: 1789
Registered: August 2008
Location: Czech Republic
Ultimate Contributor

Also, there is Ctrl+T shortcut. But the idea is that you shouldn't really need this. You can either compose your GUI using the editor (with *.lay file), or do it in your code (in *.cpp). But you should never edit *.lay files "manualy" in their text form.
Re: Problem in example code [message #45724 is a reply to message #45722] Tue, 29 December 2015 17:25 Go to previous messageGo to next message
vegaonline is currently offline  vegaonline
Messages: 35
Registered: December 2015
Location: Mumbai, India
Member

@Klugier

Hi!

Thanks a lot for the prompt and perfect help. Now I can see layout text.

@dolik.rce
Hi!

Thanks for the remark. However, I am confused with your statement. If I can edit .lay file why can't I edit it in their text form?
For example I want to put a StaticText or label specifying foreground and background color. GUI editor shows only foreground color or INK COLOR.
How can I do this?

Wish all of you Happy New Year

Best,
Abhijit
Re: Problem in example code [message #45726 is a reply to message #45724] Tue, 29 December 2015 19:31 Go to previous messageGo to next message
dolik.rce is currently offline  dolik.rce
Messages: 1789
Registered: August 2008
Location: Czech Republic
Ultimate Contributor

vegaonline wrote on Tue, 29 December 2015 17:25
Thanks for the remark. However, I am confused with your statement. If I can edit .lay file why can't I edit it in their text form?


Well, that you can do something doesn't really mean you should Smile If you modify the file in such a way that the editor in TheIDE will not understand it anymore, you might loose some information. I never actually tried that, so maybe the editor is clever enough to prevent this, but I wouldn't rely on it... The only reasonable situation where I would consider editing .lay file in its text form is when I wanted to do some Find&Replace to rename a bunch of widgets or some similar task that would be too tedious to do in the editor.

vegaonline wrote on Tue, 29 December 2015 17:25

For example I want to put a StaticText or label specifying foreground and background color. GUI editor shows only foreground color or INK COLOR.
How can I do this?

Things that can't be done in GUI editor are usually done in code. It is actually quite simple, e.g. to change the text of StaticText programatically:
#include <CtrlLib/CtrlLib.h>
using namespace Upp;

#define LAYOUTFILE <MyApp/MyApp.lay>
#include <CtrlCore/lay.h>

class MyWindow : public WithMyLayout<TopWindow> {
	typedef MyWindow CLASSNAME;

public:
	MyWindow(){
		CtrlLayout(*this, "");
		MyStaticText.SetText("MyText");
	}

};

The exact case you ask for, changing background color, is actually kind of tricky Smile There is nothing like SetBackgroundColor method, but it is possible to change the background of the text itself. StaticText and many other widgets support QTF. It might look scary, but there is a nice editor in TheIDE (press Alt+Q). So to set The background of your text to blue, you'd do this:
MyStaticText.SetText(t_("\1[$(0.0.255) Test]")
The "\1" at the beginning denotes that the string should be treated as QTF, see the documentation here.

Honza
Re: Problem in example code [message #45734 is a reply to message #45726] Thu, 31 December 2015 07:14 Go to previous messageGo to next message
vegaonline is currently offline  vegaonline
Messages: 35
Registered: December 2015
Location: Mumbai, India
Member

Thanks for the explanation.

I am sorry asking too many and silly questions. Please consider me as a learner who likes to clear confusion. Although the concept and implement of U++ is superb, "theide" is also great! I am surprised to see why I did not find this tool before!


1. I find that upp.out directory contains all the upp related staff and ~/MyApps/Testing contains all .cpp, .lay and .h files. If I want to build an application and like to run on some other machine not having Upp or other staffs installed, how can I do it? I found that in my machine, I can run executable file Testing built at ~/upp.out/MyApps/GCC.Debug.Debug_Full.Gui.Shared/.

2. Can I plot mathematical graphs etc.? Can I use codes with matplotlib in python or U++ has own widgets?

I am making a GUI for my App which is a small scientific application for my experimental device which needs a menu while one menu item shall open a small panel in same window to input text and data, while the other panel in the same window shall erase earlier panel and may plot some files in 2D, 3D, contour etc.

Best,
Abhijit
Re: Problem in example code [message #45736 is a reply to message #45734] Thu, 31 December 2015 13:58 Go to previous messageGo to next message
dolik.rce is currently offline  dolik.rce
Messages: 1789
Registered: August 2008
Location: Czech Republic
Ultimate Contributor

vegaonline wrote on Thu, 31 December 2015 07:14
Thanks for the explanation.

I am sorry asking too many and silly questions. Please consider me as a learner who likes to clear confusion. Although the concept and implement of U++ is superb, "theide" is also great! I am surprised to see why I did not find this tool before!

You are welcome. Everyone on this forum knows that U++ has pretty steep learning curve and that the documentation doesn't always make everything clear. So the newbies are expected to ask many questions, and there is also many people willing to answer.

vegaonline wrote on Thu, 31 December 2015 07:14
1. I find that upp.out directory contains all the upp related staff and ~/MyApps/Testing contains all .cpp, .lay and .h files. If I want to build an application and like to run on some other machine not having Upp or other staffs installed, how can I do it? I found that in my machine, I can run executable file Testing built at ~/upp.out/MyApps/GCC.Debug.Debug_Full.Gui.Shared/.
Yes, all the intermediate files (object files and libraries) are stored in upp.out (or whatever path you configure). The resulting binary is by default stored there to, but this can be easily changed. Just go to Build -> Output mode and there is a field labeled "Target file override" (actually there is two of them, one for debug mode and for release). If you check the checkbox there, TheIDE will create the binary with the path and name specified in the corresponding input field.

All you need to do to run any U++ program on other machine is to copy this single binary. Often it works out of the box, but sometimes there might be some libraries that are not installed on the other machine, but that is usually pretty easy to figure out and fix just by installing them using distribution packages. It might also happen that the other machine contains some of those libraries in version incompatible with those on the machine used to build your app, in which case it is bit harder to fix and it might be actually easier to just install theide and compile your package from source Smile

vegaonline wrote on Thu, 31 December 2015 07:14
2. Can I plot mathematical graphs etc.? Can I use codes with matplotlib in python or U++ has own widgets?
Check ScatterCtrl package.

vegaonline wrote on Thu, 31 December 2015 07:14
I am making a GUI for my App which is a small scientific application for my experimental device which needs a menu while one menu item shall open a small panel in same window to input text and data, while the other panel in the same window shall erase earlier panel and may plot some files in 2D, 3D, contour etc.
That should be a piece of cake in U++ Smile For multiple windows at once, see part 6 of GUI tutorial. For 2D plots, there is already mentioned Scatter package and for 3D, there is GlCtrl. Together, you should be able to do what you need.

Honza
Re: Problem in example code [message #45743 is a reply to message #45736] Thu, 31 December 2015 18:31 Go to previous messageGo to next message
vegaonline is currently offline  vegaonline
Messages: 35
Registered: December 2015
Location: Mumbai, India
Member

Thanks a lot.

I have seen GU Tut 6. I want a menu at the top. Depending on the menu item, panels need to be opened in the same window in stead of separate windows
erasing contents of earlier items.

Best,
Abhijit

[Updated on: Thu, 31 December 2015 18:36]

Report message to a moderator

Re: Problem in example code [message #45749 is a reply to message #45743] Fri, 01 January 2016 20:07 Go to previous messageGo to next message
dolik.rce is currently offline  dolik.rce
Messages: 1789
Registered: August 2008
Location: Czech Republic
Ultimate Contributor

vegaonline wrote on Thu, 31 December 2015 18:31
I have seen GU Tut 6. I want a menu at the top. Depending on the menu item, panels need to be opened in the same window in stead of separate windows erasing contents of earlier items.

Oh, ok. That is actually even simpler Smile You can represent each panel using ParentCtrl (or WithMyLayout<ParentCtrl>, when using .lay file). This way you can Add and Remove multiple widgets (that is your 'panel') at once easily. For more customizable interface, you can also use Splitter Wink

Honza
Re: Problem in example code [message #45760 is a reply to message #45749] Sat, 02 January 2016 22:39 Go to previous messageGo to next message
vegaonline is currently offline  vegaonline
Messages: 35
Registered: December 2015
Location: Mumbai, India
Member

@HONZA,

Thanks for kindly guiding me.

I am trying to use ParentCtrl, while I am facing problem.

I am attaching required files. The initial screen is OK. When I press "Configure", I want "CardLayout1" is to be shown which is not coming.
By the by, please ignore many commented lines as I am learner.

Please guide me.
  • Attachment: Abhijit.tgz
    (Size: 2.67KB, Downloaded 192 times)

[Updated on: Sat, 02 January 2016 22:40]

Report message to a moderator

Re: Problem in example code [message #45769 is a reply to message #45760] Sun, 03 January 2016 12:57 Go to previous messageGo to next message
dolik.rce is currently offline  dolik.rce
Messages: 1789
Registered: August 2008
Location: Czech Republic
Ultimate Contributor

vegaonline wrote on Sat, 02 January 2016 22:39
@HONZA,

Thanks for kindly guiding me.

I am trying to use ParentCtrl, while I am facing problem.

I am attaching required files. The initial screen is OK. When I press "Configure", I want "CardLayout1" is to be shown which is not coming.
By the by, please ignore many commented lines as I am learner.

Please guide me.


Hi Abhijit,

The only part you were missing is adding and removing the ParentCtrl as necessary. The two functions called from menu should do something like this:
void Testing::doConfig() {
	doPlot.Remove();
	Add(doCard);
}

void Testing::doGeom() {
	doCard.Remove();
	Add(doPlot);
}


Also, the menu should be added using AddFrame, which you probably already tried, I've seen it in one of the comments Smile It makes things much easier when switching the layouts, sinco you don't have to care about it's position. I have modified the sources and attach them for your reference.
Re: Problem in example code [message #45773 is a reply to message #45769] Sun, 03 January 2016 14:41 Go to previous messageGo to next message
vegaonline is currently offline  vegaonline
Messages: 35
Registered: December 2015
Location: Mumbai, India
Member

Great ! I understand. Thanks a lot.

However, I may reach Plot menu from any other menu item having separate layout except card menu. Should I use ".Remove() for all other different layout or there is any single Remove command to remove all other layout which may be present there?
Best,
Abhijit
Re: Problem in example code [message #45780 is a reply to message #45773] Sun, 03 January 2016 21:08 Go to previous messageGo to next message
dolik.rce is currently offline  dolik.rce
Messages: 1789
Registered: August 2008
Location: Czech Republic
Ultimate Contributor

vegaonline wrote on Sun, 03 January 2016 14:41

However, I may reach Plot menu from any other menu item having separate layout except card menu. Should I use ".Remove() for all other different layout or there is any single Remove command to remove all other layout which may be present there?

There are ways to access the all the children of given Ctrls and to iterate through them. See GetFirstChild(), GetNext(), GetChildIndex(), GetIndexChild(), GetChildCount() and related functions in Ctrl documentation. In your particular case it would probably be ok just to call GetLasChild()->Remove(). But I never actually needed to use such a low level approach in my apps and it feels kind of error prone to me.

There is actually much simpler way: You can just remember your last state Smile For example, you can add Ctrl* active to your class (don't forget to initialize it to NULL in constructor, otherwise you'll get crashes Wink ), and then use a method like this for the switching:
void Testing::SetLayout(Ctrl* ctrl) {
	if (active)
		active->Remove();
	Add(*ctrl);
	active = ctrl;
}
Your menu code could then be as simple as this:
		menu.Add("Configure", THISBACK1(SetLayout, &doCard)).Help("Edit Simulation Setup");
		menu.Add("Geometry", THISBACK1(SetLayout, &doPlot)).Help("Edit Experimental Geometry");
That is of course assuming there is no special initialization for each layout needed on each switch, in which case you would have to still call doConfig() and doGeom() from menu and they would in turn call the common switching code in SetLayout.

Honza
Re: Problem in example code [message #45782 is a reply to message #45780] Mon, 04 January 2016 13:59 Go to previous messageGo to next message
vegaonline is currently offline  vegaonline
Messages: 35
Registered: December 2015
Location: Mumbai, India
Member

[quote title=dolik.rce wrote on Mon, 04 January 2016 01:38]vegaonline wrote on Sun, 03 January 2016 14:41

		menu.Add("Configure", THISBACK1(SetLayout, &doCard)).Help("Edit Simulation Setup");
		menu.Add("Geometry", THISBACK1(SetLayout, &doPlot)).Help("Edit Experimental Geometry");
That is of course assuming there is no special initialization for each layout needed on each switch, in which case you would have to still call doConfig() and doGeom() from menu and they would in turn call the common switching code in SetLayout.

Honza


Hi the idea is superb. However, I am getting the following error for the above code:
index.php?t=getfile&id=4916&private=0

Pl. advise.

Thanks and Regards
Abhijit
  • Attachment: ABHI_Err.jpg
    (Size: 106.75KB, Downloaded 832 times)
Re: Problem in example code [message #45784 is a reply to message #45782] Mon, 04 January 2016 14:47 Go to previous messageGo to next message
dolik.rce is currently offline  dolik.rce
Messages: 1789
Registered: August 2008
Location: Czech Republic
Ultimate Contributor

You are passing the functions (doConfig, doGeom) instead of the ParentCtrls (doCard, doPlot) Wink

Honza
Re: Problem in example code [message #45786 is a reply to message #45784] Mon, 04 January 2016 17:21 Go to previous messageGo to next message
vegaonline is currently offline  vegaonline
Messages: 35
Registered: December 2015
Location: Mumbai, India
Member

dolik.rce wrote on Mon, 04 January 2016 19:17
You are passing the functions (doConfig, doGeom) instead of the ParentCtrls (doCard, doPlot) Wink

Honza



You are Great! Thanks a lot. Sorry for the silly mistake.
Re: Problem in example code [message #45787 is a reply to message #45786] Mon, 04 January 2016 21:10 Go to previous messageGo to next message
vegaonline is currently offline  vegaonline
Messages: 35
Registered: December 2015
Location: Mumbai, India
Member

HI!

I have another very peculiar problem. I wanted to make a simple layout like before by adding a new layout. While build is performed, I get an error
 In file included from /home/vega/MyApps/honza/Testing/main.cpp:1:0:
/home/vega/MyApps/honza/Testing/Testing.h:15:2: error: 'WithPltLayout1' does
     not name a type
  WithPltLayout1<ParentCtrl>doGeo;
  ^


I cleaned and tried to re-build, while getting the same error.

Thanks and Regards
Abhiit
Re: Problem in example code [message #45789 is a reply to message #45787] Mon, 04 January 2016 21:23 Go to previous messageGo to next message
dolik.rce is currently offline  dolik.rce
Messages: 1789
Registered: August 2008
Location: Czech Republic
Ultimate Contributor

vegaonline wrote on Mon, 04 January 2016 21:10
I wanted to make a simple layout like before by adding a new layout. While build is performed, I get an error
 In file included from /home/vega/MyApps/honza/Testing/main.cpp:1:0:
/home/vega/MyApps/honza/Testing/Testing.h:15:2: error: 'WithPltLayout1' does
     not name a type
  WithPltLayout1<ParentCtrl>doGeo;
  ^

Hard to say without seeing the actual code. Few thigns to check:
  • Is there really layout called PltLayout1? Check for typos...
  • Is it in the .lay file that is properly included in Testing.h (using #define LAYOUTFILE <Testing/xyz.ly> with #include CtrlCore/lay.h following)?
  • Is there some syntax error preceding this line, that would make your compiler report this as an error, while it is actually correct?

Honza
Re: Problem in example code [message #45840 is a reply to message #45789] Tue, 12 January 2016 12:04 Go to previous messageGo to next message
vegaonline is currently offline  vegaonline
Messages: 35
Registered: December 2015
Location: Mumbai, India
Member

Hi!

I have two very silly problems which I could not fix as per my satisfaction.

In my code I have menus and one of them is plot. In this plot menu I have a layout in which there is a droplist entry with name "pltType". I tried many ways yet I could not put any option there.

Next, how can I read a data file and use for plotting using scatterCtrl? I find that LoadFromFile reads in string. How can I put Serialize?

Thanks and Regards
Abhijit
  • Attachment: Testing.tgz
    (Size: 3.93KB, Downloaded 183 times)
Re: Problem in example code [message #45844 is a reply to message #45840] Tue, 12 January 2016 13:57 Go to previous messageGo to previous message
koldo is currently offline  koldo
Messages: 3355
Registered: August 2008
Senior Veteran
Hello Abhijit

For the ScatterCtrl the best for you would be to open ScatterCtrl_demo and reading for example tab1_Basic.cpp.

For example you can declare a Vector<Pointf> data in a safe place (as a class member, for example), fill it with the data from your file and do this:

void Tab1_Basic::Init()
{
	CtrlLayout(*this);	
	SizePos();
	
	data << Pointf(10, 26) << Pointf(20, 37) << Pointf(30, 31) << Pointf(40, 33) << Pointf(50, 28);
	scatter.AddSeries(data).Legend("Series 1").Fill().MarkBorderColor();
	
	scatter.SetRange(60, 50).SetMajorUnits(10, 10);
	scatter.ShowInfo().ShowContextMenu().ShowPropertiesDlg().SetPopText("h", "v", "v2").SetMouseHandling(true, true);
	scatter.SetLegendPos(Point(20, 20));
}


Best regards
Iñaki
Previous Topic: Issues using 2015.2 version
Next Topic: How to build FREBSD *.so in Windows?
Goto Forum:
  


Current Time: Thu Mar 28 22:49:56 CET 2024

Total time taken to generate the page: 0.01711 seconds