Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

AreaLayout.cpp

Go to the documentation of this file.
00001 
00002 /*
00003     TEDDY - General graphics application library
00004     Copyright (C) 1999-2002  Timo Suoranta
00005     tksuoran@cc.helsinki.fi
00006 
00007     This library is free software; you can redistribute it and/or
00008     modify it under the terms of the GNU Lesser General Public
00009     License as published by the Free Software Foundation; either
00010     version 2.1 of the License, or (at your option) any later version.
00011 
00012     This library is distributed in the hope that it will be useful,
00013     but WITHOUT ANY WARRANTY; without even the implied warranty of
00014     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015     Lesser General Public License for more details.
00016 
00017     You should have received a copy of the GNU Lesser General Public
00018     License along with this library; if not, write to the Free Software
00019     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00020 
00021     $Id:  $
00022 */
00023 
00024 
00025 #include "Teddy/PhysicalComponents/Area.h"
00026 #include "Teddy/PhysicalComponents/Style.h"
00027 #include "Teddy/Graphics/View.h"
00028 #include "Teddy/SysSupport/Messages.h"
00029 #include "Teddy/SysSupport/StdIO.h"
00030 #ifndef SWIG
00031 #include <cassert>
00032 #endif
00033 using namespace Teddy::Graphics;
00034 
00035 
00036 namespace Teddy              {
00037 namespace PhysicalComponents {
00038 
00039 
00040 /*virtual*/ const Vector2 &Area::doSize( const Vector2 &ref ){
00041     dmsg( M_WML, "%s->Area::doSize( %f x %f )", this->getName().c_str(), ref[0], ref[1] );
00042     beginSize( ref );
00043     list<Area*>::iterator a_it = areas.begin();
00044     while( a_it != areas.end() ){
00045         callSize( *a_it );
00046         a_it++;
00047     }
00048     endSize();
00049     dmsg( M_WML, "  %s->size = %f x %f", this->getName().c_str(), size[0], size[1] );
00050     return size;
00051 }
00052 
00053 
00054 /*virtual*/ void Area::beginSize( const Vector2 &ref ){
00055     dmsg( M_WML, "%s->Area::beginSize( %f x %f )", this->getName().c_str(), ref[0], ref[1] );
00056     size  = fill_base_pixels + ref * fill_free_size_relative;
00057     size[0] = (float)ceil( (double)size[0] );
00058     size[1] = (float)ceil( (double)size[1] );
00059     //size -= style->padding * 2;
00060     dmsg( M_WML, "  %s->size = %f x %f", this->getName().c_str(), size[0], size[1] );
00061 }
00062 
00063 
00064 /*virtual*/ void Area::callSize( Area *a ){
00065     dmsg( M_WML, "%s->Area::callSize( %s )", this->getName().c_str(), a->getName().c_str() );
00066     a->doSize( size );
00067 }
00068 
00069 
00070 /*virtual*/ void Area::endSize(){
00071     dmsg( M_WML, "%s->Area::endSize() size = %f x %f", this->getName().c_str(), size[0], size[1] );
00072 }
00073 
00074 
00075 /*virtual*/ const Vector2 &Area::doPlace( const Rect &ref ){
00076     dmsg( M_WML, "%s->Area::doPlace( %f, %f .. %f, %f )", this->getName().c_str(), ref.min[0], ref.min[1], ref.max[0], ref.max[1] );
00077     dmsg( M_WML, "  %s->size = %f x %f", this->getName().c_str(), size[0], size[1] );
00078     beginPlace( ref );
00079     list<Area*>::iterator a_it = areas.begin();
00080     while( a_it != areas.end() ){
00081         callPlace( *a_it );
00082         a_it++;
00083     }
00084     endPlace();
00085     return size;
00086 }
00087 
00088 
00089 /*virtual*/ void Area::beginPlace( const Rect &ref ){
00090     dmsg( M_WML, "%s->Area::beginPlace( %f, %f .. %f, %f )", this->getName().c_str(), ref.min[0], ref.min[1], ref.max[0], ref.max[1] );
00091     dmsg( M_WML, "  %s->size = %f x %f", this->getName().c_str(), size[0], size[1] );
00092     rect.min = ref.min + offset_pixels + ref.getSize() * offset_free_size_relative + size * offset_self_size_relative;
00093     rect.min[0] = (float)ceil( (double)rect.min[0] );
00094     rect.min[1] = (float)ceil( (double)rect.min[1] );
00095     rect.max = rect.min + size;
00096     if( isEnabled(Area::USE_CLIP_TO_REFERENCE) ){
00097         rect.intersect( ref );
00098     }
00099 
00100     in_rect = rect.shrink( style->padding );
00101 
00102 }
00103 
00104 
00105 /*virtual*/ void Area::callPlace( Area *a ){
00106     dmsg( M_WML, "%s->Area::callPlace( %s )", this->getName().c_str(), a->getName().c_str() );
00107     a->doPlace( rect );
00108 }
00109 
00110 
00111 /*virtual*/ void Area::endPlace(){
00112 }
00113 
00114 
00115 };  //  namespace PhysicalComponents
00116 };  //  namespace Teddy
00117