Home » U++ Library support » U++ Library : Other (not classified elsewhere) » [Feature request] Relative positioning
Re: [Feature request] Relative positioning [message #48771 is a reply to message #48673] |
Wed, 13 September 2017 15:49 |
rafiwui
Messages: 105 Registered: June 2017 Location: Stuttgart, Germany
|
Experienced Member |
|
|
I finished my work on my AutoResizer. So if anyone wants to use it simply include and inherit from AutoResizeTopWindow instead of TopWindow.
So here is the solution I came up with:
#ifndef _AutoResizeTopWindow_h_
#define _AutoResizeTopWindow_h_
#include <CtrlLib/CtrlLib.h>
using namespace Upp;
class AutoResizeTopWindow : public 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
[Updated on: Thu, 14 September 2017 08:45] Report message to a moderator
|
|
|
Goto Forum:
Current Time: Fri Sep 20 03:46:49 CEST 2024
Total time taken to generate the page: 0.06550 seconds
|