]> git.saurik.com Git - wxWidgets.git/blame - src/html/m_list.cpp
fixed missing Idle events
[wxWidgets.git] / src / html / m_list.cpp
CommitLineData
5526e819 1/////////////////////////////////////////////////////////////////////////////
c88293a4 2// Name: m_list.cpp
5526e819
VS
3// Purpose: wxHtml module for lists
4// Author: Vaclav Slavik
69941f05 5// RCS-ID: $Id$
5526e819
VS
6// Copyright: (c) 1999 Vaclav Slavik
7// Licence: wxWindows Licence
8/////////////////////////////////////////////////////////////////////////////
ec4f5ef5
RS
9#ifdef __GNUG__
10#pragma implementation
11#endif
12
314260fb 13#include "wx/wxprec.h"
ec4f5ef5 14
5526e819
VS
15
16#include "wx/defs.h"
f6bcfd97 17#if wxUSE_HTML && wxUSE_STREAMS
5526e819 18
2b5f62a0 19#ifdef __BORLANDC__
ec4f5ef5
RS
20#pragma hdrstop
21#endif
22
23#ifndef WXPRECOMP
04dbb646
VZ
24 #include "wx/brush.h"
25 #include "wx/dc.h"
ec4f5ef5
RS
26#endif
27
69941f05
VS
28#include "wx/html/forcelnk.h"
29#include "wx/html/m_templ.h"
5526e819 30
69941f05 31#include "wx/html/htmlcell.h"
5526e819 32
c88293a4 33FORCE_LINK_ME(m_list)
5526e819
VS
34
35
36//-----------------------------------------------------------------------------
37// wxHtmlListmarkCell
38//-----------------------------------------------------------------------------
39
40class wxHtmlListmarkCell : public wxHtmlCell
41{
42 private:
43 wxBrush m_Brush;
44 public:
45 wxHtmlListmarkCell(wxDC *dc, const wxColour& clr);
46 void Draw(wxDC& dc, int x, int y, int view_y1, int view_y2);
47};
48
49wxHtmlListmarkCell::wxHtmlListmarkCell(wxDC* dc, const wxColour& clr) : wxHtmlCell(), m_Brush(clr, wxSOLID)
50{
ee66bc1f 51 m_Width = dc->GetCharHeight();
1da7aa8c 52 m_Height = dc->GetCharHeight();
5526e819
VS
53 m_Descent = 0;
54}
55
56
57
d699f48b 58void wxHtmlListmarkCell::Draw(wxDC& dc, int x, int y, int WXUNUSED(view_y1), int WXUNUSED(view_y2))
5526e819
VS
59{
60 dc.SetBrush(m_Brush);
ee66bc1f
VS
61 dc.DrawEllipse(x + m_PosX + m_Width / 3, y + m_PosY + m_Height / 3,
62 (m_Width / 3), (m_Width / 3));
5526e819
VS
63}
64
65
66
67
68//-----------------------------------------------------------------------------
69// The list handler:
70//-----------------------------------------------------------------------------
71
72
73TAG_HANDLER_BEGIN(OLULLI, "OL,UL,LI")
74
75 TAG_HANDLER_VARS
76 int m_Numbering;
77 // this is number of actual item of list or 0 for dots
78
79 TAG_HANDLER_CONSTR(OLULLI)
80 {
81 m_Numbering = 0;
82 }
83
84 TAG_HANDLER_PROC(tag)
85 {
86 wxHtmlContainerCell *c;
87
88 // List Item:
04dbb646
VZ
89 if (tag.GetName() == wxT("LI"))
90 {
211dfedd
VS
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();
95
96 c = m_WParser->OpenContainer();
97 c->SetWidthFloat(2 * m_WParser->GetCharWidth(), wxHTML_UNITS_PIXELS);
211dfedd 98 if (m_Numbering == 0)
ad410280
JS
99 {
100 // Centering gives more space after the bullet
101 c->SetAlignHor(wxHTML_ALIGN_CENTER);
211dfedd 102 c->InsertCell(new wxHtmlListmarkCell(m_WParser->GetDC(), m_WParser->GetActualColor()));
ad410280 103 }
211dfedd 104 else
04dbb646 105 {
ad410280 106 c->SetAlignHor(wxHTML_ALIGN_RIGHT);
211dfedd
VS
107 wxString mark;
108 mark.Printf(wxT("%i."), m_Numbering);
109 c->InsertCell(new wxHtmlWordCell(mark, *(m_WParser->GetDC())));
5526e819 110 }
211dfedd
VS
111 m_WParser->CloseContainer();
112
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);
116
117 m_WParser->OpenContainer();
118
119 if (m_Numbering != 0) m_Numbering++;
120
5526e819
VS
121 return FALSE;
122 }
123
124 // Begin of List (not-numbered): "UL", "OL"
04dbb646
VZ
125 else
126 {
5526e819
VS
127 int oldnum = m_Numbering;
128
0413cec5 129 if (tag.GetName() == wxT("UL")) m_Numbering = 0;
5526e819
VS
130 else m_Numbering = 1;
131
1da7aa8c 132 c = m_WParser->GetContainer();
04dbb646
VZ
133 if (c->GetFirstCell() != NULL)
134 {
1da7aa8c
VS
135 m_WParser->CloseContainer();
136 m_WParser->OpenContainer();
137 c = m_WParser->GetContainer();
5526e819 138 }
1da7aa8c
VS
139 c->SetAlignHor(wxHTML_ALIGN_LEFT);
140 c->SetIndent(2 * m_WParser->GetCharWidth(), wxHTML_INDENT_LEFT);
141 m_WParser->OpenContainer()->SetAlignVer(wxHTML_ALIGN_TOP);
5526e819 142
1da7aa8c
VS
143 m_WParser->OpenContainer();
144 m_WParser->OpenContainer();
5526e819 145 ParseInner(tag);
5526e819 146
1da7aa8c
VS
147 m_WParser->GetContainer()->SetIndent(0, wxHTML_INDENT_TOP);
148 // this is to prevent indetation in <li><p> case
149 m_WParser->CloseContainer();
150
151 m_WParser->CloseContainer();
152 m_WParser->CloseContainer();
153 m_WParser->CloseContainer();
154 m_WParser->OpenContainer();
5526e819
VS
155
156 m_Numbering = oldnum;
157 return TRUE;
158 }
159 }
160
161TAG_HANDLER_END(OLULLI)
162
163
164TAGS_MODULE_BEGIN(List)
165
166 TAGS_MODULE_ADD(OLULLI)
167
168TAGS_MODULE_END(List)
169
170#endif