[Kstars-devel] kdeedu/kstars/kstars
Jason Harris
kstars at 30doradus.org
Sun Jul 25 23:35:29 CEST 2004
CVS commit by harris:
There is now a "magnifying glass" mouse cursor, which is shown while
Ctrl+LMB are pressed (this is the mode to define a "zoom box")
CCMAIL: kstars-devel at kde.org
M +35 -0 skymap.cpp 1.144
M +4 -0 skymap.h 1.65
M +4 -1 skymapevents.cpp 1.96
--- kdeedu/kstars/kstars/skymap.cpp #1.143:1.144
@@ -1191,7 +1191,42 @@ bool SkyMap::unusablePoint (double dx, d
}
+void SkyMap::setZoomMouseCursor()
+{
+ mouseMoveCursor = false; // no mousemove cursor
+
+ QPainter p;
+ QPixmap cursorPix (32, 32); // size 32x32 (this size is compatible to all systems)
+// the center of the pixmap
+ int mx = cursorPix. width() / 2;
+ int my = cursorPix. height() / 2;
+
+ cursorPix.fill (white); // white background
+ p.begin (&cursorPix);
+ p.setPen (QPen (black, 2)); // black lines
+
+ p.drawEllipse( mx - 7, my - 7, 14, 14 );
+ p.drawLine( mx + 5, my + 5, mx + 11, my + 11 );
+ p.end();
+
+// create a mask to make parts of the pixmap invisible
+ QBitmap mask (32, 32);
+ mask.fill (color0); // all is invisible
+
+ p.begin (&mask);
+// paint over the parts which should be visible
+ p.setPen (QPen (color1, 3));
+ p.drawEllipse( mx - 7, my - 7, 14, 14 );
+ p.drawLine( mx + 5, my + 5, mx + 12, my + 12 );
+ p.end();
+
+ cursorPix.setMask (mask); // set the mask
+ QCursor cursor (cursorPix);
+ setCursor (cursor);
+}
+
void SkyMap::setDefaultMouseCursor()
{
mouseMoveCursor = false; // no mousemove cursor
+
QPainter p;
QPixmap cursorPix (32, 32); // size 32x32 (this size is compatible to all systems)
--- kdeedu/kstars/kstars/skymap.h #1.64:1.65
@@ -895,4 +895,8 @@ private:
void setDefaultMouseCursor();
+/**@short Sets the shape of the mouse cursor to a magnifying glass.
+ */
+ void setZoomMouseCursor();
+
/**Check if the current point on screen is a valid point on the sky. This is needed
*to avoid a crash of the program if the user clicks on a point outside the sky (the
--- kdeedu/kstars/kstars/skymapevents.cpp #1.95:1.96
@@ -562,7 +562,9 @@ void SkyMap::mouseReleaseEvent( QMouseEv
ksw->zoom( Options::zoomFactor() * factor );
+ setDefaultMouseCursor();
ZoomRect = QRect(); //invalidate ZoomRect
forceUpdate();
} else {
+ setDefaultMouseCursor();
ZoomRect = QRect(); //just in case user Ctrl+clicked + released w/o dragging...
}
@@ -597,4 +599,5 @@ void SkyMap::mousePressEvent( QMouseEven
if ( (e->state() & ControlButton) && (e->button() == LeftButton) ) {
ZoomRect.moveCenter( e->pos() );
+ setZoomMouseCursor();
update(); //refresh without redrawing skymap
return;
More information about the Kstars-devel
mailing list