| 1 | // kln89_page.hxx - base class for 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 | #ifndef _KLN89_PAGE_HXX |
| 25 | #define _KLN89_PAGE_HXX |
| 26 | |
| 27 | #include <Instrumentation/dclgps.hxx> |
| 28 | #include "kln89.hxx" |
| 29 | |
| 30 | class KLN89; |
| 31 | |
| 32 | class KLN89Page { |
| 33 | |
| 34 | public: |
| 35 | KLN89Page(KLN89* parent); |
| 36 | virtual ~KLN89Page(); |
| 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(); |
| 53 | |
| 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 |
| 57 | // GPS::_cleanUpPage |
| 58 | virtual void CleanUp(); |
| 59 | |
| 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(); |
| 64 | |
| 65 | inline void SetEntInvert(bool b) { _entInvert = b; } |
| 66 | |
| 67 | // Get / Set a waypoint id, NOT the page name! |
| 68 | virtual void SetId(const std::string& s); |
| 69 | virtual const std::string& GetId(); |
| 70 | |
| 71 | inline int GetSubPage() { return(_subPage); } |
| 72 | void SetSubPage(int n); |
| 73 | |
| 74 | inline int GetNSubPages() { return(_nSubPages); } |
| 75 | |
| 76 | inline const std::string& GetName() { return(_name); } |
| 77 | |
| 78 | protected: |
| 79 | |
| 80 | KLN89* _kln89; |
| 81 | |
| 82 | std::string _name; // eg. "APT", "NAV" etc |
| 83 | int _nSubPages; |
| 84 | // _subpage is zero based |
| 85 | int _subPage; // The subpage gets remembered when other pages are displayed |
| 86 | |
| 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; |
| 92 | |
| 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 |
| 96 | |
| 97 | // Invert ID and display ENT in field 1 |
| 98 | bool _entInvert; |
| 99 | |
| 100 | std::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. |
| 102 | |
| 103 | void ShowScratchpadMessage(const std::string& line1, const std::string& line2); |
| 104 | |
| 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 | std::string _scratchpadLine1; |
| 108 | std::string _scratchpadLine2; |
| 109 | |
| 110 | // TODO: remove this function from this class and use a built in method instead. |
| 111 | std::string GPSitoa(int n); |
| 112 | }; |
| 113 | |
| 114 | #endif // _KLN89_PAGE_HXX |