00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 #ifndef INC_MI32_HTMLSTYLE_H
00037 #define INC_MI32_HTMLSTYLE_H
00038
00039 #ifndef INC_MI32_CSSPROPERTIES_H
00040 #include <mi32/cssproperties.h>
00041 #endif
00042
00043 #ifndef INC_MI32_ELEMSTYL_H
00044 #include <mi32/elemstyl.h>
00045 #endif
00046
00047 #ifndef INC_MI32_MISTRING_H
00048 #include <mi32/mistring.h>
00049 #endif
00050
00051 #ifndef INC_MI32_SCRNUNIT_H
00052 #include <mi32/scrnunit.h>
00053 #endif
00054
00055 #ifndef INC_MGUI_CURSORID_H
00056 #include <mgui/cursorid.h>
00057 #endif
00058
00059 #ifndef INC_MI32_HTMLMEASUREMENT_H
00060 #include <mi32/htmlmeasurement.h>
00061 #endif
00062
00063 #ifndef INC_MI32_ENUM_H
00064 #include <mi32/htmlenum.h>
00065 #endif
00066
00067
00068 class STRUTF8;
00069 namespace MGD {
00070 class CONTEXT;
00071 }
00072
00073 namespace HTML {
00074 class STYLE;
00075 class ELEMENT;
00076
00077 #ifndef GENERATING_DOXYGEN_OUTPUT
00078 class STYLESHEET;
00079 struct INLINE_POS;
00080 #endif
00081
00083 class BORDER {
00084 public:
00085 enum TYPE {
00086 TYPE_None = 0,
00087 TYPE_Dotted,
00088 TYPE_Dashed,
00089 TYPE_Solid,
00090 TYPE_Double,
00091 TYPE_Groove,
00092 TYPE_Ridge,
00093 TYPE_Inset,
00094 TYPE_Outset
00095 };
00096
00097 enum SIDE {
00098 SIDE_Top,
00099 SIDE_Bottom,
00100 SIDE_Left,
00101 SIDE_Right
00102 };
00103
00104 BORDER();
00105 BORDER(const BORDER&);
00106
00107 bool operator==(const BORDER& rhs) const;
00108 bool operator!=(const BORDER& rhs) const;
00109
00110 void Combine (
00111 const BORDER& rhs
00112 );
00113
00114 void Draw (
00115 MGD::CONTEXT* gc,
00116 SIDE side,
00117 INT32 x1,
00118 INT32 y1,
00119 INT32 x2,
00120 INT32 y2,
00121 const ELEMENT* Element,
00122 const BORDER& PrevBorder,
00123 const BORDER& NextBorder
00124 ) const;
00125
00126 const COLOR& GetColor (
00127 ) const { return m_Color; }
00128
00129 const MEASUREMENT& GetWidth (
00130 ) const { return m_Width; }
00131
00132 const ENUM<TYPE>& GetType (
00133 ) const { return m_Type; }
00134
00135 bool IsColorSet (
00136 ) const { return m_bColorSet; }
00137
00139 bool IsSet (
00140 ) const { return (m_Type.IsSet() || IsColorSet() || m_Width.IsSet()); }
00141
00142 #ifndef GENERATING_DOXYGEN_OUTPUT
00143 private:
00144 friend class STYLE;
00145
00146 void Parse (
00147 const char* value,
00148 bool bWidth,
00149 bool bType,
00150 bool bColor
00151 );
00152
00153 COLOR m_Color;
00154 MEASUREMENT m_Width;
00155 ENUM<TYPE> m_Type;
00156 bool m_bColorSet;
00157
00158 #endif
00159 };
00160
00161
00164 class STYLE {
00165 public:
00166
00167 enum PSEUDO {
00168 PSEUDO_None = 0,
00169 PSEUDO_CurrentState,
00170 PSEUDO_FirstChild,
00171 PSEUDO_Hover,
00172 PSEUDO_Active,
00173 PSEUDO_Link,
00174 PSEUDO_Visited,
00175 PSEUDO_Before,
00176 PSEUDO_After,
00177 PSEUDO_FirstLine,
00178 PSEUDO_FirstLetter,
00179 PSEUDO_NUMPSEUDO
00180 };
00181
00182 enum BORDER_COLLAPSE {
00183 BORDER_COLLAPSE_Separate = 0,
00184 BORDER_COLLAPSE_Collapse = 1
00185 };
00186
00187 enum EMPTY_CELLS {
00188 EMPTY_CELLS_Hide = 0,
00189 EMPTY_CELLS_Show = 1
00190 };
00191
00192 enum BACKGROUND_REPEAT {
00193 BACKGROUND_Repeat = 0,
00194 BACKGROUND_NoRepeat,
00195 BACKGROUND_RepeatX,
00196 BACKGROUND_RepeatY
00197 };
00198
00199 enum BACKGROUND_POS {
00200 BACKGROUND_POS_Numeric = 0,
00201 BACKGROUND_POS_Top,
00202 BACKGROUND_POS_Bottom,
00203 BACKGROUND_POS_Left,
00204 BACKGROUND_POS_Right,
00205 BACKGROUND_POS_Center
00206 };
00207
00208 enum DISPLAY {
00209 DISPLAY_Inline = 0,
00210 DISPLAY_Block,
00211 DISPLAY_None,
00212 DISPLAY_InlineBlock,
00213 DISPLAY_ListItem,
00214 DISPLAY_Table,
00215 DISPLAY_TableRow,
00216 DISPLAY_TableHeaderGroup,
00217 DISPLAY_TableRowGroup,
00218 DISPLAY_TableFooterGroup,
00219 DISPLAY_TableColumn,
00220 DISPLAY_TableColumnGroup,
00221 DISPLAY_TableCell,
00222 DISPLAY_TableCaption,
00223 DISPLAY_Marker
00224 };
00225
00226 enum LISTPOSITION {
00227 LISTPOSITION_Outside = 0,
00228 LISTPOSITION_Inside
00229 };
00230
00231 enum LISTTYPE {
00232 LISTTYPE_None = 0,
00233 LISTTYPE_Disc,
00234 LISTTYPE_Circle,
00235 LISTTYPE_Square,
00236 LISTTYPE_Decimal,
00237 LISTTYPE_LowerRoman,
00238 LISTTYPE_UpperRoman,
00239 LISTTYPE_LowerAlpha,
00240 LISTTYPE_UpperAlpha
00241 };
00242
00243 enum CSSOVERFLOW {
00244 OVERFLOW_Visible = 0,
00245 OVERFLOW_Hidden
00246 };
00247
00248
00249 enum POSITION {
00250 POSITION_Static = 0,
00251 POSITION_Absolute,
00252 POSITION_Relative
00253 };
00254
00255 enum VISIBILITY {
00256 VISIBILITY_Inherit = 0,
00257 VISIBILITY_Visible = 1,
00258 VISIBILITY_Hidden
00259 };
00260
00261 enum WHITESPACE {
00262 WHITESPACE_Normal = 0,
00263 WHITESPACE_NoWrap,
00264 WHITESPACE_Pre
00265 };
00266
00267 enum CLEAR {
00268 CLEAR_None = 0,
00269 CLEAR_Left,
00270 CLEAR_Right,
00271 CLEAR_Both
00272 };
00273
00274 enum TEXT_TRANSFORM {
00275 TEXT_TRANSFORM_None = 0,
00276 TEXT_TRANSFORM_Capitalize,
00277 TEXT_TRANSFORM_UpperCase,
00278 TEXT_TRANSFORM_LowerCase
00279 };
00280
00281 enum FLOAT {
00282 FLOAT_None = 0,
00283 FLOAT_Left,
00284 FLOAT_Right
00285 };
00286
00287 enum VALIGN {
00288 VALIGN_Baseline = 0,
00289 VALIGN_Auto,
00290 VALIGN_Sub,
00291 VALIGN_Super,
00292 VALIGN_Top,
00293 VALIGN_Middle,
00294 VALIGN_Bottom,
00295 VALIGN_TextTop,
00296 VALIGN_TextBottom,
00297 VALIGN_Numeric
00298 };
00299
00300 class EDGE {
00301 public:
00302 EDGE(BORDER::SIDE side);
00303 EDGE(const EDGE&);
00304
00305
00306 void Combine (
00307 const EDGE&
00308 );
00309
00310
00311 const BORDER& GetBorder (
00312 ) const { return m_Border; }
00313
00314
00315 const MEASUREMENT& GetMargin (
00316 ) const { return m_Margin; }
00317
00318
00319 const MEASUREMENT& GetOffset (
00320 ) const { return m_Offset; }
00321
00322
00323 const MEASUREMENT& GetPadding (
00324 ) const { return m_Padding; }
00325
00328 double GetWidth (
00329 MGD::CONTEXT* gc,
00330 const ELEMENT*
00331 ) const;
00332
00335 bool IsInheritable (
00336 ) const;
00337
00342 bool CompareSize (
00343 const EDGE& other
00344 ) const;
00345
00346 #ifndef GENERATING_DOXYGEN_OUTPUT
00347 private:
00348 friend class STYLE;
00349 BORDER m_Border;
00350 MEASUREMENT m_Margin;
00351 MEASUREMENT m_Padding;
00352 MEASUREMENT m_Offset;
00353 #endif
00354
00355 };
00356
00357 class SELECTOR {
00358 public:
00359 SELECTOR();
00360 SELECTOR(const MISTRING&);
00361 SELECTOR(const SELECTOR&);
00362 SELECTOR& operator=(const SELECTOR&rhs);
00363 bool operator==(const SELECTOR& rhs) const;
00364 bool operator!=(const SELECTOR& rhs) const;
00365 ~SELECTOR();
00366
00370 void GetText (
00371 MISTRING& str
00372 ) const;
00373
00375 bool IsValid (
00376 ) const;
00377
00378 STYLE::PSEUDO GetPseudo (
00379 ) const;
00380 #ifndef GENERATING_DOXYGEN_OUTPUT
00381 private:
00382 friend class STYLESHEET;
00383 class PRIV;
00384 PRIV* m_priv;
00385 #endif
00386 };
00387
00389 STYLE(const char* selector = 0, const char* css = 0);
00390 STYLE(const STYLE&);
00391
00393 void AddRef (
00394 );
00395
00399 void Combine (
00400 const STYLE& rhs
00401 );
00402
00406 bool IsInheritable (
00407 ) const;
00408
00409
00416 void GenerateCSS (
00417 MISTRING& css,
00418 bool bInline = true,
00419 char quote = '\''
00420 ) const;
00421
00422
00423 const MEASUREMENT& GetBorderSpacing (
00424 ) const { return m_BorderSpacing; }
00425
00426 const MEASUREMENT& GetMeasurement (
00427 CSS_PROPERTY property
00428 ) const;
00429
00430 const TEXTSTYLEDIFF& GetTextStyle (
00431 ) const { return m_TextStyle; }
00432
00433
00434 void GetTextStyle (
00435 TEXTSTYLE& TextStyle,
00436 MGD::CONTEXT* gc,
00437 const ELEMENT* Element
00438 ) const;
00439
00440 void Combine (
00441 const EDGE& rhs
00442 );
00443
00448 bool CompareSize (
00449 const STYLE& other
00450 ) const;
00451
00452
00453
00454 const EDGE& GetEdge (
00455 int num
00456 ) const;
00457
00458
00459
00460 EDGE& GetEdge (
00461 int num
00462 );
00463
00464 const EDGE& GetLeftEdge (
00465 ) const { return m_Left; }
00466
00467 const EDGE& GetRightEdge (
00468 ) const { return m_Right; }
00469
00470 const EDGE& GetTopEdge (
00471 ) const { return m_Top; }
00472
00473 const EDGE& GetBottomEdge (
00474 ) const { return m_Bottom; }
00475
00476 const MEASUREMENT& GetHeight (
00477 ) const { return m_Height; }
00478
00479 const MEASUREMENT& GetWidth (
00480 ) const { return m_Width; }
00481
00482 const MEASUREMENT& GetVAlignNum (
00483 ) const { return m_VAlignNum; }
00484
00485
00486 const MEASUREMENT& GetFontSize (
00487 ) const { return m_FontSize; }
00488
00489 const MEASUREMENT& GetLineHeight (
00490 ) const { return m_LineHeight; }
00491
00492
00493 const MEASUREMENT& GetIndent (
00494 ) const { return m_Indent; }
00495
00496 INT32 GetTabStop (
00497 ) const { return m_TabStop; }
00498
00499 INT32 GetZIndex (
00500 ) const { return m_ZIndex; }
00501
00502 const MISTRING& GetBackgroundImage (
00503 ) const { return m_BackgroundImage; }
00504
00505 const MISTRING& GetListStyleImage (
00506 ) const { return m_ListStyleImage; }
00507
00508 const COLOR& GetBGColor (
00509 ) const { return m_BGColor; }
00510
00511 const ENUM<BACKGROUND_POS>& GetBackgroundPosX (
00512 ) const { return m_BackgroundPosX; }
00513
00514 const MEASUREMENT& GetBackgroundPosNumX (
00515 ) const { return m_BackgroundPosNumX; }
00516
00517 const ENUM<BACKGROUND_POS>& GetBackgroundPosY (
00518 ) const { return m_BackgroundPosY; }
00519
00520 const MEASUREMENT& GetBackgroundPosNumY (
00521 ) const { return m_BackgroundPosNumY; }
00522
00523 const ENUM<BACKGROUND_REPEAT>& GetBackgroundRepeat (
00524 ) const { return m_BackgroundRepeat; }
00525
00526 const ENUM<TEXT_TRANSFORM>& GetTextTransform (
00527 ) const { return m_TextTransform; }
00528
00529 const ENUM<BORDER_COLLAPSE>& GetBorderCollapse (
00530 ) const { return m_BorderCollapse; }
00531
00532 const ENUM<CLEAR>& GetClear (
00533 ) const { return m_Clear; }
00534
00535 const MISTRING& GetContent (
00536 ) const { return m_Content; }
00537
00538 const MISTRING& GetCounterIncrement (
00539 ) const { return m_CounterIncrement; }
00540
00541 const MISTRING& GetCounterReset (
00542 ) const { return m_CounterReset; }
00543
00544 #ifdef USE_MGUI
00545 const ENUM<MGUI::CURSORID>& GetCursor (
00546 ) const { return m_Cursor; }
00547 #endif
00548
00549 const ENUM<DISPLAY>& GetDisplay (
00550 ) const { return m_Display; }
00551
00552 const ENUM<EMPTY_CELLS>& GetEmptyCells (
00553 ) const { return m_EmptyCells; }
00554
00555 const ENUM<FLOAT>& GetFloat (
00556 ) const { return m_Float; }
00557
00558 const ENUM<LISTPOSITION>& GetListPosition (
00559 ) const { return m_ListPosition; }
00560
00561 const ENUM<LISTTYPE>& GetListType (
00562 ) const { return m_ListType; }
00563
00564 const MEASUREMENT& GetMarkerOffset (
00565 ) const { return m_MarkerOffset; }
00566
00567 bool GetMinimizeWidth (
00568 ) const { return m_bMinimizeWidth; }
00569
00570 const MISTRING& GetOpenTypeFeatures (
00571 ) const { return m_OpenTypeFeatures; }
00572
00573 const ENUM<CSSOVERFLOW>& GetOverflow (
00574 ) const { return m_Overflow; }
00575
00576 const ENUM<POSITION>& GetPosition (
00577 ) const { return m_Position; }
00578
00579 const MISTRING& GetQuotes (
00580 ) const { return m_Quotes; }
00581
00582 const SELECTOR& GetSelector (
00583 ) const { return m_selector; }
00584
00585 const ENUM<VALIGN>& GetVAlign (
00586 ) const { return m_VAlign; }
00587
00588 const ENUM<VISIBILITY>& GetVisibility (
00589 ) const { return m_Visibility; }
00590
00591 const ENUM<WHITESPACE>& GetWhitespace (
00592 ) const { return m_Whitespace; }
00593
00594 bool IsBGColorSet (
00595 ) const { return m_bBGColorSet; }
00596
00597 bool IsMinimizeWidthSet (
00598 ) const { return m_bMinimizeWidthSet; }
00599
00601 bool IsShared (
00602 ) const { return m_bIsShared; }
00603
00605 bool IsSpecialState (
00606 ) const { return m_bSpecialState; }
00607
00612 void Parse(const MISTRING& str);
00613
00616 void ParseTildeCodes (
00617 const MISTRING& codes,
00618 MISTRING& UnhandledCodes
00619 );
00620
00624 void Release (
00625 );
00626
00627 void SetBGColor (
00628 const COLOR& color
00629 ) {
00630 m_BGColor = color;
00631 m_bBGColorSet = true;
00632 }
00633
00634 void SetTextStyle (
00635 const TEXTSTYLE& TextStyle
00636 ) {
00637 m_TextStyle = TextStyle;
00638 m_FontSize.Set(TextStyle.Height, static_cast<SCREENUNIT>(TextStyle.HeightUnits));
00639 m_LineHeight.Set(TextStyle.LineSpace, static_cast<SCREENUNIT>(TextStyle.SpaceUnits));
00640 }
00641
00642 bool ParseFontSize (
00643 const STRUTF8& str
00644 );
00645
00646 bool ParseFontStyle (
00647 const STRUTF8& str
00648 );
00649
00650 bool ParseFontVariant (
00651 const STRUTF8& str
00652 );
00653
00654 bool ParseFontWeight (
00655 const STRUTF8& str
00656 );
00657
00658 void ParseLineHeight (
00659 const STRUTF8& str
00660 );
00661
00662 bool ParseFont (
00663 const MISTRING& mistr
00664 );
00665
00666 #ifndef GENERATING_DOXYGEN_OUTPUT
00667 private:
00668 friend class STYLESHEET;
00669 friend class HTMLDOC;
00670
00671 INT32 m_RefCount;
00672 bool m_bIsShared;
00673
00674 SELECTOR m_selector;
00675 TEXTSTYLEDIFF m_TextStyle;
00676
00677 EDGE m_Left;
00678 EDGE m_Right;
00679 EDGE m_Top;
00680 EDGE m_Bottom;
00681 MEASUREMENT m_Height;
00682 MEASUREMENT m_Width;
00683 MEASUREMENT m_VAlignNum;
00684 MEASUREMENT m_Indent;
00685
00686 MEASUREMENT m_FontSize;
00687 MEASUREMENT m_LineHeight;
00688 MEASUREMENT m_BorderSpacing;
00689 INT32 m_ZIndex;
00690 INT32 m_TabStop;
00691
00692 ENUM<BACKGROUND_POS> m_BackgroundPosX;
00693 MEASUREMENT m_BackgroundPosNumX;
00694 ENUM<BACKGROUND_POS> m_BackgroundPosY;
00695 MEASUREMENT m_BackgroundPosNumY;
00696 ENUM<BACKGROUND_REPEAT> m_BackgroundRepeat;
00697 ENUM<CLEAR> m_Clear;
00698 #ifdef USE_MGUI
00699 ENUM<MGUI::CURSORID> m_Cursor;
00700 #endif
00701 ENUM<DISPLAY> m_Display;
00702 ENUM<EMPTY_CELLS> m_EmptyCells;
00703 ENUM<FLOAT> m_Float;
00704 ENUM<LISTPOSITION> m_ListPosition;
00705 ENUM<LISTTYPE> m_ListType;
00706 ENUM<CSSOVERFLOW> m_Overflow;
00707 ENUM<BORDER_COLLAPSE> m_BorderCollapse;
00708 bool m_bMinimizeWidth;
00709 bool m_bMinimizeWidthSet;
00710 ENUM<POSITION> m_Position;
00711 ENUM<TEXT_TRANSFORM> m_TextTransform;
00712 ENUM<VALIGN> m_VAlign;
00713 ENUM<VISIBILITY> m_Visibility;
00714 ENUM<WHITESPACE> m_Whitespace;
00715 COLOR m_BGColor;
00716 bool m_bBGColorSet;
00717 MISTRING m_BackgroundImage;
00718 MISTRING m_ListStyleImage;
00719 bool m_bSpecialState;
00720
00721 MISTRING m_CounterIncrement;
00722 MISTRING m_CounterReset;
00723 MISTRING m_Content;
00724 MISTRING m_Quotes;
00725 MISTRING m_OpenTypeFeatures;
00726 MEASUREMENT m_MarkerOffset;
00727
00728
00729
00730
00731
00732 STYLE(const STYLE&, bool bInheritable);
00733
00734 void ParseFontStyleFlag (
00735 const char* value,
00736 const char* expected,
00737 UINT32 flag
00738 );
00739
00740 void SetSelector (
00741 const SELECTOR& selector
00742 );
00743
00744 ~STYLE();
00745 #endif // doxygen
00746 };
00747
00748 }
00749
00750
00751 #endif
00752