original 1.0.1 release
[xwelltris.git] / src / wellinput.cxx
blob8e260f1fb247ddf82a3e2dfd81f4a52d11b225c9
1 // docm_prefix(///)
2 /****************************************************************************
3 * Copyright (C) 2002 by Leo Khramov
4 * email: leo@xnc.dubna.su
5 *
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: wellinput.cxx,v 1.2 2003/02/21 11:40:33 leo Exp $
17 #include "globals.h"
18 #include "wellinput.h"
19 #include "wellengine.h"
21 //////////////////////////////WellInput class///////////////////////////////
23 //===========================================================================
24 /// global WellInput(char*)
25 /// constructor - fill name and get geometry
26 /// tags WellInput
27 WellInput::WellInput(char* iname) : WellObject()
29 strncpy(object_name,iname,GEO_NAME);
30 object_name[GEO_NAME]=0;
31 geo=get_geo_by_name(object_name);
32 fnt=default_well_engine->new_well_image_font(imFont1,FONT2_L,FONT2_H,
33 FONT2_DX,FONT2_DY);
34 fnt->set_screen_region(geo[1].tox, geo[1].toy, geo[1].l, geo[1].h);
38 //===========================================================================
39 /// global process_event(wEvent)
40 /// stub that process events
41 /// tags WellInput
42 bool WellInput::process_event(wEvent ev)
44 switch(ev.type)
46 case eKeyPress:
47 dbgprintf(("WellInput - done\n"));
48 object_on_enter.call(wEvent(aInputDone,this));
49 return false;
52 return true;
55 //===========================================================================
56 /// global highlight(int mx, int my)
57 /// highlights key
58 /// tags WellInput
59 void WellInput::set_text(char* txt)
61 if(txt)
63 strcpy(buf,txt);
64 buflen=strlen(buf);
65 if(buflen>maxlen)
66 buflen=maxlen;
67 buf[buflen]=0;
68 pos=buflen;
69 } else
71 buflen=pos=0;
72 buf[buflen]=0;
77 //===========================================================================
78 /// global draw_text()
79 /// draw text on the screen
80 /// tags WellInput
81 void WellInput::draw_text()
83 fnt->draw_text(buf,buflen,BackColor);
86 //===========================================================================
87 /// global show()
88 /// show object
89 /// tags WellInput
90 void WellInput::show()
92 shown=true;
93 redraw();
94 default_well_engine->add_object(this);
97 //===========================================================================
98 /// global redraw()
99 /// redraw object
100 /// tags WellInput
101 void WellInput::redraw()
103 if(shown)
105 default_well_engine->screen_copy(&geo[0]);
106 draw_text();
110 //===========================================================================
111 /// global hide()
112 /// hide object
113 /// tags WellInput
114 void WellInput::hide()
116 shown=false;
117 default_well_engine->screen_clear(&geo[0]);
118 default_well_engine->del_object(this);