00001
00054 #ifndef INC_RVC_STYLEPATTERNBASE_H
00055 #define INC_RVC_STYLEPATTERNBASE_H
00056
00057 #ifndef INC_MI32_SIMPLEAR_H
00058 #include <mi32/simplear.h>
00059 #endif
00060
00061 #ifndef INC_MI32_COLOR_H
00062 #include <mi32/color.h>
00063 #endif
00064
00065 #ifndef INC_RVC_OBJECTNAME_H
00066 #include <rvc/objectname.h>
00067 #endif
00068
00069 #ifndef INC_RVC_STYLETYPE_H
00070 #include <rvc/styletype.h>
00071 #endif
00072
00073 namespace RVC {
00074
00075 #ifndef GENERATING_DOXYGEN_OUTPUT
00076 class STYLE;
00077 #endif // GENERATING_DOXYGEN_OUTPUT
00078
00080 class STYLEPATTERN_BASE {
00081 public:
00082
00083 enum SPECIALCOLOR {
00084 SPECIALCOLOR_Transparent = 255,
00085 SPECIALCOLOR_Variable = 254
00086 };
00087
00089 STYLEPATTERN_BASE (
00090 ) :
00091 m_PattBuff(0),
00092 m_PattHdrSize(sizeof(PATTERNHEADER)),
00093 m_PattBuffSize(sizeof(PATTERNHEADER)),
00094 m_BuffSizeAlloc(sizeof(PATTERNHEADER))
00095 {
00096 MmAllocCExc((void**)&m_PattBuff, m_PattBuffSize);
00097 }
00098
00100 virtual ~STYLEPATTERN_BASE (
00101 ) { MmFree(m_PattBuff); }
00102
00105 ERRVALUE AppendColor (
00106 const COLOR& color
00107 );
00108
00110 void Clear (
00111 ) { m_PattBuffSize = m_PattHdrSize; memset(m_PattBuff,0,m_PattHdrSize); }
00112
00114 const RVC::OBJECTNAME& GetName (
00115 ) const { return (*reinterpret_cast<const OBJECTNAME*>(m_PattBuff)); }
00116
00118 const COLOR& GetColor (
00119 UINT8 idx
00120 ) const { return (GetColors()[idx]); }
00121
00123 const COLOR* GetColors (
00124 ) const { return (reinterpret_cast<COLOR*>(m_PattBuff + m_PattHdrSize)); }
00125
00128 INT32 GetNumColors (
00129 ) const { return (reinterpret_cast<const PATTERNHEADER*>(m_PattBuff)->numcolors); }
00130
00132 INT32 GetNumElements (
00133 ) const { return (reinterpret_cast<const PATTERNHEADER*>(m_PattBuff)->numelements); }
00134
00136 PATTERNTYPE GetPatternType (
00137 ) const { return (m_PattType); }
00138
00140
00141 INT32 GetSize (
00142 ) const { return (m_PattBuffSize); }
00143
00146 bool IsEmpty (
00147 ) const { return (v_IsEmpty()); }
00148
00150 bool IsEqualDef (
00151 const STYLEPATTERN_BASE& rhs
00152 ) const {
00153 if (m_PattBuffSize != rhs.m_PattBuffSize) return (false);
00154 return (memcmp(m_PattBuff+sizeof(OBJECTNAME),rhs.m_PattBuff+sizeof(OBJECTNAME),m_PattBuffSize-sizeof(OBJECTNAME))==0);
00155 }
00156
00158 void SetColor (
00159 UINT8 idx,
00160 const COLOR& color
00161 ) { if (idx < GetNumColors()) reinterpret_cast<COLOR*>(m_PattBuff + m_PattHdrSize)[idx] = color; }
00162
00164 void SetName (
00165 const OBJECTNAME& name
00166 ) { *reinterpret_cast<OBJECTNAME*>(m_PattBuff) = name; }
00167
00169 ERRVALUE SetPattern (
00170 const void* SrcPattBuff,
00171 INT32 PattBuffSize,
00172 INT32 PattHdrSize
00173 );
00174
00176
00177 operator const void* (
00178 ) const { return (m_PattBuff); }
00179
00180
00181 protected:
00182
00184 struct PATTERNHEADER {
00185 RVC::OBJECTNAME name;
00186 INT16 numelements;
00187 INT16 numcolors;
00188 };
00189
00191 STYLEPATTERN_BASE (
00192 PATTERNTYPE PattType,
00193 int PattHdrSize
00194 ) :
00195 m_PattBuff(0),
00196 m_PattHdrSize(PattHdrSize),
00197 m_PattBuffSize(PattHdrSize),
00198 m_BuffSizeAlloc(PattHdrSize),
00199 m_PattType(PattType)
00200 {
00201 MmAllocCExc((void**)&m_PattBuff, m_PattBuffSize);
00202 }
00203
00205 STYLEPATTERN_BASE (const STYLEPATTERN_BASE& rhs);
00206
00208 STYLEPATTERN_BASE& operator= (const STYLEPATTERN_BASE& rhs);
00209
00211 void DeleteColorSet (
00212 const UINT8 *set
00213 );
00214
00216 void DeleteFromBuffer (
00217 INT32 offset,
00218 INT32 numbytes
00219 );
00220
00222 const UINT8* GetPattBuffer (
00223 ) const { return (m_PattBuff); }
00224
00226 UINT8* GetPattBuffer (
00227 ) { return (m_PattBuff); }
00228
00230 const UINT8* GetFirstElemPtr (
00231 ) const { return (m_PattBuff+m_PattHdrSize+((GetNumColors()>0)?GetNumColors():0)*sizeof(COLOR)); }
00232
00234 UINT8* GetFirstElemPtr (
00235 ) { return (m_PattBuff+m_PattHdrSize+((GetNumColors()>0)?GetNumColors():0)*sizeof(COLOR)); }
00236
00238 ERRVALUE InsertIntoBuffer (
00239 INT32 offset,
00240 INT32 numbytes,
00241 const void *data = 0
00242 );
00243
00244 #ifndef GENERATING_DOXYGEN_OUTPUT
00245 UINT8* m_PattBuff;
00246 INT32 m_PattHdrSize;
00247 INT32 m_PattBuffSize;
00248 mutable SIMPLE_ARRAY<UINT32> m_OffsetArray;
00249 #endif // GENERATING_DOXYGEN_OUTPUT
00250
00251 private:
00252 #ifndef GENERATING_DOXYGEN_OUTPUT
00253 INT32 m_BuffSizeAlloc;
00254 PATTERNTYPE m_PattType;
00255
00258 virtual bool v_IsEmpty (
00259 ) const { return (GetNumElements() == 0); }
00260
00261 friend class STYLE;
00262 #endif // GENERATING_DOXYGEN_OUTPUT
00263 };
00264
00265 }
00266
00267 #endif // INC_RVC_STYLEPATTERNBASE_H