| 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 - daveluff AT ntlworld.com |
| 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 21 | // |
| 22 | // $Id$ |
| 23 | |
| 24 | #ifdef HAVE_CONFIG_H |
| 25 | # include "config.h" |
| 26 | #endif |
| 27 | |
| 28 | #include "kln89_page_act.hxx" |
| 29 | #include "kln89_page_apt.hxx" |
| 30 | #include "kln89_page_vor.hxx" |
| 31 | #include "kln89_page_ndb.hxx" |
| 32 | #include "kln89_page_int.hxx" |
| 33 | #include "kln89_page_usr.hxx" |
| 34 | |
| 35 | KLN89ActPage::KLN89ActPage(KLN89* parent) |
| 36 | : KLN89Page(parent) { |
| 37 | _nSubPages = 1; |
| 38 | _subPage = 0; |
| 39 | _name = "ACT"; |
| 40 | _actWp = NULL; |
| 41 | _actWpId = -1; |
| 42 | _actPage = NULL; |
| 43 | |
| 44 | _aptPage = new KLN89AptPage(parent); |
| 45 | _vorPage = new KLN89VorPage(parent); |
| 46 | _ndbPage = new KLN89NDBPage(parent); |
| 47 | _intPage = new KLN89IntPage(parent); |
| 48 | _usrPage = new KLN89UsrPage(parent); |
| 49 | } |
| 50 | |
| 51 | KLN89ActPage::~KLN89ActPage() { |
| 52 | delete _aptPage; |
| 53 | delete _vorPage; |
| 54 | delete _ndbPage; |
| 55 | delete _intPage; |
| 56 | delete _usrPage; |
| 57 | } |
| 58 | |
| 59 | void KLN89ActPage::Update(double dt) { |
| 60 | if(!_actWp) { |
| 61 | _actWp = _kln89->GetActiveWaypoint(); |
| 62 | _actWpId = _kln89->GetActiveWaypointIndex(); |
| 63 | } |
| 64 | if(_actWp) { |
| 65 | switch(_actWp->type) { |
| 66 | case GPS_WP_APT: _actPage = _aptPage; break; |
| 67 | case GPS_WP_VOR: _actPage = _vorPage; break; |
| 68 | case GPS_WP_NDB: _actPage = _ndbPage; break; |
| 69 | case GPS_WP_INT: _actPage = _intPage; break; |
| 70 | case GPS_WP_USR: _actPage = _usrPage; break; |
| 71 | default: |
| 72 | _actPage = NULL; |
| 73 | // ASSERT(0); // ie. we shouldn't ever get here. |
| 74 | } |
| 75 | } |
| 76 | |
| 77 | _id = _actWp->id; |
| 78 | if(_actPage) { |
| 79 | _actPage->SetId(_actWp->id); |
| 80 | _actPage->Update(dt); |
| 81 | } else { |
| 82 | KLN89Page::Update(dt); |
| 83 | } |
| 84 | } |
| 85 | |
| 86 | void KLN89ActPage::CrsrPressed() { |
| 87 | if(_actPage) { |
| 88 | _actPage->CrsrPressed(); |
| 89 | } else { |
| 90 | KLN89Page::CrsrPressed(); |
| 91 | } |
| 92 | } |
| 93 | |
| 94 | void KLN89ActPage::EntPressed() { |
| 95 | if(_actPage) { |
| 96 | _actPage->EntPressed(); |
| 97 | } else { |
| 98 | KLN89Page::EntPressed(); |
| 99 | } |
| 100 | } |
| 101 | |
| 102 | void KLN89ActPage::ClrPressed() { |
| 103 | if(_actPage) { |
| 104 | _actPage->ClrPressed(); |
| 105 | } else { |
| 106 | KLN89Page::ClrPressed(); |
| 107 | } |
| 108 | } |
| 109 | |
| 110 | void KLN89ActPage::Knob1Left1() { |
| 111 | if(_actPage) { |
| 112 | _actPage->Knob1Left1(); |
| 113 | } |
| 114 | } |
| 115 | |
| 116 | void KLN89ActPage::Knob1Right1() { |
| 117 | if(_actPage) { |
| 118 | _actPage->Knob1Right1(); |
| 119 | } |
| 120 | } |
| 121 | |
| 122 | void KLN89ActPage::Knob2Left1() { |
| 123 | if((_kln89->_mode != KLN89_MODE_CRSR) && (_actPage)) { |
| 124 | _actPage->Knob2Left1(); |
| 125 | } |
| 126 | } |
| 127 | |
| 128 | void KLN89ActPage::Knob2Right1() { |
| 129 | if((_kln89->_mode != KLN89_MODE_CRSR) && (_actPage)) { |
| 130 | _actPage->Knob2Right1(); |
| 131 | } |
| 132 | } |
| 133 | |
| 134 | void KLN89ActPage::LooseFocus() { |
| 135 | // Setting to NULL and -1 is better than resetting to |
| 136 | // active waypoint and index since we can't guarantee that |
| 137 | // the fpl active waypoint won't change behind our backs |
| 138 | // when we don't have focus. |
| 139 | _actWp = NULL; |
| 140 | _actWpId = -1; |
| 141 | } |