void GLUI_EditText::draw( int x, int y ) { GLUI_DRAWINGSENTINAL_IDIOM int name_x; name_x = MAX(text_x_offset - string_width(this->name) - 3,0); draw_name( name_x , 13); glBegin( GL_LINES ); glColor3f( .5, .5, .5 ); glVertex2i( text_x_offset, 0 ); glVertex2i( w, 0 ); glVertex2i( text_x_offset, 0 ); glVertex2i( text_x_offset, h ); glColor3f( 1., 1., 1. ); glVertex2i( text_x_offset, h ); glVertex2i( w, h ); glVertex2i( w, h ); glVertex2i( w, 0 ); if ( enabled ) glColor3f( 0., 0., 0. ); else glColor3f( .25, .25, .25 ); glVertex2i( text_x_offset+1, 1 ); glVertex2i( w-1, 1 ); glVertex2i( text_x_offset+1, 1 ); glVertex2i( text_x_offset+1, h-1 ); glColor3f( .75, .75, .75 ); glVertex2i( text_x_offset+1, h-1 ); glVertex2i( w-1, h-1 ); glVertex2i( w-1, h-1 ); glVertex2i( w-1, 1 ); glEnd(); /** Find where to draw the text **/ update_substring_bounds(); draw_text(0,0); draw_insertion_pt(); }
void GLUI_TextBox::deactivate( void ) { active = false; if ( NOT glui ) return; if ( debug ) dump( stdout, "-> DISACTIVATE" ); sel_start = sel_end = insertion_pt = -1; /***** Retrieve the current value from the text *****/ /***** The live variable will be updated by set_text() ****/ set_text(text.c_str()); /* This will force callbacks and gfx refresh */ update_substring_bounds(); /******** redraw text without insertion point ***********/ redraw(); /***** Now do callbacks if value changed ******/ if ( orig_text != text ) { this->execute_callback(); } if ( debug ) dump( stdout, "<- DISACTIVATE" ); }
void GLUI_EditText::update_and_draw_text( void ) { if ( NOT can_draw() ) return; update_substring_bounds(); /* printf( "ss: %d/%d\n", substring_start, substring_end ); */ redraw(); }
void GLUI_EditText::draw( int x, int y ) { int orig; int name_x; if ( NOT can_draw() ) return; orig = set_to_glut_window(); name_x = MAX(text_x_offset - string_width(this->name) - 3,0); draw_name( name_x , 13); glBegin( GL_LINES ); glColor3f( .5, .5, .5 ); glVertex2i( text_x_offset, 0 ); glVertex2i( w, 0 ); glVertex2i( text_x_offset, 0 ); glVertex2i( text_x_offset, h ); glColor3f( 1., 1., 1. ); glVertex2i( text_x_offset, h ); glVertex2i( w, h ); glVertex2i( w, h ); glVertex2i( w, 0 ); if ( enabled ) glColor3f( 0., 0., 0. ); else glColor3f( .25, .25, .25 ); glVertex2i( text_x_offset+1, 1 ); glVertex2i( w-1, 1 ); glVertex2i( text_x_offset+1, 1 ); glVertex2i( text_x_offset+1, h-1 ); glColor3f( .75, .75, .75 ); glVertex2i( text_x_offset+1, h-1 ); glVertex2i( w-1, h-1 ); glVertex2i( w-1, h-1 ); glVertex2i( w-1, 1 ); glEnd(); /** Find where to draw the text **/ update_substring_bounds(); draw_text(0,0); draw_insertion_pt(); restore_window(orig); }
void GLUI_EditText::deactivate( void ) { int new_int_val; float new_float_val; double new_double_val; active = false; if ( NOT glui ) return; if ( debug ) dump( stdout, "-> DISACTIVATE" ); sel_start = sel_end = insertion_pt = -1; /***** Retrieve the current value from the text *****/ /***** The live variable will be updated by set_text() ****/ if ( data_type == GLUI_EDITTEXT_FLOAT ) { if ( text.length() == 0 ) /* zero-length string - make it "0.0" */ text = "0.0"; new_float_val = atof( text.c_str() ); set_float_val( new_float_val ); } else if ( data_type == GLUI_EDITTEXT_DOUBLE ) { if ( text.length() == 0 ) /* zero-length string - make it "0.0" */ text = "0.0"; new_double_val = atof( text.c_str() ); set_double_val( new_double_val ); } else if ( data_type == GLUI_EDITTEXT_INT ) { if ( text.length() == 0 ) /* zero-length string - make it "0" */ text = "0"; new_int_val = atoi( text.c_str() ); set_int_val( new_int_val ); } else if ( data_type == GLUI_EDITTEXT_TEXT ) { set_text(text); /* This will force callbacks and gfx refresh */ } update_substring_bounds(); /******** redraw text without insertion point ***********/ redraw(); /***** Now do callbacks if value changed ******/ if ( orig_text != text ) { this->execute_callback(); if ( 0 ) { /* THE CODE BELOW IS FROM WHEN SPINNER ALSO MAINTAINED CALLBACKS */ if ( spinner == NULL ) { /** Are we independent of a spinner? **/ if ( callback ) { callback( this ); } } else { /* We're attached to a spinner */ spinner->do_callbacks(); /* Let the spinner do the callback stuff */ } } } if ( debug ) dump( stdout, "<- DISACTIVATE" ); }