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 » 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 Go to next message
nejnadusho is currently offline  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 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

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 #37722 is a reply to message #37712] Mon, 05 November 2012 19:46 Go to previous messageGo to next message
nejnadusho is currently offline  nejnadusho
Messages: 60
Registered: October 2012
Member
Honza,

First thank you very much for trying helping me again.



Quote:

Honza wrote on Mon, 05 November 2012 01:06

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.


I want to avoid multiple windows popping up. Not in this app I am trying to develop.



I tried this and it does not work.
It does not even display any of the layers.

I tried similar approaches on my own and non of the worked.

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();
		}
};





Also I believe I get the sense what you are trying to achieve with the code above, though, I think this way would not really achieve derived layout but just a switch of the layouts.


I really need to have the base layout like a permanent and the derided layer(s) to overlap with it but not switch.

Exactly like the this Example Derived Layout and the very similar example I posted.

Though to be able to show and hide them which is not possible in those examples.




Best,

nejnio
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 Go to previous messageGo to next message
dolik.rce is currently offline  dolik.rce
Messages: 1789
Registered: August 2008
Location: Czech Republic
Ultimate Contributor

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 Smile

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 Smile

Best regards,
Honza
Re: Derived Layouts Show/Hide & Run/Close in the Same Window [message #37738 is a reply to message #37712] Wed, 07 November 2012 15:36 Go to previous message
nejnadusho is currently offline  nejnadusho
Messages: 60
Registered: October 2012
Member
Honza,

That is exactly what I was trying to achieve.


Thank you very much for your help.

All the best,
nejnio
Previous Topic: TabDlg Change Default Background Window
Next Topic: UserClass Layout Placeholder
Goto Forum:
  


Current Time: Sat May 04 01:46:39 CEST 2024

Total time taken to generate the page: 0.01836 seconds