34#include <wx/msw/private.h>
37#include "ocpn_types.h"
38#include "ocpn_print.h"
39#include "color_handler.h"
42#include "SencManager.h"
43#include "comm_appmsg_bus.h"
46wxColour GetGlobalColor(wxString colorName);
47wxColour GetDialogColor(DialogColor color);
49int GetApplicationMemoryUse(
void);
52wxString _menuText(wxString name, wxString shortcut);
55double AnchorDistFix(
double const d,
double const AnchorPointMinDist,
56 double const AnchorPointMaxDist);
58bool TestGLCanvas(wxString prog_dir);
60void ApplyLocale(
void);
79#define TIMER_GFRAME_1 999
82#define ID_CM93ZOOMG 102
88#define ID_CMD_APPLY_SETTINGS 300
89#define ID_CMD_NULL_REFRESH 301
90#define ID_CMD_TRIGGER_RESIZE 302
91#define ID_CMD_SETVP 303
92#define ID_CMD_POST_JSON_TO_PLUGINS 304
93#define ID_CMD_SET_LOCALE 305
94#define ID_CMD_SOUND_FINISHED 306
96#define N_STATUS_BAR_FIELDS_MAX 20
98#ifdef __OCPN__ANDROID__
99#define STAT_FIELD_COUNT 2
100#define STAT_FIELD_TICK -1
101#define STAT_FIELD_SOGCOG 0
102#define STAT_FIELD_CURSOR_LL -1
103#define STAT_FIELD_CURSOR_BRGRNG -1
104#define STAT_FIELD_SCALE 1
106#define STAT_FIELD_COUNT 5
107#define STAT_FIELD_TICK 0
108#define STAT_FIELD_SOGCOG 1
109#define STAT_FIELD_CURSOR_LL 2
110#define STAT_FIELD_CURSOR_BRGRNG 3
111#define STAT_FIELD_SCALE 4
115#define GPS_TIMEOUT_SECONDS 10
120#define TIMER_TC_VALUE_SECONDS 300
122#define MAX_COG_AVERAGE_SECONDS 60
123#define MAX_COGSOG_FILTER_SECONDS 60
130class OCPN_DataStreamEvent;
131class OCPN_SignalKEvent;
143 void SetSString(std::string
string) { m_string = string; }
144 std::string GetSString() {
return m_string; }
147 wxEvent *Clone()
const;
150 std::string m_string;
154 friend class SignalKEventHandler;
157 MyFrame(wxFrame *frame,
const wxString &title,
const wxPoint &pos,
158 const wxSize &size,
long style);
162 int GetApplicationMemoryUse(
void);
164 void OnEraseBackground(wxEraseEvent &event);
165 void OnMaximize(wxMaximizeEvent &event);
166 void OnCloseWindow(wxCloseEvent &event);
167 void OnExit(wxCommandEvent &event);
168 void OnSize(wxSizeEvent &event);
169 void OnMove(wxMoveEvent &event);
170 void OnInitTimer(wxTimerEvent &event);
172 bool DoChartUpdate(
void);
174 void OnEvtOCPN_NMEA(OCPN_DataStreamEvent &event);
175 void OnEvtOCPN_SignalK(OCPN_SignalKEvent &event);
176 void OnEvtOCPN_SIGNALK_Test(OCPN_SignalKEvent &event);
178 void OnMemFootTimer(wxTimerEvent &event);
179 void OnRecaptureTimer(wxTimerEvent &event);
181 void OnIconize(wxIconizeEvent &event);
182 void OnBellsFinished(wxCommandEvent &event);
184#ifdef wxHAS_POWER_EVENTS
185 void OnSuspending(wxPowerEvent &event);
186 void OnSuspended(wxPowerEvent &event);
187 void OnSuspendCancel(wxPowerEvent &event);
188 void OnResume(wxPowerEvent &event);
192 void UpdateAllFonts(
void);
193 void PositionConsole(
void);
194 void OnToolLeftClick(wxCommandEvent &event);
195 void ClearRouteTool();
198 void selectChartDisplay(
int type,
int family);
199 void applySettingsString(wxString settings);
200 void setStringVP(wxString VPS);
201 void InvalidateAllGL();
202 void RefreshAllCanvas(
bool bErase =
true);
203 void CancelAllMouseRoute();
204 void InvalidateAllQuilts();
208 wxMenuBar *GetMainMenuBar() {
return m_pMenuBar; }
214 void DoSettings(
void);
217 int GetCanvasIndexUnderMouse();
219 bool DropMarker(
bool atOwnShip =
true);
221 void TriggerResize(wxSize sz);
222 void OnResizeTimer(wxTimerEvent &event);
224 void TriggerRecaptureTimer();
225 bool SetGlobalToolbarViz(
bool viz);
227 void MouseEvent(wxMouseEvent &event);
228 void CenterView(
ChartCanvas *cc,
const LLBBox &bbox);
232 void ProcessCanvasResize(
void);
234 void BuildMenuBar(
void);
235 void ApplyGlobalSettings(
bool bnewtoolbar);
236 void RegisterGlobalMenuItems();
237 void UpdateGlobalMenuItems();
239 int DoOptionsDialog();
240 bool ProcessOptionsDialog(
int resultFlags, ArrayOfCDI *pNewDirArray);
242 void StopSockets(
void);
243 void ResumeSockets(
void);
246 void ToggleFullScreen();
253 void ToggleRocks(
void);
259 void ToggleTestPause(
void);
261 void SetENCDisplayCategory(
ChartCanvas *cc,
enum _DisCat nset);
264 Track *TrackOff(
bool do_add_point =
false);
265 void TrackDailyRestart(
void);
266 bool ShouldRestartTrack();
267 void ToggleColorScheme();
268 void SetMenubarItemState(
int item_id,
bool state);
269 void SetMasterToolbarItemState(
int tool_id,
bool state);
271 void SetToolbarItemBitmaps(
int tool_id, wxBitmap *bitmap,
272 wxBitmap *bmpDisabled);
273 void SetToolbarItemSVG(
int tool_id, wxString normalSVGfile,
274 wxString rolloverSVGfile, wxString toggledSVGfile);
278 void ShowTides(
bool bShow);
279 void ShowCurrents(
bool bShow);
281 void SubmergeAllCanvasToolbars(
void);
283 void ToggleAllToolbars(
bool b_smooth =
false);
284 void SetAllToolbarScale(
void);
285 void SetGPSCompassScale(
void);
286 void InvalidateAllCanvasUndo();
288 void RefreshGroupIndices(
void);
290 double GetBestVPScale(
ChartBase *pchart);
292 ColorScheme GetColorScheme();
293 void SetAndApplyColorScheme(ColorScheme cs);
295 void OnFrameTCTimer(wxTimerEvent &event);
296 void OnFrameCOGTimer(wxTimerEvent &event);
298 void HandleBasicNavMsg(std::shared_ptr<const BasicNavDataMsg> msg);
299 void HandleGPSWatchdogMsg(std::shared_ptr<const GPSWatchdogMsg> msg);
301 void ChartsRefresh();
303 bool CheckGroup(
int igroup);
304 double GetMag(
double a);
305 double GetMag(
double a,
double lat,
double lon);
306 bool SendJSON_WMM_Var_Request(
double lat,
double lon, wxDateTime date);
308 void DestroyPersistentDialogs();
309 void TouchAISActive(
void);
310 void UpdateAISTool(
void);
315 wxStatusBar *m_pStatusBar;
316 wxMenuBar *m_pMenuBar;
325 wxTimer FrameTCTimer;
327 wxTimer FrameCOGTimer;
328 wxTimer MemFootTimer;
329 wxTimer m_resizeTimer;
335 int GetNextToolbarToolId() {
return m_next_available_plugin_tool_id; }
336 void RequestNewToolbarArgEvent(wxCommandEvent &WXUNUSED(event)) {
337 return RequestNewMasterToolbar();
339 void RequestNewToolbars(
bool bforcenew =
false);
341 void ActivateMOB(
void);
342 void UpdateGPSCompassStatusBoxes(
bool b_force_new =
false);
343 void UpdateRotationState(
double rotation);
345 bool UpdateChartDatabaseInplace(ArrayOfCDI &DirArray,
bool b_force,
347 const wxString &ChartListFileName);
349 bool m_bdefer_resize;
352 double COGTable[MAX_COG_AVERAGE_SECONDS];
355 void SetChartUpdatePeriod();
356 void CreateCanvasLayout(
bool b_useStoredSize =
false);
357 void LoadHarmonics();
359 void SetCanvasSizes(wxSize frameSize);
362 void RequestNewMasterToolbar(
bool bforcenew =
true);
363 bool CheckAndAddPlugInTool();
364 bool AddDefaultPositionPlugInTools();
366 void NotifyChildrenResize(
void);
367 void UpdateCanvasConfigDescriptors();
368 void ScheduleSettingsDialog();
369 static void RebuildChartDatabase();
370 void PositionIENCToolbar();
372 void InitAppMsgBusListener();
373 void UpdateStatusBar(
void);
376 void CheckToolbarPosition();
377 void ODoSetSize(
void);
380 void UpdateAllToolbars(ColorScheme cs);
382 void FilterCogSog(
void);
384 void ApplyGlobalColorSchemetoStatusBar(
void);
386 bool ScrubGroupArray();
387 wxString GetGroupName(
int igroup);
389 bool EvalPriority(
const wxString &message, DataStream *pDS);
390 void SetAISDisplayStyle(
ChartCanvas *cc,
int StyleIndx);
392 bool GetMasterToolItemShow(
int toolid);
393 void OnToolbarAnimateTimer(wxTimerEvent &event);
394 bool CollapseGlobalToolbar();
396 int m_StatusBarFieldCount;
398 wxDateTime m_MMEAeventTime;
399 unsigned long m_ulLastNMEATicktime;
402 wxString m_last_reported_chart_name;
403 wxString m_last_reported_chart_pubdate;
405 wxString m_lastAISiconName;
408 int m_next_available_plugin_tool_id;
410 double COGFilterTable[MAX_COGSOG_FILTER_SECONDS];
411 double SOGFilterTable[MAX_COGSOG_FILTER_SECONDS];
413 bool m_bpersistent_quilt;
414 int m_ChartUpdatePeriod;
415 bool m_last_bGPSValid;
416 bool m_last_bVelocityValid;
418 wxString prev_locale;
420 bool bPrevFullScreenQuilt;
424 wxMenu *piano_ctx_menu;
427 time_t m_last_track_rotation_ts;
428 wxRect m_mainlast_tb_rect;
429 wxTimer ToolbarAnimateTimer;
430 int m_nMasterToolCountShown;
431 wxTimer m_recaptureTimer;
437 DECLARE_EVENT_TABLE()
void OnFrameTimer1(wxTimerEvent &event)
void SurfaceAllCanvasToolbars(void)
Keeps listening over it's lifespan, removes itself on destruction.