[go: up one dir, main page]

Menu

[r8]: / ColorStock.h  Maximize  Restore  History

Download this file

194 lines (164 with data), 6.1 kB

  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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
/******************************************************************************\
*
* File: ColorStock.h
* Creation date: January 05, 2004 20:02
* Author: Mel Viso
* 2004
* Purpose: Declaration of class 'ColorStock'
*
* Modifications: @INSERT_MODIFICATIONS(* )
* June 22, 2004 05:53 Mel Viso
* Update comment header
* January 05, 2004 21:53 Mel Viso
* Added method 'CyclePalette'
* Added member 'm_pLOGPALETTE'
* Added member 'm_offset'
* January 05, 2004 20:20 Mel Viso
* Added method 'GetHPal'
* Added member 'm_hPal'
* January 05, 2004 20:02 Mel Viso
* Added method 'FindColorEntry'
* Added method 'DestructorInclude'
* Added method 'ConstructorInclude'
* Added method 'ColorFromIndex'
* Added method '~ColorStock'
* Added method 'ColorStock'
* Added relation 'ColorStock <>-->> ColorEntry'
*
*Copyright (C) 2004, Mel Viso
*
*This program is free software; you can redistribute it and/or
*modify it under the terms of the GNU General Public License
*as published by the Free Software Foundation; either version 2
*of the License, or (at your option) any later version.
*
*This program is distributed in the hope that it will be useful,
*but WITHOUT ANY WARRANTY; without even the implied warranty of
*MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
*GNU General Public License for more details.
*
*You should have received a copy of the GNU General Public License (LICENSE.TXT)
*along with this program; if not, write to the Free Software
*Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
\******************************************************************************/
#ifndef _COLORSTOCK_H
#define _COLORSTOCK_H
//@START_USER1
//@END_USER1
class ColorStock
{
// RELATION_UNIQUEVALUETREE_OWNED_ACTIVE(ColorStock, ColorStock, ColorEntry, ColorEntry)
private:
CB_PTR(ColorEntry) _firstColorEntry;
int _countColorEntry;
protected:
public:
void AddColorEntry(ColorEntry* item);
void RemoveColorEntry(ColorEntry* item);
void DeleteAllColorEntry();
void ReplaceColorEntry(ColorEntry* item, ColorEntry* newItem);
ColorEntry* GetFirstColorEntry() const;
ColorEntry* GetLastColorEntry() const;
ColorEntry* GetNextColorEntry(ColorEntry* pos) const;
ColorEntry* GetPrevColorEntry(ColorEntry* pos) const;
int GetColorEntryCount() const;
class ColorEntryIterator
{
private:
ColorEntry* _refColorEntry;
ColorEntry* _prevColorEntry;
ColorEntry* _nextColorEntry;
const ColorStock* _iterColorStock;
ColorEntryIterator* _prev;
ColorEntryIterator* _next;
int (ColorEntry::*_method)() const;
static ColorEntryIterator* _first;
static ColorEntryIterator* _last;
public:
ColorEntryIterator(const ColorStock* iterColorStock,
int (ColorEntry::*method)() const = 0,
ColorEntry* refColorEntry = 0);
ColorEntryIterator(const ColorStock& iterColorStock,
int (ColorEntry::*method)() const = 0,
ColorEntry* refColorEntry = 0);
ColorEntryIterator(const ColorEntryIterator& iterator__,
int (ColorEntry::*method)() const = 0);
~ColorEntryIterator();
ColorEntryIterator& operator= (const ColorEntryIterator& iterator__)
{
_iterColorStock = iterator__._iterColorStock;
_refColorEntry = iterator__._refColorEntry;
_prevColorEntry = iterator__._prevColorEntry;
_nextColorEntry = iterator__._nextColorEntry;
_method = iterator__._method;
return *this;
}
ColorEntry* operator++ ()
{
_nextColorEntry = _iterColorStock->GetNextColorEntry(_nextColorEntry);
if (_method != 0)
{
while (_nextColorEntry && !(_nextColorEntry->*_method)())
_nextColorEntry = _iterColorStock->GetNextColorEntry(_nextColorEntry);
}
_refColorEntry = _prevColorEntry = _nextColorEntry;
return _refColorEntry;
}
ColorEntry* operator-- ()
{
_prevColorEntry = _iterColorStock->GetPrevColorEntry(_prevColorEntry);
if (_method != 0)
{
while (_prevColorEntry && !(_prevColorEntry->*_method)())
_prevColorEntry = _iterColorStock->GetPrevColorEntry(_prevColorEntry);
}
_refColorEntry = _nextColorEntry = _prevColorEntry;
return _refColorEntry;
}
operator ColorEntry*() { return _refColorEntry; }
ColorEntry* operator-> () { return _refColorEntry; }
ColorEntry* Get() { return _refColorEntry; }
void Reset() { _refColorEntry = _prevColorEntry = _nextColorEntry = (ColorEntry*)0; }
int IsLast() { return (_iterColorStock->GetLastColorEntry() == _refColorEntry); }
int IsFirst() { return (_iterColorStock->GetFirstColorEntry() == _refColorEntry); }
static void Check(ColorEntry* itemColorEntry);
static void Check(ColorEntry* itemColorEntry, ColorEntry* newItemColorEntry);
};
//@START_USER2
//@END_USER2
// Members
private:
HPALETTE m_hPal;
int m_offset;
LOGPALETTE* m_pLOGPALETTE;
protected:
public:
// Methods
private:
void ConstructorInclude();
void DestructorInclude();
protected:
public:
ColorStock();
virtual ~ColorStock();
COLORREF ColorFromIndex(double index);
void CyclePalette(HDC hDC);
HPALETTE GetHPal() const;
ColorEntry* FindColorEntry(COLORREF color);
};
#endif
#ifdef CB_INLINES
#ifndef _COLORSTOCK_H_INLINES
#define _COLORSTOCK_H_INLINES
/*@NOTE_1133
Returns the value of member 'm_hPal'.
*/
inline HPALETTE ColorStock::GetHPal() const
{//@CODE_1133
return m_hPal;
}//@CODE_1133
//@START_USER3
//@END_USER3
#endif
#endif