Changed the way invisble HTML cells are NOT
[wxWidgets.git] / src / html / m_hline.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: m_hline.cpp
3 // Purpose: wxHtml module for horizontal line (HR tag)
4 // Author: Vaclav Slavik
5 // RCS-ID: $Id$
6 // Copyright: (c) 1999 Vaclav Slavik
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
9
10 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
11 #pragma implementation
12 #endif
13
14 #include "wx/wxprec.h"
15
16
17 #include "wx/defs.h"
18 #if wxUSE_HTML && wxUSE_STREAMS
19 #ifdef __BORLANDC__
20 #pragma hdrstop
21 #endif
22
23 #ifndef WXPRECOMP
24 #include "wx/brush.h"
25 #include "wx/pen.h"
26 #include "wx/dc.h"
27 #endif
28
29 #include "wx/html/forcelnk.h"
30 #include "wx/html/m_templ.h"
31
32 #include "wx/html/htmlcell.h"
33
34 FORCE_LINK_ME(m_hline)
35
36
37 //-----------------------------------------------------------------------------
38 // wxHtmlLineCell
39 //-----------------------------------------------------------------------------
40
41 class wxHtmlLineCell : public wxHtmlCell
42 {
43 public:
44 wxHtmlLineCell(int size, bool shading) : wxHtmlCell() {m_Height = size; m_HasShading = shading;}
45 void Draw(wxDC& dc, int x, int y, int view_y1, int view_y2,
46 wxHtmlRenderingInfo& info);
47 void Layout(int w)
48 { m_Width = w; wxHtmlCell::Layout(w); }
49
50 private:
51 // Should we draw 3-D shading or not
52 bool m_HasShading;
53
54 DECLARE_NO_COPY_CLASS(wxHtmlLineCell)
55 };
56
57
58 void wxHtmlLineCell::Draw(wxDC& dc, int x, int y,
59 int WXUNUSED(view_y1), int view_y2,
60 wxHtmlRenderingInfo& WXUNUSED(info))
61 {
62 if (y+m_PosY+m_Height > view_y2) return;
63
64 wxBrush mybrush(wxT("GREY"), (m_HasShading) ? wxTRANSPARENT : wxSOLID);
65 wxPen mypen(wxT("GREY"), 1, wxSOLID);
66 dc.SetBrush(mybrush);
67 dc.SetPen(mypen);
68 dc.DrawRectangle(x + m_PosX, y + m_PosY, m_Width, m_Height);
69 }
70
71
72
73
74 //-----------------------------------------------------------------------------
75 // The list handler:
76 //-----------------------------------------------------------------------------
77
78
79 TAG_HANDLER_BEGIN(HR, "HR")
80 TAG_HANDLER_CONSTR(HR) { }
81
82 TAG_HANDLER_PROC(tag)
83 {
84 wxHtmlContainerCell *c;
85 int sz;
86 bool HasShading;
87
88 m_WParser->CloseContainer();
89 c = m_WParser->OpenContainer();
90
91 c->SetIndent(m_WParser->GetCharHeight(), wxHTML_INDENT_VERTICAL);
92 c->SetAlignHor(wxHTML_ALIGN_CENTER);
93 c->SetAlign(tag);
94 c->SetWidthFloat(tag);
95 sz = 1;
96 tag.GetParamAsInt(wxT("SIZE"), &sz);
97 HasShading = !(tag.HasParam(wxT("NOSHADE")));
98 c->InsertCell(new wxHtmlLineCell((int)((double)sz * m_WParser->GetPixelScale()), HasShading));
99
100 m_WParser->CloseContainer();
101 m_WParser->OpenContainer();
102
103 return false;
104 }
105
106 TAG_HANDLER_END(HR)
107
108
109
110
111
112 TAGS_MODULE_BEGIN(HLine)
113
114 TAGS_MODULE_ADD(HR)
115
116 TAGS_MODULE_END(HLine)
117
118 #endif