]>
git.saurik.com Git - wxWidgets.git/blob - src/html/m_pre.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/html/m_pre.cpp
3 // Purpose: wxHtml module for <PRE> ... </PRE> tag (code citation)
4 // Author: Vaclav Slavik
6 // Copyright: (c) 1999 Vaclav Slavik
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
10 #include "wx/wxprec.h"
16 #if wxUSE_HTML && wxUSE_STREAMS
21 #include "wx/html/forcelnk.h"
22 #include "wx/html/m_templ.h"
24 #include "wx/html/htmlcell.h"
25 #include "wx/tokenzr.h"
26 #include "wx/encconv.h"
30 // replaces '\t', ' ' and '\n' with HTML markup:
31 static wxString LINKAGEMODE
HtmlizeWhitespaces(const wxString
& str
)
34 size_t len
= str
.Len();
36 for (size_t i
= 0; i
< len
; i
++)
38 switch ( str
[i
].GetValue() )
41 while (i
< len
&& str
[i
] != wxT('>'))
57 for (size_t j
= 8 - linepos
% 8; j
> 0; j
--)
59 linepos
+= 8 - linepos
% 8;
72 //-----------------------------------------------------------------------------
74 //-----------------------------------------------------------------------------
77 TAG_HANDLER_BEGIN(PRE
, "PRE")
78 TAG_HANDLER_CONSTR(PRE
) { }
82 wxHtmlContainerCell
*c
;
84 int fixed
= m_WParser
->GetFontFixed(),
85 italic
= m_WParser
->GetFontItalic(),
86 underlined
= m_WParser
->GetFontUnderlined(),
87 bold
= m_WParser
->GetFontBold(),
88 fsize
= m_WParser
->GetFontSize();
90 c
= m_WParser
->GetContainer();
91 m_WParser
->SetFontUnderlined(false);
92 m_WParser
->SetFontBold(false);
93 m_WParser
->SetFontItalic(false);
94 m_WParser
->SetFontFixed(true);
95 m_WParser
->SetFontSize(3);
96 c
->InsertCell(new wxHtmlFontCell(m_WParser
->CreateCurrentFont()));
98 m_WParser
->CloseContainer();
99 c
= m_WParser
->OpenContainer();
100 c
->SetWidthFloat(tag
);
101 c
= m_WParser
->OpenContainer();
102 c
->SetAlignHor(wxHTML_ALIGN_LEFT
);
103 c
->SetIndent(m_WParser
->GetCharHeight(), wxHTML_INDENT_TOP
);
105 wxString srcMid
= m_WParser
->GetInnerSource(tag
);
106 ParseInnerSource(HtmlizeWhitespaces(srcMid
));
108 m_WParser
->CloseContainer();
109 m_WParser
->CloseContainer();
110 c
= m_WParser
->OpenContainer();
112 m_WParser
->SetFontUnderlined(underlined
);
113 m_WParser
->SetFontBold(bold
);
114 m_WParser
->SetFontItalic(italic
);
115 m_WParser
->SetFontFixed(fixed
);
116 m_WParser
->SetFontSize(fsize
);
117 c
->InsertCell(new wxHtmlFontCell(m_WParser
->CreateCurrentFont()));
128 TAGS_MODULE_BEGIN(Pre
)