test/testime.c
branchgsoc2009_IME
changeset 3133 84119fe89d26
parent 3132 88861448961f
child 3134 f896821736fb
     1.1 --- a/test/testime.c	Wed Jul 01 07:33:58 2009 +0000
     1.2 +++ b/test/testime.c	Wed Jul 01 16:12:00 2009 +0000
     1.3 @@ -63,8 +63,9 @@
     1.4      }
     1.5  
     1.6      /* Prepare a rect for text input */
     1.7 -    SDL_Rect textRect = { 100, 80, 300, 50 }, markedRect;
     1.8 +    SDL_Rect textRect = { 100, 80, 300, 50 }, markedRect, underlineRect, cursorRect;
     1.9      Uint32 backColor = SDL_MapRGB(screen->format, 0xFF, 0xFF, 0xFF);
    1.10 +    Uint32 lineColor = SDL_MapRGB(screen->format, 0x0, 0x0, 0x0);
    1.11      SDL_Color textColor = { 0, 0, 0 };
    1.12      SDL_FillRect(screen, &textRect, backColor);
    1.13  
    1.14 @@ -106,6 +107,11 @@
    1.15              render_text(screen, font, text, textRect.x, textRect.y, textColor);
    1.16              TTF_SizeUTF8(font, text, &w, &h);
    1.17              markedRect.x = textRect.x + w;
    1.18 +
    1.19 +            cursorRect = markedRect;
    1.20 +            cursorRect.w = 2;
    1.21 +            cursorRect.h = h;
    1.22 +            SDL_FillRect(screen, &cursorRect, lineColor);
    1.23              SDL_Flip(screen);
    1.24  
    1.25              SDL_StartTextInput(&markedRect);
    1.26 @@ -117,6 +123,13 @@
    1.27  
    1.28              SDL_FillRect(screen, &markedRect, backColor);
    1.29              render_text(screen, font, event.edit.text, markedRect.x, markedRect.y, textColor);
    1.30 +            TTF_SizeUTF8(font, event.edit.text, &w, &h);
    1.31 +            underlineRect = markedRect;
    1.32 +            underlineRect.y += (h - 2);
    1.33 +            underlineRect.h = 2;
    1.34 +            underlineRect.w = w;
    1.35 +            SDL_FillRect(screen, &underlineRect, lineColor);
    1.36 +
    1.37              SDL_Flip(screen);
    1.38              break;
    1.39