OpenCPN Partial API docs
Loading...
Searching...
No Matches
config_mgr.h
Go to the documentation of this file.
1/**************************************************************************
2 * Copyright (C) 2018 by David S. Register *
3 * *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
8 * *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
13 * *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, see <https://www.gnu.org/licenses/>. *
16 **************************************************************************/
17
24#ifndef __CONFIGMGR_H__
25#define __CONFIGMGR_H__
26
27#include "wx/wxprec.h"
28#ifndef WX_PRECOMP
29#include "wx/wx.h"
30#endif
31
32#include <wx/event.h>
33#include <wx/panel.h>
34#include <wx/string.h>
35
36#include "canvas_config.h"
37
38class OCPNConfigCatalog; // forward -- in config_mgr.cpp
39class OCPNConfigObject; // forward -- in config_mgr.cpp
40
41using ConfigObjectList = std::list<OCPNConfigObject *>;
42
47class ConfigMgr {
48public:
49 static ConfigMgr &Get();
50 static void Shutdown();
51
52 wxString CreateNamedConfig(const wxString &title, const wxString &description,
53 wxString UUID);
54 bool DeleteConfig(wxString GUID);
55 wxArrayString GetConfigGUIDArray();
56
57 wxPanel *GetConfigPanel(wxWindow *parent, wxString GUID);
58 wxString GetTemplateTitle(wxString GUID);
59 bool ApplyConfigGUID(wxString GUID);
60 bool CheckTemplateGUID(wxString GUID);
61 arrayofCanvasConfigPtr &GetCanvasConfigArray() { return g_canvasConfigArray; }
62
63private: // private for singleton
64 ConfigMgr();
65 ~ConfigMgr();
66 ConfigMgr(const ConfigMgr &) {}
67 ConfigMgr &operator=(const ConfigMgr &) { return *this; }
68 static ConfigMgr *instance;
69
70 void Init();
71 bool LoadCatalog();
72 bool SaveCatalog();
73 wxString GetUUID(void);
74 bool SaveTemplate(wxString fileName);
75 wxString GetConfigDir() { return m_configDir; }
76 std::list<OCPNConfigObject *> *GetConfigList() { return configList; }
77 OCPNConfigObject *GetConfig(wxString GUID);
78 bool CheckTemplate(wxString fileName);
79
80 wxString m_configDir;
81 wxString m_configCatalogName;
82 OCPNConfigCatalog *m_configCatalog;
83 std::list<OCPNConfigObject *> *configList;
84 arrayofCanvasConfigPtr g_canvasConfigArray;
85};
86
92class ConfigPanel : public wxPanel {
93public:
94 ConfigPanel(OCPNConfigObject *config, wxWindow *parent,
95 wxWindowID id = wxID_ANY, const wxPoint &pos = wxDefaultPosition,
96 const wxSize &size = wxDefaultSize);
98
99 wxString GetConfigGUID();
100
101private:
102 void OnConfigPanelMouseSelected(wxMouseEvent &event);
103 OCPNConfigObject *m_config;
104};
105
106#endif
Chart canvas configuration state
Manages the user configuration matrix.
Definition config_mgr.h:47
Represents a panel for displaying and editing a configuration.
Definition config_mgr.h:92