Debian Codegraph @

wxcrafter/src/wxgui_helpers.h

raw
1 #ifndef _WXGUI_HELPERS_H_
2 #define _WXGUI_HELPERS_H_
3
4 #include <event_notifier.h>
5 #include <macros.h>
6 #include <set>
7 #include <vector>
8 #include <wx/colour.h>
9 #include <wx/filename.h>
10 #include <wx/frame.h>
11 #include <wx/gdicmn.h>
12 #include <wx/settings.h>
13 #include <wx/string.h>
14 #include <wx/tokenzr.h>
15
16 #define ITEM_NORMAL wxT("normal")
17 #define ITEM_RADIO wxT("radio")
18 #define ITEM_CHECK wxT("checkable")
19 #define ITEM_SPACE wxT("space")
20 #define ITEM_SEPARATOR wxT("separator")
21 #define ITEM_DROPDOWN wxT("dropdown")
22
23 class wxXmlNode;
24
25 namespace wxCrafter
26 {
27 enum TOOL_TYPE {
28 TOOL_TYPE_NORMAL,
29 TOOL_TYPE_RADIO,
30 TOOL_TYPE_CHECK,
31 TOOL_TYPE_SEPARATOR,
32 TOOL_TYPE_SPACE,
33 TOOL_TYPE_DROPDOWN, // Toolbar only
34 TOOL_TYPE_NONSTRETCHSPACE, // AuiToolbar only
35 TOOL_TYPE_AUILABEL // AuiToolbar only
36 };
37
38 wxBorder GetControlBorder();
39 wxSize DecodeSize(const wxString& strSize);
40 wxString EncodeSize(const wxSize& size);
41 wxString GetSizeAsDlgUnits(const wxSize& size, const wxString& parent);
42 wxFileName LoadXRC(const wxString& xrcString, const wxString& filename, wxString& caption, wxString& style,
43 wxString& bmppath);
44 int ToNumber(const wxString& str, int defaultValue);
45 float ToFloat(const wxString& str, float defaultValue);
46 wxString FloatToCString(float f);
47 wxString ToString(int n);
48 /**
49 * @brief split string of numbers separated by comma
50 */
51 wxArrayString SplitByString(const wxString& str, const wxString& delim, bool keepEmptyLines = false);
52 wxArrayString Split(const wxString& str, const wxString& delim, wxStringTokenizerMode mode = wxTOKEN_STRTOK);
53 wxString Join(const wxArrayString& arr, const wxString& delim);
54 /**
55 * @brief attempt to make a 'CamelCase' string form str
56 */
57 wxString CamelCase(const wxString& str);
58
59 wxString WXT(const wxString& s);
60 wxString ESCAPE(const wxString& s);
61 wxString UNDERSCORE(const wxString& s);
62 wxString FontToString(const wxFont& font);
63 wxFont StringToFont(const wxString& font);
64 bool IsSystemFont(const wxString& font);
65 wxString FontToXRC(const wxString& font);
66 wxString XRCToFontstring(const wxXmlNode* propertynode);
67 wxString FBToFontstring(const wxString& FBstr);
68 wxString FontToCpp(const wxString& font, const wxString& fontMemberName);
69 wxString XMLEncode(const wxString& text, bool decode = false);
70 wxString ToBool(const wxString& text);
71 wxString CDATA(const wxString& text);
72 wxArrayString MakeUnique(const wxArrayString& arr);
73 wxString AddQuotes(const wxString& str);
74 void MakeAbsToProject(wxFileName& fn);
75
76 /**
77 * @brief convert windows slashes to unix paths
78 */
79 wxString ToUnixPath(const wxString& path);
80
81 // ------------------ colors -------------------------------
82
83 wxString ColourToCpp(const wxString& guiname);
84 /**
85 * @brief convert color name to XRC valid color
86 */
87 wxString GetColourForXRC(const wxString& name);
88
89 wxColour NameToColour(const wxString& name);
90
91 /**
92 * @brief convert color string (of unknown format) to a string suitable for ColorProperty
93 */
94 wxString ValueToColourString(const wxString& value);
95
96 /**
97 * @brief convert color name to system index, return -1 if not found
98 */
99 int GetColourSysIndex(const wxString& name);
100
101 // ------------------ colors end -------------------------------
102
103 void WriteFile(const wxFileName& filename, const wxString& content, bool overwriteContent);
104 /**
105 * @brief compare two text files
106 */
107 bool IsTheSame(const wxFileName& f1, const wxFileName& f2);
108 /**
109 * @brief return true of file content is same as the one on disk
110 */
111 bool IsTheSame(const wxString& fileContent, const wxFileName& f);
112
113 std::set<wxString> VectorToSet(const std::vector<wxFileName>& v);
114
115 wxArrayString GetToolTypes(bool forToolbar = false);
116
117 TOOL_TYPE GetToolType(const wxString& name);
118
119 /**
120 * @brief convert TOOL_TYPE to wx TYPE
121 * @param type
122 * @return
123 */
124 wxString ToolTypeToWX(TOOL_TYPE type);
125
126 wxString GetUserDataDir();
127
128 wxString GetConfigFile();
129
130 /**
131 * @brief set status bar message at column 0
132 */
133 void SetStatusMessage(const wxString& msg);
134
135 /**
136 * @brief print wx29 preprocessor start condition
137 * @return
138 */
139 wxString WX294_BLOCK_START();
140
141 /**
142 *
143 * @brief print wx3.0 preprocessor start condition
144 * @return
145 */
146 wxString WX30_BLOCK_START();
147
148 /**
149 *
150 * @brief print wx3.1 preprocessor start condition
151 * @return
152 */
153 wxString WX31_BLOCK_START();
154 /**
155 *
156 * @brief print wx3.3 preprocessor start condition
157 * @return
158 */
159 wxString WX33_BLOCK_START();
160
161 /**
162 *
163 * @brief print wx2.9 preprocessor start condition
164 * @return
165 */
166 wxString WX29_BLOCK_START();
167
168 /**
169 * @brief print wx29 preprocessor end condition
170 * @return
171 */
172 wxString WXVER_CHECK_BLOCK_END();
173
174 int ToAligment(const wxString& aligment);
175
176 /**
177 * @brief convert column flag from string to int
178 * enum {
179 * wxCOL_RESIZABLE = 1,
180 * wxCOL_SORTABLE = 2,
181 * wxCOL_REORDERABLE = 4,
182 * wxCOL_HIDDEN = 8,
183 * wxCOL_DEFAULT_FLAGS = wxCOL_RESIZABLE | wxCOL_REORDERABLE
184 * }
185 */
186 int ColumnFlagsFromString(const wxString& col_flags);
187
188 bool IsArtProviderBitmap(const wxString& bmpString, wxString& artId, wxString& clientID, wxString& sizeHint);
189
190 /**
191 * @brief convert 'size' into a string that can be used in C++ code.
192 * For example:
193 * '16' -> wxSize(16, 16)
194 * '16,15' -> wxSize(16, 15)
195 * wxDefaultSize -> wxDefaultSize
196 */
197 wxString MakeWxSizeStr(const wxString& size);
198
199 /*
200 * wxSHOW_EFFECT_NONE
201 * wxSHOW_EFFECT_ROLL_TO_LEFT
202 * wxSHOW_EFFECT_ROLL_TO_RIGHT
203 * wxSHOW_EFFECT_ROLL_TO_TOP
204 * wxSHOW_EFFECT_ROLL_TO_BOTTOM
205 * wxSHOW_EFFECT_SLIDE_TO_LEFT
206 * wxSHOW_EFFECT_SLIDE_TO_RIGHT
207 * wxSHOW_EFFECT_SLIDE_TO_TOP
208 * wxSHOW_EFFECT_SLIDE_TO_BOTTOM
209 * wxSHOW_EFFECT_BLEND
210 * wxSHOW_EFFECT_EXPAND
211 */
212 wxShowEffect ShowEffectFromString(const wxString& effect);
213
214 /**
215 * @brief notify codelite about file save
216 * @param fn the file that was saved/generated
217 */
218 void NotifyFileSaved(const wxFileName& fn);
219
220 /**
221 * @brief wrap block of code with #if <...> #endif
222 * @param condname
223 * @param codeblock
224 */
225 void WrapInIfBlock(const wxString& condname, wxString& codeblock);
226
227 /**
228 * @brief return the workspace files as set
229 */
230 void GetWorkspaceFiles(wxStringSet_t& files);
231 /**
232 * @brief return the workspace files as set
233 */
234 void GetProjectFiles(const wxString& projectName, wxStringSet_t& files);
235
236 /**
237 * @brief format source code string
238 */
239 void FormatString(wxString& content, const wxFileName& filename);
240
241 /**
242 * @brief format
243 * @param content
244 * @param filename
245 */
246 void FormatFile(const wxFileName& filename);
247
248 /**
249 * @brief return the top frame
250 */
251 wxWindow* TopFrame();
252
253 /**
254 * @brief set the top frame
255 */
256 void SetTopFrame(wxWindow* frame);
257 } // namespace wxCrafter
258
259 #endif // _WXGUI_HELPERS_H_