8 """ Standard QScrollArea extended by zooming capabilties. 14 QScrollArea.__init__(self, parent)
15 Zoomable.__init__(self)
21 """ If wheelEvent occurs either zoom window (ctrl-key pressed) or scroll the area. 23 if event.modifiers() == Qt.ControlModifier:
25 oldLeft = self.widget().mapFrom(self,QPoint(event.x(),0)).x()
26 oldTop = self.widget().mapFrom(self,QPoint(0,event.y())).y()
34 zoomFactor = newZoom / oldZoom
35 newLeft = oldLeft * zoomFactor
36 newTop = oldTop * zoomFactor
39 self.ensureVisible(newLeft-event.x()+self.viewport().
width()/2.0,newTop-event.y()+self.viewport().height()/2.0,self.viewport().
width()/2.0,self.viewport().height()/2.0)
40 self.emit(SIGNAL(
'wheelZoom()'))
42 QScrollArea.wheelEvent(self, event)
45 """ Sets its own zoom factor and passes it to it's child widget if child is Zoomable. 47 Zoomable.setZoom(self, zoom)
48 if isinstance(self.widget(), ZoomableWidget):
51 self.emit(SIGNAL(
"zoomChanged(float)"), zoom)
54 """Calls autosizeScrollWidget(). 57 QScrollArea.resizeEvent(self, event)
60 """Sets size of child widget to the size needed to fit whole content. 64 childrenRect = self.widget().childrenRect()
65 width =
max(self.viewport().
width(), childrenRect.bottomRight().x()) -
min(0, childrenRect.topLeft().x())
66 height =
max(self.viewport().height(), childrenRect.bottomRight().y()) -
min(0, childrenRect.topLeft().y())
67 self.widget().resize(width, height)
70 """ Forward mousePressEvent. 75 """ Forward valueChanged(int) signal from scroll bars to viewport widget. 77 If the widget (see QScrollArea.widget()) has a function called "scrollBarValueChanged", it will be called. 79 if hasattr(self.widget(),
"scrollBarValueChanged"):