test/testime.c
branchgsoc2009_IME
changeset 3136 962357f325e1
parent 3134 f896821736fb
child 3137 311c678f3b2e
equal deleted inserted replaced
3135:f4e553ec6a62 3136:962357f325e1
    63     }
    63     }
    64 }
    64 }
    65 
    65 
    66 void CleanupVideo()
    66 void CleanupVideo()
    67 {
    67 {
       
    68     SDL_StopTextInput();
    68     TTF_CloseFont(font);
    69     TTF_CloseFont(font);
    69     TTF_Quit();
    70     TTF_Quit();
    70 }
    71 }
    71 
    72 
    72 void InitInput()
    73 void InitInput()
    80     textRect.h = 50;
    81     textRect.h = 50;
    81 
    82 
    82     text[0] = 0;
    83     text[0] = 0;
    83     markedRect = textRect;
    84     markedRect = textRect;
    84     markedText = NULL;
    85     markedText = NULL;
       
    86 
       
    87     SDL_StartTextInput();
    85 }
    88 }
    86 
    89 
    87 static void RenderText(SDL_Surface *sur,
    90 static void RenderText(SDL_Surface *sur,
    88                         TTF_Font *font,
    91                         TTF_Font *font,
    89                         const char *text,
    92                         const char *text,
   113     markedRect.x = textRect.x + w;
   116     markedRect.x = textRect.x + w;
   114     markedRect.w = textRect.w - w;
   117     markedRect.w = textRect.w - w;
   115     if (markedRect.w < 0)
   118     if (markedRect.w < 0)
   116     {
   119     {
   117         SDL_Flip(screen);
   120         SDL_Flip(screen);
       
   121         // Stop text input because we cannot hold any more characters
       
   122         SDL_StopTextInput();
   118         return;
   123         return;
   119     }
   124     }
   120 
   125 
   121     SDL_FillRect(screen, &markedRect, backColor);
   126     SDL_FillRect(screen, &markedRect, backColor);
   122 
   127 
   137     cursorRect.h = h;
   142     cursorRect.h = h;
   138     SDL_FillRect(screen, &cursorRect, lineColor);
   143     SDL_FillRect(screen, &cursorRect, lineColor);
   139 
   144 
   140     SDL_Flip(screen);
   145     SDL_Flip(screen);
   141 
   146 
   142     SDL_StartTextInput(&markedRect);
   147     SDL_SetTextInputRect(&markedRect);
   143 }
   148 }
   144 
   149 
   145 void
   150 void
   146 HotKey_ToggleFullScreen(void)
   151 HotKey_ToggleFullScreen(void)
   147 {
   152 {