]>
git.saurik.com Git - wxWidgets.git/blob - src/html/m_pre.cpp
1 /////////////////////////////////////////////////////////////////////////////
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 /////////////////////////////////////////////////////////////////////////////
11 #pragma implementation
14 #include "wx/wxprec.h"
17 #if wxUSE_HTML && wxUSE_STREAMS
25 #include "wx/html/forcelnk.h"
26 #include "wx/html/m_templ.h"
28 #include "wx/html/htmlcell.h"
29 #include "wx/tokenzr.h"
30 #include "wx/encconv.h"
34 //-----------------------------------------------------------------------------
36 //-----------------------------------------------------------------------------
39 TAG_HANDLER_BEGIN(PRE
, "PRE")
43 wxHtmlContainerCell
*c
;
45 int fixed
= m_WParser
->GetFontFixed(),
46 italic
= m_WParser
->GetFontItalic(),
47 underlined
= m_WParser
->GetFontUnderlined(),
48 bold
= m_WParser
->GetFontBold(),
49 fsize
= m_WParser
->GetFontSize();
51 c
= m_WParser
->GetContainer();
52 m_WParser
->SetFontUnderlined(FALSE
);
53 m_WParser
->SetFontBold(FALSE
);
54 m_WParser
->SetFontItalic(FALSE
);
55 m_WParser
->SetFontFixed(TRUE
);
56 m_WParser
->SetFontSize(3);
57 c
->InsertCell(new wxHtmlFontCell(m_WParser
->CreateCurrentFont()));
59 m_WParser
->CloseContainer();
60 c
= m_WParser
->OpenContainer();
61 c
->SetAlignHor(wxHTML_ALIGN_LEFT
);
65 src
= *m_WParser
->GetSource();
66 srcMid
= src
.Mid(tag
.GetBeginPos(),
67 tag
.GetEndPos1() - tag
.GetBeginPos());
68 srcMid
.Replace(wxT("\t"), wxT(" "));
69 srcMid
.Replace(wxT(" "), wxT(" "));
70 srcMid
.Replace(wxT("\n"), wxT("<br>"));
72 // It is safe to temporarily change the source being parsed,
73 // provided we restore the state back after parsing
74 m_Parser
->SetSource(srcMid
);
75 m_Parser
->DoParsing();
76 m_Parser
->SetSource(src
);
78 m_WParser
->CloseContainer();
79 c
= m_WParser
->OpenContainer();
81 m_WParser
->SetFontUnderlined(underlined
);
82 m_WParser
->SetFontBold(bold
);
83 m_WParser
->SetFontItalic(italic
);
84 m_WParser
->SetFontFixed(fixed
);
85 m_WParser
->SetFontSize(fsize
);
86 c
->InsertCell(new wxHtmlFontCell(m_WParser
->CreateCurrentFont()));
97 TAGS_MODULE_BEGIN(Pre
)