-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathguiwin.h
More file actions
231 lines (183 loc) · 6.38 KB
/
Copy pathguiwin.h
File metadata and controls
231 lines (183 loc) · 6.38 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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
// Copyright distributed.net 1997-2004 - All Rights Reserved
// For use in distributed.net projects only.
// Any other distribution or use of this source violates copyright.
#ifndef __GUIWIN_H__
#define __GUIWIN_H__
#if defined(__TURBOC__)
// Borland C++ warnings
#pragma warn -inl // function cannot be inlined
#if (__TURBOC__ <= 0x400)
typedef int bool;
#define false (0)
#define true (!0)
#endif
#elif defined(_MSC_VER)
// MS Visual C++ warnings
#pragma warning(disable:4068) // unknown pragma
#pragma warning(disable:4530) // unwind symantecs not used.
#if (_MSC_VER < 1100)
typedef int bool;
#define false (0)
#define true (!0)
#endif
#endif
#include "version.h"
// Windows headers.
#define WIN32_LEAN_AND_MEAN
#define _WIN32_WINNT 0x0400
#include <windows.h>
#include <commctrl.h>
#include <commdlg.h>
#include <shellapi.h>
// ANSI C Library functions
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <math.h>
#include <sys/stat.h>
// Standard Template Library headers.
#include <queue>
#include <list>
using namespace std;
// gui encapsulation headers
#include "resource.h"
#include "sliderrange.h"
// function prototypes.
extern const char *LogGetCurrentLogFilename(void);
extern void LogSetCurrentLogFilename(const char *filename, bool removeQuotes);
extern LRESULT CALLBACK Main_WindowProc(HWND,UINT,WPARAM,LPARAM);
extern void Main_CmOpenLogfile(HWND hwnd);
extern void Main_CmExportCSV(HWND hwnd);
extern void Main_CmAbout(HWND hwnd);
extern void Main_UpdateTitlebar(HWND hwnd);
// data prototypes.
class MyGraphWindow;
extern MyGraphWindow graphwin;
extern bool bShowIdleDrops;
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// Data Record unit entry, used to store each of the keyrate data samples
// that have been read in and parsed from the log file.
struct MyGraphEntry
{
time_t timestamp;
double rate;
double duration;
double statunits;
operator time_t(void) const { return timestamp; }
};
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// Class definition for the main graphing window itself. This window
// repaints itself with the graph data and handles log parsing by itself.
class MyGraphWindow
{
public:
enum LoggerState {
nologloaded, lognotfound, loadinprogress, logloaded, loginvalid
};
enum project_t {
PROJECT_UNKNOWN,
PROJECT_RC5,
PROJECT_RC5_72,
PROJECT_DES,
PROJECT_CSC,
PROJECT_OGR,
PROJECT_OGR_P2,
PROJECT_NEXTUNUSED // this entry must be last.
};
protected:
// data type to represent the data storage class.
#if 0
typedef priority_queue< deque<MyGraphEntry>, less<time_t>() > LogDataStorage_t;
#else
typedef deque<MyGraphEntry> LogDataStorage_t;
#endif
// storage data variables.
LogDataStorage_t logdata;
time_t mintime, maxtime;
double minrate, maxrate;
double totalkeys;
bool haveprojectdata[PROJECT_NEXTUNUSED];
// user configurable options.
time_t rangestart, rangeend;
project_t viewedproject;
// current application state.
HANDLE hLogThread;
LoggerState loggerstate;
bool bStateChanged;
CRITICAL_SECTION loggerbusy;
// log parsing
static long LogParseThread(long lParam);
void ReadLogData(void);
public:
// constructor and destructor.
MyGraphWindow(void);
~MyGraphWindow(void);
// window repainting.
int DoRedraw(HDC dc, RECT clientrect);
// public interface methods.
void LogRereadNeeded(HWND hwnd);
// public interface methods.
void GetDataRange(time_t &start, time_t &end) const
{ start = mintime; end = maxtime; }
// public interface methods.
void GetRange(time_t &start, time_t &end) const
{ start = rangestart; end = rangeend; }
// public interface methods.
void SetRange(time_t start, time_t end)
{ rangestart = start; rangeend = end; }
// public interface methods.
bool IsDataAvailable(void) const
{ return loggerstate == logloaded && !logdata.empty() &&
minrate != maxrate && mintime != maxtime; }
bool IsDataAvailable(project_t project) const
{ return (loggerstate == logloaded || loggerstate == loginvalid) && haveprojectdata[project]; }
// public interface methods.
// also resets the status changed tracker.
const char *GetStatusString(void);
// public interface methods.
LoggerState GetStatusValue(void) const { return loggerstate; }
// public interface methods.
// indicates of GetStatusString() will return a different value.
bool HasStatusChanged(void) const { return bStateChanged; }
// public interface methods.
int ExportCSV(const char *outputfile);
// public interface methods.
UINT GetViewedProjectMenuId(void) const;
bool SetViewedProjectByMenuId(UINT menuid);
};
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// Class definition for the time range configuration dialog that is
// activated from the popup context menu within the graph viewer.
class MyGraphConfig
{
protected:
// data storage.
time_t userstart, userend;
// event handlers
static BOOL CALLBACK DialogProc(HWND, UINT, WPARAM, LPARAM);
int OnCommand(HWND hwndDlg, WORD wNotifyCode, WORD wID, HWND hWndControl);
int OnInitDialog(HWND hwndDlg, HWND hWndFocus, LPARAM lParam);
BOOL OnOK(HWND hwndDlg);
public:
// class constructor.
MyGraphConfig() : starttime(0), endtime(0), datastart(0), dataend(0),
userstart(0), userend(0) {};
// public method to invoke blocking dialog execution.
int DoModal(HWND parent);
// Data storage for currently selected date ranges.
// Modify these values before calling DoModal(), and read
// from them after regaining control.
time_t starttime, endtime;
time_t datastart, dataend;
};
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
#endif // __GUIWIN_H__