Home » Community » Newbie corner » Resizing a GUI object?
Re: Resizing a GUI object? [message #48748 is a reply to message #48747] |
Sun, 10 September 2017 08:27   |
 |
mirek
Messages: 14257 Registered: November 2005
|
Ultimate Member |
|
|
ptkacz wrote on Sun, 10 September 2017 07:31Hi 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
|
|
|
Goto Forum:
Current Time: Sat May 10 04:46:35 CEST 2025
Total time taken to generate the page: 0.02650 seconds
|