]> git.saurik.com Git - wxWidgets.git/blame - src/html/m_list.cpp
fixed bug with loading standard icons
[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
ec4f5ef5
RS
19#ifdef __BORDLANDC__
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{
1da7aa8c
VS
51 m_Width = dc->GetCharWidth();
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);
61 dc.DrawEllipse(x + m_PosX + m_Width / 4, y + m_PosY + m_Height / 4, m_Width / 2, m_Width / 2);
5526e819
VS
62}
63
64
65
66
67//-----------------------------------------------------------------------------
68// The list handler:
69//-----------------------------------------------------------------------------
70
71
72TAG_HANDLER_BEGIN(OLULLI, "OL,UL,LI")
73
74 TAG_HANDLER_VARS
75 int m_Numbering;
76 // this is number of actual item of list or 0 for dots
77
78 TAG_HANDLER_CONSTR(OLULLI)
79 {
80 m_Numbering = 0;
81 }
82
83 TAG_HANDLER_PROC(tag)
84 {
85 wxHtmlContainerCell *c;
86
87 // List Item:
04dbb646
VZ
88 if (tag.GetName() == wxT("LI"))
89 {
211dfedd
VS
90 m_WParser->GetContainer()->SetIndent(0, wxHTML_INDENT_TOP);
91 // this is to prevent indetation in <li><p> case
92 m_WParser->CloseContainer();
93 m_WParser->CloseContainer();
94
95 c = m_WParser->OpenContainer();
96 c->SetWidthFloat(2 * m_WParser->GetCharWidth(), wxHTML_UNITS_PIXELS);
97 c->SetAlignHor(wxHTML_ALIGN_RIGHT);
98 if (m_Numbering == 0)
99 c->InsertCell(new wxHtmlListmarkCell(m_WParser->GetDC(), m_WParser->GetActualColor()));
100 else
04dbb646 101 {
211dfedd
VS
102 wxString mark;
103 mark.Printf(wxT("%i."), m_Numbering);
104 c->InsertCell(new wxHtmlWordCell(mark, *(m_WParser->GetDC())));
5526e819 105 }
211dfedd
VS
106 m_WParser->CloseContainer();
107
108 c = m_WParser->OpenContainer();
109 c->SetIndent(m_WParser->GetCharWidth() / 4, wxHTML_INDENT_LEFT);
110 c->SetWidthFloat(-2 * m_WParser->GetCharWidth(), wxHTML_UNITS_PIXELS);
111
112 m_WParser->OpenContainer();
113
114 if (m_Numbering != 0) m_Numbering++;
115
5526e819
VS
116 return FALSE;
117 }
118
119 // Begin of List (not-numbered): "UL", "OL"
04dbb646
VZ
120 else
121 {
5526e819
VS
122 int oldnum = m_Numbering;
123
0413cec5 124 if (tag.GetName() == wxT("UL")) m_Numbering = 0;
5526e819
VS
125 else m_Numbering = 1;
126
1da7aa8c 127 c = m_WParser->GetContainer();
04dbb646
VZ
128 if (c->GetFirstCell() != NULL)
129 {
1da7aa8c
VS
130 m_WParser->CloseContainer();
131 m_WParser->OpenContainer();
132 c = m_WParser->GetContainer();
5526e819 133 }
1da7aa8c
VS
134 c->SetAlignHor(wxHTML_ALIGN_LEFT);
135 c->SetIndent(2 * m_WParser->GetCharWidth(), wxHTML_INDENT_LEFT);
136 m_WParser->OpenContainer()->SetAlignVer(wxHTML_ALIGN_TOP);
5526e819 137
1da7aa8c
VS
138 m_WParser->OpenContainer();
139 m_WParser->OpenContainer();
5526e819 140 ParseInner(tag);
5526e819 141
1da7aa8c
VS
142 m_WParser->GetContainer()->SetIndent(0, wxHTML_INDENT_TOP);
143 // this is to prevent indetation in <li><p> case
144 m_WParser->CloseContainer();
145
146 m_WParser->CloseContainer();
147 m_WParser->CloseContainer();
148 m_WParser->CloseContainer();
149 m_WParser->OpenContainer();
5526e819
VS
150
151 m_Numbering = oldnum;
152 return TRUE;
153 }
154 }
155
156TAG_HANDLER_END(OLULLI)
157
158
159TAGS_MODULE_BEGIN(List)
160
161 TAGS_MODULE_ADD(OLULLI)
162
163TAGS_MODULE_END(List)
164
165#endif