[Kalzium] KDE/kdeedu/kalzium/src

Carsten Niehaus cniehaus at gmx.de
Thu Jul 14 23:28:35 CEST 2005


SVN commit 434631 by cniehaus:

Wow, very nice patch from Eloy Cuadra. The table looks now much better

CCMAIL: ecuadra at eloihr.net
CCMAIL: kalzium at kde.org


 M  +8 -1      element.cpp  
 M  +14 -6     pse.cpp  


--- trunk/KDE/kdeedu/kalzium/src/element.cpp #434630:434631
@@ -483,7 +483,14 @@
 
 int Element::yPos() const
 {
-	return ( y-1 )*ELEMENTSIZE + ELEMENTSIZE;
+// original
+//	return ( y-1 )*ELEMENTSIZE + ELEMENTSIZE;
+  int tmp_y = ( y-1 )*ELEMENTSIZE + ELEMENTSIZE;
+
+  if ( (m_number > 57 && m_number < 72) || (m_number > 89 && m_number < 104) )
+	tmp_y += ELEMENTSIZE/3;
+
+  return tmp_y;
 }
 
 QPoint Element::pos() const
--- trunk/KDE/kdeedu/kalzium/src/pse.cpp #434630:434631
@@ -393,9 +393,11 @@
 	if (m_currentPoint.x() == -1)
 		return;
 
-	int x = m_currentPoint.x()-1;
-	int y = m_currentPoint.y();
+	int x = (m_currentPoint.x()-1)*ELEMENTSIZE;
+	int y = m_currentPoint.y()*ELEMENTSIZE;
 
+	if (m_currentPoint.y() > 7) y += ELEMENTSIZE/3;
+
 	QPainter p;
 	p.begin(table);
 
@@ -405,11 +407,11 @@
 	pen.setColor( Qt::blue );
 	p.setPen( pen );
 
-	p.drawEllipse( x*ELEMENTSIZE-10,y*ELEMENTSIZE-10,ELEMENTSIZE+20,ELEMENTSIZE+20 );
+	p.drawEllipse( x-10,y-10,ELEMENTSIZE+20,ELEMENTSIZE+20 );
 	pen.setWidth( 3 );
 	pen.setColor( Qt::red );
 	p.setPen( pen );
-	p.drawEllipse( x*ELEMENTSIZE-5,y*ELEMENTSIZE-5,ELEMENTSIZE+10,ELEMENTSIZE+10 );
+	p.drawEllipse( x-5,y-5,ELEMENTSIZE+10,ELEMENTSIZE+10 );
 
 	p.end();
 }
@@ -768,7 +770,9 @@
 	
 	//for the y-position I need to substract ELEMENTSIZE pixel because
 	//the whole table doesn't start at (0,0) but at (0,ELEMENTSIZE)
-	int Y = ( mouse->y()-ELEMENTSIZE)/ELEMENTSIZE;
+	int Y = mouse->y()-ELEMENTSIZE;
+	if (Y > (ELEMENTSIZE*7)) Y -= ELEMENTSIZE/3;
+	Y /= ELEMENTSIZE;
 		
 	X += 1;
 	Y += 1;
@@ -1114,7 +1118,11 @@
 QPoint PSE::ElementUnderMouse()
 {
 	int X = mapFromGlobal( QCursor::pos() ).x()/ELEMENTSIZE;
-	int Y = ( mapFromGlobal( QCursor::pos() ).y( )-ELEMENTSIZE)/ELEMENTSIZE;
+	int Y = mapFromGlobal( QCursor::pos() ).y( )-ELEMENTSIZE;
+
+	if (Y > (ELEMENTSIZE*7)) Y -= ELEMENTSIZE/3;
+
+	Y /= ELEMENTSIZE;
 	
 	X += 1;
 	Y += 1;


More information about the Kalzium mailing list