class PreferenceFrame(wx.Frame):
"""
This allows the user to set their preferences. Changes automatically
update as the user makes them; when they're done, they close the window.
"""
checkbox(self, "fastStoryPanel", 'Faster but rougher story map display')
checkbox(self, "flatDesign", 'Flat Design(TM) mode')
checkbox(self, "imageArrows", 'Connector arrows for images and stylesheets')
checkbox(self, "displayArrows", 'Connector arrows for <<display>>ed passages')
checkbox(self, "createPassagePrompt", 'Offer to create new passages for broken links')
checkbox(self, "importImagePrompt", 'Offer to import externally linked images')
checkbox(self, "passageWarnings", 'Warn about possible passage code errors')
panelSizer.Add(wx.StaticText(panel, label = 'Normal Font'), flag = wx.ALIGN_CENTER_VERTICAL)
panelSizer.Add(self.editorFont)
panelSizer.Add(wx.StaticText(panel, label = 'Monospace Font'), flag = wx.ALIGN_CENTER_VERTICAL)
panelSizer.Add(self.monoFont)
panelSizer.Add(wx.StaticText(panel, label = 'Fullscreen Editor Font'), flag = wx.ALIGN_CENTER_VERTICAL)
panelSizer.Add(self.fsFont)
panelSizer.Add(wx.StaticText(panel, label = 'Fullscreen Editor Text Color'), flag = wx.ALIGN_CENTER_VERTICAL)
panelSizer.Add(self.fsTextColor)
panelSizer.Add(wx.StaticText(panel, label = 'Fullscreen Editor Background Color'), \
flag = wx.ALIGN_CENTER_VERTICAL)
panelSizer.Add(self.fsBgColor)
panelSizer.Add(wx.StaticText(panel, label = 'Fullscreen Editor Line Spacing'), flag = wx.ALIGN_CENTER_VERTICAL)
panelSizer.Add(fsLineHeightPanel, flag = wx.ALIGN_CENTER_VERTICAL)
panelSizer.Add(self.fastStoryPanel) # pylint: disable=no-member
panelSizer.Add((1,2))
panelSizer.Add(self.flatDesign) # pylint: disable=no-member
panelSizer.Add((1,2))
panelSizer.Add(self.imageArrows) # pylint: disable=no-member
panelSizer.Add((1,2))
panelSizer.Add(self.displayArrows) # pylint: disable=no-member
panelSizer.Add((1,2))
panelSizer.Add(wx.StaticText(panel, label = 'When closing a passage:'), flag = wx.ALIGN_CENTER_VERTICAL)
panelSizer.Add((1,2))
panelSizer.Add(self.createPassagePrompt) # pylint: disable=no-member
panelSizer.Add((1,2))
panelSizer.Add(self.importImagePrompt) # pylint: disable=no-member
panelSizer.Add((1,2))
panelSizer.Add(self.passageWarnings) # pylint: disable=no-member
def getPrefFont(self, key):
"""
Returns a font saved in preferences as a wx.Font instance.
"""
return wx.Font(self.app.config.ReadInt(key + 'FontSize'), wx.FONTFAMILY_MODERN, \
wx.FONTSTYLE_NORMAL, wx.NORMAL, False, self.app.config.Read(key + 'FontFace'))
def savePref(self, key, value):
"""
Saves changes to a preference and sends an update message to the application.
"""
if isinstance(value, wx.Colour):
self.app.config.Write(key, value.GetAsString(wx.C2S_HTML_SYNTAX))
elif type(value) is int:
self.app.config.WriteInt(key, value)
elif type(value) is bool:
self.app.config.WriteBool(key, value)
else:
self.app.config.Write(key, value)
self.app.applyPrefs()
def saveFontPref(self, key, font):
"""
Saves a user-chosen font to preference keys, then sends an update message to the application.
"""
self.app.config.Write(key + 'FontFace', font.GetFaceName())
self.app.config.WriteInt(key + 'FontSize', font.GetPointSize())
self.app.applyPrefs()
self.panelSizer.Fit(self)
self.borderSizer.Fit(self)