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 #ifndef ROOT_TGHtml
00035 #define ROOT_TGHtml
00036
00037 #ifndef ROOT_TGView
00038 #include "TGView.h"
00039 #endif
00040
00041 #ifndef ROOT_TGHtmlTokens
00042 #include "TGHtmlTokens.h"
00043 #endif
00044
00045 class TGClient;
00046 class TImage;
00047 class TGFont;
00048 class TGIdleHandler;
00049 class THashTable;
00050 class TTimer;
00051
00052
00053
00054 #define HTML_RELIEF_FLAT 0
00055 #define HTML_RELIEF_SUNKEN 1
00056 #define HTML_RELIEF_RAISED 2
00057
00058
00059
00060
00061
00062
00063 #define DEBUG
00064
00065 #define CANT_HAPPEN \
00066 fprintf(stderr, \
00067 "Unplanned behavior in the HTML Widget in file %s line %d\n", \
00068 __FILE__, __LINE__)
00069
00070 #define UNTESTED \
00071 fprintf(stderr, \
00072 "Untested code executed in the HTML Widget in file %s line %d\n", \
00073 __FILE__, __LINE__)
00074
00075
00076
00077
00078 #ifdef DEBUG
00079 #define HtmlAssert(X) \
00080 if(!(X)){ \
00081 fprintf(stderr,"Assertion failed on line %d of %s\n",__LINE__,__FILE__); \
00082 }
00083 #define HtmlCantHappen \
00084 fprintf(stderr,"Can't happen on line %d of %s\n",__LINE__,__FILE__);
00085 #else
00086 #define HtmlAssert(X)
00087 #define HtmlCantHappen
00088 #endif
00089
00090
00091
00092 #define HtmlTrace_Table1 0x00000001
00093 #define HtmlTrace_Table2 0x00000002
00094 #define HtmlTrace_Table3 0x00000004
00095 #define HtmlTrace_Table4 0x00000008
00096 #define HtmlTrace_Table5 0x00000010
00097 #define HtmlTrace_Table6 0x00000020
00098 #define HtmlTrace_GetLine 0x00000100
00099 #define HtmlTrace_GetLine2 0x00000200
00100 #define HtmlTrace_FixLine 0x00000400
00101 #define HtmlTrace_BreakMarkup 0x00001000
00102 #define HtmlTrace_Style 0x00002000
00103 #define HtmlTrace_Input1 0x00004000
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115 #ifdef DEBUG
00116 extern int HtmlTraceMask;
00117 extern int HtmlDepth;
00118 # define TRACE_INDENT printf("%*s",HtmlDepth-3,"")
00119 # define TRACE(Flag, Args) \
00120 if( (Flag)&HtmlTraceMask ){ \
00121 TRACE_INDENT; printf Args; fflush(stdout); \
00122 }
00123 # define TRACE_PUSH(Flag) if( (Flag)&HtmlTraceMask ){ HtmlDepth+=3; }
00124 # define TRACE_POP(Flag) if( (Flag)&HtmlTraceMask ){ HtmlDepth-=3; }
00125 #else
00126 # define TRACE_INDENT
00127 # define TRACE(Flag, Args)
00128 # define TRACE_PUSH(Flag)
00129 # define TRACE_POP(Flag)
00130 #endif
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142 typedef unsigned char Html_u8_t;
00143 typedef short Html_16_t;
00144 typedef unsigned short Html_u16_t;
00145 typedef int Html_32_t;
00146
00147
00148
00149
00150 struct SHtmlStyle_t {
00151 unsigned int fFont : 6;
00152 unsigned int fColor : 6;
00153 signed int fSubscript : 4;
00154 unsigned int fAlign : 2;
00155 unsigned int fBgcolor : 6;
00156 unsigned int fExpbg : 1;
00157 unsigned int fFlags : 7;
00158 };
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170 #define N_FONT_FAMILY 8
00171 #define N_FONT_SIZE 7
00172 #define N_FONT 71
00173 #define NormalFont(X) (X)
00174 #define BoldFont(X) ((X) | 8)
00175 #define ItalicFont(X) ((X) | 16)
00176 #define CWFont(X) ((X) | 32)
00177 #define FontSize(X) ((X) & 007)
00178 #define FontFamily(X) ((X) & 070)
00179 #define FONT_Any -1
00180 #define FONT_Default 3
00181 #define FontSwitch(Size, Bold, Italic, Cw) \
00182 ((Size) | ((Bold+(Italic)*2+(Cw)*4) << 3))
00183
00184
00185
00186 #define FontIsValid(I) ((fFontValid[(I)>>3] & (1<<((I)&3)))!=0)
00187 #define FontSetValid(I) (fFontValid[(I)>>3] |= (1<<((I)&3)))
00188 #define FontClearValid(I) (fFontValid[(I)>>3] &= ~(1<<((I)&3)))
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201 #define N_COLOR 32 // Total number of colors
00202
00203 #define COLOR_Normal 0 // Index for normal color (black)
00204 #define COLOR_Unvisited 1 // Index for unvisited hyperlinks
00205 #define COLOR_Visited 2 // Color for visited hyperlinks
00206 #define COLOR_Selection 3 // Background color for the selection
00207 #define COLOR_Background 4 // Default background color
00208 #define N_PREDEFINED_COLOR 5 // Number of predefined colors
00209
00210
00211
00212
00213
00214
00215 #define ALIGN_Left 1
00216 #define ALIGN_Right 2
00217 #define ALIGN_Center 3
00218 #define ALIGN_None 0
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240 #define STY_Preformatted 0x001
00241 #define STY_StrikeThru 0x002
00242 #define STY_Underline 0x004
00243 #define STY_NoBreak 0x008
00244 #define STY_Anchor 0x010
00245 #define STY_DT 0x020
00246 #define STY_Invisible 0x040
00247 #define STY_FontMask (STY_StrikeThru|STY_Underline)
00248
00249
00250
00251
00252
00253
00254
00255
00256 class TGHtmlElement : public TObject {
00257 public:
00258 TGHtmlElement(int etype = 0);
00259
00260 virtual int IsMarkup() const { return (fType > Html_Block); }
00261 virtual const char *MarkupArg(const char * , const char * ) { return 0; }
00262 virtual int GetAlignment(int dflt) { return dflt; }
00263 virtual int GetOrderedListType(int dflt) { return dflt; }
00264 virtual int GetUnorderedListType(int dflt) { return dflt; }
00265 virtual int GetVerticalAlignment(int dflt) { return dflt; }
00266
00267 public:
00268 TGHtmlElement *fPNext;
00269 TGHtmlElement *fPPrev;
00270 SHtmlStyle_t fStyle;
00271 Html_u8_t fType;
00272 Html_u8_t fFlags;
00273 Html_16_t fCount;
00274 int fElId;
00275 int fOffs;
00276 };
00277
00278
00279
00280
00281 #define HTML_Visible 0x01 // This element produces "ink"
00282 #define HTML_NewLine 0x02 // type == Html_Space and ends with newline
00283 #define HTML_Selected 0x04 // Some or all of this Html_Block is selected
00284
00285
00286
00287
00288
00289
00290
00291
00292 class TGHtmlTextElement : public TGHtmlElement {
00293 public:
00294 TGHtmlTextElement(int size);
00295 virtual ~TGHtmlTextElement();
00296
00297 Html_32_t fY;
00298 Html_16_t fX;
00299 Html_16_t fW;
00300 Html_u8_t fAscent;
00301 Html_u8_t fDescent;
00302 Html_u8_t fSpaceWidth;
00303 char *fZText;
00304 };
00305
00306
00307
00308
00309 class TGHtmlSpaceElement : public TGHtmlElement {
00310 public:
00311 Html_16_t fW;
00312 Html_u8_t fAscent;
00313 Html_u8_t fDescent;
00314
00315 public:
00316 TGHtmlSpaceElement() : TGHtmlElement(Html_Space), fW(0), fAscent(0), fDescent(0) {}
00317 };
00318
00319
00320
00321
00322
00323
00324
00325
00326 class TGHtmlMarkupElement : public TGHtmlElement {
00327 public:
00328 TGHtmlMarkupElement(int type, int argc, int arglen[], char *argv[]);
00329 virtual ~TGHtmlMarkupElement();
00330
00331 virtual const char *MarkupArg(const char *tag, const char *zDefault);
00332 virtual int GetAlignment(int dflt);
00333 virtual int GetOrderedListType(int dflt);
00334 virtual int GetUnorderedListType(int dflt);
00335 virtual int GetVerticalAlignment(int dflt);
00336
00337 public:
00338 char **fArgv;
00339 };
00340
00341
00342
00343
00344
00345 #define HTML_MAX_COLUMNS 40
00346
00347
00348
00349
00350
00351
00352
00353
00354
00355
00356 class TGHtmlTable : public TGHtmlMarkupElement {
00357 public:
00358 TGHtmlTable(int type, int argc, int arglen[], char *argv[]);
00359 ~TGHtmlTable();
00360
00361 public:
00362 Html_u8_t fBorderWidth;
00363 Html_u8_t fNCol;
00364 Html_u16_t fNRow;
00365 Html_32_t fY;
00366 Html_32_t fH;
00367 Html_16_t fX;
00368 Html_16_t fW;
00369 int fMinW[HTML_MAX_COLUMNS+1];
00370 int fMaxW[HTML_MAX_COLUMNS+1];
00371 TGHtmlElement *fPEnd;
00372 TImage *fBgImage;
00373 int fHasbg;
00374 };
00375
00376
00377
00378
00379
00380
00381
00382
00383 class TGHtmlCell : public TGHtmlMarkupElement {
00384 public:
00385 TGHtmlCell(int type, int argc, int arglen[], char *argv[]);
00386 ~TGHtmlCell();
00387
00388 public:
00389 Html_16_t fRowspan;
00390 Html_16_t fColspan;
00391 Html_16_t fX;
00392 Html_16_t fW;
00393 Html_32_t fY;
00394 Html_32_t fH;
00395 TGHtmlTable *fPTable;
00396 TGHtmlElement *fPRow;
00397 TGHtmlElement *fPEnd;
00398 TImage *fBgImage;
00399 };
00400
00401
00402
00403
00404
00405
00406
00407 class TGHtmlRef : public TGHtmlMarkupElement {
00408 public:
00409 TGHtmlRef(int type, int argc, int arglen[], char *argv[]);
00410 ~TGHtmlRef();
00411
00412 public:
00413 TGHtmlElement *fPOther;
00414 TImage *fBgImage;
00415 };
00416
00417
00418
00419
00420
00421 class TGHtmlLi : public TGHtmlMarkupElement {
00422 public:
00423 TGHtmlLi(int type, int argc, int arglen[], char *argv[]);
00424
00425 public:
00426 Html_u8_t fLtype;
00427 Html_u8_t fAscent;
00428 Html_u8_t fDescent;
00429 Html_16_t fCnt;
00430 Html_16_t fX;
00431 Html_32_t fY;
00432 };
00433
00434
00435
00436
00437
00438
00439
00440 #define LI_TYPE_Undefined 0 // If in TGHtmlLi, use the TGHtmlListStart value
00441 #define LI_TYPE_Bullet1 1 // A solid circle
00442 #define LI_TYPE_Bullet2 2 // A hollow circle
00443 #define LI_TYPE_Bullet3 3 // A hollow square
00444 #define LI_TYPE_Enum_1 4 // Arabic numbers
00445 #define LI_TYPE_Enum_A 5 // A, B, C, ...
00446 #define LI_TYPE_Enum_a 6 // a, b, c, ...
00447 #define LI_TYPE_Enum_I 7 // Capitalized roman numerals
00448 #define LI_TYPE_Enum_i 8 // Lower-case roman numerals
00449
00450
00451
00452
00453 class TGHtmlListStart : public TGHtmlMarkupElement {
00454 public:
00455 TGHtmlListStart(int type, int argc, int arglen[], char *argv[]);
00456
00457 public:
00458 Html_u8_t fLtype;
00459 Html_u8_t fCompact;
00460 Html_u16_t fCnt;
00461 Html_u16_t fWidth;
00462 TGHtmlListStart *fLPrev;
00463 };
00464
00465
00466 #define HTML_MAP_RECT 1
00467 #define HTML_MAP_CIRCLE 2
00468 #define HTML_MAP_POLY 3
00469
00470 class TGHtmlMapArea : public TGHtmlMarkupElement {
00471 public:
00472 TGHtmlMapArea(int type, int argc, int arglen[], char *argv[]);
00473
00474 public:
00475 int fMType;
00476 int *fCoords;
00477 int fNum;
00478 };
00479
00480
00481
00482
00483
00484
00485 struct SHtmlExtensions_t {
00486 void *fExts;
00487 int fTyp;
00488 int fFlags;
00489 SHtmlExtensions_t *fNext;
00490 };
00491
00492
00493
00494
00495
00496
00497
00498
00499
00500
00501
00502
00503
00504
00505
00506 class TGHtml;
00507 class TGHtmlImageMarkup;
00508
00509 class TGHtmlImage : public TObject {
00510 public:
00511 TGHtmlImage(TGHtml *htm, const char *url, const char *width,
00512 const char *height);
00513 virtual ~TGHtmlImage();
00514
00515 public:
00516 TGHtml *fHtml;
00517 TImage *fImage;
00518 Html_32_t fW;
00519 Html_32_t fH;
00520 char *fZUrl;
00521 char *fZWidth, *fZHeight;
00522 TGHtmlImage *fPNext;
00523 TGHtmlImageMarkup *fPList;
00524
00525 TTimer *fTimer;
00526 };
00527
00528
00529
00530
00531
00532
00533 class TGHtmlImageMarkup : public TGHtmlMarkupElement {
00534 public:
00535 TGHtmlImageMarkup(int type, int argc, int arglen[], char *argv[]);
00536
00537 public:
00538 Html_u8_t fAlign;
00539 Html_u8_t fTextAscent;
00540 Html_u8_t fTextDescent;
00541 Html_u8_t fRedrawNeeded;
00542
00543 Html_16_t fH;
00544 Html_16_t fW;
00545 Html_16_t fAscent;
00546 Html_16_t fDescent;
00547 Html_16_t fX;
00548 Html_32_t fY;
00549 const char *fZAlt;
00550 TGHtmlImage *fPImage;
00551 TGHtmlElement *fPMap;
00552 TGHtmlImageMarkup *fINext;
00553 };
00554
00555
00556
00557
00558
00559 #define IMAGE_ALIGN_Bottom 0
00560 #define IMAGE_ALIGN_Middle 1
00561 #define IMAGE_ALIGN_Top 2
00562 #define IMAGE_ALIGN_TextTop 3
00563 #define IMAGE_ALIGN_AbsMiddle 4
00564 #define IMAGE_ALIGN_AbsBottom 5
00565 #define IMAGE_ALIGN_Left 6
00566 #define IMAGE_ALIGN_Right 7
00567
00568
00569
00570
00571
00572
00573
00574
00575
00576
00577
00578 class TGHtmlForm;
00579
00580 class TGHtmlInput : public TGHtmlMarkupElement {
00581 public:
00582 TGHtmlInput(int type, int argc, int arglen[], char *argv[]);
00583
00584 void Empty();
00585
00586 public:
00587 TGHtmlForm *fPForm;
00588 TGHtmlInput *fINext;
00589 TGFrame *fFrame;
00590 TGHtml *fHtml;
00591 TGHtmlElement *fPEnd;
00592 Html_u16_t fInpId;
00593 Html_u16_t fSubId;
00594 Html_32_t fY;
00595 Html_u16_t fX;
00596 Html_u16_t fW, fH;
00597 Html_u8_t fPadLeft;
00598 Html_u8_t fAlign;
00599 Html_u8_t fTextAscent;
00600 Html_u8_t fTextDescent;
00601 Html_u8_t fItype;
00602 Html_u8_t fSized;
00603 Html_u16_t fCnt;
00604 };
00605
00606
00607
00608
00609
00610
00611 #define INPUT_TYPE_Unknown 0
00612 #define INPUT_TYPE_Checkbox 1
00613 #define INPUT_TYPE_File 2
00614 #define INPUT_TYPE_Hidden 3
00615 #define INPUT_TYPE_Image 4
00616 #define INPUT_TYPE_Password 5
00617 #define INPUT_TYPE_Radio 6
00618 #define INPUT_TYPE_Reset 7
00619 #define INPUT_TYPE_Select 8
00620 #define INPUT_TYPE_Submit 9
00621 #define INPUT_TYPE_Text 10
00622 #define INPUT_TYPE_TextArea 11
00623 #define INPUT_TYPE_Applet 12
00624 #define INPUT_TYPE_Button 13
00625
00626
00627
00628
00629
00630
00631
00632 class TGHtmlForm : public TGHtmlMarkupElement {
00633 public:
00634 TGHtmlForm(int type, int argc, int arglen[], char *argv[]);
00635
00636 public:
00637 Html_u16_t fFormId;
00638 unsigned int fElements;
00639 unsigned int fHasctl;
00640 TGHtmlElement *fPFirst;
00641 TGHtmlElement *fPEnd;
00642 };
00643
00644
00645
00646
00647 class TGHtmlHr : public TGHtmlMarkupElement {
00648 public:
00649 TGHtmlHr(int type, int argc, int arglen[], char *argv[]);
00650
00651 public:
00652 Html_32_t fY;
00653 Html_u16_t fX;
00654 Html_u16_t fW, fH;
00655 Html_u8_t fIs3D;
00656 };
00657
00658
00659
00660
00661 class TGHtmlAnchor : public TGHtmlMarkupElement {
00662 public:
00663 TGHtmlAnchor(int type, int argc, int arglen[], char *argv[]);
00664
00665 public:
00666 Html_32_t fY;
00667 };
00668
00669
00670
00671
00672
00673
00674
00675
00676
00677 class TGHtmlScript : public TGHtmlMarkupElement {
00678 public:
00679 TGHtmlScript(int type, int argc, int arglen[], char *argv[]);
00680
00681 public:
00682 int fNStart;
00683 int fNScript;
00684
00685 };
00686
00687
00688
00689
00690
00691
00692
00693
00694
00695
00696
00697
00698
00699
00700
00701
00702
00703
00704
00705
00706
00707
00708
00709 class TGHtmlBlock : public TGHtmlElement {
00710 public:
00711 TGHtmlBlock();
00712 virtual ~TGHtmlBlock();
00713
00714 public:
00715 char *fZ;
00716 int fTop, fBottom;
00717 Html_u16_t fLeft, fRight;
00718 Html_u16_t fN;
00719 TGHtmlBlock *fBPrev, *fBNext;
00720 };
00721
00722
00723
00724
00725
00726
00727
00728
00729
00730
00731 struct SHtmlStyleStack_t {
00732 SHtmlStyleStack_t *fPNext;
00733 int fType;
00734 SHtmlStyle_t fStyle;
00735 };
00736
00737
00738
00739
00740
00741 struct SHtmlMargin_t {
00742 int fIndent;
00743 int fBottom;
00744 int fTag;
00745 SHtmlMargin_t *fPNext;
00746 };
00747
00748
00749
00750
00751
00752 #define HTML_INDENT 36
00753
00754
00755
00756
00757
00758
00759 class TGHtmlLayoutContext : public TObject {
00760 public:
00761 TGHtmlLayoutContext();
00762
00763 void LayoutBlock();
00764 void Reset();
00765
00766 void PopIndent();
00767 void PushIndent();
00768
00769 protected:
00770 void PushMargin(SHtmlMargin_t **ppMargin, int indent, int bottom, int tag);
00771 void PopOneMargin(SHtmlMargin_t **ppMargin);
00772 void PopMargin(SHtmlMargin_t **ppMargin, int tag);
00773 void PopExpiredMargins(SHtmlMargin_t **ppMarginStack, int y);
00774 void ClearMarginStack(SHtmlMargin_t **ppMargin);
00775
00776 TGHtmlElement *GetLine(TGHtmlElement *pStart, TGHtmlElement *pEnd,
00777 int width, int minX, int *actualWidth);
00778
00779 void FixAnchors(TGHtmlElement *p, TGHtmlElement *pEnd, int y);
00780 int FixLine(TGHtmlElement *pStart, TGHtmlElement *pEnd,
00781 int bottom, int width, int actualWidth, int leftMargin,
00782 int *maxX);
00783 void Paragraph(TGHtmlElement *p);
00784 void ComputeMargins(int *pX, int *pY, int *pW);
00785 void ClearObstacle(int mode);
00786 TGHtmlElement *DoBreakMarkup(TGHtmlElement *p);
00787 int InWrapAround();
00788 void WidenLine(int reqWidth, int *pX, int *pY, int *pW);
00789
00790 TGHtmlElement *TableLayout(TGHtmlTable *p);
00791
00792 public:
00793 TGHtml *fHtml;
00794 TGHtmlElement *fPStart;
00795 TGHtmlElement *fPEnd;
00796 int fHeadRoom;
00797 int fTop;
00798 int fBottom;
00799 int fLeft, fRight;
00800 int fPageWidth;
00801
00802 int fMaxX, fMaxY;
00803 SHtmlMargin_t *fLeftMargin;
00804 SHtmlMargin_t *fRightMargin;
00805 };
00806
00807
00808
00809
00810
00811
00812
00813
00814
00815
00816
00817 #define N_CACHE_GC 32
00818
00819 struct GcCache_t {
00820 GContext_t fGc;
00821 Html_u8_t fFont;
00822 Html_u8_t fColor;
00823 Html_u8_t fIndex;
00824 };
00825
00826
00827
00828
00829
00830 struct SHtmlIndex_t {
00831 TGHtmlElement *fP;
00832 int fI;
00833 };
00834
00835
00836
00837
00838 struct SHtmlTokenMap_t {
00839 const char *fZName;
00840 Html_16_t fType;
00841 Html_16_t fObjType;
00842 SHtmlTokenMap_t *fPCollide;
00843 };
00844
00845
00846
00847
00848
00849 #define O_HtmlMarkupElement 0
00850 #define O_HtmlCell 1
00851 #define O_HtmlTable 2
00852 #define O_HtmlRef 3
00853 #define O_HtmlLi 4
00854 #define O_HtmlListStart 5
00855 #define O_HtmlImageMarkup 6
00856 #define O_HtmlInput 7
00857 #define O_HtmlForm 8
00858 #define O_HtmlHr 9
00859 #define O_HtmlAnchor 10
00860 #define O_HtmlScript 11
00861 #define O_HtmlMapArea 12
00862
00863
00864
00865
00866
00867
00868 class TGListBox;
00869 class THashTable;
00870
00871 class TGHtml : public TGView {
00872 public:
00873 TGHtml(const TGWindow *p, int w, int h, int id = -1);
00874 virtual ~TGHtml();
00875
00876 virtual Bool_t HandleFocusChange(Event_t *event);
00877 virtual Bool_t HandleButton(Event_t *event);
00878 virtual Bool_t HandleMotion(Event_t *event);
00879
00880 virtual Bool_t HandleIdleEvent(TGIdleHandler *i);
00881 virtual Bool_t HandleTimer(TTimer *timer);
00882
00883 virtual Bool_t ProcessMessage(Long_t, Long_t, Long_t);
00884
00885 virtual void DrawRegion(Int_t x, Int_t y, UInt_t w, UInt_t h);
00886 virtual Bool_t ItemLayout();
00887
00888 Bool_t HandleHtmlInput(TGHtmlInput *pr, Event_t *event);
00889 Bool_t HandleRadioButton(TGHtmlInput *p);
00890
00891 public:
00892
00893 int ParseText(char *text, const char *index = 0);
00894
00895 void SetTableRelief(int relief);
00896 int GetTableRelief() const { return fTableRelief; }
00897
00898 void SetRuleRelief(int relief);
00899 int GetRuleRelief() const { return fRuleRelief; }
00900 int GetRulePadding() const { return fRulePadding; }
00901
00902 void UnderlineLinks(int onoff);
00903
00904 void SetBaseUri(const char *uri);
00905 const char *GetBaseUri() const { return fZBase; }
00906
00907 int GotoAnchor(const char *name);
00908
00909 public:
00910
00911
00912 virtual void Clear(Option_t * = "");
00913
00914
00915 virtual char *ResolveUri(const char *uri);
00916
00917
00918 virtual TImage *LoadImage(const char *uri, int w = 0, int h = 0) ;
00919
00920
00921
00922 virtual int IsVisited(const char * )
00923 { return kFALSE; }
00924
00925
00926 virtual int ProcessToken(TGHtmlElement * , const char * , int )
00927 { return kFALSE; }
00928
00929 virtual TGFont *GetFont(int iFont);
00930
00931
00932
00933
00934
00935
00936 virtual int ProcessFrame()
00937 { return kFALSE; }
00938
00939
00940 virtual TGFrame *ProcessApplet(TGHtmlInput * )
00941 { return 0; }
00942
00943
00944 virtual int FormCreate(TGHtmlForm * , const char * , const char * )
00945 { return kFALSE; }
00946
00947
00948 virtual int FormAction(TGHtmlForm * , int )
00949 { return kFALSE; }
00950
00951
00952 virtual char *GetFontName()
00953 { return 0; }
00954
00955
00956 virtual char *ProcessScript(TGHtmlScript * )
00957 { return 0; }
00958
00959 public:
00960 const char *GetText() const { return fZText; }
00961
00962 int GetMarginWidth() { return fMargins.fL + fMargins.fR; }
00963 int GetMarginHeight() { return fMargins.fT + fMargins.fB; }
00964
00965 TGHtmlInput *GetInputElement(int x, int y);
00966 const char *GetHref(int x, int y, const char **target = 0);
00967
00968 TGHtmlImage *GetImage(TGHtmlImageMarkup *p);
00969
00970 int InArea(TGHtmlMapArea *p, int left, int top, int x, int y);
00971 TGHtmlElement *GetMap(const char *name);
00972
00973 void ResetBlocks() { fFirstBlock = fLastBlock = 0; }
00974 int ElementCoords(TGHtmlElement *p, int i, int pct, int *coords);
00975
00976 TGHtmlElement *TableDimensions(TGHtmlTable *pStart, int lineWidth);
00977 int CellSpacing(TGHtmlElement *pTable);
00978 void MoveVertically(TGHtmlElement *p, TGHtmlElement *pLast, int dy);
00979
00980 void PrintList(TGHtmlElement *first, TGHtmlElement *last);
00981
00982 char *GetTokenName(TGHtmlElement *p);
00983 char *DumpToken(TGHtmlElement *p);
00984
00985 void EncodeText(TGString *str, const char *z);
00986
00987 protected:
00988 void HClear();
00989 void ClearGcCache();
00990 void ResetLayoutContext();
00991 void Redraw();
00992 void ComputeVirtualSize();
00993
00994 void ScheduleRedraw();
00995
00996 void RedrawArea(int left, int top, int right, int bottom);
00997 void RedrawBlock(TGHtmlBlock *p);
00998 void RedrawEverything();
00999 void RedrawText(int y);
01000
01001 float ColorDistance(ColorStruct_t *pA, ColorStruct_t *pB);
01002 int IsDarkColor(ColorStruct_t *p);
01003 int IsLightColor(ColorStruct_t *p);
01004 int GetColorByName(const char *zColor);
01005 int GetDarkShadowColor(int iBgColor);
01006 int GetLightShadowColor(int iBgColor);
01007 int GetColorByValue(ColorStruct_t *pRef);
01008
01009 void FlashCursor();
01010
01011 GContext_t GetGC(int color, int font);
01012 GContext_t GetAnyGC();
01013
01014 void AnimateImage(TGHtmlImage *image);
01015 void ImageChanged(TGHtmlImage *image, int newWidth, int newHeight);
01016 int GetImageAlignment(TGHtmlElement *p);
01017 int GetImageAt(int x, int y);
01018 const char *GetPctWidth(TGHtmlElement *p, char *opt, char *ret);
01019 void TableBgndImage(TGHtmlElement *p);
01020
01021 TGHtmlElement *FillOutBlock(TGHtmlBlock *p);
01022 void UnlinkAndFreeBlock(TGHtmlBlock *pBlock);
01023 void AppendBlock(TGHtmlElement *pToken, TGHtmlBlock *pBlock);
01024
01025 void StringHW(const char *str, int *h, int *w);
01026 TGHtmlElement *MinMax(TGHtmlElement *p, int *pMin, int *pMax,
01027 int lineWidth, int hasbg);
01028
01029 void DrawSelectionBackground(TGHtmlBlock *pBlock, Drawable_t Drawable_t,
01030 int x, int y);
01031 void DrawRect(Drawable_t drawable, TGHtmlElement *src,
01032 int x, int y, int w, int h, int depth, int relief);
01033 void BlockDraw(TGHtmlBlock *pBlock, Drawable_t wid,
01034 int left, int top,
01035 int width, int height, Pixmap_t pixmap);
01036 void DrawImage(TGHtmlImageMarkup *image, Drawable_t wid,
01037 int left, int top,
01038 int right, int bottom);
01039 void DrawTableBgnd(int x, int y, int w, int h, Drawable_t d, TImage *image);
01040
01041 TGHtmlElement *FindStartOfNextBlock(TGHtmlElement *p, int *pCnt);
01042 void FormBlocks();
01043
01044 void AppendElement(TGHtmlElement *pElem);
01045 int Tokenize();
01046 void AppToken(TGHtmlElement *pNew, TGHtmlElement *p, int offs);
01047 TGHtmlMarkupElement *MakeMarkupEntry(int objType, int type, int argc,
01048 int arglen[], char *argv[]);
01049 void TokenizerAppend(const char *text);
01050 TGHtmlElement *InsertToken(TGHtmlElement *pToken,
01051 char *zType, char *zArgs, int offs);
01052 SHtmlTokenMap_t *NameToPmap(char *zType);
01053 int NameToType(char *zType);
01054 const char *TypeToName(int type);
01055 int TextInsertCmd(int argc, char **argv);
01056 SHtmlTokenMap_t* GetMarkupMap(int n);
01057
01058 TGHtmlElement *TokenByIndex(int N, int flag);
01059 int TokenNumber(TGHtmlElement *p);
01060
01061 void MaxIndex(TGHtmlElement *p, int *pIndex, int isLast);
01062 int IndexMod(TGHtmlElement **pp, int *ip, char *cp);
01063 void FindIndexInBlock(TGHtmlBlock *pBlock, int x,
01064 TGHtmlElement **ppToken, int *pIndex);
01065 void IndexToBlockIndex(SHtmlIndex_t sIndex,
01066 TGHtmlBlock **ppBlock, int *piIndex);
01067 int DecodeBaseIndex(const char *zBase,
01068 TGHtmlElement **ppToken, int *pIndex);
01069 int GetIndex(const char *zIndex, TGHtmlElement **ppToken, int *pIndex);
01070
01071 void LayoutDoc();
01072
01073 int MapControls();
01074 void UnmapControls();
01075 void DeleteControls();
01076 int ControlSize(TGHtmlInput *p);
01077 void SizeAndLink(TGFrame *frame, TGHtmlInput *pElem);
01078 int FormCount(TGHtmlInput *p, int radio);
01079 void AddFormInfo(TGHtmlElement *p);
01080 void AddSelectOptions(TGListBox *lb, TGHtmlElement *p, TGHtmlElement *pEnd);
01081 void AppendText(TGString *str, TGHtmlElement *pFirst, TGHtmlElement *pEnd);
01082
01083 void UpdateSelection(int forceUpdate);
01084 void UpdateSelectionDisplay();
01085 void LostSelection();
01086 int SelectionSet(const char *startIx, const char *endIx);
01087 void UpdateInsert();
01088 int SetInsert(const char *insIx);
01089
01090 const char *GetUid(const char *string);
01091 ColorStruct_t *AllocColor(const char *name);
01092 ColorStruct_t *AllocColorByValue(ColorStruct_t *color);
01093 void FreeColor(ColorStruct_t *color);
01094
01095 SHtmlStyle_t GetCurrentStyle();
01096 void PushStyleStack(int tag, SHtmlStyle_t style);
01097 SHtmlStyle_t PopStyleStack(int tag);
01098
01099 void MakeInvisible(TGHtmlElement *p_first, TGHtmlElement *p_last);
01100 int GetLinkColor(const char *zURL);
01101 void AddStyle(TGHtmlElement *p);
01102 void Sizer();
01103
01104 int NextMarkupType(TGHtmlElement *p);
01105
01106 TGHtmlElement *AttrElem(const char *name, char *value);
01107
01108 public:
01109 void AppendArglist(TGString *str, TGHtmlMarkupElement *pElem);
01110 TGHtmlElement *FindEndNest(TGHtmlElement *sp, int en, TGHtmlElement *lp);
01111 TGString *ListTokens(TGHtmlElement *p, TGHtmlElement *pEnd);
01112 TGString *TableText(TGHtmlTable *pTable, int flags);
01113
01114 virtual void MouseOver(const char *uri) { Emit("MouseOver(const char *)",uri); }
01115 virtual void MouseDown(const char *uri) { Emit("MouseDown(const char *)",uri); }
01116 virtual void ButtonClicked(const char *name, const char *val);
01117 virtual void SubmitClicked(const char *val);
01118 virtual void CheckToggled(const char *name, Bool_t on, const char *val);
01119 virtual void RadioChanged(const char *name, const char *val);
01120 virtual void InputSelected(const char *name, const char *val);
01121 virtual void SavePrimitive(ostream &out, Option_t * = "");
01122
01123 protected:
01124 virtual void UpdateBackgroundStart();
01125
01126 protected:
01127 TGHtmlElement *fPFirst;
01128 TGHtmlElement *fPLast;
01129 int fNToken;
01130
01131 TGHtmlElement *fLastSized;
01132 TGHtmlElement *fNextPlaced;
01133
01134 TGHtmlBlock *fFirstBlock;
01135 TGHtmlBlock *fLastBlock;
01136 TGHtmlInput *fFirstInput;
01137 TGHtmlInput *fLastInput;
01138 int fNInput;
01139 int fNForm;
01140 int fVarId;
01141
01142 int fInputIdx;
01143 int fRadioIdx;
01144
01145
01146
01147 SHtmlIndex_t fSelBegin;
01148 SHtmlIndex_t fSelEnd;
01149 TGHtmlBlock *fPSelStartBlock;
01150 Html_16_t fSelStartIndex;
01151
01152 Html_16_t fSelEndIndex;
01153 TGHtmlBlock *fPSelEndBlock;
01154
01155
01156
01157 int fInsOnTime;
01158 int fInsOffTime;
01159 int fInsStatus;
01160 TTimer *fInsTimer;
01161 SHtmlIndex_t fIns;
01162 TGHtmlBlock *fPInsBlock;
01163 int fInsIndex;
01164
01165
01166
01167 char *fZText;
01168 int fNText;
01169 int fNAlloc;
01170 int fNComplete;
01171
01172 int fICol;
01173
01174 int fIPlaintext;
01175
01176
01177
01178 TGHtmlScript *fPScript;
01179
01180 TGIdleHandler *fIdle;
01181
01182
01183
01184
01185
01186
01187 SHtmlStyleStack_t *fStyleStack;
01188 int fParaAlignment;
01189 int fRowAlignment;
01190 int fAnchorFlags;
01191 int fInDt;
01192 int fInTr;
01193 int fInTd;
01194 TGHtmlAnchor *fAnchorStart;
01195 TGHtmlForm *fFormStart;
01196 TGHtmlInput *fFormElemStart;
01197 TGHtmlInput *fFormElemLast;
01198 TGHtmlListStart *fInnerList;
01199 TGHtmlElement *fLoEndPtr;
01200 TGHtmlForm *fLoFormStart;
01201
01202
01203
01204
01205
01206 TGHtmlLayoutContext fLayoutContext;
01207
01208
01209
01210 int fHighlightWidth;
01211
01212
01213 TGInsets fMargins;
01214
01215 ColorStruct_t *fHighlightBgColorPtr;
01216
01217 ColorStruct_t *fHighlightColorPtr;
01218 TGFont *fAFont[N_FONT];
01219 char fFontValid[(N_FONT+7)/8];
01220
01221
01222 ColorStruct_t *fApColor[N_COLOR];
01223 Long_t fColorUsed;
01224
01225 int fIDark[N_COLOR];
01226 int fILight[N_COLOR];
01227 ColorStruct_t *fBgColor;
01228 ColorStruct_t *fFgColor;
01229 ColorStruct_t *fNewLinkColor;
01230 ColorStruct_t *fOldLinkColor;
01231 ColorStruct_t *fSelectionColor;
01232 GcCache_t fAGcCache[N_CACHE_GC];
01233 int fGcNextToFree;
01234 int fLastGC;
01235 TGHtmlImage *fImageList;
01236 TImage *fBgImage;
01237
01238 int fFormPadding;
01239 int fOverrideFonts;
01240 int fOverrideColors;
01241 int fUnderlineLinks;
01242 int fHasScript;
01243 int fHasFrames;
01244 int fAddEndTags;
01245 int fTableBorderMin;
01246 int fVarind;
01247
01248
01249
01250 int fExportSelection;
01251
01252
01253
01254
01255 int fTableRelief;
01256 int fRuleRelief;
01257 int fRulePadding;
01258 const char *fZBase;
01259 char *fZBaseHref;
01260 Cursor_t fCursor;
01261 int fMaxX, fMaxY;
01262
01263
01264 int fDirtyLeft, fDirtyTop;
01265
01266
01267 int fDirtyRight, fDirtyBottom;
01268 int fFlags;
01269 int fIdind;
01270 int fInParse;
01271 char *fZGoto;
01272
01273 SHtmlExtensions_t *fExts;
01274
01275 THashTable *fUidTable;
01276
01277 const char *fLastUri;
01278 int fExiting;
01279
01280 ClassDef(TGHtml, 0);
01281 };
01282
01283
01284
01285
01286
01287
01288
01289
01290
01291
01292
01293
01294
01295
01296
01297
01298
01299
01300
01301
01302
01303
01304
01305
01306
01307
01308
01309
01310
01311
01312
01313
01314
01315
01316
01317
01318
01319 #define REDRAW_PENDING 0x000001
01320 #define GOT_FOCUS 0x000002
01321 #define HSCROLL 0x000004
01322 #define VSCROLL 0x000008
01323 #define RELAYOUT 0x000010
01324 #define RESIZE_ELEMENTS 0x000020
01325 #define REDRAW_FOCUS 0x000040
01326 #define REDRAW_TEXT 0x000080
01327 #define EXTEND_LAYOUT 0x000100
01328 #define STYLER_RUNNING 0x000200
01329 #define INSERT_FLASHING 0x000400
01330 #define REDRAW_IMAGES 0x000800
01331 #define ANIMATE_IMAGES 0x001000
01332
01333
01334
01335
01336 #define HtmlHasFlag(A,F) (((A)->flags&(F))==(F))
01337 #define HtmlHasAnyFlag(A,F) (((A)->flags&(F))!=0)
01338 #define HtmlSetFlag(A,F) ((A)->flags|=(F))
01339 #define HtmlClearFlag(A,F) ((A)->flags&=~(F))
01340
01341
01342
01343
01344 #define LARGE_NUMBER 100000000
01345
01346
01347
01348
01349 #define DEF_HTML_BG_COLOR DEF_FRAME_BG_COLOR
01350 #define DEF_HTML_BG_MONO DEF_FRAME_BG_MONO
01351 #define DEF_HTML_EXPORT_SEL 1
01352 #define DEF_HTML_FG DEF_BUTTON_FG
01353 #define DEF_HTML_HIGHLIGHT_BG DEF_BUTTON_HIGHLIGHT_BG
01354 #define DEF_HTML_HIGHLIGHT DEF_BUTTON_HIGHLIGHT
01355 #define DEF_HTML_HIGHLIGHT_WIDTH "0"
01356 #define DEF_HTML_INSERT_OFF_TIME 300
01357 #define DEF_HTML_INSERT_ON_TIME 600
01358 #define DEF_HTML_PADX (HTML_INDENT / 4)
01359 #define DEF_HTML_PADY (HTML_INDENT / 4)
01360 #define DEF_HTML_RELIEF "raised"
01361 #define DEF_HTML_SELECTION_COLOR "skyblue"
01362 #define DEF_HTML_TAKE_FOCUS "0"
01363 #define DEF_HTML_UNVISITED "blue2"
01364 #define DEF_HTML_VISITED "purple4"
01365
01366 #ifdef NAVIGATOR_TABLES
01367
01368 #define DEF_HTML_TABLE_BORDER "0"
01369 #define DEF_HTML_TABLE_CELLPADDING "2"
01370 #define DEF_HTML_TABLE_CELLSPACING "5"
01371 #define DEF_HTML_TABLE_BORDER_LIGHT_COLOR "gray80"
01372 #define DEF_HTML_TABLE_BORDER_DARK_COLOR "gray40"
01373
01374 #endif // NAVIGATOR_TABLES
01375
01376
01377
01378
01379
01380
01381
01382
01383
01384
01385
01386
01387
01388
01389
01390
01391
01392
01393
01394
01395
01396
01397 #endif // ROOT_TGHtml