1 # -*- coding: UTF-8 -*-
2 # vim: expandtab sw=4 ts=4 sts=4:
5 HTML displayer with custom link handling
7 __author__
= 'Michal Čihař'
8 __email__
= 'michal@cihar.com'
10 Copyright © 2003 - 2008 Michal Čihař
12 This program is free software; you can redistribute it and/or modify it
13 under the terms of the GNU General Public License version 2 as published by
14 the Free Software Foundation.
16 This program is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
21 You should have received a copy of the GNU General Public License along with
22 this program; if not, write to the Free Software Foundation, Inc.,
23 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
30 from Wammu
.Locales
import HtmlStrConv
, StrConv
32 class Displayer(wx
.html
.HtmlWindow
):
33 def __init__(self
, parent
, win
):
34 wx
.html
.HtmlWindow
.__init
__(self
, parent
, -1)
37 def SetContent(self
, text
):
38 # default system colours
39 bgc
= wx
.SystemSettings
.GetColour(wx
.SYS_COLOUR_LISTBOX
)
40 fgc
= wx
.SystemSettings
.GetColour(wx
.SYS_COLOUR_WINDOWTEXT
)
41 hfgc
= wx
.SystemSettings
.GetColour(wx
.SYS_COLOUR_WINDOWTEXT
)
43 colours
= 'text="#%02x%02x%02x" bgcolor="#%02x%02x%02x" link="#%02x%02x%02x"' % (
44 fgc
.Red(), fgc
.Green(), fgc
.Blue(),
45 bgc
.Red(), bgc
.Green(), bgc
.Blue(),
46 hfgc
.Red(), hfgc
.Green(), hfgc
.Blue())
48 pagefmt
= u
'<html><head><meta http-equiv="Content-Type" content="text/html; charset=%s"></head><body %s>%s</body></html>'
52 self
.SetPage(pagefmt
% (charset
, colours
, text
))
55 def OnLinkClicked(self
, linkinfo
):
56 evt
= Wammu
.Events
.LinkEvent(
57 link
= linkinfo
.GetHref()
59 wx
.PostEvent(self
.win
, evt
)