19 from wx
import html, Colour
21 from .
import sizers, ButtonWithHandler
38 def __init__(self, parent, size=wx.DefaultSize, text=None, color_background=None, color_foreground=None):
39 html.HtmlWindow.__init__(self, parent, size=size, style=html.HW_DEFAULT_STYLE)
40 from ..preferences
import RideSettings
44 _settings = RideSettings()
51 self.SetStandardFonts(size=9)
57 self.
fontfont = self.GetFont()
60 self.SetFont(self.
fontfont)
62 self.Bind(wx.EVT_KEY_DOWN, self.
OnKeyDownOnKeyDown)
63 self.Bind(wx.EVT_CLOSE, self.
closeclose)
69 color =
''.join(hex(item)[2:]
for item
in tuple(bkgcolor))
73 _content =
'<body bgcolor=#%s>%s</body>' % (color, content)
78 _content =
'<body bgcolor=%s>%s</body>' % (bkgcolor, content)
79 self.SetPage(_content)
84 self.Parent.OnKey(event)
89 return event.GetKeyCode() == ord(
'C')
and event.CmdDown()
92 wx.TheClipboard.Open()
93 wx.TheClipboard.SetData(wx.TextDataObject(self.SelectionToText()))
94 wx.TheClipboard.Close()
97 webbrowser.open(link.Href)
109 def __init__(self, title='', parent=None, size=None, style=None, message=None):
110 size = size
or (-1, -1)
111 style = style
or (wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER)
112 wx.Dialog.__init__(self, parent=parent, title=title, size=size, style=style)
114 self.SetLayoutDirection(wx.Layout_LeftToRight)
116 from ..preferences
import RideSettings
120 _settings = RideSettings()
133 sizer = wx.BoxSizer(wx.VERTICAL)
135 content = wx.StaticText(self, -1, self.
messagemessage)
136 button = wx.Button(self, wx.ID_OK,
'', style=style)
141 sizer.Add(content, 0, wx.ALL | wx.EXPAND, 3)
142 sizer.Add(wx.StaticText(self, -1,
"\n\n"), 0, wx.ALL, 3)
143 sizer.Add(button, 0, wx.ALIGN_CENTER | wx.BOTTOM, 5)
144 self.CenterOnParent()
147 buttons = self.CreateStdDialogButtonSizer(wx.OK|wx.CANCEL)
150 for item
in self.GetChildren():
151 if isinstance(item, (wx.Button, wx.BitmapButton, ButtonWithHandler)):
156 sizer.Add(buttons, flag=wx.ALIGN_CENTER | wx.ALL, border=5)
159 line = wx.StaticLine(self, size=(20, -1), style=wx.LI_HORIZONTAL)
160 if wx.VERSION < (4, 1, 0):
161 sizer.Add(line, border=5, flag=wx.GROW | wx.ALIGN_CENTER_VERTICAL | wx.RIGHT | wx.TOP)
163 sizer.Add(line, border=5, flag=wx.GROW | wx.RIGHT | wx.TOP)
167 if self.ShowModal() == wx.ID_OK:
173 raise NotImplementedError(self.__class__.__name__)
178 def __init__(self, title, content, padding=0, font_size=-1):
179 RIDEDialog.__init__(self, title)
181 self.SetLayoutDirection(wx.Layout_LeftToRight)
184 self.
html_wndhtml_wnd.SetStandardFonts(size=font_size)
185 szr.add_expanding(self.
html_wndhtml_wnd, padding=padding)