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 » 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 Go to previous message
rafiwui is currently offline  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
 
Read Message
Read Message
Read Message
Previous Topic: Add layouts/ParentCtrl to column list
Next Topic: How to blur a Ctrl
Goto Forum:
  


Current Time: Tue Apr 16 18:28:53 CEST 2024

Total time taken to generate the page: 0.01777 seconds