]> git.saurik.com Git - wxWidgets.git/blob - src/html/mod_list.cpp
Replaced wxUSE_LIBGIF with wxUSE_GIF
[wxWidgets.git] / src / html / mod_list.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: mod_list.cpp
3 // Purpose: wxHtml module for lists
4 // Author: Vaclav Slavik
5 // Copyright: (c) 1999 Vaclav Slavik
6 // Licence: wxWindows Licence
7 /////////////////////////////////////////////////////////////////////////////
8 #ifdef __GNUG__
9 #pragma implementation
10 #endif
11
12 #include <wx/wxprec.h>
13
14
15 #include "wx/defs.h"
16 #if wxUSE_HTML
17
18 #ifdef __BORDLANDC__
19 #pragma hdrstop
20 #endif
21
22 #ifndef WXPRECOMP
23 #include <wx/wx.h>
24 #endif
25
26
27 #include <wx/html/forcelink.h>
28 #include <wx/html/mod_templ.h>
29
30 #include <wx/html/htmlcell.h>
31
32 FORCE_LINK_ME(mod_list)
33
34
35 //-----------------------------------------------------------------------------
36 // wxHtmlListmarkCell
37 //-----------------------------------------------------------------------------
38
39 class wxHtmlListmarkCell : public wxHtmlCell
40 {
41 private:
42 wxBrush m_Brush;
43 public:
44 wxHtmlListmarkCell(wxDC *dc, const wxColour& clr);
45 void Draw(wxDC& dc, int x, int y, int view_y1, int view_y2);
46 };
47
48 wxHtmlListmarkCell::wxHtmlListmarkCell(wxDC* dc, const wxColour& clr) : wxHtmlCell(), m_Brush(clr, wxSOLID)
49 {
50 m_Width = dc -> GetCharWidth();
51 m_Height = dc -> GetCharHeight();
52 m_Descent = 0;
53 }
54
55
56
57 void wxHtmlListmarkCell::Draw(wxDC& dc, int x, int y, int view_y1, int view_y2)
58 {
59 dc.SetBrush(m_Brush);
60 dc.DrawEllipse(x + m_PosX + m_Width / 4, y + m_PosY + m_Height / 4, m_Width / 2, m_Width / 2);
61 wxHtmlCell::Draw(dc, x, y, view_y1, view_y2);
62 }
63
64
65
66
67 //-----------------------------------------------------------------------------
68 // The list handler:
69 //-----------------------------------------------------------------------------
70
71
72 TAG_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:
88 if (tag.GetName() == "LI") {
89 if (!tag.IsEnding()) {
90 m_WParser -> CloseContainer();
91 m_WParser -> CloseContainer();
92
93 c = m_WParser -> OpenContainer();
94 c -> SetWidthFloat(2 * m_WParser -> GetCharWidth(), HTML_UNITS_PIXELS);
95 c -> SetAlignHor(HTML_ALIGN_RIGHT);
96 if (m_Numbering == 0)
97 c -> InsertCell(new wxHtmlListmarkCell(m_WParser -> GetDC(), m_WParser -> GetActualColor()));
98 else {
99 wxString mark;
100 mark.Printf("%i.", m_Numbering);
101 c -> InsertCell(new wxHtmlWordCell(mark, *(m_WParser -> GetDC())));
102 }
103 m_WParser -> CloseContainer();
104
105 c = m_WParser -> OpenContainer();
106 c -> SetIndent(m_WParser -> GetCharWidth() / 4, HTML_INDENT_LEFT);
107 c -> SetWidthFloat(-2 * m_WParser -> GetCharWidth(), HTML_UNITS_PIXELS);
108
109 m_WParser -> OpenContainer();
110
111 if (m_Numbering != 0) m_Numbering++;
112 }
113 return FALSE;
114 }
115
116 // Begin of List (not-numbered): "UL", "OL"
117 else {
118 int oldnum = m_Numbering;
119
120 if (tag.GetName() == "UL") m_Numbering = 0;
121 else m_Numbering = 1;
122
123 c = m_WParser -> GetContainer();
124 if (c -> GetFirstCell() != NULL) {
125 m_WParser -> CloseContainer();
126 m_WParser -> OpenContainer();
127 c = m_WParser -> GetContainer();
128 }
129 c -> SetAlignHor(HTML_ALIGN_LEFT);
130 c -> SetIndent(2 * m_WParser -> GetCharWidth(), HTML_INDENT_LEFT);
131 m_WParser -> OpenContainer() -> SetAlignVer(HTML_ALIGN_TOP);
132
133 m_WParser -> OpenContainer();
134 m_WParser -> OpenContainer();
135 ParseInner(tag);
136 m_WParser -> CloseContainer();
137
138 m_WParser -> CloseContainer();
139 m_WParser -> CloseContainer();
140 m_WParser -> CloseContainer();
141 m_WParser -> OpenContainer();
142
143 m_Numbering = oldnum;
144 return TRUE;
145 }
146 }
147
148 TAG_HANDLER_END(OLULLI)
149
150
151 TAGS_MODULE_BEGIN(List)
152
153 TAGS_MODULE_ADD(OLULLI)
154
155 TAGS_MODULE_END(List)
156
157 #endif