| 
 | 
 | 
 
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   | 
		 
		
			
				
				
				
					
						  
						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 #3704 is a reply to message #3684] | 
			Wed, 14 June 2006 15:52    | 
		 
		
			
				
				
				
					
						  
						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   | 
		 
		
			
				
				
				  | 
					
						  
						mirek
						 Messages: 14271 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 
		
		
		
 |  
	| 
		
	 | 
 
 
 |   
Goto Forum:
 
 Current Time: Mon Nov 03 13:44:19 CET 2025 
 Total time taken to generate the page: 0.04021 seconds 
 |   
 |  
  |