Warning, file /include/root/TGHtml.h was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034 #ifndef ROOT_TGHtml
0035 #define ROOT_TGHtml
0036
0037 #include "TGView.h"
0038
0039 #include "TGHtmlTokens.h"
0040
0041 class TGClient;
0042 class TImage;
0043 class TGFont;
0044 class TGIdleHandler;
0045 class THashTable;
0046 class TTimer;
0047 class TGPopupMenu;
0048
0049
0050
0051 #define HTML_RELIEF_FLAT 0
0052 #define HTML_RELIEF_SUNKEN 1
0053 #define HTML_RELIEF_RAISED 2
0054
0055
0056
0057
0058
0059
0060 #define CANT_HAPPEN \
0061 fprintf(stderr, \
0062 "Unplanned behavior in the HTML Widget in file %s line %d\n", \
0063 __FILE__, __LINE__)
0064
0065 #define UNTESTED \
0066 fprintf(stderr, \
0067 "Untested code executed in the HTML Widget in file %s line %d\n", \
0068 __FILE__, __LINE__)
0069
0070
0071
0072 #ifdef DEBUG
0073 #define HtmlAssert(X) \
0074 if(!(X)){ \
0075 fprintf(stderr,"Assertion failed on line %d of %s\n",__LINE__,__FILE__); \
0076 }
0077 #define HtmlCantHappen \
0078 fprintf(stderr,"Can't happen on line %d of %s\n",__LINE__,__FILE__);
0079 #else
0080 #define HtmlAssert(X)
0081 #define HtmlCantHappen
0082 #endif
0083
0084
0085
0086 #define HtmlTrace_Table1 0x00000001
0087 #define HtmlTrace_Table2 0x00000002
0088 #define HtmlTrace_Table3 0x00000004
0089 #define HtmlTrace_Table4 0x00000008
0090 #define HtmlTrace_Table5 0x00000010
0091 #define HtmlTrace_Table6 0x00000020
0092 #define HtmlTrace_GetLine 0x00000100
0093 #define HtmlTrace_GetLine2 0x00000200
0094 #define HtmlTrace_FixLine 0x00000400
0095 #define HtmlTrace_BreakMarkup 0x00001000
0096 #define HtmlTrace_Style 0x00002000
0097 #define HtmlTrace_Input1 0x00004000
0098
0099
0100
0101
0102
0103
0104
0105
0106
0107
0108
0109 #ifdef DEBUG
0110 extern int HtmlTraceMask;
0111 extern int HtmlDepth;
0112 # define TRACE_INDENT printf("%*s",HtmlDepth-3,"")
0113 # define TRACE(Flag, Args) \
0114 if( (Flag)&HtmlTraceMask ){ \
0115 TRACE_INDENT; printf Args; fflush(stdout); \
0116 }
0117 # define TRACE_PUSH(Flag) if( (Flag)&HtmlTraceMask ){ HtmlDepth+=3; }
0118 # define TRACE_POP(Flag) if( (Flag)&HtmlTraceMask ){ HtmlDepth-=3; }
0119 #else
0120 # define TRACE_INDENT
0121 # define TRACE(Flag, Args)
0122 # define TRACE_PUSH(Flag)
0123 # define TRACE_POP(Flag)
0124 #endif
0125
0126
0127
0128
0129
0130
0131
0132
0133
0134
0135
0136 typedef unsigned char Html_u8_t;
0137 typedef short Html_16_t;
0138 typedef unsigned short Html_u16_t;
0139 typedef int Html_32_t;
0140
0141
0142
0143
0144 struct SHtmlStyle_t {
0145 unsigned int fFont : 6;
0146 unsigned int fColor : 6;
0147 signed int fSubscript : 4;
0148 unsigned int fAlign : 2;
0149 unsigned int fBgcolor : 6;
0150 unsigned int fExpbg : 1;
0151 unsigned int fFlags : 7;
0152 };
0153
0154
0155
0156
0157
0158
0159
0160
0161
0162
0163
0164 #define N_FONT_FAMILY 8
0165 #define N_FONT_SIZE 7
0166 #define N_FONT 71
0167 #define NormalFont(X) (X)
0168 #define BoldFont(X) ((X) | 8)
0169 #define ItalicFont(X) ((X) | 16)
0170 #define CWFont(X) ((X) | 32)
0171 #define FontSize(X) ((X) & 007)
0172 #define FontFamily(X) ((X) & 070)
0173 #define FONT_Any -1
0174 #define FONT_Default 3
0175 #define FontSwitch(Size, Bold, Italic, Cw) \
0176 ((Size) | ((Bold+(Italic)*2+(Cw)*4) << 3))
0177
0178
0179
0180 #define FontIsValid(I) ((fFontValid[(I)>>3] & (1<<((I)&3)))!=0)
0181 #define FontSetValid(I) (fFontValid[(I)>>3] |= (1<<((I)&3)))
0182 #define FontClearValid(I) (fFontValid[(I)>>3] &= ~(1<<((I)&3)))
0183
0184
0185
0186
0187
0188
0189
0190
0191
0192
0193
0194
0195 #define N_COLOR 32
0196
0197 #define COLOR_Normal 0
0198 #define COLOR_Unvisited 1
0199 #define COLOR_Visited 2
0200 #define COLOR_Selection 3
0201 #define COLOR_Background 4
0202 #define N_PREDEFINED_COLOR 5
0203
0204
0205
0206
0207
0208
0209 #define ALIGN_Left 1
0210 #define ALIGN_Right 2
0211 #define ALIGN_Center 3
0212 #define ALIGN_None 0
0213
0214
0215
0216
0217
0218
0219
0220
0221
0222
0223
0224
0225
0226
0227
0228
0229
0230
0231
0232
0233
0234 #define STY_Preformatted 0x001
0235 #define STY_StrikeThru 0x002
0236 #define STY_Underline 0x004
0237 #define STY_NoBreak 0x008
0238 #define STY_Anchor 0x010
0239 #define STY_DT 0x020
0240 #define STY_Invisible 0x040
0241 #define STY_FontMask (STY_StrikeThru|STY_Underline)
0242
0243
0244
0245
0246
0247
0248
0249
0250 class TGHtmlElement : public TObject {
0251 public:
0252 TGHtmlElement(int etype = 0);
0253
0254 virtual int IsMarkup() const { return (fType > Html_Block); }
0255 virtual const char *MarkupArg(const char * , const char * ) { return nullptr; }
0256 virtual int GetAlignment(int dflt) { return dflt; }
0257 virtual int GetOrderedListType(int dflt) { return dflt; }
0258 virtual int GetUnorderedListType(int dflt) { return dflt; }
0259 virtual int GetVerticalAlignment(int dflt) { return dflt; }
0260
0261 public:
0262 TGHtmlElement *fPNext;
0263 TGHtmlElement *fPPrev;
0264 SHtmlStyle_t fStyle;
0265 Html_u8_t fType;
0266 Html_u8_t fFlags;
0267 Html_16_t fCount;
0268 int fElId;
0269 int fOffs;
0270 };
0271
0272
0273
0274
0275 #define HTML_Visible 0x01
0276 #define HTML_NewLine 0x02
0277 #define HTML_Selected 0x04
0278
0279
0280
0281
0282
0283
0284
0285
0286 class TGHtmlTextElement : public TGHtmlElement {
0287 private:
0288 TGHtmlTextElement(const TGHtmlTextElement&) = delete;
0289 TGHtmlTextElement &operator=(const TGHtmlTextElement&) = delete;
0290
0291 public:
0292 TGHtmlTextElement(int size);
0293 ~TGHtmlTextElement() override;
0294
0295 Html_32_t fY;
0296 Html_16_t fX;
0297 Html_16_t fW;
0298 Html_u8_t fAscent;
0299 Html_u8_t fDescent;
0300 Html_u8_t fSpaceWidth;
0301 char *fZText;
0302 };
0303
0304
0305
0306
0307 class TGHtmlSpaceElement : public TGHtmlElement {
0308 public:
0309 Html_16_t fW;
0310 Html_u8_t fAscent;
0311 Html_u8_t fDescent;
0312
0313 public:
0314 TGHtmlSpaceElement() : TGHtmlElement(Html_Space), fW(0), fAscent(0), fDescent(0) {}
0315 };
0316
0317
0318
0319
0320
0321
0322
0323
0324 class TGHtmlMarkupElement : public TGHtmlElement {
0325 public:
0326 TGHtmlMarkupElement(int type, int argc, int arglen[], char *argv[]);
0327 ~TGHtmlMarkupElement() override;
0328
0329 const char *MarkupArg(const char *tag, const char *zDefault) override;
0330 int GetAlignment(int dflt) override;
0331 int GetOrderedListType(int dflt) override;
0332 int GetUnorderedListType(int dflt) override;
0333 int GetVerticalAlignment(int dflt) override;
0334
0335 public:
0336 char **fArgv;
0337 };
0338
0339
0340
0341
0342
0343 #define HTML_MAX_COLUMNS 40
0344
0345
0346
0347
0348
0349
0350
0351
0352
0353
0354 class TGHtmlTable : public TGHtmlMarkupElement {
0355 public:
0356 TGHtmlTable(int type, int argc, int arglen[], char *argv[]);
0357 ~TGHtmlTable() override;
0358
0359 public:
0360 Html_u8_t fBorderWidth;
0361 Html_u8_t fNCol;
0362 Html_u16_t fNRow;
0363 Html_32_t fY;
0364 Html_32_t fH;
0365 Html_16_t fX;
0366 Html_16_t fW;
0367 int fMinW[HTML_MAX_COLUMNS+1];
0368 int fMaxW[HTML_MAX_COLUMNS+1];
0369 TGHtmlElement *fPEnd;
0370 TImage *fBgImage;
0371 int fHasbg;
0372 };
0373
0374
0375
0376
0377
0378
0379
0380
0381 class TGHtmlCell : public TGHtmlMarkupElement {
0382 public:
0383 TGHtmlCell(int type, int argc, int arglen[], char *argv[]);
0384 ~TGHtmlCell() override;
0385
0386 public:
0387 Html_16_t fRowspan;
0388 Html_16_t fColspan;
0389 Html_16_t fX;
0390 Html_16_t fW;
0391 Html_32_t fY;
0392 Html_32_t fH;
0393 TGHtmlTable *fPTable;
0394 TGHtmlElement *fPRow;
0395 TGHtmlElement *fPEnd;
0396 TImage *fBgImage;
0397 };
0398
0399
0400
0401
0402
0403
0404
0405 class TGHtmlRef : public TGHtmlMarkupElement {
0406 public:
0407 TGHtmlRef(int type, int argc, int arglen[], char *argv[]);
0408 ~TGHtmlRef() override;
0409
0410 public:
0411 TGHtmlElement *fPOther;
0412 TImage *fBgImage;
0413 };
0414
0415
0416
0417
0418
0419 class TGHtmlLi : public TGHtmlMarkupElement {
0420 public:
0421 TGHtmlLi(int type, int argc, int arglen[], char *argv[]);
0422
0423 public:
0424 Html_u8_t fLtype;
0425 Html_u8_t fAscent;
0426 Html_u8_t fDescent;
0427 Html_16_t fCnt;
0428 Html_16_t fX;
0429 Html_32_t fY;
0430 };
0431
0432
0433
0434
0435
0436
0437
0438 #define LI_TYPE_Undefined 0
0439 #define LI_TYPE_Bullet1 1
0440 #define LI_TYPE_Bullet2 2
0441 #define LI_TYPE_Bullet3 3
0442 #define LI_TYPE_Enum_1 4
0443 #define LI_TYPE_Enum_A 5
0444 #define LI_TYPE_Enum_a 6
0445 #define LI_TYPE_Enum_I 7
0446 #define LI_TYPE_Enum_i 8
0447
0448
0449
0450
0451 class TGHtmlListStart : public TGHtmlMarkupElement {
0452 public:
0453 TGHtmlListStart(int type, int argc, int arglen[], char *argv[]);
0454
0455 public:
0456 Html_u8_t fLtype;
0457 Html_u8_t fCompact;
0458 Html_u16_t fCnt;
0459 Html_u16_t fWidth;
0460 TGHtmlListStart *fLPrev;
0461 };
0462
0463
0464 #define HTML_MAP_RECT 1
0465 #define HTML_MAP_CIRCLE 2
0466 #define HTML_MAP_POLY 3
0467
0468 class TGHtmlMapArea : public TGHtmlMarkupElement {
0469 public:
0470 TGHtmlMapArea(int type, int argc, int arglen[], char *argv[]);
0471
0472 public:
0473 int fMType;
0474 int *fCoords;
0475 int fNum;
0476 };
0477
0478
0479
0480
0481
0482
0483 struct SHtmlExtensions_t {
0484 void *fExts;
0485 int fTyp;
0486 int fFlags;
0487 SHtmlExtensions_t *fNext;
0488 };
0489
0490
0491
0492
0493
0494
0495
0496
0497
0498
0499
0500
0501
0502
0503
0504 class TGHtml;
0505 class TGHtmlImageMarkup;
0506
0507 class TGHtmlImage : public TObject {
0508 private:
0509 TGHtmlImage(const TGHtmlImage&) = delete;
0510 TGHtmlImage &operator=(const TGHtmlImage&) = delete;
0511
0512 public:
0513 TGHtmlImage(TGHtml *htm, const char *url, const char *width,
0514 const char *height);
0515 ~TGHtmlImage() override;
0516
0517 public:
0518 TGHtml *fHtml;
0519 TImage *fImage;
0520 Html_32_t fW;
0521 Html_32_t fH;
0522 char *fZUrl;
0523 char *fZWidth, *fZHeight;
0524 TGHtmlImage *fPNext;
0525 TGHtmlImageMarkup *fPList;
0526
0527 TTimer *fTimer;
0528 };
0529
0530
0531
0532
0533
0534
0535 class TGHtmlImageMarkup : public TGHtmlMarkupElement {
0536 public:
0537 TGHtmlImageMarkup(int type, int argc, int arglen[], char *argv[]);
0538
0539 public:
0540 Html_u8_t fAlign;
0541 Html_u8_t fTextAscent;
0542 Html_u8_t fTextDescent;
0543 Html_u8_t fRedrawNeeded;
0544
0545 Html_16_t fH;
0546 Html_16_t fW;
0547 Html_16_t fAscent;
0548 Html_16_t fDescent;
0549 Html_16_t fX;
0550 Html_32_t fY;
0551 const char *fZAlt;
0552 TGHtmlImage *fPImage;
0553 TGHtmlElement *fPMap;
0554 TGHtmlImageMarkup *fINext;
0555 };
0556
0557
0558
0559
0560
0561 #define IMAGE_ALIGN_Bottom 0
0562 #define IMAGE_ALIGN_Middle 1
0563 #define IMAGE_ALIGN_Top 2
0564 #define IMAGE_ALIGN_TextTop 3
0565 #define IMAGE_ALIGN_AbsMiddle 4
0566 #define IMAGE_ALIGN_AbsBottom 5
0567 #define IMAGE_ALIGN_Left 6
0568 #define IMAGE_ALIGN_Right 7
0569
0570
0571
0572
0573
0574
0575
0576
0577
0578
0579
0580 class TGHtmlForm;
0581
0582 class TGHtmlInput : public TGHtmlMarkupElement {
0583 public:
0584 TGHtmlInput(int type, int argc, int arglen[], char *argv[]);
0585
0586 void Empty();
0587
0588 public:
0589 TGHtmlForm *fPForm;
0590 TGHtmlInput *fINext;
0591 TGFrame *fFrame;
0592 TGHtml *fHtml;
0593 TGHtmlElement *fPEnd;
0594 Html_u16_t fInpId;
0595 Html_u16_t fSubId;
0596 Html_32_t fY;
0597 Html_u16_t fX;
0598 Html_u16_t fW, fH;
0599 Html_u8_t fPadLeft;
0600 Html_u8_t fAlign;
0601 Html_u8_t fTextAscent;
0602 Html_u8_t fTextDescent;
0603 Html_u8_t fItype;
0604 Html_u8_t fSized;
0605 Html_u16_t fCnt;
0606 };
0607
0608
0609
0610
0611
0612
0613 #define INPUT_TYPE_Unknown 0
0614 #define INPUT_TYPE_Checkbox 1
0615 #define INPUT_TYPE_File 2
0616 #define INPUT_TYPE_Hidden 3
0617 #define INPUT_TYPE_Image 4
0618 #define INPUT_TYPE_Password 5
0619 #define INPUT_TYPE_Radio 6
0620 #define INPUT_TYPE_Reset 7
0621 #define INPUT_TYPE_Select 8
0622 #define INPUT_TYPE_Submit 9
0623 #define INPUT_TYPE_Text 10
0624 #define INPUT_TYPE_TextArea 11
0625 #define INPUT_TYPE_Applet 12
0626 #define INPUT_TYPE_Button 13
0627
0628
0629
0630
0631
0632
0633
0634 class TGHtmlForm : public TGHtmlMarkupElement {
0635 public:
0636 TGHtmlForm(int type, int argc, int arglen[], char *argv[]);
0637
0638 public:
0639 Html_u16_t fFormId;
0640 unsigned int fElements;
0641 unsigned int fHasctl;
0642 TGHtmlElement *fPFirst;
0643 TGHtmlElement *fPEnd;
0644 };
0645
0646
0647
0648
0649 class TGHtmlHr : public TGHtmlMarkupElement {
0650 public:
0651 TGHtmlHr(int type, int argc, int arglen[], char *argv[]);
0652
0653 public:
0654 Html_32_t fY;
0655 Html_u16_t fX;
0656 Html_u16_t fW, fH;
0657 Html_u8_t fIs3D;
0658 };
0659
0660
0661
0662
0663 class TGHtmlAnchor : public TGHtmlMarkupElement {
0664 public:
0665 TGHtmlAnchor(int type, int argc, int arglen[], char *argv[]);
0666
0667 public:
0668 Html_32_t fY;
0669 };
0670
0671
0672
0673
0674
0675
0676
0677
0678
0679 class TGHtmlScript : public TGHtmlMarkupElement {
0680 public:
0681 TGHtmlScript(int type, int argc, int arglen[], char *argv[]);
0682
0683 public:
0684 int fNStart;
0685 int fNScript;
0686
0687 };
0688
0689
0690
0691
0692
0693
0694
0695
0696
0697
0698
0699
0700
0701
0702
0703
0704
0705
0706
0707
0708
0709
0710
0711 class TGHtmlBlock : public TGHtmlElement {
0712 public:
0713 TGHtmlBlock();
0714 ~TGHtmlBlock() override;
0715
0716 public:
0717 char *fZ;
0718 int fTop, fBottom;
0719 Html_u16_t fLeft, fRight;
0720 Html_u16_t fN;
0721 TGHtmlBlock *fBPrev, *fBNext;
0722 };
0723
0724
0725
0726
0727
0728
0729
0730
0731
0732
0733 struct SHtmlStyleStack_t {
0734 SHtmlStyleStack_t *fPNext;
0735 int fType;
0736 SHtmlStyle_t fStyle;
0737 };
0738
0739
0740
0741
0742
0743 struct SHtmlMargin_t {
0744 int fIndent;
0745 int fBottom;
0746 int fTag;
0747 SHtmlMargin_t *fPNext;
0748 };
0749
0750
0751
0752
0753
0754 #define HTML_INDENT 36
0755
0756
0757
0758
0759
0760
0761 class TGHtmlLayoutContext : public TObject {
0762 public:
0763 TGHtmlLayoutContext();
0764
0765 void LayoutBlock();
0766 void Reset();
0767
0768 void PopIndent();
0769 void PushIndent();
0770
0771 protected:
0772 void PushMargin(SHtmlMargin_t **ppMargin, int indent, int bottom, int tag);
0773 void PopOneMargin(SHtmlMargin_t **ppMargin);
0774 void PopMargin(SHtmlMargin_t **ppMargin, int tag);
0775 void PopExpiredMargins(SHtmlMargin_t **ppMarginStack, int y);
0776 void ClearMarginStack(SHtmlMargin_t **ppMargin);
0777
0778 TGHtmlElement *GetLine(TGHtmlElement *pStart, TGHtmlElement *pEnd,
0779 int width, int minX, int *actualWidth);
0780
0781 void FixAnchors(TGHtmlElement *p, TGHtmlElement *pEnd, int y);
0782 int FixLine(TGHtmlElement *pStart, TGHtmlElement *pEnd,
0783 int bottom, int width, int actualWidth, int leftMargin,
0784 int *maxX);
0785 void Paragraph(TGHtmlElement *p);
0786 void ComputeMargins(int *pX, int *pY, int *pW);
0787 void ClearObstacle(int mode);
0788 TGHtmlElement *DoBreakMarkup(TGHtmlElement *p);
0789 int InWrapAround();
0790 void WidenLine(int reqWidth, int *pX, int *pY, int *pW);
0791
0792 TGHtmlElement *TableLayout(TGHtmlTable *p);
0793
0794 public:
0795 TGHtml *fHtml;
0796 TGHtmlElement *fPStart;
0797 TGHtmlElement *fPEnd;
0798 int fHeadRoom;
0799 int fTop;
0800 int fBottom;
0801 int fLeft, fRight;
0802 int fPageWidth;
0803
0804 int fMaxX, fMaxY;
0805 SHtmlMargin_t *fLeftMargin;
0806 SHtmlMargin_t *fRightMargin;
0807 };
0808
0809
0810
0811
0812
0813
0814
0815
0816
0817
0818
0819 #define N_CACHE_GC 32
0820
0821 struct GcCache_t {
0822 GContext_t fGc;
0823 Html_u8_t fFont;
0824 Html_u8_t fColor;
0825 Html_u8_t fIndex;
0826 };
0827
0828
0829
0830
0831
0832 struct SHtmlIndex_t {
0833 TGHtmlElement *fP;
0834 int fI;
0835 };
0836
0837
0838
0839
0840 struct SHtmlTokenMap_t {
0841 const char *fZName;
0842 Html_16_t fType;
0843 Html_16_t fObjType;
0844 SHtmlTokenMap_t *fPCollide;
0845 };
0846
0847
0848
0849
0850
0851 #define O_HtmlMarkupElement 0
0852 #define O_HtmlCell 1
0853 #define O_HtmlTable 2
0854 #define O_HtmlRef 3
0855 #define O_HtmlLi 4
0856 #define O_HtmlListStart 5
0857 #define O_HtmlImageMarkup 6
0858 #define O_HtmlInput 7
0859 #define O_HtmlForm 8
0860 #define O_HtmlHr 9
0861 #define O_HtmlAnchor 10
0862 #define O_HtmlScript 11
0863 #define O_HtmlMapArea 12
0864
0865
0866
0867
0868
0869
0870 class TGListBox;
0871 class THashTable;
0872
0873 class TGHtml : public TGView {
0874 public:
0875 TGHtml(const TGWindow *p, int w, int h, int id = -1);
0876 ~TGHtml() override;
0877
0878 Bool_t HandleFocusChange(Event_t *event) override;
0879 Bool_t HandleButton(Event_t *event) override;
0880 Bool_t HandleMotion(Event_t *event) override;
0881
0882 Bool_t HandleIdleEvent(TGIdleHandler *i) override;
0883 Bool_t HandleTimer(TTimer *timer) override;
0884
0885 Bool_t ProcessMessage(Longptr_t, Longptr_t, Longptr_t) override;
0886
0887 void DrawRegion(Int_t x, Int_t y, UInt_t w, UInt_t h) override;
0888 Bool_t ItemLayout() override;
0889
0890 Bool_t HandleHtmlInput(TGHtmlInput *pr, Event_t *event);
0891 Bool_t HandleRadioButton(TGHtmlInput *p);
0892
0893 public:
0894
0895 int ParseText(char *text, const char *index = nullptr);
0896
0897 void SetTableRelief(int relief);
0898 int GetTableRelief() const { return fTableRelief; }
0899
0900 void SetRuleRelief(int relief);
0901 int GetRuleRelief() const { return fRuleRelief; }
0902 int GetRulePadding() const { return fRulePadding; }
0903
0904 void UnderlineLinks(int onoff);
0905
0906 void SetBaseUri(const char *uri);
0907 const char *GetBaseUri() const { return fZBase; }
0908
0909 int GotoAnchor(const char *name);
0910
0911 public:
0912
0913
0914 void Clear(Option_t * = "") override;
0915
0916
0917 virtual char *ResolveUri(const char *uri);
0918
0919
0920 virtual TImage *LoadImage(const char *uri, int w = 0, int h = 0) ;
0921
0922
0923
0924 virtual int IsVisited(const char * )
0925 { return kFALSE; }
0926
0927
0928 virtual int ProcessToken(TGHtmlElement * , const char * , int )
0929 { return kFALSE; }
0930
0931 virtual TGFont *GetFont(int iFont);
0932
0933
0934
0935
0936
0937
0938 virtual int ProcessFrame()
0939 { return kFALSE; }
0940
0941
0942 virtual TGFrame *ProcessApplet(TGHtmlInput * )
0943 { return nullptr; }
0944
0945
0946 virtual int FormCreate(TGHtmlForm * , const char * , const char * )
0947 { return kFALSE; }
0948
0949
0950 virtual int FormAction(TGHtmlForm * , int )
0951 { return kFALSE; }
0952
0953
0954 virtual char *GetFontName()
0955 { return nullptr; }
0956
0957
0958 virtual char *ProcessScript(TGHtmlScript * )
0959 { return nullptr; }
0960
0961 public:
0962 const char *GetText() const { return fZText; }
0963
0964 void HandleMenu(Int_t);
0965 void SaveFileAs();
0966
0967 int GetMarginWidth() { return fMargins.fL + fMargins.fR; }
0968 int GetMarginHeight() { return fMargins.fT + fMargins.fB; }
0969
0970 TGHtmlInput *GetInputElement(int x, int y);
0971 const char *GetHref(int x, int y, const char **target = nullptr);
0972
0973 TGHtmlImage *GetImage(TGHtmlImageMarkup *p);
0974
0975 int InArea(TGHtmlMapArea *p, int left, int top, int x, int y);
0976 TGHtmlElement *GetMap(const char *name);
0977
0978 void ResetBlocks() { fFirstBlock = fLastBlock = nullptr; }
0979 int ElementCoords(TGHtmlElement *p, int i, int pct, int *coords);
0980
0981 TGHtmlElement *TableDimensions(TGHtmlTable *pStart, int lineWidth);
0982 int CellSpacing(TGHtmlElement *pTable);
0983 void MoveVertically(TGHtmlElement *p, TGHtmlElement *pLast, int dy);
0984
0985 void PrintList(TGHtmlElement *first, TGHtmlElement *last);
0986
0987 char *GetTokenName(TGHtmlElement *p);
0988 char *DumpToken(TGHtmlElement *p);
0989
0990 void EncodeText(TGString *str, const char *z);
0991
0992 protected:
0993 void HClear();
0994 void ClearGcCache();
0995 void ResetLayoutContext();
0996 void Redraw();
0997 void ComputeVirtualSize();
0998
0999 void ScheduleRedraw();
1000
1001 void RedrawArea(int left, int top, int right, int bottom);
1002 void RedrawBlock(TGHtmlBlock *p);
1003 void RedrawEverything();
1004 void RedrawText(int y);
1005
1006 float ColorDistance(ColorStruct_t *pA, ColorStruct_t *pB);
1007 int IsDarkColor(ColorStruct_t *p);
1008 int IsLightColor(ColorStruct_t *p);
1009 int GetColorByName(const char *zColor);
1010 int GetDarkShadowColor(int iBgColor);
1011 int GetLightShadowColor(int iBgColor);
1012 int GetColorByValue(ColorStruct_t *pRef);
1013
1014 void FlashCursor();
1015
1016 GContext_t GetGC(int color, int font);
1017 GContext_t GetAnyGC();
1018
1019 void AnimateImage(TGHtmlImage *image);
1020 void ImageChanged(TGHtmlImage *image, int newWidth, int newHeight);
1021 int GetImageAlignment(TGHtmlElement *p);
1022 int GetImageAt(int x, int y);
1023 const char *GetPctWidth(TGHtmlElement *p, char *opt, char *ret);
1024 void TableBgndImage(TGHtmlElement *p);
1025
1026 TGHtmlElement *FillOutBlock(TGHtmlBlock *p);
1027 void UnlinkAndFreeBlock(TGHtmlBlock *pBlock);
1028 void AppendBlock(TGHtmlElement *pToken, TGHtmlBlock *pBlock);
1029
1030 void StringHW(const char *str, int *h, int *w);
1031 TGHtmlElement *MinMax(TGHtmlElement *p, int *pMin, int *pMax,
1032 int lineWidth, int hasbg);
1033
1034 void DrawSelectionBackground(TGHtmlBlock *pBlock, Drawable_t Drawable_t,
1035 int x, int y);
1036 void DrawRect(Drawable_t drawable, TGHtmlElement *src,
1037 int x, int y, int w, int h, int depth, int relief);
1038 void BlockDraw(TGHtmlBlock *pBlock, Drawable_t wid,
1039 int left, int top,
1040 int width, int height, Pixmap_t pixmap);
1041 void DrawImage(TGHtmlImageMarkup *image, Drawable_t wid,
1042 int left, int top,
1043 int right, int bottom);
1044 void DrawTableBgnd(int x, int y, int w, int h, Drawable_t d, TImage *image);
1045
1046 TGHtmlElement *FindStartOfNextBlock(TGHtmlElement *p, int *pCnt);
1047 void FormBlocks();
1048
1049 void AppendElement(TGHtmlElement *pElem);
1050 int Tokenize();
1051 void AppToken(TGHtmlElement *pNew, TGHtmlElement *p, int offs);
1052 TGHtmlMarkupElement *MakeMarkupEntry(int objType, int type, int argc,
1053 int arglen[], char *argv[]);
1054 void TokenizerAppend(const char *text);
1055 TGHtmlElement *InsertToken(TGHtmlElement *pToken,
1056 char *zType, char *zArgs, int offs);
1057 SHtmlTokenMap_t *NameToPmap(char *zType);
1058 int NameToType(char *zType);
1059 const char *TypeToName(int type);
1060 int TextInsertCmd(int argc, char **argv);
1061 SHtmlTokenMap_t* GetMarkupMap(int n);
1062
1063 TGHtmlElement *TokenByIndex(int N, int flag);
1064 int TokenNumber(TGHtmlElement *p);
1065
1066 void MaxIndex(TGHtmlElement *p, int *pIndex, int isLast);
1067 int IndexMod(TGHtmlElement **pp, int *ip, char *cp);
1068 void FindIndexInBlock(TGHtmlBlock *pBlock, int x,
1069 TGHtmlElement **ppToken, int *pIndex);
1070 void IndexToBlockIndex(SHtmlIndex_t sIndex,
1071 TGHtmlBlock **ppBlock, int *piIndex);
1072 int DecodeBaseIndex(const char *zBase,
1073 TGHtmlElement **ppToken, int *pIndex);
1074 int GetIndex(const char *zIndex, TGHtmlElement **ppToken, int *pIndex);
1075
1076 void LayoutDoc();
1077
1078 int MapControls();
1079 void UnmapControls();
1080 void DeleteControls();
1081 int ControlSize(TGHtmlInput *p);
1082 void SizeAndLink(TGFrame *frame, TGHtmlInput *pElem);
1083 int FormCount(TGHtmlInput *p, int radio);
1084 void AddFormInfo(TGHtmlElement *p);
1085 void AddSelectOptions(TGListBox *lb, TGHtmlElement *p, TGHtmlElement *pEnd);
1086 void AppendText(TGString *str, TGHtmlElement *pFirst, TGHtmlElement *pEnd);
1087
1088 void UpdateSelection(int forceUpdate);
1089 void UpdateSelectionDisplay();
1090 void LostSelection();
1091 int SelectionSet(const char *startIx, const char *endIx);
1092 void UpdateInsert();
1093 int SetInsert(const char *insIx);
1094
1095 const char *GetUid(const char *string);
1096 ColorStruct_t *AllocColor(const char *name);
1097 ColorStruct_t *AllocColorByValue(ColorStruct_t *color);
1098 void FreeColor(ColorStruct_t *color);
1099
1100 SHtmlStyle_t GetCurrentStyle();
1101 void PushStyleStack(int tag, SHtmlStyle_t style);
1102 SHtmlStyle_t PopStyleStack(int tag);
1103
1104 void MakeInvisible(TGHtmlElement *p_first, TGHtmlElement *p_last);
1105 int GetLinkColor(const char *zURL);
1106 void AddStyle(TGHtmlElement *p);
1107 void Sizer();
1108
1109 int NextMarkupType(TGHtmlElement *p);
1110
1111 TGHtmlElement *AttrElem(const char *name, char *value);
1112
1113 public:
1114 void AppendArglist(TGString *str, TGHtmlMarkupElement *pElem);
1115 TGHtmlElement *FindEndNest(TGHtmlElement *sp, int en, TGHtmlElement *lp);
1116 TGString *ListTokens(TGHtmlElement *p, TGHtmlElement *pEnd);
1117 TGString *TableText(TGHtmlTable *pTable, int flags);
1118
1119 virtual void MouseOver(const char *uri) { Emit("MouseOver(const char *)",uri); }
1120 virtual void MouseDown(const char *uri) { Emit("MouseDown(const char *)",uri); }
1121 virtual void ButtonClicked(const char *name, const char *val);
1122 virtual void SubmitClicked(const char *val);
1123 virtual void CheckToggled(const char *name, Bool_t on, const char *val);
1124 virtual void RadioChanged(const char *name, const char *val);
1125 virtual void InputSelected(const char *name, const char *val);
1126 void SavePrimitive(std::ostream &out, Option_t * = "") override;
1127
1128 protected:
1129 void UpdateBackgroundStart() override;
1130
1131 protected:
1132 enum {
1133 kM_FILE_SAVEAS, kM_FILE_PRINT
1134 };
1135
1136 TGHtmlElement *fPFirst;
1137 TGHtmlElement *fPLast;
1138 int fNToken;
1139
1140 TGHtmlElement *fLastSized;
1141 TGHtmlElement *fNextPlaced;
1142
1143 TGHtmlBlock *fFirstBlock;
1144 TGHtmlBlock *fLastBlock;
1145 TGHtmlInput *fFirstInput;
1146 TGHtmlInput *fLastInput;
1147 int fNInput;
1148 int fNForm;
1149 int fVarId;
1150
1151 int fInputIdx;
1152 int fRadioIdx;
1153
1154
1155
1156 SHtmlIndex_t fSelBegin;
1157 SHtmlIndex_t fSelEnd;
1158 TGHtmlBlock *fPSelStartBlock;
1159 Html_16_t fSelStartIndex;
1160
1161 Html_16_t fSelEndIndex;
1162 TGHtmlBlock *fPSelEndBlock;
1163
1164
1165
1166 int fInsOnTime;
1167 int fInsOffTime;
1168 int fInsStatus;
1169 TTimer *fInsTimer;
1170 SHtmlIndex_t fIns;
1171 TGHtmlBlock *fPInsBlock;
1172 int fInsIndex;
1173
1174
1175
1176 char *fZText;
1177 int fNText;
1178 int fNAlloc;
1179 int fNComplete;
1180
1181 int fICol;
1182
1183 int fIPlaintext;
1184
1185
1186
1187 TGHtmlScript *fPScript;
1188
1189 TGIdleHandler *fIdle;
1190 TGPopupMenu *fMenu;
1191
1192
1193
1194
1195
1196
1197 SHtmlStyleStack_t *fStyleStack;
1198 int fParaAlignment;
1199 int fRowAlignment;
1200 int fAnchorFlags;
1201 int fInDt;
1202 int fInTr;
1203 int fInTd;
1204 TGHtmlAnchor *fAnchorStart;
1205 TGHtmlForm *fFormStart;
1206 TGHtmlInput *fFormElemStart;
1207 TGHtmlInput *fFormElemLast;
1208 TGHtmlListStart *fInnerList;
1209 TGHtmlElement *fLoEndPtr;
1210 TGHtmlForm *fLoFormStart;
1211
1212
1213
1214
1215
1216 TGHtmlLayoutContext fLayoutContext;
1217
1218
1219
1220 int fHighlightWidth;
1221
1222
1223 TGInsets fMargins;
1224
1225 ColorStruct_t *fHighlightBgColorPtr;
1226
1227 ColorStruct_t *fHighlightColorPtr;
1228 TGFont *fAFont[N_FONT];
1229 char fFontValid[(N_FONT+7)/8];
1230
1231
1232 ColorStruct_t *fApColor[N_COLOR];
1233 Long_t fColorUsed;
1234
1235 int fIDark[N_COLOR];
1236 int fILight[N_COLOR];
1237 ColorStruct_t *fBgColor;
1238 ColorStruct_t *fFgColor;
1239 ColorStruct_t *fNewLinkColor;
1240 ColorStruct_t *fOldLinkColor;
1241 ColorStruct_t *fSelectionColor;
1242 GcCache_t fAGcCache[N_CACHE_GC];
1243 int fGcNextToFree;
1244 int fLastGC;
1245 TGHtmlImage *fImageList;
1246 TImage *fBgImage;
1247
1248 int fFormPadding;
1249 int fOverrideFonts;
1250 int fOverrideColors;
1251 int fUnderlineLinks;
1252 int fHasScript;
1253 int fHasFrames;
1254 int fAddEndTags;
1255 int fTableBorderMin;
1256 int fVarind;
1257
1258
1259
1260 int fExportSelection;
1261
1262
1263
1264
1265 int fTableRelief;
1266 int fRuleRelief;
1267 int fRulePadding;
1268 const char *fZBase;
1269 char *fZBaseHref;
1270 Cursor_t fCursor;
1271 int fMaxX, fMaxY;
1272
1273
1274 int fDirtyLeft, fDirtyTop;
1275
1276
1277 int fDirtyRight, fDirtyBottom;
1278 int fFlags;
1279 int fIdind;
1280 int fInParse;
1281 char *fZGoto;
1282
1283 SHtmlExtensions_t *fExts;
1284
1285 THashTable *fUidTable;
1286
1287 const char *fLastUri;
1288 int fExiting;
1289
1290 ClassDefOverride(TGHtml, 0);
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 #define REDRAW_PENDING 0x000001
1330 #define GOT_FOCUS 0x000002
1331 #define HSCROLL 0x000004
1332 #define VSCROLL 0x000008
1333 #define RELAYOUT 0x000010
1334 #define RESIZE_ELEMENTS 0x000020
1335 #define REDRAW_FOCUS 0x000040
1336 #define REDRAW_TEXT 0x000080
1337 #define EXTEND_LAYOUT 0x000100
1338 #define STYLER_RUNNING 0x000200
1339 #define INSERT_FLASHING 0x000400
1340 #define REDRAW_IMAGES 0x000800
1341 #define ANIMATE_IMAGES 0x001000
1342
1343
1344
1345
1346 #define HtmlHasFlag(A,F) (((A)->flags&(F))==(F))
1347 #define HtmlHasAnyFlag(A,F) (((A)->flags&(F))!=0)
1348 #define HtmlSetFlag(A,F) ((A)->flags|=(F))
1349 #define HtmlClearFlag(A,F) ((A)->flags&=~(F))
1350
1351
1352
1353
1354 #define LARGE_NUMBER 100000000
1355
1356
1357
1358
1359 #define DEF_HTML_BG_COLOR DEF_FRAME_BG_COLOR
1360 #define DEF_HTML_BG_MONO DEF_FRAME_BG_MONO
1361 #define DEF_HTML_EXPORT_SEL 1
1362 #define DEF_HTML_FG DEF_BUTTON_FG
1363 #define DEF_HTML_HIGHLIGHT_BG DEF_BUTTON_HIGHLIGHT_BG
1364 #define DEF_HTML_HIGHLIGHT DEF_BUTTON_HIGHLIGHT
1365 #define DEF_HTML_HIGHLIGHT_WIDTH "0"
1366 #define DEF_HTML_INSERT_OFF_TIME 300
1367 #define DEF_HTML_INSERT_ON_TIME 600
1368 #define DEF_HTML_PADX (HTML_INDENT / 4)
1369 #define DEF_HTML_PADY (HTML_INDENT / 4)
1370 #define DEF_HTML_RELIEF "raised"
1371 #define DEF_HTML_SELECTION_COLOR "skyblue"
1372 #define DEF_HTML_TAKE_FOCUS "0"
1373 #define DEF_HTML_UNVISITED "blue2"
1374 #define DEF_HTML_VISITED "purple4"
1375
1376 #ifdef NAVIGATOR_TABLES
1377
1378 #define DEF_HTML_TABLE_BORDER "0"
1379 #define DEF_HTML_TABLE_CELLPADDING "2"
1380 #define DEF_HTML_TABLE_CELLSPACING "5"
1381 #define DEF_HTML_TABLE_BORDER_LIGHT_COLOR "gray80"
1382 #define DEF_HTML_TABLE_BORDER_DARK_COLOR "gray40"
1383
1384 #endif
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407 #endif