|
|
Home » Community » Newbie corner » Derived Layouts Show/Hide & Run/Close in the Same Window
Derived Layouts Show/Hide & Run/Close in the Same Window [message #37712] |
Sun, 04 November 2012 21:41 |
nejnadusho
Messages: 60 Registered: October 2012
|
Member |
|
|
Hi,
I am trying to achieve to be able to Show/Hide and Run/Execute/Close derived layouts(!not windows!) in the same window.
I need the Show/Hide option because I would want to be able to keep the state of the layouts while working on another layout.
Currently I am trying the following:
.h File
class Base : public WithBaseLayout<TopWindow> {
public:
typedef Base CLASSNAME;
Base();
void DisplayDerived1();
private:
};
class Derived1 : public WithDerived1Layout<Base>{
public:
Derived1();
typedef Derived1 CLASSNAME;
};
main.cpp File
Base::Base()
{
CtrlLayout(*this, "Window title");
push1 <<= THISBACK(DisplayDerived1);
}
void Base::DisplayDerived1(){
Derived1 der1;
der1.Execute();
}
Derived1::Derived1(){
SetLayout_Derived1Layout(*this, true);
}
GUI_APP_MAIN
{
Base().Run();
}
With the code above I achieve every time I run the derived class a new window pops up.
The only thing I can do is to close the old window and kill whatever is going on that layout(window in the current case).
This is not efficient for my application.
However, I need derived layouts because I would allays need the base layout's features together with one at a time of any of the derived layouts.
Having said that I also find difficult to figure out how to Run/Execute all the classes so they can keep parallel separate states at the same time.
Any help is greatly appreciated.
If clarification needed please let me know.
Best,
nejnio
|
|
|
Re: Derived Layouts Show/Hide & Run/Close in the Same Window [message #37715 is a reply to message #37712] |
Mon, 05 November 2012 07:06 |
|
Hi nejnio
What about something like this (note: I haven't tested the code, but I believe it should work):
class App : public TopWindow {
WithBaseLayout<ParentCtrl> base;
WithDerivedLayout<ParentCtrl> derived;
public:
typedef App CLASSNAME;
Base() {
Add(base.SizePos());
Add(derived.SizePos());
derived.Hide();
}
void DisplayBase(){
base.Show();
derived.Hide();
}
void DisplayDerived(){
base.Hide();
derived.Show();
}
};
There is one more level in the Ctrl hierarchy, but everything is in one window. Note that instead of Show/Hide, you can also use Add/Remove (e.g. Add(derived); Remove(base); to display derived) because Ctrls retain state even when removed.
Regarding the parallel execution: have a look at the GUI manual, paragraph 6. It shows the most general way of running multiple windows at once, with freedom to close any of them without terminating the application and to use them in any order and combination.
Best regards,
Honza
|
|
|
|
Re: Derived Layouts Show/Hide & Run/Close in the Same Window [message #37732 is a reply to message #37712] |
Tue, 06 November 2012 19:43 |
|
Sorry nejnio,
Seems like I kind of misunderstood the problem, my mistake. Also, there were some mistakes in the code I posted, sorry for that too. I hope I got it all right this time
Attached is a code of an example application allowing to dynamically change part of your layout, while keeping the "base" constant. It is not using inheritance, so it is not really derived layouts, but the design part stays the same and the general idea of not repeating the same thing over and over in each layout holds too. I believe that you also want to keep the state of the "base part" constant when switching the "variable parts".
The general idea is same as what I proposed in my last post, showing and hiding the parts as desired. I think it is quite easy to read the code, so I won't go in to details here... If you find something unclear, just ask
Best regards,
Honza
|
|
|
|
Goto Forum:
Current Time: Tue May 21 19:13:08 CEST 2024
Total time taken to generate the page: 0.02608 seconds
|
|
|