Skip to content

Commit

Permalink
incubates #6339
Browse files Browse the repository at this point in the history
Issue: #6101
Extends PR: #6178

Merge branch 'i6101_SymbolsListCtrl' into next

Conflicts:
	source/gui/settingsDialogs.py
  • Loading branch information
feerrenrut committed Sep 29, 2016
2 parents bff3686 + d34d48d commit c68a4d4
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 11 deletions.
11 changes: 7 additions & 4 deletions source/gui/guiHelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ def __init__(self,parent):

import wx
from wx.lib import scrolledpanel
import nvdaControls

#: border space to be used around all controls in dialogs
BORDER_FOR_DIALOGS=10
Expand Down Expand Up @@ -122,7 +123,7 @@ def associateElements( firstElement, secondElement):
sizer = wx.BoxSizer(wx.VERTICAL)
sizer.Add(firstElement)
sizer.AddSpacer(SPACE_BETWEEN_ASSOCIATED_CONTROL_VERTICAL)
sizer.Add(secondElement)
sizer.Add(secondElement, flag=wx.EXPAND)
# button and checkBox
elif isinstance(firstElement, wx.Button) and isinstance(secondElement, wx.CheckBox):
sizer = wx.BoxSizer(wx.HORIZONTAL)
Expand Down Expand Up @@ -226,12 +227,11 @@ def __init__(self, parent, orientation=None, sizer=None):
else:
raise ValueError("Orientation OR Sizer must be supplied.")

def addItem(self, item):
def addItem(self, item, **keywordArgs):
""" Adds an item with space between it and the previous item.
Does not handle adding LabledControlHelper; use L{addlabelledControl} instead.
"""
toAdd = item
keywordArgs = {}
shouldAddSpacer = self.hasFirstItemBeenAdded

if isinstance(item, ButtonHelper):
Expand Down Expand Up @@ -272,5 +272,8 @@ def addLabeledControl(self, labelText, wxCtrlClass, **kwargs):
limitations from there.
"""
labeledControl = LabeledControlHelper(self._parent, labelText, wxCtrlClass, **kwargs)
self.addItem(labeledControl.sizer)
if(isinstance(labeledControl.control, nvdaControls.AutoWidthColumnListCtrl)):
self.addItem(labeledControl.sizer, flag=wx.EXPAND)
else:
self.addItem(labeledControl.sizer)
return labeledControl.control
22 changes: 22 additions & 0 deletions source/gui/nvdaControls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# -*- coding: UTF-8 -*-
#A part of NonVisual Desktop Access (NVDA)
#Copyright (C) 2016 NV Access Limited
#This file is covered by the GNU General Public License.
#See the file COPYING for more details.

import wx
from wx.lib.mixins import listctrl as listmix

class AutoWidthColumnListCtrl(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin):
"""
A list control that allows you to specify a column to resize to take up the remaining width of a wx.ListCtrl
"""
def __init__(self, parent, id=wx.ID_ANY, autoSizeColumnIndex="LAST", pos=wx.DefaultPosition, size=wx.DefaultSize, style=0):
""" initialiser
Takes the same parameter as a wx.ListCtrl with the following additions:
autoSizeColumnIndex - defaults to "LAST" which results in the last column being resized. Pass the index of
the column to be resized.
"""
wx.ListCtrl.__init__(self, parent, id, pos, size, style)
listmix.ListCtrlAutoWidthMixin.__init__(self)
self.setResizeColumn(autoSizeColumnIndex)
14 changes: 7 additions & 7 deletions source/gui/settingsDialogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
except RuntimeError:
updateCheck = None
import inputCore

import nvdaControls

class SettingsDialog(wx.Dialog):
"""A settings dialog.
Expand Down Expand Up @@ -1712,23 +1712,23 @@ def makeSettings(self, settingsSizer):
sHelper = guiHelper.BoxSizerHelper(self, sizer=settingsSizer)
# Translators: The label for symbols list in symbol pronunciation dialog.
symbolsText = _("&Symbols")
self.symbolsList = sHelper.addLabeledControl(symbolsText, wx.ListCtrl, style=wx.LC_REPORT | wx.LC_SINGLE_SEL, size=(360, 350))
self.symbolsList = sHelper.addLabeledControl(symbolsText, nvdaControls.AutoWidthColumnListCtrl, autoSizeColumnIndex=0, style=wx.LC_REPORT | wx.LC_SINGLE_SEL )
# Translators: The label for a column in symbols list used to identify a symbol.
self.symbolsList.InsertColumn(0, _("Symbol"), width=150)
self.symbolsList.InsertColumn(1, _("Replacement"), width=150)
self.symbolsList.InsertColumn(0, _("Symbol"))
self.symbolsList.InsertColumn(1, _("Replacement"))
# Translators: The label for a column in symbols list used to identify a symbol's speech level (either none, some, most, all or character).
self.symbolsList.InsertColumn(2, _("Level"), width=60)
self.symbolsList.InsertColumn(2, _("Level"))
# Translators: The label for a column in symbols list which specifies when the actual symbol will be sent to the synthesizer (preserved).
# See the "Punctuation/Symbol Pronunciation" section of the User Guide for details.
self.symbolsList.InsertColumn(3, _("Preserve"), width=60)
self.symbolsList.InsertColumn(3, _("Preserve"))
for symbol in symbols:
item = self.symbolsList.Append((symbol.displayName,))
self.updateListItem(item, symbol)
self.symbolsList.Bind(wx.EVT_LIST_ITEM_FOCUSED, self.onListItemFocused)
self.symbolsList.Bind(wx.EVT_CHAR, self.onListChar)

# Translators: The label for the group of controls in symbol pronunciation dialog to change the pronunciation of a symbol.
changeSymbolText = _("Change symbol")
changeSymbolText = _("Change selected symbol")
changeSizer = sHelper.addItem(guiHelper.BoxSizerHelper(self,
sizer=wx.StaticBoxSizer( wx.StaticBox(self, label=changeSymbolText), wx.VERTICAL)))

Expand Down

0 comments on commit c68a4d4

Please sign in to comment.