]>
git.saurik.com Git - wxWidgets.git/blob - src/html/m_list.cpp
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxHtml module for lists
4 // Author: Vaclav Slavik
6 // Copyright: (c) 1999 Vaclav Slavik
7 // Licence: wxWindows Licence
8 /////////////////////////////////////////////////////////////////////////////
10 #pragma implementation
13 #include "wx/wxprec.h"
17 #if wxUSE_HTML && wxUSE_STREAMS
28 #include "wx/html/forcelnk.h"
29 #include "wx/html/m_templ.h"
31 #include "wx/html/htmlcell.h"
36 //-----------------------------------------------------------------------------
38 //-----------------------------------------------------------------------------
40 class wxHtmlListmarkCell
: public wxHtmlCell
45 wxHtmlListmarkCell(wxDC
*dc
, const wxColour
& clr
);
46 void Draw(wxDC
& dc
, int x
, int y
, int view_y1
, int view_y2
,
47 wxHtmlRenderingInfo
& info
);
49 DECLARE_NO_COPY_CLASS(wxHtmlListmarkCell
)
52 wxHtmlListmarkCell::wxHtmlListmarkCell(wxDC
* dc
, const wxColour
& clr
) : wxHtmlCell(), m_Brush(clr
, wxSOLID
)
54 m_Width
= dc
->GetCharHeight();
55 m_Height
= dc
->GetCharHeight();
61 void wxHtmlListmarkCell::Draw(wxDC
& dc
, int x
, int y
,
62 int WXUNUSED(view_y1
), int WXUNUSED(view_y2
),
63 wxHtmlRenderingInfo
& WXUNUSED(info
))
66 dc
.DrawEllipse(x
+ m_PosX
+ m_Width
/ 3, y
+ m_PosY
+ m_Height
/ 3,
67 (m_Width
/ 3), (m_Width
/ 3));
73 //-----------------------------------------------------------------------------
75 //-----------------------------------------------------------------------------
78 TAG_HANDLER_BEGIN(OLULLI
, "OL,UL,LI")
82 // this is number of actual item of list or 0 for dots
84 TAG_HANDLER_CONSTR(OLULLI
)
91 wxHtmlContainerCell
*c
;
94 if (tag
.GetName() == wxT("LI"))
96 m_WParser
->GetContainer()->SetIndent(0, wxHTML_INDENT_TOP
);
97 // this is to prevent indetation in <li><p> case
98 m_WParser
->CloseContainer();
99 m_WParser
->CloseContainer();
101 c
= m_WParser
->OpenContainer();
102 c
->SetWidthFloat(2 * m_WParser
->GetCharWidth(), wxHTML_UNITS_PIXELS
);
103 if (m_Numbering
== 0)
105 // Centering gives more space after the bullet
106 c
->SetAlignHor(wxHTML_ALIGN_CENTER
);
107 c
->InsertCell(new wxHtmlListmarkCell(m_WParser
->GetDC(), m_WParser
->GetActualColor()));
111 c
->SetAlignHor(wxHTML_ALIGN_RIGHT
);
113 mark
.Printf(wxT("%i."), m_Numbering
);
114 c
->InsertCell(new wxHtmlWordCell(mark
, *(m_WParser
->GetDC())));
116 m_WParser
->CloseContainer();
118 c
= m_WParser
->OpenContainer();
119 c
->SetIndent(m_WParser
->GetCharWidth() / 4, wxHTML_INDENT_LEFT
);
120 c
->SetWidthFloat(-2 * m_WParser
->GetCharWidth(), wxHTML_UNITS_PIXELS
);
122 m_WParser
->OpenContainer();
124 if (m_Numbering
!= 0) m_Numbering
++;
129 // Begin of List (not-numbered): "UL", "OL"
132 int oldnum
= m_Numbering
;
134 if (tag
.GetName() == wxT("UL")) m_Numbering
= 0;
135 else m_Numbering
= 1;
137 c
= m_WParser
->GetContainer();
138 if (c
->GetFirstChild() != NULL
)
140 m_WParser
->CloseContainer();
141 m_WParser
->OpenContainer();
142 c
= m_WParser
->GetContainer();
144 c
->SetAlignHor(wxHTML_ALIGN_LEFT
);
145 c
->SetIndent(2 * m_WParser
->GetCharWidth(), wxHTML_INDENT_LEFT
);
146 m_WParser
->OpenContainer()->SetAlignVer(wxHTML_ALIGN_TOP
);
148 m_WParser
->OpenContainer();
149 m_WParser
->OpenContainer();
152 m_WParser
->GetContainer()->SetIndent(0, wxHTML_INDENT_TOP
);
153 // this is to prevent indetation in <li><p> case
154 m_WParser
->CloseContainer();
156 m_WParser
->CloseContainer();
157 m_WParser
->CloseContainer();
158 m_WParser
->CloseContainer();
159 m_WParser
->OpenContainer();
161 m_Numbering
= oldnum
;
166 TAG_HANDLER_END(OLULLI
)
169 TAGS_MODULE_BEGIN(List
)
171 TAGS_MODULE_ADD(OLULLI
)
173 TAGS_MODULE_END(List
)