Menu

[r7]: / Plugin / globals.h  Maximize  Restore  History

Download this file

192 lines (164 with data), 5.8 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//
// copyright : (C) 2008 by Eran Ifrah
// file name : globals.h
//
// -------------------------------------------------------------------------
// A
// _____ _ _ _ _
// / __ \ | | | | (_) |
// | / \/ ___ __| | ___| | _| |_ ___
// | | / _ \ / _ |/ _ \ | | | __/ _ )
// | \__/\ (_) | (_| | __/ |___| | || __/
// \____/\___/ \__,_|\___\_____/_|\__\___|
//
// F i l e
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
#ifndef GLOBALS_H
#define GLOBALS_H
#include <wx/string.h>
#include <wx/colour.h>
#include <wx/arrstr.h>
#include "workspace.h"
class wxListCtrl;
class IEditor;
/**
* \brief send command event to the application (wxTheApp),
* \param eventId
* \param clientData allocated data on the heap. Must be freed by the handler
*/
void SendCmdEvent(int eventId, void *clientData = NULL);
/**
* \brief post command event to the application (wxTheApp),
* \param eventId
* \param clientData allocated data on the heap. Must be freed by the handler
*/
void PostCmdEvent(int eventId, void *clientData = NULL);
/**
* \brief set column text
* \param list the list
* \param indx row ID
* \param column column ID
* \param rText the text
* \param imgId image id
*/
void SetColumnText (wxListCtrl *list, long indx, long column, const wxString &rText, int imgId = wxNOT_FOUND );
/**
* \brief return column's text
* \param list the list control
* \param index the row ID
* \param column the column ID
* \return the column's text
*/
wxString GetColumnText(wxListCtrl *list, long index, long column);
/**
* \brief append row to list control
* \param list the list
* \return new row index
*/
long AppendListCtrlRow(wxListCtrl *list);
/**
* \brief read file from disk using appropriate file conversion
* \param fileName file name
* \param content output string
* \return true on success, false otherwise
*/
bool ReadFileWithConversion(const wxString &fileName, wxString &content);
/**
* \brief write file using UTF8 converter
* \param fileName file path
* \param content file's conent
* \return true on success, false otherwise
*/
bool WriteFileUTF8(const wxString &fileName, const wxString &content);
/**
* \brief delete directory using shell command
* \param path directory path
* \return true on success, false otherwise
*/
bool RemoveDirectory(const wxString &path);
/**
* \brief return true of id is a valid cpp identifier
*/
bool IsValidCppIndetifier(const wxString &id);
/**
* \brief return true of id is a valid cpp file
*/
bool IsValidCppFile(const wxString &id);
/**
* Expand variables to their real value, if expanding fails
* the return value is same as input. The variable is expanded
* in the project context
*/
wxString ExpandVariables(const wxString &expression, ProjectPtr proj, IEditor *editor);
/**
* \brief accepts expression string and expand all known marcos (e.g. $(ProjectName))
* \param expression expression
* \param projectName project name (to be used for $(ProjectName) macro)
* \param fileName file name, to help expand the $(CurrentFile) macro family
* \return an expanded string. If a macro is unknown it is replaced by empty string
*/
wxString ExpandAllVariables(const wxString &expression, Workspace *workspace, const wxString &projectName, const wxString &selConf, const wxString &fileName);
/**
* \brief copy entire directory content (recursievly) from source to target
* \param src source path
* \param target target path
* \return true on success, false otherwise
*/
bool CopyDir(const wxString& src, const wxString& target);
/**
* \brief create a directory
* \param path directory path
*/
void Mkdir(const wxString &path);
/**
* \brief write file content with optinal backup
* \param file_name
* \param content
* \param backup
* \return true on success, false otherwise
*/
bool WriteFileWithBackup(const wxString &file_name, const wxString &content, bool backup);
/**
* \brief copy text to the clipboard
* \return true on success false otherwise
*/
bool CopyToClipboard(const wxString &text);
/**
* \brief make colour lighter
* \param color
* \param level
* \return modified colour
*/
wxColour MakeColourLighter(wxColour color, float level);
/**
* @brief return true if filename is readonly false otherwise
*/
bool IsFileReadOnly(const wxFileName &filename);
/**
* \brief fill an array with a semi-colon separated string
* \param arr [out] the array to fill
* \param str the string to split
*/
void FillFromSmiColonString(wxArrayString &arr, const wxString &str);
/**
* \brief return a string semi-colon separated of the given array
*/
wxString ArrayToSmiColonString(const wxArrayString &array);
/**
* \brief Remove all semi colons of the given string
*/
void StripSemiColons(wxString &str);
/**
* \brief Normalize the given path (change all \ by /)
*/
wxString NormalizePath(const wxString &path);
#endif //GLOBALS_H
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.