This file is indexed.

/usr/include/mingpp.h is in libming-dev 1:0.4.5-1ubuntu5.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

   1
   2
   3
   4
   5
   6
   7
   8
   9
  10
  11
  12
  13
  14
  15
  16
  17
  18
  19
  20
  21
  22
  23
  24
  25
  26
  27
  28
  29
  30
  31
  32
  33
  34
  35
  36
  37
  38
  39
  40
  41
  42
  43
  44
  45
  46
  47
  48
  49
  50
  51
  52
  53
  54
  55
  56
  57
  58
  59
  60
  61
  62
  63
  64
  65
  66
  67
  68
  69
  70
  71
  72
  73
  74
  75
  76
  77
  78
  79
  80
  81
  82
  83
  84
  85
  86
  87
  88
  89
  90
  91
  92
  93
  94
  95
  96
  97
  98
  99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 110
 111
 112
 113
 114
 115
 116
 117
 118
 119
 120
 121
 122
 123
 124
 125
 126
 127
 128
 129
 130
 131
 132
 133
 134
 135
 136
 137
 138
 139
 140
 141
 142
 143
 144
 145
 146
 147
 148
 149
 150
 151
 152
 153
 154
 155
 156
 157
 158
 159
 160
 161
 162
 163
 164
 165
 166
 167
 168
 169
 170
 171
 172
 173
 174
 175
 176
 177
 178
 179
 180
 181
 182
 183
 184
 185
 186
 187
 188
 189
 190
 191
 192
 193
 194
 195
 196
 197
 198
 199
 200
 201
 202
 203
 204
 205
 206
 207
 208
 209
 210
 211
 212
 213
 214
 215
 216
 217
 218
 219
 220
 221
 222
 223
 224
 225
 226
 227
 228
 229
 230
 231
 232
 233
 234
 235
 236
 237
 238
 239
 240
 241
 242
 243
 244
 245
 246
 247
 248
 249
 250
 251
 252
 253
 254
 255
 256
 257
 258
 259
 260
 261
 262
 263
 264
 265
 266
 267
 268
 269
 270
 271
 272
 273
 274
 275
 276
 277
 278
 279
 280
 281
 282
 283
 284
 285
 286
 287
 288
 289
 290
 291
 292
 293
 294
 295
 296
 297
 298
 299
 300
 301
 302
 303
 304
 305
 306
 307
 308
 309
 310
 311
 312
 313
 314
 315
 316
 317
 318
 319
 320
 321
 322
 323
 324
 325
 326
 327
 328
 329
 330
 331
 332
 333
 334
 335
 336
 337
 338
 339
 340
 341
 342
 343
 344
 345
 346
 347
 348
 349
 350
 351
 352
 353
 354
 355
 356
 357
 358
 359
 360
 361
 362
 363
 364
 365
 366
 367
 368
 369
 370
 371
 372
 373
 374
 375
 376
 377
 378
 379
 380
 381
 382
 383
 384
 385
 386
 387
 388
 389
 390
 391
 392
 393
 394
 395
 396
 397
 398
 399
 400
 401
 402
 403
 404
 405
 406
 407
 408
 409
 410
 411
 412
 413
 414
 415
 416
 417
 418
 419
 420
 421
 422
 423
 424
 425
 426
 427
 428
 429
 430
 431
 432
 433
 434
 435
 436
 437
 438
 439
 440
 441
 442
 443
 444
 445
 446
 447
 448
 449
 450
 451
 452
 453
 454
 455
 456
 457
 458
 459
 460
 461
 462
 463
 464
 465
 466
 467
 468
 469
 470
 471
 472
 473
 474
 475
 476
 477
 478
 479
 480
 481
 482
 483
 484
 485
 486
 487
 488
 489
 490
 491
 492
 493
 494
 495
 496
 497
 498
 499
 500
 501
 502
 503
 504
 505
 506
 507
 508
 509
 510
 511
 512
 513
 514
 515
 516
 517
 518
 519
 520
 521
 522
 523
 524
 525
 526
 527
 528
 529
 530
 531
 532
 533
 534
 535
 536
 537
 538
 539
 540
 541
 542
 543
 544
 545
 546
 547
 548
 549
 550
 551
 552
 553
 554
 555
 556
 557
 558
 559
 560
 561
 562
 563
 564
 565
 566
 567
 568
 569
 570
 571
 572
 573
 574
 575
 576
 577
 578
 579
 580
 581
 582
 583
 584
 585
 586
 587
 588
 589
 590
 591
 592
 593
 594
 595
 596
 597
 598
 599
 600
 601
 602
 603
 604
 605
 606
 607
 608
 609
 610
 611
 612
 613
 614
 615
 616
 617
 618
 619
 620
 621
 622
 623
 624
 625
 626
 627
 628
 629
 630
 631
 632
 633
 634
 635
 636
 637
 638
 639
 640
 641
 642
 643
 644
 645
 646
 647
 648
 649
 650
 651
 652
 653
 654
 655
 656
 657
 658
 659
 660
 661
 662
 663
 664
 665
 666
 667
 668
 669
 670
 671
 672
 673
 674
 675
 676
 677
 678
 679
 680
 681
 682
 683
 684
 685
 686
 687
 688
 689
 690
 691
 692
 693
 694
 695
 696
 697
 698
 699
 700
 701
 702
 703
 704
 705
 706
 707
 708
 709
 710
 711
 712
 713
 714
 715
 716
 717
 718
 719
 720
 721
 722
 723
 724
 725
 726
 727
 728
 729
 730
 731
 732
 733
 734
 735
 736
 737
 738
 739
 740
 741
 742
 743
 744
 745
 746
 747
 748
 749
 750
 751
 752
 753
 754
 755
 756
 757
 758
 759
 760
 761
 762
 763
 764
 765
 766
 767
 768
 769
 770
 771
 772
 773
 774
 775
 776
 777
 778
 779
 780
 781
 782
 783
 784
 785
 786
 787
 788
 789
 790
 791
 792
 793
 794
 795
 796
 797
 798
 799
 800
 801
 802
 803
 804
 805
 806
 807
 808
 809
 810
 811
 812
 813
 814
 815
 816
 817
 818
 819
 820
 821
 822
 823
 824
 825
 826
 827
 828
 829
 830
 831
 832
 833
 834
 835
 836
 837
 838
 839
 840
 841
 842
 843
 844
 845
 846
 847
 848
 849
 850
 851
 852
 853
 854
 855
 856
 857
 858
 859
 860
 861
 862
 863
 864
 865
 866
 867
 868
 869
 870
 871
 872
 873
 874
 875
 876
 877
 878
 879
 880
 881
 882
 883
 884
 885
 886
 887
 888
 889
 890
 891
 892
 893
 894
 895
 896
 897
 898
 899
 900
 901
 902
 903
 904
 905
 906
 907
 908
 909
 910
 911
 912
 913
 914
 915
 916
 917
 918
 919
 920
 921
 922
 923
 924
 925
 926
 927
 928
 929
 930
 931
 932
 933
 934
 935
 936
 937
 938
 939
 940
 941
 942
 943
 944
 945
 946
 947
 948
 949
 950
 951
 952
 953
 954
 955
 956
 957
 958
 959
 960
 961
 962
 963
 964
 965
 966
 967
 968
 969
 970
 971
 972
 973
 974
 975
 976
 977
 978
 979
 980
 981
 982
 983
 984
 985
 986
 987
 988
 989
 990
 991
 992
 993
 994
 995
 996
 997
 998
 999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
/*
    Ming, an SWF output library
    Copyright (C) 2001  Opaque Industries - http://www.opaque.net/

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
    License as published by the Free Software Foundation; either
    version 2.1 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public
    License along with this library; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/

#ifndef SWF_MINGPP_H_INCLUDED
#define SWF_MINGPP_H_INCLUDED

/* why would we need to include these ??
#include <stdio.h>
*/
#include <cstring> /* for strlen used in SWFBitmap costructor */
#include <stdexcept>
#include <iostream>
#include <string>
#include <list>

#ifdef _MSC_VER
#define strcasecmp stricmp 
#endif

/* mask the c type names so that we can replace them with classes.
   weird, but it works.  (on gcc, anyway..) */

extern "C"
{
  #define SWFShape        c_SWFShape
  #define SWFMovie        c_SWFMovie
  #define SWFDisplayItem  c_SWFDisplayItem
  #define SWFFill         c_SWFFill
  #define SWFFillStyle    c_SWFFillStyle
  #define SWFCharacter    c_SWFCharacter
  #define SWFBlock        c_SWFBlock
  #define SWFSprite       c_SWFSprite
  #define SWFMovieClip    c_SWFMovieClip
  #define SWFBitmap       c_SWFBitmap
  #define SWFGradient     c_SWFGradient
  #define SWFMorph        c_SWFMorph
  #define SWFText         c_SWFText
  #define SWFFont         c_SWFFont
  #define SWFBrowserFont  c_SWFBrowserFont
  #define SWFFontCollection  c_SWFFontCollection
  #define SWFTextField    c_SWFTextField
  #define SWFAction       c_SWFAction
  #define SWFButton       c_SWFButton
  #define SWFSoundStream  c_SWFSoundStream
  #define SWFInput        c_SWFInput
  #define SWFSound        c_SWFSound
  #define SWFVideoStream  c_SWFVideoStream
  #define SWFFilter       c_SWFFilter
  #define SWFBlur         c_SWFBlur
  #define SWFShadow       c_SWFShadow
  #define SWFFilterMatrix c_SWFFilterMatrix
  #define SWFInitAction   c_SWFInitAction
  #define SWFButtonRecord c_SWFButtonRecord
  #define SWFFontCharacter c_SWFFontCharacter
  #define SWFPrebuiltClip c_SWFPrebuiltClip
  #define SWFSoundInstance c_SWFSoundInstance
  #define SWFBinaryData	  c_SWFBinaryData
  #define SWFMatrix	  c_SWFMatrix
  #define SWFCXform	  c_SWFCXform

  #include <ming.h>

/* 
 * declaration from src/blocks/fdbfont.h. 
 * internal function to maintain behavior of older ming-version
 */
SWFFont loadSWFFont_fromFdbFile(FILE *file);

  #undef SWFShape
  #undef SWFMovie
  #undef SWFDisplayItem
  #undef SWFFill
  #undef SWFFillStyle
  #undef SWFCharacter
  #undef SWFBlock
  #undef SWFSprite
  #undef SWFMovieClip
  #undef SWFBitmap
  #undef SWFGradient
  #undef SWFMorph
  #undef SWFFont
  #undef SWFBrowserFont
  #undef SWFFontCollection
  #undef SWFText
  #undef SWFTextField
  #undef SWFAction
  #undef SWFButton
  #undef SWFSoundStream
  #undef SWFInput
  #undef SWFSound
  #undef SWFFontCharacter
  #undef SWFPrebuiltClip 
  #undef SWFVideoStream
  #undef SWFFilter
  #undef SWFBlur
  #undef SWFShadow
  #undef SWFFilterMatrix
  #undef SWFInitAction
  #undef SWFButtonRecord
  #undef SWFSoundInstance
  #undef SWFBinaryData
  #undef SWFMatrix
  #undef SWFCXform
} // extern C

#define SWF_DECLAREONLY(classname) \
	private: \
	classname(const classname&); \
	const classname& operator=(const classname&)


class SWFException : public std::exception
{
public:
	SWFException(const char *m)
	{ 
		this->message = m;
	}

	virtual ~SWFException() throw () 
	{ }
		
	virtual const char *what()
	{
		return this->message.c_str();
	}	
private:
	std::string message;
};

/* SWFMatrix */
class SWFMatrix
{
 friend class SWFDisplayItem;
 public:
  c_SWFMatrix matrix;

  double getScaleX()
  { return SWFMatrix_getScaleX(this->matrix); }

  double getScaleY()
  { return SWFMatrix_getScaleY(this->matrix); }

  double getRotate0()
  { return SWFMatrix_getRotate0(this->matrix); }
 
  double getRotate1()
  { return SWFMatrix_getRotate1(this->matrix); }

  int getTranslateX()
  { return SWFMatrix_getTranslateX(this->matrix); }

  int getTranslateY()
  { return SWFMatrix_getTranslateY(this->matrix); }

 private:
  SWFMatrix(c_SWFMatrix matrix)
  {
    if(matrix == NULL)
      throw SWFException("SWFMatrix(c_SWFMatrix matrix)");
    this->matrix = matrix;
  }
 SWF_DECLAREONLY(SWFMatrix);
};

class SWFCXform
{
 public:
  c_SWFCXform cx;

  SWFCXform(int rAdd, int gAdd, int bAdd, int aAdd, float rMult, float gMult, float bMult, float aMult)
  {
    this->cx =  newSWFCXform(rAdd, gAdd, bAdd, aAdd, rMult, gMult, bMult, aMult);
    if(this->cx == NULL)
      throw SWFException("SWFCXform(int rAdd, int gAdd,...)");
  }

  void setColorAdd(int rAdd, int gAdd, int bAdd, int aAdd)
  { SWFCXform_setColorAdd(this->cx, rAdd, gAdd, bAdd, aAdd); }

  void setColorMult(float rMult, float gMult, float bMult, float aMult)
  { SWFCXform_setColorMult(this->cx, rMult, gMult, bMult, aMult); }

  ~ SWFCXform()
  { destroySWFCXform(cx); }

  static SWFCXform *AddCXForm(int rAdd, int gAdd, int bAdd, int aAdd)
  { return new SWFCXform(newSWFAddCXform(rAdd, gAdd, bAdd, aAdd));  }

  static SWFCXform *MultCXForm(float rMult, float gMult, float bMult, float aMult)
 { return new SWFCXform(newSWFMultCXform(rMult, gMult, bMult, aMult)); }

  

 private:
  SWFCXform(c_SWFCXform cx)
  {
    if(cx == NULL)
      throw SWFException("SWFCXform(c_SWFCXform cx)");

    this->cx = cx;
  }
  SWF_DECLAREONLY(SWFCXform);

};

/*  SWFInput  */

class SWFInput
{
 public:
  c_SWFInput input;

  SWFInput(FILE *f)
  { 
    this->input = newSWFInput_file(f); 
    if(this->input == NULL) 
      throw SWFException("SWFInput(FILE *f)\n");
  }

  SWFInput(unsigned char *buffer, int length)
  { 
    this->input = newSWFInput_buffer(buffer, length); 
    if(this->input == NULL)
      throw SWFException("SWFInput(unsigned char *buffer, int length)\n");
  }

  SWFInput(unsigned char *buffer, int length, int alloced)
  {
    if(alloced)
      this->input = newSWFInput_allocedBuffer(buffer, length);
    else
      this->input = newSWFInput_buffer(buffer, length);

    if(this->input == NULL)
      SWFException("SWFInput(unsigned char *buffer, int length, int alloced)\n");
  }

  virtual ~SWFInput() { destroySWFInput(this->input); }

  SWF_DECLAREONLY(SWFInput);
  SWFInput();
};


/*  SWFBlock  */

class SWFBlock
{
 public:
  virtual c_SWFBlock getBlock() = 0;
};

/*  SWFCharacter  */

class SWFCharacter : public SWFBlock
{
 friend class SWFMovie;
 friend class SWFDisplayItem;
 public:
  c_SWFCharacter character;

    float getWidth()
    { return SWFCharacter_getWidth(this->character); }

  float getHeight()
    { return SWFCharacter_getHeight(this->character); }

  virtual c_SWFBlock getBlock()
    { return (c_SWFBlock)character; }

 protected:
  SWFCharacter()
  { character = NULL; }
  
  SWFCharacter(c_SWFCharacter c)
  { character = c; }


  SWF_DECLAREONLY(SWFCharacter);
};
/*  SWFFontCharacter */
class SWFFontCharacter : public SWFCharacter
{
 friend class SWFMovie;
 public:
  c_SWFFontCharacter fontcharacter;
  
  void addChars(const char *str)
    { SWFFontCharacter_addChars(this->fontcharacter, str); }

  void addUTF8Chars(const char *str)
    { SWFFontCharacter_addUTF8Chars(this->fontcharacter, str); }

  void addAllChars()
    { SWFFontCharacter_addAllChars(this->fontcharacter); }

 private:
  SWFFontCharacter(c_SWFFontCharacter fontcharacter)
  { 
	this->fontcharacter = fontcharacter; 
	this->character = (c_SWFCharacter)fontcharacter;
  }

  virtual ~SWFFontCharacter()
    { }

  SWF_DECLAREONLY(SWFFontCharacter);
  SWFFontCharacter();
};


/*  SWFPrebuiltClip */

class SWFPrebuiltClip : public SWFBlock
{
 public:
  c_SWFPrebuiltClip prebuiltclip;

  SWFPrebuiltClip(c_SWFPrebuiltClip prebuiltclip)
  { 
    if(prebuiltclip == NULL)
      throw SWFException("new SWFPrebuiltClip: prebuiltclip == NULL)");
    this->prebuiltclip = prebuiltclip; 
  }

  virtual ~SWFPrebuiltClip()
    { }

  c_SWFBlock getBlock()
    { return (c_SWFBlock)this->prebuiltclip; }


  SWFPrebuiltClip(const char *name)
  {
    if(strlen(name) > 4 &&
       strcmp(name + strlen(name) - 4, ".swf") == 0)
      this->prebuiltclip = newSWFPrebuiltClip_fromFile(name);
    else
      this->prebuiltclip = NULL;
   
    if(this->prebuiltclip == NULL)
      throw SWFException("SWFPrebuiltClip(const char *name)");
  }
  SWF_DECLAREONLY(SWFPrebuiltClip);
  SWFPrebuiltClip();
};
// )))) end minguts 2004/08/31


/*  SWFAction  */

class SWFAction : public SWFBlock
{
 public:
  c_SWFAction action;

  SWFAction(const char *script)
  { 
    this->action = newSWFAction(script); 
    if(this->action == NULL)
      throw SWFException("SWFAction(const char *script)");
  }

  // movies, buttons, etc. destroy the c_SWFAction..
  virtual ~SWFAction() {}

  c_SWFBlock getBlock()
    { return (c_SWFBlock)this->action; }

  int compile(int swfVersion, int *length)
    { return SWFAction_compile(this->action, swfVersion, length); }

  unsigned char *getByteCode(int *len)
    { return SWFAction_getByteCode(this->action, len); }
  
  SWF_DECLAREONLY(SWFAction);
  SWFAction();
};

/*  SWFInitAction  */

class SWFInitAction : public SWFBlock
{
 public:
  c_SWFInitAction init;

  SWFInitAction(SWFAction *action)
  { 
    this->init = newSWFInitAction(action->action); 
    if(this->init == NULL)
      throw SWFException("SWFInitAction(SWFAction *action)");
  }

  SWFInitAction(SWFAction *action, int id)
  { 
    this->init = newSWFInitAction_withId(action->action, id); 
    if(this->init == NULL)
      throw SWFException("SWFInitAction(SWFAction *action, int id)");
  }

  virtual ~SWFInitAction() {}

  c_SWFBlock getBlock()
    { return (c_SWFBlock)this->init; }

  SWF_DECLAREONLY(SWFInitAction);
  SWFInitAction();
};


/*  SWFGradient  */

class SWFGradient
{
 public:
  c_SWFGradient gradient;

  SWFGradient()
  { 
    this->gradient = newSWFGradient(); 
    if(this->gradient == NULL)
      throw SWFGradient();
  }

  virtual ~SWFGradient()
    { destroySWFGradient(this->gradient); }

  void addEntry(float ratio, byte r, byte g, byte b, byte a=0xff)
    { SWFGradient_addEntry(this->gradient, ratio, r, g, b, a); }

  void setSpreadMode(GradientSpreadMode mode)
    { SWFGradient_setSpreadMode(this->gradient, mode); }

  void setInterpolationMode(GradientInterpolationMode mode)
    { SWFGradient_setInterpolationMode(this->gradient, mode); }

  void setFocalPoint(float focalPoint)
    { SWFGradient_setFocalPoint(this->gradient, focalPoint); }

  SWF_DECLAREONLY(SWFGradient);
};

/* SWFFilter */
class SWFBlur
{
 public:
  c_SWFBlur blur;
  
  SWFBlur(float blurX, float blurY, int passes)
  {  
    this->blur = newSWFBlur(blurX, blurY, passes); 
    if(this->blur == NULL)
      throw SWFException("SWFBlur(float blurX, float blurY, int passes)");
  }

  ~SWFBlur()
    { destroySWFBlur(blur); }

  SWF_DECLAREONLY(SWFBlur);
  SWFBlur();
};

class SWFShadow
{
 public:
  c_SWFShadow shadow;

  SWFShadow(float angle, float distance, float strength)
  { 
    this->shadow = newSWFShadow(angle, distance, strength); 
    if(this->shadow == NULL)
      throw SWFException("SWFShadow(float angle, float distance, float strength)");
  }

  ~SWFShadow()
    { destroySWFShadow(shadow); }

  SWF_DECLAREONLY(SWFShadow);
  SWFShadow();
};

class SWFFilterMatrix 
{
 public:
  c_SWFFilterMatrix matrix;

  SWFFilterMatrix(int cols, int rows, float *vals)
  { 
    this->matrix = newSWFFilterMatrix(cols, rows, vals); 
    if(this->matrix == NULL)
      throw SWFException("SWFFilterMatrix(int cols, int rows, float *vals)");
  }

  ~SWFFilterMatrix()
    { destroySWFFilterMatrix(matrix); }

  SWF_DECLAREONLY(SWFFilterMatrix);
  SWFFilterMatrix();
};

class SWFFilter
{
 public:
  c_SWFFilter filter;

  virtual ~SWFFilter() {}

  static SWFFilter *BlurFilter(SWFBlur *blur)
    { return new SWFFilter(newBlurFilter(blur->blur)); }

  static SWFFilter *DropShadowFilter(SWFColor color, SWFBlur *blur, 
                                    SWFShadow *shadow, int flags)
    { return new SWFFilter(newDropShadowFilter(color, blur->blur, shadow->shadow, flags)); } 

  static SWFFilter *GlowFilter(SWFColor color, SWFBlur *blur, 
                              float strength, int flags)
    { return new SWFFilter(newGlowFilter(color, blur->blur, strength, flags));}

  static SWFFilter *BevelFilter(SWFColor sColor, SWFColor hColor,
                               SWFBlur *blur, SWFShadow *shadow, int flags)
    { return new SWFFilter(newBevelFilter(sColor, hColor, blur->blur, shadow->shadow, flags)); }

  static SWFFilter *GradientGlowFilter(SWFGradient *gradient, SWFBlur *blur, SWFShadow *shadow, int flags)
    { return new SWFFilter(newGradientGlowFilter(gradient->gradient, blur->blur, shadow->shadow, flags)); }

  static SWFFilter *GradientBevelFilter(SWFGradient *gradient, SWFBlur *blur,
                                       SWFShadow *shadow, int flags)
    { return new SWFFilter(newGradientBevelFilter(gradient->gradient, blur->blur, shadow->shadow, flags)); }

  static SWFFilter *ConvolutionFilter(SWFFilterMatrix *matrix, float divisor,
                                     float bias, SWFColor color, int flags)
    { return new SWFFilter(newConvolutionFilter(matrix->matrix, divisor, bias, color, flags)); }

  static SWFFilter *ColorMatrixFilter(SWFFilterMatrix *matrix)
    { return new SWFFilter(newColorMatrixFilter(matrix->matrix)); }

private:
  SWFFilter(c_SWFFilter filter)
  {  
    this->filter = filter;
    if(this->filter == NULL)
      throw SWFException("SWFFilter(c_SWFFilter filter)");
  } 
  SWF_DECLAREONLY(SWFFilter);
  SWFFilter();
};



/*  SWFDisplayItem  */

class SWFDisplayItem
{
 friend class SWFMovie;
 friend class SWFMovieClip;
 friend class SWFSprite;
 public:
  c_SWFDisplayItem item;
 
  void rotate(double degrees)
    { SWFDisplayItem_rotate(this->item, degrees); }

  void rotateTo(double degrees)
    { SWFDisplayItem_rotateTo(this->item, degrees); }

  void getRotation(double *degrees)
    { SWFDisplayItem_getRotation(this->item, degrees); }

  void move(double x, double y)
    { SWFDisplayItem_move(this->item, x, y); }

  void moveTo(double x, double y)
    { SWFDisplayItem_moveTo(this->item, x, y); }

  void getPosition(double *x, double *y)
    { SWFDisplayItem_getPosition(this->item, x, y); }

  void scale(double xScale, double yScale)
    { SWFDisplayItem_scale(this->item, xScale, yScale); }

  void scale(double scale)
    { SWFDisplayItem_scale(this->item, scale, scale); }

  void scaleTo(double xScale, double yScale)
    { SWFDisplayItem_scaleTo(this->item, xScale, yScale); }

  void scaleTo(double scale)
    { SWFDisplayItem_scaleTo(this->item, scale, scale); }

  void getScale(double *xScale, double *yScale)
    { SWFDisplayItem_getScale(this->item, xScale, yScale); }

  void skewX(double skew)
    { SWFDisplayItem_skewX(this->item, skew); }

  void skewXTo(double skew)
    { SWFDisplayItem_skewXTo(this->item, skew); }

  void skewY(double skew)
    { SWFDisplayItem_skewY(this->item, skew); }

  void skewYTo(double skew)
    { SWFDisplayItem_skewYTo(this->item, skew); }

  void getSkew(double *xSkew, double *ySkew)
    { SWFDisplayItem_getSkew(this->item, xSkew, ySkew); }

  int getDepth()
    { return SWFDisplayItem_getDepth(this->item); }

  void setDepth(int depth)
    { SWFDisplayItem_setDepth(this->item, depth); }

  void remove()
    { SWFDisplayItem_remove(this->item); }

  void setName(const char *name)
    { SWFDisplayItem_setName(this->item, name); }

  void setRatio(float ratio)
    { SWFDisplayItem_setRatio(this->item, ratio); }

  void addColor(int r, int g, int b, int a=0)
    { SWFDisplayItem_setColorAdd(this->item, r, g, b, a); }

  void multColor(float r, float g, float b, float a=1.0)
    { SWFDisplayItem_setColorMult(this->item, r, g, b, a); }

  void addAction(SWFAction *action, int flags)
    { SWFDisplayItem_addAction(this->item, action->action, flags); }

  void addFilter(SWFFilter *filter)
    { SWFDisplayItem_addFilter(this->item, filter->filter); }

  void cacheAsBitmap(int flag)
    { SWFDisplayItem_cacheAsBitmap(this->item, flag); }

  void setBlendMode(int mode)
    { SWFDisplayItem_setBlendMode(this->item, mode); }
  
  void setMatrix(double a, double b, double c, double d, double x, double y)
    { SWFDisplayItem_setMatrix(this->item, a, b, c, d, x, y); }

  SWFMatrix getMatrix()
    { return SWFMatrix(SWFDisplayItem_getMatrix(this->item)); }

  void setMaskLevel(int level)
    { SWFDisplayItem_setMaskLevel(this->item, level); }

  void endMask()
    { SWFDisplayItem_endMask(this->item); }
  
  void flush()
    { SWFDisplayItem_flush(this->item); }
 
  SWFCharacter *getCharacter()
    { return new SWFCharacter(SWFDisplayItem_getCharacter(this->item)); }

  void setCXform(SWFCXform *cx)
    { SWFDisplayItem_setCXform(this->item, cx->cx); } 
  
 private:
  SWFDisplayItem(c_SWFDisplayItem item)
  { 
    this->item = item; 
    if(this->item == NULL)
      throw SWFException("SWFDisplayItem()");
  }
  ~SWFDisplayItem() { }

  SWF_DECLAREONLY(SWFDisplayItem);
  SWFDisplayItem();
};


/*  SWFSoundStream  */

class SWFSoundStream
{
 public:
  c_SWFSoundStream sound;

  SWFSoundStream(FILE *file)
  { 
    this->sound = newSWFSoundStream(file); 
    if(this->sound == NULL)
      throw SWFException("SWFSoundStream(FILE *file)");
  }

  SWFSoundStream(SWFInput *input)
  { 
    this->sound = newSWFSoundStream_fromInput(input->input); 
    if(this->sound == NULL)
      throw SWFException("SWFSoundStream(SWFInput *input)");
  }

  SWFSoundStream(char *filename)
  { 
    this->sound = newSWFSoundStream(fopen(filename, "rb")); 
    if(this->sound == NULL)
      throw SWFException("SWFSoundStream(char *filename)");
  }

  unsigned int getDuration()
  {
    return SWFSoundStream_getDuration(this->sound);
  }

  void setInitialMp3Delay(int delaySeek)
  {
    SWFSoundStream_setInitialMp3Delay(this->sound, delaySeek);
  }

  virtual ~SWFSoundStream()
    { destroySWFSoundStream(this->sound); }
  SWF_DECLAREONLY(SWFSoundStream);
  SWFSoundStream();
};




class SWFSound : public SWFBlock
{
 public:
  c_SWFSound sound;

  SWFSound(FILE *file, int flags)
  { 
	filep = NULL;
	this->sound = newSWFSound(file, flags);
	if(this->sound == NULL)
		throw SWFException("SWFSound(FILE *file, int flags)");
  }

  SWFSound(SWFInput *input, int flags)
  {
	this->sound = newSWFSound_fromInput(input->input, flags); 
	filep = NULL;
	if(this->sound == NULL)
		throw SWFException("SWFSound(SWFInput *input, int flags)");
  }

  SWFSound(char *filename, int flags)
  { 
	filep = fopen(filename, "rb");
	this->sound = newSWFSound(filep, flags);
	if(this->sound == NULL)
	{
		fclose(filep);
		throw SWFException("SWFSound(char *filename, int flags)");
	}
  }
  
  SWFSound(SWFSoundStream *stream)
  { 
	this->sound = newSWFSound_fromSoundStream(stream->sound); 
	filep = NULL;
	if(this->sound == NULL)
		throw SWFException("SWFSound(SWFSoundStream *stream)");
  }

  void delaySeek(int delaySeek)
  {
	SWFSound_setInitialMp3Delay(this->sound, delaySeek);
  }

  virtual ~SWFSound()
  {
	if(filep)
		fclose(filep); 
	destroySWFSound(this->sound); 
  }

  c_SWFBlock getBlock()
    { return (c_SWFBlock)this->sound; }
 
 private:
    FILE *filep;

  SWF_DECLAREONLY(SWFSound);
  SWFSound();
};

/*  SWFFont  */

class SWFFont : public SWFBlock
{
 friend class SWFFontCollection;
 public:
  c_SWFFont font;

  SWFFont(FILE *file) // deprecated 
  {
	std::cerr << "SWFFont(FILE *file) is deprecated and will be removed in future releases." << std::endl;
	this->font = loadSWFFont_fromFdbFile(file);
	if(this->font == NULL)
		throw SWFException("SWFFont(FILE *file)");
  }

  SWFFont(const char *path)
  { 
    this->font = newSWFFont_fromFile(path); 
    if(this->font == NULL)
      throw SWFException("SWFFont(char *path)");
  }

  virtual ~SWFFont()
    { destroySWFFont(/*(c_SWFBlock)*/this->font); }

  c_SWFBlock getBlock()
    { return (c_SWFBlock)this->font; }

  float getStringWidth(const char *string)
    { return SWFFont_getStringWidth(this->font, string); }

  float getWidth(const char *string)
    { return SWFFont_getStringWidth(this->font, string); }

  float getUTF8StringWidth(const char *string)
    { return SWFFont_getUTF8StringWidth(this->font, string); }

  float getAscent()
    { return SWFFont_getAscent(this->font); }

  float getDescent()
    { return SWFFont_getDescent(this->font); }

  float getLeading()
    { return SWFFont_getLeading(this->font); }

  const char *getName()
    { return SWFFont_getName(this->font); }

  int getGlyphCount()
    { return SWFFont_getGlyphCount(this->font); }
  
  char *getShape(unsigned short c) __deprecated
    { return SWFFont_getShape(this->font, c); }

  SWF_DECLAREONLY(SWFFont);

 private:
  SWFFont(c_SWFFont font)
  { 
    this->font = font;
    if(this->font == NULL)
      throw SWFException("SWFFont(c_SWFFont)");
  }
};

/* SWFBrowserFont */
class SWFBrowserFont : public SWFBlock
{
 public:
  c_SWFBrowserFont bfont;
  
  SWFBrowserFont(char *name)
  { 
    this->bfont = newSWFBrowserFont(name); 
    if(this->bfont == NULL)
      throw SWFException("SWFBrowserFont(char *name)");
  }

  c_SWFBlock getBlock()
    { return (c_SWFBlock)this->bfont; }

  virtual ~SWFBrowserFont()
    { destroySWFBrowserFont(this->bfont); }
  
  SWF_DECLAREONLY(SWFBrowserFont);
};

class SWFFontCollection
{
 public:
  c_SWFFontCollection fc;

  SWFFontCollection(const char *filename)
  {
    this->fc = newSWFFontCollection_fromFile(filename);
    if(this->fc == NULL)
      throw SWFException("SWFFontCollection(filename)");
  }

  ~ SWFFontCollection()
    { destroySWFFontCollection(this->fc); }

  SWFFont *getFont(int index)
    { return new SWFFont(SWFFontCollection_getFont(this->fc, index)); }

  int getFontCount()
    { return SWFFontCollection_getFontCount(this->fc); }

  SWF_DECLAREONLY(SWFFontCollection);
};

class SWFSoundInstance
{
 friend class SWFMovie;
 friend class SWFMovieClip;

 public:
  c_SWFSoundInstance instance;
 
  void setNoMultiple()
  { SWFSoundInstance_setNoMultiple(this->instance); }

  void setLoopInPoint(unsigned int point)
  { SWFSoundInstance_setLoopInPoint(this->instance, point); }
  
  void setLoopOutPoint(unsigned int point)
  {  SWFSoundInstance_setLoopOutPoint(this->instance, point); }

  void setLoopCount(int count)
  {  SWFSoundInstance_setLoopCount(this->instance, count); }

  void addEnvelope(unsigned int mark44, short left, short right)
  { SWFSoundInstance_addEnvelope(this->instance, mark44, left, right); }

 private:
  SWFSoundInstance(c_SWFSoundInstance inst)
  {
    if(inst == NULL)
      throw SWFException("SWFSoundInstance(c_SWFSoundInstance inst)");

    this->instance = inst;
  }
 SWF_DECLAREONLY(SWFSoundInstance);
};

/*  SWFMovie  */
class SWFMovie
{
 public:
  c_SWFMovie movie;

  SWFMovie()
  { 
    this->movie = newSWFMovie();
    if(this->movie == NULL)
      throw SWFException("SWFMovie()");
  }

  SWFMovie(int version)
  { 
    this->movie = newSWFMovieWithVersion(version);
    if(this->movie == NULL)
      throw SWFException("SWFMovie(int version)");
  }

  virtual ~SWFMovie()
    { destroySWFMovie(this->movie); }

  void setRate(float rate)
    { SWFMovie_setRate(this->movie, rate); }

  float getRate()
    { return SWFMovie_getRate(this->movie); }

  void setDimension(float x, float y)
    { SWFMovie_setDimension(this->movie, x, y); }

  void setNumberOfFrames(int nFrames)
    { SWFMovie_setNumberOfFrames(this->movie, nFrames); }

  /* aka */
  void setFrames(int nFrames)
    { SWFMovie_setNumberOfFrames(this->movie, nFrames); }

  void setBackground(byte r, byte g, byte b)
    { SWFMovie_setBackground(this->movie, r, g, b); }

  void setSoundStream(SWFSoundStream *sound, float skip=0.0)
  {
    if(skip > 0)
      SWFMovie_setSoundStreamAt(this->movie, sound->sound, skip);
    else
      SWFMovie_setSoundStream(this->movie, sound->sound); 
  }

  SWFDisplayItem *add(SWFBlock *character)
  {
    SWFMovieBlockType ublock;
    ublock.block = character->getBlock();
    c_SWFDisplayItem item = SWFMovie_add_internal(this->movie, ublock);
    if(item == NULL)
      return NULL;
    SWFDisplayItem *_item_ = new SWFDisplayItem(item);
    itemList.push_back(_item_);
    return _item_; 
  }

  void addExport(SWFBlock *exp, char *name)
    {  SWFMovie_addExport(this->movie, exp->getBlock(), name); }

  void remove(SWFDisplayItem *item)
    { SWFMovie_remove(this->movie, item->item); }

  bool replace(SWFDisplayItem *item, SWFBlock *character)
  { 
    SWFMovieBlockType ublock;
    ublock.block = character->getBlock();
    return SWFMovie_replace_internal(this->movie, item->item, ublock); 
  }

  void nextFrame()
    { SWFMovie_nextFrame(this->movie); }

  void labelFrame(const char *label)
    { SWFMovie_labelFrame(this->movie, label); }

  void namedAnchor(const char *label)
    { SWFMovie_namedAnchor(this->movie, label); }

  int output(int level=-1)
  {
    int oldlevel = Ming_setSWFCompression(level);
    int ret = SWFMovie_output_to_stream(this->movie, stdout);
    cleanUp();
    Ming_setSWFCompression(oldlevel);
    return ret;
  }

  int save(const char *filename, int level=-1)
  {
    int oldlevel = Ming_setSWFCompression(level);
    int result = SWFMovie_save(this->movie,filename);
    Ming_setSWFCompression(oldlevel);
    cleanUp();
    return result;
  }

  SWFSoundInstance *startSound(SWFSound *sound)
    { return new SWFSoundInstance(SWFMovie_startSound(this->movie, sound->sound)); }
  void stopSound(SWFSound *sound)
    { SWFMovie_stopSound(this->movie, sound->sound); }

  SWFCharacter *importCharacter(const char *filename, const char *name)
    { return new SWFCharacter(SWFMovie_importCharacter(this->movie, filename, name)); }

  SWFFontCharacter *importFont(const char *filename, const char *name)
  { return new SWFFontCharacter(SWFMovie_importFont(this->movie, filename, name)); }

  SWFFontCharacter *addFont(SWFFont *font)
  { return new SWFFontCharacter(SWFMovie_addFont(this->movie, font->font)); }

  void protect()
  { SWFMovie_protect(this->movie, NULL);}

  void protect(char *password)
  { SWFMovie_protect(this->movie,password); }
  
  void addMetadata(char *xml)
    { SWFMovie_addMetadata(this->movie, xml); }
  
  void setNetworkAccess(int flag)
    { SWFMovie_setNetworkAccess(this->movie, flag); }
  
  void setScriptLimits(int maxRecursion, int timeout)
    { SWFMovie_setScriptLimits(this->movie, maxRecursion, timeout); }

  void setTabIndex(int depth, int index)
    { SWFMovie_setTabIndex(this->movie, depth, index); }

  void assignSymbol(SWFCharacter *character, char *name)
    { SWFMovie_assignSymbol(this->movie, (c_SWFCharacter)character->getBlock(), name); }

  void defineScene(unsigned int offset, const char *name)
    { SWFMovie_defineScene(this->movie, offset, name); }

  void writeExports()
    { SWFMovie_writeExports(this->movie); }

  SWF_DECLAREONLY(SWFMovie);
 private:

  void cleanUp()
  {
    std::list<SWFDisplayItem *>::iterator iter = itemList.begin();
    for(; iter != itemList.end(); iter++)
      delete (*iter);
  }
  std::list<SWFDisplayItem *> itemList;
};





/*  SWFBitmap  */

class SWFBitmap : public SWFCharacter
{
 public:
  c_SWFBitmap bitmap;

  c_SWFBlock getBlock()
    { return (c_SWFBlock)this->bitmap; }
  
  SWFBitmap(const char *filename, const char *alpha=NULL)
  {
    if(strlen(filename) > 4)
    {
      if(strcasecmp(filename+strlen(filename)-4, ".dbl") == 0)
	this->bitmap = (c_SWFBitmap) newSWFDBLBitmap(fopen(filename, "rb"));

      else if(strcasecmp(filename+strlen(filename)-4, ".gif") == 0)
	this->bitmap = (c_SWFBitmap) newSWFDBLBitmapData_fromGifFile(filename);

      else if(strcasecmp(filename+strlen(filename)-4, ".png") == 0)
 		this->bitmap =   (c_SWFBitmap) newSWFDBLBitmapData_fromPngFile( filename );

      else if(strcasecmp(filename+strlen(filename)-4, ".jpg") == 0 ||
	(strlen(filename) > 5 && (strcasecmp(filename+strlen(filename)-5, ".jpeg") == 0)))
      {
	if(alpha != NULL)
	  this->bitmap = (c_SWFBitmap) newSWFJpegWithAlpha(fopen(filename, "rb"),
					     fopen(alpha, "rb"));
	else
	  this->bitmap = (c_SWFBitmap) newSWFJpegBitmap(fopen(filename, "rb"));
      }

      else
	bitmap = NULL;
    }
    if ( ! this->bitmap ) 
      throw SWFException("SWFBitmap(const char *filename, const char *alpha=NULL)");

    this->character = (c_SWFCharacter)bitmap;
  }
  
  SWFBitmap(unsigned char *raw, SWFRawImgFmt srcFmt, SWFBitmapFmt dstFmt, 
            unsigned short width, unsigned short height)
  {
    this->bitmap = newSWFBitmap_fromRawImg(raw, srcFmt, dstFmt, width, height);
    if ( ! this->bitmap ) 
      throw SWFException("SWFBitmap(const char *filename, const char *alpha=NULL)");
    this->character = (c_SWFCharacter)bitmap;
  }
  
  SWFBitmap(SWFInput *input)
  { 
    this->bitmap = newSWFBitmap_fromInput(input->input);
    if(this->bitmap == NULL)
      throw SWFException("SWFBitmap(SWFInput *input)");
    this->character = (c_SWFCharacter)bitmap;
  }

  virtual ~SWFBitmap()
    { destroySWFBitmap(this->bitmap); }
  
  int getWidth()
    { return SWFBitmap_getWidth(this->bitmap); }

  int getHeight()
    { return SWFBitmap_getHeight(this->bitmap); }

  SWF_DECLAREONLY(SWFBitmap);
  SWFBitmap();
};

class SWFFillStyle
{
 friend class SWFFill;
 public:
  c_SWFFillStyle fill;
  
  virtual ~SWFFillStyle() { }

  static SWFFillStyle *SolidFillStyle(byte r, byte g, byte b, byte a=255)
    { return new SWFFillStyle(newSWFSolidFillStyle(r, g, b, a)); }

  static SWFFillStyle *GradientFillStyle(SWFGradient *gradient, byte flags)
    { return new SWFFillStyle(newSWFGradientFillStyle(gradient->gradient, flags)); }

  static SWFFillStyle *BitmapFillStyle(SWFBitmap *bitmap, byte flags)
    { return new SWFFillStyle(newSWFBitmapFillStyle(bitmap ? bitmap->bitmap : 0, flags)); }

 private:
  SWFFillStyle(c_SWFFillStyle fill)
  { 
    this->fill = fill; 
    if(this->fill == NULL)
      throw SWFException("SWFFillStyle");
  }
  SWF_DECLAREONLY(SWFFillStyle);
  SWFFillStyle();
};   

/*  SWFFill  */
class SWFFill
{
 friend class SWFShape;
 public:
  c_SWFFill fill;

  SWFFill(SWFFillStyle *fs)
  {
	this->fill = newSWFFill(fs->fill);
	if(this->fill == NULL)
		throw SWFException("SWFFill");
  }

    // shape destroys c_SWFFill object
  virtual ~SWFFill() 
	{ destroySWFFill(this->fill); }

  void skewX(float x)
    { SWFFill_skewX(this->fill, x); }

  void skewXTo(float x)
    { SWFFill_skewXTo(this->fill, x); }

  void skewY(float y)
    { SWFFill_skewY(this->fill, y); }

  void skewYTo(float y)
    { SWFFill_skewYTo(this->fill, y); }

  void scaleX(float x)
    { SWFFill_scaleX(this->fill, x); }

  void scaleXTo(float x)
    { SWFFill_scaleXTo(this->fill, x); }

  void scaleY(float y)
    { SWFFill_scaleY(this->fill, y); }

  void scaleYTo(float y)
    { SWFFill_scaleYTo(this->fill, y); }

  void scale(float x, float y)
    { SWFFill_scaleXY(this->fill, x, y); }

  void scale(float scale)
    { SWFFill_scaleXY(this->fill, scale, scale); }

  void scaleTo(float x, float y)
    { SWFFill_scaleXYTo(this->fill, x, y); }

  void scaleTo(float scale)
    { SWFFill_scaleXYTo(this->fill, scale, scale); }

  void rotate(float degrees)
    { SWFFill_rotate(this->fill, degrees); }

  void rotateTo(float degrees)
    { SWFFill_rotateTo(this->fill, degrees); }

  void move(float x, float y)
    { SWFFill_move(this->fill, x, y); }

  void moveTo(float x, float y)
    { SWFFill_move(this->fill, x, y); }

  void setMatrix( float a, float b, float c, float d, float x, float y)
    { SWFFill_setMatrix(this->fill, a, b, c, d, x, y); }

  SWFFillStyle *getFillStyle()
    { return new SWFFillStyle(SWFFill_getFillStyle(this->fill)); }

  SWF_DECLAREONLY(SWFFill);
  SWFFill(); 

private:
  SWFFill(c_SWFFill fill)
  { 
    this->fill = fill; 
    if(this->fill == NULL)
      throw SWFException("SWFFill");
  }
};


/*  SWFShape  */
class SWFShape : public SWFCharacter
{
 public:
  c_SWFShape shape;

  SWFShape()
  { 
    this->shape = newSWFShape();
    if(this->shape == NULL)
      throw SWFException("SWFShape()");

    this->character = (c_SWFCharacter)shape;
  }

  SWFShape(c_SWFShape shape)
  { 
    this->shape = shape;
    if(this->shape == NULL)
      throw SWFException("SWFShape(c_SWFShape shape)");
  }

  virtual ~SWFShape()
    { destroySWFShape(this->shape); }

  c_SWFBlock getBlock()
    { return (c_SWFBlock)this->shape; }

  void movePen(double x, double y)
    { SWFShape_movePen(this->shape, x, y); }

  void movePenTo(double x, double y)
    { SWFShape_movePenTo(this->shape, x, y); }

  void drawLine(double x, double y)
    { SWFShape_drawLine(this->shape, x, y); }

  void drawLineTo(double x, double y)
    { SWFShape_drawLineTo(this->shape, x, y); }

  void drawCurve(double cx, double cy, double ax, double ay)
    { SWFShape_drawCurve(this->shape, cx, cy, ax, ay); }

  void drawCurveTo(double cx, double cy, double ax, double ay)
    { SWFShape_drawCurveTo(this->shape, cx, cy, ax, ay); }

  void drawCubic(double ax, double ay, double bx, double by, double cx, double cy)
    { SWFShape_drawCubic(this->shape, ax, ay, bx, by, cx, cy); }

  void drawCubicTo(double ax, double ay, double bx, double by, double cx, double cy)
    { SWFShape_drawCubicTo(this->shape, ax, ay, bx, by, cx, cy); }

  void getPen(double *x, double *y)
    { SWFShape_getPen(this->shape, x, y); }

  void end()
    { SWFShape_end(this->shape); }

  SWFFill *addSolidFill(byte r, byte g, byte b, byte a=0xff)
    { return new SWFFill(SWFShape_addSolidFill(this->shape, r, g, b, a)); }

  SWFFill *addGradientFill(SWFGradient *gradient, byte flags=0x10)
    { return new SWFFill(SWFShape_addGradientFill(this->shape, gradient->gradient, flags)); }

  SWFFill *addBitmapFill(SWFBitmap *bitmap, byte flags=0x40)
    { return new SWFFill(SWFShape_addBitmapFill(this->shape, bitmap ? bitmap->bitmap : 0, flags)); }

  void setLeftFillStyle(SWFFillStyle *fill)
    { SWFShape_setLeftFillStyle(this->shape, fill->fill); }

  void setRightFillStyle(SWFFillStyle *fill)
    { SWFShape_setRightFillStyle(this->shape, fill->fill); }

  void setLeftFill(SWFFill *fill)
    { SWFShape_setLeftFill(this->shape, fill->fill); }

  void setRightFill(SWFFill *fill)
    { SWFShape_setRightFill(this->shape, fill->fill); }

  void setLine(unsigned short width, byte r, byte g, byte b, byte a=0xff)
    { SWFShape_setLine(this->shape, width, r, g, b, a); }

  void drawCharacterBounds(SWFCharacter *character)
	{ SWFShape_drawCharacterBounds(this->shape, character->character); }

  void setLineStyle(unsigned short width, byte r, byte g, byte b, byte a=0xff) // alias for setline
	{ setLine(width, r, g, b, a); }

  void setLine2Filled(unsigned short width, SWFFillStyle *fill, int flags, float miterLimit)
    {  SWFShape_setLine2Filled(this->shape, width, fill->fill, flags, miterLimit); }
  
  void setLine2(unsigned short width, byte r, byte g, byte b, byte a, int flags, float miterLimit)
    {  SWFShape_setLine2(this->shape, width, r, g, b, a, flags, miterLimit); }

  void drawArc(double r, double startAngle, double endAngle)
    { SWFShape_drawArc(this->shape, r, startAngle, endAngle); }

  void drawCircle(double r)
    { SWFShape_drawCircle(this->shape, r); }

  void drawGlyph(SWFFont *font, unsigned short c, int size=0)
    { SWFShape_drawSizedGlyph(this->shape, font->font, c, size); }

  void useVersion(int version)
    { SWFShape_useVersion(this->shape, version); }

  int getVersion()
    { return SWFShape_getVersion(this->shape); }

  void setRenderingHintingFlags(int flags)
    { SWFShape_setRenderHintingFlags(this->shape, flags); }

  void hideLine()
    { SWFShape_hideLine(this->shape); }

  void drawFontGlyph(SWFFont *font, unsigned short c)
    { SWFShape_drawGlyph(this->shape, font->font, c); }

  char *dumpOutline()
  { return SWFShape_dumpOutline(this->shape); }

  SWF_DECLAREONLY(SWFShape);
};


/*  SWFMovieClip  */
class SWFMovieClip : public SWFCharacter
{
 public:
  c_SWFMovieClip clip;

  SWFMovieClip()
  { 
    this->clip = newSWFMovieClip();
    if(this->clip == NULL)
      throw SWFException("SWFMovieClip()");

    this->character = (c_SWFCharacter)clip;
  }

  virtual ~SWFMovieClip()
    { destroySWFMovieClip(this->clip); }

  c_SWFBlock getBlock()
    { return (c_SWFBlock)this->clip; }

  void setNumberOfFrames(int nFrames)
    { SWFMovieClip_setNumberOfFrames(this->clip, nFrames); }

  SWFDisplayItem *add(SWFBlock *character)
  {
    c_SWFDisplayItem item = SWFMovieClip_add(this->clip, character->getBlock());
    if(item == NULL)
      return NULL;
    else
      return new SWFDisplayItem(item); 
  }

  void remove(SWFDisplayItem *item)
    { SWFMovieClip_remove(this->clip, item->item); }

  void nextFrame()
    { SWFMovieClip_nextFrame(this->clip); }

  void labelFrame(char *label)
    { SWFMovieClip_labelFrame(this->clip, label); }

  void addInitAction(SWFAction* a)
    { SWFMovieClip_addInitAction(this->clip, a->action); }

  void setScalingGrid(int x, int y, int w, int h)
    { SWFMovieClip_setScalingGrid(this->clip, x, y, w, h); }

  void removeScalingGrid()
    { SWFMovieClip_removeScalingGrid(this->clip); }

   SWFSoundInstance *startSound(SWFSound *sound)
    { return new SWFSoundInstance(SWFMovieClip_startSound(this->clip, sound->sound)); }

  void stopSound(SWFSound *sound)
    { SWFMovieClip_stopSound(this->clip, sound->sound); }

  void setSoundStream(SWFSoundStream *sound, float rate, float skip=0.0)
  { SWFMovieClip_setSoundStreamAt(this->clip, sound->sound, rate, skip); }

  SWF_DECLAREONLY(SWFMovieClip);
};

/*  SWFSprite  */
/* deprecated ! */
class SWFSprite : public SWFMovieClip
{
  SWF_DECLAREONLY(SWFSprite);
};


/*  SWFMorph  */

class SWFMorph : public SWFCharacter
{
 public:
  c_SWFMorph morph;

  SWFMorph()
  { 
    this->morph = newSWFMorphShape();
    if(this->morph == NULL)
      throw SWFException("SWFMorph()");

    this->character = (c_SWFCharacter)morph;
  }

  virtual ~SWFMorph()
    { destroySWFMorph(this->morph); }

  c_SWFBlock getBlock()
    { return (c_SWFBlock)this->morph; }

  SWFShape *getShape1()
    { return new SWFShape(SWFMorph_getShape1(this->morph)); }

  SWFShape *getShape2()
    { return new SWFShape(SWFMorph_getShape2(this->morph)); }
  SWF_DECLAREONLY(SWFMorph);
};


/*  SWFText  */

class SWFText : public SWFCharacter
{
 public:
  c_SWFText text;

  SWFText(int version = 1)
  { 
      if(version == 2)
        this->text = newSWFText2();
      else 
        this->text = newSWFText();
      if(this->text == NULL)
        throw SWFException("SWFText()");
      this->character = (c_SWFCharacter)text;
  }

  virtual ~SWFText()
    { destroySWFText(this->text); }

  c_SWFBlock getBlock()
    { return (c_SWFBlock)this->text; }

  void setFont(SWFFont *font)
    { SWFText_setFont(this->text, font->font); }

  void setHeight(float height)
    { SWFText_setHeight(this->text, height); }

  // I don't like this..  it's too easy to confuse with displayitem::moveTo
  void moveTo(float x, float y)
    { SWFText_moveTo(this->text, x, y); }

  void setColor(byte r, byte g, byte b, byte a=0xff)
    { SWFText_setColor(this->text, r, g, b, a); }

  void addString(const char *string, int *advance=NULL)
    { SWFText_addString(this->text, string, advance); }

  void addUTF8String(const char *string, int *advance=NULL)
    { SWFText_addUTF8String(this->text, string, advance); }

  void addWideString(const unsigned short *string, int len, int *advance = NULL)
    { SWFText_addWideString(this->text, string, len, advance); }

  void setSpacing(float spacing)
    { SWFText_setSpacing(this->text, spacing); }

  float getStringWidth(const char *string)
    { return SWFText_getStringWidth(this->text, string); }

  float getWidth(const char *string)
    { return SWFText_getStringWidth(this->text, string); }

  float getWideStringWidth(const unsigned short *string)
    { return SWFText_getWideStringWidth(this->text, string); }

  float getUTF8Width(const char *string)
    { return SWFText_getUTF8StringWidth(this->text, string); }

  float getAscent()
    { return SWFText_getAscent(this->text); }

  float getDescent()
    { return SWFText_getDescent(this->text); }
  
  float getLeading()
    { return SWFText_getLeading(this->text); }
  SWF_DECLAREONLY(SWFText);
};

/*  SWFTextField  */

class SWFTextField : public SWFCharacter
{
 public:
  c_SWFTextField textField;

  SWFTextField()
  { 
    this->textField = newSWFTextField();
    if(this->textField == NULL)
      throw SWFException("SWFTextField()");
    this->character = (c_SWFCharacter)textField;
  }

  virtual ~SWFTextField()
    { destroySWFTextField(this->textField); }

  c_SWFBlock getBlock()
    { return (c_SWFBlock)this->textField; }

  void setFont(SWFBlock *font)
    { SWFTextField_setFont(this->textField, font->getBlock()); }

  void setBounds(float width, float height)
    { SWFTextField_setBounds(this->textField, width, height); }

  void setFlags(int flags)
    { SWFTextField_setFlags(this->textField, flags); }

  void setColor(byte r, byte g, byte b, byte a=0xff)
    { SWFTextField_setColor(this->textField, r, g, b, a); }

  void setVariableName(const char *name)
    { SWFTextField_setVariableName(this->textField, name); }

  void addString(const char *string)
    { SWFTextField_addString(this->textField, string); }

  void addUTF8String(const char *string)
    { SWFTextField_addUTF8String(this->textField, string); }

  void setHeight(float height)
    { SWFTextField_setHeight(this->textField, height); }

  void setLeftMargin(float margin)
    { SWFTextField_setLeftMargin(this->textField, margin); }

  void setRightMargin(float margin)
    { SWFTextField_setRightMargin(this->textField, margin); }

  void setIndentation(float indentation)
    { SWFTextField_setIndentation(this->textField, indentation); }

  void setPadding(float padding)
    { SWFTextField_setPadding(this->textField, padding); }

  void setLineSpacing(float lineSpacing)
    { SWFTextField_setLineSpacing(this->textField, lineSpacing); }

  void setAlignment(SWFTextFieldAlignment alignment)
    { SWFTextField_setAlignment(this->textField, alignment); }

  void align(SWFTextFieldAlignment alignment)
    { SWFTextField_setAlignment(this->textField, alignment); }

  void setFieldHeight(int height)
    { SWFTextField_setFieldHeight(this->textField, height); }

  void setLength(int length)
    { SWFTextField_setLength(this->textField, length); }

  void addChars(const char *string)
    { SWFTextField_addChars(this->textField, string); }

  SWF_DECLAREONLY(SWFTextField);
};

class SWFButtonRecord
{
 friend class SWFButton;
 public:
  c_SWFButtonRecord record;

  void addFilter(SWFFilter *f)
    { SWFButtonRecord_addFilter(this->record, f->filter); }

  void setDepth(int depth)
    { SWFButtonRecord_setDepth(this->record, depth); }

  void setBlendMode(int mode)
    { SWFButtonRecord_setBlendMode(this->record, mode); }

  void move(float x, float y)
    { SWFButtonRecord_move(this->record, x, y); }

  void moveTo(float x, float y)
    { SWFButtonRecord_moveTo(this->record, x, y); }

  void rotate(float deg)
    { SWFButtonRecord_rotate(this->record, deg); }

  void rotateTo(float deg)
    { SWFButtonRecord_rotateTo(this->record, deg); }

  void scale(float scaleX, float scaleY)
    { SWFButtonRecord_scale(this->record, scaleX, scaleY); }

  void scaleTo(float scaleX, float scaleY)
    { SWFButtonRecord_scaleTo(this->record, scaleX, scaleY); }

  void skewX(float skewX)
    { SWFButtonRecord_skewX(this->record, skewX); }

  void skewY(float skewY)
    { SWFButtonRecord_skewY(this->record, skewY); }

  void skewXTo(float skewX)
    { SWFButtonRecord_skewXTo(this->record, skewX); }

  void skewYTo(float skewY)
    { SWFButtonRecord_skewYTo(this->record, skewY); }

 private:
  SWFButtonRecord(c_SWFButtonRecord record)
  { 
    this->record = record; 
    if(this->record == NULL)
      throw SWFException("ButtonRecord");
  }
  SWF_DECLAREONLY(SWFButtonRecord);	
};

/*  SWFButton  */

class SWFButton : public SWFCharacter
{
 public:
  c_SWFButton button;

  SWFButton()
  { 
    this->button = newSWFButton();
    if(this->button == NULL)
      throw SWFException("SWFButton()");
    this->character = (c_SWFCharacter)button;
  }

  virtual ~SWFButton()
    { destroySWFButton(this->button); }

  c_SWFBlock getBlock()
    { return (c_SWFBlock)this->button; }

  SWFButtonRecord* addShape(SWFCharacter *character, byte flags)
    { return new SWFButtonRecord(SWFButton_addCharacter(this->button, (c_SWFCharacter)character->getBlock(), flags)); }

  void addAction(SWFAction *action, int flags)
    { SWFButton_addAction(this->button, action->action, flags); }

  void setMenu(int flag=0)
    { SWFButton_setMenu(this->button, flag); }

  void addSound(SWFSound *sound, int flags)
    { SWFButton_addSound(this->button, sound->sound, flags); }

  void setScalingGrid(int x, int y, int w, int h)
    { SWFButton_setScalingGrid(this->button, x, y, w, h); }

  void removeScalingGrid()
    { SWFButton_removeScalingGrid(this->button); }

  SWFButtonRecord* addCharacter(SWFCharacter *character, byte flags)
    { return new SWFButtonRecord(
        SWFButton_addCharacter(this->button, (c_SWFCharacter)character->getBlock(), flags)); }

  SWF_DECLAREONLY(SWFButton);
};

/* SWFBinaryData */
class SWFBinaryData : public SWFBlock
{
 public:
  c_SWFBinaryData data;

  SWFBinaryData(unsigned char *data, int length)
  {
    this->data = newSWFBinaryData(data, length);
    if(this->data == NULL)
      throw SWFException("SWFBinaryData(char *data, int length)");
  }

  virtual ~SWFBinaryData()
    { destroySWFBinaryData(this->data); }

  c_SWFBlock getBlock()
    { return (c_SWFBlock)this->data; }
  SWF_DECLAREONLY(SWFBinaryData);
};

/* SWFVideoStream */
class SWFVideoStream : public SWFCharacter
{
 public:
  c_SWFVideoStream stream;

  SWFVideoStream()
  { 
    this->stream = newSWFVideoStream();
    if(this->stream == NULL) 
      throw SWFException("newSWFVideoStream()");
    this->character = (c_SWFCharacter)stream;
  }

  SWFVideoStream(const char *path)
  { 
    this->stream = newSWFVideoStream_fromFile(fopen(path, "rb")); 
    if(this->stream == NULL)
      throw SWFException("SWFVideoStream(const char *path)");
  }

  SWFVideoStream(FILE *file)
  { 
    this->stream = newSWFVideoStream_fromFile(file); 
    if(this->stream == NULL)
      throw SWFException(" SWFVideoStream(FILE *file)");
  }

  virtual ~SWFVideoStream()
    { destroySWFVideoStream(this->stream); }

  void setDimension(int width, int height)
    { SWFVideoStream_setDimension(this->stream, width, height); }

  int getNumFrames()
    { return SWFVideoStream_getNumFrames(this->stream); }

  int hasAudio()
    { return SWFVideoStream_hasAudio(this->stream); }

  int setFrameMode(int mode)
    { return SWFVideoStream_setFrameMode(this->stream, mode); }

  int nextFrame()
    { return SWFVideoStream_nextFrame(this->stream); }

  int seek(int frame, int whence)
    { return SWFVideoStream_seek(this->stream, frame, whence); }

  c_SWFBlock getBlock()
    { return (c_SWFBlock)this->stream; }

  SWF_DECLAREONLY(SWFVideoStream);

};

#endif /* SWF_MINGPP_H_INCLUDED */