]> git.saurik.com Git - wxWidgets.git/blame - src/html/m_pre.cpp
Corrected wxToolBar::ToolSetBitmapSize()
[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
3096bd2f 23#include "wx/wx.h"
3364ab79
RS
24#endif
25
5526e819 26
69941f05
VS
27#include "wx/html/forcelnk.h"
28#include "wx/html/m_templ.h"
5526e819 29
69941f05 30#include "wx/html/htmlcell.h"
3096bd2f 31#include "wx/tokenzr.h"
57f59026 32#include "wx/encconv.h"
5526e819 33
c88293a4 34FORCE_LINK_ME(m_pre)
5526e819 35
5526e819
VS
36//-----------------------------------------------------------------------------
37// The list handler:
38//-----------------------------------------------------------------------------
39
40
41TAG_HANDLER_BEGIN(PRE, "PRE")
42
43 TAG_HANDLER_PROC(tag)
44 {
45 wxHtmlContainerCell *c;
46
4f9297b0
VS
47 int fixed = m_WParser->GetFontFixed(),
48 italic = m_WParser->GetFontItalic(),
49 underlined = m_WParser->GetFontUnderlined(),
50 bold = m_WParser->GetFontBold(),
51 fsize = m_WParser->GetFontSize();
5526e819 52
1309ba6c 53 c = m_WParser->GetContainer();
4f9297b0
VS
54 m_WParser->SetFontUnderlined(FALSE);
55 m_WParser->SetFontBold(FALSE);
56 m_WParser->SetFontItalic(FALSE);
57 m_WParser->SetFontFixed(TRUE);
58 m_WParser->SetFontSize(3);
59 c->InsertCell(new wxHtmlFontCell(m_WParser->CreateCurrentFont()));
5526e819 60
1309ba6c
VS
61 m_WParser->CloseContainer();
62 c = m_WParser->OpenContainer();
63 c->SetAlignHor(wxHTML_ALIGN_LEFT);
64
65 wxString src, srcMid;
66
67 src = *m_WParser->GetSource();
68 srcMid = src.Mid(tag.GetBeginPos(),
69 tag.GetEndPos1() - tag.GetBeginPos());
70 srcMid.Replace(wxT("\t"), wxT(" "));
71 srcMid.Replace(wxT(" "), wxT("&nbsp;"));
72 srcMid.Replace(wxT("\n"), wxT("<br>"));
73
74 // It is safe to temporarily change the source being parsed,
75 // provided we restore the state back after parsing
76 m_Parser->SetSource(srcMid);
77 m_Parser->DoParsing();
78 m_Parser->SetSource(src);
79
80 m_WParser->CloseContainer();
81 c = m_WParser->OpenContainer();
5526e819 82
4f9297b0
VS
83 m_WParser->SetFontUnderlined(underlined);
84 m_WParser->SetFontBold(bold);
85 m_WParser->SetFontItalic(italic);
86 m_WParser->SetFontFixed(fixed);
87 m_WParser->SetFontSize(fsize);
88 c->InsertCell(new wxHtmlFontCell(m_WParser->CreateCurrentFont()));
5526e819 89
5526e819
VS
90 return TRUE;
91 }
92
93TAG_HANDLER_END(PRE)
94
95
96
97
98
99TAGS_MODULE_BEGIN(Pre)
100
101 TAGS_MODULE_ADD(PRE)
102
103TAGS_MODULE_END(Pre)
104
105#endif