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 » Multi Layout App
Multi Layout App [message #37519] Sun, 14 October 2012 05:43 Go to next message
nejnadusho is currently offline  nejnadusho
Messages: 60
Registered: October 2012
Member
Hi,

I am obviously a newbie and am attempting to create GUI of an app.
I have read many posts on the forum on the topic of multi layouts on a single window.

However, I still have no understanding of how the magic of using many layouts on a single window happens.

Would anyone please!?!?!

Is there one kind person that can post an actual working code and include the full content of the .lay, .cpp, and, .h, where at least two layouts are being used for example swapped/switched in a clicking event or anything like that?

And if hopefully there is a person that does dare Smile to attempt the above please let Non of the names of the layouts be anything like the .lay file's name or project's name or .cpp file's name.

Thank you very much for your time.

Best,
Re: Multi Layout App [message #37540 is a reply to message #37519] Mon, 15 October 2012 18:21 Go to previous messageGo to next message
nejnadusho is currently offline  nejnadusho
Messages: 60
Registered: October 2012
Member
index.php?t=getfile&id=3895&private=0


OK I already have the following code. In fact I had it before the first post.

Now I thought that one that might help would want to see some effort.

I have tried all kinds of stuff out of the forums and tutorials cant make it work yet.




.h File
#ifndef _SProject_SProject_h
#define _SProject_SProject_h

#include <CtrlLib/CtrlLib.h>

using namespace Upp;

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



class SProject : public WithSProjectLayout<TopWindow> {
	
	
public:	
	typedef SProject CLASSNAME;
	SProject();
};


#endif



.cpp File

#include "SProject.h"


SProject::SProject()
{	
	CtrlLayout(*this, "Window title");
	Sizeable().Zoomable();	
	
}




GUI_APP_MAIN
{
	SProject().Run();
}



.lay File

LAYOUT(SProjectLayout, 704, 524)
	ITEM(Button, logInButton, SetLabel(t_("LogInButton\aLogIn")).SetFont(StdFontZ(18).Bold().Italic()).SetFrame(FieldFrame()).LeftPosZ(304, 104).TopPosZ(420, 32))
	ITEM(EditField, LogInTxtBox, MaxChars(18).SetFont(StdFontZ(14)).SetFrame(FieldFrame()).WantFocus(false).LeftPosZ(268, 168).TopPosZ(292, 28))
	ITEM(Label, usernameBox, SetLabel(t_("\"UsernameBoxLabel\aUsername ")).SetFont(StdFontZ(12).Italic()).LeftPosZ(268, 164).TopPosZ(296, 21))
	ITEM(StaticText, dv___3, SetText(t_("Restaurant’s Easy One Solution")).SetFont(SansSerifZ(20).Bold()).LeftPosZ(192, 332).TopPosZ(104, 36))
	ITEM(StaticText, dv___4, SetText(t_("Welcome")).SetAlign(ALIGN_CENTER).SetFont(SansSerifZ(20).Bold()).LeftPosZ(184, 332).TopPosZ(64, 19))
	ITEM(StaticText, dv___5, SetText(t_("to")).SetAlign(ALIGN_CENTER).SetFont(SansSerifZ(20).Bold()).LeftPosZ(332, 40).TopPosZ(84, 19))
	ITEM(EditField, dv___6, SetFrame(FieldFrame()).WantFocus(false).LeftPosZ(268, 168).TopPosZ(324, 27))
	ITEM(Label, passwordBox, SetLabel(t_("Password")).SetFont(StdFontZ(12).Italic()).LeftPosZ(268, 125).TopPosZ(328, 21))
END_LAYOUT

LAYOUT(Page1, 400, 200)
	ITEM(Button, Button1, SetLabel(t_("Back")).SetFont(StdFont().Bold()).SetFrame(FieldFrame()).LeftPosZ(160, 56).TopPosZ(96, 15))
END_LAYOUT



How can I do the trick to display the Page1 layout when I click the 'LogIn' Button and display back the SProjectLayout when I click the 'Back' button.

Again I have been looking at alot of posts and tutorials etc. there is no clear description or at least I cannot grasp it.

Please add the 2-3-4 lines of code for the .h and.cpp files that will make this scenario work.

Thank you a lot.

nejnio
Re: Multi Layout App [message #37542 is a reply to message #37519] Mon, 15 October 2012 19:54 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 nejnio

While it is possible to switch layouts in a running application, it is not something you would really need very often. In most cases, yours included, it is much easier to just use two windows. It is fairly easy to coordinate them in such way, that only one is visible at any time. E.g.:
struct Logged : public WithTestLayout2<TopWindow> {
	typedef Logged CLASSNAME;
	
	Logged() {
		Title("Logged in").Sizeable();
		CtrlLayout(*this);
		back <<= THISBACK(Close);
	}
};

struct App : public WithTestLayout<TopWindow> {
	typedef App CLASSNAME;
	
	void Login(){
		Hide();
		Logged().Execute();
		Show();
	}
	
	App() {
		Title("Test").Sizeable();
		CtrlLayout(*this);
		login <<= THISBACK(Login);
	}
};

GUI_APP_MAIN{
	App().Run();
};
(Full source is included in the attachment.)

Best regards,
Honza
  • Attachment: guitest.zip
    (Size: 1.00KB, Downloaded 167 times)
Re: Multi Layout App [message #37543 is a reply to message #37542] Mon, 15 October 2012 20:58 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
dolik.rce wrote on Mon, 15 October 2012 13:54


While it is possible to switch layouts in a running application, it is not something you would really need very often.


Anyway, it IS possible:

http://www.ultimatepp.org/reference$SetLayout$en-us.html

Mirek
Re: Multi Layout App [message #37544 is a reply to message #37543] Mon, 15 October 2012 21:41 Go to previous messageGo to next message
BioBytes is currently offline  BioBytes
Messages: 307
Registered: October 2008
Location: France
Senior Member
Hello all friends,

Just to add I agree with Honza: I prefer to build 2 different windows for better controlling the development and making the source code easier to handle.

Regards

Biobytes
Re: Multi Layout App [message #37545 is a reply to message #37543] Mon, 15 October 2012 22:28 Go to previous messageGo to next message
dolik.rce is currently offline  dolik.rce
Messages: 1789
Registered: August 2008
Location: Czech Republic
Ultimate Contributor

mirek wrote on Mon, 15 October 2012 20:58

dolik.rce wrote on Mon, 15 October 2012 13:54


While it is possible to switch layouts in a running application, it is not something you would really need very often.


Anyway, it IS possible:

http://www.ultimatepp.org/reference$SetLayout$en-us.html

Mirek

I know, I already used it in past... I just wanted to point out that it is usually better to re-think the problem, as there is very little problems that really require this Wink

Honza
Re: Multi Layout App [message #37636 is a reply to message #37545] Mon, 29 October 2012 23:48 Go to previous message
nejnadusho is currently offline  nejnadusho
Messages: 60
Registered: October 2012
Member
Honza,

Thank you very much for your help once again.

nejnio
Previous Topic: Report & sch file
Next Topic: error LNK2019 when using CtrlLib/CtrlLib.h
Goto Forum:
  


Current Time: Sat Apr 27 09:37:20 CEST 2024

Total time taken to generate the page: 0.04381 seconds