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 » U++ Library support » U++ Widgets - General questions or Mixed problems » Add layouts/ParentCtrl to column list
Add layouts/ParentCtrl to column list [message #48487] Fri, 07 July 2017 10:51 Go to next message
rafiwui is currently offline  rafiwui
Messages: 105
Registered: June 2017
Location: Stuttgart, Germany
Experienced Member
I want to make a selection screen where you can select different "pages" of my app.
I tried to add my WithTestLayout<ParentCtrl> members to the column list like this:

ColumnList columnList;
WithTestLayout<ParentCtrl> layout;

columnList.Add(layout);


The compiler then tells me that he can't convert WithTestLayout<ParentCtrl> to const Upp::Value& (I guessed that before compiling but better try)
So my question is: Is there a way to achieve this or do I have to write my own ParentCtrlList?

Greetings
Daniel


Greetings
Daniel
Re: Add layouts/ParentCtrl to column list [message #48493 is a reply to message #48487] Mon, 10 July 2017 04:14 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3355
Registered: August 2008
Senior Veteran
Hello Daniel

ColumnList shows a series of texts in a list.
If you want to use it to show "pages" of your app similar to using a TabCtrl, you could:
- do a layout including the ColumnList and a StaticRect to host all pages.
- put all pages in an Array.
- Add() all pages to that StaticRect with SizePos() to fill it.
- use ColumnList::WhenSel() to Hide() all pages and Show() the one you want. You would do it using a for() through all pages in previous Array.


Best regards
IƱaki
Re: Add layouts/ParentCtrl to column list [message #48507 is a reply to message #48493] Tue, 11 July 2017 09:35 Go to previous messageGo to next message
rafiwui is currently offline  rafiwui
Messages: 105
Registered: June 2017
Location: Stuttgart, Germany
Experienced Member
So basically you mean it like this I guess (of course with the array and the list but this is good to show):

LAYOUT(Test1, 250, 70)
	ITEM(Label, dv___0, SetLabel(t_("Layout 1")).SetAlign(ALIGN_CENTER).SetFont(StdFontZ(20).Bold()).LeftPosZ(25, 200).TopPosZ(10, 50))
END_LAYOUT

LAYOUT(Test2, 250, 70)
	ITEM(Label, dv___0, SetLabel(t_("Layout 2")).SetAlign(ALIGN_CENTER).SetFont(StdFontZ(20).Bold()).LeftPosZ(25, 200).TopPosZ(10, 50))
END_LAYOUT

LAYOUT(MainLayout, 400, 200)
	ITEM(StaticRect, viewport, LeftPosZ(50, 300).TopPosZ(30, 100))
	ITEM(Button, button1, SetLabel(t_("Layout 1")).LeftPosZ(100, 75).TopPosZ(150, 30))
	ITEM(Button, button2, SetLabel(t_("Layout 2")).RightPosZ(100, 75).TopPosZ(150, 30))
END_LAYOUT


#include <CtrlLib/CtrlLib.h>
using namespace Upp;

#define LAYOUTFILE <main/layouts.lay>
#include <CtrlCore/lay.h>

class MyWindow : public WithMainLayout<TopWindow>
{
public:
	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();
	viewport.Add(layout1);
	viewport.Add(layout2);
	layout1.SizePos();
	layout2.SizePos();
	
	button1 << THISBACK(OnClickButton1);
	button2 << THISBACK(OnClickButton2);
}

void MyWindow::OnClickButton1()
{
	Title("Layout 1");
	layout1.Show();
	layout2.Hide();
}

void MyWindow::OnClickButton2()
{
	Title("Layout 2");
	layout1.Hide();
	layout2.Show();
}

GUI_APP_MAIN
{
	MyWindow app;
	CtrlLayout(app);
	app.SetRect(0, 0, Zx(400), Zy(200));
	app.Run();
}


But this does not work because the layouts are not centered/filling the StaticRect completely.
Can you tell me why and/or how to achieve this?


Greetings
Daniel
Re: Add layouts/ParentCtrl to column list [message #48711 is a reply to message #48487] Sat, 26 August 2017 13:27 Go to previous message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
rafiwui wrote on Fri, 07 July 2017 10:51

The compiler then tells me that he can't convert WithTestLayout<ParentCtrl> to const Upp::Value& (I guessed that before compiling but better try)
So my question is: Is there a way to achieve this or do I have to write my own ParentCtrlList?

Greetings
Daniel


ColumnList can, at this moment, only contain Values, not widgets.

If multiple columns are not important for you, you might consider using ArrayCtrl and ArrayCtrl::SetCtrl (that puts general widget into ArrayCtrl cell).
Previous Topic: [BUG] Patch to Switch.cpp to support touch screens
Next Topic: [Closed] Get size and position of widget
Goto Forum:
  


Current Time: Thu Mar 28 14:18:34 CET 2024

Total time taken to generate the page: 0.00923 seconds