TGHtml.h

Go to the documentation of this file.
00001 // $Id: TGHtml.h,v 1.1 2007/05/04 17:07:01 brun Exp $
00002 // Author:  Valeriy Onuchin   03/05/2007
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2001, Rene Brun, Fons Rademakers and Reiner Rohlfs *
00006  * All rights reserved.                                                  *
00007  *                                                                       *
00008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00010  *************************************************************************/
00011 
00012 /**************************************************************************
00013 
00014     HTML widget for xclass. Based on tkhtml 1.28
00015     Copyright (C) 1997-2000 D. Richard Hipp <drh@acm.org>
00016     Copyright (C) 2002-2003 Hector Peraza.
00017 
00018     This library is free software; you can redistribute it and/or
00019     modify it under the terms of the GNU Library General Public
00020     License as published by the Free Software Foundation; either
00021     version 2 of the License, or (at your option) any later version.
00022 
00023     This library is distributed in the hope that it will be useful,
00024     but WITHOUT ANY WARRANTY; without even the implied warranty of
00025     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00026     Library General Public License for more details.
00027 
00028     You should have received a copy of the GNU Library General Public
00029     License along with this library; if not, write to the Free
00030     Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
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 //#define TABLE_TRIM_BLANK 1
00059 
00060 
00061 // Debug must be turned on for testing to work.
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 // Sanity checking macros.
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 // Bitmasks for the HtmlTraceMask global variable
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 // The TRACE macro is used to print internal information about the
00106 // HTML layout engine during testing and debugging. The amount of
00107 // information printed is governed by a global variable named
00108 // HtmlTraceMask. If bits in the first argument to the TRACE macro
00109 // match any bits in HtmlTraceMask variable, then the trace message
00110 // is printed.
00111 //
00112 // All of this is completely disabled, of course, if the DEBUG macro
00113 // is not defined.
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 // Various data types. This code is designed to run on a modern cached
00136 // architecture where the CPU runs a lot faster than the memory bus. Hence
00137 // we try to pack as much data into as small a space as possible so that it
00138 // is more likely to fit in cache. The extra CPU instruction or two needed
00139 // to unpack the data is not normally an issue since we expect the speed of
00140 // the memory bus to be the limiting factor.
00141 
00142 typedef unsigned char  Html_u8_t;      // 8-bit unsigned integer
00143 typedef short          Html_16_t;      // 16-bit signed integer
00144 typedef unsigned short Html_u16_t;     // 16-bit unsigned integer
00145 typedef int            Html_32_t;      // 32-bit signed integer
00146 
00147 // An instance of the following structure is used to record style
00148 // information on each Html element.
00149 
00150 struct SHtmlStyle_t {
00151   unsigned int fFont      : 6;      // Font to use for display
00152   unsigned int fColor     : 6;      // Foreground color
00153   signed int   fSubscript : 4;      // Positive for <sup>, negative for <sub>
00154   unsigned int fAlign     : 2;      // Horizontal alignment
00155   unsigned int fBgcolor   : 6;      // Background color
00156   unsigned int fExpbg     : 1;      // Set to 1 if bgcolor explicitely set
00157   unsigned int fFlags     : 7;      // the STY_ flags below
00158 };
00159 
00160 
00161 // We allow 8 different font families: Normal, Bold, Italic and Bold-Italic
00162 // in either variable or constant width. Within each family there can be up
00163 // to 7 font sizes from 1 (the smallest) up to 7 (the largest). Hence, the
00164 // widget can use a maximum of 56 fonts. The ".font" field of the style is
00165 // an integer between 0 and 55 which indicates which font to use.
00166 
00167 // HP: we further subdivide the .font field into two 3-bit subfields (size
00168 // and family). That makes easier to manipulate the family field.
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 // Macros for manipulating the fontValid bitmap of an TGHtml object.
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 // Information about available colors.
00192 //
00193 // The widget will use at most N_COLOR colors. 4 of these colors are
00194 // predefined. The rest are user selectable by options to various markups.
00195 // (Ex: <font color=red>)
00196 //
00197 // All colors are stored in the apColor[] array of the main widget object.
00198 // The ".color" field of the SHtmlStyle_t is an integer between 0 and
00199 // N_COLOR-1 which indicates which of these colors to use.
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 // The "align" field of the style determines how text is justified
00212 // horizontally. ALIGN_None means that the alignment is not specified.
00213 // (It should probably default to ALIGN_Left in this case.)
00214 
00215 #define ALIGN_Left   1
00216 #define ALIGN_Right  2
00217 #define ALIGN_Center 3
00218 #define ALIGN_None   0
00219 
00220 
00221 // Possible value of the "flags" field of SHtmlStyle_t are shown below.
00222 //
00223 //  STY_Preformatted       If set, the current text occurred within
00224 //                         <pre>..</pre>
00225 //
00226 //  STY_StrikeThru         Draw a solid line thru the middle of this text.
00227 //
00228 //  STY_Underline          This text should drawn with an underline.
00229 //
00230 //  STY_NoBreak            This text occurs within <nobr>..</nobr>
00231 //
00232 //  STY_Anchor             This text occurs within <a href=X>..</a>.
00233 //
00234 //  STY_DT                 This text occurs within <dt>..</dt>.
00235 //
00236 //  STY_Invisible          This text should not appear in the main HTML
00237 //                         window. (For example, it might be within
00238 //                         <title>..</title> or <marquee>..</marquee>.)
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 // The first thing done with input HTML text is to parse it into
00252 // TGHtmlElements. All sizing and layout is done using these elements.
00253 
00254 // Every element contains at least this much information:
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 * /*tag*/, const char * /*zDefault*/) { 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;        // Next input token in a list of them all
00269    TGHtmlElement *fPPrev;        // Previous token in a list of them all
00270    SHtmlStyle_t   fStyle;        // The rendering style for this token
00271    Html_u8_t      fType;         // The token type.
00272    Html_u8_t      fFlags;        // The HTML_ flags below
00273    Html_16_t      fCount;        // Various uses, depending on "type"
00274    int            fElId;         // Unique identifier
00275    int            fOffs;         // Offset within zText
00276 };
00277 
00278 
00279 // Bitmasks for the "flags" field of the TGHtmlElement
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                               // Used by Html_Block elements only.
00285 
00286 
00287 // Each text element holds additional information as shown here. Notice that
00288 // extra space is allocated so that zText[] will be large enough to hold the
00289 // complete text of the element. X and y coordinates are relative to the
00290 // virtual canvas. The y coordinate refers to the baseline.
00291 
00292 class TGHtmlTextElement : public TGHtmlElement {
00293 public:
00294    TGHtmlTextElement(int size);
00295    virtual ~TGHtmlTextElement();
00296 
00297    Html_32_t    fY;                // y coordinate where text should be rendered
00298    Html_16_t    fX;                // x coordinate where text should be rendered
00299    Html_16_t    fW;                // width of this token in pixels
00300    Html_u8_t    fAscent;           // height above the baseline
00301    Html_u8_t    fDescent;          // depth below the baseline
00302    Html_u8_t    fSpaceWidth;       // Width of one space in the current font
00303    char        *fZText;            // Text for this element. Null terminated
00304 };
00305 
00306 
00307 // Each space element is represented like this:
00308 
00309 class TGHtmlSpaceElement : public TGHtmlElement {
00310 public:
00311    Html_16_t fW;                  // Width of a single space in current font
00312    Html_u8_t fAscent;             // height above the baseline
00313    Html_u8_t fDescent;            // depth below the baseline
00314 
00315 public:
00316    TGHtmlSpaceElement() : TGHtmlElement(Html_Space), fW(0), fAscent(0), fDescent(0) {}
00317 };
00318 
00319 // Most markup uses this class. Some markup extends this class with
00320 // additional information, but most use it as is, at the very least.
00321 //
00322 // If the markup doesn't have arguments (the "count" field of
00323 // TGHtmlElement is 0) then the extra "argv" field of this class
00324 // is not allocated and should not be used.
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://protected:
00338    char **fArgv;
00339 };
00340 
00341 
00342 // The maximum number of columns allowed in a table. Any columns beyond
00343 // this number are ignored.
00344 
00345 #define HTML_MAX_COLUMNS 40
00346 
00347 
00348 // This class is used for each <table> element.
00349 //
00350 // In the minW[] and maxW[] arrays, the [0] element is the overall
00351 // minimum and maximum width, including cell padding, spacing and
00352 // the "hspace". All other elements are the minimum and maximum
00353 // width for the contents of individual cells without any spacing or
00354 // padding.
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;              // Width of the border
00363    Html_u8_t      fNCol;                     // Number of columns
00364    Html_u16_t     fNRow;                     // Number of rows
00365    Html_32_t      fY;                        // top edge of table border
00366    Html_32_t      fH;                        // height of the table border
00367    Html_16_t      fX;                        // left edge of table border
00368    Html_16_t      fW;                        // width of the table border
00369    int            fMinW[HTML_MAX_COLUMNS+1]; // minimum width of each column
00370    int            fMaxW[HTML_MAX_COLUMNS+1]; // maximum width of each column
00371    TGHtmlElement *fPEnd;                     // Pointer to the end tag element
00372    TImage        *fBgImage;                  // A background for the entire table
00373    int            fHasbg;                    // 1 if a table above has bgImage
00374 };
00375 
00376 
00377 // Each <td> or <th> markup is represented by an instance of the
00378 // following class.
00379 //
00380 // Drawing for a cell is a sunken 3D border with the border width given
00381 // by the borderWidth field in the associated <table> object.
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;      // Number of rows spanned by this cell
00390    Html_16_t      fColspan;      // Number of columns spanned by this cell
00391    Html_16_t      fX;            // X coordinate of left edge of border
00392    Html_16_t      fW;            // Width of the border
00393    Html_32_t      fY;            // Y coordinate of top of border indentation
00394    Html_32_t      fH;            // Height of the border
00395    TGHtmlTable   *fPTable;       // Pointer back to the <table>
00396    TGHtmlElement *fPRow;         // Pointer back to the <tr>
00397    TGHtmlElement *fPEnd;         // Element that ends this cell
00398    TImage        *fBgImage;      // Background for the cell
00399 };
00400 
00401 
00402 // This class is used for </table>, </td>, <tr>, </tr> and </th> elements.
00403 // It points back to the <table> element that began the table. It is also
00404 // used by </a> to point back to the original <a>. I'll probably think of
00405 // other uses before all is said and done...
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;      // Pointer to some other Html element
00414    TImage        *fBgImage;     // A background for the entire row
00415 };
00416 
00417 
00418 // An instance of the following class is used to represent
00419 // each <LI> markup.
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;    // What type of list is this?
00427    Html_u8_t fAscent;   // height above the baseline
00428    Html_u8_t fDescent;  // depth below the baseline
00429    Html_16_t fCnt;      // Value for this element (if inside <OL>)
00430    Html_16_t fX;        // X coordinate of the bullet
00431    Html_32_t fY;        // Y coordinate of the bullet
00432 };
00433 
00434 
00435 // The ltype field of an TGHtmlLi or TGHtmlListStart object can take on
00436 // any of the following values to indicate what type of bullet to draw.
00437 // The value in TGHtmlLi will take precedence over the value in
00438 // TGHtmlListStart if the two values differ.
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 // An instance of this class is used for <UL> or <OL> markup.
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;     // One of the LI_TYPE_ defines above
00459    Html_u8_t         fCompact;   // True if the COMPACT flag is present
00460    Html_u16_t        fCnt;       // Next value for <OL>
00461    Html_u16_t        fWidth;     // How much space to allow for indentation
00462    TGHtmlListStart  *fLPrev;     // Next higher level list, or NULL
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 // Structure to chain extension data onto.
00484 
00485 struct SHtmlExtensions_t {
00486    void              *fExts;
00487    int                fTyp;
00488    int                fFlags;
00489    SHtmlExtensions_t *fNext;
00490 };
00491 
00492 
00493 //----------------------------------------------------------------------
00494 
00495 // Information about each image on the HTML widget is held in an instance
00496 // of the following class. All images are held on a list attached to the
00497 // main widget object.
00498 //
00499 // This class is NOT an element. The <IMG> element is represented by an
00500 // TGHtmlImageMarkup object below. There is one TGHtmlImageMarkup for each
00501 // <IMG> in the source HTML. There is one of these objects for each unique
00502 // image loaded. (If two <IMG> specify the same image, there are still two
00503 // TGHtmlImageMarkup objects but only one TGHtmlImage object that is shared
00504 // between them.)
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;              // The owner of this image
00517    TImage            *fImage;             // The image token
00518    Html_32_t          fW;                 // Requested width of this image (0 if none)
00519    Html_32_t          fH;                 // Requested height of this image (0 if none)
00520    char              *fZUrl;              // The URL for this image.
00521    char              *fZWidth, *fZHeight; // Width and height in the <img> markup.
00522    TGHtmlImage       *fPNext;             // Next image on the list
00523    TGHtmlImageMarkup *fPList;             // List of all <IMG> markups that use this
00524                                           // same image
00525    TTimer            *fTimer;             // for animations
00526 };
00527 
00528 // Each <img> markup is represented by an instance of the following
00529 // class.
00530 //
00531 // If pImage == 0, then we use the alternative text in zAlt.
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;          // Alignment. See IMAGE_ALIGN_ defines below
00539    Html_u8_t          fTextAscent;     // Ascent of text font in force at the <IMG>
00540    Html_u8_t          fTextDescent;    // Descent of text font in force at the <IMG>
00541    Html_u8_t          fRedrawNeeded;   // Need to redraw this image because the image
00542                                        // content changed.
00543    Html_16_t          fH;              // Actual height of the image
00544    Html_16_t          fW;              // Actual width of the image
00545    Html_16_t          fAscent;         // How far image extends above "y"
00546    Html_16_t          fDescent;        // How far image extends below "y"
00547    Html_16_t          fX;              // X coordinate of left edge of the image
00548    Html_32_t          fY;              // Y coordinate of image baseline
00549    const char        *fZAlt;           // Alternative text
00550    TGHtmlImage       *fPImage;         // Corresponding TGHtmlImage object
00551    TGHtmlElement     *fPMap;           // usemap
00552    TGHtmlImageMarkup *fINext;          // Next markup using the same TGHtmlImage object
00553 };
00554 
00555 
00556 // Allowed alignments for images. These represent the allowed arguments
00557 // to the "align=" field of the <IMG> markup.
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 // All kinds of form markup, including <INPUT>, <TEXTAREA> and <SELECT>
00570 // are represented by instances of the following class.
00571 //
00572 // (later...)  We also use this for the <APPLET> markup. That way,
00573 // the window we create for an <APPLET> responds to the TGHtml::MapControls()
00574 // and TGHtml::UnmapControls() function calls. For an <APPLET>, the
00575 // pForm field is NULL. (Later still...) <EMBED> works just like
00576 // <APPLET> so it uses this class too.
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;       // The <FORM> to which this belongs
00588    TGHtmlInput    *fINext;       // Next element in a list of all input elements
00589    TGFrame        *fFrame;       // The xclass window that implements this control
00590    TGHtml         *fHtml;        // The HTML widget this control is attached to
00591    TGHtmlElement  *fPEnd;        // End tag for <TEXTAREA>, etc.
00592    Html_u16_t      fInpId;       // Unique id for this element
00593    Html_u16_t      fSubId;       // For radio - an id, for select - option count
00594    Html_32_t       fY;           // Baseline for this input element
00595    Html_u16_t      fX;           // Left edge
00596    Html_u16_t      fW, fH;       // Width and height of this control
00597    Html_u8_t       fPadLeft;     // Extra padding on left side of the control
00598    Html_u8_t       fAlign;       // One of the IMAGE_ALIGN_xxx types
00599    Html_u8_t       fTextAscent;  // Ascent for the current font
00600    Html_u8_t       fTextDescent; // descent for the current font
00601    Html_u8_t       fItype;       // What type of input is this?
00602    Html_u8_t       fSized;       // True if this input has been sized already
00603    Html_u16_t      fCnt;         // Used to derive widget name. 0 if no widget
00604 };
00605 
00606 
00607 // An input control can be one of the following types. See the
00608 // comment about <APPLET> on the TGHtmlInput class insight into
00609 // INPUT_TYPE_Applet.
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 // There can be multiple <FORM> entries on a single HTML page.
00628 // Each one must be given a unique number for identification purposes,
00629 // and so we can generate unique state variable names for radiobuttons,
00630 // checkbuttons, and entry boxes.
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;    // Unique number assigned to this form
00638    unsigned int   fElements;  // Number of elements
00639    unsigned int   fHasctl;    // Has controls
00640    TGHtmlElement *fPFirst;    // First form element
00641    TGHtmlElement *fPEnd;      // Pointer to end tag element
00642 };
00643 
00644 
00645 // Information used by a <HR> markup
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;      // Baseline for this input element
00653    Html_u16_t  fX;      // Left edge
00654    Html_u16_t  fW, fH;  // Width and height of this control
00655    Html_u8_t   fIs3D;   // Is it drawn 3D?
00656 };
00657 
00658 
00659 // Information used by a <A> markup
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;   // Top edge for this element
00667 };
00668 
00669 
00670 // Information about the <SCRIPT> markup. The parser treats <SCRIPT>
00671 // specially. All text between <SCRIPT> and </SCRIPT> is captured and
00672 // is indexed to by the nStart field of this class.
00673 //
00674 // The nStart field indexs to a spot in the zText field of the TGHtml object.
00675 // The nScript field determines how long the script is.
00676 
00677 class TGHtmlScript : public TGHtmlMarkupElement {
00678 public:
00679    TGHtmlScript(int type, int argc, int arglen[], char *argv[]);
00680 
00681 public:
00682    int   fNStart;    // Start of the script (index into TGHtml::zText)
00683    int   fNScript;   // Number of characters of text in zText holding
00684                      // the complete text of this script
00685 };
00686 
00687 
00688 // A block is a single unit of display information. This can be one or more
00689 // text elements, or the border of table, or an image, etc.
00690 //
00691 // Blocks are used to improve display speed and to improve the speed of
00692 // linear searchs through the token list. A single block will typically
00693 // contain enough information to display a dozen or more Text and Space
00694 // elements all with a single call to OXFont::DrawChars(). The blocks are
00695 // linked together on their own list, so we can search them much faster than
00696 // elements (since there are fewer of them.)
00697 //
00698 // Of course, you can construct pathological HTML that has as many Blocks as
00699 // it has normal tokens. But you haven't lost anything. Using blocks just
00700 // speeds things up in the common case.
00701 //
00702 // Much of the information needed for display is held in the original
00703 // TGHtmlElement objects. "fPNext" points to the first object in the list
00704 // which can be used to find the "style" "x" and "y".
00705 //
00706 // If n is zero, then "fPNext" might point to a special TGHtmlElement
00707 // that defines some other kind of drawing, like <LI> or <IMG> or <INPUT>.
00708 
00709 class TGHtmlBlock : public TGHtmlElement {
00710 public:
00711    TGHtmlBlock();
00712    virtual ~TGHtmlBlock();
00713 
00714 public:
00715    char        *fZ;                 // Space to hold text when n > 0
00716    int          fTop, fBottom;      // Extremes of y coordinates
00717    Html_u16_t   fLeft, fRight;      // Left and right boundry of this object
00718    Html_u16_t   fN;                 // Number of characters in z[]
00719    TGHtmlBlock *fBPrev, *fBNext;    // Linked list of all Blocks
00720 };
00721 
00722 
00723 // A stack of these structures is used to keep track of nested font and
00724 // style changes. This allows us to easily revert to the previous style
00725 // when we encounter and end-tag like </em> or </h3>.
00726 //
00727 // This stack is used to keep track of the current style while walking
00728 // the list of elements. After all elements have been assigned a style,
00729 // the information in this stack is no longer used.
00730 
00731 struct SHtmlStyleStack_t {
00732    SHtmlStyleStack_t *fPNext;   // Next style on the stack
00733    int                fType;    // A markup that ends this style. Ex: Html_EndEM
00734    SHtmlStyle_t       fStyle;   // The currently active style.
00735 };
00736 
00737 
00738 // A stack of the following structures is used to remember the
00739 // left and right margins within a layout context.
00740 
00741 struct SHtmlMargin_t {
00742    int            fIndent;    // Size of the current margin
00743    int            fBottom;    // Y value at which this margin expires
00744    int            fTag;       // Markup that will cancel this margin
00745    SHtmlMargin_t *fPNext;     // Previous margin
00746 };
00747 
00748 
00749 // How much space (in pixels) used for a single level of indentation due
00750 // to a <UL> or <DL> or <BLOCKQUOTE>, etc.
00751 
00752 #define HTML_INDENT 36
00753 
00754 
00755 //----------------------------------------------------------------------
00756 
00757 // A layout context holds all state information used by the layout engine.
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;            // The html widget undergoing layout
00794    TGHtmlElement    *fPStart;          // Start of elements to layout
00795    TGHtmlElement    *fPEnd;            // Stop when reaching this element
00796    int               fHeadRoom;        // Extra space wanted above this line
00797    int               fTop;             // Absolute top of drawing area
00798    int               fBottom;          // Bottom of previous line
00799    int               fLeft, fRight;    // Left and right extremes of drawing area
00800    int               fPageWidth;       // Width of the layout field, including
00801                                        // the margins
00802    int               fMaxX, fMaxY;     // Maximum X and Y values of paint
00803    SHtmlMargin_t    *fLeftMargin;      // Stack of left margins
00804    SHtmlMargin_t    *fRightMargin;     // Stack of right margins
00805 };
00806 
00807 
00808 // With 28 different fonts and 16 colors, we could in principle have
00809 // as many as 448 different GCs. But in practice, a single page of
00810 // HTML will typically have much less than this. So we won't try to
00811 // keep all GCs on hand. Instead, we'll keep around the most recently
00812 // used GCs and allocate new ones as necessary.
00813 //
00814 // The following structure is used to build a cache of GCs in the
00815 // main widget object.
00816 
00817 #define N_CACHE_GC 32
00818 
00819 struct GcCache_t {
00820    GContext_t  fGc;        // The graphics context
00821    Html_u8_t   fFont;      // Font used for this context
00822    Html_u8_t   fColor;     // Color used for this context
00823    Html_u8_t   fIndex;     // Index used for LRU replacement
00824 };
00825 
00826 
00827 // An SHtmlIndex_t is a reference to a particular character within a
00828 // particular Text or Space token.
00829 
00830 struct SHtmlIndex_t {
00831    TGHtmlElement *fP;     // The token containing the character
00832    int            fI;     // Index of the character
00833 };
00834 
00835 
00836 // Used by the tokenizer
00837 
00838 struct SHtmlTokenMap_t {
00839    const char       *fZName;        // Name of a markup
00840    Html_16_t         fType;         // Markup type code
00841    Html_16_t         fObjType;      // Which kind of TGHtml... object to alocate
00842    SHtmlTokenMap_t  *fPCollide;     // Hash table collision chain
00843 };
00844 
00845 
00846 // Markup element types to be allocated by the tokenizer.
00847 // Do not confuse with .type field in TGHtmlElement
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 // The HTML widget. A derivate of TGView.
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:   // user commands
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:   // reloadable methods
00910 
00911    // called when the widget is cleared
00912    virtual void Clear(Option_t * = "");
00913 
00914    // User function to resolve URIs
00915    virtual char *ResolveUri(const char *uri);
00916 
00917    // User function to get an image from a URL
00918    virtual TImage *LoadImage(const char *uri, int w = 0, int h = 0) ;//
00919    //    { return 0; }
00920 
00921    // User function to tell if a hyperlink has already been visited
00922    virtual int IsVisited(const char * /*url*/)
00923       { return kFALSE; }
00924 
00925    // User function to to process tokens of the given type
00926    virtual int ProcessToken(TGHtmlElement * /*pElem*/, const char * /*name*/, int /*type*/)
00927       { return kFALSE; }
00928 
00929    virtual TGFont *GetFont(int iFont);
00930 
00931    // The HTML parser will invoke the following methods from time
00932    // to time to find out information it needs to complete formatting of
00933    // the document.
00934 
00935    // Method for handling <frameset> markup
00936    virtual int ProcessFrame()
00937       { return kFALSE; }
00938 
00939    // Method to process applets
00940    virtual TGFrame *ProcessApplet(TGHtmlInput * /*input*/)
00941       { return 0; }
00942 
00943    // Called when parsing forms
00944    virtual int FormCreate(TGHtmlForm * /*form*/, const char * /*zUrl*/, const char * /*args*/)
00945       { return kFALSE; }
00946 
00947    // Called when user presses Submit
00948    virtual int FormAction(TGHtmlForm * /*form*/, int /*id*/)
00949       { return kFALSE; }
00950 
00951    // Invoked to find font names
00952    virtual char *GetFontName()
00953       { return 0; }
00954 
00955    // Invoked for each <SCRIPT> markup
00956    virtual char *ProcessScript(TGHtmlScript * /*script*/)
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); } // *SIGNAL*
01115    virtual void MouseDown(const char *uri)  { Emit("MouseDown(const char *)",uri); } // *SIGNAL*
01116    virtual void ButtonClicked(const char *name, const char *val); // *SIGNAL*
01117    virtual void SubmitClicked(const char *val); // *SIGNAL*
01118    virtual void CheckToggled(const char *name, Bool_t on, const char *val); // *SIGNAL*
01119    virtual void RadioChanged(const char *name, const char *val); // *SIGNAL*
01120    virtual void InputSelected(const char *name, const char *val);   //*SIGNAL*
01121    virtual void SavePrimitive(ostream &out, Option_t * = "");
01122 
01123 protected:
01124    virtual void UpdateBackgroundStart();
01125 
01126 protected:
01127    TGHtmlElement *fPFirst;          // First HTML token on a list of them all
01128    TGHtmlElement *fPLast;           // Last HTML token on the list
01129    int            fNToken;          // Number of HTML tokens on the list.
01130                                     // Html_Block tokens don't count.
01131    TGHtmlElement *fLastSized;       // Last HTML element that has been sized
01132    TGHtmlElement *fNextPlaced;      // Next HTML element that needs to be
01133                                     // positioned on canvas.
01134    TGHtmlBlock   *fFirstBlock;      // List of all TGHtmlBlock tokens
01135    TGHtmlBlock   *fLastBlock;       // Last TGHtmlBlock in the list
01136    TGHtmlInput   *fFirstInput;      // First <INPUT> element
01137    TGHtmlInput   *fLastInput;       // Last <INPUT> element
01138    int            fNInput;          // The number of <INPUT> elements
01139    int            fNForm;           // The number of <FORM> elements
01140    int            fVarId;           // Used to construct a unique name for a
01141                                     // global array used by <INPUT> elements
01142    int            fInputIdx;        // Unique input index
01143    int            fRadioIdx;        // Unique radio index
01144 
01145    // Information about the selected region of text
01146 
01147    SHtmlIndex_t   fSelBegin;        // Start of the selection
01148    SHtmlIndex_t   fSelEnd;          // End of the selection
01149    TGHtmlBlock   *fPSelStartBlock;  // Block in which selection starts
01150    Html_16_t      fSelStartIndex;   // Index in pSelStartBlock of first selected
01151                                     // character
01152    Html_16_t      fSelEndIndex;     // Index of last selecte char in pSelEndBlock
01153    TGHtmlBlock   *fPSelEndBlock;    // Block in which selection ends
01154 
01155    // Information about the insertion cursor
01156 
01157    int            fInsOnTime;       // How long the cursor states one (millisec)
01158    int            fInsOffTime;      // How long it is off (milliseconds)
01159    int            fInsStatus;       // Is it visible?
01160    TTimer        *fInsTimer;        // Timer used to flash the insertion cursor
01161    SHtmlIndex_t   fIns;             // The insertion cursor position
01162    TGHtmlBlock   *fPInsBlock;       // The TGHtmlBlock containing the cursor
01163    int            fInsIndex;        // Index in pInsBlock of the cursor
01164 
01165    // The following fields hold state information used by the tokenizer.
01166 
01167    char          *fZText;           // Complete text of the unparsed HTML
01168    int            fNText;           // Number of characters in zText
01169    int            fNAlloc;          // Space allocated for zText
01170    int            fNComplete;       // How much of zText has actually been
01171                                     // converted into tokens
01172    int            fICol;            // The column in which zText[nComplete]
01173                                     // occurs. Used to resolve tabs in input
01174    int            fIPlaintext;      // If not zero, this is the token type that
01175                                     // caused us to go into plaintext mode. One
01176                                     // of Html_PLAINTEXT, Html_LISTING or
01177                                     // Html_XMP
01178    TGHtmlScript  *fPScript;         // <SCRIPT> currently being parsed
01179 
01180    TGIdleHandler *fIdle;
01181 
01182    // These fields hold state information used by the HtmlAddStyle routine.
01183    // We have to store this state information here since HtmlAddStyle
01184    // operates incrementally. This information must be carried from
01185    // one incremental execution to the next.
01186 
01187    SHtmlStyleStack_t *fStyleStack;     // The style stack
01188    int               fParaAlignment;   // Justification associated with <p>
01189    int               fRowAlignment;    // Justification associated with <tr>
01190    int               fAnchorFlags;     // Style flags associated with <A>...</A>
01191    int               fInDt;            // Style flags associated with <DT>...</DT>
01192    int               fInTr;            // True if within <tr>..</tr>
01193    int               fInTd;            // True if within <td>..</td> or <th>..</th>
01194    TGHtmlAnchor     *fAnchorStart;     // Most recent <a href=...>
01195    TGHtmlForm       *fFormStart;       // Most recent <form>
01196    TGHtmlInput      *fFormElemStart;   // Most recent <textarea> or <select>
01197    TGHtmlInput      *fFormElemLast;    // Most recent <input>, <textarea> or <select>
01198    TGHtmlListStart  *fInnerList;       // The inner most <OL> or <UL>
01199    TGHtmlElement    *fLoEndPtr;        // How far AddStyle has gone to
01200    TGHtmlForm       *fLoFormStart;     // For AddStyle
01201 
01202    // These fields are used to hold the state of the layout engine.
01203    // Because the layout is incremental, this state must be held for
01204    // the life of the widget.
01205 
01206    TGHtmlLayoutContext fLayoutContext;
01207 
01208    // Information used when displaying the widget:
01209 
01210    int               fHighlightWidth;        // Width in pixels of highlight to draw
01211                                              // around widget when it has the focus.
01212                                              // <= 0 means don't draw a highlight.
01213    TGInsets          fMargins;               // document margins (separation between the
01214                                              // edge of the clip window and rendered HTML).
01215    ColorStruct_t    *fHighlightBgColorPtr;   // Color for drawing traversal highlight
01216                                              // area when highlight is off.
01217    ColorStruct_t    *fHighlightColorPtr;     // Color for drawing traversal highlight.
01218    TGFont           *fAFont[N_FONT];         // Information about all screen fonts
01219    char              fFontValid[(N_FONT+7)/8]; // If bit N%8 of work N/8 of this field is 0
01220                                              // if aFont[N] needs to be reallocated before
01221                                              // being used.
01222    ColorStruct_t    *fApColor[N_COLOR];      // Information about all colors
01223    Long_t            fColorUsed;             // bit N is 1 if color N is in use. Only
01224                                              // applies to colors that aren't predefined
01225    int               fIDark[N_COLOR];        // Dark 3D shadow of color K is iDark[K]
01226    int               fILight[N_COLOR];       // Light 3D shadow of color K is iLight[K]
01227    ColorStruct_t    *fBgColor;               // Background color of the HTML document
01228    ColorStruct_t    *fFgColor;               // Color of normal text. apColor[0]
01229    ColorStruct_t    *fNewLinkColor;          // Color of unvisitied links. apColor[1]
01230    ColorStruct_t    *fOldLinkColor;          // Color of visitied links. apColor[2]
01231    ColorStruct_t    *fSelectionColor;        // Background color for selections
01232    GcCache_t         fAGcCache[N_CACHE_GC];  // A cache of GCs for general use
01233    int               fGcNextToFree;
01234    int               fLastGC;                // Index of recently used GC
01235    TGHtmlImage      *fImageList;             // A list of all images
01236    TImage           *fBgImage;               // Background image
01237 
01238    int               fFormPadding;           // Amount to pad form elements by
01239    int               fOverrideFonts;         // TRUE if we should override fonts
01240    int               fOverrideColors;        // TRUE if we should override colors
01241    int               fUnderlineLinks;        // TRUE if we should underline hyperlinks
01242    int               fHasScript;             // TRUE if we can do scripts for this page
01243    int               fHasFrames;             // TRUE if we can do frames for this page
01244    int               fAddEndTags;            // TRUE if we add /LI etc.
01245    int               fTableBorderMin;        // Force tables to have min border size
01246    int               fVarind;                // Index suffix for unique global var name
01247 
01248    // Information about the selection
01249 
01250    int               fExportSelection;       // True if the selection is automatically
01251                                              // exported to the clipboard
01252 
01253    // Miscellaneous information:
01254 
01255    int               fTableRelief;           // 3d effects on <TABLE>
01256    int               fRuleRelief;            // 3d effects on <HR>
01257    int               fRulePadding;           // extra pixels above and below <HR>
01258    const char       *fZBase;                 // The base URI
01259    char             *fZBaseHref;             // zBase as modified by <BASE HREF=..> markup
01260    Cursor_t          fCursor;                // Current cursor for window, or None.
01261    int               fMaxX, fMaxY;           // Maximum extent of any "paint" that appears
01262                                              // on the virtual canvas. Used to compute
01263                                              // scrollbar positions.
01264    int               fDirtyLeft, fDirtyTop;  // Top left corner of region to redraw. These
01265                                              // are physical screen coordinates relative to
01266                                              // the clip win, not main window.
01267    int               fDirtyRight, fDirtyBottom;  // Bottom right corner of region to redraw
01268    int               fFlags;                 // Various flags; see below for definitions.
01269    int               fIdind;
01270    int               fInParse;               // Prevent update if parsing
01271    char             *fZGoto;                 // Label to goto right after layout
01272 
01273    SHtmlExtensions_t *fExts;                 // Pointer to user extension data
01274 
01275    THashTable       *fUidTable;              // Hash table for some used string values
01276                                              // like color names, etc.
01277    const char       *fLastUri;               // Used in HandleMotion
01278    int               fExiting;               // True if the widget is being destroyed
01279 
01280    ClassDef(TGHtml, 0); // HTML widget
01281 };
01282 
01283 
01284 // Flag bits "flags" field of the Html widget:
01285 //
01286 // REDRAW_PENDING         An idle handler has already been queued to
01287 //                        call the TGHtml::Redraw() method.
01288 //
01289 // GOT_FOCUS              This widget currently has input focus.
01290 //
01291 // HSCROLL                Horizontal scrollbar position needs to be
01292 //                        recomputed.
01293 //
01294 // VSCROLL                Vertical scrollbar position needs to be
01295 //                        recomputed.
01296 //
01297 // RELAYOUT               We need to reposition every element on the
01298 //                        virtual canvas. (This happens, for example,
01299 //                        when the size of the widget changes and we
01300 //                        need to recompute the line breaks.)
01301 //
01302 // RESIZE_ELEMENTS        We need to recompute the size of every element.
01303 //                        This happens, for example, when the fonts
01304 //                        change.
01305 //
01306 // REDRAW_FOCUS           We need to repaint the focus highlight border.
01307 //
01308 // REDRAW_TEXT            Everything in the clipping window needs to be redrawn.
01309 //
01310 // STYLER_RUNNING         There is a call to HtmlAddStyle() in process.
01311 //                        Used to prevent a recursive call to HtmlAddStyle().
01312 //
01313 // INSERT_FLASHING        True if there is a timer scheduled that will toggle
01314 //                        the state of the insertion cursor.
01315 //
01316 // REDRAW_IMAGES          One or more TGHtmlImageMarkup objects have their
01317 //                        redrawNeeded flag set.
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 // Macros to set, clear or test bits of the "flags" field.
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 // No coordinate is ever as big as this number
01343 
01344 #define LARGE_NUMBER 100000000
01345 
01346 
01347 // Default values for configuration options
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 // Messages generated by the HTML widget
01380 /*
01381 class TGHtmlMessage : public OWidgetMessage {
01382 public:
01383   TGHtmlMessage(int t, int a, int i, const char *u, int rx, int ry) :
01384     OWidgetMessage(t, a, i) {
01385       uri = u;
01386       x_root = rx;
01387       y_root = ry;
01388     }
01389 
01390 public:
01391   const char *uri;
01392   //ORectangle bbox;
01393   int x_root, y_root;
01394 };
01395 */
01396 
01397 #endif  // ROOT_TGHtml

Generated on Tue Jul 5 14:22:15 2011 for ROOT_528-00b_version by  doxygen 1.5.1