1 // kln89_page.hxx - base class for the "pages" that
2 // are used in the KLN89 GPS unit simulation.
4 // Written by David Luff, started 2005.
6 // Copyright (C) 2005 - David C Luff - david.luff@nottingham.ac.uk
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.
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.
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.
24 #ifndef _KLN89_PAGE_HXX
25 #define _KLN89_PAGE_HXX
27 #include <Instrumentation/dclgps.hxx>
35 KLN89Page(KLN89* parent);
37 virtual void Update(double dt);
38 virtual void Knob1Left1();
39 virtual void Knob1Right1();
40 virtual void Knob2Left1();
41 virtual void Knob2Right1();
42 virtual void CrsrPressed();
43 virtual void EntPressed();
44 virtual void ClrPressed();
45 // Even though some/all of the buttons below aren't processed directly by the current page,
46 // the current page often needs to save or change some state when they are pressed, and
47 // hence should provide a function to handle them.
48 virtual void DtoPressed();
49 virtual void NrstPressed();
50 virtual void AltPressed();
51 virtual void OBSPressed();
52 virtual void MsgPressed();
54 // Sometimes a page needs to maintain state for some return paths,
55 // but change it for others. The CleanUp function can be used for
56 // changing state for non-ENT return paths in conjunction with
58 virtual void CleanUp();
60 // The LooseFocus function is called when a page or subpage looses focus
61 // and allows pages to clean up state that is maintained whilst focus is
62 // retained, but lost on return.
63 virtual void LooseFocus();
65 inline void SetEntInvert(bool b) { _entInvert = b; }
67 // Get / Set a waypoint id, NOT the page name!
68 virtual void SetId(const string& s);
69 virtual const string& GetId();
71 inline int GetSubPage() { return(_subPage); }
72 void SetSubPage(int n);
74 inline int GetNSubPages() { return(_nSubPages); }
76 inline const string& GetName() { return(_name); }
82 string _name; // eg. "APT", "NAV" etc
84 // _subpage is zero based
85 int _subPage; // The subpage gets remembered when other pages are displayed
87 // Underline position in cursor mode is not persistant when subpage is changed - hence we only need one variable per page for it.
88 // Note that pos 0 is special - this is the leg pos in field 1, so pos will normally be set to 1 when crsr is pressed.
89 // Also note that in general it doesn't seem to wrap.
90 unsigned int _uLinePos;
91 unsigned int _maxULinePos;
93 // This is NOT the main gps to/from flag - derived page classes can use this flag
94 // for any purpose, typically whether a radial bearing should be displayed to or from.
95 bool _to_flag; // true for TO, false for FROM
97 // Invert ID and display ENT in field 1
100 string _id; // The ID of the waypoint that the page is displaying.
101 // Doesn't make sense for all pages, but does for all the data pages.
103 void ShowScratchpadMessage(const string& line1, const string& line2);
105 bool _scratchpadMsg; // Set true when there is a scratchpad message to display
106 double _scratchpadTimer; // Used for displaying the scratchpad messages for the right amount of time.
107 string _scratchpadLine1;
108 string _scratchpadLine2;
110 // TODO - remove this function from this class and use a built in method instead.
111 string GPSitoa(int n);
114 #endif // _KLN89_PAGE_HXX