1 /*************************************************************************** 2 * 3 * Project: OpenCPN 4 * 5 *************************************************************************** 6 * Copyright (C) 2013 by David S. Register * 7 * * 8 * This program is free software; you can redistribute it and/or modify * 9 * it under the terms of the GNU General Public License as published by * 10 * the Free Software Foundation; either version 2 of the License, or * 11 * (at your option) any later version. * 12 * * 13 * This program is distributed in the hope that it will be useful, * 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 16 * GNU 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 * 20 * Free Software Foundation, Inc., * 21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * 22 *************************************************************************** 23 */ 24 25 #ifndef __NMEALOGWINDOW_H__ 26 #define __NMEALOGWINDOW_H__ 27 28 #include "WindowDestroyListener.h" 29 30 class wxWindow; 31 class wxString; 32 class wxSize; 33 class wxPoint; 34 class TTYWindow; 35 36 /** 37 * This class provides access to the NMEA log/debug window. 38 * 39 * This provides everything needed to use the single NMEA log window. 40 * 41 * Singleton. 42 * 43 * Reading geometry information from the window will cache them 44 * inside this class. This is used to store them permanently in 45 * the configuration file. 46 */ 47 class NMEALogWindow : public WindowDestroyListener 48 { 49 public: 50 static NMEALogWindow & Get(); 51 bool Active() const; 52 void Create(wxWindow * parent, int num_lines = 35); 53 void Add(const wxString & s); 54 void Refresh(bool do_refresh = false); 55 int GetSizeW(); 56 int GetSizeH(); 57 int GetPosX(); 58 int GetPosY(); 59 void SetSize(int w, int h); 60 void SetSize(const wxSize & size); 61 void SetPos(int x, int y); 62 void SetPos(const wxPoint & pos); 63 void CheckPos(int display_width, int display_height); 64 void Move(); 65 virtual void DestroyWindow(); 66 static void Shutdown(); GetTTYWindow(void)67 wxWindow *GetTTYWindow( void ){ return (wxWindow *)window; } 68 69 private: // prevent class from being copied, needed by singleton 70 NMEALogWindow(); NMEALogWindow(const NMEALogWindow &)71 NMEALogWindow(const NMEALogWindow &) {} ~NMEALogWindow()72 virtual ~NMEALogWindow() {}; 73 NMEALogWindow & operator=(const NMEALogWindow &) { return *this; } 74 void UpdateGeometry(); 75 private: 76 static NMEALogWindow * instance; 77 TTYWindow * window; 78 int width; 79 int height; 80 int pos_x; 81 int pos_y; 82 }; 83 84 #endif 85