Thread: [Plib-cvs] plib/src/pui pu.h,1.137,1.138 puInput.cxx,1.31,1.32 puLargeInput.cxx,1.45,1.46
Brought to you by:
sjbaker
From: Norman V. <nh...@us...> - 2003-02-07 16:04:29
|
Update of /cvsroot/plib/plib/src/pui In directory sc8-pr-cvs1:/tmp/cvs-serv26203 Modified Files: pu.h puInput.cxx puLargeInput.cxx Log Message: changes from John Fay fix some compiler warnings in 'puInput' and 'puLargeInput'. It also fixes a couple of bugs dealing with order of operations. Finally, it keeps the 'puInput' cursor visible by scrolling the text. Index: pu.h =================================================================== RCS file: /cvsroot/plib/plib/src/pui/pu.h,v retrieving revision 1.137 retrieving revision 1.138 diff -u -d -r1.137 -r1.138 --- pu.h 7 Feb 2003 15:02:49 -0000 1.137 +++ pu.h 7 Feb 2003 16:04:23 -0000 1.138 @@ -1522,7 +1522,7 @@ void setValidData ( const char *data ) { delete [] valid_data ; - valid_data = data != NULL ? ulStrDup ( data ) : NULL ; + valid_data = ( data != NULL ) ? ulStrDup ( data ) : NULL ; } void addValidData ( const char *data ) ; @@ -1538,7 +1538,7 @@ void disableInput ( void ) { input_disabled = TRUE ; } int inputDisabled ( void ) const { return input_disabled ; } - puInputBase ( puObject *wgt ) + puInputBase ( void ) { accepting = FALSE ; cursor_position = 0 ; @@ -1546,7 +1546,7 @@ select_end_position = -1 ; valid_data = NULL; - widget = wgt ; + widget = (puObject *)NULL ; input_disabled = FALSE ; } @@ -1572,12 +1572,14 @@ } puInput ( int minx, int miny, int maxx, int maxy ) : - puInputBase ( this ), puObject ( minx, miny, maxx, maxy ) + puInputBase (), puObject ( minx, miny, maxx, maxy ) { type |= PUCLASS_INPUT ; setColourScheme ( 0.8f, 0.7f, 0.7f ) ; /* Yeukky Pink */ setColour ( PUCOL_MISC, 0.1f, 0.1f, 1.0f ) ; /* Colour of 'I' bar cursor */ + + widget = this ; } } ; Index: puInput.cxx =================================================================== RCS file: /cvsroot/plib/plib/src/pui/puInput.cxx,v retrieving revision 1.31 retrieving revision 1.32 diff -u -d -r1.31 -r1.32 --- puInput.cxx 27 Sep 2002 23:53:52 -0000 1.31 +++ puInput.cxx 7 Feb 2003 16:04:24 -0000 1.32 @@ -27,20 +27,32 @@ UL_RTTI_DEF2(puInput,puInputBase,puObject) -static char *chop_to_width ( puFont fnt, const char *s, int width, int *ncut ) +static char *chop_to_width ( puFont fnt, const char *s, int width, int cursor_position, int *ncut ) { - char *res = new char [ strlen ( s ) + 1 ] ; + int new_len = strlen ( s ) ; + char *res = new char [ new_len + 1 ] ; int n = 0 ; int w ; do { - strcpy ( res, & s[n] ) ; + memcpy ( res, s + n, new_len + 1 ) ; n++ ; + new_len -- ; w = fnt.getStringWidth ( res ) + 2 * PUSTR_RGAP + PUSTR_LGAP ; - } while ( w >= width ) ; + } while ( ( w >= width ) && ( n < cursor_position - 1 ) ) ; - if ( ncut != NULL ) *ncut = n-1 ; + if ( ncut != NULL ) *ncut = n - 1 ; + + n = 0 ; + + while ( w >= width ) + { + res[new_len] = '\0' ; + n++ ; + new_len -- ; + w = fnt.getStringWidth ( res ) + 2 * PUSTR_RGAP + PUSTR_LGAP ; + } return res ; } @@ -74,7 +86,7 @@ if ( select_end_position > 0 && select_end_position != select_start_position ) { - s2 = chop_to_width ( legendFont, getStringValue(), abox.max[0]-abox.min[0], &ncut ) ; + s2 = chop_to_width ( legendFont, getStringValue(), abox.max[0]-abox.min[0], getCursor (), &ncut ) ; int sep = select_end_position - ncut ; int ssp = select_start_position - ncut ; @@ -115,7 +127,7 @@ colour [ PUCOL_LEGEND ][3] / 2.0f ) ; /* 50% more transp */ s2 = chop_to_width ( legendFont, getStringValue(), - abox.max[0]-abox.min[0], &ncut ) ; + abox.max[0]-abox.min[0], getCursor (), &ncut ) ; legendFont.drawString ( s2, dx + abox.min[0] + xx, @@ -178,7 +190,7 @@ int ncut ; char *s2 = chop_to_width ( legendFont, getStringValue(), - abox.max[0]-abox.min[0], &ncut ) ; + abox.max[0]-abox.min[0], getCursor (), &ncut ) ; int i = strlen ( s2 ) ; int length, prev_length ; Index: puLargeInput.cxx =================================================================== RCS file: /cvsroot/plib/plib/src/pui/puLargeInput.cxx,v retrieving revision 1.45 retrieving revision 1.46 diff -u -d -r1.45 -r1.46 --- puLargeInput.cxx 27 Sep 2002 23:53:53 -0000 1.45 +++ puLargeInput.cxx 7 Feb 2003 16:04:24 -0000 1.46 @@ -66,7 +66,7 @@ // Public functions from the widget itself puLargeInput::puLargeInput ( int x, int y, int w, int h, int arrows, int sl_width, int wrap_text ) : - puInputBase ( this ), puGroup ( x, y ) + puInputBase (), puGroup ( x, y ) { setColour ( PUCOL_MISC, 0.1f, 0.1f, 1.0f ) ; // Colour of the 'I' bar cursor @@ -79,6 +79,8 @@ ( getLegendFont().getStringHeight() + getLegendFont().getStringDescender() + 1 ) ; top_line_in_window = 0 ; max_width = 0 ; + + widget = this ; // Set up the widgets |