diff options
author | Javier Fernandez <jfernandez@igalia.com> | 2013-05-03 14:03:04 +0000 |
---|---|---|
committer | Javier Fernandez <jfernandez@igalia.com> | 2013-05-08 09:36:38 +0000 |
commit | b88aeb62eeef1f5b7bbff545550f61ca333001d8 (patch) | |
tree | bb9f0913ba4288e3b278a2684055ffaeec183984 /wizards | |
parent | b11afacfb7e227df7538c73b9b6350c6ed802450 (diff) |
PyWebWizard: Fixing bugs and implementation of mising features.
The wizard dialog has now support for HighContrast images.
Change-Id: Ic7990d162e11484aad973abb78de3d240bd67a0e
Diffstat (limited to 'wizards')
-rw-r--r-- | wizards/com/sun/star/wizards/ui/PeerConfig.py | 10 | ||||
-rw-r--r-- | wizards/com/sun/star/wizards/ui/UnoDialog.py | 78 |
2 files changed, 80 insertions, 8 deletions
diff --git a/wizards/com/sun/star/wizards/ui/PeerConfig.py b/wizards/com/sun/star/wizards/ui/PeerConfig.py index 442e42159b29..9b02dfcf8897 100644 --- a/wizards/com/sun/star/wizards/ui/PeerConfig.py +++ b/wizards/com/sun/star/wizards/ui/PeerConfig.py @@ -15,6 +15,8 @@ # except in compliance with the License. You may obtain a copy of # the License at http://www.apache.org/licenses/LICENSE-2.0 . # +import traceback + from .event.CommonListener import WindowListenerProcAdapter ''' @@ -52,13 +54,13 @@ class PeerConfig(object): xVclWindowPeer = i.xControl.Peer xVclWindowPeer.setProperty(i.propnames, i.propvalues) - for i in self.aImageUrlTasks: + for aImageUrlTask in self.aImageUrlTasks: if isinstance(aImageUrlTask.oResource, int): - sImageUrl = oUnoDialog.getWizardImageUrl(aImageUrlTask.oResource, aImageUrlTask.oHCResource) + sImageUrl = self.oUnoDialog.getWizardImageUrl(aImageUrlTask.oResource, aImageUrlTask.oHCResource) elif isinstance(aImageUrlTask.oResource, str): - sImageUrl = oUnoDialog.getImageUrl(aImageUrlTask.oResource, aImageUrlTask.oHCResource) + sImageUrl = self.oUnoDialog.getImageUrl(aImageUrlTask.oResource, aImageUrlTask.oHCResource) if sImageUrl != "": - Helper.setUnoPropertyValue(aImageUrlTask.oModel, PropertyNames.PROPERTY_IMAGEURL, sImageUrl) + aImageUrlTask.oModel.ImageURL = sImageUrl except Exception: traceback.print_exc() diff --git a/wizards/com/sun/star/wizards/ui/UnoDialog.py b/wizards/com/sun/star/wizards/ui/UnoDialog.py index f2b36a130ea1..40804b44254b 100644 --- a/wizards/com/sun/star/wizards/ui/UnoDialog.py +++ b/wizards/com/sun/star/wizards/ui/UnoDialog.py @@ -28,6 +28,8 @@ class UnoDialog(object): createDict = False dictProperties = None + BisHighContrastModeActivated = None + xVclWindowPeer = None def __init__(self, xMSF, PropertyNames, PropertyValues): try: @@ -125,8 +127,7 @@ class UnoDialog(object): except Exception: traceback.print_exc() - def insertControlModel( - self, serviceName, componentName, sPropNames, oPropValues): + def insertControlModel(self, serviceName, componentName, sPropNames, oPropValues): try: xControlModel = self.xDialogModel.createInstance(serviceName) uno.invoke(xControlModel, "setPropertyValues", @@ -188,11 +189,14 @@ class UnoDialog(object): if self.xWindowPeer is None: self.createWindowPeer() + + self.xVclWindowPeer = self.xWindowPeer + self.BisHighContrastModeActivated = self.isHighContrastModeActivated() return self.xUnoDialog.execute() def setVisible(self, parent): - self.calculateDialogPosition(parent.xWindow.getPosSize()) - if self.xWindowPeer is None: + self.calculateDialogPosition(parent.xUnoDialog.getPosSize()) + if self.xWindowPeer == None: self.createWindowPeer() self.xUnoDialog.setVisible(True) @@ -258,6 +262,14 @@ class UnoDialog(object): xListBox.selectItemPos((short)(SelPos - 1), True) @classmethod + def setEnabled(self, control, enabled): + control.Model.Enabled = enabled + + @classmethod + def getModel(self, control): + return control.getModel() + + @classmethod def getDisplayProperty(self, xServiceInfo): if xServiceInfo.supportsService( "com.sun.star.awt.UnoControlFixedTextModel"): @@ -312,3 +324,61 @@ class UnoDialog(object): def addResourceHandler(self, _Unit, _Module): self.m_oResource = Resource(self.xMSF, _Unit, _Module) + + def isHighContrastModeActivated(self): + if (self.xVclWindowPeer is not None): + if (self.BisHighContrastModeActivated is None): + nUIColor = 0 + try: + nUIColor = self.xVclWindowPeer.getProperty("DisplayBackgroundColor") + except IllegalArgumentException: + traceback.print_exc() + return False + + # TODO: The following methods could be wrapped in an own class implementation + nRed = self.getRedColorShare(nUIColor) + nGreen = self.getGreenColorShare(nUIColor) + nBlue = self.getBlueColorShare(nUIColor) + nLuminance = ((nBlue * 28 + nGreen * 151 + nRed * 77) / 256) + bisactivated = (nLuminance <= 25) + self.BisHighContrastModeActivated = bool(bisactivated) + return bisactivated; + else: + return self.BisHighContrastModeActivated + else: + return False + + + def getRedColorShare(self, _nColor): + nRed = _nColor / 65536 + nRedModulo = _nColor % 65536 + nGreen = nRedModulo / 256 + nGreenModulo = (nRedModulo % 256) + nBlue = nGreenModulo + return nRed + + def getGreenColorShare(self, _nColor): + nRed = _nColor / 65536 + nRedModulo = _nColor % 65536 + nGreen = nRedModulo / 256 + return nGreen + + def getBlueColorShare(self, _nColor): + nRed = _nColor / 65536 + nRedModulo = _nColor % 65536 + nGreen = nRedModulo / 256 + nGreenModulo = (nRedModulo % 256) + nBlue = nGreenModulo + return nBlue + + def getWizardImageUrl(self, _nResId, _nHCResId): + if (self.isHighContrastModeActivated()): + return "private:resource/wzi/image/" + str(_nHCResId) + else: + return "private:resource/wzi/image/" + str(_nResId) + + def getImageUrl(self, _surl, _shcurl): + if (self.isHighContrastModeActivated()): + return _shcurl + else: + return _surl |