1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
|
////////////////////////////////////////////////////////////////////////////////
/*! @file Color.h Classes sColor and sColorSet.
- Part of RANet - Research Assistant Net Library (based on ANSI C++).
- Copyright(C) 2010-2015, Viktor E. Bursian, St.Petersburg, Russia.
Viktor.Bursian@mail.ioffe.ru
*///////////////////////////////////////////////////////////////////////////////
#ifndef Color_H
#define Color_H
#include "Storable.h"
#include <map>
namespace RA {
//------------------------------------------------------------------------------
ANNOUNCE_CLASS(sColor)
ANNOUNCE_CLASS(sColorSet)
//------------------------------------------------------------------- sColor ---
class RANet_EXPORT sColor : public virtual sStorable
{
STORABLE(sColor)
public: //static
static const sColor cWhite;
static const sColor cGrey;
static const sColor cBlack;
static const sColor cRed;
static const sColor cGreen;
static const sColor cBlue;
static const sColor cDarkRed;
static const sColor cDarkGreen;
static const sColor cDarkBlue;
static const sColor cMagenta;
static const sColor cYellow;
static const sColor cCyan;
static const sColor cPurple;
static const sColor cOlive;
static const sColor cTeal;
static const sColor cChocolate;
static const sColor cCoral;
static const sColor cOrange;
static const sColor cOrange1;
static const sColor cOrange2;
static const sColor cGold;
public:
sColor (byte red ,byte green ,byte blue
,byte alpha = 0xFF)
:R(red),G(green),B(blue),A(alpha)
{}
sColor ()
:R(0),G(0),B(0),A(0xFF)
{}
sColor (rcsColor);
rsColor operator = (rcsColor);
bool operator == (rcsColor) const;
bool operator != (rcsColor C) const
{ return !operator==(C); }
int Red () const
{ return R; }
int Green () const
{ return G; }
int Blue () const
{ return B; }
int Alpha () const
{ return A; }
sString HexARGB () const;
sString StyleTagRGBA () const;
void Bleach (/*short_*/real BleachingStrength = 2.0);
private: //fields
byte R;
byte G;
byte B;
byte A;
};
//---------------------------------------------------------------- sColorSet ---
/*! Набор цветов со встроенным механизмом последовательного (циклически
замкнутого) перечисления элементов для назначения цветов кривым и т.п.
*/
class RANet_EXPORT sColorSet : public virtual sStorable
{
STORABLE(sColorSet)
public: //type
ANNOUNCE_CLASS(sItem)
class RANet_EXPORT sItem
{
public:
sItem (rcsColor color
,rcsString name )
:Color(color),Name(name)
{}
sItem (rcsItem other)
:Color(other.Color),Name(other.Name)
{}
public:
csColor Color;
csString Name;
};
public: //static
static sColorSet Basic ();/*!< возвращает базовый набор цветов*/
public:
virtual ~sColorSet ();
sColorSet ();/*!< порождает пустой набор цветов*/
sColorSet (rcsColorSet);
rsColorSet operator = (rcsColorSet);
virtual bool Empty () const
{ return TheSize == 0; }
virtual int Size () const
{ return TheSize; }
virtual void Clear ();
virtual rsColorSet Add (rcsColor color
,rcsString name = sString() );
virtual sColor CurrentColor () const;
virtual void SetToFirst ();
virtual void ShiftToNext ();
// virtual void ShiftBack ();
virtual int CurrentIndex () const
{ return TheCurrentIndex; }
virtual bool SetCurrentIndex (int index);
virtual sItem operator [] (int index) const;
// virtual sColor Color (int index) const;
// virtual sString Name (int index) const;
virtual void Change (int index
,rcsColor color
,rcsString name = sString() );
private: //fields
int TheSize;
int TheCurrentIndex;
std::map<int,sItem> Items;
};
//------------------------------------------------------------------------------
} //namespace RA
#endif
|