]>
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
);
49 wxHtmlListmarkCell::wxHtmlListmarkCell(wxDC
* dc
, const wxColour
& clr
) : wxHtmlCell(), m_Brush(clr
, wxSOLID
)
51 m_Width
= dc
->GetCharHeight();
52 m_Height
= dc
->GetCharHeight();
58 void wxHtmlListmarkCell::Draw(wxDC
& dc
, int x
, int y
, int WXUNUSED(view_y1
), int WXUNUSED(view_y2
))
61 dc
.DrawEllipse(x
+ m_PosX
+ m_Width
/ 3, y
+ m_PosY
+ m_Height
/ 3,
62 (m_Width
/ 3), (m_Width
/ 3));
68 //-----------------------------------------------------------------------------
70 //-----------------------------------------------------------------------------
73 TAG_HANDLER_BEGIN(OLULLI
, "OL,UL,LI")
77 // this is number of actual item of list or 0 for dots
79 TAG_HANDLER_CONSTR(OLULLI
)
86 wxHtmlContainerCell
*c
;
89 if (tag
.GetName() == wxT("LI"))
91 m_WParser
->GetContainer()->SetIndent(0, wxHTML_INDENT_TOP
);
92 // this is to prevent indetation in <li><p> case
93 m_WParser
->CloseContainer();
94 m_WParser
->CloseContainer();
96 c
= m_WParser
->OpenContainer();
97 c
->SetWidthFloat(2 * m_WParser
->GetCharWidth(), wxHTML_UNITS_PIXELS
);
100 // Centering gives more space after the bullet
101 c
->SetAlignHor(wxHTML_ALIGN_CENTER
);
102 c
->InsertCell(new wxHtmlListmarkCell(m_WParser
->GetDC(), m_WParser
->GetActualColor()));
106 c
->SetAlignHor(wxHTML_ALIGN_RIGHT
);
108 mark
.Printf(wxT("%i."), m_Numbering
);
109 c
->InsertCell(new wxHtmlWordCell(mark
, *(m_WParser
->GetDC())));
111 m_WParser
->CloseContainer();
113 c
= m_WParser
->OpenContainer();
114 c
->SetIndent(m_WParser
->GetCharWidth() / 4, wxHTML_INDENT_LEFT
);
115 c
->SetWidthFloat(-2 * m_WParser
->GetCharWidth(), wxHTML_UNITS_PIXELS
);
117 m_WParser
->OpenContainer();
119 if (m_Numbering
!= 0) m_Numbering
++;
124 // Begin of List (not-numbered): "UL", "OL"
127 int oldnum
= m_Numbering
;
129 if (tag
.GetName() == wxT("UL")) m_Numbering
= 0;
130 else m_Numbering
= 1;
132 c
= m_WParser
->GetContainer();
133 if (c
->GetFirstCell() != NULL
)
135 m_WParser
->CloseContainer();
136 m_WParser
->OpenContainer();
137 c
= m_WParser
->GetContainer();
139 c
->SetAlignHor(wxHTML_ALIGN_LEFT
);
140 c
->SetIndent(2 * m_WParser
->GetCharWidth(), wxHTML_INDENT_LEFT
);
141 m_WParser
->OpenContainer()->SetAlignVer(wxHTML_ALIGN_TOP
);
143 m_WParser
->OpenContainer();
144 m_WParser
->OpenContainer();
147 m_WParser
->GetContainer()->SetIndent(0, wxHTML_INDENT_TOP
);
148 // this is to prevent indetation in <li><p> case
149 m_WParser
->CloseContainer();
151 m_WParser
->CloseContainer();
152 m_WParser
->CloseContainer();
153 m_WParser
->CloseContainer();
154 m_WParser
->OpenContainer();
156 m_Numbering
= oldnum
;
161 TAG_HANDLER_END(OLULLI
)
164 TAGS_MODULE_BEGIN(List
)
166 TAGS_MODULE_ADD(OLULLI
)
168 TAGS_MODULE_END(List
)