2 /****************************************************************************
3 * Copyright (C) 2002-2003 by Leo Khramov
4 * email: leo@xnc.dubna.su
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 ****************************************************************************/
16 // $Id: sdlwellinput.cxx,v 1.2 2003/02/20 15:09:41 leo Exp $
18 /// module description
19 /// SDL implementation of WellInput class - make input text from user
20 /// display it through WellImageFont, convert SDL Key event to symbols
22 #include "sdlwellinput.h"
23 #include "sdl_gfxprimitives.h"
24 //===========================================================================
25 /// global SDLWellInput(char*)
26 /// constructor - fill name and get geometry
28 SDLWellInput::SDLWellInput(char* iname
) : WellInput(iname
)
30 engine
=(SDLWellEngine
*) default_well_engine
;
31 mainw
=engine
->get_main_window();
34 //===========================================================================
35 /// global process_event(wEvent)
36 /// stub that process events
38 bool SDLWellInput::process_event(wEvent ev
)
40 SDL_Event
*xev
=(SDL_Event
*)ev
.data
;
51 //===========================================================================
52 /// global draw_text()
53 /// draw text on the screen
55 void SDLWellInput::draw_text()
57 fnt
->draw_text(buf
,buflen
,BackColor
);
62 //===========================================================================
63 /// global show_cursor()
64 /// draw cursor on the screen
66 void SDLWellInput::show_cursor()
69 Uint32
*colors
=engine
->get_colors();
71 dest
.x
= geo
[1].tox
+buflen
*FONT2_L
;
77 SDL_FillRect(mainw
, &dest
, colors
[BonusColor2
]);
78 SDL_UpdateRects(mainw
, 1, &dest
);
82 //===========================================================================
83 /// global hide_cursor()
84 /// hide cursor on the screen
86 void SDLWellInput::hide_cursor()
89 Uint32
*colors
=engine
->get_colors();
91 dest
.x
= geo
[1].tox
+buflen
*FONT2_L
;
96 SDL_FillRect(mainw
, &dest
, colors
[BackColor
]);
97 SDL_UpdateRects(mainw
, 1, &dest
);
101 //===========================================================================
102 /// global process_key(SDLEvent)
103 /// draw text on the screen
104 /// tags SDLWellInput
106 void SDLWellInput::process_key(SDL_Event
*xev
)
108 switch(xev
->key
.keysym
.sym
)
112 object_on_enter
.call(wEvent(aInputDone
,this));
127 xev
->key
.keysym
.unicode
>=32 &&
128 xev
->key
.keysym
.unicode
<128)
131 buf
[buflen
++]=(char)xev
->key
.keysym
.unicode
;