Home » U++ Library support » U++ Widgets - General questions or Mixed problems » [Closed] Get size and position of widget
[Closed] Get size and position of widget [message #48767] |
Wed, 13 September 2017 09:05 |
rafiwui
Messages: 105 Registered: June 2017 Location: Stuttgart, Germany
|
Experienced Member |
|
|
I try to write an auto resizing app and so I need to know how to get the position and size of all widgets correct, because the solution I worked out has kind of a bug/problem:
This is how it looks
This is how it should look
And here is the Layout file:
LAYOUT(TestSimpleLayout, 400, 200)
ITEM(Clock, m_widget, LeftPosZ(16, 368).TopPosZ(20, 156))
END_LAYOUT
The code of the resizing is shown here:
void TestWindow::Layout()
{
float sizeXChange = (float)GetSize().cx / (float)m_startSize.cx;
float sizeYChange = (float)GetSize().cy / (float)m_startSize.cy;
Ctrl* child = GetFirstChild();
while(child != NULL)
{
String temp;
temp << child->GetSize().cx << " | " << child->GetSize().cy;
temp << " @ " << child->GetRect().TopLeft().x << " | " << child->GetRect().TopLeft().y;
Title(temp);
child->LeftPosZ(child->GetRect().TopLeft().x * sizeXChange, child->GetSize().cx * sizeXChange);
child->TopPosZ(child->GetRect().TopLeft().y * sizeYChange, child->GetSize().cy * sizeYChange);
child = child->GetNext();
}
}
So like you can see there is sth wrong with the size/position gathering because it is sth completely different to the values I set in the layout file.
I will add the complete testprogram as well if you want to check it out.
Greetings
Daniel
[Updated on: Wed, 13 September 2017 15:50] Report message to a moderator
|
|
|
Goto Forum:
Current Time: Wed Apr 24 13:06:29 CEST 2024
Total time taken to generate the page: 0.01807 seconds
|