]>
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"
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
-> GetCharWidth();
52 m_Height
= dc
-> GetCharHeight();
58 void wxHtmlListmarkCell::Draw(wxDC
& dc
, int x
, int y
, int view_y1
, int view_y2
)
61 dc
.DrawEllipse(x
+ m_PosX
+ m_Width
/ 4, y
+ m_PosY
+ m_Height
/ 4, m_Width
/ 2, m_Width
/ 2);
62 wxHtmlCell::Draw(dc
, x
, y
, view_y1
, view_y2
);
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")) {
90 if (!tag
.IsEnding()) {
91 m_WParser
-> CloseContainer();
92 m_WParser
-> CloseContainer();
94 c
= m_WParser
-> OpenContainer();
95 c
-> SetWidthFloat(2 * m_WParser
-> GetCharWidth(), wxHTML_UNITS_PIXELS
);
96 c
-> SetAlignHor(wxHTML_ALIGN_RIGHT
);
98 c
-> InsertCell(new wxHtmlListmarkCell(m_WParser
-> GetDC(), m_WParser
-> GetActualColor()));
101 mark
.Printf(wxT("%i."), m_Numbering
);
102 c
-> InsertCell(new wxHtmlWordCell(mark
, *(m_WParser
-> GetDC())));
104 m_WParser
-> CloseContainer();
106 c
= m_WParser
-> OpenContainer();
107 c
-> SetIndent(m_WParser
-> GetCharWidth() / 4, wxHTML_INDENT_LEFT
);
108 c
-> SetWidthFloat(-2 * m_WParser
-> GetCharWidth(), wxHTML_UNITS_PIXELS
);
110 m_WParser
-> OpenContainer();
112 if (m_Numbering
!= 0) m_Numbering
++;
117 // Begin of List (not-numbered): "UL", "OL"
119 int oldnum
= m_Numbering
;
121 if (tag
.GetName() == wxT("UL")) m_Numbering
= 0;
122 else m_Numbering
= 1;
124 c
= m_WParser
-> GetContainer();
125 if (c
-> GetFirstCell() != NULL
) {
126 m_WParser
-> CloseContainer();
127 m_WParser
-> OpenContainer();
128 c
= m_WParser
-> GetContainer();
130 c
-> SetAlignHor(wxHTML_ALIGN_LEFT
);
131 c
-> SetIndent(2 * m_WParser
-> GetCharWidth(), wxHTML_INDENT_LEFT
);
132 m_WParser
-> OpenContainer() -> SetAlignVer(wxHTML_ALIGN_TOP
);
134 m_WParser
-> OpenContainer();
135 m_WParser
-> OpenContainer();
137 m_WParser
-> CloseContainer();
139 m_WParser
-> CloseContainer();
140 m_WParser
-> CloseContainer();
141 m_WParser
-> CloseContainer();
142 m_WParser
-> OpenContainer();
144 m_Numbering
= oldnum
;
149 TAG_HANDLER_END(OLULLI
)
152 TAGS_MODULE_BEGIN(List
)
154 TAGS_MODULE_ADD(OLULLI
)
156 TAGS_MODULE_END(List
)