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 » Resizing a GUI object?
Resizing a GUI object? [message #48747] Sun, 10 September 2017 07:31 Go to next message
ptkacz is currently offline  ptkacz
Messages: 84
Registered: March 2017
Member
Hi Guys,

When we create a U++ APP, a layout is created. For example, if our APP is named SimpleAPP, the layout SimpleAPPLayout gets created.

Within the SimpleApp class header file, the class gets defined as,
class SimpleAPP : public WithSimpleAPPLayout<TopWindow> {...

We might also define some private member variables:
DrawCanvas canvas;
WithButtonLayout<ParentCtrl> buttonPanel;

Within main.cpp, the mail GUI body looks as follows:
GUI_APP_MAIN
{
	SimpleAPP().Run();
}

Within the SimpleAPP constructor, our APP is defined as follows:
SimpleAPP::SimpleAPP()
{
	CtrlLayout(*this, "Simple APP");
	Sizeable();
	canvas.SetRect(100, 0, 600, 500 );

	CtrlLayout(buttonPanel);
	buttonPanel.someButton << THISBACK(doSomething);
	
	Add(buttonPanel);
	Add(canvas);
	BackPaint();	
}


When the APP's window gets resized or maxed, the Paint method of our APP's class gets called (i.e. void Paint(Draw& w)). I can retrieve a layouts size, etc. for example:
Size sz2 = buttonPanel.GetSize();

This can be done for other components (i.e. canvas). The width of the buttonPanel can be accessed as, sz2.cx.

How can one set the size of a widget since a SetSize method does not appear to exist? In this case, it would be liked for the buttonPanel to remain the same size, but have the canvas be resized to fill the remaining space.


Peter




Re: Resizing a GUI object? [message #48748 is a reply to message #48747] Sun, 10 September 2017 08:27 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 11991
Registered: November 2005
Ultimate Member
ptkacz wrote on Sun, 10 September 2017 07:31
Hi Guys,

When we create a U++ APP, a layout is created. For example, if our APP is named SimpleAPP, the layout SimpleAPPLayout gets created.

Within the SimpleApp class header file, the class gets defined as,
class SimpleAPP : public WithSimpleAPPLayout<TopWindow> {...

We might also define some private member variables:
DrawCanvas canvas;
WithButtonLayout<ParentCtrl> buttonPanel;

Within main.cpp, the mail GUI body looks as follows:
GUI_APP_MAIN
{
	SimpleAPP().Run();
}

Within the SimpleAPP constructor, our APP is defined as follows:
SimpleAPP::SimpleAPP()
{
	CtrlLayout(*this, "Simple APP");
	Sizeable();
	canvas.SetRect(100, 0, 600, 500 );

	CtrlLayout(buttonPanel);
	buttonPanel.someButton << THISBACK(doSomething);
	
	Add(buttonPanel);
	Add(canvas);
	BackPaint();	
}


When the APP's window gets resized or maxed, the Paint method of our APP's class gets called (i.e. void Paint(Draw& w)). I can retrieve a layouts size, etc. for example:
Size sz2 = buttonPanel.GetSize();

This can be done for other components (i.e. canvas). The width of the buttonPanel can be accessed as, sz2.cx.

How can one set the size of a widget since a SetSize method does not appear to exist? In this case, it would be liked for the buttonPanel to remain the same size, but have the canvas be resized to fill the remaining space.


Peter






SetRect, LeftPos, HSizePos, etc...

Note that there is nothing magical about layouts. In fact, all layout is that it provides a routine that calls above methods to place the object.

It might be worth looking at .lay file as text (press Ctrl+T) as illustration.

Mirek
Re: Resizing a GUI object? [message #48765 is a reply to message #48747] Tue, 12 September 2017 04:12 Go to previous message
ptkacz is currently offline  ptkacz
Messages: 84
Registered: March 2017
Member
Thanks Mirek,

SetRect applied to the canvas within Paint worked great, in that the canvas now resizes, when the main window is resized!

The only downside is that I had to fill in the area on the left with a DrawRect, otherwise the column area below the panel/layout on the left, would randomly fill in with contents from the desktop and or the desktop lock screen.



Peter

[Updated on: Tue, 12 September 2017 04:13]

Report message to a moderator

Previous Topic: What's the relationship between the U++ GUI and OpenGL?
Next Topic: Using namespace Upp
Goto Forum:
  


Current Time: Thu Aug 22 17:51:32 CEST 2019

Total time taken to generate the page: 0.01468 seconds