Graphics/PixmapDiagram.py

changeset 945
8cd4d08fa9f6
parent 791
9ec2ac20e54e
child 1112
8a7d1b9d18db
equal deleted inserted replaced
944:1b59c4ba121e 945:8cd4d08fa9f6
15 from .ZoomDialog import ZoomDialog 15 from .ZoomDialog import ZoomDialog
16 16
17 import UI.Config 17 import UI.Config
18 18
19 import Preferences 19 import Preferences
20
20 21
21 class PixmapDiagram(QMainWindow): 22 class PixmapDiagram(QMainWindow):
22 """ 23 """
23 Class implementing a dialog showing a pixmap. 24 Class implementing a dialog showing a pixmap.
24 """ 25 """
25 def __init__(self, pixmap, parent = None, name = None): 26 def __init__(self, pixmap, parent=None, name=None):
26 """ 27 """
27 Constructor 28 Constructor
28 29
29 @param pixmap filename of a graphics file to show (string) 30 @param pixmap filename of a graphics file to show (string)
30 @param parent parent widget of the view (QWidget) 31 @param parent parent widget of the view (QWidget)
192 193
193 @param scrollBar reference to the scrollbar object (QScrollBar) 194 @param scrollBar reference to the scrollbar object (QScrollBar)
194 @param factor factor to adjust by (float) 195 @param factor factor to adjust by (float)
195 """ 196 """
196 scrollBar.setValue(int(factor * scrollBar.value() 197 scrollBar.setValue(int(factor * scrollBar.value()
197 + ((factor - 1) * scrollBar.pageStep()/2))) 198 + ((factor - 1) * scrollBar.pageStep() / 2)))
198 199
199 def __doZoom(self, factor): 200 def __doZoom(self, factor):
200 """ 201 """
201 Private method to perform the zooming. 202 Private method to perform the zooming.
202 203
239 240
240 def __printDiagram(self): 241 def __printDiagram(self):
241 """ 242 """
242 Private slot called to print the diagram. 243 Private slot called to print the diagram.
243 """ 244 """
244 printer = QPrinter(mode = QPrinter.ScreenResolution) 245 printer = QPrinter(mode=QPrinter.ScreenResolution)
245 printer.setFullPage(True) 246 printer.setFullPage(True)
246 if Preferences.getPrinter("ColorMode"): 247 if Preferences.getPrinter("ColorMode"):
247 printer.setColorMode(QPrinter.Color) 248 printer.setColorMode(QPrinter.Color)
248 else: 249 else:
249 printer.setColorMode(QPrinter.GrayScale) 250 printer.setColorMode(QPrinter.GrayScale)
261 """ 262 """
262 Private slot called to show a print preview of the diagram. 263 Private slot called to show a print preview of the diagram.
263 """ 264 """
264 from PyQt4.QtGui import QPrintPreviewDialog 265 from PyQt4.QtGui import QPrintPreviewDialog
265 266
266 printer = QPrinter(mode = QPrinter.ScreenResolution) 267 printer = QPrinter(mode=QPrinter.ScreenResolution)
267 printer.setFullPage(True) 268 printer.setFullPage(True)
268 if Preferences.getPrinter("ColorMode"): 269 if Preferences.getPrinter("ColorMode"):
269 printer.setColorMode(QPrinter.Color) 270 printer.setColorMode(QPrinter.Color)
270 else: 271 else:
271 printer.setColorMode(QPrinter.GrayScale) 272 printer.setColorMode(QPrinter.GrayScale)
310 # write a foot note 311 # write a foot note
311 s = self.trUtf8("Diagram: {0}").format(self.getDiagramName()) 312 s = self.trUtf8("Diagram: {0}").format(self.getDiagramName())
312 tc = QColor(50, 50, 50) 313 tc = QColor(50, 50, 50)
313 painter.setPen(tc) 314 painter.setPen(tc)
314 painter.drawRect(marginX, marginY, width, height) 315 painter.drawRect(marginX, marginY, width, height)
315 painter.drawLine(marginX, marginY + height + 2, 316 painter.drawLine(marginX, marginY + height + 2,
316 marginX + width, marginY + height + 2) 317 marginX + width, marginY + height + 2)
317 painter.setFont(font) 318 painter.setFont(font)
318 painter.drawText(marginX, marginY + height + 4, width, 319 painter.drawText(marginX, marginY + height + 4, width,
319 fontHeight, Qt.AlignRight, s) 320 fontHeight, Qt.AlignRight, s)
320 321

eric ide

mercurial