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 » Missing Functions for Layouter
Missing Functions for Layouter [message #10722] Wed, 25 July 2007 10:34 Go to next message
Zardos is currently offline  Zardos
Messages: 62
Registered: April 2007
Member
Hello,

because I'm more productive if I use layout manager and automatic gui layouting functions instead of moving widgets on the screen I started to programm some simple layouting stuff.

But soon I ran into problems. What I would need is a "GetOptSize()" functions for controls. This function should return the "optimum size" of a control. For example for a button it should take into account:

the used font
the label
the image
default margin

... Because there is nothing like a GetOptSize() for Ctrls I started to make my own outside of the class like this:

Size GetOptSize(Ctrl &c) {
	Button *b = dynamic_cast<Button *>(&c);
	if(b) {
		Size s;
		
		s = GetTLTextSize(WString(b->GetDesc()), StdFont());
		s.cx += GUI_MARGIN * 2;
		
		return s;
	} else
		return c.GetStdSize();
}


... well not nice, but it should work.


What I'm really missing are a function to get the used font for ctrls and for buttons a GetImage:

If I would start adding the following functions to button (and other controls):

GetFont();
GetImage();

...and create a patch would you accept it?

Or even better would you like to have a "virtual GetOptSize()" for Ctrls?

Or do you have any other suggestions?

- Ralf
Re: Missing Functions for Layouter [message #10723 is a reply to message #10722] Wed, 25 July 2007 10:40 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Actually, there is GetStdSize.

Unfortunately, for many widgets, it is not implemented correctly...

In fact, there are three of kind:

GetMinSize (minimal size)
GetStdSize (optimal size)
GetMaxSize (maximal size)

Default implementation of GetStdSize calls GetMinsSize (at least, this does make sense...)

Mirek
Re: Missing Functions for Layouter [message #10724 is a reply to message #10723] Wed, 25 July 2007 10:47 Go to previous messageGo to next message
Zardos is currently offline  Zardos
Messages: 62
Registered: April 2007
Member
Yes, thanks.

I have found this functions. But as you wrote some of them are not correct.

Especially for buttons: It allways returns the same size regardless of the label and use image, font, etc...

So,

if I would start "fixing" the GetStdSize functions. Starting with the buttons, you would accept it?

I thought GetStdSize is made this way by itension (always return a "default" size - independent of the content). ...But of course if GetSdtSize means something like "optimum size" then we could start fixing the functions.

Edit:
Anyway, I could get around an "incorrect" GetStdSize with my own function. It would just be very helpful to have access to the used Iamge and the used font for a button. If I miss more for other controls I will mention it again in the forum. Wink

- Ralf

[Updated on: Wed, 25 July 2007 11:01]

Report message to a moderator

Re: Missing Functions for Layouter [message #10725 is a reply to message #10724] Wed, 25 July 2007 10:57 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Zardos wrote on Wed, 25 July 2007 04:47


if I would start "fixing" the GetStdSize functions. Starting with the buttons, you would accept it?
- Ralf


Yes. Just will need a bit of thinking how min and std values should look like.

OTOH, you seem to be the main user, so I guess you will get it right Smile

Mirek
Re: Missing Functions for Layouter [message #10726 is a reply to message #10725] Wed, 25 July 2007 11:05 Go to previous messageGo to next message
Zardos is currently offline  Zardos
Messages: 62
Registered: April 2007
Member
[quote title=luzr wrote on Wed, 25 July 2007 10:57][quote Yes. Just will need a bit of thinking how min and std values should look like.

OTOH, you seem to be the main user, so I guess you will get it right Smile

Ok thanks. Smile

I will start with the button and submit the patch here. if I encounter more I will submit the additional patches again.

- Ralf
Re: Missing Functions for Layouter [message #10727 is a reply to message #10725] Wed, 25 July 2007 11:37 Go to previous messageGo to next message
Zardos is currently offline  Zardos
Messages: 62
Registered: April 2007
Member
OK,

here comes the patch for the button

- Ralf
Re: Missing Functions for Layouter [message #10747 is a reply to message #10727] Fri, 27 July 2007 13:19 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Should not these constants rather be chameleon variables?

Why Pusher::GetStdSize?

Re: Missing Functions for Layouter [message #10752 is a reply to message #10747] Fri, 27 July 2007 15:26 Go to previous messageGo to next message
Zardos is currently offline  Zardos
Messages: 62
Registered: April 2007
Member
luzr wrote on Fri, 27 July 2007 13:19

Should not these constants rather be chameleon variables?

Why Pusher::GetStdSize?




Ok, I will move necessary constants to chameleon. I will also reduce the new constants to a minimum and remove all constants related to Layout engines.

Pusher: GetStdSize:
I thought if someone derives from it, there would be a - hopefully - usable GetStdSize.
But no problem I will remove it.


Additional changes I discovered useful while programming my layouter:

I will more concentrate on GetMinSize(), because here it is relative clear what is meant: The minimum size which will not truncate an information (labels, text, ...).

For some controls - like buttons - I will supply GetStdSize().
For example I will add a small margin to the left and right of the button and make sure the button has a minimum default size.


Since my layouter is nearly complete I will soon start with checking and implementing GetMinSize(), GetStdSize() for some other controls and post the new patch for review.

I leave out GetMaxSize completely, because currently I have no clue what could be useful values for it.


Thanks,
Ralf
Re: Missing Functions for Layouter [message #10764 is a reply to message #10752] Fri, 27 July 2007 22:39 Go to previous message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Pusher: Well, derived classes have to implement Paint, so it is doubtful GetMinSize is releveant for it...

GetMinSize vs GetStdSize -> that is exactly how we meant it Wink

GetMaxSize use is meant for top-level windows.

Previous Topic: Refresh(), Paint(Draw& w), or something else nearby?
Next Topic: there is no fontpusher class (just checking)
Goto Forum:
  


Current Time: Fri Apr 19 09:55:56 CEST 2024

Total time taken to generate the page: 0.03084 seconds