]> git.mxchange.org Git - flightgear.git/blob - src/Instrumentation/KLN89/kln89_page_dir.cxx
Vassilii Khachaturov:
[flightgear.git] / src / Instrumentation / KLN89 / kln89_page_dir.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_dir.hxx"
25
26 KLN89DirPage::KLN89DirPage(KLN89* parent)
27 : KLN89Page(parent) {
28         _nSubPages = 1;
29         _subPage = 0;
30         _name = "DIR";
31         _DToWpDispMode = 2;
32 }
33
34 KLN89DirPage::~KLN89DirPage() {
35 }
36
37 void KLN89DirPage::Update(double dt) {
38         // TODO - this can apparently be "ACTIVATE:" under some circumstances
39         _kln89->DrawText("DIRECT TO:", 2, 2, 3);
40         
41         if(_kln89->_mode == KLN89_MODE_CRSR) {
42                 if(_DToWpDispMode == 0) {
43                         string s = _id;
44                         while(s.size() < 5) s += ' ';
45                         if(!_kln89->_blink) {
46                                 _kln89->DrawText(s, 2, 4, 1, false, 99);
47                                 _kln89->DrawEnt(1, 0, 1);
48                         }
49                 } else if(_DToWpDispMode == 1) {
50                         if(!_kln89->_blink) {
51                                 // TODO
52                                 _kln89->DrawEnt(1, 0, 1);
53                         }
54                         _kln89->Underline(2, 4, 1, 5);
55                 } else {
56                         if(!_kln89->_blink) _kln89->DrawText("_____", 2, 4, 1);
57                         _kln89->Underline(2, 4, 1, 5);
58                 }
59         } else {
60                 _kln89->DrawText("_____", 2, 4, 1);
61         }
62         
63         KLN89Page::Update(dt);
64 }
65
66 void KLN89DirPage::SetId(const string& s) {
67         if(s.size()) {
68                 _id = s;
69                 // TODO - fill in lat, lon, type
70                 // or just pass in waypoints (probably better!)
71                 _DToWpDispMode = 0;
72                 // TODO - this (above) should probably be dependent on whether s is a *valid* waypoint!
73         } else {
74                 _DToWpDispMode = 2;
75         }
76         _saveMasterMode = _kln89->_mode;
77         _uLinePos = 1;  // Needed to stop Leg flashing
78 }
79
80 void KLN89DirPage::ClrPressed() {
81         if(_kln89->_mode == KLN89_MODE_CRSR) {
82                 if(_DToWpDispMode <= 1) {
83                         _DToWpDispMode = 2;
84                         _id.clear();
85                 } else {
86                         // Restore the original master mode
87                         _kln89->_mode = _saveMasterMode;
88                         // Stop displaying dir page
89                         _kln89->_activePage = _kln89->_pages[_kln89->_curPage];
90                 }
91         } else {
92                 // TODO
93         }
94 }
95
96 void KLN89DirPage::EntPressed() {
97         //cout << "DTO ENT Pressed()\n";
98         if(_id.empty()) {
99                 _kln89->DtoCancel();
100         } else {
101                 _kln89->DtoInitiate(_id);
102         }
103 }