]> git.saurik.com Git - wxWidgets.git/blame - src/html/m_pre.cpp
renamed Number method (should be GetCount)
[wxWidgets.git] / src / html / m_pre.cpp
CommitLineData
5526e819 1/////////////////////////////////////////////////////////////////////////////
c88293a4 2// Name: m_pre.cpp
5526e819
VS
3// Purpose: wxHtml module for <PRE> ... </PRE> tag (code citation)
4// Author: Vaclav Slavik
69941f05 5// RCS-ID: $Id$
5526e819
VS
6// Copyright: (c) 1999 Vaclav Slavik
7// Licence: wxWindows Licence
8/////////////////////////////////////////////////////////////////////////////
9
3364ab79
RS
10#ifdef __GNUG__
11#pragma implementation
12#endif
13
3096bd2f 14#include "wx/wxprec.h"
3364ab79 15
314260fb 16#include "wx/defs.h"
f6bcfd97 17#if wxUSE_HTML && wxUSE_STREAMS
3364ab79
RS
18#ifdef __BORDLANDC__
19#pragma hdrstop
20#endif
21
22#ifndef WXPRECOMP
3364ab79
RS
23#endif
24
69941f05
VS
25#include "wx/html/forcelnk.h"
26#include "wx/html/m_templ.h"
5526e819 27
69941f05 28#include "wx/html/htmlcell.h"
3096bd2f 29#include "wx/tokenzr.h"
57f59026 30#include "wx/encconv.h"
5526e819 31
c88293a4 32FORCE_LINK_ME(m_pre)
5526e819 33
5526e819
VS
34//-----------------------------------------------------------------------------
35// The list handler:
36//-----------------------------------------------------------------------------
37
38
39TAG_HANDLER_BEGIN(PRE, "PRE")
40
41 TAG_HANDLER_PROC(tag)
42 {
43 wxHtmlContainerCell *c;
44
4f9297b0
VS
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();
5526e819 50
1309ba6c 51 c = m_WParser->GetContainer();
4f9297b0
VS
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()));
5526e819 58
1309ba6c
VS
59 m_WParser->CloseContainer();
60 c = m_WParser->OpenContainer();
61 c->SetAlignHor(wxHTML_ALIGN_LEFT);
62
211dfedd
VS
63 wxString srcMid =
64 m_WParser->GetSource()->Mid(tag.GetBeginPos(),
65 tag.GetEndPos1() - tag.GetBeginPos());
1309ba6c
VS
66 srcMid.Replace(wxT("\t"), wxT(" "));
67 srcMid.Replace(wxT(" "), wxT("&nbsp;"));
68 srcMid.Replace(wxT("\n"), wxT("<br>"));
69
70 // It is safe to temporarily change the source being parsed,
71 // provided we restore the state back after parsing
211dfedd 72 m_Parser->SetSourceAndSaveState(srcMid);
1309ba6c 73 m_Parser->DoParsing();
211dfedd 74 m_Parser->RestoreState();
04dbb646 75
1309ba6c
VS
76 m_WParser->CloseContainer();
77 c = m_WParser->OpenContainer();
5526e819 78
4f9297b0
VS
79 m_WParser->SetFontUnderlined(underlined);
80 m_WParser->SetFontBold(bold);
81 m_WParser->SetFontItalic(italic);
82 m_WParser->SetFontFixed(fixed);
83 m_WParser->SetFontSize(fsize);
84 c->InsertCell(new wxHtmlFontCell(m_WParser->CreateCurrentFont()));
5526e819 85
5526e819
VS
86 return TRUE;
87 }
88
89TAG_HANDLER_END(PRE)
90
91
92
93
94
95TAGS_MODULE_BEGIN(Pre)
96
97 TAGS_MODULE_ADD(PRE)
98
99TAGS_MODULE_END(Pre)
100
101#endif