Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

[81b7ce]: win32 / SciTEWin.h Maximize Restore History

Download this file

SciTEWin.h    427 lines (359 with data), 11.9 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
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
// SciTE - Scintilla based Text Editor
/** @file SciTEWin.h
** Header of main code for the Windows version of the editor.
**/
// Copyright 1998-2003 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed.
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <stdio.h>
#include <fcntl.h>
#include <stdarg.h>
#include <sys/stat.h>
#include <string>
#include <vector>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <sstream>
#include <iomanip>
#ifdef __MINGW_H
#define _WIN32_IE 0x0400
#endif
#undef _WIN32_WINNT
#undef WINVER
#ifdef WIN_TARGET
#define _WIN32_WINNT WIN_TARGET
#define WINVER WIN_TARGET
#else
#define _WIN32_WINNT 0x0501
#define WINVER 0x0501
#endif
#ifdef _MSC_VER
// windows.h, et al, use a lot of nameless struct/unions - can't fix it, so allow it
#pragma warning(disable: 4201)
#endif
#include <windows.h>
#if defined(DISABLE_THEMES) || (defined(_MSC_VER) && (_MSC_VER <= 1200))
// Old compilers do not have Uxtheme.h
typedef void *HTHEME;
#else
#include <uxtheme.h>
#endif
#ifdef _MSC_VER
// okay, that's done, don't allow it in our code
#pragma warning(default: 4201)
#endif
#include <commctrl.h>
#include <richedit.h>
#include <shlwapi.h>
#include <io.h>
#include <process.h>
#include <mmsystem.h>
#include <commctrl.h>
#ifdef _MSC_VER
#include <direct.h>
#endif
#ifdef __DMC__
#include <dir.h>
#endif
#if defined(DTBG_CLIPRECT) && !defined(DISABLE_THEMES)
#define THEME_AVAILABLE
#endif
// Since Vsstyle.h and Vssym32.h are not available from all compilers just define the used symbols
#define CBS_NORMAL 1
#define CBS_HOT 2
#define CBS_PUSHED 3
#define WP_SMALLCLOSEBUTTON 19
#define TS_NORMAL 1
#define TS_HOT 2
#define TS_PRESSED 3
#define TS_CHECKED 5
#define TS_HOTCHECKED 6
#define TP_BUTTON 1
#ifndef DFCS_HOT
#define DFCS_HOT 1000
#endif
#ifndef WM_UPDATEUISTATE
#define WM_UPDATEUISTATE 0x0128
#endif
#include "Scintilla.h"
#include "ILexer.h"
#include "GUI.h"
#include "SString.h"
#include "StringList.h"
#include "StringHelpers.h"
#include "FilePath.h"
#include "StyleDefinition.h"
#include "PropSetFile.h"
#include "StyleWriter.h"
#include "Extender.h"
#include "SciTE.h"
#include "Mutex.h"
#include "JobQueue.h"
#include "Cookie.h"
#include "Worker.h"
#include "FileWorker.h"
#include "SciTEBase.h"
#include "SciTEKeys.h"
#include "UniqueInstance.h"
#include "StripDefinition.h"
#include "Strips.h"
const int SCITE_TRAY = WM_APP + 0;
const int SCITE_DROP = WM_APP + 1;
const int SCITE_WORKER = WM_APP + 2;
enum {
WORK_EXECUTE = WORK_PLATFORM + 1
};
class SciTEWin;
class CommandWorker : public Worker {
public:
SciTEWin *pSciTE;
int icmd;
int originalEnd;
int exitStatus;
GUI::ElapsedTime commandTime;
std::string output;
int flags;
bool seenOutput;
int outputScroll;
CommandWorker();
void Initialise(bool resetToStart);
virtual void Execute();
};
class Dialog;
class ContentWin : public BaseWin {
SciTEWin *pSciTEWin;
bool capturedMouse;
public:
ContentWin() : pSciTEWin(0), capturedMouse(false) {
}
void SetSciTE(SciTEWin *pSciTEWin_) {
pSciTEWin = pSciTEWin_;
}
void Paint(HDC hDC, GUI::Rectangle rcPaint);
LRESULT WndProc(UINT iMessage, WPARAM wParam, LPARAM lParam);
};
struct Band {
bool visible;
int height;
bool expands;
GUI::Window win;
Band(bool visible_, int height_, bool expands_, GUI::Window win_) :
visible(visible_),
height(height_),
expands(expands_),
win(win_) {
}
};
/** Windows specific stuff.
**/
class SciTEWin : public SciTEBase {
friend class ContentWin;
friend class Strip;
friend class SearchStrip;
friend class FindStrip;
friend class ReplaceStrip;
friend class UserStrip;
protected:
int cmdShow;
static HINSTANCE hInstance;
static const TCHAR *className;
static const TCHAR *classNameInternal;
static SciTEWin *app;
WINDOWPLACEMENT winPlace;
RECT rcWorkArea;
GUI::gui_char openWhat[200];
GUI::gui_char tooltipText[MAX_PATH*2 + 1];
bool tbLarge;
bool modalParameters;
int filterDefault;
bool staticBuild;
int menuSource;
std::deque<GUI::gui_string> dropFilesQueue;
// Fields also used in tool execution thread
CommandWorker cmdWorker;
HANDLE hWriteSubProcess;
DWORD subProcessGroupId;
HACCEL hAccTable;
GUI::Rectangle pagesetupMargin;
HGLOBAL hDevMode;
HGLOBAL hDevNames;
UniqueInstance uniqueInstance;
/// HTMLHelp module
HMODULE hHH;
/// Multimedia (sound) module
HMODULE hMM;
// Tab Bar
HFONT fontTabs;
/// Preserve focus during deactivation
HWND wFocus;
GUI::Window wFindInFiles;
GUI::Window wFindReplace;
GUI::Window wParameters;
ContentWin contents;
BackgroundStrip backgroundStrip;
UserStrip userStrip;
SearchStrip searchStrip;
FindStrip findStrip;
ReplaceStrip replaceStrip;
enum { bandTool, bandTab, bandContents, bandUser, bandBackground, bandSearch, bandFind, bandReplace, bandStatus };
std::vector<Band> bands;
virtual void ReadLocalization();
virtual void GetWindowPosition(int *left, int *top, int *width, int *height, int *maximize);
virtual void ReadProperties();
virtual void TimerStart(int mask);
virtual void TimerEnd(int mask);
virtual void SizeContentWindows();
virtual void SizeSubWindows();
virtual void SetMenuItem(int menuNumber, int position, int itemID,
const GUI::gui_char *text, const GUI::gui_char *mnemonic = 0);
virtual void RedrawMenu();
virtual void DestroyMenuItem(int menuNumber, int itemID);
virtual void CheckAMenuItem(int wIDCheckItem, bool val);
virtual void EnableAMenuItem(int wIDCheckItem, bool val);
virtual void CheckMenus();
void LocaliseMenu(HMENU hmenu);
void LocaliseMenus();
void LocaliseControl(HWND w);
void LocaliseDialog(HWND wDialog);
int DoDialog(HINSTANCE hInst, const TCHAR *resName, HWND hWnd, DLGPROC lpProc);
GUI::gui_string DialogFilterFromProperty(const GUI::gui_char *filterProperty);
virtual bool OpenDialog(FilePath directory, const GUI::gui_char *filter);
FilePath ChooseSaveName(FilePath directory, const char *title, const GUI::gui_char *filter=0, const char *ext=0);
virtual bool SaveAsDialog();
virtual void SaveACopy();
virtual void SaveAsHTML();
virtual void SaveAsRTF();
virtual void SaveAsPDF();
virtual void SaveAsTEX();
virtual void SaveAsXML();
virtual void LoadSessionDialog();
virtual void SaveSessionDialog();
virtual bool PreOpenCheck(const GUI::gui_char *file);
virtual bool IsStdinBlocked();
/// Print the current buffer.
virtual void Print(bool showDialog);
/// Handle default print setup values and ask the user its preferences.
virtual void PrintSetup();
BOOL HandleReplaceCommand(int cmd, bool reverseFind = false);
virtual int WindowMessageBox(GUI::Window &w, const GUI::gui_string &msg, int style);
virtual void FindMessageBox(const SString &msg, const std::string *findItem = 0);
virtual void AboutDialog();
void DropFiles(HDROP hdrop);
void MinimizeToTray();
void RestoreFromTray();
static GUI::gui_string ProcessArgs(const GUI::gui_char *cmdLine);
virtual void QuitProgram();
virtual FilePath GetDefaultDirectory();
virtual FilePath GetSciteDefaultHome();
virtual FilePath GetSciteUserHome();
virtual void SetFileProperties(PropSetFile &ps);
virtual void SetStatusBarText(const char *s);
virtual void TabInsert(int index, const GUI::gui_char *title);
virtual void TabSelect(int index);
virtual void RemoveAllTabs();
/// Warn the user, by means defined in its properties.
virtual void WarnUser(int warnID);
virtual void Notify(SCNotification *notification);
virtual void ShowToolBar();
virtual void ShowTabBar();
virtual void ShowStatusBar();
virtual void ActivateWindow(const char *timestamp);
void ExecuteHelp(const char *cmd);
void ExecuteOtherHelp(const char *cmd);
void CopyAsRTF();
void CopyPath();
void FullScreenToggle();
void Command(WPARAM wParam, LPARAM lParam);
HWND MainHWND();
virtual void UserStripShow(const char *description);
virtual void UserStripSet(int control, const char *value);
virtual void UserStripSetList(int control, const char *value);
virtual const char *UserStripValue(int control);
void UserStripClosed();
virtual void ShowBackgroundProgress(const GUI::gui_string &explanation, int size, int progress);
BOOL FindMessage(HWND hDlg, UINT message, WPARAM wParam);
static BOOL CALLBACK FindDlg(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
BOOL ReplaceMessage(HWND hDlg, UINT message, WPARAM wParam);
static BOOL CALLBACK ReplaceDlg(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
virtual void UIClosed();
void PerformGrep();
void FillCombos(Dialog &dlg);
BOOL GrepMessage(HWND hDlg, UINT message, WPARAM wParam);
static BOOL CALLBACK GrepDlg(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
virtual void FindIncrement();
bool FindReplaceAdvanced();
virtual void Find();
virtual void FindInFiles();
virtual void Replace();
virtual void FindReplace(bool replace);
virtual void DestroyFindReplace();
BOOL GoLineMessage(HWND hDlg, UINT message, WPARAM wParam);
static BOOL CALLBACK GoLineDlg(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
virtual void GoLineDialog();
BOOL AbbrevMessage(HWND hDlg, UINT message, WPARAM wParam);
static BOOL CALLBACK AbbrevDlg(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
virtual bool AbbrevDialog();
BOOL TabSizeMessage(HWND hDlg, UINT message, WPARAM wParam);
static BOOL CALLBACK TabSizeDlg(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
virtual void TabSizeDialog();
virtual bool ParametersOpen();
void ParamGrab();
virtual bool ParametersDialog(bool modal);
BOOL ParametersMessage(HWND hDlg, UINT message, WPARAM wParam);
static BOOL CALLBACK ParametersDlg(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
BOOL AboutMessage(HWND hDlg, UINT message, WPARAM wParam);
static BOOL CALLBACK AboutDlg(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
void AboutDialogWithBuild(int staticBuild);
void RestorePosition();
public:
SciTEWin(Extension *ext = 0);
~SciTEWin();
static bool DialogHandled(GUI::WindowID id, MSG *pmsg);
bool ModelessHandler(MSG *pmsg);
void CreateUI();
/// Management of the command line parameters.
void Run(const GUI::gui_char *cmdLine);
uptr_t EventLoop();
void OutputAppendEncodedStringSynchronised(GUI::gui_string s, int codePage);
void ResetExecution();
void ExecuteNext();
DWORD ExecuteOne(const Job &jobToRun);
void ProcessExecute();
void ShellExec(const SString &cmd, const char *dir);
virtual void Execute();
virtual void StopExecute();
virtual void AddCommand(const SString &cmd, const SString &dir, JobSubsystem jobType, const SString &input = "", int flags=0);
virtual bool PerformOnNewThread(Worker *pWorker);
virtual void PostOnMainThread(int cmd, Worker *pWorker);
virtual void WorkerCommand(int cmd, Worker *pWorker);
void Creation();
LRESULT KeyDown(WPARAM wParam);
LRESULT KeyUp(WPARAM wParam);
virtual void AddToPopUp(const char *label, int cmd=0, bool enabled=true);
LRESULT ContextMenuMessage(UINT iMessage, WPARAM wParam, LPARAM lParam);
void CheckForScintillaFailure(int statusFailure);
LRESULT WndProc(UINT iMessage, WPARAM wParam, LPARAM lParam);
virtual std::string EncodeString(const std::string &s);
virtual SString GetRangeInUIEncoding(GUI::ScintillaWindow &wCurrent, int selStart, int selEnd);
HACCEL GetAcceleratorTable() {
return hAccTable;
}
uptr_t GetInstance();
static void Register(HINSTANCE hInstance_);
static LRESULT PASCAL TWndProc(
HWND hWnd, UINT iMessage, WPARAM wParam, LPARAM lParam);
friend class UniqueInstance;
};
inline bool IsKeyDown(int key) {
return (::GetKeyState(key) & 0x80000000) != 0;
}
inline GUI::Point PointFromLong(LPARAM lPoint) {
return GUI::Point(static_cast<short>(LOWORD(lPoint)), static_cast<short>(HIWORD(lPoint)));
}
inline int ControlIDOfWParam(WPARAM wParam) {
return wParam & 0xffff;
}