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
00026
00027 #ifndef OSDL_UPRIGHT_RECTANGLE_H_
00028 #define OSDL_UPRIGHT_RECTANGLE_H_
00029
00030
00031 #include "OSDLVideoTypes.h"
00032 #include "OSDLPixel.h"
00033
00034 #include "Ceylan.h"
00035
00036
00037
00038 #if ! defined(OSDL_USES_SDL) || OSDL_USES_SDL
00039
00040 #include "SDL.h"
00041
00042 #endif // OSDL_USES_SDL
00043
00044
00045
00046 #include <iostream>
00047 #include <string>
00048
00049
00050
00051 #if ! defined(OSDL_USES_SDL) || OSDL_USES_SDL
00052
00053
00054 struct SDL_Rect ;
00055 struct SDL_Color ;
00056
00057 #endif // ! defined(OSDL_USES_SDL) || OSDL_USES_SDL
00058
00059
00060
00061
00062 namespace OSDL
00063 {
00064
00065
00066
00067 namespace Video
00068 {
00069
00070
00071
00072 namespace TwoDimensional
00073 {
00074
00075
00076
00077
00078 class UprightRectangle ;
00079
00080
00081
00082 #if ! defined(OSDL_USES_SDL) || OSDL_USES_SDL
00083
00084
00085 typedef ::SDL_Rect LowLevelRect ;
00086
00087 #else // OSDL_USES_SDL
00088
00089 struct LowLevelRect {} ;
00090
00091 #endif // OSDL_USES_SDL
00092
00093
00094 }
00095
00096 }
00097
00098 }
00099
00100
00101
00102
00103
00104
00106 OSDL_DLL bool operator == (
00107 const OSDL::Video::TwoDimensional::UprightRectangle & first,
00108 const OSDL::Video::TwoDimensional::UprightRectangle & second ) ;
00109
00110
00111
00117 OSDL_DLL bool operator != (
00118 const OSDL::Video::TwoDimensional::UprightRectangle & first,
00119 const OSDL::Video::TwoDimensional::UprightRectangle & second ) ;
00120
00121
00122
00123
00124 namespace OSDL
00125 {
00126
00127
00128 namespace Video
00129 {
00130
00131
00132
00133
00134 class Surface ;
00135
00136
00137
00138 namespace TwoDimensional
00139 {
00140
00141
00142
00143
00144 class Point2D ;
00145
00146
00147
00148
00168 class OSDL_DLL UprightRectangle: public Ceylan::TextDisplayable
00169 {
00170
00171
00172 friend bool::operator == ( const UprightRectangle & first,
00173 const UprightRectangle & second ) ;
00174
00175
00176
00177 public:
00178
00179
00180
00182 UprightRectangle( const Point2D & upperLeftCorner,
00183 const Point2D & lowerRightCorner ) ;
00184
00185
00186
00192 UprightRectangle( const Point2D & upperLeftCorner,
00193 Length width, Length height ) ;
00194
00195
00196
00202 UprightRectangle( Coordinate x, Coordinate y, Length width,
00203 Length height ) ;
00204
00205
00206
00213 explicit UprightRectangle( const LowLevelRect & source ) ;
00214
00215
00216
00218 virtual ~UprightRectangle() throw() ;
00219
00220
00221
00222
00223
00224
00225
00226
00227
00229 virtual Point2D getUpperLeftCorner() const ;
00230
00231
00232
00238 virtual void setUpperLeftCorner(
00239 Point2D & newUpperLeftCorner ) ;
00240
00241
00242
00243
00245 virtual Coordinate getUpperLeftAbscissa() const ;
00246
00247
00248
00254 virtual void setUpperLeftAbscissa(
00255 Coordinate newAbscissa ) ;
00256
00257
00258
00260 virtual Coordinate getUpperLeftOrdinate() const ;
00261
00262
00263
00269 virtual void setUpperLeftOrdinate(
00270 Coordinate newOrdinate ) ;
00271
00272
00273
00274
00275
00276
00277
00278
00279
00281 virtual Point2D getLowerRightCorner() const ;
00282
00283
00284
00292 virtual void setLowerRightCorner(
00293 Point2D & newLowerRightCorner ) ;
00294
00295
00296
00298 virtual Coordinate getLowerRightAbscissa() const ;
00299
00300
00309 virtual void setLowerRightAbscissa(
00310 Coordinate newAbscissa ) ;
00311
00312
00313
00314
00316 virtual Coordinate getLowerRightOrdinate() const ;
00317
00318
00327 virtual void setLowerRightOrdinate(
00328 Coordinate newOrdinate ) ;
00329
00330
00331
00332
00334 virtual Length getWidth() const ;
00335
00336
00337
00339 virtual void setWidth( Length newWidth ) ;
00340
00341
00342
00343
00345 virtual Length getHeight() const ;
00346
00347
00348
00350 virtual void setHeight( Length newHeight ) ;
00351
00352
00353
00368 virtual bool draw(
00369 Surface & target,
00370 Pixels::ColorElement red,
00371 Pixels::ColorElement blue,
00372 Pixels::ColorElement green,
00373 Pixels::ColorElement alpha = Pixels::AlphaOpaque,
00374 bool filled = true ) const ;
00375
00376
00377
00392 virtual bool draw( Surface & target,
00393 Pixels::ColorDefinition colorDef = Pixels::White,
00394 bool filled = true ) const ;
00395
00396
00397
00422 virtual bool drawWithRoundedCorners(
00423 Surface & target, Length edgeWidth = 3,
00424 Pixels::ColorDefinition edgeColorDef = Pixels::White,
00425 Pixels::ColorDefinition backgroundColorDef
00426 = Pixels::Transparent ) const ;
00427
00428
00429
00445 virtual Length computeRadiusForRoundRectangle(
00446 Length edgeWidth ) const ;
00447
00448
00449
00463 virtual LowLevelRect * toLowLevelRect() const ;
00464
00465
00466
00479 virtual const std::string toString(
00480 Ceylan::VerbosityLevels level = Ceylan::high ) const ;
00481
00482
00483
00484
00485
00486 protected:
00487
00488
00489
00491 Coordinate _x ;
00492
00493
00495 Coordinate _y ;
00496
00497
00498
00499
00500 private:
00501
00502
00503
00505 Length _width ;
00506
00507
00509 Length _height ;
00510
00511
00512
00521 explicit UprightRectangle(
00522 const UprightRectangle & source ) ;
00523
00524
00525
00534 UprightRectangle & operator = (
00535 const UprightRectangle & source ) ;
00536
00537
00538 } ;
00539
00540
00541 }
00542
00543 }
00544
00545 }
00546
00547
00548
00549
00551 std::ostream & operator << ( std::ostream & os,
00552 OSDL::Video::TwoDimensional::UprightRectangle & rect ) ;
00553
00554
00555
00556 #endif // OSDL_UPRIGHT_RECTANGLE_H_
00557