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

Area.h

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: Area.h,v 1.6 2002/03/12 10:46:07 tksuoran Exp $
00022 */
00023 
00024 
00025 #ifndef TEDDY__PHYSICAL_COMPONENTS__AREA__H
00026 #define TEDDY__PHYSICAL_COMPONENTS__AREA__H
00027 
00028 
00029 #include "Teddy/Graphics/ViewClient.h"
00030 #include "Teddy/Maths/Vector.h"
00031 #include "Teddy/Maths/Rect.h"
00032 #include "Teddy/MixIn/Named.h"
00033 #include "Teddy/MixIn/Options.h"
00034 #include "Teddy/SysSupport/StdList.h"
00035 #include "Teddy/SysSupport/Types.h"
00036 
00037 
00038 //  Forward declarations
00039 namespace Teddy {
00040     namespace Graphics           { class Font;          };
00041     namespace PhysicalComponents { class WindowManager; };
00042 }
00043 using namespace Teddy::Maths;
00044 using namespace Teddy::Graphics;
00045 using namespace Teddy::MixIn;
00046 
00047 
00048 namespace Teddy              {
00049 namespace PhysicalComponents {
00050 
00051 
00052 class EventListener;
00053 class Projection;
00054 class Style;
00055 
00089 class Area :
00090 public Named,
00091 public Options,
00092 public ViewClient
00093 {
00094 public:
00095     static const unsigned long CLIP_LAYOUT   ;
00096     static const unsigned long CLIP_RENDERING;
00097     static const unsigned long CLEAR         ;
00098     static const unsigned long PICK          ;
00099     static const unsigned long USE_OFFSET_SELF_SIZE_RELATIVE;
00100     static const unsigned long USE_OFFSET_FREE_SIZE_RELATIVE;
00101     static const unsigned long USE_FILL_MAX_PIXELS          ;
00102     static const unsigned long USE_FILL_FREE_SIZE_RELATIVE  ;
00103     static const unsigned long USE_CLIP_TO_REFERENCE        ;
00104 
00105 public:
00106     Area();
00107     Area( std::string &name ); //  cant be const for Area( "blah" ) to work
00108     Area( const std::string &name ); //  cant be const for Area( "blah" ) to work
00109     virtual ~Area();
00110 
00111     enum e_ordering {
00112         pre_self,      
00113         post_self,     
00114         separate_self  
00115     };
00116 
00117     //  Area
00118     virtual Area  *getHit       ( const Vector2 &pos );
00119     virtual void   insert       ( Area *area );
00120     virtual bool   remove       ( Area *area );
00121     virtual void   setParent    ( Area *parent, View *view = NULL );
00122     Area          *getParent    ();
00123     View          *getView      () const;  
00124     const Rect    &getRect      () const;
00125     const Vector2 &getSize      () const;
00126 //  int           *getViewport  ();
00127 //  virtual void   moveDelta    ( const Vector2 &delta );
00128 //  virtual void   sizeDelta    ( const Vector2 &delta );
00129     static void    setDefaultWindowManager( WindowManager *wm );
00130 
00131     //  AreaDraw
00132     virtual void  draw         ();
00133     virtual void  drawSelf     ();  
00134     virtual void  drawString   ( const Vector2 &pos, const char *str, Font *font );
00135     virtual void  drawRect     ( const float x1, const float y1, const float x2, const float y2 );
00136     virtual void  drawFillRect ( const float x1, const float y1, const float x2, const float y2 );
00137     virtual void  drawBiColRect( const float x1, const float y1, const float x2, const float y2, const Color &top_left, const Color &bottom_right );
00138     virtual void  drawVertex   ( const float x1, const float y1 );
00139 
00140     //  AreaLayout
00141     virtual const Vector2 &doSize    ( const Vector2 &ref );
00142     virtual void           beginSize ( const Vector2 &ref );
00143     virtual void           callSize  ( Area *a );
00144     virtual void           endSize   ();
00145     virtual const Vector2 &doPlace   ( const Rect &ref );
00146     virtual void           beginPlace( const Rect &ref );
00147     virtual void           callPlace ( Area *a );
00148     virtual void           endPlace  ();
00149 
00150 public:
00151     Vector2        offset_pixels;              
00152     Vector2        offset_self_size_relative;  
00153     Vector2        offset_free_size_relative;  
00154     Vector2        fill_base_pixels;           
00155     Vector2        fill_free_size_relative;    
00156 
00157 protected:
00158     WindowManager *window_manager;             
00159     Style         *style;                      
00160     Area          *parent;                     
00161     list<Area*>    areas;                      
00162     e_ordering     drawing_ordering;           
00163     e_ordering     event_ordering;             
00164 
00165 
00166     Vector2        size;                       
00167     Rect           rect;                       
00168     Rect           in_rect;
00169 
00170     static WindowManager *default_window_manager;
00171 };
00172 
00173 
00174 };  //  namespace PhysicalComponents
00175 };  //  namespace Teddy
00176 
00177 
00178 #endif  //  TEDDY__PHYSICAL_COMPONENTS__AREA__H
00179