00001
00002
00003
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 #include <string.h>
00035
00036 #include "TGHtml.h"
00037 #include "TImage.h"
00038
00039
00040
00041 extern void HtmlTranslateEscapes(char *z);
00042 extern void ToLower(char *z);
00043
00044
00045
00046 TGHtmlElement::TGHtmlElement(int etype)
00047 {
00048
00049
00050 fPNext = fPPrev = 0;
00051 fStyle.fFont = 0;
00052 fStyle.fColor = 0;
00053 fStyle.fSubscript = 0;
00054 fStyle.fAlign = 0;
00055 fStyle.fBgcolor = 0;
00056 fStyle.fExpbg = 0;
00057 fStyle.fFlags = 0;
00058 fType = etype;
00059 fFlags = 0;
00060 fCount = 0;
00061 fElId = 0;
00062 fOffs = 0;
00063 }
00064
00065
00066 TGHtmlTextElement::TGHtmlTextElement(int size) : TGHtmlElement(Html_Text)
00067 {
00068
00069
00070 fZText = new char[size + 1];
00071 fX = 0; fY = 0; fW = 0;
00072 fAscent = 0;
00073 fDescent = 0;
00074 fSpaceWidth = 0;
00075 }
00076
00077
00078 TGHtmlTextElement::~TGHtmlTextElement()
00079 {
00080
00081
00082 delete[] fZText;
00083 }
00084
00085
00086 TGHtmlMarkupElement::TGHtmlMarkupElement(int type2, int argc, int arglen[],
00087 char *av[]) : TGHtmlElement(type2)
00088 {
00089
00090
00091 fCount = argc - 1;
00092
00093 if (argc > 1) {
00094 fArgv = new char*[argc+1];
00095 for (int i = 1; i < argc; i++) {
00096 if (arglen) {
00097 fArgv[i-1] = new char[arglen[i]+1];
00098
00099 strncpy(fArgv[i-1], av[i], arglen[i]);
00100 fArgv[i-1][arglen[i]] = 0;
00101 HtmlTranslateEscapes(fArgv[i-1]);
00102 if ((i & 1) == 1) ToLower(fArgv[i-1]);
00103 } else {
00104 fArgv[i-1] = StrDup(av[i]);
00105 HtmlTranslateEscapes(fArgv[i-1]);
00106 if ((i & 1) == 1) ToLower(fArgv[i-1]);
00107 }
00108 }
00109 fArgv[argc-1] = 0;
00110
00111
00112 fArgv[argc] = (char *) fArgv;
00113
00114 } else {
00115 fArgv = 0;
00116 }
00117 }
00118
00119
00120 TGHtmlMarkupElement::~TGHtmlMarkupElement()
00121 {
00122
00123
00124 if (fArgv) {
00125 for (int i = 0; i < fCount; ++i) delete [] fArgv[i];
00126 delete [] fArgv;
00127 }
00128 }
00129
00130
00131 const char *TGHtmlMarkupElement::MarkupArg(const char *tag, const char *zDefault)
00132 {
00133
00134
00135
00136
00137 int i;
00138
00139 for (i = 0; i < fCount; i += 2) {
00140 if (strcmp(fArgv[i], tag) == 0) return fArgv[i+1];
00141 }
00142 return zDefault;
00143 }
00144
00145
00146 int TGHtmlMarkupElement::GetAlignment(int dflt)
00147 {
00148
00149
00150
00151
00152 const char *z = MarkupArg("align", 0);
00153 int rc = dflt;
00154
00155 if (z) {
00156 if (strcasecmp(z, "left") == 0) {
00157 rc = ALIGN_Left;
00158 } else if (strcasecmp(z, "right") == 0) {
00159 rc = ALIGN_Right;
00160 } else if (strcasecmp(z, "center") == 0) {
00161 rc = ALIGN_Center;
00162 }
00163 }
00164
00165 return rc;
00166 }
00167
00168
00169 int TGHtmlMarkupElement::GetOrderedListType(int dflt)
00170 {
00171
00172
00173
00174
00175
00176 const char *z = MarkupArg("type", 0);
00177 if (z) {
00178 switch (*z) {
00179 case 'A': dflt = LI_TYPE_Enum_A; break;
00180 case 'a': dflt = LI_TYPE_Enum_a; break;
00181 case '1': dflt = LI_TYPE_Enum_1; break;
00182 case 'I': dflt = LI_TYPE_Enum_I; break;
00183 case 'i': dflt = LI_TYPE_Enum_i; break;
00184 default: break;
00185 }
00186 }
00187
00188 return dflt;
00189 }
00190
00191
00192 int TGHtmlMarkupElement::GetUnorderedListType(int dflt)
00193 {
00194
00195
00196
00197
00198 const char *z = MarkupArg("type", 0);
00199 if (z) {
00200 if (strcasecmp(z, "disc") == 0) {
00201 dflt = LI_TYPE_Bullet1;
00202 } else if (strcasecmp(z, "circle") == 0) {
00203 dflt = LI_TYPE_Bullet2;
00204 } else if (strcasecmp(z, "square") == 0) {
00205 dflt = LI_TYPE_Bullet3;
00206 }
00207 }
00208
00209 return dflt;
00210 }
00211
00212
00213
00214
00215 TGHtmlTable::TGHtmlTable(int type2, int argc, int arglen[], char *argv2[]) :
00216 TGHtmlMarkupElement(type2, argc, arglen, argv2)
00217 {
00218
00219
00220 fBorderWidth = 0;
00221 fNCol = 0;
00222 fNRow = 0;
00223 fX = 0; fY = 0; fW = 0; fH = 0;
00224 fPEnd = 0;
00225 fBgImage = 0;
00226 fHasbg = 0;
00227 for (int i=0;i<=HTML_MAX_COLUMNS;++i) {
00228 fMinW[i] = fMaxW[i] = 0;
00229 }
00230 }
00231
00232
00233 TGHtmlTable::~TGHtmlTable()
00234 {
00235
00236
00237 if (fBgImage) delete fBgImage;
00238 }
00239
00240
00241 TGHtmlCell::TGHtmlCell(int type2, int argc, int arglen[], char *argv2[]) :
00242 TGHtmlMarkupElement(type2, argc, arglen, argv2)
00243 {
00244
00245
00246 fRowspan = 0;
00247 fColspan = 0;
00248 fX = 0; fY = 0; fW = 0; fH = 0;
00249 fPTable = 0;
00250 fPRow = 0;
00251 fPEnd = 0;
00252 fBgImage = 0;
00253 }
00254
00255
00256 TGHtmlCell::~TGHtmlCell()
00257 {
00258
00259
00260 if (fBgImage) delete fBgImage;
00261 }
00262
00263
00264 TGHtmlRef::TGHtmlRef(int type2, int argc, int arglen[], char *argv2[]) :
00265 TGHtmlMarkupElement(type2, argc, arglen, argv2)
00266 {
00267
00268
00269 fPOther = 0;
00270 fBgImage = 0;
00271 }
00272
00273
00274 TGHtmlRef::~TGHtmlRef()
00275 {
00276
00277
00278 if (fBgImage) delete fBgImage;
00279 }
00280
00281
00282 TGHtmlLi::TGHtmlLi(int type2, int argc, int arglen[], char *argv2[]) :
00283 TGHtmlMarkupElement(type2, argc, arglen, argv2)
00284 {
00285
00286
00287 fLtype = 0;
00288 fAscent = 0;
00289 fDescent = 0;
00290 fCnt = 0;
00291 fX = 0; fY = 0;
00292 }
00293
00294
00295 TGHtmlListStart::TGHtmlListStart(int type2, int argc, int arglen[], char *argv2[]) :
00296 TGHtmlMarkupElement(type2, argc, arglen, argv2)
00297 {
00298
00299
00300 fLtype = 0;
00301 fCompact = 0;
00302 fCnt = 0;
00303 fWidth = 0;
00304 fLPrev = 0;
00305 }
00306
00307
00308 TGHtmlImageMarkup::TGHtmlImageMarkup(int type2, int argc,
00309 int arglen[], char *argv2[]) :
00310 TGHtmlMarkupElement(type2, argc, arglen, argv2)
00311 {
00312
00313
00314 fAlign = 0;
00315 fTextAscent = 0;
00316 fTextDescent = 0;
00317 fRedrawNeeded = 0;
00318 fX = 0; fY = 0; fW = 0; fH = 0;
00319 fAscent = 0;
00320 fDescent = 0;
00321 fZAlt = 0;
00322 fPImage = 0;
00323 fPMap = 0;
00324 fINext = 0;
00325 }
00326
00327
00328 TGHtmlForm::TGHtmlForm(int type2, int argc, int arglen[], char *argv2[]) :
00329 TGHtmlMarkupElement(type2, argc, arglen, argv2)
00330 {
00331
00332
00333 fFormId = 0;
00334 fElements = 0;
00335 fHasctl = 0;
00336 fPFirst = 0;
00337 fPEnd = 0;
00338 }
00339
00340
00341 TGHtmlHr::TGHtmlHr(int type2, int argc, int arglen[], char *argv2[]) :
00342 TGHtmlMarkupElement(type2, argc, arglen, argv2)
00343 {
00344
00345
00346 fX = 0; fY = 0; fW = 0; fH = 0;
00347 fIs3D = 0;
00348 }
00349
00350
00351 TGHtmlAnchor::TGHtmlAnchor(int type2, int argc, int arglen[], char *argv2[]) :
00352 TGHtmlMarkupElement(type2, argc, arglen, argv2)
00353 {
00354
00355
00356 fY = 0;
00357 }
00358
00359
00360 TGHtmlScript::TGHtmlScript(int type2, int argc, int arglen[], char *argv2[]) :
00361 TGHtmlMarkupElement(type2, argc, arglen, argv2)
00362 {
00363
00364
00365 fNStart = -1;
00366 fNScript = 0;
00367 }
00368
00369
00370 TGHtmlMapArea::TGHtmlMapArea(int type2, int argc, int arglen[], char *argv2[]) :
00371 TGHtmlMarkupElement(type2, argc, arglen, argv2)
00372 {
00373
00374
00375 fMType = 0;
00376 fCoords = 0;
00377 fNum = 0;
00378 }
00379
00380
00381
00382
00383 #if 0
00384 TGHtmlBlock::TGHtmlBlock()
00385 {
00386
00387 }
00388
00389 TGHtmlBlock::~TGHtmlBlock()
00390 {
00391
00392 }
00393 #endif
00394
00395
00396 TGHtmlInput::TGHtmlInput(int type2, int argc, int arglen[], char *argv2[]) :
00397 TGHtmlMarkupElement(type2, argc, arglen, argv2)
00398 {
00399
00400
00401 fPForm = 0;
00402 fINext = 0;
00403 fFrame = 0;
00404 fHtml = 0;
00405 fPEnd = 0;
00406 fInpId = 0; fSubId = 0;
00407 fX = 0; fY = 0; fW = 0; fH = 0;
00408 fPadLeft = 0;
00409 fAlign = 0;
00410 fTextAscent = 0;
00411 fTextDescent = 0;
00412 fItype = 0;
00413 fSized = 0;
00414 fCnt = 0;
00415 }
00416
00417
00418 void TGHtmlInput::Empty()
00419 {
00420
00421
00422
00423
00424
00425
00426 fFrame = NULL;
00427 fW = 0;
00428 fH = 0;
00429 fFlags &= ~HTML_Visible;
00430 fStyle.fFlags |= STY_Invisible;
00431 fSized = 1;
00432 }
00433