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 » FrameAddSize(Size& sz) really needed?
FrameAddSize(Size& sz) really needed? [message #3647] Sun, 11 June 2006 12:35 Go to next message
Werner is currently offline  Werner
Messages: 234
Registered: May 2006
Location: Cologne / Germany
Experienced Member
I can't see the point in using FrameAddSize(Size& sz).

Sure - the syntactical need for it is obvious because CtrlFrame::FrameAddSize(Size& sz) is a pure virtual function. If you don't define it in your derived class the compiler complains.

But where is the semantical need for it? Calling FrameLayout(Rect& r) calculates the new size of the view but lets the size of the control unchanged. FrameAddSize(Size& sz) is to compute the new size of the control. But this is unchanged, or is it?

This raises the following questions:

In which case is FrameAddSize(Size& sz) called by Ultimate++'s framework?
Or do I need to call it myself? If so: When?

Does it make sense to define and use FrameLayout(Rect& r) without semantically defining FrameAddSize(Size& sz)?

Does it make sense to define and use FrameAddSize(Size& sz) without semantically defining FrameLayout(Rect& r)?

Werner

[Updated on: Sun, 11 June 2006 18:27]

Report message to a moderator

Re: FrameAddSize(Size& sz) really needed? [message #3651 is a reply to message #3647] Sun, 11 June 2006 21:07 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 14105
Registered: November 2005
Ultimate Member
Is is required because sometimes you need to get the Size of Ctrl based on its view size.

(If you want to know when, try FindInFiles in uppsrc Wink

Mirek
Re: FrameAddSize(Size& sz) really needed? [message #3655 is a reply to message #3651] Sun, 11 June 2006 22:52 Go to previous messageGo to next message
Werner is currently offline  Werner
Messages: 234
Registered: May 2006
Location: Cologne / Germany
Experienced Member
luzr wrote on Sun, 11 June 2006 21:07

Is is required because sometimes you need to get the Size of Ctrl based on its view size.

(If you want to know when, try FindInFiles in uppsrc Wink

Mirek


Well, I once again tried FindInFiles (Indeed, I already did it before posting Rolling Eyes .) I learned that you always use FrameLayout in combination with FrameAddSize. And in principle I recognize that "sometimes you need to get the Size of Ctrl based on its view size". But I still can't figure out in which cases you do need it. As far as I grasp I should look for a piece of code querying the size of the control. But I don't understand which precise expression to look for Embarassed .

So I don't know if I need FrameAddSize for my own frames. But of course I can write "FrameAddSize(Size& sz) {}" and just observe what happens Very Happy .

Werner

[Updated on: Sun, 11 June 2006 22:54]

Report message to a moderator

Re: FrameAddSize(Size& sz) really needed? [message #3680 is a reply to message #3655] Mon, 12 June 2006 17:20 Go to previous messageGo to next message
Werner is currently offline  Werner
Messages: 234
Registered: May 2006
Location: Cologne / Germany
Experienced Member
Werner wrote on Sun, 11 June 2006 22:52

luzr wrote on Sun, 11 June 2006 21:07

Is is required because sometimes you need to get the Size of Ctrl based on its view size.

(If you want to know when, try FindInFiles in uppsrc Wink

Mirek


Well, I once again tried FindInFiles (Indeed, I already did it before posting Rolling Eyes .) I learned that you always use FrameLayout in combination with FrameAddSize. And in principle I recognize that "sometimes you need to get the Size of Ctrl based on its view size". But I still can't figure out in which cases you do need it. As far as I grasp I should look for a piece of code querying the size of the control. But I don't understand which precise expression to look for Embarassed .

So I don't know if I need FrameAddSize for my own frames. But of course I can write "FrameAddSize(Size& sz) {}" and just observe what happens Very Happy .

Werner



Just if somebody read this thread and might be interested in the answers ...

I fiddled about with some frames and I hope to have found the answers. Here they are (If something is wrong I would be happy to get corrected!):


1.
In which case is FrameAddSize(Size& sz) called by Ultimate++'s framework?

Never.

2.
Do I need to call it myself? If so: When?

Not normally. Only if I need to get the size of a ctrl based on the size of its view. So far I couldn't find an example where this is the case.

3.
Does it make sense to define and use FrameLayout(Rect& r) without semantically defining FrameAddSize(Size& sz)?

Yes, see the answer to question #2. But in any case in my own frame class for syntactical reasons I need to define the FrameAddSize function even if it's empty.

4.
Does it make sense to define and use FrameAddSize(Size& sz) without semantically defining FrameLayout(Rect& r)?

Maybe. But I doubt it very much. In any case I can't imagine a useful example.


All this sounds quite obvious. Laughing So, why did I ask these silly questions? Embarassed

I studied the article "About Frames" in "Browse topics" where FrameAddSize is semantically defined in 2 cases. And I still wonder what is the need for this ... Rolling Eyes

Werner
Re: FrameAddSize(Size& sz) really needed? [message #3684 is a reply to message #3680] Mon, 12 June 2006 18:48 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 14105
Registered: November 2005
Ultimate Member
Well, as I said before, it is not needed until some situation expects the right value....

One of such situations is e.g. when creating TopWindow with layout

MyWin::MyWin()
{
SetFrame(MyFrame);
CtrlLayout(*this, "");
}

Now try to make MyFrame quite thick (e.g. 50 pixels) and do not implement AddFrameSize.

Mirek
Re: FrameAddSize(Size& sz) really needed? [message #3704 is a reply to message #3684] Wed, 14 June 2006 15:52 Go to previous messageGo to next message
Werner is currently offline  Werner
Messages: 234
Registered: May 2006
Location: Cologne / Germany
Experienced Member
luzr wrote on Mon, 12 June 2006 18:48

Well, as I said before, it is not needed until some situation expects the right value....

One of such situations is e.g. when creating TopWindow with layout

MyWin::MyWin()
{
SetFrame(MyFrame);
CtrlLayout(*this, "");
}

Now try to make MyFrame quite thick (e.g. 50 pixels) and do not implement AddFrameSize.

Mirek


Yes!

CtrlLayout calls AddFrameSize ...

template <class T>                                       // In TopWindow.h
void CtrlLayout(T& ctrl)
{
	InitLayout(ctrl, ctrl, ctrl, ctrl);
	Size sz = ctrl.AddFrameSize(T::GetLayoutSize());
	ctrl.SetMinSize(sz);
	ctrl.SetRect(sz);
}


... and AddFrameSize in turn calls FrameAddSize ...

Size Ctrl::AddFrameSize(int cx, int cy) const           // In CtrlPos.cpp
{
	Size sz = Size(cx, cy);
	for(int i = frame.GetCount() - 1; i >= 0; i--)
		frame[i].frame->FrameAddSize(sz);
	return sz;
}


Sorry for the inconvenience!

Werner
Re: FrameAddSize(Size& sz) really needed? [message #3706 is a reply to message #3704] Wed, 14 June 2006 17:45 Go to previous message
mirek is currently offline  mirek
Messages: 14105
Registered: November 2005
Ultimate Member
Werner wrote on Wed, 14 June 2006 09:52

luzr wrote on Mon, 12 June 2006 18:48

Well, as I said before, it is not needed until some situation expects the right value....

One of such situations is e.g. when creating TopWindow with layout

MyWin::MyWin()
{
SetFrame(MyFrame);
CtrlLayout(*this, "");
}

Now try to make MyFrame quite thick (e.g. 50 pixels) and do not implement AddFrameSize.

Mirek


Yes!

CtrlLayout calls AddFrameSize ...

template <class T>                                       // In TopWindow.h
void CtrlLayout(T& ctrl)
{
	InitLayout(ctrl, ctrl, ctrl, ctrl);
	Size sz = ctrl.AddFrameSize(T::GetLayoutSize());
	ctrl.SetMinSize(sz);
	ctrl.SetRect(sz);
}


... and AddFrameSize in turn calls FrameAddSize ...

Size Ctrl::AddFrameSize(int cx, int cy) const           // In CtrlPos.cpp
{
	Size sz = Size(cx, cy);
	for(int i = frame.GetCount() - 1; i >= 0; i--)
		frame[i].frame->FrameAddSize(sz);
	return sz;
}


Sorry for the inconvenience!

Werner



Do not worry, keep digging.

Actually, AddFrameSize is really rarely used and in fact was added years after Frame interface first emerged to provide clean solution to similar corner-cases...

Mirek
Previous Topic: How to set the Constructor of a derived widget class?
Next Topic: OpenGL, SDL
Goto Forum:
  


Current Time: Fri Nov 01 00:58:37 CET 2024

Total time taken to generate the page: 0.02493 seconds