00001
00002 #ifndef LIBSSWF_H
00003 #define LIBSSWF_H
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046 #include <stdarg.h>
00047 #include <stdio.h>
00048 #include <stdlib.h>
00049 #ifndef _MSVC
00050 #include <unistd.h>
00051 #endif
00052 #include <string.h>
00053 #include <limits.h>
00054 #include <errno.h>
00055 #include <zlib.h>
00056 #include <math.h>
00057 #include <ctype.h>
00058 #include <wctype.h>
00059 #ifdef STATIC_ICONV
00060 #include <iconv.h.static>
00061 #else
00062 #include <iconv.h>
00063 #endif
00064
00065 #if IRIX
00066 #include <sys/endian.h>
00067 #endif
00068
00069 #include "sswf/libsswf-config.h"
00070
00071
00072 #ifndef _MSVC
00073 #ifndef __APPLE_CC__
00074 #ifndef _WINT_T
00075 #define _WINT_T
00076 typedef unsigned int wint_t;
00077 #endif
00078 #endif
00079 #endif
00080
00081 #ifndef M_PI
00082 #define M_PI 3.14159265358979323846
00083 #endif
00084
00085
00086 #ifdef _MSVC
00087 #define strcasecmp stricmp
00088 #define rint(x) ((double) (long) floor(x + 0.5))
00089 #endif
00090
00091 #ifdef _LIBICONV_H
00092 #define ICONV_INPUT_CAST
00093 #else
00094
00095
00096
00097
00098
00099 #define ICONV_INPUT_CAST (char**)
00100 #endif
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113 #define exposed_class class
00114 #define invisible public
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145 namespace sswf
00146 {
00147
00148
00149
00150
00151 void assert(int cond, const char *format, ...)
00152 #ifndef _MSVC
00153 __attribute__ ((format (printf, 2, 3)))
00154 #endif
00155 ;
00156
00157
00158 #if DEBUG
00159 inline void assert(int cond, const char *format, ...)
00160 {
00161 va_list ap;
00162
00163
00164 if(cond) {
00165 return;
00166 }
00167 fflush(stdout);
00168 fflush(stderr);
00169 fprintf(stderr, "\n");
00170 va_start(ap, format);
00171 vfprintf(stderr, format, ap);
00172 va_end(ap);
00173 fprintf(stderr, ".\n");
00174 fflush(stderr);
00175 abort();
00176 }
00177 #else
00178 inline void assert(int , const char * , ...) {}
00179 #endif
00180
00181
00182 typedef unsigned short sswf_id_t;
00183 typedef unsigned short sswf_frame_t;
00184 typedef int32_t sswf_ucs4_t;
00185
00186
00187 #define SSWF_ID_NONE ((sswf_id_t) -1) // this is an invalid ID (it seems)
00188
00189
00190 extern void swap(void *s1, void *s2, size_t size);
00191 extern int wctomb(const sswf_ucs4_t *wc, size_t wc_len, char *mb, size_t& mb_size);
00192 extern int mbtowc(const char *mb, size_t mb_len, sswf_ucs4_t *& wc, size_t& wc_len);
00193 extern char * wcname(sswf_ucs4_t wc, char *result);
00194 extern long wcslen(sswf_ucs4_t *wcstr);
00195
00196 inline unsigned short swap_short(unsigned short s)
00197 {
00198 return (s >> 8) | (s << 8);
00199 }
00200
00201 inline unsigned int swap_int(unsigned int l)
00202 {
00203 return (l >> 24) | (l << 24)
00204 | ((l >> 8) & 0x0000FF00)
00205 | ((l << 8) & 0x00FF0000);
00206 }
00207
00208 extern const char * sswf_version(void);
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219 class ErrorManager
00220 {
00221 public:
00222 enum error_code_t {
00223 ERROR_CODE_NONE = 0,
00224
00225 ERROR_CODE_ACTION_OVERFLOW,
00226 ERROR_CODE_ALPHA_MISMATCH,
00227 ERROR_CODE_BAD_STATE_FLAGS,
00228 ERROR_CODE_BUTTON_MISSING_STATE,
00229 ERROR_CODE_CANNOT_CHANGE_STYLE,
00230 ERROR_CODE_CHILDREN_NOT_SUPPORTED,
00231 ERROR_CODE_COMPRESSED_SOUND_8BITS,
00232 ERROR_CODE_EMPTY_POSITION_RANGE,
00233 ERROR_CODE_ENDED_ACTION_SCRIPT,
00234 ERROR_CODE_ENHANCED_LINE_REQUIRES_ALPHA,
00235 ERROR_CODE_ENVELOPE_EXISTS,
00236 ERROR_CODE_ENVELOPE_OVERFLOW,
00237 ERROR_CODE_FILE_NOT_FOUND,
00238 ERROR_CODE_FORMAT_LOCKED,
00239 ERROR_CODE_GLYPH_DEFINED_TWICE,
00240 ERROR_CODE_ICONV_ENCODER_NOT_AVAILABLE,
00241 ERROR_CODE_ICONV_FAILED,
00242 ERROR_CODE_IO,
00243 ERROR_CODE_INCOMPATIBLE_CHILD,
00244 ERROR_CODE_INCOMPATIBLE_MORPH,
00245 ERROR_CODE_INTERNAL_ERROR,
00246 ERROR_CODE_INVALID_DEPTH,
00247 ERROR_CODE_INVALID_EM_SQUARE,
00248 ERROR_CODE_INVALID_FILL_PARAMETER,
00249 ERROR_CODE_INVALID_FOCAL,
00250 ERROR_CODE_INVALID_GLYPH,
00251 ERROR_CODE_INVALID_IDENTIFIER,
00252 ERROR_CODE_INVALID_IMAGE,
00253 ERROR_CODE_INVALID_INTERPOLATION_MODE,
00254 ERROR_CODE_INVALID_LINE_INFO,
00255 ERROR_CODE_INVALID_MORPH_INDEX,
00256 ERROR_CODE_INVALID_OBJECT_EXPORTED,
00257 ERROR_CODE_INVALID_POSITION,
00258 ERROR_CODE_INVALID_SHAPE,
00259 ERROR_CODE_INVALID_SPREAD_MODE,
00260 ERROR_CODE_INVALID_STYLE,
00261 ERROR_CODE_INVALID_TEXT_SETUP,
00262 ERROR_CODE_JPEG,
00263 ERROR_CODE_LOOP_ZERO,
00264 ERROR_CODE_MISSING_FRAME_NAME,
00265 ERROR_CODE_MISSING_SHAPE,
00266 ERROR_CODE_MORPH_GRADIENT_LIMIT,
00267 ERROR_CODE_MORPH_REQUIRES_ALPHA,
00268 ERROR_CODE_NAME_TOO_LONG,
00269 ERROR_CODE_NEGATIVE_MITER,
00270 ERROR_CODE_NO_FOCAL_WITH_MORPH,
00271 ERROR_CODE_NO_HEADER,
00272 ERROR_CODE_NO_STATES,
00273 ERROR_CODE_NO_SUCH_GLYPH,
00274 ERROR_CODE_LABEL_NOT_FOUND,
00275 ERROR_CODE_LABEL_OVERFLOW,
00276 ERROR_CODE_MORPH_MISMATCH,
00277 ERROR_CODE_OBJECT_NOT_FOUND,
00278 ERROR_CODE_REGISTER_OVERFLOW,
00279 ERROR_CODE_SIZE_MISMATCH,
00280 ERROR_CODE_START_SOUND_NO_INFO,
00281 ERROR_CODE_TOO_MANY_STYLES,
00282 ERROR_CODE_TWO_OR_MORE_JPEGTABLES,
00283 ERROR_CODE_TWO_OR_MORE_METADATA,
00284 ERROR_CODE_UNEXPECTED_EVENT_FLAG,
00285 ERROR_CODE_UNKNOWN_FORMAT,
00286 ERROR_CODE_UNKNOWN_OBJECT_EXPORTED,
00287 ERROR_CODE_UNSUPPORTED_IMAGE_FORMAT,
00288 ERROR_CODE_UNSUPPORTED_SOUND_FORMAT,
00289 ERROR_CODE_VERSION_UNSATISFIED,
00290 ERROR_CODE_VOLUME_OUT_OF_RANGE,
00291
00292 ERROR_CODE_max
00293 };
00294
00295 ErrorManager(void);
00296
00297 void Reset(void);
00298 int Count(void) const;
00299 static error_code_t KeepFirst(error_code_t a, error_code_t b);
00300
00301 error_code_t OnError(error_code_t errcode, const char *message, va_list ap) const;
00302
00303 public:
00304 class InternalErrorException {};
00305
00306 class ErrorHandler
00307 {
00308 public:
00309 virtual ~ErrorHandler();
00310 virtual error_code_t OnError(error_code_t errcode, const char *msg) = 0;
00311 };
00312
00313 ErrorHandler * SetErrorHandler(ErrorHandler *error_handler);
00314 error_code_t OnError(error_code_t errcode, const char *message, ...) const;
00315
00316 private:
00317 mutable int f_error_count;
00318 ErrorHandler * f_error_handler;
00319 };
00320
00321
00322
00323
00324
00325
00326 class Buffer;
00327 class MemBuffer
00328 {
00329 public:
00330 MemBuffer(void);
00331 virtual ~MemBuffer();
00332
00333 void AttachBuffer(Buffer *buffer);
00334 Buffer * GetBuffer(void) const;
00335
00336 private:
00337 Buffer * f_buffer;
00338 };
00339
00340
00341 class Buffer
00342 {
00343 public:
00344 Buffer(Buffer **head, size_t size, const char *info);
00345 Buffer(Buffer **head, MemBuffer *ptr, size_t size, const char *info);
00346
00347 ~Buffer();
00348
00349 void * Realloc(size_t size);
00350 void * Data(void) const { return f_data; }
00351 Buffer * Next(void) const { return (Buffer *) f_next; }
00352 Buffer * Previous(void) const { return (Buffer *) f_previous; }
00353 size_t Size(void) const { return f_size; }
00354 const char * Info(void) const { return f_info; }
00355
00356 static Buffer * FindBuffer(void *ptr);
00357 #if 0
00358
00359 static bool IsBuffer(void *ptr);
00360 #endif
00361
00362 private:
00363
00364 struct mem_buffer_t {
00365 unsigned long f_magic;
00366 Buffer * f_buffer;
00367 };
00368 enum {
00369 DMAGIC = (unsigned long) 0x53535746,
00370 OMAGIC = (unsigned long) 0x5353574F
00371 };
00372 #define SSWF_ALIGN(value, modulo) (((value) + ((modulo) - 1)) & - (long) (modulo))
00373 #define SSWF_SPACE SSWF_ALIGN(sizeof(mem_buffer_t), sizeof(double))
00374 #if DEBUG
00375 void Test(void);
00376 #define SSWF_SAFE (sizeof(double) * 32)
00377 #define SSWF_TEST ((long)0xBADC0FFE)
00378 #else
00379 #define SSWF_SAFE 0
00380 #endif
00381
00382 Buffer ** f_head;
00383 Buffer * f_next;
00384 Buffer * f_previous;
00385 const char * f_info;
00386 size_t f_size;
00387 mutable void * f_data;
00388 };
00389
00390
00391 class MemoryManager
00392 {
00393 public:
00394 MemoryManager(void);
00395 virtual ~MemoryManager();
00396
00397 void MemAttach(MemBuffer *ptr, size_t size, const char *info);
00398 void * MemAlloc(size_t size, const char *info);
00399 void * MemRealloc(void *ptr, size_t size, const char *info);
00400 void MemFree(void *ptr);
00401 void MemClean(void *ptr);
00402 char * StrDup(const char *string);
00403 char * StrCat(const char *s1, const char *s2);
00404 #if DEBUG
00405 void MemTest(void *ptr);
00406 #endif
00407 unsigned long Size(void *ptr);
00408
00409 private:
00410 Buffer * f_head;
00411 };
00412
00413
00414
00415 class ItemBase : public MemBuffer
00416 {
00417 public:
00418 ItemBase(void) {}
00419 virtual ~ItemBase() {}
00420 };
00421
00422
00423 class Vectors : public MemoryManager, public MemBuffer
00424 {
00425 public:
00426 Vectors(void);
00427 Vectors(const Vectors& vector);
00428 ~Vectors();
00429
00430 ItemBase * Get(int index) const;
00431 void Set(int index, ItemBase *vector);
00432 void Insert(int index, ItemBase *vector);
00433 void SetSize(int size);
00434 int Count(void) const { return f_count; }
00435 void Empty(void) { f_count = 0; }
00436
00437 public:
00438 Vectors& operator = (const Vectors& vectors);
00439
00440 private:
00441 int f_count;
00442 int f_max;
00443 ItemBase ** f_vectors;
00444 };
00445
00446
00447
00448
00449
00450
00451
00452 class Data : public MemoryManager
00453 {
00454 public:
00455 Data(void);
00456 ~Data();
00457
00458 void Empty(void) { f_pos = 0; }
00459 void Align(void);
00460 void Overwrite(size_t offset, const void *ptr, size_t size);
00461 void OverwriteByte(size_t offset, char c);
00462 void OverwriteShort(size_t offset, short s);
00463 void OverwriteLong(size_t offset, long l);
00464 void Write(const void *ptr, size_t size);
00465 void WriteBits(long value, size_t bits);
00466 void PutByte(char c);
00467 void PutShort(short s);
00468 void PutLong(long l);
00469 void PutDLong(int64_t ll);
00470 void PutShortFloat(float f);
00471 void PutLongFloat(float f);
00472 void PutDoubleFloat(double f);
00473 void PutString(const char *string);
00474 void Append(const Data& append);
00475
00476 void Read(void *& ptr, size_t& size);
00477
00478
00479 unsigned long ByteSize(void) const { return (f_pos + CHAR_BIT - 1) / CHAR_BIT; }
00480 unsigned long GetSize(void) const { return f_pos; }
00481 void SetSize(unsigned long size);
00482
00483 private:
00484 void AdjustSize(size_t size);
00485
00486 unsigned long f_pos;
00487 unsigned long f_size;
00488 char * f_data;
00489 };
00490
00491
00492
00493
00494
00495
00496
00497 class SRectangle
00498 {
00499 public:
00500 SRectangle(void);
00501
00502 void Reset(void);
00503 void Set(long xmin, long xmax, long ymin, long ymax);
00504 void SetReorder(long xmin, long xmax, long ymin, long ymax);
00505 long XMin(void) const;
00506 long XMax(void) const;
00507 long YMin(void) const;
00508 long YMax(void) const;
00509 bool IsEmpty(void) const;
00510
00511 void Save(Data& data) const;
00512
00513 private:
00514 long f_xmin;
00515 long f_xmax;
00516 long f_ymin;
00517 long f_ymax;
00518 };
00519
00520
00521 class Color
00522 {
00523 public:
00524 Color(void) { Reset(); }
00525
00526 void Reset(void);
00527 void Set(unsigned char red, unsigned char green, unsigned char blue, unsigned char alpha = 255);
00528 unsigned char Red(void) const { return f_red; }
00529 unsigned char Green(void) const { return f_green; }
00530 unsigned char Blue(void) const { return f_blue; }
00531 unsigned char Alpha(void) const { return f_alpha; }
00532
00533 void Save(Data& data, bool save_alpha = true);
00534
00535 bool IsSolid(void) const { return f_alpha == 255; }
00536 bool IsInvisible(void) const { return f_alpha == 0; }
00537
00538 public:
00539 bool operator == (const Color& color) const;
00540 bool operator != (const Color& color) const;
00541
00542 private:
00543 unsigned char f_red;
00544 unsigned char f_green;
00545 unsigned char f_blue;
00546 unsigned char f_alpha;
00547 };
00548
00549
00550
00551 class ColorTransform
00552 {
00553 public:
00554 ColorTransform(void);
00555
00556 void Reset(void);
00557 void SetAdd(double red, double green, double blue, double alpha = 0.0);
00558 void SetMult(double red, double green, double blue, double alpha = 1.0);
00559 double AddRed(void) const { return f_add_red; }
00560 double AddGreen(void) const { return f_add_green; }
00561 double AddBlue(void) const { return f_add_blue; }
00562 double AddAlpha(void) const { return f_add_alpha; }
00563 double MultRed(void) const { return f_add_red; }
00564 double MultGreen(void) const { return f_add_green; }
00565 double MultBlue(void) const { return f_add_blue; }
00566 double MultAlpha(void) const { return f_add_alpha; }
00567
00568 void Save(Data& data, bool save_alpha = true);
00569
00570 bool IsNull(bool with_alpha) const;
00571 bool IsSolidCompatible(void) const;
00572
00573 private:
00574 double f_add_red;
00575 double f_add_green;
00576 double f_add_blue;
00577 double f_add_alpha;
00578 double f_mult_red;
00579 double f_mult_green;
00580 double f_mult_blue;
00581 double f_mult_alpha;
00582 };
00583
00584
00585
00586 class Matrix
00587 {
00588 public:
00589 Matrix(void);
00590
00591 void Reset(void);
00592 void SetScale(double x, double y) { f_scale_x = x; f_scale_y = y; }
00593 void SetScale(double scale) { f_scale_x = scale; f_scale_y = scale; }
00594 void SetRotate(double rotate);
00595 void SetSkew(double skew0, double skew1) { f_skew_0 = skew0; f_skew_1 = skew1; }
00596 void SetTranslate(long x, long y) { f_translate_x = x; f_translate_y = y; }
00597
00598 void Save(Data& data);
00599
00600 bool IsNull(void) const;
00601
00602 public:
00603 bool operator == (const Matrix& matrix) const;
00604 bool operator != (const Matrix& matrix) const;
00605
00606 private:
00607
00608 struct signed_matrix_t {
00609 long m[4];
00610 };
00611
00612 void ComputeMatrix(signed_matrix_t& m) const;
00613
00614 double f_scale_x;
00615 double f_scale_y;
00616 double f_rotate;
00617 long f_translate_x;
00618 long f_translate_y;
00619 double f_skew_0;
00620 double f_skew_1;
00621 };
00622
00623
00624
00625 class Envelope : public ItemBase
00626 {
00627 public:
00628 Envelope(unsigned long p, unsigned short l, unsigned short r);
00629 Envelope(const Envelope& envelope);
00630
00631 unsigned long Position(void) const;
00632 unsigned short Left(void) const;
00633 unsigned short Right(void) const;
00634 void Save(Data& data) const;
00635
00636 private:
00637 unsigned long f_position;
00638 unsigned short f_left;
00639 unsigned short f_right;
00640 };
00641
00642
00643 class SoundInfo : public MemoryManager
00644 {
00645 public:
00646 SoundInfo(ErrorManager& error_manager);
00647
00648 void SetSoundID(sswf_id_t id);
00649 void StopSound(bool stop = true);
00650 void NoMultiple(bool no_multiple = true);
00651 void SetRange(unsigned long start, unsigned long end);
00652 void SetLoop(unsigned short loop);
00653 void AddEnvelope(const Envelope& envelope);
00654
00655 ErrorManager::error_code_t PreSave(void);
00656 void Save(Data& data) const;
00657
00658 private:
00659 ErrorManager& f_error_manager;
00660 sswf_id_t f_sound_id;
00661 bool f_stop;
00662 bool f_no_multiple;
00663 unsigned long f_start_position;
00664 unsigned long f_end_position;
00665 unsigned short f_loop;
00666 Vectors f_envelopes;
00667 };
00668
00669
00670
00671
00672 class BlendMode
00673 {
00674 public:
00675 enum blend_mode_t {
00676 BLEND_MODE_UNDEFINED = -1,
00677 BLEND_MODE_NORMAL = 1,
00678 BLEND_MODE_LAYER = 2,
00679 BLEND_MODE_MULTIPLY = 3,
00680 BLEND_MODE_SCREEN = 4,
00681 BLEND_MODE_LIGHTEN = 5,
00682 BLEND_MODE_DARKEN = 6,
00683 BLEND_MODE_DIFFERENCE = 7,
00684 BLEND_MODE_ADD = 8,
00685 BLEND_MODE_SUBTRACT = 9,
00686 BLEND_MODE_INVERT = 10,
00687 BLEND_MODE_ALPHA = 11,
00688 BLEND_MODE_ERASE = 12,
00689 BLEND_MODE_OVERLAY = 13,
00690 BLEND_MODE_HARDLIGHT = 14
00691 };
00692
00693 BlendMode(void);
00694
00695 bool HasBlendMode(void) const;
00696 void SetBlendMode(blend_mode_t blend_mode_value);
00697 bool SetBlendModeByName(const char *blend_mode_name);
00698 blend_mode_t GetBlendMode(void) const;
00699
00700 void Save(Data& data);
00701
00702 private:
00703 blend_mode_t f_blend_mode;
00704 };
00705
00706
00707 class State : public ItemBase
00708 {
00709 public:
00710
00711 enum state_flags_t {
00712 STATE_FLAG_UP = 0x01,
00713 STATE_FLAG_OVER = 0x02,
00714 STATE_FLAG_DOWN = 0x04,
00715 STATE_FLAG_HIT_TEST = 0x08,
00716
00717 STATE_ALL_FLAGS = 0x0F
00718 };
00719
00720 explicit State(ErrorManager& error_manager);
00721
00722 void Reset(void);
00723 void SetObjectID(sswf_id_t id);
00724 bool SetFlags(unsigned char flags);
00725 void SetLayer(unsigned short layer);
00726 void SetMatrix(const Matrix& matrix);
00727 void SetColorTransform(const ColorTransform& color_transform);
00728 bool HasColorTransform(void) const;
00729 void SetBlendMode(const BlendMode& blend_mode);
00730 ErrorManager::error_code_t Save(Data& data, bool color_transform = false);
00731
00732 unsigned char GetFlags(void) const;
00733
00734 private:
00735 ErrorManager& f_error_manager;
00736 sswf_id_t f_id;
00737 bool f_has_color_transform;
00738 unsigned char f_flags;
00739 unsigned short f_layer;
00740 Matrix f_matrix;
00741 ColorTransform f_color_transform;
00742 BlendMode f_blend_mode;
00743 };
00744
00745
00746
00747
00748
00749 class Action;
00750 class Event : public MemoryManager, public ItemBase
00751 {
00752 public:
00753 Event(void);
00754
00755 void Reset(void);
00756 void SetEvents(unsigned long events);
00757 void SetKey(unsigned char key);
00758 unsigned long Events(void) const;
00759 unsigned long Conditions(void) const;
00760 unsigned char Key(void) const;
00761 Vectors& Actions(void);
00762
00763 static unsigned long StringToEvents(const char *s);
00764 static unsigned char StringToKeyCode(const char *s);
00765
00766
00767
00768
00769
00770 enum event_flag_t {
00771 EVENT_COND_MENU_LEAVE = 0x80000000,
00772 EVENT_COND_MENU_ENTER = 0x40000000,
00773
00774 EVENT_CONSTRUCT = 0x00040000,
00775 EVENT_KEY_PRESS = 0x00020000,
00776 EVENT_POINTER_DRAG_LEAVE = 0x00010000,
00777 EVENT_POINTER_DRAG_ENTER = 0x00008000,
00778 EVENT_POINTER_LEAVE = 0x00004000,
00779 EVENT_POINTER_ENTER = 0x00002000,
00780 EVENT_POINTER_RELEASE_OUTSIDE = 0x00001000,
00781 EVENT_POINTER_RELEASE_INSIDE = 0x00000800,
00782 EVENT_POINTER_PUSH = 0x00000400,
00783 EVENT_INITIALIZE = 0x00000200,
00784 EVENT_DATA = 0x00000100,
00785 EVENT_KEY_UP = 0x00000080,
00786 EVENT_KEY_DOWN = 0x00000040,
00787 EVENT_POINTER_UP = 0x00000020,
00788 EVENT_POINTER_DOWN = 0x00000010,
00789 EVENT_POINTER_MOVE = 0x00000008,
00790 EVENT_UNLOAD = 0x00000004,
00791 EVENT_ENTER_FRAME = 0x00000002,
00792 EVENT_ONLOAD = 0x00000001
00793 };
00794 #define SSWF_EVENT_V5 0x0000FF01 // flags present in V5
00795 #define SSWF_EVENT_V6 0x000300FE // flags added in V6
00796 #define SSWF_EVENT_V7 0x00040000 // flag added in V7
00797 #define SSWF_EVENT_CONDITIONS 0xC001FC00 // flags used by conditions in DefineButton2
00798 #define SSWF_EVENT_COUNT 20
00799 struct event_names_t {
00800 event_flag_t f_flag;
00801 const char * f_name;
00802 };
00803
00804 enum condition_flag_t {
00805 CONDITION_KEY_MASK = 0xFE00,
00806 CONDITION_KEY_SHIFT = 9,
00807 CONDITION_MENU_LEAVE = 0x0100,
00808 CONDITION_MENU_ENTER = 0x0080,
00809 CONDITION_POINTER_RELEASE_OUTSIDE = 0x0040,
00810 CONDITION_POINTER_DRAG_ENTER = 0x0020,
00811 CONDITION_POINTER_DRAG_LEAVE = 0x0010,
00812 CONDITION_POINTER_RELEASE_INSIDE = 0x0008,
00813 CONDITION_POINTER_PUSH = 0x0004,
00814 CONDITION_POINTER_LEAVE = 0x0002,
00815 CONDITION_POINTER_ENTER = 0x0001
00816 };
00817
00818 enum key_code_t {
00819 KEY_CODE_NONE = 0,
00820 KEY_CODE_LEFT_ARROW = 1,
00821 KEY_CODE_RIGHT_ARROW = 2,
00822 KEY_CODE_HOME = 3,
00823 KEY_CODE_END = 4,
00824 KEY_CODE_INSERT = 5,
00825 KEY_CODE_DELETE = 6,
00826 KEY_CODE_BACKSPACE = 8,
00827 KEY_CODE_ENTER = 13,
00828 KEY_CODE_UP_ARROW = 14,
00829 KEY_CODE_DOWN_ARROW = 15,
00830 KEY_CODE_PAGE_UP = 16,
00831 KEY_CODE_PAGE_DOWN = 17,
00832 KEY_CODE_TAB = 18,
00833 KEY_CODE_ESCAPE = 19,
00834 KEY_CODE_SPACE = 20,
00835
00836 };
00837 #define SSWF_KEY_COUNT 15
00838 struct key_names_t {
00839 key_code_t f_code;
00840 const char * f_name;
00841 };
00842
00843 public:
00844 static const event_names_t g_event_names[SSWF_EVENT_COUNT];
00845 static const key_names_t g_key_names[SSWF_KEY_COUNT];
00846
00847 private:
00848 unsigned long f_events;
00849 unsigned char f_key;
00850 Vectors f_actions;
00851 };
00852
00853
00854
00855
00856
00857 class Style : public ItemBase
00858 {
00859 public:
00860 enum style_t {
00861 STYLE_TYPE_UNKNOWN = 0,
00862 STYLE_TYPE_NO_LINE,
00863 STYLE_TYPE_NO_FILL,
00864 STYLE_TYPE_LINE,
00865 STYLE_TYPE_ENHANCED_LINE,
00866 STYLE_TYPE_SOLID,
00867 STYLE_TYPE_GRADIENT_LINEAR,
00868 STYLE_TYPE_GRADIENT_RADIAL,
00869 STYLE_TYPE_GRADIENT_FOCAL,
00870 STYLE_TYPE_BITMAP_TILLED,
00871 STYLE_TYPE_BITMAP_CLIPPED,
00872 STYLE_TYPE_BITMAP_HARDEDGE_TILLED,
00873 STYLE_TYPE_BITMAP_HARDEDGE_CLIPPED,
00874
00875 STYLE_TYPE_MATRIX,
00876
00877
00878 STYLE_TYPE_max
00879 };
00880
00881 enum cap_t {
00882 STYLE_LINE_CAP_SAME = -1,
00883 STYLE_LINE_CAP_ROUND = 0,
00884 STYLE_LINE_CAP_NONE = 1,
00885 STYLE_LINE_CAP_SQUARE = 2
00886 };
00887
00888 enum join_t {
00889 STYLE_LINE_JOIN_UNKNOWN = -1,
00890 STYLE_LINE_JOIN_ROUND = 0,
00891 STYLE_LINE_JOIN_BEVEL = 1,
00892 STYLE_LINE_JOIN_MITER = 2
00893 };
00894
00895 enum spread_t {
00896 STYLE_GRADIENT_SPREAD_PAD = 0,
00897 STYLE_GRADIENT_SPREAD_REFLECT = 1,
00898 STYLE_GRADIENT_SPREAD_REPEAT = 2,
00899 };
00900
00901 enum interpolation_t {
00902 STYLE_GRADIENT_INTERPOLATION_NORMAL = 0,
00903 STYLE_GRADIENT_INTERPOLATION_LINEAR = 1
00904 };
00905
00906 explicit Style(ErrorManager& error_manager);
00907 virtual ~Style();
00908
00909 void Reset(void);
00910 style_t Type(void) const { return f_style; }
00911 signed char Gradients(void) const { return f_gradient; }
00912 bool HasMorph(void) const { return f_morph; }
00913 bool HasAlpha(void) const { return f_use_alpha; }
00914 bool HasHardEdges(void) const { return f_style == STYLE_TYPE_BITMAP_HARDEDGE_TILLED
00915 || f_style == STYLE_TYPE_BITMAP_HARDEDGE_CLIPPED; }
00916 bool SetType(style_t style_type);
00917 bool SetLine(int index, unsigned short width, const Color& color);
00918 bool SetLineCaps(cap_t start, cap_t end = STYLE_LINE_CAP_SAME);
00919 bool SetLineJoin(join_t join, float miter_limit_factor = 0.0f);
00920 bool SetLineScale(bool horiz, bool vert);
00921 bool SetLinePixelHinting(bool pixel_hinting);
00922 bool SetLineNoClose(bool no_close);
00923 bool SetLineFillStyle(const Style& fill_style);
00924 bool SetColor(int index, const Color& color);
00925 bool SetGradient(int index, int pos, const Color& color);
00926 bool SetGradientModes(spread_t spread, interpolation_t interpolation);
00927 bool SetGradientFocal(float focal);
00928 bool SetMatrix(int index, const Matrix& matrix);
00929 bool SetBitmap(sswf_id_t id_ref);
00930 bool SetClipping(void);
00931
00932 ErrorManager::error_code_t Save(Data& data, bool save_alpha, bool save_morph);
00933
00934 public:
00935
00936
00937
00938
00939
00940
00941
00942 static const signed char MAX_GRADIENTS = 15;
00943
00944 bool operator == (const Style& style) const;
00945
00946 private:
00947
00948 ErrorManager& f_error_manager;
00949
00950
00951 style_t f_style;
00952
00953
00954 bool f_morph;
00955
00956
00957 bool f_use_alpha;
00958
00959
00960 unsigned short f_line_width[2];
00961 cap_t f_start_cap_style;
00962 cap_t f_end_cap_style;
00963 join_t f_join_style;
00964 float f_miter_limit_factor;
00965 bool f_no_hscale;
00966 bool f_no_vscale;
00967 bool f_pixel_hinting;
00968 bool f_no_close;
00969 Style * f_fill_style;
00970
00971
00972 Color f_color[2];
00973
00974
00975 sswf_id_t f_bitmap_ref;
00976
00977
00978 Matrix f_matrix[2];
00979
00980
00981 signed char f_gradient;
00982 unsigned char f_gradient_pos[MAX_GRADIENTS * 2];
00983 Color f_gradient_color[MAX_GRADIENTS * 2];
00984 spread_t f_gradient_spread;
00985 interpolation_t f_gradient_interpolation;
00986 signed short f_gradient_focal;
00987 };
00988
00989
00990
00991
00992
00993 class Edges : public MemoryManager, public ItemBase
00994 {
00995 public:
00996
00997
00998 struct edge_t {
00999 long f_x;
01000 long f_y;
01001 long f_ctrl_x;
01002 long f_ctrl_y;
01003
01004 edge_t(void)
01005 {
01006 f_x = 0;
01007 f_y = 0;
01008 f_ctrl_x = LONG_MIN;
01009 f_ctrl_y = LONG_MIN;
01010 }
01011 edge_t(long x, long y)
01012 {
01013 f_x = x;
01014 f_y = y;
01015 f_ctrl_x = LONG_MIN;
01016 f_ctrl_y = LONG_MIN;
01017 }
01018 edge_t(long x, long y, long ctrl_x, long ctrl_y)
01019 {
01020 f_x = x;
01021 f_y = y;
01022 f_ctrl_x = ctrl_x;
01023 f_ctrl_y = ctrl_y;
01024 }
01025 edge_t(const edge_t& edge)
01026 {
01027 f_x = edge.f_x;
01028 f_y = edge.f_y;
01029 f_ctrl_x = edge.f_ctrl_x;
01030 f_ctrl_y = edge.f_ctrl_y;
01031 }
01032 edge_t& operator = (const edge_t& edge)
01033 {
01034 if(this != &edge) {
01035 f_x = edge.f_x;
01036 f_y = edge.f_y;
01037 f_ctrl_x = edge.f_ctrl_x;
01038 f_ctrl_y = edge.f_ctrl_y;
01039 }
01040 return *this;
01041 }
01042 bool IsLine(void) const { return f_ctrl_x == LONG_MIN || f_ctrl_y == LONG_MIN; }
01043 };
01044
01045 public:
01046
01047
01048 enum {
01049
01050 EDGE_BLOCK = 64
01051 };
01052
01053 Edges(void);
01054 virtual ~Edges();
01055
01056
01057 void Set(long x, long y) { edge_t edge(x, y); Set(-1, edge); }
01058 void Set(long x, long y, long ctrl_x, long ctrl_y) { edge_t edge(x, y, ctrl_x, ctrl_y); Set(-1, edge); }
01059 void Set(int index, long x, long y, long ctrl_x, long ctrl_y) { edge_t edge(x, y, ctrl_x, ctrl_y); Set(index, edge); }
01060
01061 void Save(Data& data, long& x, long& y);
01062
01063 public:
01064 void Set(const edge_t& edge) { Set(-1, edge); }
01065 void Set(int index, const edge_t& edge);
01066
01067 private:
01068
01069 struct array_edge_t : public ItemBase {
01070 edge_t f_edge[EDGE_BLOCK];
01071 };
01072
01073
01074 Edges(const Edges& edges) {}
01075 Edges& operator = (const Edges& edges) { return *this; }
01076
01077 void SaveEdge(Data& data, const edge_t& edge, long& x, long& y);
01078
01079 Vectors f_edges;
01080 int f_pos;
01081 array_edge_t f_array;
01082 };
01083
01084
01085
01086
01087
01088
01089
01090
01091
01092 class TagHeader;
01093 class TagBase : public MemoryManager
01094 {
01095 public:
01096
01097 enum swf_tag_t {
01098 SWF_TAG_UNKNOWN = -1,
01099
01100
01101 SWF_TAG_END = 0,
01102 SWF_TAG_SHOW_FRAME = 1,
01103 SWF_TAG_DEFINE_SHAPE = 2,
01104 SWF_TAG_PLACE_OBJECT = 4,
01105 SWF_TAG_REMOVE_OBJECT = 5,
01106 SWF_TAG_DEFINE_BITS = 6,
01107 SWF_TAG_DEFINE_BITS_JPEG = 6,
01108 SWF_TAG_DEFINE_BUTTON = 7,
01109 SWF_TAG_JPEG_TABLES = 8,
01110 SWF_TAG_SET_BACKGROUND_COLOR = 9,
01111 SWF_TAG_DEFINE_FONT = 10,
01112 SWF_TAG_DEFINE_TEXT = 11,
01113 SWF_TAG_DO_ACTION = 12,
01114 SWF_TAG_DEFINE_FONT_INFO = 13,
01115
01116
01117 SWF_TAG_DEFINE_SOUND = 14,
01118 SWF_TAG_START_SOUND = 15,
01119 SWF_TAG_STOP_SOUND = 16,
01120 SWF_TAG_DEFINE_BUTTON_SOUND = 17,
01121 SWF_TAG_SOUND_STREAM_HEAD = 18,
01122 SWF_TAG_SOUND_STREAM_BLOCK = 19,
01123 SWF_TAG_DEFINE_BITS_LOSSLESS = 20,
01124 SWF_TAG_DEFINE_BITS_JPEG2 = 21,
01125 SWF_TAG_DEFINE_SHAPE2 = 22,
01126 SWF_TAG_DEFINE_BUTTON_COLOR_TRANSFORM = 23,
01127 SWF_TAG_PROTECT = 24,
01128
01129
01130 SWF_TAG_PLACE_OBJECT2 = 26,
01131 SWF_TAG_REMOVE_OBJECT2 = 28,
01132 SWF_TAG_DEFINE_SHAPE3 = 32,
01133 SWF_TAG_DEFINE_TEXT2 = 33,
01134 SWF_TAG_DEFINE_BUTTON2 = 34,
01135 SWF_TAG_DEFINE_BITS_JPEG3 = 35,
01136 SWF_TAG_DEFINE_BITS_LOSSLESS2 = 36,
01137 SWF_TAG_DEFINE_SPRITE = 39,
01138 SWF_TAG_PRODUCT_INFO = 41,
01139 SWF_TAG_FRAME_LABEL = 43,
01140 SWF_TAG_DEFINE_BEHAVIOR = 44,
01141 SWF_TAG_SOUND_STREAM_HEAD2 = 45,
01142 SWF_TAG_DEFINE_MORPH_SHAPE = 46,
01143 SWF_TAG_DEFINE_FONT2 = 48,
01144 SWF_TAG_DEFINE_INFO = 49,
01145
01146
01147 SWF_TAG_TEXT_FIELD = 37,
01148
01149
01150 SWF_TAG_DEFINE_FUNCTION = 53,
01151 SWF_TAG_PLACE_FUNCTION = 54,
01152 SWF_TAG_GENERATE_TAG_OBJECT = 55,
01153
01154
01155 SWF_TAG_EXPORT = 56,
01156 SWF_TAG_IMPORT = 57,
01157 SWF_TAG_PROTECT_DEBUG = 58,
01158
01159
01160 SWF_TAG_DO_INIT_ACTION = 59,
01161 SWF_TAG_DEFINE_VIDEO_STREAM = 60,
01162 SWF_TAG_VIDEO_FRAME = 61,
01163 SWF_TAG_DEFINE_FONT_INFO2 = 62,
01164 SWF_TAG_DEBUG_ID = 63,
01165 SWF_TAG_PROTECT_DEBUG2 = 64,
01166
01167
01168 SWF_TAG_SCRIPT_LIMITS = 65,
01169 SWF_TAG_SET_TAB_INDEX = 66,
01170
01171
01172 SWF_TAG_FILE_ATTRIBUTES = 69,
01173 SWF_TAG_PLACE_OBJECT3 = 70,
01174 SWF_TAG_IMPORT2 = 71,
01175 SWF_TAG_DEFINE_FONT_ALIGN_ZONES = 73,
01176 SWF_TAG_CSM_TEXT_SETTINGS = 74,
01177 SWF_TAG_DEFINE_FONT3 = 75,
01178 SWF_TAG_METADATA = 77,
01179 SWF_TAG_DEFINE_SCALING_GRID = 78,
01180 SWF_TAG_DEFINE_SHAPE4 = 83,
01181 SWF_TAG_DEFINE_MORPH_SHAPE2 = 84,
01182
01183
01184 SWF_TAG_ACTIONSCRIPT2 = 72,
01185 SWF_TAG_ACTIONSCRIPT2_INSTANTIATE = 76,
01186 SWF_TAG_ACTIONSCRIPT2_DEFINE = 82,
01187 SWF_TAG_SCENE_FRAME_DATA = 86,
01188 SWF_TAG_DEFINE_BINARY_DATA = 87,
01189 SWF_TAG_DEFINE_FONT_NAME = 88,
01190
01191 SWF_TAG_max
01192 };
01193 typedef long swf_type_t;
01194
01195 #define SWF_TYPE_DEFINE 0x00000001 // a definition tag, must be in the main movie
01196 #define SWF_TYPE_CONTROL 0x00000002 // a control tag, can be in sprites as well
01197 #define SWF_TYPE_UNIQUE 0x00000004 // a unique tag, can't be duplicated in the movie (merge if possible)
01198 #define SWF_TYPE_START 0x00000008 // if present, put it near the start of the movie
01199 #define SWF_TYPE_ONE 0x00000010 // (should) use at most one per frame
01200 #define SWF_TYPE_REFERENCE 0x00000020 // object includes references to other objects
01201 #define SWF_TYPE_HAS_ID 0x00000040 // this object was derived from TagBaseID and has an ID
01202
01203 #define SWF_TYPE_SCRIPT 0x20000000 // object can accept action scripts
01204 #define SWF_TYPE_SPRITE 0x40000000 // this is a sprite (can include other tags)
01205 #define SWF_TYPE_HEADER 0x80000000 // the header
01206
01207 virtual ~TagBase();
01208
01209 ErrorManager::error_code_t SaveString(Data& data, const char *string);
01210 static int SaveTag(Data& data, swf_tag_t tag, size_t size);
01211
01212 static long SIBitSize(long value);
01213 static long UIBitSize(unsigned long value);
01214 static long Double2Signed16(double value);
01215 static long Double2Signed(double value);
01216 static double Signed2Double(long value);
01217
01218 virtual void MinimumVersion(unsigned char version);
01219 virtual unsigned char Version(void) const;
01220
01221 const char * Name(void) const;
01222 const char * Label(void) const;
01223 void ResetFrames(void);
01224 void ShowFrame(void);
01225 sswf_frame_t FrameCount(void) const;
01226
01227 sswf_frame_t WhichFrame(void) const;
01228 void SetLabel(const char *label);
01229 TagBase * FindLabelledTag(const char *label) const;
01230 TagBase * FindTagWithID(sswf_id_t id, bool search_import = true) const;
01231 TagBase * Children(void);
01232 TagBase * Next(void);
01233 TagBase * Previous(void);
01234 TagBase * Parent(void);
01235 TagHeader * Header(void) const;
01236 virtual ErrorManager::error_code_t OnError(ErrorManager::error_code_t errcode, const char *message, va_list ap) const;
01237
01238 public:
01239 virtual ErrorManager::error_code_t Save(Data& data) = 0;
01240 virtual swf_type_t TypeFlags(void) const = 0;
01241 virtual ErrorManager::error_code_t OnError(ErrorManager::error_code_t errcode, const char *message, ...) const;
01242
01243
01244
01245
01246
01247
01248
01249
01250
01251
01252 void * f_userdata;
01253
01254 protected:
01255
01256 TagBase(const char *name, TagBase *parent);
01257 virtual ErrorManager::error_code_t PreSave(void);
01258 virtual ErrorManager::error_code_t PreSave2ndPass(void);
01259
01260 virtual ErrorManager::error_code_t OnNewChild(const char *child_name) const;
01261
01262 private:
01263 TagBase * FindLabel(const TagBase *p, const char *label) const;
01264 TagBase * FindID(const TagBase *p, sswf_id_t id, bool search_import) const;
01265
01266 const char * f_name;
01267 char * f_label;
01268
01269 TagBase * f_parent;
01270 TagBase * f_next;
01271 TagBase * f_previous;
01272 TagBase * f_children;
01273
01274 sswf_frame_t f_frames;
01275 };
01276
01277
01278
01279
01280
01281
01282
01283
01284
01285
01286
01287
01288
01289
01290
01291
01292 class TagHeader : public TagBase, public ErrorManager
01293 {
01294 public:
01295 TagHeader(void);
01296 virtual ~TagHeader();
01297
01298 virtual ErrorManager::error_code_t Save(Data& data);
01299 ErrorManager::error_code_t SaveEncodedString(Data& data, const char *string);
01300 virtual swf_type_t TypeFlags(void) const;
01301 virtual ErrorManager::error_code_t OnError(ErrorManager::error_code_t errcode, const char *message, va_list ap) const;
01302
01303 sswf_id_t NextID(void);
01304 void RemoveID(sswf_id_t id);
01305
01306
01307 virtual unsigned char Version(void) const;
01308 void SetVersion(unsigned char version);
01309 void SetMinimumVersion(unsigned char version);
01310 void SetMaximumVersion(unsigned char version);
01311
01312 void SetCompress(bool compress = true);
01313 void SetAutoOrder(bool auto_order = true);
01314 void SetUseNetwork(bool use_network = true);
01315 void SetFrame(const SRectangle& rect);
01316 const SRectangle& Frame(void) const;
01317
01318 void SetOutputEncoding(const char *encoding);
01319 void SetRate(float rate);
01320 float Rate(void) const;
01321
01322 public:
01323 virtual void MinimumVersion(unsigned char version);
01324 ErrorManager::error_code_t DefineMinimumVersion(int& min_version);
01325 virtual ErrorManager::error_code_t OnError(ErrorManager::error_code_t errcode, const char *message, ...) const;
01326
01327 protected:
01328 virtual ErrorManager::error_code_t PreSave(void);
01329 virtual ErrorManager::error_code_t OnNewChild(const char *child_name) const;
01330
01331 private:
01332
01333 unsigned char f_version;
01334 unsigned char f_min_version;
01335 unsigned char f_minimum_version;
01336 unsigned char f_maximum_version;
01337 SRectangle f_frame;
01338 float f_rate;
01339 bool f_compress;
01340 bool f_auto_order;
01341 bool f_use_network;
01342 bool f_has_metadata;
01343 bool f_has_jpegtables;
01344 sswf_id_t f_next_id;
01345 char * f_output_encoding;
01346 bool f_iconvertor_open;
01347 iconv_t f_iconvertor;
01348 #if DEBUG
01349 bool f_saving;
01350 #endif
01351 };
01352
01353
01354
01355
01356
01357
01358
01359
01360
01361
01362
01363
01364
01365
01366
01367
01368
01369
01370
01371
01372
01373
01374
01375
01376
01377
01378
01379
01380
01381 class ActionLabel;
01382 class Action : public ItemBase
01383 {
01384 public:
01385 enum action_t {
01386 ACTION_UNKNOWN = -1,
01387 ACTION_LABEL = -2,
01388 ACTION_min = 0x00,
01389
01390
01391 ACTION_END = 0x00,
01392 ACTION_NEXT_FRAME = 0x04,
01393 ACTION_PREVIOUS_FRAME = 0x05,
01394 ACTION_PLAY = 0x06,
01395 ACTION_STOP = 0x07,
01396 ACTION_TOGGLE_QUALITY = 0x08,
01397 ACTION_STOP_SOUND = 0x09,
01398 ACTION_ADD = 0x0A,
01399
01400 ACTION_SUBTRACT = 0x0B,
01401 ACTION_MULTIPLY = 0x0C,
01402 ACTION_DIVIDE = 0x0D,
01403 ACTION_EQUAL = 0x0E,
01404 ACTION_LESS_THAN = 0x0F,
01405 ACTION_LOGICAL_AND = 0x10,
01406 ACTION_LOGICAL_OR = 0x11,
01407 ACTION_LOGICAL_NOT = 0x12,
01408 ACTION_STRING_EQUAL = 0x13,
01409 ACTION_STRING_LENGTH = 0x14,
01410 ACTION_SUB_STRING = 0x15,
01411 ACTION_POP = 0x17,
01412 ACTION_INTEGRAL_PART = 0x18,
01413 ACTION_GET_VARIABLE = 0x1C,
01414 ACTION_SET_VARIABLE = 0x1D,
01415 ACTION_SET_TARGET2 = 0x20,
01416 ACTION_CONCATENATE = 0x21,
01417 ACTION_GET_PROPERTY = 0x22,
01418 ACTION_SET_PROPERTY = 0x23,
01419 ACTION_DUPLICATE_SPRITE = 0x24,
01420 ACTION_REMOVE_SPRITE = 0x25,
01421 ACTION_TRACE = 0x26,
01422 ACTION_START_DRAG = 0x27,
01423 ACTION_STOP_DRAG = 0x28,
01424 ACTION_STRING_LESS_THAN = 0x29,
01425 ACTION_THROW = 0x2A,
01426 ACTION_CAST_OBJECT = 0x2B,
01427 ACTION_IMPLEMENTS = 0x2C,
01428 ACTION_FSCOMMAND2 = 0x2D,
01429 ACTION_RANDOM = 0x30,
01430 ACTION_MBSTRING_LENGTH = 0x31,
01431 ACTION_ORD = 0x32,
01432 ACTION_CHR = 0x33,
01433 ACTION_GET_TIMER = 0x34,
01434 ACTION_SUB_MBSTRING = 0x35,
01435 ACTION_MBORD = 0x36,
01436 ACTION_MBCHR = 0x37,
01437 ACTION_DELETE = 0x3A,
01438 ACTION_SET_LOCAL_VAR = 0x3C,
01439 ACTION_SET_LOCAL_VARIABLE = 0x3C,
01440 ACTION_CALL_FUNCTION = 0x3D,
01441 ACTION_RETURN = 0x3E,
01442 ACTION_MODULO = 0x3F,
01443 ACTION_NEW = 0x40,
01444 ACTION_DECLARE_LOCAL_VAR = 0x41,
01445 ACTION_DECLARE_LOCAL_VARIABLE = 0x41,
01446 ACTION_DECLARE_ARRAY = 0x42,
01447 ACTION_DECLARE_OBJECT = 0x43,
01448 ACTION_TYPE_OF = 0x44,
01449 ACTION_GET_TARGET = 0x45,
01450 ACTION_ENUMERATE = 0x46,
01451 ACTION_ADD_TYPED = 0x47,
01452 ACTION_LESS_THAN_TYPED = 0x48,
01453 ACTION_EQUAL_TYPED = 0x49,
01454 ACTION_NUMBER = 0x4A,
01455 ACTION_STRING = 0x4B,
01456 ACTION_DUPLICATE = 0x4C,
01457 ACTION_SWAP = 0x4D,
01458 ACTION_GET_MEMBER = 0x4E,
01459 ACTION_SET_MEMBER = 0x4F,
01460 ACTION_INCREMENT = 0x50,
01461 ACTION_DECREMENT = 0x51,
01462 ACTION_CALL_METHOD = 0x52,
01463 ACTION_NEW_METHOD = 0x53,
01464 ACTION_INSTANCE_OF = 0x54,
01465 ACTION_ENUMERATE_OBJECT = 0x55,
01466 ACTION_AND = 0x60,
01467 ACTION_OR = 0x61,
01468 ACTION_XOR = 0x62,
01469 ACTION_SHIFT_LEFT = 0x63,
01470 ACTION_SHIFT_RIGHT = 0x64,
01471 ACTION_SHIFT_RIGHT_UNSIGNED = 0x65,
01472 ACTION_STRICT_EQUAL = 0x66,
01473 ACTION_GREATER_THAN_TYPED = 0x67,
01474 ACTION_STRING_GREATER_THAN = 0x68,
01475 ACTION_EXTENDS = 0x69,
01476 ACTION_GOTO_FRAME = 0x81,
01477 ACTION_URL = 0x83,
01478 ACTION_STORE_REGISTER = 0x87,
01479 ACTION_DECLARE_DICTIONARY = 0x88,
01480 ACTION_STRICT_MODE = 0x89,
01481 ACTION_WAIT_FOR_FRAME = 0x8A,
01482 ACTION_SET_TARGET = 0x8B,
01483 ACTION_GOTO_LABEL = 0x8C,
01484 ACTION_WAIT_FOR_FRAME2 = 0x8D,
01485 ACTION_DECLARE_FUNCTION2 = 0x8E,
01486 ACTION_TRY = 0x8F,
01487 ACTION_WITH = 0x94,
01488 ACTION_PUSH_DATA = 0x96,
01489 ACTION_BRANCH_ALWAYS = 0x99,
01490 ACTION_URL2 = 0x9A,
01491 ACTION_DECLARE_FUNCTION = 0x9B,
01492 ACTION_BRANCH_IF_TRUE = 0x9D,
01493 ACTION_CALL_FRAME = 0x9E,
01494 ACTION_GOTO_EXPRESSION = 0x9F,
01495
01496 ACTION_max = 0xFF
01497 };
01498
01499 Action(TagBase *tag, action_t action);
01500 virtual ~Action() {}
01501
01502 virtual Action * Duplicate(void) const;
01503 unsigned long Offset(void) const { return f_offset; }
01504 virtual unsigned char Version(void) const { return f_min_version; }
01505
01506 ErrorManager::error_code_t Save(Data& data);
01507 virtual Vectors * SubList(void);
01508 ErrorManager::error_code_t SaveList(const Vectors *list, Data& data, const Vectors *extra = 0);
01509 static int MinimumListVersion(const Vectors& list);
01510 static int GetMaximumRegister(const Vectors& list);
01511 static ActionLabel * FindLabel(const Vectors& list, const char *label);
01512
01513 public:
01514 ErrorManager::error_code_t OnError(ErrorManager::error_code_t errcode, const char *message, ...) const;
01515
01516 protected:
01517 virtual ErrorManager::error_code_t SaveData(Data& data, Data& nested_data);
01518 virtual ErrorManager::error_code_t Save2ndPass(const Vectors& list, Data& data);
01519 virtual int GetMaxRegister(void) const { return 0; }
01520 ErrorManager::error_code_t SaveString(Data& data, const char *string);
01521 TagBase * Tag(void) const { return const_cast<TagBase *>(f_tag); }
01522
01523 const action_t f_action;
01524 unsigned long f_offset;
01525
01526 private:
01527 #if DEBUG
01528
01529
01530
01531
01532 Action(const Action& action);
01533 Action& operator = (const Action& action);
01534 #endif
01535
01536 TagBase * f_tag;
01537 unsigned char f_min_version;
01538 };
01539
01540
01541 class ActionBranch : public Action, public MemoryManager
01542 {
01543 public:
01544
01545
01546
01547
01548 ActionBranch(TagBase *tag, action_t action = ACTION_BRANCH_ALWAYS);
01549
01550 void SetLabel(const char *label);
01551
01552 private:
01553 virtual Action * Duplicate(void) const;
01554 virtual ErrorManager::error_code_t SaveData(Data& data, Data& nested_data);
01555 virtual ErrorManager::error_code_t Save2ndPass(const Vectors& list, Data& data);
01556
01557 char * f_label;
01558 };
01559
01560
01561
01562 class ActionCallFrame : public Action, public MemoryManager
01563 {
01564 public:
01565 ActionCallFrame(TagBase *tag);
01566
01567 private:
01568 virtual ErrorManager::error_code_t SaveData(Data& data, Data& nested_data);
01569 };
01570
01571
01572
01573 class ActionDictionary : public Action, public MemoryManager
01574 {
01575 public:
01576 ActionDictionary(TagBase *tag);
01577
01578 void AddString(const char *string);
01579
01580 private:
01581
01582 struct string_t : public ItemBase
01583 {
01584
01585 char * f_string;
01586 };
01587
01588 virtual Action * Duplicate(void) const;
01589 virtual ErrorManager::error_code_t SaveData(Data& data, Data& nested_data);
01590
01591
01592 Vectors f_strings;
01593 };
01594
01595
01596
01597 class ActionFunction : public Action, public MemoryManager
01598 {
01599 public:
01600
01601
01602
01603
01604 ActionFunction(TagBase *tag, action_t action = ACTION_DECLARE_FUNCTION);
01605
01606 enum action_function_t {
01607 ACTION_FUNCTION_LOAD_THIS = 0x0001,
01608 ACTION_FUNCTION_SUPPRESS_THIS = 0x0002,
01609 ACTION_FUNCTION_LOAD_ARGUMENTS = 0x0004,
01610 ACTION_FUNCTION_SUPPRESS_ARGUMENTS = 0x0008,
01611 ACTION_FUNCTION_LOAD_SUPER = 0x0010,
01612 ACTION_FUNCTION_SUPPRESS_SUPER = 0x0020,
01613 ACTION_FUNCTION_LOAD_ROOT = 0x0040,
01614 ACTION_FUNCTION_LOAD_PARENT = 0x0080,
01615 ACTION_FUNCTION_LOAD_GLOBAL = 0x0100
01616 };
01617
01618 void SetName(const char *name);
01619 void SetRegistersCount(unsigned int count);
01620 void AddParameter(const char *name, int register_number = -1);
01621 void AddAction(Action *action);
01622 virtual Vectors * SubList(void);
01623
01624
01625
01626 enum as_set_prop_flags_t {
01627 PROP_FLAG_IS_HIDDEN = 1,
01628 PROP_FLAG_CAN_DELETE = 2,
01629 PROP_FLAG_CAN_OVERWRITE = 4
01630 };
01631
01632 private:
01633
01634 struct parameter_t : public ItemBase
01635 {
01636
01637 char * f_name;
01638
01639 int f_register_number;
01640 };
01641
01642 virtual Action * Duplicate(void) const;
01643 virtual ErrorManager::error_code_t SaveData(Data& data, Data& nested_data);
01644
01645 char * f_name;
01646 unsigned int f_registers_count;
01647 unsigned short f_flags;
01648 Vectors f_parameters;
01649 Vectors f_actions;
01650 };
01651
01652
01653
01654 class ActionGoto : public Action, public MemoryManager
01655 {
01656 public:
01657
01658
01659
01660
01661
01662 ActionGoto(TagBase *tag, action_t action = ACTION_GOTO_FRAME);
01663
01664 void SetFrameName(const char *frame_name);
01665 void SetPlay(bool play) { f_play = play; }
01666
01667 private:
01668 virtual Action * Duplicate(void) const;
01669 virtual ErrorManager::error_code_t SaveData(Data& data, Data& nested_data);
01670
01671 char * f_frame_name;
01672 bool f_play;
01673 };
01674
01675
01676
01677 class ActionLabel : public Action, public MemoryManager
01678 {
01679 public:
01680 ActionLabel(TagBase *tag);
01681
01682 void SetLabel(const char *label);
01683 const char * GetLabel(void) const { return f_label; }
01684
01685 private:
01686 virtual Action * Duplicate(void) const;
01687
01688
01689 char * f_label;
01690 };
01691
01692
01693
01694
01695 class ActionPushData : public Action, public MemoryManager
01696 {
01697 public:
01698 ActionPushData(TagBase *tag);
01699
01700 void AddEmptyString(void) { AddString(0); }
01701 void AddString(const char *string);
01702 void AddTrue(void) { AddBoolean(true); }
01703 void AddFalse(void) { AddBoolean(false); }
01704 void AddBoolean(bool value);
01705 void AddInteger(long value);
01706 void AddFloat(float value);
01707 void AddDouble(double value);
01708 void AddNull(void);
01709 void AddLookup(unsigned short index);
01710 void AddRegister(unsigned char reg_index);
01711 void AddUndefined(void);
01712
01713 private:
01714 enum action_immediate_type_t
01715 {
01716 ACTION_IMMEDIATE_TYPE_UNKNOWN = -1,
01717 ACTION_IMMEDIATE_TYPE_STRING = 0x00,
01718 ACTION_IMMEDIATE_TYPE_FLOAT = 0x01,
01719 ACTION_IMMEDIATE_TYPE_NULL = 0x02,
01720 ACTION_IMMEDIATE_TYPE_UNDEFINED = 0x03,
01721 ACTION_IMMEDIATE_TYPE_REGISTER = 0x04,
01722 ACTION_IMMEDIATE_TYPE_BOOLEAN = 0x05,
01723 ACTION_IMMEDIATE_TYPE_DOUBLE = 0x06,
01724 ACTION_IMMEDIATE_TYPE_INTEGER = 0x07,
01725 ACTION_IMMEDIATE_TYPE_LOOKUP = 0x08,
01726 ACTION_IMMEDIATE_TYPE_LOOKUP_LARGE = 0x09
01727 };
01728
01729 struct action_immediate_t : public ItemBase
01730 {
01731 action_immediate_type_t f_type;
01732 union
01733 {
01734 char * f_string;
01735 float f_float32;
01736 double f_float64;
01737 bool f_boolean;
01738 long f_integer32;
01739 unsigned short f_lookup;
01740 unsigned char f_register;
01741 } f_data;
01742
01743 action_immediate_t(action_immediate_type_t type)
01744 {
01745 f_type = type;
01746 memset(&f_data, 0, sizeof(f_data));
01747 }
01748 };
01749
01750 virtual Action * Duplicate(void) const;
01751 virtual ErrorManager::error_code_t SaveData(Data& data, Data& nested_data);
01752 virtual int GetMaxRegister(void) const;
01753
01754 Vectors f_data;
01755 };
01756
01757
01758
01759
01760 class ActionSetTarget : public Action, public MemoryManager
01761 {
01762 public:
01763 ActionSetTarget(TagBase *tag);
01764
01765 void SetTarget(const char *target);
01766
01767 private:
01768 virtual Action * Duplicate(void) const;
01769 virtual ErrorManager::error_code_t SaveData(Data& data, Data& nested_data);
01770
01771 char * f_target;
01772 };
01773
01774
01775 class ActionStoreRegister : public Action, public MemoryManager
01776 {
01777 public:
01778 ActionStoreRegister(TagBase *tag);
01779
01780 void SetRegister(unsigned char reg);
01781
01782 private:
01783 virtual Action * Duplicate(void) const;
01784 virtual ErrorManager::error_code_t SaveData(Data& data, Data& nested_data);
01785 virtual int GetMaxRegister(void) const;
01786
01787 unsigned char f_reg;
01788 };
01789
01790
01791 class ActionStrictMode : public Action, public MemoryManager
01792 {
01793 public:
01794 ActionStrictMode(TagBase *tag);
01795
01796 void SetStrict(bool strict);
01797
01798 private:
01799 virtual Action * Duplicate(void) const;
01800 virtual ErrorManager::error_code_t SaveData(Data& data, Data& nested_data);
01801
01802 bool f_strict;
01803 };
01804
01805
01806 class ActionTry : public Action, public MemoryManager
01807 {
01808 public:
01809 ActionTry(TagBase *tag);
01810
01811 void AddTryAction(Action *action);
01812 void AddCatchAction(Action *action);
01813 void AddFinallyAction(Action *action);
01814 void SetIdentifier(int register_number);
01815 void SetIdentifier(const char *variable_name);
01816
01817 Vectors * SubListTry(void);
01818 Vectors * SubListCatch(void);
01819 Vectors * SubListFinally(void);
01820
01821 private:
01822 virtual Action * Duplicate(void) const;
01823 virtual ErrorManager::error_code_t SaveData(Data& data, Data& nested_data);
01824 virtual int GetMaxRegister(void) const;
01825 virtual unsigned char Version(void) const;
01826
01827 int f_register;
01828 char * f_variable_name;
01829 bool f_has_catch;
01830 bool f_has_finally;
01831 Vectors f_actions_try;
01832 Vectors f_actions_catch;
01833 Vectors f_actions_finally;
01834 };
01835
01836
01837
01838 class ActionURL : public Action, public MemoryManager
01839 {
01840 public:
01841
01842
01843
01844
01845 ActionURL(TagBase *tag, action_t action = ACTION_URL);
01846
01847 enum url_method_t {
01848 URL_METHOD_UNDEFINED = -1,
01849 URL_METHOD_NOVARIABLE = 0,
01850 URL_METHOD_NOVARIABLES = URL_METHOD_NOVARIABLE,
01851 URL_METHOD_GET = 1,
01852 URL_METHOD_POST = 2
01853 };
01854
01855 void SetURL(const char *url, const char *target);
01856 void SetMethod(url_method_t method);
01857
01858 private:
01859 virtual Action * Duplicate(void) const;
01860 virtual ErrorManager::error_code_t SaveData(Data& data, Data& nested_data);
01861
01862 char * f_url;
01863 char * f_target;
01864 url_method_t f_method;
01865 };
01866
01867
01868
01869 class ActionWaitForFrame : public Action, public MemoryManager
01870 {
01871 public:
01872
01873
01874
01875
01876 ActionWaitForFrame(TagBase *tag, action_t action = ACTION_WAIT_FOR_FRAME);
01877
01878 void SetFrameName(const char *name);
01879 void AddAction(Action *action);
01880 virtual Vectors * SubList(void);
01881
01882 private:
01883 virtual Action * Duplicate(void) const;
01884 virtual ErrorManager::error_code_t SaveData(Data& data, Data& nested_data);
01885
01886 Vectors f_actions;
01887 char * f_frame_name;
01888 };
01889
01890
01891
01892 class ActionWith : public Action, public MemoryManager
01893 {
01894 public:
01895 ActionWith(TagBase *tag);
01896
01897 void AddAction(Action *action);
01898 virtual Vectors * SubList(void);
01899
01900 private:
01901 virtual Action * Duplicate(void) const;
01902 virtual ErrorManager::error_code_t SaveData(Data& data, Data& nested_data);
01903
01904 Vectors f_actions;
01905 };
01906
01907
01908
01909
01910
01911
01912 class TagDoAction : public TagBase
01913 {
01914 public:
01915
01916
01917
01918
01919 TagDoAction(TagBase *parent);
01920
01921 virtual ErrorManager::error_code_t Save(Data& data);
01922 virtual swf_type_t TypeFlags(void) const;
01923
01924
01925 void SetAction(const Action& action);
01926 void SetSprite(sswf_id_t sprite);
01927 Vectors& Actions(void) { return f_actions; }
01928
01929 private:
01930 virtual ErrorManager::error_code_t PreSave(void);
01931
01932 sswf_id_t f_sprite;
01933 Vectors f_actions;
01934 };
01935
01936
01937
01938
01939
01940 class TagMetadata : public TagBase
01941 {
01942 public:
01943 TagMetadata(TagBase *parent);
01944
01945 virtual ErrorManager::error_code_t Save(Data& data);
01946 virtual swf_type_t TypeFlags(void) const;
01947
01948
01949
01950
01951
01952
01953
01954
01955
01956
01957
01958
01959
01960
01961
01962
01963
01964
01965
01966
01967
01968
01969 void SetFilename(const char *filename);
01970 void SetMetadata(const char *xml);
01971 void SetTitle(const char *title);
01972 void SetDescription(const char *description);
01973 void SetAuthor(const char *description);
01974 void SetPublisher(const char *publisher);
01975 void SetCopyright(const char *copyright);
01976 void SetURL(const char *url);
01977
01978 private:
01979 virtual ErrorManager::error_code_t PreSave(void);
01980
01981 char * f_xml;
01982 char * f_filename;
01983 char * f_title;
01984 char * f_description;
01985 char * f_author;
01986 char * f_publisher;
01987 char * f_copyright;
01988 char * f_url;
01989 };
01990
01991
01992
01993
01994
01995 class TagPlace : public TagBase
01996 {
01997 public:
01998 TagPlace(TagBase *parent);
01999
02000 virtual ErrorManager::error_code_t Save(Data& data);
02001 virtual swf_type_t TypeFlags(void) const;
02002
02003
02004 void SetObjectID(sswf_id_t id);
02005 void SetDepth(int depth);
02006 void SetClip(int depth);
02007 void SetMatrix(const Matrix& matrix);
02008 void SetColorTransform(const ColorTransform& color_transform);
02009 void SetName(const char *name);
02010 void SetMorphPosition(int position);
02011 void SetBlendMode(const BlendMode& blend_mode);
02012 void SetBitmapCaching(int bitmap_caching);
02013 void Replace(void);
02014 void Place(void);
02015 bool AddEvent(Event *event);
02016
02017 private:
02018 virtual ErrorManager::error_code_t PreSave(void);
02019
02020 bool f_id_defined;
02021 sswf_id_t f_id;
02022 int f_replace;
02023 int f_depth;
02024 int f_clip_depth;
02025 char * f_name;
02026 unsigned long f_events_all_flags;
02027 int f_position;
02028 BlendMode f_blend_mode;
02029 int f_bitmap_caching;
02030 bool f_has_matrix;
02031 Matrix f_matrix;
02032 ColorTransform f_color_transform;
02033 Vectors f_events;
02034 };
02035
02036
02037
02038 class TagRemove : public TagBase
02039 {
02040 public:
02041 TagRemove(TagBase *parent);
02042
02043 virtual ErrorManager::error_code_t Save(Data& data);
02044 virtual swf_type_t TypeFlags(void) const;
02045
02046
02047 void SetDepth(int depth) { f_depth = depth; }
02048 void SetObjectID(sswf_id_t id) { f_id = id; }
02049
02050 private:
02051 virtual ErrorManager::error_code_t PreSave(void);
02052
02053 int f_depth;
02054 sswf_id_t f_id;
02055 };
02056
02057
02058
02059 class TagSceneFrameData : public TagBase
02060 {
02061 public:
02062 TagSceneFrameData(TagBase *parent);
02063
02064 virtual ErrorManager::error_code_t Save(Data& data);
02065 virtual swf_type_t TypeFlags(void) const;
02066
02067
02068 bool SetFileData(const char *filename);
02069 void SetSceneFrameData(const char *data, size_t size);
02070
02071 private:
02072 virtual ErrorManager::error_code_t PreSave(void);
02073
02074 char * f_data;
02075 size_t f_size;
02076 };
02077
02078
02079
02080
02081 class TagScriptLimits : public TagBase
02082 {
02083 public:
02084 TagScriptLimits(TagBase *parent);
02085
02086 virtual ErrorManager::error_code_t Save(Data& data);
02087 virtual swf_type_t TypeFlags(void) const;
02088
02089
02090 void SetMaxRecursionDepth(int depth);
02091 void SetTimeoutSeconds(int timeout);
02092 int GetMaxRecursionDepth(void) const;
02093 int GetTimeoutSeconds(void) const;
02094
02095 private:
02096 virtual ErrorManager::error_code_t PreSave(void);
02097
02098 int f_depth;
02099 int f_timeout;
02100 };
02101
02102
02103
02104 class TagSetTabIndex : public TagBase
02105 {
02106 public:
02107 TagSetTabIndex(TagBase *parent);
02108
02109 virtual ErrorManager::error_code_t Save(Data& data);
02110 virtual swf_type_t TypeFlags(void) const;
02111
02112
02113 void SetDepth(int depth);
02114 void SetIndex(int timeout);
02115 int GetDepth(void) const;
02116 int GetIndex(void) const;
02117
02118 private:
02119 virtual ErrorManager::error_code_t PreSave(void);
02120
02121 int f_depth;
02122 int f_index;
02123 };
02124
02125
02126
02127 class TagSetBackgroundColor : public TagBase
02128 {
02129 public:
02130 TagSetBackgroundColor(TagBase *parent);
02131
02132 virtual ErrorManager::error_code_t Save(Data& data);
02133 virtual swf_type_t TypeFlags(void) const;
02134
02135
02136 void SetColor(Color& color);
02137 Color& GetColor(void);
02138
02139 private:
02140 Color f_color;
02141 };
02142
02143
02144 class TagShowFrame : public TagBase
02145 {
02146 public:
02147 TagShowFrame(TagBase *parent);
02148
02149 virtual ErrorManager::error_code_t Save(Data& data);
02150 virtual swf_type_t TypeFlags(void) const;
02151 };
02152
02153
02154 class TagEnd : public TagBase
02155 {
02156 public:
02157 TagEnd(TagBase *parent);
02158
02159 virtual ErrorManager::error_code_t Save(Data& data);
02160 virtual swf_type_t TypeFlags(void) const;
02161 };
02162
02163
02164 class TagFrameLabel : public TagBase
02165 {
02166 public:
02167 TagFrameLabel(TagBase *parent);
02168
02169 virtual ErrorManager::error_code_t Save(Data& data);
02170 virtual swf_type_t TypeFlags(void) const;
02171
02172
02173 void SetFrameLabel(const char *label);
02174
02175 private:
02176 virtual ErrorManager::error_code_t PreSave(void);
02177
02178 char * f_label;
02179 };
02180
02181
02182
02183 class TagExport : public TagBase
02184 {
02185 public:
02186 TagExport(TagBase *parent);
02187
02188 virtual ErrorManager::error_code_t Save(Data& data);
02189 virtual swf_type_t TypeFlags(void) const;
02190
02191
02192 void SetObject(sswf_id_t id, const char *name, const char *used_glyphs);
02193
02194 private:
02195
02196 struct export_t : public ItemBase
02197 {
02198 sswf_id_t f_id;
02199 const char * f_name;
02200 const char * f_used_glyphs;
02201 };
02202
02203 virtual ErrorManager::error_code_t PreSave(void);
02204
02205 Vectors f_objects;
02206 };
02207
02208
02209
02210 class TagImport : public TagBase
02211 {
02212 public:
02213
02214
02215
02216
02217 TagImport(TagBase *parent);
02218
02219 virtual ErrorManager::error_code_t Save(Data& data);
02220 virtual swf_type_t TypeFlags(void) const;
02221 const char * HasID(sswf_id_t id) const;
02222 sswf_id_t HasName(const char *name) const;
02223
02224
02225 void SetURL(const char *url);
02226 void SetFilename(const char *filename);
02227 void AddName(const char *name, const char *type);
02228
02229 private:
02230
02231 struct import_t : public ItemBase
02232 {
02233 sswf_id_t f_id;
02234 const char * f_name;
02235 const char * f_type;
02236 };
02237
02238 virtual ErrorManager::error_code_t PreSave(void);
02239
02240 char * f_url;
02241 char * f_filename;
02242 Vectors f_objects;
02243 };
02244
02245
02246
02247 class TagProtect : public TagBase
02248 {
02249 public:
02250
02251
02252
02253
02254
02255
02256 TagProtect(TagBase *parent);
02257
02258 virtual ErrorManager::error_code_t Save(Data& data);
02259 virtual swf_type_t TypeFlags(void) const;
02260
02261
02262 void SetPassword(const char *password);
02263 void SetEncodedPassword(const char *password);
02264
02265 private:
02266 virtual ErrorManager::error_code_t PreSave(void);
02267
02268 char * f_password;
02269 };
02270
02271
02272
02273 class TagProductInfo : public TagBase
02274 {
02275 public:
02276 TagProductInfo(TagBase *parent);
02277
02278 virtual ErrorManager::error_code_t Save(Data& data);
02279 virtual swf_type_t TypeFlags(void) const;
02280
02281
02282 void SetProduct(long product_id);
02283 void SetEdition(long edition);
02284 void SetVersion(int major, int minor);
02285 void SetBuild(int64_t build_number);
02286 void SetCompileDate(int64_t date);
02287
02288 private:
02289 virtual ErrorManager::error_code_t PreSave(void);
02290
02291 long f_product_id;
02292 long f_edition;
02293 int f_major;
02294 int f_minor;
02295 int64_t f_build_number;
02296 int64_t f_date;
02297 };
02298
02299
02300
02301 class TagInfo : public TagBase
02302 {
02303 public:
02304 TagInfo(TagBase *parent);
02305
02306 virtual ErrorManager::error_code_t Save(Data& data);
02307 virtual swf_type_t TypeFlags(void) const;
02308
02309
02310 void SetInfo(const char *info);
02311 void SetVersion(long version);
02312
02313 private:
02314 virtual ErrorManager::error_code_t PreSave(void);
02315
02316 char * f_info;
02317 long f_version;
02318 };
02319
02320
02321 class TagStartSound : public TagBase
02322 {
02323 public:
02324 TagStartSound(TagBase *parent);
02325
02326 virtual ErrorManager::error_code_t Save(Data& data);
02327 virtual swf_type_t TypeFlags(void) const;
02328
02329
02330 void SetInfo(SoundInfo *sound_info);
02331
02332 private:
02333 virtual ErrorManager::error_code_t PreSave(void);
02334
02335 SoundInfo * f_sound_info;
02336 };
02337
02338
02339
02340
02341
02342
02343
02344
02345 class TagScalingGrid
02346 {
02347 public:
02348 virtual ~TagScalingGrid();
02349
02350 ErrorManager::error_code_t GridSave(Data& data, sswf_id_t id);
02351 ErrorManager::error_code_t GridPreSave(void);
02352
02353 const SRectangle& Grid(void) const;
02354
02355
02356 void SetGrid(const SRectangle& rect);
02357
02358 private:
02359 SRectangle f_grid;
02360 };
02361
02362
02363
02364
02365
02366
02367
02368
02369
02370
02371
02372
02373
02374
02375
02376
02377 class TagBaseID : public TagBase
02378 {
02379 public:
02380 virtual ~TagBaseID();
02381
02382 virtual sswf_id_t Identification(void) const;
02383 void NoIdentification(void);
02384 bool HasIdentification(void) const;
02385
02386 int SaveID(Data& data) const;
02387
02388 public:
02389 TagBaseID(const char *name, TagBase *parent);
02390
02391 private:
02392 sswf_id_t f_id;
02393 bool f_identified;
02394 };
02395
02396
02397
02398
02399
02400 class TagBinaryData : public TagBaseID
02401 {
02402 public:
02403 TagBinaryData(TagBase *parent);
02404 virtual ~TagBinaryData();
02405
02406 virtual ErrorManager::error_code_t Save(Data& data);
02407 virtual swf_type_t TypeFlags(void) const;
02408
02409
02410 void GetData(const char *& data, size_t& size) const;
02411 void SetData(const char *data, size_t size);
02412
02413 private:
02414 virtual ErrorManager::error_code_t PreSave(void);
02415
02416 char * f_data;
02417 size_t f_size;
02418 };
02419
02420
02421
02422
02423 class TagButton : public TagBaseID, public TagScalingGrid
02424 {
02425 public:
02426 TagButton(TagBase *parent);
02427
02428 virtual ErrorManager::error_code_t Save(Data& data);
02429 virtual swf_type_t TypeFlags(void) const;
02430
02431
02432 bool SetState(const State& state);
02433 void SetAction(const Action& action);
02434 void SetMenu(bool menu = true);
02435 Vectors& Actions(void);
02436 bool AddEvent(Event *event);
02437
02438 private:
02439 virtual ErrorManager::error_code_t PreSave(void);
02440
02441 bool f_save_button2;
02442 bool f_menu;
02443 Vectors f_states;
02444 Vectors f_actions;
02445 Vectors f_events;
02446 };
02447
02448
02449
02450 class TagCSMTextSettings
02451 {
02452 public:
02453 enum csm_text_renderer_t {
02454 CSM_TEXT_RENDERER_NORMAL = 0,
02455 CSM_TEXT_RENDERER_FLASH = 1
02456 };
02457 enum csm_text_gridfit_t {
02458 CSM_TEXT_GRIDFIT_NO_GRID = 0,
02459 CSM_TEXT_GRIDFIT_PIXEL = 1,
02460 CSM_TEXT_GRIDFIT_SUBPIXEL = 2
02461 };
02462
02463 TagCSMTextSettings(void);
02464 virtual ~TagCSMTextSettings(void);
02465
02466 bool IsCSMTextSettingsDefined(void) const;
02467
02468 void SetRenderer(csm_text_renderer_t csm_text_renderer);
02469 void SetGridFit(csm_text_gridfit_t csm_text_gridfit);
02470 void SetThickness(float thickness);
02471 void SetSharpness(float sharpness);
02472
02473 protected:
02474
02475 ErrorManager::error_code_t PreSaveCSMTextSettings(void);
02476 ErrorManager::error_code_t SaveCSMTextSettings(Data& data);
02477
02478 private:
02479 csm_text_renderer_t f_csm_text_renderer;
02480 csm_text_gridfit_t f_csm_text_gridfit;
02481 float f_thickness;
02482 float f_sharpness;
02483 };
02484
02485
02486 class TagShape;
02487 class TagFont : public TagBaseID
02488 {
02489 public:
02490 enum font_type_t {
02491 FONT_TYPE_BEST = 0,
02492 FONT_TYPE_ASCII,
02493 FONT_TYPE_UNICODE,
02494 FONT_TYPE_SHIFTJIS,
02495 };
02496 enum font_language_t {
02497 FONT_LANGUAGE_UNKNOWN = -1,
02498 FONT_LANGUAGE_LOCALE = 0,
02499 FONT_LANGUAGE_LATIN = 1,
02500 FONT_LANGUAGE_JAPANESE = 2,
02501 FONT_LANGUAGE_KOREAN = 3,
02502 FONT_LANGUAGE_SIMPLIFIED_CHINESE = 4,
02503 FONT_LANGUAGE_TRADITIONAL_CHINESE = 5,
02504
02505 FONT_LANGUAGE_max = 6
02506 };
02507 enum font_thickness_t {
02508 FONT_THICKNESS_UNKNOWN = -1,
02509 FONT_THICKNESS_THIN = 0,
02510 FONT_THICKNESS_MEDIUM = 1,
02511 FONT_THICKNESS_THICK = 2,
02512
02513 FONT_THICKNESS_max = 3
02514 };
02515 enum font_em_size_t {
02516 FONT_EM_SMALL = 0,
02517 FONT_EM_LARGE = 1
02518 };
02519
02520 #define SSWF_FONT_SPACE_INDEX static_cast<unsigned long>(-1)
02521
02522
02523 struct font_info_t {
02524 sswf_ucs4_t f_glyph;
02525 unsigned short f_saved_index;
02526 unsigned long f_index;
02527 unsigned long f_position;
02528 long f_advance;
02529 bool f_is_empty;
02530 };
02531
02532 TagFont(TagBase *parent);
02533
02534 virtual ErrorManager::error_code_t Save(Data& data);
02535 virtual swf_type_t TypeFlags(void) const;
02536 ErrorManager::error_code_t GlyphInfo(font_info_t& info) const;
02537 bool HasGlyph(void) const;
02538 bool FindGlyph(font_info_t& info, bool mark_empty_in_use = false) const;
02539 const char * FontName(void) const;
02540 long DefaultAscent(void) const;
02541 long DefaultDescent(void) const;
02542 long DefaultLeadingHeight(void) const;
02543 static font_language_t StringToLanguage(const char *language);
02544 static const char * LanguageToString(font_language_t language);
02545
02546
02547
02548
02549
02550
02551
02552
02553
02554 ErrorManager::error_code_t AddGlyph(sswf_ucs4_t name, const TagBase *ref, long advance = LONG_MIN);
02555 void SetName(const char *font_name);
02556 void SetDisplayName(const char *display_name);
02557 void SetCopyright(const char *copyright);
02558 void SetLayout(long ascent, long descent, long leading_height);
02559 void SetDefaultAdvance(long advance);
02560 void SetSpaceAdvance(long advance);
02561 void SetType(font_type_t type);
02562 void SetLanguage(font_language_t language);
02563 void SetBold(bool bold);
02564 void SetItalic(bool italic);
02565 void SetSmallText(bool small_text = true);
02566 void SetThickness(font_thickness_t thickness);
02567 void SetEMSize(font_em_size_t font_em_size);
02568 void SetWide(bool wide);
02569 ErrorManager::error_code_t SetUsedGlyphs(const char *used_glyphs, bool mark_empty_in_use = false);
02570 ErrorManager::error_code_t SetUsedGlyphs(const sswf_ucs4_t *used_glyphs, bool mark_empty_in_use = false);
02571 void SetUsedByEditText(bool used = true);
02572 void AddKern(sswf_ucs4_t code0, sswf_ucs4_t code1, long advance);
02573
02574 private:
02575
02576 struct font_glyph_t : public ItemBase
02577 {
02578 sswf_ucs4_t f_name;
02579 unsigned short f_index;
02580 const TagShape *f_shape;
02581 long f_advance;
02582 bool f_in_use;
02583 };
02584
02585 struct font_kern_t : public ItemBase
02586 {
02587 sswf_ucs4_t f_code[2];
02588 long f_advance;
02589 };
02590
02591 virtual ErrorManager::error_code_t PreSave(void);
02592 virtual ErrorManager::error_code_t PreSave2ndPass(void);
02593
02594 static const char * g_font_language_name[FONT_LANGUAGE_max];
02595 char * f_font_name;
02596 char * f_display_name;
02597 char * f_copyright;
02598 font_language_t f_language;
02599 font_type_t f_type;
02600 bool f_bold;
02601 bool f_italic;
02602 bool f_small_text;
02603 bool f_wide;
02604 bool f_has_wide_char;
02605 bool f_has_wide_offsets;
02606 bool f_has_layout;
02607 bool f_used_by_edit_text;
02608 bool f_define_font2;
02609 font_thickness_t f_thickness;
02610 font_em_size_t f_font_em_size;
02611 long f_ascent;
02612 long f_descent;
02613 long f_leading_height;
02614 long f_default_advance;
02615 long f_space_advance;
02616 long f_offsets_max;
02617 unsigned long * f_offsets;
02618 unsigned long f_count;
02619 Data f_save_glyphs;
02620 Vectors f_glyphs;
02621 Vectors f_kerns;
02622 };
02623
02624
02625
02626
02627
02628 class TagEditText : public TagBaseID, public TagCSMTextSettings
02629 {
02630 public:
02631 enum edit_text_alignment_t {
02632 EDIT_TEXT_ALIGNMENT_LEFT = 0,
02633 EDIT_TEXT_ALIGNMENT_RIGHT = 1,
02634 EDIT_TEXT_ALIGNMENT_CENTER = 2,
02635 EDIT_TEXT_ALIGNMENT_JUSTIFY = 3
02636 };
02637
02638 TagEditText(TagBase *parent);
02639
02640 virtual ErrorManager::error_code_t Save(Data& data);
02641 virtual swf_type_t TypeFlags(void) const;
02642
02643
02644 void SetText(const char *text);
02645 void SetVariableName(const char *name);
02646 void SetFont(const TagFont *font, long height);
02647 void SetMargins(long left, long right);
02648 void SetBounds(const SRectangle& bounds);
02649 void SetAlign(edit_text_alignment_t align);
02650 void SetIndent(long indent);
02651 void SetLeading(long leading);
02652 void SetColor(Color& color);
02653 void SetMaxLength(long length);
02654 void SetWordWrap(bool status = true);
02655 void SetMultiline(bool status = true);
02656 void SetPassword(bool status = true);
02657 void SetReadOnly(bool status = true);
02658 void SetNoSelect(bool status = true);
02659 void SetBorder(bool status = true);
02660 void SetOutline(bool status = true);
02661 void SetHTML(bool status = true);
02662 void SetAutoSize(bool status = true);
02663 void SetUsedGlyphs(const char *lists);
02664 void AddUsedString(const char *string);
02665
02666 private:
02667 virtual ErrorManager::error_code_t PreSave(void);
02668
02669 SRectangle f_bounds;
02670 edit_text_alignment_t f_align;
02671 long f_left_margin;
02672 long f_right_margin;
02673 long f_indent;
02674 long f_leading;
02675 const TagFont * f_font;
02676 unsigned short f_font_height;
02677 long f_max_length;
02678 char * f_var_name;
02679 char * f_text;
02680 sswf_ucs4_t * f_used_glyphs;
02681 sswf_ucs4_t * f_used_strings;
02682 Color f_color;
02683 bool f_has_color;
02684 bool f_word_wrap;
02685 bool f_multiline;
02686 bool f_password;
02687 bool f_readonly;
02688 bool f_no_select;
02689 bool f_border;
02690 bool f_outline;
02691 bool f_html;
02692 bool f_autosize;
02693 };
02694
02695
02696 class TagImage : public TagBaseID
02697 {
02698 public:
02699 enum image_format_t {
02700 IMAGE_FORMAT_UNKNOWN = 0,
02701 IMAGE_FORMAT_LOSSLESS_BEST,
02702 IMAGE_FORMAT_LOSSLESS_8,
02703 IMAGE_FORMAT_LOSSLESS_16,
02704 IMAGE_FORMAT_LOSSLESS_32,
02705 IMAGE_FORMAT_JPEG,
02706 IMAGE_FORMAT_max
02707 };
02708
02709 struct image_t {
02710 bool f_alpha;
02711 long f_width;
02712 long f_height;
02713 unsigned char * f_data;
02714 };
02715
02716 TagImage(TagBase *parent);
02717
02718
02719 virtual ErrorManager::error_code_t Save(Data& data);
02720 virtual swf_type_t TypeFlags(void) const;
02721 void GetImageData(image_t& image_data) { image_data = f_image; }
02722
02723
02724 void SetFormat(image_format_t format) { f_format = format; }
02725 void SetQuality(int quality) { f_quality = quality; }
02726 ErrorManager::error_code_t SetFilename(const char *image, const char *mask);
02727 void SetImage(long width, long height, unsigned char *data, bool alpha = false, long count = 0, unsigned char *colormap = 0);
02728
02729 ErrorManager::error_code_t LoadTGA(const char *filename, image_t& im);
02730 ErrorManager::error_code_t LoadJPEG(const char *filename, image_t& im);
02731 ErrorManager::error_code_t SaveJPEG(Data& encoding, Data& image);
02732 ErrorManager::error_code_t SetAlpha(image_t& im, const image_t& mask);
02733
02734 private:
02735 virtual ErrorManager::error_code_t PreSave(void);
02736
02737 image_format_t f_format;
02738 image_t f_image;
02739 int f_quality;
02740 long f_count;
02741 unsigned char * f_colormap;
02742 };
02743
02744
02745
02746 class TagShape : public TagBaseID
02747 {
02748 public:
02749 enum morph_t {
02750 MORPH_MODE_SHAPE0 = 0,
02751 MORPH_MODE_SHAPE1 = 1,
02752 MORPH_MODE_BOTH_SHAPES = 2
02753 };
02754 enum fill_t {
02755 SHAPE_FILL_EVEN = 0,
02756 SHAPE_FILL_ODD = 1
02757 };
02758
02759 TagShape(TagBase *parent);
02760
02761 virtual ErrorManager::error_code_t Save(Data& data);
02762 virtual swf_type_t TypeFlags(void) const;
02763 ErrorManager::error_code_t SaveWithoutStyles(Data& data);
02764 void SaveAlignZone(Data& data) const;
02765 bool HasAlignZone(void) const;
02766 bool HasBounds(void) const { return !f_bounds[0].IsEmpty() || !f_bounds[1].IsEmpty(); }
02767 const SRectangle& Bounds(int index) const { assert(index == 0 || index == 1, "invalid index to query bounds"); return f_bounds[index]; }
02768 bool IsGlyph(void) const;
02769 bool IsEmpty(void) const;
02770
02771
02772
02773 ErrorManager::error_code_t AddMove(morph_t morph_mode, long x, long y);
02774 ErrorManager::error_code_t AddEdge(morph_t morph_mode, long x, long y) { Edges::edge_t edge(x, y); return AddEdge(morph_mode, edge); }
02775 ErrorManager::error_code_t AddEdge(morph_t morph_mode, long x, long y, long ctrl_x, long ctrl_y) { Edges::edge_t edge(x, y, ctrl_x, ctrl_y); return AddEdge(morph_mode, edge); };
02776 void NewStyles(void);
02777 ErrorManager::error_code_t AddStyle(const Style& style, fill_t fill = SHAPE_FILL_EVEN);
02778 void SetAlignZone(const SRectangle& zone);
02779 ErrorManager::error_code_t SetBounds(int index, const SRectangle& rect, bool show = false);
02780 ErrorManager::error_code_t SetStrokesBounds(int index, const SRectangle& rect);
02781 void ShowBounds(bool show = true) { f_show_bounds = show; }
02782 void ShowOrigin(bool show = true) { f_show_origin = show; }
02783 void SetNonScalingStrokes(bool has_non_scaling_strokes) { f_has_non_scaling_strokes = has_non_scaling_strokes; }
02784 void SetScalingStrokes(bool has_scaling_strokes) { f_has_scaling_strokes = has_scaling_strokes; }
02785 void Glyph(void);
02786
02787 bool HasShowBounds(void) const { return f_show_bounds; }
02788
02789 public:
02790 ErrorManager::error_code_t AddEdge(morph_t morph_mode, const Edges::edge_t& edge);
02791
02792 private:
02793 enum what_t {
02794 SHAPE_EDGES,
02795 SHAPE_SETUP
02796 };
02797
02798
02799 struct shape_what_t : public ItemBase
02800 {
02801 what_t f_what;
02802 shape_what_t(what_t what) { f_what = what; }
02803 };
02804
02805 struct shape_edges_t : public shape_what_t
02806 {
02807 Edges f_edges;
02808 shape_edges_t(what_t what) : shape_what_t(what) {}
02809 };
02810
02811 struct shape_setup_t : public shape_what_t
02812 {
02813 int f_fill_ref[2];
02814 int f_line_ref;
02815 long f_x;
02816 long f_y;
02817
02818 shape_setup_t(what_t what, bool origin = false) : shape_what_t(what)
02819 {
02820 f_fill_ref[0] = f_fill_ref[1] = f_line_ref = -1;
02821 if(origin) {
02822 f_x = f_y = 0;
02823 }
02824 else {
02825 f_x = f_y = LONG_MIN;
02826 }
02827 }
02828 };
02829
02830
02831 struct shape_record_t : public ItemBase {
02832 Vectors * f_fill_styles;
02833 Vectors * f_line_styles;
02834 Vectors * f_record;
02835 };
02836
02837
02838 struct save_info_t {
02839 shape_record_t f_sr;
02840 bool f_save_alpha;
02841 bool f_ext_size;
02842 bool f_first;
02843 bool f_save_styles;
02844 bool f_shape4;
02845 Data f_data;
02846 int f_fill_bits_count;
02847 int f_line_bits_count;
02848 };
02849
02850 void RecordEdges(void);
02851 void RecordSetup(void);
02852 void NewEdges(void);
02853 void NewSetup(void);
02854 void SetMorph(void);
02855
02856
02857 virtual ErrorManager::error_code_t PreSave(void);
02858 ErrorManager::error_code_t SaveShape(save_info_t& info, shape_setup_t& last_setup);
02859
02860 ErrorManager::error_code_t SaveSetup(save_info_t& info, const shape_setup_t& setup, shape_setup_t& last);
02861 ErrorManager::error_code_t SaveStyles(save_info_t& info);
02862 ErrorManager::error_code_t SaveStylesCount(save_info_t& info, long count);
02863
02864 unsigned char f_version;
02865 bool f_morph;
02866 bool f_is_glyph;
02867 bool f_show_bounds;
02868 bool f_show_origin;
02869 bool f_has_non_scaling_strokes;
02870 bool f_has_scaling_strokes;
02871 SRectangle f_align_zone;
02872 SRectangle f_bounds[2];
02873 SRectangle f_strokes_bounds[2];
02874
02875 Vectors f_shapes;
02876
02877 shape_edges_t * f_edges;
02878 shape_edges_t * f_morph_edges;
02879 shape_setup_t * f_setup;
02880 Vectors f_fill_styles;
02881 Vectors f_line_styles;
02882 Vectors f_record;
02883 Vectors f_morph_record;
02884 };
02885
02886
02887
02888 class TagSound : public TagBaseID
02889 {
02890 public:
02891 enum sound_format_t {
02892 SOUND_FORMAT_UNKNOWN = -1,
02893 SOUND_FORMAT_RAW = 0,
02894 SOUND_FORMAT_ADPCM = 1,
02895 SOUND_FORMAT_MP3 = 2,
02896 SOUND_FORMAT_UNCOMPRESSED = 3,
02897 SOUND_FORMAT_NELLYMOSER = 6
02898 };
02899 enum sound_endian_t {
02900 SOUND_ENDIAN_LITTLE = 0,
02901 SOUND_ENDIAN_BIG,
02902 SOUND_ENDIAN_SAME,
02903 SOUND_ENDIAN_DONTUSE,
02904 SOUND_ENDIAN_UNKNOWN
02905 };
02906
02907 TagSound(TagBase *parent);
02908
02909 virtual ErrorManager::error_code_t Save(Data& data);
02910 virtual swf_type_t TypeFlags(void) const;
02911
02912 size_t GetSamplesCount(void) const;
02913
02914
02915 ErrorManager::error_code_t SetFilename(const char *filename);
02916 void SetFormat(sound_format_t format);
02917 int SetData(const void *data, size_t size, sound_endian_t endian, int width, unsigned int rate, bool stereo);
02918 void SetMono(void);
02919 void Set8Bits(void);
02920
02921 public:
02922 static const int g_sound_rates[4];
02923
02924 private:
02925
02926 struct sound_wave_t {
02927 short format;
02928 short channels;
02929 int rate;
02930 int average_rate;
02931 short align;
02932
02933 short width;
02934 };
02935
02936 virtual ErrorManager::error_code_t PreSave(void);
02937 short ReadSample(const unsigned char *data, unsigned short adjust, int in_fmt);
02938 void Resample(unsigned char *snd, unsigned int out_bytes, const unsigned char *src, size_t size, unsigned int in_bytes, size_t max, double fix, unsigned short adjust, int in_fmt);
02939 int LoadWaveFile(FILE *f);
02940 int LoadMP3File(FILE *f);
02941 int CheckMP3Header(FILE *f, unsigned char *header, int& frame_size);
02942 int ReadMP3Header(FILE *f, unsigned char *header);
02943
02944 static const int g_bitrates[2][16];
02945 static const int g_frequencies[4][4];
02946
02947 sound_format_t f_format;
02948 bool f_stereo;
02949 int f_rate;
02950 int f_width;
02951 size_t f_samples;
02952 int f_data_size;
02953 int f_data_maxsize;
02954 unsigned char * f_data;
02955 int f_latency_seek;
02956 };
02957
02958
02959
02960
02961
02962
02963 class TagSprite : public TagBaseID, public TagScalingGrid
02964 {
02965 public:
02966 TagSprite(TagBase *parent);
02967
02968 virtual ErrorManager::error_code_t Save(Data& data);
02969 virtual swf_type_t TypeFlags(void) const;
02970
02971
02972
02973
02974
02975
02976
02977
02978
02979 protected:
02980 virtual ErrorManager::error_code_t OnNewChild(const char *child_name) const;
02981
02982 private:
02983 virtual ErrorManager::error_code_t PreSave(void);
02984 };
02985
02986
02987
02988
02989 class TagText : public TagBaseID, public TagCSMTextSettings
02990 {
02991 public:
02992 TagText(TagBase *parent);
02993
02994 virtual ErrorManager::error_code_t Save(Data& data);
02995 virtual swf_type_t TypeFlags(void) const;
02996
02997
02998 void SetMatrix(const Matrix& matrix);
02999 void SetBounds(const SRectangle& bounds);
03000 ErrorManager::error_code_t AddText(const char *string, long advance = LONG_MIN);
03001 void AddFont(const TagFont *font, long height);
03002 void AddOffsets(long x, long y);
03003 void AddColor(Color& color);
03004
03005 private:
03006 enum text_type_t {
03007 TEXT_ENTRY_TEXT = 0,
03008 TEXT_ENTRY_SETUP
03009 };
03010
03011
03012 struct text_define_t : public ItemBase {
03013 const text_type_t f_type;
03014
03015 text_define_t(text_type_t type) : f_type(type) {}
03016 };
03017
03018
03019 struct text_setup_t : public text_define_t {
03020 bool f_has_font;
03021 const TagFont * f_font;
03022 unsigned short f_font_height;
03023 bool f_has_xadjust;
03024 long f_xadjust;
03025 bool f_has_xoffset;
03026 long f_x;
03027 bool f_has_yoffset;
03028 long f_y;
03029 bool f_has_color;
03030 Color f_color;
03031
03032 text_setup_t(void);
03033 text_setup_t(const text_setup_t& setup);
03034 void Unused(void);
03035 bool IsUsed(void) const;
03036 };
03037
03038
03039 struct text_entry_t : public text_define_t {
03040 sswf_ucs4_t * f_text;
03041 long f_advance;
03042 unsigned long f_length;
03043 unsigned long f_exact_length;
03044 TagFont::font_info_t * f_entries;
03045
03046 text_entry_t(sswf_ucs4_t *string, long advance);
03047 };
03048
03049 virtual ErrorManager::error_code_t PreSave(void);
03050 int DefineText(int start, text_setup_t *s, const TagFont *font, int font_height);
03051 ErrorManager::error_code_t RecordSetup(void);
03052 void NewSetup(void);
03053
03054 Matrix f_matrix;
03055 SRectangle f_bounds;
03056 text_setup_t f_setup;
03057 bool f_new_text;
03058 int f_version;
03059 Vectors f_records;
03060 };
03061
03062
03063
03064
03065
03066
03067
03068
03069
03070 };
03071 #endif