mElite  1.0
An Elite clone based on TextElite by Jan-Philipp Kappmeier and Melanie Schmidt.
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
TextInput.cpp
Go to the documentation of this file.
1 
6 #include "TextInput.h"
7 
13  m_tf = tf;
14  text[0] = 0;
15  letterCount = 0;
16 }
17 
22 }
23 
27 GLvoid TextInput::back( GLvoid ) {
28  if( letterCount > 0 )
29  text[letterCount--] = 0;
30 }
31 
32 
36 char * TextInput::getText( GLvoid ) {
37  return text;
38 }
39 
41 
45 GLvoid TextInput::newLetter( char letter ) {
46  if( letterCount == 254 )
47  return;
48  text[letterCount++] = letter;
49  text[letterCount] = 0;
50 }
51 
53 
56 GLvoid TextInput::print( GLvoid ) {
57  // show blinking cursor
58  if( glutGet( GLUT_ELAPSED_TIME )/500 % 2 == 0)
59  m_tf->print( 50, 50, text, 800, 600 );
60  else {
61  text[letterCount] = '_';
62  text[letterCount + 1] = 0;
63  m_tf->print( 50, 50, text, 800, 600 );
64  text[letterCount] = 0;
65  }
66 }
67 
71 GLvoid TextInput::reset( GLvoid ) {
72  text[0] = 0;
73  letterCount = 0;
74 }