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 #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
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 );
00108 Area( const std::string &name );
00109 virtual ~Area();
00110
00111 enum e_ordering {
00112 pre_self,
00113 post_self,
00114 separate_self
00115 };
00116
00117
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
00127
00128
00129 static void setDefaultWindowManager( WindowManager *wm );
00130
00131
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
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 };
00175 };
00176
00177
00178 #endif // TEDDY__PHYSICAL_COMPONENTS__AREA__H
00179