home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / flash078.zip / flashsource-r0_7_8.zip / FFont.h < prev    next >
C/C++ Source or Header  |  2001-08-02  |  8KB  |  262 lines

  1. #ifndef FFONT_H_FILE
  2. #define FFONT_H_FILE
  3.  
  4. #include "FBase.h"
  5. #include "FShape.h"
  6.  
  7. #include <vector>
  8.  
  9. typedef FlashIDFactory FlashFontIDFactory;
  10. typedef FlashIDEnabled FlashFontIDEnabled;
  11.  
  12. #define FTDFI_UNICODE        (1 << 5)
  13. #define FTDFI_SHIFTJIS        (1 << 4)
  14. #define FTDFI_ANSI            (1 << 3)
  15. #define FTDFI_ITALIC        (1 << 2)
  16. #define FTDFI_BOLD            (1 << 1)
  17. #define FTDFI_WIDECODES        (1)
  18.  
  19. class FlashTagDefineFontInfo : public FlashTag, public FlashFontIDEnabled
  20. {
  21. DEFINE_RW_INTERFACE
  22. public:
  23.     FlashTagDefineFontInfo(char *_str, unsigned char _flags) : str(_str), flags(_flags) {}
  24.  
  25.     void AddCode(UWORD code) { codes.push_back(code); }
  26.  
  27.     friend std::istream &operator >> (std::istream &in,  FlashTagDefineFontInfo &data);
  28.     friend std::ostream &operator << (std::ostream &out, FlashTagDefineFontInfo &data);
  29.  
  30. private:
  31.     std::vector<UWORD> codes;
  32.     gc_vector<char *> strings;
  33.     char *str;
  34.     unsigned char flags;
  35. };
  36.  
  37.  
  38. class FlashTagDefineFont : public FlashTag, public FlashFontIDEnabled
  39. {
  40. DEFINE_RW_INTERFACE
  41. public:
  42.     FlashTagDefineFont() {}
  43.     
  44.     void AddShape(FlashShape& shape);
  45.     friend std::istream &operator >> (std::istream &in,  FlashTagDefineFont &data);
  46.     friend std::ostream &operator << (std::ostream &out, FlashTagDefineFont &data);
  47. private:
  48.     std::vector<FlashShape> shapes;
  49. };
  50.  
  51. class FlashTextRecord : public FlashVersionEnabled
  52. {
  53. public:    
  54.     FlashTextRecord() {};
  55.     virtual void Write(std::ostream &out, unsigned char bitsGlyph=0, unsigned char bitsAdvance=0) = 0;
  56.     virtual bool isGlyph(void) = 0;
  57.     virtual int returnGlyphBits(void) { return -1; }
  58.     virtual int returnAdvBits(void) { return -1; }
  59. };
  60.  
  61. class FlashTextRecordStyle : public FlashTextRecord
  62. {
  63. public:
  64.     FlashTextRecordStyle(bool hasFont, bool hasFlashRGB, bool hasOffsetx, bool hasOffsety, 
  65.         UWORD FontID, UWORD FontHeight, FlashRGB color, SWORD offsetx, SWORD offsety) :        
  66.             mhasFont(hasFont), mhasFlashRGB(hasFlashRGB), mhasOffsetx(hasOffsetx), mhasOffsety(hasOffsety), 
  67.             mFontID(FontID), mFontHeight(FontHeight), mcolor(color), moffsetx(offsetx), moffsety(offsety) {}
  68.     
  69.     virtual void Write(std::ostream &out, unsigned char bitsGlyph=0, unsigned char bitsAdvance=0);
  70.     virtual bool isGlyph(void);
  71.     
  72.  
  73. private:
  74.     bool mhasFont;
  75.     bool mhasFlashRGB;
  76.     bool mhasOffsetx;
  77.     bool mhasOffsety;
  78.     UWORD mFontID;
  79.     UWORD mFontHeight;
  80.     FlashRGB mcolor;
  81.     SWORD moffsetx;
  82.     SWORD moffsety;
  83. };
  84. typedef flash_pair<UWORD, SWORD> FlashGlyphEntry;
  85.  
  86. class FlashTextRecordGlyph : public FlashTextRecord
  87. {
  88.     
  89. public:
  90.         FlashTextRecordGlyph() {}
  91.         virtual ~FlashTextRecordGlyph() {}
  92.     virtual void Write(std::ostream &out, unsigned char bitsGlyph=0, unsigned char bitsAdvance=0);
  93.     virtual bool isGlyph(void) { return true; }
  94.     virtual int returnGlyphBits(void);
  95.     virtual int returnAdvBits(void);
  96.  
  97.     void AddGlyph(FlashGlyphEntry &e) { v.push_back(e); }
  98. private:
  99.     std::vector<FlashGlyphEntry> v;
  100. };
  101.  
  102. class FlashTagDefineText : public FlashTag, public FlashIDEnabled
  103. {
  104. DEFINE_RW_INTERFACE
  105. public:
  106.     FlashTagDefineText(FlashRect &r, FlashMatrix &m) : rect(r), matrix(m) {}
  107.  
  108.     void AddTextRecord(FlashTextRecord *r);
  109.  
  110.     friend std::istream &operator >> (std::istream &in,  FlashTagDefineText &data);
  111.     friend std::ostream &operator << (std::ostream &out, FlashTagDefineText &data);
  112.  
  113. private:
  114.     FlashRect rect;
  115.     FlashMatrix matrix;
  116.     std::vector<FlashTextRecord *> records;
  117.  
  118. };
  119.  
  120. class FlashTagDefineText2 : public FlashTag, public FlashIDEnabled
  121. {
  122. DEFINE_RW_INTERFACE
  123. public:
  124.     FlashTagDefineText2(FlashRect &r, FlashMatrix &m) : rect(r), matrix(m) {}
  125.  
  126.     void AddTextRecord(FlashTextRecord *r);
  127.  
  128.     friend std::istream &operator >> (std::istream &in,  FlashTagDefineText2 &data);
  129.     friend std::ostream &operator << (std::ostream &out, FlashTagDefineText2 &data);
  130.  
  131. private:
  132.     FlashRect rect;
  133.     FlashMatrix matrix;
  134.     std::vector<FlashTextRecord *> records;
  135.  
  136. };
  137.  
  138.  
  139. class FlashKerningRecord : public FlashVersionEnabled
  140. {
  141. public:
  142.     FlashKerningRecord(UWORD _code1, UWORD _code2, SWORD _adjustment) : code1(_code1), code2(_code2), adjustment(_adjustment) {}
  143. private:
  144.     friend std::istream &operator >> (std::istream &in,  FlashKerningRecord &data);
  145.     friend std::ostream &operator << (std::ostream &out, FlashKerningRecord &data);
  146.  
  147.     UWORD code1;
  148.     UWORD code2;
  149.     SWORD adjustment;
  150.  
  151. };
  152.  
  153. #define FTDF2_HASLAYOUT            (1 << 7)
  154. #define FTDF2_SHIFTJIS            (1 << 6)
  155. #define FTDF2_UNICODE            (1 << 5)
  156. #define FTDF2_ANSI                (1 << 4)
  157. #define FTDF2_WIDEOFFSETS        (1 << 3)
  158. #define FTDF2_WIDECODES            (1 << 2)
  159. #define FTDF2_ITALIC            (1 << 1)
  160. #define FTDF2_BOLD                (1)
  161.  
  162. class FlashTagDefineFont2 : public FlashTag, public FlashFontIDEnabled
  163. {
  164.     DEFINE_RW_INTERFACE
  165. public:
  166.     FlashTagDefineFont2(char fontflags,    const char *_fontname) : flags(fontflags), fontname(_fontname) {}
  167.     
  168.     class FlashFontLayout
  169.     {        
  170.     public:
  171.         FlashFontLayout() {}
  172.         FlashFontLayout(SWORD ascent, SWORD descent, SWORD leading,
  173.             std::vector<SWORD> &advance) : fontAscent(ascent), fontDescent(descent),
  174.             fontLeading(leading), fontAdvanceTable(advance) {}
  175.         FlashFontLayout(SWORD ascent, SWORD descent, SWORD leading,
  176.             std::vector<SWORD> &advance, std::vector<FlashRect> &bounds,
  177.             std::vector<FlashKerningRecord> &kerning) 
  178.             : fontAscent(ascent), fontDescent(descent),
  179.             fontLeading(leading), fontAdvanceTable(advance),
  180.             fontBoundsTable(bounds), fontKerningTable(kerning){}
  181.         
  182.         void Write(std::ostream &out);
  183.     private:
  184.         SWORD fontAscent;
  185.         SWORD fontDescent;
  186.         SWORD fontLeading;
  187.  
  188.         std::vector<SWORD>fontAdvanceTable;
  189.         
  190.         std::vector<FlashRect> fontBoundsTable;
  191.         std::vector<FlashKerningRecord> fontKerningTable;
  192.     };
  193.  
  194.     void SetLayout(FlashFontLayout &l) {layout = true; layout_data = l; }
  195.     void AddShape(FlashShape &shape) { shapes.push_back(shape); }
  196.     void AddCode(UWORD code) { codes.push_back(code); }
  197.  
  198. private:
  199.  
  200.     std::vector<UWORD> codes;
  201.     std::vector<FlashShape> shapes;
  202.     bool layout;
  203.         char flags;
  204.     const char *fontname;
  205.     FlashFontLayout layout_data;
  206.  
  207.     
  208.     friend std::ostream &operator << (std::ostream &out, FlashTagDefineFont2 &data);
  209.     friend std::istream &operator >> (std::istream &in,  FlashTagDefineFont2 &data);
  210.  
  211. };
  212.  
  213. #define FTDEB_HASTEXT            (1 << 15)
  214. #define FTDEB_WORDWRAP            (1 << 14)
  215. #define FTDEB_MULTILINE            (1 << 13)
  216. #define FTDEB_PASSWORD            (1 << 12)
  217. #define FTDEB_READONLY            (1 << 11)
  218. #define FTDEB_HASTEXTCOLOR        (1 << 10)
  219. #define FTDEB_HASMAXLENGTH        (1 << 9)
  220. #define FTDEB_HASFONT            (1 << 8)
  221. //reserved 2 bits
  222. #define FTDEB_HASLAYOUT            (1 << 5)
  223. #define FTDEB_NOSELECT            (1 << 4)
  224. #define FTDEB_BORDER            (1 << 3)
  225. //reserved 1 bit
  226. #define FTDEB_HTML               (1 << 1)
  227. #define FTDEB_USEOUTLINES        (1)
  228.  
  229. class FlashTagDefineEditBox : public FlashTag, public FlashIDEnabled
  230. {
  231. DEFINE_RW_INTERFACE
  232. public:    
  233.     FlashTagDefineEditBox(FlashRect &r, UWORD flags, UWORD fontID, UWORD fontHeight, 
  234.                           FlashRGB color /*WITH ALPHA*/, UWORD maxLength, unsigned char align, 
  235.                           UWORD leftmargin, UWORD rightmargin, UWORD indent, UWORD leading, 
  236.                           char *variable, char *initialtext) :
  237.                         mr(r), mflags(flags), mfontID(fontID),mfontHeight(fontHeight),mcolor(color),
  238.                         mmaxLength(maxLength), malign(align), mleftmargin(leftmargin), mrightmargin(rightmargin),
  239.                         mindent(indent), mleading(leading), mvariable(variable), 
  240.                         minitialtext(initialtext) {}
  241. private:
  242.  
  243.     friend std::ostream &operator << (std::ostream &out, FlashTagDefineEditBox &data);
  244.     friend std::istream &operator >> (std::istream &in,  FlashTagDefineEditBox &data);
  245.  
  246.     gc_vector<char *> gc;
  247.     FlashRect &mr;
  248.     UWORD mflags; 
  249.     UWORD mfontID; 
  250.     UWORD mfontHeight;
  251.     FlashRGB mcolor /*WITH ALPHA*/; 
  252.     UWORD mmaxLength; 
  253.     unsigned char malign;
  254.     UWORD mleftmargin; 
  255.     UWORD mrightmargin; 
  256.     UWORD mindent; 
  257.     UWORD mleading;
  258.     char *mvariable; 
  259.     char *minitialtext;
  260. };
  261. #endif
  262.