BALL
1.4.1
|
00001 // -*- Mode: C++; tab-width: 2; -*- 00002 // vi: set ts=2: 00003 // 00004 00005 #ifndef BALL_VIEW_DATATYPE_COLORRGBA_H 00006 #define BALL_VIEW_DATATYPE_COLORRGBA_H 00007 00008 #ifndef BALL_VIEW_DATATYPE_COLORUNIT_H 00009 # include <BALL/VIEW/DATATYPE/colorUnit.h> 00010 #endif 00011 00012 #ifndef BALL_CONCEPT_TIMESTAMP_H 00013 #include <BALL/CONCEPT/timeStamp.h> 00014 #endif 00015 00016 class QColor; 00017 namespace BALL 00018 { 00019 namespace VIEW 00020 { 00021 // forward declarations 00022 class ColorHSV; 00023 00031 class BALL_VIEW_EXPORT ColorRGBA 00032 { 00036 friend class ColorHSV; 00037 00038 public: 00039 00040 // BALL_CREATE(ColorRGBA) 00041 00045 00049 ColorRGBA(); 00050 00053 ColorRGBA(const ColorRGBA& color); 00054 00058 ColorRGBA(const ColorHSV& color); 00059 00071 ColorRGBA(const char* value); 00072 00080 ColorRGBA(const String& value); 00081 00089 ColorRGBA 00090 (const ColorUnit& red_value, const ColorUnit& green_value, 00091 const ColorUnit& blue_value, const ColorUnit& alpha_value = (float)1); 00092 00094 ColorRGBA(const QColor& color); 00095 00097 ColorRGBA(const QColor& color, const ColorUnit& alpha); 00098 00100 00103 00106 ~ColorRGBA(); 00107 00116 void clear(); 00117 00119 00122 00129 operator String() const; 00130 00132 00135 00139 void set(const ColorRGBA& color); 00140 00144 const ColorRGBA& operator = (const ColorRGBA& color); 00145 00148 void set(const ColorHSV& color); 00149 00153 const ColorRGBA& operator = (const ColorHSV& color); 00154 00157 void get(ColorHSV& color) const; 00158 00166 void set(const char* value); 00167 00176 const ColorRGBA& operator = (const char* value); 00177 00186 void get(char* value) const; 00187 00194 void set(const String& value); 00195 00206 const ColorRGBA& operator = (const String& value); 00207 00214 void get(String& value) const; 00215 00217 void get(QColor& color) const; 00218 00223 bool set(const QColor& color); 00224 00226 QColor getQColor() const; 00227 00231 void swap(ColorRGBA& color); 00232 00234 00237 00241 void setRed(const ColorUnit& red_value); 00242 00247 ColorUnit& getRed(); 00248 00251 const ColorUnit& getRed() const; 00252 00257 void setGreen(const ColorUnit& green_value); 00258 00263 ColorUnit& getGreen(); 00264 00268 const ColorUnit& getGreen() const; 00269 00274 void setBlue(const ColorUnit& blue_value); 00275 00279 ColorUnit& getBlue(); 00280 00284 const ColorUnit& getBlue() const; 00285 00290 void setAlpha(const ColorUnit& alpha_value); 00291 00296 ColorUnit& getAlpha(); 00297 00301 const ColorUnit& getAlpha() const; 00302 00314 void set 00315 (const ColorUnit& red_value, const ColorUnit& green_value, 00316 const ColorUnit& blue_value, const ColorUnit& alpha_value = (float)1); 00317 00327 void get(ColorUnit& red_value, ColorUnit& green_value, 00328 ColorUnit& blue_value, ColorUnit& alpha_value) const; 00329 00338 void get(ColorUnit& red_value, 00339 ColorUnit& green_value, 00340 ColorUnit& blue_value) const; 00341 00343 ColorRGBA getInverseColor() const; 00344 00346 00349 00353 bool operator == (const ColorRGBA& color) const; 00354 00357 bool operator != (const ColorRGBA& color) const; 00358 00363 bool operator < (const ColorRGBA& color) const; 00364 00369 bool operator <= (const ColorRGBA& color) const; 00370 00375 bool operator > (const ColorRGBA& color) const; 00376 00381 bool operator >= (const ColorRGBA& color) const; 00382 00384 00387 00395 void dump(std::ostream& s = std::cout, Size depth = 0) const; 00396 00398 00401 00410 friend BALL_VIEW_EXPORT std::istream& operator >> (std::istream& s, ColorRGBA& color); 00411 00420 friend BALL_VIEW_EXPORT std::ostream& operator << (std::ostream& s, const ColorRGBA& color); 00421 00423 00424 private: 00425 00426 ColorUnit red_; 00427 ColorUnit green_; 00428 ColorUnit blue_; 00429 ColorUnit alpha_; 00430 00431 // @throw Exception::InvalidRange 00432 // @throw Exception::NotInHexFormat 00433 void stringToRGBA_(const String& s); 00434 }; 00435 00437 extern ColorRGBA BALL_SELECTED_COLOR; 00438 extern PreciseTime BALL_SELECTED_COLOR_CHANGE_TIME; 00439 00441 #ifdef BALL_COMPILER_MSVC 00442 #include <vector> 00443 template class BALL_VIEW_EXPORT std::vector<ColorRGBA>; 00444 #endif 00445 00446 # ifndef BALL_NO_INLINE_FUNCTIONS 00447 # include <BALL/VIEW/DATATYPE/colorRGBA.iC> 00448 # endif 00449 00450 } // namespace VIEW 00451 } // namespace BALL 00452 00453 #endif // <BALL/VIEW_DATATYPE_COLORRGBA_H