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