00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef INC_MI32_HTMLELEMENT_H
00024 #define INC_MI32_HTMLELEMENT_H
00025
00026 #ifndef INC_MI32_RECT_H
00027 #include <mi32/rect.h>
00028 #endif
00029
00030 #ifndef INC_MI32_HTMLSTYLE_H
00031 #include <mi32/htmlstyle.h>
00032 #endif
00033
00034 #ifndef INC_MAP
00035 #define INC_MAP
00036 #include <map>
00037 #endif
00038
00039 #ifndef GENERATING_DOXYGEN_OUTPUT
00040 class MISTRING;
00041 class STRUTF8;
00042 class XMLNODE;
00043 class REGION2D;
00044 class TRANS2D_AFFINE;
00045 namespace MGD {
00046 class DEVICE;
00047 class CONTEXT;
00048 }
00049 namespace HTML {
00050 class HTMLDOC;
00051 class STYLESHEET;
00052 struct INLINE_POS;
00053 }
00054 #endif
00055
00056 namespace HTML {
00057
00058 class ELEMENT {
00059 public:
00060
00061 enum STATE {
00062 STATE_Normal = 0,
00063 STATE_Hover,
00064 STATE_Active,
00065 STATE_Link,
00066 STATE_NUMSTATES
00067 };
00068
00069 ELEMENT (
00070 HTMLDOC* doc,
00071 XMLNODE* node
00072 );
00073
00074 virtual ~ELEMENT();
00075
00077 ERRVALUE DoLayout (
00078 MGD::CONTEXT* gc,
00079 double MaxWidth,
00080 DPOINT2D& pt,
00081 REGION2D& Container,
00082 DRECT2D& Extents
00083 );
00084
00087 void DoLayoutPass2 (
00088 MGD::CONTEXT* gc,
00089 DPOINT2D& AbsPos
00090 );
00091
00093 void Draw (
00094 MGD::CONTEXT* gc,
00095 const DPOINT2D& pos,
00096 const DRECT2D* clip = 0
00097 );
00098
00099
00100 void AddToRegion (
00101 REGION2D& region,
00102 const DPOINT2D& pos,
00103 bool bOnlyIfDirty
00104 );
00105
00108 ELEMENT* FindChild (
00109 const DPOINT2D& pt
00110 );
00111
00114 const DRECT2D& GetExtents (
00115 ) const { return m_Extents; }
00116
00117 double GetIntrinsicHeight (
00118 ) const { return v_GetIntrinsicHeight(); }
00119
00120 double GetIntrinsicWidth (
00121 ) const { return v_GetIntrinsicWidth(); }
00122
00125 double GetHeight (
00126 ) const { return m_Height; }
00127
00128 XMLNODE* GetNode (
00129 ) const { return m_node; }
00130
00133 double GetWidth (
00134 ) const { return m_Width; }
00135
00136
00137
00138 const DPOINT2D& GetPos (
00139 ) const { return m_Pos; }
00140
00141
00142 void GetRegion (
00143 REGION2D& region,
00144 bool bRootRelative = true
00145 );
00146
00147 const STYLE* GetStyle (
00148 STYLE::PSEUDO pseudo = STYLE::PSEUDO_CurrentState
00149 ) const;
00150
00151 const ELEMENT* GetParent() const;
00152 ELEMENT* GetParent();
00153 const ELEMENT* GetFirstChild() const;
00154 ELEMENT* GetFirstChild();
00155
00156 const ELEMENT* GetNext() const;
00157 ELEMENT* GetNext();
00158
00161 bool IsEmpty (
00162 ) const;
00163
00165 bool IsHidden (
00166 ) const { return v_IsHidden(); }
00167
00170 void SetStyle (
00171 STYLE* style
00172 );
00173
00174 void SetState (
00175 STATE state
00176 );
00177
00178 #ifndef GENERATING_DOXYGEN_OUTPUT
00179
00180
00181
00182
00184 const HTMLDOC* GetDoc (
00185 ) const { return m_Doc; }
00186
00189 void SetHeight (
00190 double height
00191 ) { m_Height = height; }
00192
00195 void SetWidth (
00196 double width
00197 ) { m_Width = width; }
00198
00199 void SetPos (
00200 const DPOINT2D& pt
00201 ) { m_Pos = pt; }
00202
00203
00204
00205 void ShrinkWidth (
00206 double WidthDelta
00207 );
00208
00209 void ShrinkToNaturalWidth (
00210 double LayoutWidth
00211 );
00212
00213
00214
00215 void SetNeedRedraw (
00216 );
00217
00218
00219
00220 INT32 GetCounter (
00221 const MISTRING& name
00222 );
00223
00224 void IncrementCounter (
00225 const MISTRING& name
00226 );
00227
00228 void ResetCounter (
00229 const MISTRING& name
00230 );
00231 #endif
00232
00233 #ifndef GENERATING_DOXYGEN_OUTPUT
00234 protected:
00235 #ifdef DEBUG
00236
00237
00238
00239 const char* m_tag;
00240 const MIUNICODE* m_content;
00241 #endif
00242 double m_Height;
00243 double m_Width;
00244 STATE m_State;
00245
00246 const MGD::DEVICE* LoadImage (
00247 const MISTRING& src
00248 );
00249
00250
00251
00252 void AttributeToCSS (
00253 const char* cssname,
00254 const STRUTF8& value
00255 );
00256
00257
00258
00259 bool ContainsPoint (
00260 const DPOINT2D& pt
00261 ) const { return v_ContainsPoint(pt); }
00262
00263
00264
00265
00266
00267
00268
00269 ERRVALUE ExpandContainer (
00270 REGION2D& Container,
00271 MGD::CONTEXT* gc,
00272 double Width,
00273 double Height
00274 );
00275
00278 void FillBackground (
00279 MGD::CONTEXT* context,
00280 const DRECT2D& rect
00281 );
00282
00293 ERRVALUE GetAvailableRect (
00294 REGION2D& Region,
00295 MGD::CONTEXT* gc,
00296 double MaxWidth,
00297 const DRECT2D& DesiredRect,
00298 DRECT2D& AvailableRect,
00299 bool bWidestPossible = true
00300 );
00301
00302 void GetInlinePos (
00303 SIMPLE_ARRAY<INLINE_POS*>& positions
00304 ) { v_GetInlinePos(positions); }
00305
00306 double GetRotAngle (
00307 ) const;
00308
00309 const TRANS2D_AFFINE& GetTransAffine (
00310 ) const;
00311
00312 void SetState (
00313 STATE state,
00314 bool bPropagateToParent,
00315 bool bPropagateToChildren
00316 );
00317
00318
00319
00320 virtual bool v_ContainsPoint (
00321 const DPOINT2D& pt
00322 ) const;
00323
00324 virtual ERRVALUE v_DoLayout (
00325 MGD::CONTEXT* gc,
00326 double MaxWidth,
00327 DPOINT2D& pt,
00328 REGION2D& Container,
00329 DRECT2D& Extents
00330 );
00331
00332
00333
00334 virtual void v_Draw (
00335 MGD::CONTEXT* gc,
00336 const DPOINT2D& pos
00337 );
00338
00343 virtual bool v_IsHidden (
00344 ) const;
00345
00346
00347 private:
00348 friend class HTMLDOC;
00349
00350 XMLNODE* m_node;
00351 HTMLDOC* m_Doc;
00352 mutable STYLE* m_Styles[STATE_NUMSTATES][STYLE::PSEUDO_NUMPSEUDO];
00353 DPOINT2D m_Pos;
00354 DPOINT2D m_ChildOffset;
00355 DRECT2D m_Extents;
00356 bool m_bNeedRedraw;
00357 bool m_bHasBackground;
00358 INT32 m_ElemNum;
00359
00360 typedef std::map<MISTRING, INT32> COUNTERMAP;
00361 COUNTERMAP m_Counters;
00362
00363 static int CompareZOrder (ELEMENT**, ELEMENT**, void*);
00364 #endif
00365
00366 virtual void v_GetInlinePos (
00367 SIMPLE_ARRAY<INLINE_POS*>& positions
00368 );
00369
00370 virtual double v_GetIntrinsicHeight (
00371 ) const;
00372
00373 virtual double v_GetIntrinsicWidth (
00374 ) const;
00375
00376 };
00377
00378 }
00379
00380
00381 #endif