]>
git.saurik.com Git - wxWidgets.git/blob - src/html/mod_list.cpp
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxHtml module for lists
4 // Author: Vaclav Slavik
5 // Copyright: (c) 1999 Vaclav Slavik
6 // Licence: wxWindows Licence
7 /////////////////////////////////////////////////////////////////////////////
12 #include <wx/html/forcelink.h>
13 #include <wx/html/mod_templ.h>
15 #include <wx/html/htmlcell.h>
17 FORCE_LINK_ME(mod_list
)
20 //-----------------------------------------------------------------------------
22 //-----------------------------------------------------------------------------
24 class wxHtmlListmarkCell
: public wxHtmlCell
29 wxHtmlListmarkCell(wxDC
*dc
, const wxColour
& clr
);
30 void Draw(wxDC
& dc
, int x
, int y
, int view_y1
, int view_y2
);
33 wxHtmlListmarkCell::wxHtmlListmarkCell(wxDC
* dc
, const wxColour
& clr
) : wxHtmlCell(), m_Brush(clr
, wxSOLID
)
35 m_Width
= dc
-> GetCharWidth();
36 m_Height
= dc
-> GetCharHeight();
42 void wxHtmlListmarkCell::Draw(wxDC
& dc
, int x
, int y
, int view_y1
, int view_y2
)
45 dc
.DrawEllipse(x
+ m_PosX
+ m_Width
/ 4, y
+ m_PosY
+ m_Height
/ 4, m_Width
/ 2, m_Width
/ 2);
46 wxHtmlCell::Draw(dc
, x
, y
, view_y1
, view_y2
);
52 //-----------------------------------------------------------------------------
54 //-----------------------------------------------------------------------------
57 TAG_HANDLER_BEGIN(OLULLI
, "OL,UL,LI")
61 // this is number of actual item of list or 0 for dots
63 TAG_HANDLER_CONSTR(OLULLI
)
70 wxHtmlContainerCell
*c
;
73 if (tag
.GetName() == "LI") {
74 if (!tag
.IsEnding()) {
75 m_WParser
-> CloseContainer();
76 m_WParser
-> CloseContainer();
78 c
= m_WParser
-> OpenContainer();
79 c
-> SetWidthFloat(2 * m_WParser
-> GetCharWidth(), HTML_UNITS_PIXELS
);
80 c
-> SetAlignHor(HTML_ALIGN_RIGHT
);
82 c
-> InsertCell(new wxHtmlListmarkCell(m_WParser
-> GetDC(), m_WParser
-> GetActualColor()));
85 mark
.Printf("%i.", m_Numbering
);
86 c
-> InsertCell(new wxHtmlWordCell(mark
, *(m_WParser
-> GetDC())));
88 m_WParser
-> CloseContainer();
90 c
= m_WParser
-> OpenContainer();
91 c
-> SetIndent(m_WParser
-> GetCharWidth() / 4, HTML_INDENT_LEFT
);
92 c
-> SetWidthFloat(-2 * m_WParser
-> GetCharWidth(), HTML_UNITS_PIXELS
);
94 m_WParser
-> OpenContainer();
96 if (m_Numbering
!= 0) m_Numbering
++;
101 // Begin of List (not-numbered): "UL", "OL"
103 int oldnum
= m_Numbering
;
105 if (tag
.GetName() == "UL") m_Numbering
= 0;
106 else m_Numbering
= 1;
108 c
= m_WParser
-> GetContainer();
109 if (c
-> GetFirstCell() != NULL
) {
110 m_WParser
-> CloseContainer();
111 m_WParser
-> OpenContainer();
112 c
= m_WParser
-> GetContainer();
114 c
-> SetAlignHor(HTML_ALIGN_LEFT
);
115 c
-> SetIndent(2 * m_WParser
-> GetCharWidth(), HTML_INDENT_LEFT
);
116 m_WParser
-> OpenContainer() -> SetAlignVer(HTML_ALIGN_TOP
);
118 m_WParser
-> OpenContainer();
119 m_WParser
-> OpenContainer();
121 m_WParser
-> CloseContainer();
123 m_WParser
-> CloseContainer();
124 m_WParser
-> CloseContainer();
125 m_WParser
-> CloseContainer();
126 m_WParser
-> OpenContainer();
128 m_Numbering
= oldnum
;
133 TAG_HANDLER_END(OLULLI
)
136 TAGS_MODULE_BEGIN(List
)
138 TAGS_MODULE_ADD(OLULLI
)
140 TAGS_MODULE_END(List
)