Home » Community » Newbie corner » Switching layout inside class
Re: Switching layout inside class [message #48451 is a reply to message #48445] |
Tue, 04 July 2017 13:13 |
Oblivion
Messages: 1093 Registered: August 2007
|
Senior Contributor |
|
|
Hello,
Quote:
Do I have to do sth with the layout1? Like layout1.Show()? Or Give it a size?
And which of the two SetLayout... is the correct one to use?
One way of doing it wil be as follows (or something along these lines should work. I can't test it at the moment, I don't have access to TheIDE now:
#include <CtrlLib/CtrlLib.h>
using namespace Upp;
#define LAYOUTFILE <main/layouts.lay>
#include <CtrlCore/lay.h>
class MyWindow : public TopWindow
{
public:
Button button1;
Button button2;
WithTest1<ParentCtrl> layout1;
WithTest2<ParentCtrl> layout2;
typedef MyWindow CLASSNAME;
MyWindow();
private:
void OnClickButton1();
void OnClickButton2();
};
MyWindow::MyWindow()
{
CtrlLayout(layout1);
CtrlLayout(layout2);
layout1.Hide();
layout2.Hide();
Add(layout1); // You should set its size or position. E.g. layout1.SizePos() will cover the window's work area.
Add(layout2); // You should set its size or position. E.g. layout2.SizePos() will cover the window's work area.
button1.SetLabel("Button 1").LeftPosZ(10, 100).TopPosZ(20, 30);
button2.SetLabel("Button 2").RightPosZ(10, 100).TopPosZ(20, 30);
button1 << THISBACK(OnClickButton1);
button2 << THISBACK(OnClickButton2);
Add(button1);
Add(button2);
}
void MyWindow::OnClickButton1()
{
Title("Layout 1");
layout1.Show();
layout2.Hide();
}
void MyWindow::OnClickButton2()
{
Title("Layout 2");
layout2.Show();
layout1.Hide();
}
GUI_APP_MAIN
{
MyWindow app;
app.SetRect(0, 0, Zx(250), Zy(70));
app.Run();
}
Best regards,
Oblivion.
Github page: https://github.com/ismail-yilmaz
upp-components: https://github.com/ismail-yilmaz/upp-components
Bobcat the terminal emulator: https://github.com/ismail-yilmaz/Bobcat
[Updated on: Tue, 04 July 2017 13:14] Report message to a moderator
|
|
|
Goto Forum:
Current Time: Mon Apr 29 14:17:22 CEST 2024
Total time taken to generate the page: 0.03122 seconds
|