00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
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 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 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
00060 dmsg( M_WML, " %s->size = %f x %f", this->getName().c_str(), size[0], size[1] );
00061 }
00062
00063
00064 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 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 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 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 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 void Area::endPlace(){
00112 }
00113
00114
00115 };
00116 };
00117