Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion addon/globalPlugins/MathCAT/MathCATPreferences.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ def __init__(self, parent: wx.Window | None):
self._panelCategories.Layout()
self.Layout()
self.GetSizer().Fit(self)
self.Centre(wx.BOTH)

# load in the system values followed by the user prefs (if any)
UserInterface.loadDefaultPreferences()
Expand All @@ -123,6 +122,28 @@ def __init__(self, parent: wx.Window | None):
UserInterface.getBrailleCodes(self)
# set the ui items to match the preferences
UserInterface.setUIValues(self)
# Generated Centre(wx.BOTH) centres on NVDA's hidden mainFrame (top-left).
self._centrePreferencesDialog()

def _centrePreferencesDialog(self) -> None:
"""Centre the dialog on a visible parent, or on screen if there is none.

NVDA's mainFrame is a hidden window at the origin. Centre(wx.BOTH) would
put this dialog at the top-left of the display. Other NVDA settings
dialogs use CentreOnScreen() for the same reason.
"""
parent: wx.Window | None = self.GetParent()
parentClientSize: wx.Size | None = parent.GetClientSize() if parent is not None else None
if (
parent is not None
and parent.IsShown()
and parentClientSize is not None
and parentClientSize.width > 0
and parentClientSize.height > 0
):
self.CentreOnParent()
else:
self.CentreOnScreen()

def onPaintLogo(self, event: wx.PaintEvent) -> None:
"""Paint the MathCAT logo onto its panel, with a light pill behind it on dark backgrounds.
Expand Down
Loading