]> git.mxchange.org Git - flightgear.git/blob - src/Instrumentation/KLN89/kln89_page_act.cxx
kln89 user interface logical pages
[flightgear.git] / src / Instrumentation / KLN89 / kln89_page_act.cxx
1 // kln89_page_*.[ch]xx - this file is one of the "pages" that
2 //                       are used in the KLN89 GPS unit simulation. 
3 //
4 // Written by David Luff, started 2005.
5 //
6 // Copyright (C) 2005 - David C Luff - david.luff@nottingham.ac.uk
7 //
8 // This program is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU General Public License as
10 // published by the Free Software Foundation; either version 2 of the
11 // License, or (at your option) any later version.
12 //
13 // This program is distributed in the hope that it will be useful, but
14 // WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16 // General Public License for more details.
17 //
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the Free Software
20 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 //
22 // $Id$
23
24 #include "kln89_page_act.hxx"
25 #include "kln89_page_apt.hxx"
26 #include "kln89_page_vor.hxx"
27 #include "kln89_page_ndb.hxx"
28 #include "kln89_page_int.hxx"
29 #include "kln89_page_usr.hxx"
30
31 KLN89ActPage::KLN89ActPage(KLN89* parent) 
32 : KLN89Page(parent) {
33         _nSubPages = 1;
34         _subPage = 0;
35         _name = "ACT";
36         _actWp = NULL;
37         _actWpId = -1;
38         _actPage = NULL;
39         
40         _aptPage = new KLN89AptPage(parent);
41         _vorPage = new KLN89VorPage(parent);
42         _ndbPage = new KLN89NDBPage(parent);
43         _intPage = new KLN89IntPage(parent);
44         _usrPage = new KLN89UsrPage(parent);
45 }
46
47 KLN89ActPage::~KLN89ActPage() {
48         delete _aptPage;
49         delete _vorPage;
50         delete _ndbPage;
51         delete _intPage;
52         delete _usrPage;
53 }
54
55 void KLN89ActPage::Update(double dt) {
56         if(!_actWp) {
57                 _actWp = _kln89->GetActiveWaypoint();
58                 _actWpId = _kln89->GetActiveWaypointIndex();
59         }
60         if(_actWp) {
61                 switch(_actWp->type) {
62                 case GPS_WP_APT: _actPage = _aptPage; break;
63                 case GPS_WP_VOR: _actPage = _vorPage; break;
64                 case GPS_WP_NDB: _actPage = _ndbPage; break;
65                 case GPS_WP_INT: _actPage = _intPage; break;
66                 case GPS_WP_USR: _actPage = _usrPage; break;
67                 default:
68                         _actPage = NULL;
69                         // ASSERT(0); // ie. we shouldn't ever get here.
70                 }
71         }
72         
73         _id = _actWp->id; 
74         if(_actPage) {
75                 _actPage->SetId(_actWp->id);
76                 _actPage->Update(dt);
77         } else {
78                 KLN89Page::Update(dt);
79         }
80 }
81
82 void KLN89ActPage::CrsrPressed() {
83         if(_actPage) {
84                 _actPage->CrsrPressed();
85         } else {
86                 KLN89Page::CrsrPressed();
87         }
88 }
89
90 void KLN89ActPage::EntPressed() {
91         if(_actPage) {
92                 _actPage->EntPressed();
93         } else {
94                 KLN89Page::EntPressed();
95         }
96 }
97
98 void KLN89ActPage::ClrPressed() {
99         if(_actPage) {
100                 _actPage->ClrPressed();
101         } else {
102                 KLN89Page::ClrPressed();
103         }
104 }
105
106 void KLN89ActPage::Knob2Left1() {
107         if((_kln89->_mode != KLN89_MODE_CRSR) && (_actPage)) {
108                 _actPage->Knob2Left1();
109         }
110 }
111
112 void KLN89ActPage::Knob2Right1() {
113         if((_kln89->_mode != KLN89_MODE_CRSR) && (_actPage)) {
114                 _actPage->Knob2Right1();
115         }
116 }
117
118 void KLN89ActPage::LooseFocus() {
119         // Setting to NULL and -1 is better than resetting to
120         // active waypoint and index since we can't guarantee that
121         // the fpl active waypoint won't change behind our backs
122         // when we don't have focus.
123         _actWp = NULL;
124         _actWpId = -1;
125 }