[Plib-cvs] plib/src/pui pu.h,1.112,1.113 puLargeInput.cxx,1.32,1.33
Brought to you by:
sjbaker
From: James J. <pu...@us...> - 2002-07-12 01:55:20
|
Update of /cvsroot/plib/plib/src/pui In directory usw-pr-cvs1:/tmp/cvs-serv32732 Modified Files: pu.h puLargeInput.cxx Log Message: PuLargeInput: Added support for all normal editing keys (pgup/down, end/home, arrows, etc...) so it acts much more like a normal text editor. Removed callbacks from the puSliders. Index: pu.h =================================================================== RCS file: /cvsroot/plib/plib/src/pui/pu.h,v retrieving revision 1.112 retrieving revision 1.113 diff -u -d -r1.112 -r1.113 --- pu.h 12 Jul 2002 01:01:24 -0000 1.112 +++ pu.h 12 Jul 2002 01:55:16 -0000 1.113 @@ -1716,6 +1716,7 @@ void setSize ( int w, int h ) ; int getNumLines ( void ) const { return num_lines ; } + int getLinesInWindow ( void ) const { return lines_in_window ; } void setTopLineInWindow ( int val ) { top_line_in_window = val ; } void draw ( int dx, int dy ) ; Index: puLargeInput.cxx =================================================================== RCS file: /cvsroot/plib/plib/src/pui/puLargeInput.cxx,v retrieving revision 1.32 retrieving revision 1.33 diff -u -d -r1.32 -r1.33 --- puLargeInput.cxx 20 Jun 2002 20:07:53 -0000 1.32 +++ puLargeInput.cxx 12 Jul 2002 01:55:16 -0000 1.33 @@ -50,14 +50,20 @@ float val ; slider->getValue ( &val ) ; val = 1.0f - val ; + int lines_in_window = text->getLinesInWindow () ; int num_lines = text->getNumLines () ; if ( num_lines > 0 ) { int idx = int ( num_lines * val + 0.5 ) + inc ; - if ( idx > num_lines ) idx = num_lines ; + /* Modified so that when clicking the down arrows, they will not scroll lines_in_window */ + /* off the screen any longer, requiring "transparent" or "do-nothing" clicks of the top */ [...587 lines suppressed...] + /* If running off the screen, scroll right. - JCJ 28 Jun 2002 */ + if ((bottom_value*max_width)+(box_width) < line_width_to_cursor+5) { + bottom_slider->setValue( ((bottom_value*max_width)+(box_width/2)+5)/max_width ) ; + } + + if (key == '\n') { + /* If pressing enter, figure out which line this is. */ + while ( line_counter < cursor_position) { + if ( old_text [ line_counter ] == '\n' ) current_line_in_window++ ; + line_counter++ ; + } + /* If hitting enter at the bottom of the screen, scroll down. - JCJ 28 Jun 2002 */ + if ( (current_line_in_window+1) >= bottom_line_in_window ) { + setTopLineInWindow ( top_line_in_window + 1 ); + right_slider->setValue (1.0f - (float)top_line_in_window / num_lines ) ; + } + } setText ( p ) ; setCursor ( temp_cursor + 1 ) ; |