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

Dock.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/Dock.h"
00026 #include "Teddy/PhysicalComponents/Style.h"
00027 #include "Teddy/SysSupport/Messages.h"
00028 using namespace Teddy::SysSupport;
00029 
00030 
00031 #if defined( _MSC_VER )
00032 # include <limits>
00033 #else
00034 extern "C" {
00035 #include <limits.h>
00036 }
00037 #endif
00038 
00039 
00040 namespace Teddy              {
00041 namespace PhysicalComponents {
00042 
00043 
00045 Dock::Dock( std::string name, const int axis )
00046 :
00047 Area    (  name  )/*,
00048 axis_sum(  axis  ),
00049 axis_max( 1-axis )*/
00050 {
00051     axis_sum = axis;
00052     axis_max = 1 - axis;
00053     event_ordering = separate_self;
00054     dmsg( M_WML, "  %s->axis_sum = %d, axis_max = %d", this->getName().c_str(), axis_sum, axis_max );
00055 }
00056 
00057 
00058 /*virtual*/ Dock::~Dock(){
00059 }
00060 
00061 
00062 /*virtual*/ void Dock::beginSize( const Vector2 &ref ){
00063     dmsg( M_WML, "%s->Dock::beginSize( %f x %f )", this->getName().c_str(), ref[0], ref[1] );
00064     dmsg( M_WML, "  %s->axis_sum = %d, axis_max = %d", this->getName().c_str(), axis_sum, axis_max );
00065     size = style->padding;
00066 }
00067 
00068 
00069 /*virtual*/ void Dock::callSize( Area *a ){
00070     dmsg( M_WML, "%s->Dock::callSize( %s ) = %...", this->getName().c_str(), a->getName().c_str() );
00071     Vector2 sub_size  = a->doSize( size );
00072     dmsg( M_WML, "  %s->Dock::callSize( %s ) = %f x %f", this->getName().c_str(), a->getName().c_str(), sub_size[0], sub_size[1] );
00073     size[axis_sum]   += sub_size[axis_sum] + style->padding[axis_sum];
00074     size[axis_max]    = MAX( size[axis_max], sub_size[axis_max] );
00075     dmsg( M_WML, "  %s->size = %f x %f", this->getName().c_str(), a->getName().c_str(), size[0], size[1] );
00076 }
00077 
00078 
00079 /*virtual*/ void Dock::endSize(){
00080     size[axis_max] += 2 * style->padding[axis_max];
00081 //    size[axis_sum] += style->padding[axis_sum];
00082     dmsg( M_WML, "%s->Dock::endSize( %f x %f )", this->getName().c_str(), size[0], size[1] );
00083 }
00084 
00085 
00086 /*virtual*/ void Dock::beginPlace( const Rect &ref ){
00087     dmsg( M_WML, "%s->Dock::beginPlace()", getName().c_str() );
00088     rect.min = ref.min  + offset_pixels + ref.getSize() * offset_free_size_relative + size * offset_self_size_relative;
00089     rect.max = rect.min + size;
00090 
00091     if( isEnabled(Area::USE_CLIP_TO_REFERENCE) ){
00092         rect.intersect( ref );
00093     }
00094 
00095     in_rect = rect.shrink( style->padding );
00096 
00097     cursor_start = rect.min + style->padding;
00098     cursor_end   = rect.max - style->padding;
00099 }
00100 
00101 
00102 /*virtual*/ void Dock::callPlace( Area *a ){
00103     dmsg( M_WML, "%s->Dock::callPlace( %s )", this->getName().c_str(), a->getName().c_str() );
00104     dmsg( M_WML, "  cursor_start = %f, %f", cursor_start[0], cursor_start[1] );
00105     Vector2 sub_size = a->doPlace( Rect(cursor_start,cursor_end) );
00106     cursor_start[axis_sum] += sub_size[axis_sum] + style->padding[axis_sum];
00107     dmsg( M_WML, "  cursor_start = %f, %f", cursor_start[0], cursor_start[1] );
00108 }
00109 
00110 
00111 };  //  namespace PhysicalComponents'
00112 };  //  namespace Teddy
00113