]>
git.saurik.com Git - wxWidgets.git/blob - src/html/m_list.cpp
689a8ebc1145073e556335cd9b9e5b4c002d9797
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
->GetCharWidth();
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 / 4, y + m_PosY + m_Height / 4, m_Width / 2, m_Width / 2);
62 // This looks better IMHO (JACS) -- I tried to get ellipses/circles working but they can
63 // just look terrible, at least on Windows. TODO: maybe have configurable bullets,
64 // possibly with the app supplying bitmaps.
65 int size
= (int) ((m_Width
/ 2.0) + 0.5);
66 dc
.DrawRectangle(x
+ m_PosX
+ (m_Width
- size
)/2, y
+ m_PosY
+ (m_Height
- size
)/ 2, size
, size
);
72 //-----------------------------------------------------------------------------
74 //-----------------------------------------------------------------------------
77 TAG_HANDLER_BEGIN(OLULLI
, "OL,UL,LI")
81 // this is number of actual item of list or 0 for dots
83 TAG_HANDLER_CONSTR(OLULLI
)
90 wxHtmlContainerCell
*c
;
93 if (tag
.GetName() == wxT("LI"))
95 m_WParser
->GetContainer()->SetIndent(0, wxHTML_INDENT_TOP
);
96 // this is to prevent indetation in <li><p> case
97 m_WParser
->CloseContainer();
98 m_WParser
->CloseContainer();
100 c
= m_WParser
->OpenContainer();
101 c
->SetWidthFloat(2 * m_WParser
->GetCharWidth(), wxHTML_UNITS_PIXELS
);
102 if (m_Numbering
== 0)
104 // Centering gives more space after the bullet
105 c
->SetAlignHor(wxHTML_ALIGN_CENTER
);
106 c
->InsertCell(new wxHtmlListmarkCell(m_WParser
->GetDC(), m_WParser
->GetActualColor()));
110 c
->SetAlignHor(wxHTML_ALIGN_RIGHT
);
112 mark
.Printf(wxT("%i."), m_Numbering
);
113 c
->InsertCell(new wxHtmlWordCell(mark
, *(m_WParser
->GetDC())));
115 m_WParser
->CloseContainer();
117 c
= m_WParser
->OpenContainer();
118 c
->SetIndent(m_WParser
->GetCharWidth() / 4, wxHTML_INDENT_LEFT
);
119 c
->SetWidthFloat(-2 * m_WParser
->GetCharWidth(), wxHTML_UNITS_PIXELS
);
121 m_WParser
->OpenContainer();
123 if (m_Numbering
!= 0) m_Numbering
++;
128 // Begin of List (not-numbered): "UL", "OL"
131 int oldnum
= m_Numbering
;
133 if (tag
.GetName() == wxT("UL")) m_Numbering
= 0;
134 else m_Numbering
= 1;
136 c
= m_WParser
->GetContainer();
137 if (c
->GetFirstCell() != NULL
)
139 m_WParser
->CloseContainer();
140 m_WParser
->OpenContainer();
141 c
= m_WParser
->GetContainer();
143 c
->SetAlignHor(wxHTML_ALIGN_LEFT
);
144 c
->SetIndent(2 * m_WParser
->GetCharWidth(), wxHTML_INDENT_LEFT
);
145 m_WParser
->OpenContainer()->SetAlignVer(wxHTML_ALIGN_TOP
);
147 m_WParser
->OpenContainer();
148 m_WParser
->OpenContainer();
151 m_WParser
->GetContainer()->SetIndent(0, wxHTML_INDENT_TOP
);
152 // this is to prevent indetation in <li><p> case
153 m_WParser
->CloseContainer();
155 m_WParser
->CloseContainer();
156 m_WParser
->CloseContainer();
157 m_WParser
->CloseContainer();
158 m_WParser
->OpenContainer();
160 m_Numbering
= oldnum
;
165 TAG_HANDLER_END(OLULLI
)
168 TAGS_MODULE_BEGIN(List
)
170 TAGS_MODULE_ADD(OLULLI
)
172 TAGS_MODULE_END(List
)