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

AreaDraw.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/EventListener.h"
00027 #include "Teddy/PhysicalComponents/Projection.h"
00028 #include "Teddy/PhysicalComponents/Style.h"
00029 #include "Teddy/Graphics/View.h"
00030 #include "Teddy/Graphics/Font.h"
00031 #include "Teddy/SysSupport/Messages.h"
00032 #include "Teddy/SysSupport/StdIO.h"
00033 #ifndef SWIG
00034 #include <cassert>
00035 #endif
00036 using namespace Teddy::Graphics;
00037 
00038 
00039 namespace Teddy              {
00040 namespace PhysicalComponents {
00041 
00042 
00044 /*virtual*/ void Area::draw(){
00045     dmsg( M_WM, "%s->Area::draw()", this->getName().c_str() );
00046     dmsg( M_WM, "  %s->rect = %f, %f .. %f, %f", this->getName().c_str(), rect.min[0], rect.min[1], rect.max[0], rect.max[1] );
00047     if( drawing_ordering == pre_self ){
00048         drawSelf();
00049     }
00050 
00051     list<Area*>::iterator a_it = areas.begin();
00052     while( a_it != areas.end() ){
00053         Area *a = *a_it;
00054         const char *name = a->getName().c_str();
00055         dmsg( M_WM, "%s->Area::draw() calling %s->draw()", this->getName().c_str(), name );
00056         a->draw();
00057         a_it++;
00058     }
00059 
00060     if( drawing_ordering == post_self ){
00061         drawSelf();
00062     }
00063 }
00064 
00065 
00067 /*virtual*/ void Area::drawSelf(){
00068 }
00069 
00070 
00071 View *Area::getView() const {
00072     return view;
00073 }
00074 
00075 
00076 void Area::drawVertex( const float x1, const float y1 ){
00077     view->vertex( x1+rect.min[0], y1+rect.min[1] );
00078 }
00079 
00080 
00082 void Area::drawRect( const float x1, const float y1, const float x2, const float y2 ){
00083     view->drawRect( x1+rect.min[0], y1+rect.min[1], x2+rect.min[0], y2+rect.min[1] );
00084 }
00085 
00086 
00088 void Area::drawFillRect( const float x1, const float y1, const float x2, const float y2 ){
00089     const char *name = this->getName().c_str();
00090     msg( M_GL, "%s->Area::drawFillRect( %f, %f, %f, %f )", name, x1,y1,x2,y2 );
00091     msg( M_GL, "%s->rect.min = %f, %f", name, rect.min[0], rect.min[1] );
00092     view->drawFillRect( x1+rect.min[0], y1+rect.min[1], x2+rect.min[0], y2+rect.min[1] );
00093 }
00094 
00095 
00097 void Area::drawBiColRect( const float x1, const float y1, const float x2, const float y2, const Color &top_left, const Color &bottom_right ){
00098     view->drawBiColRect( x1+rect.min[0], y1+rect.min[1], x2+rect.min[0], y2+rect.min[1], top_left, bottom_right );
00099 }
00100 
00101 
00103 void Area::drawString( const Vector2 &pos, const char *str, Font *font ){
00104     view->drawString( pos + rect.min, str, font );
00105 }
00106 
00107 
00108 };  //  namespace PhysicalComponents
00109 };  //  namespace Teddy
00110