Home » Community » Newbie corner » Multi Layout App
|
Re: Multi Layout App [message #37540 is a reply to message #37519] |
Mon, 15 October 2012 18:21   |
nejnadusho
Messages: 60 Registered: October 2012
|
Member |
|
|

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   |
|
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 210 times)
|
|
|
|
|
Re: Multi Layout App [message #37545 is a reply to message #37543] |
Mon, 15 October 2012 22:28   |
|
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 
Honza
|
|
|
|
Goto Forum:
Current Time: Tue Apr 29 01:49:32 CEST 2025
Total time taken to generate the page: 0.01745 seconds
|