Home » U++ Library support » U++ Widgets - General questions or Mixed problems » [Closed] Get size and position of widget
Re: Get size and position of widget [message #48770 is a reply to message #48768] |
Wed, 13 September 2017 15:45  |
rafiwui
Messages: 105 Registered: June 2017 Location: Stuttgart, Germany
|
Experienced Member |
|
|
Ok I solved the problem and if anyone else want to use the AutResizeTopWindow feel free to copy the code below or download the header.
#ifndef _AutoResizeTopWindow_h_
#define _AutoResizeTopWindow_h_
#include <CtrlLib/CtrlLib.h>
using namespace Upp;
class AutoResizeTopWindow : public virtual TopWindow
{
public:
virtual void Layout()
{
Size currentSize = GetSize();
if(firstSizing)
startSize = currentSize;
float sizeXChange = (float)currentSize.cx / (float)startSize.cx;
float sizeYChange = (float)currentSize.cy / (float)startSize.cy;
Ctrl* pChild = GetFirstChild();
for(int i = 0; pChild != NULL; i++)
{
if(firstSizing)
startRects.Add(pChild->GetRect());
float rectLeft = startRects[i].left * sizeXChange;
float rectTop = startRects[i].top * sizeYChange;
float rectSizeX = startRects[i].Width() * sizeXChange;
float rectSizeY = startRects[i].Height() * sizeYChange;
pChild->SetRect(rectLeft, rectTop,
rectSizeX, rectSizeY);
pChild = pChild->GetNext();
}
firstSizing = false;
}
private:
bool firstSizing = true;
Size startSize;
Vector<Rect> startRects;
};
#endif
Greetings
Daniel
|
|
|
Goto Forum:
Current Time: Mon Sep 01 11:14:28 CEST 2025
Total time taken to generate the page: 0.05298 seconds
|