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 » Community » Newbie corner » Getting the width of a layout?
Getting the width of a layout? [message #47785] Sun, 26 March 2017 06:48 Go to next message
ptkacz is currently offline  ptkacz
Messages: 89
Registered: March 2017
Member
There appears to be some U++ magic going on, in how one goes from creating a layout and accessing it programatically.

If one creates a layout, let's say called, "ButtonLayout", one is able to then reference it as "WithButtonLayout". One can then define an object as follows:

WithButtonLayout<ParentCtrl> buttonPanel;

Button panel now allows us to work with the layout. How does one acquire the width or dimensions of the layout (i.e. buttonPanel)?

My other question, is how does "WithButtonLayout" come to be?


Peter
Re: Getting the width of a layout? [message #47797 is a reply to message #47785] Wed, 29 March 2017 09:33 Go to previous messageGo to next message
cbpporter is currently offline  cbpporter
Messages: 1401
Registered: September 2007
Ultimate Contributor
When you see:
WithButtonLayout<ParentCtrl> buttonPanel;

Read instead:
ParentCtrl buttonPanel;

ParentCtrl is still the class of buttonPanel. Adding WithButtonLayout does not change the base class of your item. All it does is add a new set of fields and the CtrlLayout method so that you can apply the layout you designed to it.

So you can use the standard methods to get position and sizes.

The online documentation here is kind of lacking:
http://www.ultimatepp.org/srcdoc$CtrlCore$LogPos$en-us.html

But you can read the documentation for these functions from Ctrl:
	Ctrl&       LeftPos(int a, int size = STDSIZE);
	Ctrl&       RightPos(int a, int size = STDSIZE);
	Ctrl&       TopPos(int a, int size = STDSIZE);
	Ctrl&       BottomPos(int a, int size = STDSIZE);
	Ctrl&       HSizePos(int a = 0, int b = 0);
	Ctrl&       VSizePos(int a = 0, int b = 0);
	Ctrl&       SizePos();
	Ctrl&       HCenterPos(int size = STDSIZE, int delta = 0);
	Ctrl&       VCenterPos(int size = STDSIZE, int delta = 0);

	Ctrl&       LeftPosZ(int a, int size = STDSIZE);
	Ctrl&       RightPosZ(int a, int size = STDSIZE);
	Ctrl&       TopPosZ(int a, int size = STDSIZE);
	Ctrl&       BottomPosZ(int a, int size = STDSIZE);
	Ctrl&       HSizePosZ(int a = 0, int b = 0);
	Ctrl&       VSizePosZ(int a = 0, int b = 0);
	Ctrl&       HCenterPosZ(int size = STDSIZE, int delta = 0);
	Ctrl&       VCenterPosZ(int size = STDSIZE, int delta = 0);

	Rect        GetRect() const;
	Rect        GetScreenRect() const;

	Rect        GetView() const;
	Rect        GetScreenView() const;
	Size        GetSize() const;



So GetRect should allow you to determine the size of your layout.

Re: Getting the width of a layout? [message #47810 is a reply to message #47785] Sun, 02 April 2017 00:32 Go to previous messageGo to next message
ptkacz is currently offline  ptkacz
Messages: 89
Registered: March 2017
Member
Wow, cbpporter, thanks.

I'll look at your list and available documentation.

I did come across in the forums that revealed how to get the width, something like the following:

Size sz = buttonPanel.GetSize();

int width = sz.cx;


Kind of strange that there doesn't appear to be any getWidth(), or width() methods, but one can specify "cx". Kind of reminds me of a complex mathematical variable.



Peter

[Updated on: Sun, 02 April 2017 00:33]

Report message to a moderator

Re: Getting the width of a layout? [message #48496 is a reply to message #47810] Mon, 10 July 2017 09:57 Go to previous message
rafiwui is currently offline  rafiwui
Messages: 105
Registered: June 2017
Location: Stuttgart, Germany
Experienced Member
I thought this would fit here:

I was wondering what size GetSize() is returning? Is it the zoomed size or do I have to call Zx/Zy in front of GetSize().cx/cy to get a size I can work with?


Greetings
Daniel
Previous Topic: Example Serial pak
Next Topic: OpenGL demo resulting in Fatal error, Heap leaks detected! error...
Goto Forum:
  


Current Time: Thu Mar 28 11:11:44 CET 2024

Total time taken to generate the page: 0.01667 seconds