00001 #ifndef _GHTML_PRIV_H_
00002 #define _GHTML_PRIV_H_
00003
00004
00005
00006
00007 enum HtmlTag
00008 {
00009 CONTENT,
00010 TAG_UNKNOWN,
00011 TAG_HTML,
00012 TAG_HEAD,
00013 TAG_BODY,
00014 TAG_B,
00015 TAG_I,
00016 TAG_U,
00017 TAG_P,
00018 TAG_BR,
00019 TAG_UL,
00020 TAG_OL,
00021 TAG_LI,
00022 TAG_FONT,
00023 TAG_A,
00024 TAG_TABLE,
00025 TAG_TR,
00026 TAG_TD,
00027 TAG_IMG,
00028 TAG_DIV,
00029 TAG_SPAN,
00030 TAG_CENTER,
00031 TAG_META,
00032 TAG_TBODY,
00033 TAG_STYLE,
00034 TAG_STRONG,
00035 TAG_BLOCKQUOTE,
00036 TAG_PRE,
00037 TAG_H1,
00038 TAG_H2,
00039 TAG_H3,
00040 TAG_H4,
00041 TAG_H5,
00042 TAG_H6,
00043 TAG_HR
00044 };
00045
00046 enum GLengthUnit
00047 {
00048 LengthNull = 0,
00049 LengthPixels,
00050 LengthPercentage,
00051 LengthPoint,
00052 LengthEm,
00053 LengthEx
00054 };
00055
00056 enum TagInfoFlags
00057 {
00058 TI_NONE = 0x00,
00059 TI_NEVER_CLOSES = 0x01,
00060 TI_NO_TEXT = 0x02,
00061 TI_BLOCK = 0x04,
00062 TI_TABLE = 0x08,
00063 };
00064
00065 struct GTagHit
00066 {
00067 GTag *Hit;
00068 class GFlowRect *Block;
00069 int Near;
00070 int Index;
00071 };
00072
00073 struct GInfo
00074 {
00075 public:
00076 HtmlTag Id;
00077 char *Tag;
00078 char *ReattachTo;
00079 int Flags;
00080
00081 bool NeverCloses() { return TestFlag(Flags, TI_NEVER_CLOSES); }
00082 bool NoText() { return TestFlag(Flags, TI_NO_TEXT); }
00083 bool Block() { return TestFlag(Flags, TI_BLOCK); }
00084 };
00085
00086
00087
00088
00089 class GFlowRegion;
00090
00091 class GLength
00092 {
00093 protected:
00094 float d;
00095 float PrevAbs;
00096 GLengthUnit u;
00097
00098 public:
00099 GLength();
00100 GLength(char *s);
00101
00102 bool IsValid();
00103 bool IsDynamic();
00104 float GetPrevAbs() { return PrevAbs; }
00105 operator float();
00106 GLength &operator =(float val);
00107 GLengthUnit GetUnits();
00108 void Set(char *s);
00109 float Get(GFlowRegion *Flow, GFont *Font, bool Lock = false);
00110 };
00111
00112 class GLine : public GLength
00113 {
00114 public:
00115 int LineStyle;
00116 int LineReset;
00117 COLOUR Colour;
00118
00119 GLine();
00120 ~GLine();
00121
00122 GLine &operator =(int i);
00123 void Set(char *s);
00124 };
00125
00126 class GCellStore
00127 {
00128 class Cell
00129 {
00130 public:
00131 int x, y;
00132 GTag *Tag;
00133 };
00134
00135 List<Cell> Cells;
00136
00137 public:
00138 GCellStore(GTag *Table);
00139 ~GCellStore()
00140 {
00141 Cells.DeleteObjects();
00142 }
00143
00144 void GetSize(int &x, int &y);
00145 void GetAll(List<GTag> &All);
00146 GTag *Get(int x, int y);
00147 bool Set(GTag *t);
00148
00149 void Dump();
00150 };
00151
00152 class GFlowRect : public GRect
00153 {
00154 public:
00155 GTag *Tag;
00156 char16 *Text;
00157 int Len;
00158
00159 GFlowRect()
00160 {
00161 Tag = 0;
00162 Text = 0;
00163 Len = 0;
00164 }
00165
00166 ~GFlowRect()
00167 {
00168 }
00169 };
00170
00171 class GArea : public List<GFlowRect>
00172 {
00173 public:
00174 ~GArea();
00175
00176 GRect *TopRect(GRegion *c);
00177 void FlowText(GTag *Tag, GFlowRegion *c, GFont *Font, char16 *Text);
00178 };
00179
00180 class GTag : public ObjProperties
00181 {
00182 static bool Selected;
00183 friend class HtmlEdit;
00184
00185
00186 void _Dump(GStringPipe &Buf, int Depth);
00187 void _TraceOpenTags();
00188
00189
00190 GFont *GetFont();
00191 GFont *NewFont();
00192 int NearestChar(GFlowRect *Fr, int x, int y);
00193 GTag *HasOpenTag(char *t);
00194 GTag *PrevTag();
00195 GRect ChildBounds();
00196 bool GetWidthMetrics(uint16 &Min, uint16 &Max);
00197 void LayoutTable(GFlowRegion *f);
00198 void BoundParents();
00199 bool PeekTag(char *s, char *tag);
00200 GTag *GetTable();
00201 char *NextTag(char *s);
00202 void ZeroTableElements();
00203
00204 COLOUR _Colour(bool Fore);
00205 COLOUR GetFore() { return _Colour(true); }
00206 COLOUR GetBack() { return _Colour(false); }
00207
00208 public:
00209
00210 HtmlTag TagId;
00211 char *Tag;
00212 char *HtmlId;
00213 GInfo *Info;
00214 int TipId;
00215 bool WasClosed;
00216 bool IsBlock;
00217
00218
00219 GHtml *Html;
00220 GTag *Parent;
00221 List<GTag> Tags;
00222
00223 void Attach(GTag *Child, int Idx = -1);
00224 void Detach();
00225
00226
00227 bool Visible;
00228 GLength Width, Height;
00229 GdcPt2 Pos;
00230 GdcPt2 Size;
00231 COLOUR Fore, Back, BorderColour;
00232 CssBackgroundRepeat BackgroundRepeat;
00233 GFont *Font;
00234
00235 GLine BorderLeft;
00236 GLine BorderTop;
00237 GLine BorderRight;
00238 GLine BorderBottom;
00239
00240 GLength MarginLeft;
00241 GLength MarginTop;
00242 GLength MarginRight;
00243 GLength MarginBottom;
00244
00245 GLength PaddingLeft;
00246 GLength PaddingTop;
00247 GLength PaddingRight;
00248 GLength PaddingBottom;
00249
00250 CssAlign AlignX;
00251 CssAlign AlignY;
00252 CssAlign GetAlign(bool x);
00253
00254
00255 GSurface *Image;
00256 void SetImage(char *uri, GSurface *i);
00257 void LoadImages();
00258 void ImageLoaded(char *uri, GSurface *img, int &Used);
00259
00260
00261 GdcPt2 Cell;
00262 GdcPt2 Span;
00263 uint8 CellSpacing;
00264 uint8 CellPadding;
00265
00266 uint16 MinContent, MaxContent;
00267 GCellStore *Cells;
00268 #ifdef _DEBUG
00269 bool Debug;
00270 #endif
00271
00272
00273 int Cursor;
00274 int Selection;
00275 char16 *Text, *PreText;
00276 class GArea TextPos;
00277
00278 GTag(GHtml *h, GTag *p);
00279 ~GTag();
00280
00281
00282 int GetTextStart();
00283 char *Dump();
00284 char16 *CleanText(char *s, int len, bool ConversionAllowed = true, bool KeepWhiteSpace = false);
00285 char *ParseHtml(char *Doc, bool InPreTag = false, bool *BackOut = 0);
00286 char *ParseText(char *Doc);
00287 void SetStyle();
00288 void SetCssStyle(char *Style);
00289 void OnFlow(GFlowRegion *Flow);
00290 void OnPaintBorder(GSurface *pDC);
00291 void OnPaint(GSurface *pDC);
00292 void SetSize(GdcPt2 &s);
00293 void SetTag(char *Tag);
00294 bool GetTagByPos(int x, int y, GTagHit *Hit);
00295 GTag *GetTagByName(char *Name);
00296 void CopyClipboard(GBytePipe &p);
00297 bool IsAnchor(char **Uri);
00298 bool CreateSource(GStringPipe &p, int Depth = 0, bool LastWasBlock = true);
00299
00300
00301 bool OnMouseClick(GMouse &m);
00302 void Invalidate();
00303
00304
00305 int RelX() { return Pos.x + MarginLeft; }
00306 int RelY() { return Pos.y + MarginTop; }
00307 int AbsX();
00308 int AbsY();
00309 GRect GetRect(bool Client = true);
00310
00311
00312 GTag *GetTableCell(int x, int y);
00313 GdcPt2 GetTableSize();
00314 };
00315
00316 #endif