00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00020
00021
00022
00023 #include "swf.h"
00024
00025 #ifdef RCSID
00026 static char *rcsid = "$Id: character.cc,v 1.1.1.1 2002/01/25 22:14:58 kergoth Exp $";
00027 #endif
00028
00030
00031 Character::Character(ObjectType objectType, long tagid)
00032 {
00033 type = objectType;
00034 tagId = tagid;
00035 name = NULL;
00036 }
00037
00038 Character::~Character()
00039 {
00040 delete name;
00041 }
00042
00043 int
00044 Character::execute(GraphicDevice *gd, Matrix *matrix, Cxform *cxform)
00045 {
00046 printf("Cannot be executed\n");
00047 return 0;
00048 }
00049
00050 ActionRecord *
00051 Character::eventHandler(GraphicDevice *gd, FlashEvent *ev)
00052 {
00053 fprintf(stderr,"Unable to handle event !!!\n");
00054 return 0;
00055 }
00056
00057 int
00058 Character::isButton()
00059 {
00060 return 0;
00061 }
00062
00063 int
00064 Character::isSprite(void)
00065 {
00066 return 0;
00067 }
00068
00069 char *
00070 Character::getName()
00071 {
00072 return name;
00073 }
00074
00075 void
00076 Character::getBoundingBox(Rect *bb, DisplayListEntry *e)
00077 {
00078
00079 bb->xmin = LONG_MAX;
00080 bb->ymin = LONG_MAX;
00081 bb->ymax = LONG_MIN;
00082 bb->ymax = LONG_MIN;
00083 return;
00084 }
00085
00086 void
00087 Character::getRegion(GraphicDevice *gd, Matrix *matrix,
00088 void *id, ScanLineFunc scan_line_func)
00089 {
00090 fprintf(stderr,"Unable to handle getRegion !!!\n");
00091 return;
00092 }
00093
00094 long
00095 Character::getTagId()
00096 {
00097 return tagId;
00098 }
00099
00100 void
00101 Character::reset()
00102 {
00103 }
00104
00105 ObjectType
00106 Character::getType()
00107 {
00108 return type;
00109 }
00110
00111 char *
00112 Character::getTypeString()
00113 {
00114 switch (type) {
00115 case BitmapType:
00116 return "Bitmap";
00117 case FontType:
00118 return "Font";
00119 case ButtonType:
00120 return "Button";
00121 case SpriteType:
00122 return "Sprite";
00123 case ShapeType:
00124 return "Shape";
00125 case SoundType:
00126 return "Sound";
00127 case TextType:
00128 return "Text";
00129 default:
00130 return "Unknown";
00131 }
00132 }
00133
00134 void
00135 Character::setName(char* string)
00136 {
00137 name = strdup(string);
00138 }
00139
00141
00142 Dict::Dict()
00143 {
00144 head = 0;
00145 }
00146
00147 Dict::~Dict()
00148 {
00149 struct sCharCell *cell,*del;
00150
00151 for(cell = head; cell;)
00152 {
00153 del = cell;
00154 cell = cell->next;
00155 delete del->elt;
00156 delete del;
00157 }
00158 }
00159
00160 void
00161 Dict::addCharacter(Character *character)
00162 {
00163 struct sCharCell *cell;
00164
00165 cell = new sCharCell;
00166 if (cell == NULL) {
00167 delete character;
00168 return;
00169 }
00170 cell->elt = character;
00171 cell->next = head;
00172
00173 head = cell;
00174 }
00175
00176 Character *
00177 Dict::getCharacter(long id)
00178 {
00179 struct sCharCell *cell;
00180
00181 for(cell = head; cell; cell = cell->next)
00182 {
00183 if (id == cell->elt->getTagId()) return cell->elt;
00184 }
00185 return 0;
00186 }
00187
00188 void
00189 Dict::dictRewind()
00190 {
00191 currentCell = head;
00192 }
00193
00194 Character *
00195 Dict::dictNextCharacter()
00196 {
00197 if (currentCell) {
00198 struct sCharCell *cell;
00199
00200 cell = currentCell;
00201 currentCell = currentCell->next;
00202 return cell->elt;
00203 } else {
00204 return 0;
00205 }
00206 }
00207
00208 void
00209 Dict::nameCharacter(long id, char *string)
00210 {
00211 struct sCharCell *cell;
00212
00213 for(cell = head; cell; cell = cell->next)
00214 {
00215 if (cell->elt->getTagId() == id) {
00216 cell->elt->setName(string);
00217 break;
00218 }
00219 }
00220 }
00221
00222 #ifdef DUMP
00223 void
00224 Dict::dictSetUnsaved()
00225 {
00226 struct sCharCell *cell;
00227
00228 for(cell = head; cell; cell = cell->next)
00229 {
00230 cell->elt->saved = 0;
00231 }
00232 }
00233 #endif