Changeset 3063

Show
Ignore:
Timestamp:
04/14/2007 02:51:47 PM (2 years ago)
Author:
paul
Message:

Added WordWrap? property to dEditBox. Default is True as always.

Added some mappings of common font names, so that if we are on Windows and
the font is set to "Sans", you'll get "Arial", on Mac "Geneva", etc.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/dabo/ui/uiwx/dEditBox.py

    r3054 r3063  
    241241 
    242242         
     243    def _getWordWrap(self): 
     244        return not self._hasWindowStyleFlag(wx.HSCROLL) 
     245 
     246    def _setWordWrap(self, val): 
     247        fontSize = self.GetFont().GetPointSize() 
     248        self._delWindowStyleFlag(wx.HSCROLL) 
     249        if not val: 
     250            self._addWindowStyleFlag(wx.HSCROLL) 
     251        dabo.ui.callAfter(self._setFontSize, fontSize) 
     252 
    243253    # property definitions follow: 
    244254    Alignment = property(_getAlignment, _setAlignment, None, 
     
    283293            _("Specifies the current state of the control (the value of the field). (varies)")) 
    284294 
     295    WordWrap = property(_getWordWrap, _setWordWrap, None, 
     296            _("""Specifies whether words get wrapped (the default). (bool) 
     297 
     298            If False, a horizontal scrollbar will appear when a line is too long 
     299            to fit in the horizontal space.""")) 
    285300 
    286301    DynamicAlignment = makeDynamicProperty(Alignment) 
  • trunk/dabo/ui/uiwx/dFont.py

    r3054 r3063  
    4949 
    5050    def _setFace(self, val): 
    51         self._nativeFont.SetFaceName(val) 
     51        if not self._nativeFont.SetFaceName(val): 
     52            # The font wasn't found on the user's system. Try to set it 
     53            # automatically based on some common-case mappings. 
     54            automatic_face = None 
     55            if val.lower() in ("courier", "courier new", "monospace", "mono"): 
     56                for trial in ("Courier New", "Courier", "Monaco", "Monospace", "Mono"): 
     57                    if self._nativeFont.SetFaceName(trial): 
     58                        automatic_face = trial 
     59                        break 
     60            elif val.lower() in ("arial", "helvetica", "geneva", "sans"): 
     61                for trial in ("Arial", "Helvetica", "Geneva", "Sans Serif", "Sans"): 
     62                    if self._nativeFont.SetFaceName(trial): 
     63                        automatic_face = trial 
     64                        break 
     65            elif val.lower() in ("times", "times new roman", "Georgia", "serif"): 
     66                for trial in ("Times New Roman", "Times", "Georgia", "Serif"): 
     67                    if self._nativeFont.SetFaceName(trial): 
     68                        automatic_face = trial 
     69                        break 
     70 
     71            if automatic_face: 
     72                dabo.infoLog.write(_("The font '%s' doesn't exist on the system. Used '%s' instead.")  
     73                        % (val, automatic_face)) 
     74            else: 
     75                dabo.errorLog.write(_("The font '%s' doesn't exist on the system.") 
     76                        % val) 
     77  
    5278        self._propsChanged() 
    5379 
  • trunk/dabo/ui/uiwx/dPemMixin.py

    r3054 r3063  
    17671767    def _setFontFace(self, val): 
    17681768        if self._constructed(): 
    1769             if val in dabo.ui.getAvailableFonts(): 
    1770                 try: 
    1771                     self.Font.Face = val 
    1772                 except dabo.ui.assertionException: 
    1773                     dabo.errorLog.write(_("Could not set the FontFace for %s to '%s'.") % (self.Name, val)) 
    1774             else: 
    1775                 dabo.errorLog.write(_("The FontFace '%s' does not exist on this system.") % val) 
    1776  
     1769            self.Font.Face = val 
    17771770        else: 
    17781771            self._properties["FontFace"] = val