]>
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/wxprec.h>
27 #include <wx/html/forcelink.h>
28 #include <wx/html/mod_templ.h>
30 #include <wx/html/htmlcell.h>
32 FORCE_LINK_ME(mod_list
)
35 //-----------------------------------------------------------------------------
37 //-----------------------------------------------------------------------------
39 class wxHtmlListmarkCell
: public wxHtmlCell
44 wxHtmlListmarkCell(wxDC
*dc
, const wxColour
& clr
);
45 void Draw(wxDC
& dc
, int x
, int y
, int view_y1
, int view_y2
);
48 wxHtmlListmarkCell::wxHtmlListmarkCell(wxDC
* dc
, const wxColour
& clr
) : wxHtmlCell(), m_Brush(clr
, wxSOLID
)
50 m_Width
= dc
-> GetCharWidth();
51 m_Height
= dc
-> GetCharHeight();
57 void wxHtmlListmarkCell::Draw(wxDC
& dc
, int x
, int y
, int view_y1
, int view_y2
)
60 dc
.DrawEllipse(x
+ m_PosX
+ m_Width
/ 4, y
+ m_PosY
+ m_Height
/ 4, m_Width
/ 2, m_Width
/ 2);
61 wxHtmlCell::Draw(dc
, x
, y
, view_y1
, view_y2
);
67 //-----------------------------------------------------------------------------
69 //-----------------------------------------------------------------------------
72 TAG_HANDLER_BEGIN(OLULLI
, "OL,UL,LI")
76 // this is number of actual item of list or 0 for dots
78 TAG_HANDLER_CONSTR(OLULLI
)
85 wxHtmlContainerCell
*c
;
88 if (tag
.GetName() == "LI") {
89 if (!tag
.IsEnding()) {
90 m_WParser
-> CloseContainer();
91 m_WParser
-> CloseContainer();
93 c
= m_WParser
-> OpenContainer();
94 c
-> SetWidthFloat(2 * m_WParser
-> GetCharWidth(), HTML_UNITS_PIXELS
);
95 c
-> SetAlignHor(HTML_ALIGN_RIGHT
);
97 c
-> InsertCell(new wxHtmlListmarkCell(m_WParser
-> GetDC(), m_WParser
-> GetActualColor()));
100 mark
.Printf("%i.", m_Numbering
);
101 c
-> InsertCell(new wxHtmlWordCell(mark
, *(m_WParser
-> GetDC())));
103 m_WParser
-> CloseContainer();
105 c
= m_WParser
-> OpenContainer();
106 c
-> SetIndent(m_WParser
-> GetCharWidth() / 4, HTML_INDENT_LEFT
);
107 c
-> SetWidthFloat(-2 * m_WParser
-> GetCharWidth(), HTML_UNITS_PIXELS
);
109 m_WParser
-> OpenContainer();
111 if (m_Numbering
!= 0) m_Numbering
++;
116 // Begin of List (not-numbered): "UL", "OL"
118 int oldnum
= m_Numbering
;
120 if (tag
.GetName() == "UL") m_Numbering
= 0;
121 else m_Numbering
= 1;
123 c
= m_WParser
-> GetContainer();
124 if (c
-> GetFirstCell() != NULL
) {
125 m_WParser
-> CloseContainer();
126 m_WParser
-> OpenContainer();
127 c
= m_WParser
-> GetContainer();
129 c
-> SetAlignHor(HTML_ALIGN_LEFT
);
130 c
-> SetIndent(2 * m_WParser
-> GetCharWidth(), HTML_INDENT_LEFT
);
131 m_WParser
-> OpenContainer() -> SetAlignVer(HTML_ALIGN_TOP
);
133 m_WParser
-> OpenContainer();
134 m_WParser
-> OpenContainer();
136 m_WParser
-> CloseContainer();
138 m_WParser
-> CloseContainer();
139 m_WParser
-> CloseContainer();
140 m_WParser
-> CloseContainer();
141 m_WParser
-> OpenContainer();
143 m_Numbering
= oldnum
;
148 TAG_HANDLER_END(OLULLI
)
151 TAGS_MODULE_BEGIN(List
)
153 TAGS_MODULE_ADD(OLULLI
)
155 TAGS_MODULE_END(List
)