1 /***************************************************************************
2  *
3  * Project:  OpenCPN
4  * Purpose:  OpenCPN Main wxWidgets Program
5  * Author:   David Register
6  *
7  ***************************************************************************
8  *   Copyright (C) 2010 by David S. Register                               *
9  *                                                                         *
10  *   This program is free software; you can redistribute it and/or modify  *
11  *   it under the terms of the GNU General Public License as published by  *
12  *   the Free Software Foundation; either version 2 of the License, or     *
13  *   (at your option) any later version.                                   *
14  *                                                                         *
15  *   This program is distributed in the hope that it will be useful,       *
16  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
17  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
18  *   GNU General Public License for more details.                          *
19  *                                                                         *
20  *   You should have received a copy of the GNU General Public License     *
21  *   along with this program; if not, write to the                         *
22  *   Free Software Foundation, Inc.,                                       *
23  *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,  USA.         *
24  **************************************************************************/
25 
26 #ifndef __CHART1_H__
27 #define __CHART1_H__
28 
29 #include "wx/print.h"
30 #include "wx/datetime.h"
31 #include <wx/cmdline.h>
32 #include <wx/snglinst.h>
33 #include <wx/power.h>
34 #include <wx/clrpicker.h>
35 
36 #ifdef __WXMSW__
37 #include "wx/msw/private.h"
38 #endif
39 
40 #include "config.h"
41 
42 #include "ocpn_types.h"
43 #include "viewport.h"
44 #include "nmea0183.h"
45 #include "chartdbs.h"
46 #include "s52s57.h"
47 #include "SencManager.h"
48 
49 #include "gdal/cpl_error.h"
50 #include "SignalKEventHandler.h"
51 
52 //    Global Static error reporting function
53 extern "C" void MyCPLErrorHandler( CPLErr eErrClass, int nError,
54                              const char * pszErrorMsg );
55 
56 wxFont *GetOCPNScaledFont( wxString item, int default_size = 0 );
57 wxFont GetOCPNGUIScaledFont( wxString item );
58 
59 wxArrayString *EnumerateSerialPorts(void);
60 wxColour GetGlobalColor(wxString colorName);
61 
62 int GetApplicationMemoryUse(void);
63 
64 // Helper to create menu label + hotkey string when registering menus
65 wxString _menuText(wxString name, wxString shortcut);
66 
67 // The point for anchor watch should really be a class...
68 double AnchorDistFix( double const d, double const AnchorPointMinDist, double const AnchorPointMaxDist);   //  pjotrc 2010.02.22
69 
70 bool TestGLCanvas(wxString prog_dir);
71 bool ReloadLocale();
72 void ApplyLocale( void );
73 
74 void LoadS57();
75 
76 class NMEA_Msg_Container;
77 WX_DECLARE_STRING_HASH_MAP( NMEA_Msg_Container*, MsgPriorityHash );
78 
79 //    Fwd definitions
80 class OCPN_NMEAEvent;
81 class ChartCanvas;
82 class ocpnFloatingToolbarDialog;
83 class OCPN_MsgEvent;
84 class options;
85 class Track;
86 class OCPN_ThreadMessageEvent;
87 class wxHtmlWindow;
88 
89 //----------------------------------------------------------------------------
90 //   constants
91 //----------------------------------------------------------------------------
92 
93 #define TIMER_GFRAME_1 999
94 
95 #define ID_QUIT         101
96 #define ID_CM93ZOOMG    102
97 
98 //    ToolBar Constants
99 const int ID_TOOLBAR = 500;
100 
101 enum
102 {
103     // The following constants represent the toolbar items (some are also used in menus).
104     // They MUST be in the SAME ORDER as on the toolbar and new items MUST NOT be added
105     // amongst them, due to the way the toolbar button visibility is saved and calculated.
106     ID_ZOOMIN = 1550,
107     ID_ZOOMOUT,
108     ID_STKUP,
109     ID_STKDN,
110     ID_ROUTE,
111     ID_FOLLOW,
112     ID_SETTINGS,
113     ID_AIS,
114     ID_ENC_TEXT,
115     ID_CURRENT,
116     ID_TIDE,
117     ID_PRINT,
118     ID_ROUTEMANAGER,
119     ID_TRACK,
120     ID_COLSCHEME,
121     ID_ABOUT,
122     ID_MOB,
123     ID_TBEXIT,
124     ID_TBSTAT,
125     ID_TBSTATBOX,
126     ID_MASTERTOGGLE,
127 
128     ID_PLUGIN_BASE // This MUST be the last item in the enum
129 };
130 
131 
132 static const long TOOLBAR_STYLE = wxTB_FLAT | wxTB_DOCKABLE | wxTB_TEXT ;
133 
134 enum
135 {
136     IDM_TOOLBAR_TOGGLETOOLBARSIZE = 200,
137     IDM_TOOLBAR_TOGGLETOOLBARORIENT,
138     IDM_TOOLBAR_TOGGLETOOLBARROWS,
139     IDM_TOOLBAR_ENABLEPRINT,
140     IDM_TOOLBAR_DELETEPRINT,
141     IDM_TOOLBAR_INSERTPRINT,
142     IDM_TOOLBAR_TOGGLEHELP,
143     IDM_TOOLBAR_TOGGLE_TOOLBAR,
144     IDM_TOOLBAR_TOGGLE_ANOTHER_TOOLBAR,
145     IDM_TOOLBAR_CHANGE_TOOLTIP,
146     IDM_TOOLBAR_SHOW_TEXT,
147     IDM_TOOLBAR_SHOW_ICONS,
148     IDM_TOOLBAR_SHOW_BOTH,
149 
150     ID_COMBO = 1000
151 };
152 
153 
154 // Menu item IDs for the main menu bar
155 enum
156 {
157     ID_MENU_ZOOM_IN = 2000,
158     ID_MENU_ZOOM_OUT,
159     ID_MENU_SCALE_IN,
160     ID_MENU_SCALE_OUT,
161 
162     ID_MENU_NAV_FOLLOW,
163     ID_MENU_NAV_TRACK,
164 
165     ID_MENU_CHART_NORTHUP,
166     ID_MENU_CHART_COGUP,
167     ID_MENU_CHART_HEADUP,
168     ID_MENU_CHART_QUILTING,
169     ID_MENU_CHART_OUTLINES,
170 
171     ID_MENU_UI_CHARTBAR,
172     ID_MENU_UI_COLSCHEME,
173     ID_MENU_UI_FULLSCREEN,
174 
175     ID_MENU_ENC_TEXT,
176     ID_MENU_ENC_LIGHTS,
177     ID_MENU_ENC_SOUNDINGS,
178     ID_MENU_ENC_ANCHOR,
179     ID_MENU_ENC_DATA_QUALITY,
180 
181     ID_MENU_SHOW_TIDES,
182     ID_MENU_SHOW_CURRENTS,
183 
184     ID_MENU_TOOL_MEASURE,
185     ID_MENU_ROUTE_MANAGER,
186     ID_MENU_ROUTE_NEW,
187     ID_MENU_MARK_BOAT,
188     ID_MENU_MARK_CURSOR,
189     ID_MENU_MARK_MOB,
190 
191     ID_MENU_AIS_TARGETS,
192     ID_MENU_AIS_MOORED_TARGETS,
193     ID_MENU_AIS_SCALED_TARGETS,
194     ID_MENU_AIS_TRACKS,
195     ID_MENU_AIS_CPADIALOG,
196     ID_MENU_AIS_CPASOUND,
197     ID_MENU_AIS_TARGETLIST,
198 
199     ID_MENU_SETTINGS_BASIC,
200 
201     ID_MENU_OQUIT,
202 
203     ID_CMD_SELECT_CHART_TYPE,
204     ID_CMD_SELECT_CHART_FAMILY,
205     ID_CMD_INVALIDATE,
206     ID_CMD_CLOSE_ALL_DIALOGS,
207 
208     ID_MENU_SHOW_NAVOBJECTS,
209 
210 };
211 
212 enum
213 {
214     TIME_TYPE_UTC = 1,
215     TIME_TYPE_LMT,
216     TIME_TYPE_COMPUTER
217 };
218 
219 //      Command identifiers for wxCommandEvents coming from the outside world.
220 //      Removed from enum to facilitate constant definition
221 #define ID_CMD_APPLY_SETTINGS 300
222 #define ID_CMD_NULL_REFRESH 301
223 #define ID_CMD_TRIGGER_RESIZE 302
224 #define ID_CMD_SETVP 303
225 #define ID_CMD_POST_JSON_TO_PLUGINS 304
226 #define ID_CMD_SET_LOCALE 305
227 #define ID_CMD_SOUND_FINISHED 306
228 
229 #define N_STATUS_BAR_FIELDS_MAX     20
230 
231 #ifdef __OCPN__ANDROID__
232 #define STAT_FIELD_COUNT            2
233 #define STAT_FIELD_TICK             -1
234 #define STAT_FIELD_SOGCOG           0
235 #define STAT_FIELD_CURSOR_LL        -1
236 #define STAT_FIELD_CURSOR_BRGRNG    -1
237 #define STAT_FIELD_SCALE            1
238 #else
239 #define STAT_FIELD_COUNT            5
240 #define STAT_FIELD_TICK             0
241 #define STAT_FIELD_SOGCOG           1
242 #define STAT_FIELD_CURSOR_LL        2
243 #define STAT_FIELD_CURSOR_BRGRNG    3
244 #define STAT_FIELD_SCALE            4
245 #endif
246 
247 
248 //      Define a constant GPS signal watchdog timeout value
249 #define GPS_TIMEOUT_SECONDS  6
250 
251 //    Define a timer value for Tide/Current updates
252 //    Note that the underlying data algorithms produce fresh data only every 15 minutes
253 //    So maybe 5 minute updates should provide sufficient oversampling
254 #define TIMER_TC_VALUE_SECONDS      300
255 
256 #define MAX_COG_AVERAGE_SECONDS        60
257 #define MAX_COGSOG_FILTER_SECONDS      60
258 //----------------------------------------------------------------------------
259 // fwd class declarations
260 //----------------------------------------------------------------------------
261 class ChartBase;
262 class wxSocketEvent;
263 class ocpnToolBarSimple;
264 class OCPN_DataStreamEvent;
265 class OCPN_SignalKEvent;
266 class DataStream;
267 class AIS_Target_Data;
268 
269 bool isSingleChart(ChartBase *chart);
270 
271 class  OCPNMessageDialog: public wxDialog
272 {
273 
274 public:
275     OCPNMessageDialog(wxWindow *parent, const wxString& message,
276                       const wxString& caption = wxMessageBoxCaptionStr,
277                       long style = wxOK|wxCENTRE, const wxPoint& pos = wxDefaultPosition);
278 
279     void OnYes(wxCommandEvent& event);
280     void OnNo(wxCommandEvent& event);
281     void OnCancel(wxCommandEvent& event);
282     void OnClose( wxCloseEvent& event );
283 
284 private:
285     int m_style;
286     DECLARE_EVENT_TABLE()
287 };
288 
289 //      A class to contain NMEA messages, their receipt time, and their source priority
290 class NMEA_Msg_Container
291 {
292 public:
293     wxDateTime  receipt_time;
294     int         current_priority;
295     wxString    stream_name;
296 };
297 
298 
299 class OCPN_ThreadMessageEvent: public wxEvent
300 {
301 public:
302     OCPN_ThreadMessageEvent( wxEventType commandType = wxEVT_NULL, int id = 0 );
303     ~OCPN_ThreadMessageEvent( );
304 
305     // accessors
SetSString(std::string string)306     void SetSString(std::string string) { m_string = string; }
GetSString()307     std::string GetSString() { return m_string; }
308 
309     // required for sending with wxPostEvent()
310     wxEvent *Clone() const;
311 
312 private:
313     std::string m_string;
314 };
315 
316 
317 class MyApp: public wxApp
318 {
319   public:
320     bool OnInit();
321     int OnExit();
322     void OnInitCmdLine(wxCmdLineParser& parser);
323     bool OnCmdLineParsed(wxCmdLineParser& parser);
324     void OnActivateApp(wxActivateEvent& event);
325 
326 #ifdef LINUX_CRASHRPT
327     //! fatal exeption handling
328     void OnFatalException();
329 #endif
330 
331 #ifdef __WXMSW__
332     //  Catch malloc/new fail exceptions
333     //  All the rest will be caught be CrashRpt
334     bool OnExceptionInMainLoop();
335 #endif
336 
337     void TrackOff(void);
338 
339     wxSingleInstanceChecker *m_checker;
340 
341     DECLARE_EVENT_TABLE()
342 
343 };
344 
345 class MyFrame: public wxFrame
346 {
347     friend class SignalKEventHandler;
348   public:
349     MyFrame(wxFrame *frame, const wxString& title, const wxPoint& pos, const wxSize& size, long style);
350 
351     ~MyFrame();
352 
353     int GetApplicationMemoryUse(void);
354 
355     void OnEraseBackground(wxEraseEvent& event);
356     void OnMaximize(wxMaximizeEvent& event);
357     void OnCloseWindow(wxCloseEvent& event);
358     void OnExit(wxCommandEvent& event);
359     void OnSize(wxSizeEvent& event);
360     void OnMove(wxMoveEvent& event);
361     void OnInitTimer(wxTimerEvent& event);
362     void OnFrameTimer1(wxTimerEvent& event);
363     bool DoChartUpdate(void);
364     void OnEvtTHREADMSG(OCPN_ThreadMessageEvent& event);
365     void OnEvtOCPN_NMEA(OCPN_DataStreamEvent & event);
366     void OnEvtOCPN_SignalK(OCPN_SignalKEvent &event);
367     void OnEvtOCPN_SIGNALK_Test(OCPN_SignalKEvent & event);
368     void OnEvtPlugInMessage( OCPN_MsgEvent & event );
369     void OnMemFootTimer(wxTimerEvent& event);
370     void OnRecaptureTimer(wxTimerEvent& event);
371     void OnSENCEvtThread( OCPN_BUILDSENC_ThreadEvent & event);
372     void OnIconize(wxIconizeEvent& event);
373     void OnBellsFinished(wxCommandEvent& event);
374 
375 #ifdef wxHAS_POWER_EVENTS
376     void OnSuspending(wxPowerEvent &event);
377     void OnSuspended(wxPowerEvent &event);
378     void OnSuspendCancel(wxPowerEvent &event);
379     void OnResume(wxPowerEvent &event);
380 #endif // wxHAS_POWER_EVENTS
381 
382     void RefreshCanvasOther( ChartCanvas *ccThis );
383     void UpdateAllFonts(void);
384     void PositionConsole(void);
385     void OnToolLeftClick(wxCommandEvent& event);
386     void ClearRouteTool();
387     void DoStackUp(ChartCanvas *cc);
388     void DoStackDown(ChartCanvas *cc);
389     void selectChartDisplay( int type, int family);
390     void applySettingsString( wxString settings);
391     void setStringVP(wxString VPS);
392     void InvalidateAllGL();
393     void RefreshAllCanvas( bool bErase = true);
394     void CancelAllMouseRoute();
395     void InvalidateAllQuilts();
396 
397     void SetUpMode( ChartCanvas *cc, int mode );
398 
GetMainMenuBar()399     wxMenuBar *GetMainMenuBar(){ return m_pMenuBar; }
400 
401     ChartCanvas *GetPrimaryCanvas();
402     ChartCanvas *GetFocusCanvas();
403 
404     void DoStackDelta( ChartCanvas *cc, int direction );
405     void DoSettings( void );
406     void SwitchKBFocus( ChartCanvas *pCanvas );
407     ChartCanvas *GetCanvasUnderMouse();
408     int GetCanvasIndexUnderMouse();
409 
410     bool DropMarker( bool atOwnShip = true );
411 
412     void TriggerResize(wxSize sz);
413     void OnResizeTimer(wxTimerEvent &event);
414 
415     void TriggerRecaptureTimer();
416     bool SetGlobalToolbarViz( bool viz );
417 
418     void MouseEvent(wxMouseEvent& event);
419 //     void SelectChartFromStack(int index,  bool bDir = false,  ChartTypeEnum New_Type = CHART_TYPE_DONTCARE, ChartFamilyEnum New_Family = CHART_FAMILY_DONTCARE);
420 //     void SelectdbChart(int dbindex);
421 //     void SelectQuiltRefChart(int selected_index);
422 //     void SelectQuiltRefdbChart(int db_index, bool b_autoscale = true);
423     void CenterView(ChartCanvas *cc, const LLBBox& bbox);
424 
425     void JumpToPosition( ChartCanvas *cc, double lat, double lon, double scale );
426 
427     void ProcessCanvasResize(void);
428 
429     void BuildMenuBar( void );
430     void ApplyGlobalSettings(bool bnewtoolbar);
431     void RegisterGlobalMenuItems();
432     void UpdateGlobalMenuItems();
433     void UpdateGlobalMenuItems( ChartCanvas *cc);
434     void SetChartThumbnail(int index);
435     int  DoOptionsDialog();
436     bool  ProcessOptionsDialog(int resultFlags, ArrayOfCDI *pNewDirArray );
437     void DoPrint(void);
438     void StopSockets(void);
439     void ResumeSockets(void);
440     void ToggleDataQuality( ChartCanvas *cc );
441     void TogglebFollow(ChartCanvas *cc);
442     void ToggleFullScreen();
443     void ToggleChartBar(ChartCanvas *cc);
444     void SetbFollow(ChartCanvas *cc);
445     void ClearbFollow(ChartCanvas *cc);
446     void ToggleChartOutlines(ChartCanvas *cc);
447     void ToggleENCText(ChartCanvas *cc);
448     void ToggleSoundings(ChartCanvas *cc);
449     void ToggleRocks(void);
450     bool ToggleLights( ChartCanvas *cc );
451     void ToggleAnchor( ChartCanvas *cc );
452     void ToggleAISDisplay( ChartCanvas *cc );
453     void ToggleAISMinimizeTargets( ChartCanvas *cc );
454 
455     void ToggleTestPause(void);
456     void TrackOn(void);
457     void SetENCDisplayCategory( ChartCanvas *cc, enum _DisCat nset );
458     void ToggleNavobjects( ChartCanvas *cc );
459 
460     Track *TrackOff(bool do_add_point = false);
461     void TrackDailyRestart(void);
462     bool ShouldRestartTrack();
463     void ToggleColorScheme();
464     void SetMenubarItemState ( int item_id, bool state );
465     void SetMasterToolbarItemState( int tool_id, bool state );
466 
467     void SetToolbarItemBitmaps ( int tool_id, wxBitmap *bitmap, wxBitmap *bmpDisabled );
468     void SetToolbarItemSVG( int tool_id, wxString normalSVGfile,
469                             wxString rolloverSVGfile,
470                             wxString toggledSVGfile );
471     void ToggleQuiltMode(ChartCanvas *cc);
472     void UpdateControlBar(ChartCanvas *cc);
473 
474     void ShowTides(bool bShow);
475     void ShowCurrents(bool bShow);
476 
477     void SubmergeAllCanvasToolbars(void);
478     void SurfaceAllCanvasToolbars(void);
479     void ToggleAllToolbars( bool b_smooth = false );
480     void SetAllToolbarScale(void);
481     void SetGPSCompassScale(void);
482     void InvalidateAllCanvasUndo();
483 
484     void RefreshGroupIndices(void);
485 
486     double GetBestVPScale(ChartBase *pchart);
487 
488     ColorScheme GetColorScheme();
489     void SetAndApplyColorScheme(ColorScheme cs);
490 
491     void OnFrameTCTimer(wxTimerEvent& event);
492     void OnFrameCOGTimer(wxTimerEvent& event);
493 
494     void ChartsRefresh();
495 
496     bool CheckGroup(int igroup);
497     double GetMag(double a);
498     double GetMag(double a, double lat, double lon);
499     bool SendJSON_WMM_Var_Request(double lat, double lon, wxDateTime date);
500 
501     void DestroyPersistentDialogs();
502     void TouchAISActive(void);
503     void UpdateAISTool(void);
504 
505     void ActivateAISMOBRoute( AIS_Target_Data *ptarget );
506     void UpdateAISMOBRoute( AIS_Target_Data *ptarget );
507 
508     wxStatusBar         *m_pStatusBar;
509     wxMenuBar           *m_pMenuBar;
510     int                 nBlinkerTick;
511     bool                m_bTimeIsSet;
512 
513     wxTimer             InitTimer;
514     int                 m_iInitCount;
515     bool                m_initializing;
516 
517     wxTimer             FrameTCTimer;
518     wxTimer             FrameTimer1;
519     wxTimer             FrameCOGTimer;
520     wxTimer             MemFootTimer;
521     wxTimer             m_resizeTimer;
522 
523     int                 m_BellsToPlay;
524     wxTimer             BellsTimer;
525 
526     //      PlugIn support
GetNextToolbarToolId()527     int GetNextToolbarToolId(){return m_next_available_plugin_tool_id;}
RequestNewToolbarArgEvent(wxCommandEvent & WXUNUSED (event))528     void RequestNewToolbarArgEvent( wxCommandEvent & WXUNUSED( event ) ){ return RequestNewMasterToolbar(); }
529     void RequestNewToolbars( bool bforcenew = false);
530 
531     void ActivateMOB(void);
532     void UpdateGPSCompassStatusBoxes(bool b_force_new = false);
533     void UpdateRotationState( double rotation );
534 
535     bool UpdateChartDatabaseInplace(ArrayOfCDI &DirArray,
536                                     bool b_force, bool b_prog,
537                                     const wxString &ChartListFileName);
538 
539     bool                m_bdefer_resize;
540     wxSize              m_defer_size;
541     wxSize              m_newsize;
542     double           COGTable[MAX_COG_AVERAGE_SECONDS];
543 
544     void FastClose();
545     void SetChartUpdatePeriod();
546     void CreateCanvasLayout( bool b_useStoredSize = false );
547     void LoadHarmonics();
548     void ReloadAllVP();
549     void SetCanvasSizes( wxSize frameSize );
550 
551     ocpnToolBarSimple *CreateMasterToolbar();
552     void RequestNewMasterToolbar( bool bforcenew = true );
553     bool CheckAndAddPlugInTool( );
554     bool AddDefaultPositionPlugInTools( );
555 
556     void NotifyChildrenResize( void );
557     void UpdateCanvasConfigDescriptors();
558     void ScheduleSettingsDialog();
559     static void RebuildChartDatabase();
560     void PositionIENCToolbar();
561 
562     bool ParsePosition(const LATLONG &Position);
563     void setSatelitesInView(int no);
564     void setPosition(double lat, double lon);
565     void setSpeedOverGround(double sog);
566     void setCourseOverGround(double cog);
567     void setHeadingTrue(double heading);
568     void setHeadingMagnetic(double heading);
569     void setMagneticVariation(double var);
570 
571 
572   private:
573 
574     void CheckToolbarPosition();
575     void ODoSetSize(void);
576     void DoCOGSet(void);
577 
578     void UpdateAllToolbars( ColorScheme cs );
579 
580     void FilterCogSog(void);
581 
582     void ApplyGlobalColorSchemetoStatusBar(void);
583     void PostProcessNMEA(bool pos_valid, bool cog_sog_valid, const wxString &sfixtime);
584 
585     bool ScrubGroupArray();
586     wxString GetGroupName(int igroup);
587 
588     bool EvalPriority(const wxString & message, DataStream *pDS );
589     void SetAISDisplayStyle(ChartCanvas *cc, int StyleIndx);
590 
591     bool GetMasterToolItemShow( int toolid );
592     void OnToolbarAnimateTimer( wxTimerEvent& event );
593     bool CollapseGlobalToolbar();
594 
595     int                 m_StatusBarFieldCount;
596 
597     NMEA0183        m_NMEA0183;                 // Used to parse messages from NMEA threads
598 
599     wxDateTime       m_MMEAeventTime;
600     unsigned long    m_ulLastNMEATicktime;
601 
602     wxMutex          m_mutexNMEAEvent;         // Mutex to handle static data from NMEA threads
603 
604     wxString         m_last_reported_chart_name;
605     wxString         m_last_reported_chart_pubdate;
606 
607 
608     wxString         m_lastAISiconName;
609 
610     //      Plugin Support
611     int                 m_next_available_plugin_tool_id;
612 
613     double              COGFilterTable[MAX_COGSOG_FILTER_SECONDS];
614     double              SOGFilterTable[MAX_COGSOG_FILTER_SECONDS];
615 
616     bool                m_bpersistent_quilt;
617     int                 m_ChartUpdatePeriod;
618     bool                m_last_bGPSValid;
619 
620     wxString            prev_locale;
621     bool                bPrevQuilt;
622     bool                bPrevFullScreenQuilt;
623     bool                bPrevOGL;
624 
625     MsgPriorityHash     NMEA_Msg_Hash;
626     wxString            m_VDO_accumulator;
627 
628     time_t              m_fixtime;
629     wxMenu              *piano_ctx_menu;
630     bool                b_autofind;
631 
632     time_t              m_last_track_rotation_ts;
633     wxRect              m_mainlast_tb_rect;
634     wxTimer             ToolbarAnimateTimer;
635     int                 m_nMasterToolCountShown;
636     wxTimer             m_recaptureTimer;
637 
638     SignalKEventHandler m_signalKHandler;
639 
640     DECLARE_EVENT_TABLE()
641 };
642 
643 //--------------------------------------------------------------------
644 //          Printing Support
645 //--------------------------------------------------------------------
646 
647 class MyPrintout: public wxPrintout
648 {
649  public:
wxPrintout(title)650   MyPrintout(const wxChar *title = _T("My printout")):wxPrintout(title){}
651   virtual
652   bool OnPrintPage(int page);
653   virtual
654   bool HasPage(int page);
655   virtual
656   bool OnBeginDocument(int startPage, int endPage);
657   virtual
658   void GetPageInfo(int *minPage, int *maxPage, int *selPageFrom, int *selPageTo);
659 
660   void DrawPageOne(wxDC *dc);
661 
662   void GenerateGLbmp(void);
663 
664 private:
665   wxBitmap m_GLbmp;
666 
667 };
668 
669 
670 //      A global definition for window, timer and other ID's as needed.
671 enum {
672     ID_NMEA_WINDOW      = wxID_HIGHEST,
673     ID_AIS_WINDOW,
674     INIT_TIMER,
675     FRAME_TIMER_1,
676     FRAME_TIMER_2,
677     TIMER_AIS1,
678     TIMER_DSC,
679     TIMER_AISAUDIO,
680     AIS_SOCKET_ID,
681     FRAME_TIMER_DOG,
682     FRAME_TC_TIMER,
683     FRAME_COG_TIMER,
684     MEMORY_FOOTPRINT_TIMER,
685     BELLS_TIMER,
686     ID_NMEA_THREADMSG,
687     RESIZE_TIMER,
688     TOOLBAR_ANIMATE_TIMER,
689     RECAPTURE_TIMER
690 
691 };
692 
693 //-----------------------------------------------------------------------
694 //          Dummy Text Control for global key events
695 //-----------------------------------------------------------------------
696 class DummyTextCtrl: public wxTextCtrl
697 {
698 public:
699       DummyTextCtrl(wxWindow *parent, wxWindowID id);
700       void OnChar(wxKeyEvent &event);
701       void OnMouseEvent(wxMouseEvent& event);
702 
703       wxTimer     m_MouseWheelTimer;
704       int         m_mouse_wheel_oneshot;
705       int         m_last_wheel_dir;
706 
707       DECLARE_EVENT_TABLE()
708 };
709 
710 
711 extern int OCPNMessageBox(wxWindow *parent,
712                           const wxString& message,
713                           const wxString& caption = _T("Message"),
714                           int style = wxOK,  int timout_sec = -1, int x = -1, int y = -1);
715 
716 
717 //----------------------------------------------------------------------------
718 // Generic Auto Timed Window
719 // Belongs to the creator, not deleted automatically on application close
720 //----------------------------------------------------------------------------
721 
722 class TimedPopupWin: public wxWindow
723 {
724 public:
725     TimedPopupWin( wxWindow *parent, int timeout = -1 );
726     ~TimedPopupWin();
727 
728     void OnPaint( wxPaintEvent& event );
729 
730     void SetBitmap( wxBitmap &bmp );
GetBitmap()731     wxBitmap* GetBitmap() { return m_pbm; }
732     void OnTimer( wxTimerEvent& event );
IsActive()733     bool IsActive() { return isActive; }
IsActive(bool state)734     void IsActive( bool state ) { isActive = state; }
735 
736 private:
737     wxBitmap *m_pbm;
738     wxTimer m_timer_timeout;
739     int m_timeout_sec;
740     bool isActive;
741 
742     DECLARE_EVENT_TABLE()
743 };
744 
745 class  OCPN_TimedHTMLMessageDialog: public wxDialog
746 {
747 
748 public:
749     OCPN_TimedHTMLMessageDialog(wxWindow *parent, const wxString& message,
750                            const wxString& caption = wxMessageBoxCaptionStr,
751                            int tSeconds = -1,
752                            long style = wxOK|wxCENTRE,
753                            bool bFixedFont = false,
754                            const wxPoint& pos = wxDefaultPosition);
755 
756     void OnYes(wxCommandEvent& event);
757     void OnNo(wxCommandEvent& event);
758     void OnCancel(wxCommandEvent& event);
759     void OnClose( wxCloseEvent& event );
760     void OnTimer(wxTimerEvent &evt);
761     void RecalculateSize( void );
762 
763 
764 private:
765     int m_style;
766     wxTimer m_timer;
767     wxHtmlWindow *msgWindow;
768 
769     DECLARE_EVENT_TABLE()
770 };
771 
772 
773 #endif
774