00001
00002
00003 #ifndef _GHTML_H
00004 #define _GHTML_H
00005
00006 #include "GMap.h"
00007 #include "GDocView.h"
00008
00009 class GTag;
00010 class GFontCache;
00011
00013 class GHtmlStatic
00014 {
00015 friend class GHtmlStaticInst;
00016 static GHtmlStatic *Inst;
00017
00018 public:
00019 int Refs;
00020 GMap<char16*,int> VarMap;
00021 GMap<char*,int> StyleMap;
00022 GMap<char*,int> ColourMap;
00023
00024 GHtmlStatic();
00025 ~GHtmlStatic();
00026 };
00027
00029 class GHtmlStaticInst
00030 {
00031 public:
00032 GHtmlStatic *Static;
00033
00034 GHtmlStaticInst()
00035 {
00036 if (NOT GHtmlStatic::Inst)
00037 {
00038 GHtmlStatic::Inst = NEW(GHtmlStatic);
00039 }
00040 if (GHtmlStatic::Inst)
00041 {
00042 GHtmlStatic::Inst->Refs++;
00043 }
00044 Static = GHtmlStatic::Inst;
00045 }
00046
00047 ~GHtmlStaticInst()
00048 {
00049 if (GHtmlStatic::Inst)
00050 {
00051 GHtmlStatic::Inst->Refs--;
00052 if (GHtmlStatic::Inst->Refs == 0)
00053 {
00054 DeleteObj(GHtmlStatic::Inst);
00055 }
00056 }
00057 }
00058 };
00059
00073 class GHtml :
00074 public GDocView,
00075 public ResObject
00076 {
00077 friend class GTag;
00078 friend class GFlowRegion;
00079 class GHtmlPrivate *d;
00080
00081
00082 GFontCache *FontCache;
00083 GTag *Tag;
00084 GTag *Cursor;
00085 GTag *Selection;
00086 List<GTag> OpenTags;
00087 char *Source;
00088 char *DocCharSet;
00089 char IsHtml;
00090 int ViewWidth;
00091 GToolTip Tip;
00092 GTag *PrevTip;
00093 GMap<char*,char*> CssMap;
00094
00095
00096 GSurface *MemDC;
00097
00098
00099 void _New();
00100 void _Delete();
00101 GFont *DefFont();
00102 GTag *GetOpenTag(char *Tag);
00103 void Parse();
00104 void AddCss(char *Css);
00105 int ScrollY();
00106
00107 public:
00108 GHtml(int Id, int x, int y, int cx, int cy, GDocumentEnv *system = 0);
00109 ~GHtml();
00110
00111
00112
00114 GTag *GetTagByPos(int x, int y, int *Index);
00115
00116
00117
00119 bool Copy();
00121 bool HasSelection();
00123 void UnSelectAll();
00125 void SelectAll();
00127 char *GetSelection();
00128
00129
00130 void SetLoadImages(bool i);
00131
00132
00133
00135 bool Name(char *s);
00137 char *Name();
00138
00139
00140 void OnPaint(GSurface *pDC);
00141 void OnMouseClick(GMouse &m);
00142 void OnMouseMove(GMouse &m);
00143 void OnMouseWheel(double Lines);
00144 bool OnKey(GKey &k);
00145 int OnNotify(GView *c, int f);
00146 void OnPosChange();
00147 void OnPulse();
00148 int OnEvent(GMessage *Msg);
00149 char *GetMimeType() { return "text/html"; }
00150 };
00151
00153 enum CssStyle
00154 {
00155 CSS_NULL = 0,
00156
00157
00158 CSS_COLOUR,
00159 CSS_BACKGROUND,
00160 CSS_BACKGROUND_COLOUR,
00161 CSS_BACKGROUND_REPEAT,
00162
00163
00164 CSS_FONT,
00165 CSS_FONT_SIZE,
00166 CSS_FONT_WEIGHT,
00167 CSS_FONT_FAMILY,
00168 CSS_FONT_STYLE,
00169
00170
00171 CSS_WIDTH,
00172 CSS_HEIGHT,
00173
00174
00175 CSS_MARGIN,
00176 CSS_MARGIN_LEFT,
00177 CSS_MARGIN_RIGHT,
00178 CSS_MARGIN_TOP,
00179 CSS_MARGIN_BOTTOM,
00180
00181
00182 CSS_PADDING,
00183 CSS_PADDING_LEFT,
00184 CSS_PADDING_TOP,
00185 CSS_PADDING_RIGHT,
00186 CSS_PADDING_BOTTOM,
00187
00188
00189 CSS_BORDER,
00190 CSS_BORDER_LEFT,
00191 CSS_BORDER_TOP,
00192 CSS_BORDER_RIGHT,
00193 CSS_BORDER_BOTTOM,
00194
00195
00196 CSS_ALIGN,
00197 CSS_VERTICAL_ALIGN,
00198 CSS_TEXT_ALIGN,
00199 };
00200
00202 enum CssAlign
00203 {
00204 AlignInherit,
00205 AlignLeft,
00206 AlignCenter,
00207 AlignRight,
00208 AlignJustify,
00209 AlignTop,
00210 AlignMiddle,
00211 AlignBottom,
00212 };
00213
00215 enum CssBackgroundRepeat
00216 {
00217 BgInherit,
00218 BgRepeat,
00219 BgRepeatX,
00220 BgRepeatY,
00221 BgNoRepeat,
00222 };
00223
00224
00225 #endif