8 #ifndef _FCITX_UTILS_COLOR_H_ 9 #define _FCITX_UTILS_COLOR_H_ 14 #include <fcitx-utils/fcitxutils_export.h> 15 #include <fcitx-utils/macros.h> 24 const char *what()
const noexcept
override {
return "Color parse error"; }
31 explicit Color(
unsigned short r,
unsigned short g,
unsigned short b,
32 unsigned short alpha = 255);
33 explicit inline Color(
const char *s) { setFromString(s); }
34 explicit inline Color(
const std::string &s) :
Color(s.c_str()) {}
35 FCITX_INLINE_DEFINE_DEFAULT_DTOR_AND_COPY(
Color);
38 std::string toString()
const;
40 bool operator==(
const Color &other)
const;
42 bool operator!=(
const Color &other) {
43 return !operator==(other);
45 bool operator!=(
const Color &other)
const {
return !operator==(other); }
47 void setFromString(
const char *s);
48 inline void setFromString(
const std::string &s) {
49 setFromString(s.c_str());
52 void setRed(
unsigned short);
53 void setGreen(
unsigned short);
54 void setBlue(
unsigned short);
55 void setAlpha(
unsigned short);
58 void setGreenF(
float);
60 void setAlphaF(
float);
62 unsigned short red()
const;
63 unsigned short green()
const;
64 unsigned short blue()
const;
65 unsigned short alpha()
const;
74 unsigned short green_;
76 unsigned short alpha_;
79 FCITXUTILS_EXPORT std::ostream &operator<<(std::ostream &os,
const Color &c);
83 #endif // _FCITX_UTILS_COLOR_H_
Color class for handling color.