Home » Community » Newbie corner » Switching layout inside class
Switching layout inside class [message #48442] |
Tue, 04 July 2017 11:12  |
rafiwui
Messages: 105 Registered: June 2017 Location: Stuttgart, Germany
|
Experienced Member |
|
|
I can't find a possibility to change the layout of a window inside the window class.
So what I want to do is kind of the following:
1. I have two layouts defined in the .lay file
2. I have a class that inherits from TopWindow
3. For this example I add two buttons to my window in the constructor
4. If I press button 1 I want to change the layout to the first layout and if I press button 2 it should show me layout 2.
But I don't want another window to open up!
So I expected it to be something like this:
OnClickButton1()
{
WithLayout1<TopWindow> layout1;
SetLayout_Layout1(layout1, true, true);
}
OnClickButton2()
{
WithLayout2<TopWindow> layout2;
SetLayout_Layout1(layout1, true, true);
}
Result: the application starts but no layout is shown.
And after inspecting the lay.h file I know why this does not work.
So my second thought then was the following:
OnClickButton1()
{
WithLayout1<TopWindow> layout1;
SetLayout_Layout1(*this, layout1, true, true);
}
OnClickButton2()
{
WithLayout2<TopWindow> layout2;
SetLayout_Layout1(*this, layout1, true, true);
}
But same thing as before: the layout doesn't show up.
But is there any way to do sth like this?
Is the problem the <TopWindow> that i use as template class when creating the parent object?
Or do I have to write another macro like the ones currently inside the lay.h file?
Probably this macro would look like this: (not tested)
#define LAYOUT(nm, x, y) template<class T> inline void SetLayoutThis_##nm(T& parent, bool add = false, bool show = false) {
#define UNTYPED(var, param) parent.var.param; if(add) Add(parent.var); if(show) parent.var.Show();
#define ITEM(class, var, param) UNTYPED(var, param);
#define END_LAYOUT }
#include LAYOUTFILE
// undef everything
Greetings
Daniel
[Updated on: Tue, 04 July 2017 11:12] Report message to a moderator
|
|
|
Goto Forum:
Current Time: Sun May 11 15:49:42 CEST 2025
Total time taken to generate the page: 0.02709 seconds
|