00001 #ifndef FSHAPE_H_FILE
00002 #define FSHAPE_H_FILE
00003
00004 #include <vector>
00005 #include "FBase.h"
00006
00007 class FlashShapeCommon
00008 {
00009 public:
00010 FlashShapeCommon() : NBitsFillStyle(0), NBitsLineStyle(0), DefineTagVersion(1) {}
00011
00012 int flags;
00013 int NBitsLineStyle;
00014 int NBitsFillStyle;
00015 int DefineTagVersion;
00016 };
00017 class FlashFillStyle : public FlashVersionEnabled
00018 {
00019 public:
00020 FlashFillStyle() : type(0) {}
00021 FlashFillStyle(UBYTE _type) : type(_type){}
00022
00023 ~FlashFillStyle() {}
00024
00025 virtual void Write(std::ostream &out) {}
00026 virtual void Read(std::istream &in) {}
00027
00028 protected:
00029 UBYTE type;
00030
00031 friend std::ostream &operator<< (std::ostream &out, FlashFillStyle &data);
00032 friend std::istream &operator>> (std::istream &in, FlashFillStyle &data);
00033
00034 };
00035
00036
00037
00038
00039
00040
00041
00042 class FlashFillStyleArray;
00043 class FlashFillStyleSolid : public FlashFillStyle
00044 {
00045 public:
00046 FlashFillStyleSolid(FlashRGB &color) : FlashFillStyle(0), r1(color) { type = 0; }
00047 ~FlashFillStyleSolid() {}
00048
00049 virtual void Write(std::ostream &out);
00050 virtual void Read(std::istream &in);
00051
00052 FlashRGB GetRGB() { return r1; }
00053 void SetRGB(FlashRGB &r) { r1=r; }
00054 private:
00055 friend std::istream &operator>> (std::istream &in, FlashFillStyleArray &data);
00056 FlashFillStyleSolid() {}
00057
00058 FlashRGB r1;
00059 };
00060
00061 class FlashGradientRecord : public FlashVersionEnabled
00062 {
00063 public:
00064 FlashGradientRecord() {}
00065 void AddGradient(UBYTE ratio, FlashRGB &r) { colors.push_back(r); ratios.push_back(ratio); }
00066
00067
00068 private:
00069
00070 std::vector<UBYTE> ratios;
00071 std::vector<FlashRGB> colors;
00072
00073 friend std::ostream &operator<< (std::ostream &out, FlashGradientRecord &data);
00074 friend std::istream &operator>> (std::istream &in, FlashGradientRecord &data);
00075
00076 };
00077
00078 class FlashFillStyleGradient : public FlashFillStyle
00079 {
00080 public:
00081 FlashFillStyleGradient(FlashMatrix &m, FlashGradientRecord &g) : FlashFillStyle(0x10), matrix(m), gradient(g){ type = 0x10; }
00082
00083 void SetLinear() { type = 0x10; }
00084 void SetRadial() { type = 0x12; }
00085
00086
00087 virtual void Write(std::ostream &out);
00088 virtual void Read(std::istream &in);
00089
00090 private:
00091 friend std::istream &operator>> (std::istream &in, FlashFillStyleArray &data);
00092 FlashFillStyleGradient() {}
00093 FlashMatrix matrix;
00094 FlashGradientRecord gradient;
00095 };
00096
00097 class FlashFillStyleBitmap : public FlashFillStyle
00098 {
00099
00100 public:
00101 FlashFillStyleBitmap(UWORD _bitmapID, FlashMatrix &m, bool _tiled=false) : bitmapID(_bitmapID), tiled(_tiled), matrix(m) { type = tiled ? 0x40 : 0x41;}
00102
00103 virtual void Write(std::ostream &out);
00104 virtual void Read(std::istream &in);
00105
00106 private:
00107 friend std::istream &operator>> (std::istream &in, FlashFillStyleArray &data);
00108 FlashFillStyleBitmap() {}
00109 bool tiled;
00110 FlashMatrix matrix;
00111 UWORD bitmapID;
00112 };
00113 class FlashFillStyleArray : public FlashVersionEnabled
00114 {
00115 public:
00116 FlashFillStyleArray() {}
00117 ~FlashFillStyleArray() {}
00118 size_t AddFillStyle(FlashFillStyle *s)
00119 {
00120 styles.push_back(s);
00121 return styles.size();
00122 }
00123
00124 int GetNBits();
00125
00126 private:
00127 std::vector<FlashFillStyle*> styles;
00128 gc_vector<FlashFillStyle*> gc;
00129 friend std::ostream &operator<< (std::ostream &out, FlashFillStyleArray &data);
00130 friend std::istream &operator>> (std::istream &in, FlashFillStyleArray &data);
00131
00132 };
00133 class FlashLineStyleArray;
00134 class FlashLineStyle : public FlashVersionEnabled
00135 {
00136 public:
00137 FlashLineStyle(UWORD _width, FlashRGB &_color) : color(_color), width(_width) {}
00138
00139 friend std::ostream &operator<< (std::ostream &out, FlashLineStyle &data);
00140 friend std::istream &operator>> (std::istream &in, FlashLineStyle &data);
00141
00142 private:
00143 friend std::istream &operator>> (std::istream &in, FlashLineStyleArray &data);
00144 FlashLineStyle() {}
00145
00146 UWORD width;
00147 FlashRGB color;
00148
00149 };
00150
00151 class FlashLineStyleArray : public FlashVersionEnabled
00152 {
00153 public:
00154 FlashLineStyleArray() {}
00155 ~FlashLineStyleArray() {}
00156
00157 size_t AddLineStyle(FlashLineStyle *s)
00158 {
00159 styles.push_back(s);
00160 return styles.size();
00161 }
00162 int GetNBits();
00163 private:
00164 std::vector<FlashLineStyle*> styles;
00165 gc_vector<FlashLineStyle*> gc;
00166 friend std::ostream &operator<< (std::ostream &out, FlashLineStyleArray &data);
00167 friend std::istream &operator>> (std::istream &in, FlashLineStyleArray &data);
00168
00169 };
00170
00171 class FlashShapeRecord : public FlashVersionEnabled
00172 {
00173 public:
00174 FlashShapeRecord() {};
00175
00176 virtual void Write(BitBuffer &out, FlashShapeCommon &c)=0;
00177 virtual void Read(BitStreamIn &in, FlashShapeCommon &data)=0;
00178 };
00179 class FlashShape;
00180 class FlashShapeWithStyle;
00181 class FlashShapeRecordStraight : public FlashShapeRecord
00182 {
00183 public:
00184 FlashShapeRecordStraight(SWORD _dx, SWORD _dy) : dx(_dx), dy(_dy) {}
00185
00186 virtual void Write(BitBuffer &out, FlashShapeCommon &data);
00187 virtual void Read(BitStreamIn &in, FlashShapeCommon &data);
00188 private:
00189 FlashShapeRecordStraight() {}
00190 SWORD dx;
00191 SWORD dy;
00192 friend class FlashShape;
00193 friend std::istream &operator>> (std::istream &in, FlashShape &data);
00194 friend std::istream &operator>> (std::istream &in, FlashShapeWithStyle &data);
00195
00196 };
00197 class FlashShapeRecordEnd : public FlashShapeRecord
00198 {
00199 public:
00200 FlashShapeRecordEnd() {}
00201
00202 virtual void Write(BitBuffer &out, FlashShapeCommon &data);
00203 virtual void Read(BitStreamIn &in, FlashShapeCommon &data);
00204 };
00205
00206 class FlashShapeRecordCurved : public FlashShapeRecord
00207 {
00208 public:
00209 FlashShapeRecordCurved(SWORD _dxc, SWORD _dyc, SWORD _dxa, SWORD _dya) :
00210 dxa(_dxa), dya(_dya), dxc(_dxc), dyc(_dyc) {}
00211
00212 virtual void Write(BitBuffer &out, FlashShapeCommon &data);
00213 virtual void Read(BitStreamIn &in, FlashShapeCommon &data);
00214 private:
00215 FlashShapeRecordCurved() {}
00216 SWORD dxa;
00217 SWORD dya;
00218 SWORD dxc;
00219 SWORD dyc;
00220 friend class FlashShape;
00221 friend std::istream &operator>> (std::istream &in, FlashShape &data);
00222 friend std::istream &operator>> (std::istream &in, FlashShapeWithStyle &data);
00223 };
00224
00225 class FlashShapeRecordChange : public FlashShapeRecord
00226 {
00227 public:
00228 FlashShapeRecordChange();
00229 FlashShapeRecordChange(SDWORD dx, SDWORD dy);
00230
00231 void NewFillStyles(FlashFillStyleArray &a, FlashLineStyleArray &c);
00232
00233 void ChangeMoveDelta(SDWORD _dx, SDWORD _dy)
00234 {
00235 moveto=true;
00236
00237 dx=_dx;
00238 dy=_dy;
00239 }
00240 void ChangeFillStyle0(UWORD style);
00241 void ChangeFillStyle1(UWORD style);
00242 void ChangeLineStyle(UWORD style);
00243
00244 virtual void Write(BitBuffer &out, FlashShapeCommon &data);
00245 virtual void Read(BitStreamIn &in, FlashShapeCommon &data);
00246 private:
00247 bool newstyles;
00248 bool linestyle;
00249 bool fillstyle1;
00250 bool fillstyle0;
00251 bool moveto;
00252
00253 UWORD stylefill0;
00254 UWORD stylefill1;
00255 UWORD styleline;
00256 SDWORD dx;
00257 SDWORD dy;
00258
00259 FlashFillStyleArray fillstyles;
00260 FlashLineStyleArray linestyles;
00261
00262 friend class FlashShape;
00263 friend std::istream &operator>> (std::istream &in, FlashShape &data);
00264 friend std::istream &operator>> (std::istream &in, FlashShapeWithStyle &data);
00265 };
00266 class FlashShape
00267 {
00268 public:
00269 FlashShape() {}
00270 ~FlashShape() {}
00271
00272 FlashRect GetBounds();
00273 void AddRecord(const FlashShapeRecordChange &r)
00274 {
00275 record_change.push_back(r);
00276 record_sequencer.push_back(flash_pair<int,long>(0,record_change.size()-1));
00277 }
00278 void AddRecord(const FlashShapeRecordStraight &r)
00279 {
00280 record_straight.push_back(r);
00281 record_sequencer.push_back(flash_pair<int,long>(1,record_straight.size()-1));
00282 }
00283 void AddRecord(const FlashShapeRecordCurved &r)
00284 {
00285 record_curved.push_back(r);
00286 record_sequencer.push_back(flash_pair<int,long>(2,record_curved.size()-1));
00287 }
00288 protected:
00289 std::vector<FlashShapeRecordChange> record_change;
00290 std::vector<FlashShapeRecordStraight> record_straight;
00291 std::vector<FlashShapeRecordCurved> record_curved;
00292
00293 std::vector<flash_pair<int,long> > record_sequencer;
00294
00295 friend std::ostream &operator<< (std::ostream &out, FlashShape &data);
00296 friend std::istream &operator>> (std::istream &in, FlashShape &data);
00297
00298 };
00299 class FlashShapeWithStyle : public FlashVersionEnabled, public FlashShape
00300 {
00301 public:
00302 FlashShapeWithStyle(){}
00303 ~FlashShapeWithStyle(){}
00304 void SetFillStyleArray(FlashFillStyleArray &_fillstyles)
00305 {
00306 fillstyles=_fillstyles;
00307 }
00308 void SetLineStyleArray(FlashLineStyleArray &_linestyles)
00309 {
00310 linestyles=_linestyles;
00311 }
00312 private:
00313 FlashFillStyleArray fillstyles;
00314 FlashLineStyleArray linestyles;
00315
00316 friend std::ostream &operator<< (std::ostream &out, FlashShapeWithStyle &data);
00317 friend std::istream &operator>> (std::istream &in, FlashShapeWithStyle &data);
00318 };
00319 class FlashTagDefineShapeBase : public FlashTag, public FlashIDEnabled
00320 {
00321 DEFINE_RW_INTERFACE
00322 public:
00323 FlashTagDefineShapeBase(FlashShapeWithStyle &s) : shapes(s) { }
00324 ~FlashTagDefineShapeBase() {}
00325
00326 FlashShapeWithStyle &GetShapes() { return shapes; }
00327 FlashRect rimport;
00328 private:
00329 friend std::ostream &operator<< (std::ostream &out, FlashTagDefineShapeBase &data);
00330 friend std::istream &operator>> (std::istream &in, FlashTagDefineShapeBase &data);
00331
00332 FlashShapeWithStyle shapes;
00333
00334
00335 friend class FlashImporter;
00336
00337 protected:
00338 FlashTagDefineShapeBase() {}
00339 int version;
00340 int header;
00341 };
00342 class FlashTagDefineShape1 : public FlashTagDefineShapeBase
00343 {
00344 DEFINE_RW_INTERFACE
00345 public:
00346 FlashTagDefineShape1(FlashShapeWithStyle &s) : FlashTagDefineShapeBase(s) { header=2; version=1; }
00347 friend class FlashImporter;
00348 private:
00349 FlashTagDefineShape1() { header=2; version=1; }
00350 };
00351
00352 class FlashTagDefineShape2 : public FlashTagDefineShapeBase
00353 {
00354 DEFINE_RW_INTERFACE
00355 public:
00356 FlashTagDefineShape2(FlashShapeWithStyle &s) : FlashTagDefineShapeBase(s) { header=22; version=2; }
00357 friend class FlashImporter;
00358 private:
00359 FlashTagDefineShape2() { header=22; version=2; }
00360 };
00361 class FlashTagDefineShape3 : public FlashTagDefineShapeBase
00362 {
00363 DEFINE_RW_INTERFACE
00364 public:
00365 FlashTagDefineShape3(FlashShapeWithStyle &s) : FlashTagDefineShapeBase(s) { header=32; version=3; }
00366 friend class FlashImporter;
00367 private:
00368 FlashTagDefineShape3() { header=32; version=3; }
00369
00370 };
00371 #endif