Update of /cvsroot/plib/plib/src/pui
In directory usw-pr-cvs1:/tmp/cvs-serv14211/src/pui
Modified Files:
puFont.cxx puObject.cxx
Log Message:
Paul Deppe's multi-line fix
Index: puFont.cxx
===================================================================
RCS file: /cvsroot/plib/plib/src/pui/puFont.cxx,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- puFont.cxx 21 Dec 2001 14:27:36 -0000 1.8
+++ puFont.cxx 27 Feb 2002 02:58:34 -0000 1.9
@@ -64,14 +64,24 @@
if ( glut_font_handle != (GlutFont) 0 )
{
int res = 0 ;
+ int max_res = 0 ;
while ( *str != '\0' )
{
- res += glutBitmapWidth ( glut_font_handle, *str ) ;
- str++ ;
+ if ( *str == '\n' )
+ {
+ if ( res > max_res ) max_res = res;
+ res = 0;
+ }
+ else
+ {
+ res += glutBitmapWidth ( glut_font_handle, *str ) ;
+ }
+ str++ ;
}
+ if ( res > max_res ) max_res = res;
- return res ;
+ return max_res ;
}
#endif // #ifdef _PU_USE_GLUT_FONTS
Index: puObject.cxx
===================================================================
RCS file: /cvsroot/plib/plib/src/pui/puObject.cxx,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -d -r1.36 -r1.37
--- puObject.cxx 21 Dec 2001 14:27:36 -0000 1.36
+++ puObject.cxx 27 Feb 2002 02:58:34 -0000 1.37
@@ -24,6 +24,26 @@
#include "puLocal.h"
+static int count_lines( const char *str )
+{
+ int k; // counts lines
+
+ if ( str == NULL )
+ k = 0;
+ else if ( strlen( str ) == 0 )
+ k = 0;
+ else
+ {
+ k = 1; // there's at least one line here
+ while ( *str != '\0' )
+ {
+ if ( *str == '\n' ) k++; // add 1 for each EOL
+ str++;
+ }
+ }
+ return( k );
+}
+
inline float clamp01 ( float x )
{
return (x >= 1.0f) ? 1.0f : x ;
@@ -310,7 +330,10 @@
case PUPLACE_LOWER_LEFT : /* Backwards compatibility to PUPLACE_LEFT */
case PUPLACE_LOWER_RIGHT : /* Backwards compatibility to PUPLACE_RIGHT */
default :
- yy = ( abox.max[1] - abox.min[1] - legendFont.getStringHeight () ) / 2 ;
+ //yy = ( abox.max[1] - abox.min[1] - legendFont.getStringHeight () ) / 2 ;
+ yy = ( abox.max[1] - abox.min[1] +
+ count_lines( legend ) * legendFont.getStringHeight () ) / 2 -
+ legendFont.getStringHeight() ;
break ;
case PUPLACE_BOTTOM_LEFT :
@@ -395,7 +418,10 @@
case PUPLACE_CENTERED_LEFT :
case PUPLACE_CENTERED_RIGHT :
default :
- yy = ( bbox.max[1] - bbox.min[1] - labelFont.getStringHeight () ) / 2 ;
+ //yy = ( bbox.max[1] - bbox.min[1] - labelFont.getStringHeight () ) / 2 ;
+ yy = ( bbox.max[1] - bbox.min[1] +
+ count_lines( label ) * labelFont.getStringHeight () ) / 2 -
+ labelFont.getStringHeight() ;
break ;
case PUPLACE_LOWER_LEFT :
@@ -479,5 +505,3 @@
lowlight () ;
return FALSE ;
}
-
-
|