]> git.saurik.com Git - wxWidgets.git/blame - src/html/m_list.cpp
moved wxDash typedef to gdicmn.h
[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"
17#if wxUSE_HTML
18
ec4f5ef5
RS
19#ifdef __BORDLANDC__
20#pragma hdrstop
21#endif
22
23#ifndef WXPRECOMP
3096bd2f 24#include "wx/wx.h"
ec4f5ef5
RS
25#endif
26
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{
51 m_Width = dc -> GetCharWidth();
52 m_Height = dc -> GetCharHeight();
53 m_Descent = 0;
54}
55
56
57
58void wxHtmlListmarkCell::Draw(wxDC& dc, int x, int y, int view_y1, int view_y2)
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);
62 wxHtmlCell::Draw(dc, x, y, view_y1, view_y2);
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:
0413cec5 89 if (tag.GetName() == wxT("LI")) {
5526e819
VS
90 if (!tag.IsEnding()) {
91 m_WParser -> CloseContainer();
92 m_WParser -> CloseContainer();
93
94 c = m_WParser -> OpenContainer();
efba2b89
VS
95 c -> SetWidthFloat(2 * m_WParser -> GetCharWidth(), wxHTML_UNITS_PIXELS);
96 c -> SetAlignHor(wxHTML_ALIGN_RIGHT);
5526e819
VS
97 if (m_Numbering == 0)
98 c -> InsertCell(new wxHtmlListmarkCell(m_WParser -> GetDC(), m_WParser -> GetActualColor()));
99 else {
100 wxString mark;
66a77a74 101 mark.Printf(wxT("%i."), m_Numbering);
5526e819
VS
102 c -> InsertCell(new wxHtmlWordCell(mark, *(m_WParser -> GetDC())));
103 }
104 m_WParser -> CloseContainer();
105
106 c = m_WParser -> OpenContainer();
efba2b89
VS
107 c -> SetIndent(m_WParser -> GetCharWidth() / 4, wxHTML_INDENT_LEFT);
108 c -> SetWidthFloat(-2 * m_WParser -> GetCharWidth(), wxHTML_UNITS_PIXELS);
5526e819
VS
109
110 m_WParser -> OpenContainer();
111
112 if (m_Numbering != 0) m_Numbering++;
113 }
114 return FALSE;
115 }
116
117 // Begin of List (not-numbered): "UL", "OL"
118 else {
119 int oldnum = m_Numbering;
120
0413cec5 121 if (tag.GetName() == wxT("UL")) m_Numbering = 0;
5526e819
VS
122 else m_Numbering = 1;
123
124 c = m_WParser -> GetContainer();
125 if (c -> GetFirstCell() != NULL) {
126 m_WParser -> CloseContainer();
127 m_WParser -> OpenContainer();
128 c = m_WParser -> GetContainer();
129 }
efba2b89
VS
130 c -> SetAlignHor(wxHTML_ALIGN_LEFT);
131 c -> SetIndent(2 * m_WParser -> GetCharWidth(), wxHTML_INDENT_LEFT);
132 m_WParser -> OpenContainer() -> SetAlignVer(wxHTML_ALIGN_TOP);
5526e819
VS
133
134 m_WParser -> OpenContainer();
135 m_WParser -> OpenContainer();
136 ParseInner(tag);
137 m_WParser -> CloseContainer();
138
139 m_WParser -> CloseContainer();
140 m_WParser -> CloseContainer();
141 m_WParser -> CloseContainer();
142 m_WParser -> OpenContainer();
143
144 m_Numbering = oldnum;
145 return TRUE;
146 }
147 }
148
149TAG_HANDLER_END(OLULLI)
150
151
152TAGS_MODULE_BEGIN(List)
153
154 TAGS_MODULE_ADD(OLULLI)
155
156TAGS_MODULE_END(List)
157
158#endif