Skip to content

Commit

Permalink
wxGUI/preferences: allow the user to change the font size/face of the…
Browse files Browse the repository at this point in the history
… manual page (OSGeo#3291)
  • Loading branch information
tmszi authored Dec 8, 2023
1 parent 8fd28c4 commit 7d99ee3
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 1 deletion.
4 changes: 4 additions & 0 deletions gui/wxpython/core/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,10 @@ def _defaultSettings(self):
"type": "Courier New",
"size": 10,
},
"manualPageFont": {
"faceName": "",
"pointSize": "",
},
# expand/collapse element list
"elementListExpand": {"selection": 0},
"menustyle": {"selection": 1},
Expand Down
22 changes: 21 additions & 1 deletion gui/wxpython/gui_core/ghelp.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@

from core import globalvar
from core.gcmd import GError, DecodeString
from core.settings import UserSettings
from gui_core.widgets import FormNotebook, ScrolledPanel
from gui_core.wrap import Button, StaticText, TextCtrl
from core.debug import Debug
Expand Down Expand Up @@ -740,7 +741,7 @@ def __init__(self, parent, command, text, skipDescription, **kwargs):
self.historyIdx = 0
self.fspath = os.path.join(os.getenv("GISBASE"), "docs", "html")

self.SetStandardFonts(size=10)
self._setFont()
self.SetBorders(10)

if text is None:
Expand All @@ -757,6 +758,25 @@ def __init__(self, parent, command, text, skipDescription, **kwargs):
self.SetPage(text)
self.loaded = True

def _setFont(self):
"""Set font size/face"""
font_face_name = UserSettings.Get(
group="appearance",
key="manualPageFont",
subkey="faceName",
)
font_size = UserSettings.Get(
group="appearance",
key="manualPageFont",
subkey="pointSize",
)
if font_size:
self.SetStandardFonts(
size=font_size,
normal_face=font_face_name,
fixed_face=font_face_name,
)

def OnLinkClicked(self, linkinfo):
url = linkinfo.GetHref()
if url[:4] != "http":
Expand Down
59 changes: 59 additions & 0 deletions gui/wxpython/gui_core/preferences.py
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,20 @@ def _createAppearancePage(self, notebook):
gridSizer.Add(
outfontButton, flag=wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL, pos=(row, 1)
)

# module HTML manual page font settings
row = 1
gridSizer.Add(
StaticText(parent=panel, id=wx.ID_ANY, label=_("Font for manual pages:")),
flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL,
pos=(row, 0),
)
manPageFontButton = Button(parent=panel, id=wx.ID_ANY, label=_("Set font"))
gridSizer.Add(
manPageFontButton,
flag=wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL,
pos=(row, 1),
)
gridSizer.AddGrowableCol(0)

#
Expand Down Expand Up @@ -806,6 +820,8 @@ def _createAppearancePage(self, notebook):
else:
outfontButton.Bind(wx.EVT_BUTTON, self.OnSetOutputFont)

manPageFontButton.Bind(wx.EVT_BUTTON, self.OnSetManualPageFontDialog)

return panel

def _createDisplayPage(self, notebook):
Expand Down Expand Up @@ -2085,6 +2101,49 @@ def OnSetOutputFont(self, event):

event.Skip()

def OnSetManualPageFontDialog(self, event):
"""Set font for module HTML manual page dialog"""
data = {}
font_point_size = self.settings.Get(
group="appearance",
key="manualPageFont",
subkey="pointSize",
)
font_face_name = self.settings.Get(
group="appearance",
key="manualPageFont",
subkey="faceName",
)
if font_point_size:
font_data = wx.FontData()
font = wx.Font(
pointSize=font_point_size,
family=wx.FONTFAMILY_MODERN,
style=wx.NORMAL,
weight=wx.FONTWEIGHT_NORMAL,
faceName=font_face_name,
)
font_data.SetInitialFont(font)
data["data"] = font_data
dlg = wx.FontDialog(parent=self, **data)
if dlg.ShowModal() == wx.ID_OK:
font_data = dlg.GetFontData()
font = font_data.GetChosenFont()
self.settings.Set(
group="appearance",
value=font.GetFaceName(),
key="manualPageFont",
subkey="faceName",
)
self.settings.Set(
group="appearance",
value=font.GetPointSize(),
key="manualPageFont",
subkey="pointSize",
)
dlg.Destroy()
event.Skip()

def OnSetSymbol(self, event):
"""Opens symbol dialog"""
winId = self.winId["vectorLayer:point:symbol"]
Expand Down

0 comments on commit 7d99ee3

Please sign in to comment.