SavvyUI C++ UI Library
Loading...
Searching...
No Matches
Common.h
Go to the documentation of this file.
1#pragma once
2
3#include <Windows.h>
4#include <windowsx.h>
5#include <commdlg.h>
6#include <ole2.h>
7#include <stdio.h>
8#include <gdiplus.h>
9#include <string>
10#include <vector>
11#include <map>
12using namespace std;
13
14#define PI 3.14159265358979323846
15
16typedef HWND WinHandle;
17typedef HDC DCHandle;
18
19class Bounds
20{
21public:
22
24 {
25 left = 0;
26 top = 0;
27 right = 0;
28 bottom = 0;
29 }
30
31 Bounds(long x, long y, long x2, long y2)
32 {
33 left = x;
34 top = y;
35 right = x2;
36 bottom = y2;
37 }
38
39 void setWidth(long w)
40 {
41 right = left + w - 1;
42 }
43
44 void setHeight(long h)
45 {
46 bottom = top + h - 1;
47 }
48
49 void deflateRect(long numPixels)
50 {
51 long xPixels = numPixels;
52 while (xPixels>0)
53 {
54 if (left >= right)
55 break;
56 left++;
57
58 if (right > left)
59 right--;
60 xPixels--;
61 }
62 long yPixels = numPixels;
63 while (yPixels > 0)
64 {
65 if (top >= bottom)
66 break;
67 top++;
68
69 if(bottom>top)
70 bottom--;
71 yPixels--;
72 }
73 }
74
75 void inflateRect(long numPixels)
76 {
77 long xPixels = numPixels;
78 while (xPixels>0)
79 {
80 if (left > 0)
81 left--;
82 else
83 break;
84
85 right++;
86 xPixels--;
87 }
88 long yPixels = numPixels;
89 while (yPixels > 0)
90 {
91 if (top > 0)
92 top--;
93 else
94 break;
95
96 bottom++;
97 yPixels--;
98 }
99 }
100
101 long width() const
102 {
103 return right - left;
104 }
105
106 long height() const
107 {
108 return bottom - top;
109 }
110
112};
113
115 LEFT = 1,
116 TOP = 2,
117 RIGHT = 3,
119};
120
132
134 PNG = 1,
135 GIF = 2,
136 JPG = 3
137};
138
150
154 INFO = 3,
157 WARN = 6,
158 GRAY = 7,
160 BLUE = 9,
162 TEAL = 11,
163 CYAN = 12,
164 PINK = 13,
165 INDIGO = 14,
166 ORANGE = 15,
167 BROWN = 16,
168 SILVER = 17,
169 RED = 18,
171};
172
174 BAR = 1,
175 PIE = 2,
176 DONUT = 3,
177 AREA = 4,
178 LINE = 5,
180 RADAR = 7,
183};
184
186{
187public:
188
189 KeyValue(const wstring& key, const wstring& value)
190 {
191 _key = key;
192 _value = value;
193 }
194 wstring _key;
195 wstring _value;
196};
197
199{
200public:
201 __int64 _value1;
202 __int64 _value2;
203 __int64 _value3;
204 __int64 _value4;
205 __int64 _value5;
206 __int64 _value6;
207 __int64 _value7;
208 __int64 _value8;
209 __int64 _value9;
210 __int64 _value10;
211};
212
214{
215 char RecordIndicator[4]; // "IER"
217};
218
220{
221 char RecordIndicator[4]; // "RDR"
222 char RecordType[30]; // "FILE|REGISTRY|INI|SHORTCUT|COMMAND"
223};
224
226{
227 char RecordIndicator[4]; // "CDR"
228 unsigned long FileSize;
229 char TargetFile[255];
231};
232
234{
235 char RecordIndicator[4]; // "CDR"
236 char TargetFile[255];
237 char Parameters[100];
240};
241
243{
244 char RecordIndicator[4]; // "CDR"
245 char Key[255];
246 char Value[255];
247 char Type[255];
248 char Data[255];
250};
251
253{
254 char RecordIndicator[4]; // "CDR"
255 char TargetFile[255];
256 char Section[100];
257 char Key[255];
258 char Value[255];
259};
260
262{
263 char RecordIndicator[4]; // "CDR"
264 char Location[100];
265 char Name[100];
266 char Description[100];
267 char Parameters[100];
269 char TargetFile[255];
270 char IconFilePath[255];
271};
272
274{
275public:
276
277 static wstring strToWStr(const char* input);
278 static string wStrToStr(const wchar_t* input);
279
280 static RECT SRectToRECT(const Bounds& rect);
281
282public:
283
284 static BOOL getExeName(string& filePath, BOOL returnFileNameOnly);
285
286public:
287
288 static BOOL copyFile(const string& srcFilePath, const string& destFilePath, BOOL failIfExists = TRUE, BOOL createDirectoryIfNotExists = TRUE);
289 static BOOL getFileSize(const string& filePath, DWORD& fileSize);
290 static BOOL getDirFromPath(const string& filePath, string& directory);
291 static BOOL getPathComponents(const string& filePath, string& directory, string& fileName, string& fileExtension);
292 static BOOL createDirectory(const string& directory);
293
294 static BOOL readFile(FILE* fp, void* buffer, size_t size, DWORD atOffset);
295 static BOOL writeFile(FILE* fp, void* buffer, size_t size, DWORD atOffset);
296
297public:
298
299 static BOOL createShortcut(const char* targetPath);
300
301 static BOOL addRegistryEntry(const char* valueName, const char* valueData, const char* subKeyPath, HKEY hSection = HKEY_CURRENT_USER);
302 static BOOL executeSystemCommand(const char* command, const char* parameters, const char* workingDirectory, BOOL waitForCompletion = FALSE);
303
304public:
305
306 static BOOL isDigit(wchar_t ch);
307 static BOOL isAlpha(wchar_t ch);
308 static BOOL isDigitOrAlpha(wchar_t ch);
309
310 static wstring systemTimeToStrYYYYMMDD(const SYSTEMTIME& sysTime);
311 static SYSTEMTIME strYYYYMMDDToSystemTime(const wstring& strYYYYMMDD);
312};
313
Direction
Definition Common.h:114
@ TOP
Definition Common.h:116
@ BOTTOM
Definition Common.h:118
@ LEFT
Definition Common.h:115
@ RIGHT
Definition Common.h:117
ImageType
Definition Common.h:133
@ JPG
Definition Common.h:136
@ PNG
Definition Common.h:134
@ GIF
Definition Common.h:135
HWND WinHandle
Definition Common.h:16
ChartType
Definition Common.h:173
@ SCATTER
Definition Common.h:181
@ RADAR
Definition Common.h:180
@ DONUT
Definition Common.h:176
@ PIE
Definition Common.h:175
@ HEATMAP
Definition Common.h:182
@ AREA
Definition Common.h:177
@ BAR
Definition Common.h:174
@ LINE
Definition Common.h:178
@ FUNNEL
Definition Common.h:179
HDC DCHandle
Definition Common.h:17
ImageAlignment
Definition Common.h:121
@ BOTTOMCENTER
Definition Common.h:129
@ TOPRIGHT
Definition Common.h:124
@ TOPCENTER
Definition Common.h:123
@ MIDDLELEFT
Definition Common.h:125
@ BOTTOMLEFT
Definition Common.h:128
@ BOTTOMRIGHT
Definition Common.h:130
@ TOPLEFT
Definition Common.h:122
@ MIDDLERIGHT
Definition Common.h:127
@ MIDDLECENTER
Definition Common.h:126
EditType
Definition Common.h:139
@ COMPUTED
Definition Common.h:148
@ DATEFIELD
Definition Common.h:143
@ MASKEDFIELD
Definition Common.h:141
@ NUMBERFIELD
Definition Common.h:142
@ COMBOBOXFIELD
Definition Common.h:145
@ TEXTAREAFIELD
Definition Common.h:146
@ BOOLFIELD
Definition Common.h:147
@ DATETIMEFIELD
Definition Common.h:144
@ TEXTFIELD
Definition Common.h:140
ButtonType
Definition Common.h:151
@ PINK
Definition Common.h:164
@ BROWN
Definition Common.h:167
@ LIGHTBLUE
Definition Common.h:161
@ BLUE
Definition Common.h:160
@ LIGHTGRAY
Definition Common.h:159
@ GRAY
Definition Common.h:158
@ PRIMARY
Definition Common.h:153
@ SILVER
Definition Common.h:168
@ INFO
Definition Common.h:154
@ WARN
Definition Common.h:157
@ DANGER
Definition Common.h:155
@ DEFAULT
Definition Common.h:152
@ CUSTOM
Definition Common.h:170
@ INDIGO
Definition Common.h:165
@ CYAN
Definition Common.h:163
@ SUCCESS
Definition Common.h:156
@ TEAL
Definition Common.h:162
@ ORANGE
Definition Common.h:166
@ RED
Definition Common.h:169
Definition Common.h:20
long left
Definition Common.h:111
void deflateRect(long numPixels)
Definition Common.h:49
Bounds()
Definition Common.h:23
void setWidth(long w)
Definition Common.h:39
void inflateRect(long numPixels)
Definition Common.h:75
void setHeight(long h)
Definition Common.h:44
long height() const
Definition Common.h:106
long top
Definition Common.h:111
Bounds(long x, long y, long x2, long y2)
Definition Common.h:31
long right
Definition Common.h:111
long width() const
Definition Common.h:101
long bottom
Definition Common.h:111
Definition Common.h:274
static RECT SRectToRECT(const Bounds &rect)
static string wStrToStr(const wchar_t *input)
static BOOL writeFile(FILE *fp, void *buffer, size_t size, DWORD atOffset)
static BOOL readFile(FILE *fp, void *buffer, size_t size, DWORD atOffset)
static BOOL createShortcut(const char *targetPath)
static SYSTEMTIME strYYYYMMDDToSystemTime(const wstring &strYYYYMMDD)
static BOOL createDirectory(const string &directory)
static BOOL getFileSize(const string &filePath, DWORD &fileSize)
static BOOL isDigitOrAlpha(wchar_t ch)
static BOOL getPathComponents(const string &filePath, string &directory, string &fileName, string &fileExtension)
static BOOL getExeName(string &filePath, BOOL returnFileNameOnly)
static BOOL copyFile(const string &srcFilePath, const string &destFilePath, BOOL failIfExists=TRUE, BOOL createDirectoryIfNotExists=TRUE)
static wstring strToWStr(const char *input)
static wstring systemTimeToStrYYYYMMDD(const SYSTEMTIME &sysTime)
static BOOL isAlpha(wchar_t ch)
static BOOL isDigit(wchar_t ch)
static BOOL executeSystemCommand(const char *command, const char *parameters, const char *workingDirectory, BOOL waitForCompletion=FALSE)
static BOOL getDirFromPath(const string &filePath, string &directory)
static BOOL addRegistryEntry(const char *valueName, const char *valueData, const char *subKeyPath, HKEY hSection=HKEY_CURRENT_USER)
wstring _key
Definition Common.h:194
KeyValue(const wstring &key, const wstring &value)
Definition Common.h:189
wstring _value
Definition Common.h:195
Definition Common.h:199
__int64 _value4
Definition Common.h:204
__int64 _value5
Definition Common.h:205
__int64 _value3
Definition Common.h:203
__int64 _value1
Definition Common.h:201
__int64 _value6
Definition Common.h:206
__int64 _value9
Definition Common.h:209
__int64 _value7
Definition Common.h:207
__int64 _value10
Definition Common.h:210
__int64 _value8
Definition Common.h:208
__int64 _value2
Definition Common.h:202
Definition Common.h:234
char WorkingDirectory[255]
Definition Common.h:238
char RecordIndicator[4]
Definition Common.h:235
BOOL WaitToCompletion
Definition Common.h:239
char Parameters[100]
Definition Common.h:237
char TargetFile[255]
Definition Common.h:236
Definition Common.h:226
BOOL OverwriteExisting
Definition Common.h:230
unsigned long FileSize
Definition Common.h:228
char TargetFile[255]
Definition Common.h:229
char RecordIndicator[4]
Definition Common.h:227
Definition Common.h:214
DWORD ExeFileSize
Definition Common.h:216
char RecordIndicator[4]
Definition Common.h:215
Definition Common.h:253
char Value[255]
Definition Common.h:258
char RecordIndicator[4]
Definition Common.h:254
char Key[255]
Definition Common.h:257
char Section[100]
Definition Common.h:256
char TargetFile[255]
Definition Common.h:255
Definition Common.h:220
char RecordType[30]
Definition Common.h:222
char RecordIndicator[4]
Definition Common.h:221
Definition Common.h:243
BOOL OverwriteExisting
Definition Common.h:249
char Value[255]
Definition Common.h:246
char RecordIndicator[4]
Definition Common.h:244
char Data[255]
Definition Common.h:248
char Type[255]
Definition Common.h:247
char Key[255]
Definition Common.h:245
Definition Common.h:262
char Name[100]
Definition Common.h:265
char TargetFile[255]
Definition Common.h:269
char WorkingDirectory[255]
Definition Common.h:268
char Location[100]
Definition Common.h:264
char RecordIndicator[4]
Definition Common.h:263
char IconFilePath[255]
Definition Common.h:270
char Description[100]
Definition Common.h:266
char Parameters[100]
Definition Common.h:267