Esempio n. 1
0
 def __init__(self, scene):
     QGraphicsView.__init__(self, scene)
     self.scene = scene
     self.setBackgroundBrush(QBrush(Color.background))
     self.antialiasing = True
     self.setHorizontalScrollBarPolicy(qt.ScrollBarAlwaysOff)
     self.setVerticalScrollBarPolicy(qt.ScrollBarAlwaysOff)
Esempio n. 2
0
 def __init__(self, scene):
     QGraphicsView.__init__(self, scene)
     self.scene = scene
     self.setBackgroundBrush(QBrush(Color.background))
     self.antialiasing = True
     self.setHorizontalScrollBarPolicy(qt.ScrollBarAlwaysOff)
     self.setVerticalScrollBarPolicy(qt.ScrollBarAlwaysOff)
Esempio n. 3
0
 def mousePressEvent(self, e):
     if e.button()==qt.MidButton or (e.button()==qt.RightButton and not self.scene.use_rightclick and not self.scene.itemAt(self.mapToScene(e.pos()), QTransform())):
         fake = QMouseEvent(e.type(), e.pos(), qt.LeftButton, qt.LeftButton, e.modifiers())
         self.scene.supress = True
         self.setDragMode(QGraphicsView.ScrollHandDrag)
         QGraphicsView.mousePressEvent(self, fake)
     else:
         QGraphicsView.mousePressEvent(self, e)
Esempio n. 4
0
 def mousePressEvent(self, e):
     if e.button()==qt.MidButton or (e.button()==qt.RightButton and not self.scene.use_rightclick and not self.scene.itemAt(self.mapToScene(e.pos()), QTransform())):
         fake = QMouseEvent(e.type(), e.pos(), qt.LeftButton, qt.LeftButton, e.modifiers())
         self.scene.supress = True
         self.setDragMode(QGraphicsView.ScrollHandDrag)
         QGraphicsView.mousePressEvent(self, fake)
     else:
         QGraphicsView.mousePressEvent(self, e)
Esempio n. 5
0
 def mouseReleaseEvent(self, e):
     if e.button()==qt.MidButton or (e.button()==qt.RightButton and self.scene.supress):
         fake = QMouseEvent(e.type(), e.pos(), qt.LeftButton, qt.LeftButton, e.modifiers())
         QGraphicsView.mouseReleaseEvent(self, fake)
         self.setDragMode(QGraphicsView.NoDrag)
         self.scene.supress = False
     else:
         QGraphicsView.mouseReleaseEvent(self, e)
Esempio n. 6
0
 def __init__(self, scene):
     QGraphicsView.__init__(self, scene)
     self.scene = scene
     self.setBackgroundBrush(QBrush(qt.white))
     self.setRenderHints(self.renderHints()|QPainter.Antialiasing)
     self.setHorizontalScrollBarPolicy(qt.ScrollBarAlwaysOff)
     self.setVerticalScrollBarPolicy(qt.ScrollBarAlwaysOff)
     self.scene.text_changed.connect(self.viewport().update) # ensure a full redraw
Esempio n. 7
0
 def __init__(self, scene):
     QGraphicsView.__init__(self, scene)
     self.scene = scene
     self.setBackgroundBrush(QBrush(qt.white))
     self.setRenderHints(self.renderHints()|QPainter.Antialiasing)
     self.setHorizontalScrollBarPolicy(qt.ScrollBarAlwaysOff)
     self.setVerticalScrollBarPolicy(qt.ScrollBarAlwaysOff)
     self.scene.text_changed.connect(self.viewport().update) # ensure a full redraw
Esempio n. 8
0
 def mouseReleaseEvent(self, e):
     if e.button()==qt.MidButton or (e.button()==qt.RightButton and self.scene.supress):
         fake = QMouseEvent(e.type(), e.pos(), qt.LeftButton, qt.LeftButton, e.modifiers())
         QGraphicsView.mouseReleaseEvent(self, fake)
         self.setDragMode(QGraphicsView.NoDrag)
         self.scene.supress = False
     else:
         QGraphicsView.mouseReleaseEvent(self, e)
Esempio n. 9
0
 def keyPressEvent(self, e):
     evt = self._get_event(e, QEvent.MouseButtonPress)
     if evt:
         self.mousePressEvent(evt)
     else:
         QGraphicsView.keyPressEvent(self, e)
     item = self.itemAt(self.mapFromGlobal(QCursor.pos()))
     if item:
         item.keyPressEvent(e)
Esempio n. 10
0
 def keyPressEvent(self, e):
     evt = self._get_event(e, QEvent.MouseButtonPress)
     if evt:
         self.mousePressEvent(evt)
     else:
         QGraphicsView.keyPressEvent(self, e)
     item = self.itemAt(self.mapFromGlobal(QCursor.pos()))
     if item:
         item.keyPressEvent(e)
Esempio n. 11
0
 def __init__(self, scene):
     QGraphicsView.__init__(self, scene)
     self.scene = scene
     self.setBackgroundBrush(QBrush(qt.white))
     self.setResizeAnchor(QGraphicsView.AnchorViewCenter)
     self.setTransformationAnchor(QGraphicsView.AnchorUnderMouse)
     self.setRenderHints(self.renderHints()|QPainter.Antialiasing)
     self.setHorizontalScrollBarPolicy(qt.ScrollBarAlwaysOff)
     self.setVerticalScrollBarPolicy(qt.ScrollBarAlwaysOff)
     inf = -1e10
     self.setSceneRect(QRectF(QPointF(-inf, -inf), QPointF(inf, inf)))
     self.scale(50, 50) #*1.00955
Esempio n. 12
0
 def __init__(self, scene):
     QGraphicsView.__init__(self, scene)
     self.scene = scene
     self.setBackgroundBrush(QBrush(qt.white))
     self.setResizeAnchor(QGraphicsView.AnchorViewCenter)
     self.setTransformationAnchor(QGraphicsView.AnchorUnderMouse)
     self.setRenderHints(self.renderHints()|QPainter.Antialiasing)
     self.setHorizontalScrollBarPolicy(qt.ScrollBarAlwaysOff)
     self.setVerticalScrollBarPolicy(qt.ScrollBarAlwaysOff)
     inf = -1e10
     self.setSceneRect(QRectF(QPointF(-inf, -inf), QPointF(inf, inf)))
     self.scale(50, 50) #*1.00955
Esempio n. 13
0
 def paintEvent(self, e):
     QGraphicsView.paintEvent(self, e)
     g = QPainter(self.viewport())
     g.setRenderHints(self.renderHints())
     try:
         self._info_font
     except AttributeError:
         self._info_font = g.font()
         multiply_font_size(self._info_font, 3)
     
     try:
         txt = ('{r} ({m})' if self.scene.mistakes else '{r}').format(r=self.scene.remaining, m=self.scene.mistakes)
         g.setFont(self._info_font)
         g.drawText(self.viewport().rect().adjusted(5, 2, -5, -2), qt.AlignTop|qt.AlignRight, txt)
     except AttributeError:
         pass
Esempio n. 14
0
 def paintEvent(self, e):
     QGraphicsView.paintEvent(self, e)
     g = QPainter(self.viewport())
     g.setRenderHints(self.renderHints())
     try:
         self._info_font
     except AttributeError:
         self._info_font = g.font()
         multiply_font_size(self._info_font, 3)
     
     try:
         txt = ('{r} ({m})' if self.scene.mistakes else '{r}').format(r=self.scene.remaining, m=self.scene.mistakes)
         g.setFont(self._info_font)
         g.drawText(self.viewport().rect().adjusted(5, 2, -5, -2), qt.AlignTop|qt.AlignRight, txt)
     except AttributeError:
         pass
Esempio n. 15
0
 def resizeEvent(self, e):
     QGraphicsView.resizeEvent(self, e)
     if not self.scene.playtest:
         self.fit()
Esempio n. 16
0
 def keyReleaseEvent(self, e):
     evt = self._get_event(e, QEvent.MouseButtonRelease)
     if evt:
         self.mouseReleaseEvent(evt)
     else:
         QGraphicsView.keyReleaseEvent(self, e)
Esempio n. 17
0
 def resizeEvent(self, e):
     QGraphicsView.resizeEvent(self, e)
     if not self.scene.playtest:
         self.fit()
Esempio n. 18
0
 def keyReleaseEvent(self, e):
     evt = self._get_event(e, QEvent.MouseButtonRelease)
     if evt:
         self.mouseReleaseEvent(evt)
     else:
         QGraphicsView.keyReleaseEvent(self, e)