2 /****************************************************************************
3 * Copyright (C) 2002 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: wellswitch.cxx,v 1.1.1.1 2003/01/04 11:37:22 leo Exp $
18 /// module description
19 /// WellSwitch class implements Switch GUI element, it can be set or reset,
20 /// uses for switching options
23 #include "wellswitch.h"
24 #include "wellengine.h"
26 //////////////////////////////WellSwitch class///////////////////////////////
28 //===========================================================================
29 /// global WellSwitch(char*)
30 /// constructor - fill name and get geometry
32 WellSwitch::WellSwitch(char* iname
) : WellObject()
34 strncpy(object_name
,iname
,GEO_NAME
);
35 object_name
[GEO_NAME
]=0;
36 geo
=get_geo_by_name(object_name
);
42 //===========================================================================
43 /// global process_event(wEvent)
44 /// stub that process events
46 bool WellSwitch::process_event(wEvent ev
)
52 pmev
=(MouseEvent
*)ev
.data
;
53 return !press(pmev
->mx
,pmev
->my
);
56 pmev
=(MouseEvent
*)ev
.data
;
57 return !highlight(pmev
->mx
,pmev
->my
);
63 //===========================================================================
64 /// global highlight(int mx, int my)
67 bool WellSwitch::highlight(int mx
, int my
)
69 if(mx
>=geo
[1].tox
&& my
>=geo
[1].toy
&&
70 mx
<geo
[1].tox
+geo
[1].l
&& my
<geo
[1].toy
+geo
[1].h
)
74 dbgprintf(("WellSwitch highlighted via mouse\n"));
76 default_well_engine
->screen_copy(&geo
[1]); //highlighted state
84 dbgprintf(("WellSwitch DEhighlighted via mouse\n"));
92 //===========================================================================
93 /// global press(int mx, int my)
94 /// press key and call object
96 bool WellSwitch::press(int mx
, int my
)
98 if(mx
>=geo
[1].tox
&& my
>=geo
[1].toy
&&
99 mx
<geo
[1].tox
+geo
[1].l
&& my
<geo
[1].toy
+geo
[1].h
)
101 dbgprintf(("WellSwitch pressed via mouse\n"));
102 value
= value
? false : true;
113 object_on_switch
.call(wEvent(aSwitchChanged
,this));
119 //===========================================================================
123 void WellSwitch::show()
127 default_well_engine
->add_object(this);
130 //===========================================================================
134 void WellSwitch::redraw()
138 default_well_engine
->screen_copy(&geo
[0]); //normal state
140 default_well_engine
->screen_copy(&geo
[2]); //value state
142 default_well_engine
->screen_clear(&geo
[2]); //value state
146 //===========================================================================
150 void WellSwitch::hide()
153 default_well_engine
->screen_clear(&geo
[0]);
154 default_well_engine
->del_object(this);