Debian Codegraph @

wxcrafter/src/wxc_settings.h

raw
1 #ifndef WXCSETTINGS_H
2 #define WXCSETTINGS_H
3
4 #include "wxcLib/json_node.h"
5
6 #include <map>
7
8 // ----------------------------------------------------------------------
9 // CustomControlTemplate
10 // ----------------------------------------------------------------------
11 class CustomControlTemplate
12 {
13 protected:
14 wxString m_includeFile;
15 wxString m_allocationLine;
16 wxString m_className;
17 wxString m_xrcPreviewClass;
18 int m_controlId;
19 wxStringMap_t m_events;
20
21 public:
22 CustomControlTemplate();
23 ~CustomControlTemplate();
24
25 JSONElement ToJSON() const;
26 void FromJSON(const JSONElement& json);
27
28 void SetEvents(const wxStringMap_t& events) { this->m_events = events; }
29 const wxStringMap_t& GetEvents() const { return m_events; }
30 void SetAllocationLine(const wxString& allocationLine) { this->m_allocationLine = allocationLine; }
31 void SetIncludeFile(const wxString& includeFile) { this->m_includeFile = includeFile; }
32 const wxString& GetAllocationLine() const { return m_allocationLine; }
33 const wxString& GetIncludeFile() const { return m_includeFile; }
34 void SetControlId(int controlId) { this->m_controlId = controlId; }
35 void SetClassName(const wxString& className) { this->m_className = className; }
36 const wxString& GetClassName() const { return m_className; }
37 int GetControlId() const { return m_controlId; }
38 bool IsValid() const { return m_controlId != wxNOT_FOUND; }
39 void SetXrcPreviewClass(const wxString& xrcPreviewClass) { this->m_xrcPreviewClass = xrcPreviewClass; }
40 const wxString& GetXrcPreviewClass() const { return m_xrcPreviewClass; }
41 };
42 typedef std::map<wxString, CustomControlTemplate> CustomControlTemplateMap_t;
43
44 // ----------------------------------------------------------------------
45 // wxcSettings
46 // ----------------------------------------------------------------------
47
48 class wxcSettings
49 {
50 public:
51 enum {
52 DLG_CODE_GENERATED = (1 << 0),
53 USE_TABBED_MODE = (1 << 1),
54 LAYOUT_RESET_DONE = (1 << 3),
55 DONT_PROMPT_ABOUT_MISSING_SUBCLASS = (1 << 5),
56 DISPLAY_EVENTS_PANE = (1 << 6),
57 DUPLICATE_KEEPS_USERSET_NAMES = (1 << 7),
58 DUPLICATE_KEEPS_ALL_NAMES = (1 << 8),
59 DUPLICATE_EVENTHANDLERS_TOO = (1 << 9),
60 FORMAT_INHERITED_FILES = (1 << 10),
61 DONT_USE_RELATIVE_BITMAPS = (1 << 11),
62 EXIT_MINIMIZE_TO_TRAY = (1 << 12),
63 };
64
65 protected:
66 size_t m_flags;
67 CustomControlTemplateMap_t m_templateClasses;
68 int m_sashPosition;
69 int m_secondarySashPos;
70 int m_treeviewSashPos;
71 wxArrayString m_history;
72 bool m_initCompleted;
73
74 public:
75 static wxcSettings& Get();
76
77 private:
78 wxcSettings();
79 ~wxcSettings();
80
81 public:
82 void Load();
83 void Save();
84
85 void EnableFlag(int flag, bool b)
86 {
87 if(b) {
88 m_flags |= flag;
89 } else {
90 m_flags &= ~flag;
91 }
92 }
93
94 void ShowNagDialogIfNeeded();
95 void SetInitCompleted(bool initCompleted) { this->m_initCompleted = initCompleted; }
96 bool IsInitCompleted() const { return m_initCompleted; }
97
98 bool HasFlag(int flag) const { return m_flags & flag; }
99 /**
100 * @brief merge custom controls to the current list
101 */
102 void MergeCustomControl(const JSONElement& arr);
103
104 JSONElement GetCustomControlsAsJSON(const wxArrayString& controls) const;
105 void SetTemplateClasses(const CustomControlTemplateMap_t& templateClasses)
106 {
107 this->m_templateClasses = templateClasses;
108 }
109 size_t GetAnnoyDialogs() const { return m_flags; }
110 const CustomControlTemplateMap_t& GetTemplateClasses() const { return m_templateClasses; }
111
112 void RegisterCustomControl(CustomControlTemplate& cct);
113 void DeleteCustomControl(const wxString& name);
114
115 bool GetShowDialog(int flag) const { return !(m_flags & flag); }
116
117 CustomControlTemplate FindByControlId(int controlId) const;
118 CustomControlTemplate FindByControlName(const wxString& name) const;
119
120 void DontShowDialog(int flag) { m_flags |= flag; }
121
122 void SetAnnoyDialogs(size_t annoyDialogs) { this->m_flags = annoyDialogs; }
123 void SetSashPosition(int sashPosition) { this->m_sashPosition = sashPosition; }
124 void SetSecondarySashPos(int secondarySashPos) { this->m_secondarySashPos = secondarySashPos; }
125 void SetTreeviewSashPos(int treeviewSashPos) { this->m_treeviewSashPos = treeviewSashPos; }
126 int GetSashPosition() const { return m_sashPosition; }
127 int GetSecondarySashPos() const { return m_secondarySashPos; }
128 int GetTreeviewSashPos() const { return m_treeviewSashPos; }
129
130 void SetHistory(const wxArrayString& history) { this->m_history = history; }
131 const wxArrayString& GetHistory() const { return m_history; }
132 };
133
134 #endif // WXCSETTINGS_H