~ubuntu-branches/ubuntu/trusty/python-enable/trusty

« back to all changes in this revision

Viewing changes to enthought/savage/traits/ui/wx/svg_button_editor.py

  • Committer: Bazaar Package Importer
  • Author(s): Varun Hiremath
  • Date: 2011-04-05 21:54:28 UTC
  • mfrom: (1.1.5 upstream)
  • mto: (8.2.1 sid)
  • mto: This revision was merged to the branch mainline in revision 10.
  • Revision ID: james.westby@ubuntu.com-20110405215428-1x2wtubz3ok2kxaq
Tags: upstream-3.4.1
ImportĀ upstreamĀ versionĀ 3.4.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
#
3
3
#  Copyright (c) 2009, Enthought, Inc.
4
4
#  All rights reserved.
5
 
 
5
#
6
6
#  This software is provided without warranty under the terms of the BSD
7
7
#  license included in enthought/LICENSE.txt and may be redistributed only
8
8
#  under the conditions described in the aforementioned license.  The license
9
9
#  is also available online at http://www.enthought.com/licenses/BSD.txt
10
10
#
11
11
#  Thanks for using Enthought open source!
12
 
#  
 
12
#
13
13
#------------------------------------------------------------------------------
14
14
 
15
15
""" Traits UI button editor for SVG images.
104
104
        # Reset the translation and zoom, then draw the text at an offset
105
105
        # based on the text width. There is a minor gotcha for supporting
106
106
        # multiple platforms here, Translate and DrawText behave differently
107
 
        # on different platforms. 
 
107
        # on different platforms.
108
108
        # It would be nice is a cross platform library actually worked the
109
109
        # same across platforms...
110
 
        
 
110
 
111
111
        text_width = dc.GetTextExtent(label_text)[0]
112
112
        text_x = (best_size.width - text_width)/2.0
113
113
        text_y = self.button.factory.height
114
114
        gc.Scale(100/float(self.zoom_x), 100/float(self.zoom_y))
115
 
        
 
115
 
116
116
        if sys.platform == 'darwin':
117
117
            gc.Translate(-x_offset + text_x, -y_offset + text_y)
118
118
            dc.DrawText(label_text, 0, 0)
119
119
        else:
120
120
            gc.Translate(-x_offset, -y_offset)
121
121
            dc.DrawText(label_text, text_x, text_y)
122
 
            
 
122
 
123
123
        if not self.button.enabled:
124
124
            self._draw_disable_mask(gc)
125
125
 
128
128
        # to the opposite of what it currently is
129
129
        if self.button.factory.toggle:
130
130
            self.toggle_state = not self.toggle_state
131
 
            
 
131
 
132
132
            if self.toggle_state:
133
133
                tooltip = wx.ToolTip(self.button.factory.toggle_tooltip)
134
134
            else:
213
213
        """ Finishes initializing the editor by creating the underlying toolkit
214
214
            widget.
215
215
        """
216
 
        
 
216
 
217
217
        self.document = SVGDocument.createFromFile(self.factory.filename, renderer=Renderer)
218
218
 
219
219
        # load the button toggle document which will be displayed when the