-
Notifications
You must be signed in to change notification settings - Fork 0
/
Settings.h
650 lines (526 loc) · 14.8 KB
/
Settings.h
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
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
#pragma once
#include <algorithm>
#include <map>
#include <vector>
#include "resource.h"
#include "res1.h"
#include "utils.h"
#include "XMLSerializer\Serializable.h"
/*const int ILANG_ENGLISH = 0;
const int ILANG_RUSSIAN = 1;*/
class WordsItem : public ISerializable, public IObjectFactory
{
public:
CString m_word;
int m_count;
CString m_sCount;
int m_percent;
int m_prc_idx;
WordsItem() { }
WordsItem(CString word, int count) : m_word(word), m_count(count) { }
int GetProperties(std::vector<CString>& properties)
{
properties.push_back(L"Value");
properties.push_back(L"Counted");
return properties.size();
}
bool GetPropertyValue(const CString& sProperty, CProperty& property)
{
if(sProperty == L"Value")
{
property = m_word;
return true;
}
else if(sProperty == L"Counted")
{
CString counted;
counted.Format(L"%d", m_count);
property = counted;
return true;
}
return false;
}
bool SetPropertyValue(const CString& sProperty, CProperty& property)
{
if(sProperty == L"Value")
{
m_word = property;
return true;
}
else if(sProperty == L"Counted")
{
m_count = StrToInt(property.GetStringValue());
return true;
}
return false;
}
bool HasMultipleInstances()
{
return true;
}
CString GetClassName()
{
return L"Word";
}
CString GetID()
{
return L"";
}
ISerializable* Create()
{
return new WordsItem;
}
void Destroy(ISerializable* obj)
{
delete obj;
}
bool operator==(const WordsItem& wi)
{
return m_word.CompareNoCase(wi.m_word) == 0;
}
};
class CHotkey : public ISerializable, public IObjectFactory
{
public:
CString m_name;
CString m_reg_name;
ACCEL m_accel;
ACCEL m_def_accel;
CString m_desc;
wchar_t m_char_val; // value for symbol hotkey
CHotkey() {}
CHotkey(CString reg_name, int IDS_CMD_NAME, WORD fVirt, WORD cmd, WORD key, CString descr = L"")
{
m_reg_name = reg_name;
m_name.LoadString(IDS_CMD_NAME);
m_def_accel.fVirt = FVIRTKEY | fVirt;
m_def_accel.cmd = cmd;
m_def_accel.key = key;
m_accel = m_def_accel;
m_desc = descr;
}
CHotkey(CString reg_name, int IDS_CMD_NAME, CString uchar, WORD fVirt, WORD cmd, WORD key, CString descr = L"")
{
m_reg_name = reg_name;
m_name.LoadString(IDS_CMD_NAME);
m_name += uchar;
m_def_accel.fVirt = FVIRTKEY | fVirt;
m_def_accel.cmd = cmd;
m_def_accel.key = key;
m_accel = m_def_accel;
m_desc = descr;
}
CHotkey(CString reg_name, CString name, wchar_t symbol, WORD fVirt, WORD cmd, WORD key, CString descr = L"")
{
m_reg_name = reg_name;
m_name = name;
m_char_val = symbol;
m_def_accel.fVirt = FVIRTKEY | fVirt;
m_def_accel.cmd = cmd;
m_def_accel.key = key;
m_accel = m_def_accel;
m_desc = descr;
}
CHotkey(CString reg_name, CString cmd_name, WORD fVirt, WORD cmd, WORD key, CString descr = L"")
{
m_reg_name = reg_name;
m_name = cmd_name;
m_def_accel.fVirt = FVIRTKEY | fVirt;
m_def_accel.cmd = cmd;
m_def_accel.key = key;
m_accel = m_def_accel;
m_desc = descr;
}
bool operator < (const CHotkey& other) const
{
return (m_name.CompareNoCase(other.m_name) < 0);
}
// ISerializable interface
int GetProperties(std::vector<CString>& properties)
{
properties.push_back(L"Name");
properties.push_back(L"Accel");
return properties.size();
}
bool GetPropertyValue(const CString& sProperty, CProperty& property)
{
if(sProperty == L"Name")
{
property = m_reg_name;
return true;
}
if(sProperty == L"Accel")
{
CString temp;
temp.Format(L"%u;%u",
m_accel.fVirt, m_accel.key);
property = temp;
return true;
}
return false;
}
bool SetPropertyValue(const CString& sProperty, CProperty& sValue)
{
if(sProperty == L"Name")
{
m_reg_name = sValue.GetStringValue();
return true;
}
else if(sProperty == L"Accel")
{
CString str = sValue.GetStringValue();
int n = 0, curPos = 0;
while(str.Tokenize(L";", curPos) != L"")
n++;
CString* tokens = new CString[n];
curPos = n =0;
CString temp;
while((temp = str.Tokenize(L";", curPos)) != L"")
{
tokens[n] = temp;
n++;
}
if(n == 2)
{
m_accel.fVirt = StrToInt(tokens[0]);
m_accel.key = StrToInt(tokens[1]);
}
delete[] tokens;
return true;
}
return false;
}
bool HasMultipleInstances()
{
return false;
}
CString GetClassName()
{
return L"Hotkey";
}
CString GetID()
{
return L"";
}
ISerializable* Create()
{
return new CHotkey;
}
void Destroy(ISerializable* obj)
{
delete obj;
}
};
class CHotkeysGroup : public ISerializable, public IObjectFactory
{
public:
CString m_name;
CString m_reg_name;
std::vector<CHotkey> m_hotkeys;
CHotkey m_hotkey_factory;
std::vector<void*> m_ptr_hotkeys;
CHotkeysGroup()
{
}
CHotkeysGroup(CString reg_name, int IDS_GROUP_NAME)
{
m_reg_name = reg_name;
::LoadString(_Module.GetResourceInstance(), IDS_GROUP_NAME, m_name.GetBufferSetLength(MAX_LOAD_STRING + 1),
MAX_LOAD_STRING + 1);
}
bool operator < (const CHotkeysGroup& other) const
{
return (m_name.CompareNoCase(other.m_name) < 0);
}
int GetProperties(std::vector<CString>& properties)
{
properties.push_back(L"GroupName");
properties.push_back(L"Hotkey");
return properties.size();
}
bool GetPropertyValue(const CString& sProperty, CProperty& property)
{
if(sProperty == L"GroupName")
{
property = m_reg_name;
return true;
}
if(sProperty == L"Hotkey")
{
for(unsigned long i = 0 ; i < m_hotkeys.size(); ++i)
m_ptr_hotkeys.push_back(&m_hotkeys[i]);
property = m_ptr_hotkeys;
property.SetFactory(&m_hotkey_factory);
return true;
}
return false;
}
bool SetPropertyValue(const CString& sProperty, CProperty& sValue)
{
if(sProperty == L"GroupName")
{
m_reg_name = sValue.GetStringValue();
return true;
}
if(sProperty == L"Hotkey")
{
std::vector<void*>::iterator iter = m_ptr_hotkeys.begin();
while(iter != m_ptr_hotkeys.end())
{
CHotkey* pHotkey = (CHotkey*)&iter;
delete pHotkey;
iter++;
}
CProperty::CopyPtrList(m_ptr_hotkeys, sValue.GetObjectList());
m_hotkeys.clear();
for(unsigned long i = 0 ; i < m_ptr_hotkeys.size(); ++i)
{
CHotkey* temp = (CHotkey*)m_ptr_hotkeys[i];
m_hotkeys.push_back(*temp);
}
return true;
}
return false;
}
bool HasMultipleInstances()
{
return true;
}
CString GetClassName()
{
return L"HkGroup";
}
CString GetID()
{
return L"";
}
ISerializable* Create()
{
return new CHotkeysGroup;
}
void Destroy(ISerializable* obj)
{
delete obj;
}
};
class DESCSHOWINFO : public ISerializable, public IObjectFactory
{
public:
std::map<CString, bool> elements;
DESCSHOWINFO()
{
SetDefaults();
}
// Default fields showing in description
void SetDefaults()
{
elements[L"ci_all"] = true;
elements[L"sti_all"] = false;
elements[L"di_id"] = true;
elements[L"id"] = true;
elements[L"ti_kw"] = true;
elements[L"ti_nic_mail_web"] = true;
elements[L"ti_genre_match"] = true;
}
// ISerializable interface
int GetProperties(std::vector<CString>& properties);
bool GetPropertyValue(const CString& sProperty, CProperty& sValue);
bool SetPropertyValue(const CString& sProperty, CProperty& sValue);
bool HasMultipleInstances();
CString GetClassName();
CString GetID();
// IObjectFactory
ISerializable* Create();
void Destroy(ISerializable*);
};
class TREEITEMSHOWINFO : public ISerializable, public IObjectFactory
{
public:
std::map<CString, bool> items;
TREEITEMSHOWINFO();
void SetDefaults();
// ISerializable interface
int GetProperties(std::vector<CString>& properties);
bool GetPropertyValue(const CString& sProperty, CProperty& sValue);
bool SetPropertyValue(const CString& sProperty, CProperty& sValue);
bool HasMultipleInstances();
CString GetClassName();
CString GetID();
// IObjectFactory
ISerializable* Create();
void Destroy(ISerializable*);
};
class CSettings : public ISerializable, public IObjectFactory
{
CRegKey m_key;
CString m_key_path;
bool m_keep_encoding; // save with opened encoding
CString m_default_encoding;
DWORD m_search_options;
DWORD m_collorBG;
DWORD m_collorFG;
DWORD m_font_size;
CString m_font;
CString m_srcfont;
bool m_xml_src_wrap;
bool m_xml_src_syntaxHL;
bool m_xml_src_tagHL;
bool m_xml_src_showEOL;
bool m_xml_src_showSpace;
bool m_fast_mode;
bool m_view_status_bar;
bool m_view_doc_tree;
// added by SeNS
bool m_usespell_check;
bool m_highlght_check;
CString m_custom_dict;
DWORD m_custom_dict_codepage;
CString m_nbsp_char;
CString m_old_nbsp;
bool m_change_kbd_layout_check;
DWORD m_keyb_layout;
bool m_show_line_numbers;
DWORD m_image_type;
DWORD m_jpeg_quality;
///
DWORD m_splitter_pos;
CString m_toolbars_settings;
bool m_restore_file_position;
DWORD m_interface_lang_id;
bool m_need_restart;
CString m_scripts_folder;
bool m_insimage_ask;
bool m_ins_clear_image;
bool m_show_words_excls;
WINDOWPLACEMENT m_words_dlg_placement;
WINDOWPLACEMENT m_wnd_placement;
DESCSHOWINFO m_desc;
TREEITEMSHOWINFO m_tree_items;
// added by SeNS: view dimensions for external helper
int m_viewWidth, m_viewHeight;
HWND m_hMainWindow;
public:
std::vector<CHotkeysGroup> m_hotkey_groups;
int keycodes; // total number of accelerators
std::vector<WordsItem> m_words;
public:
CSettings();
~CSettings();
void Init();
void InitHotkeyGroups();
void Close();
// ISerializable interface
int GetProperties(std::vector<CString>& properties);
bool GetPropertyValue(const CString& sProperty, CProperty& sValue);
bool SetPropertyValue(const CString& sProperty, CProperty& sValue);
bool HasMultipleInstances();
CString GetClassName();
CString GetID();
// IObjectFactory
ISerializable* Create();
void Destroy(ISerializable*);
void SetDefaults();
void Load();
void Save();
void LoadHotkeyGroups();
void SaveHotkeyGroups();
CHotkeysGroup* GetGroupByName(const CString& name);
CHotkey* GetHotkeyByName(const CString& name, CHotkeysGroup& group);
void LoadWords();
void SaveWords();
bool NeedRestart()const;
bool KeepEncoding()const;
bool XmlSrcWrap()const;
bool XmlSrcSyntaxHL()const;
bool XmlSrcTagHL()const;
bool XmlSrcShowEOL()const;
bool XmlSrcShowSpace()const;
bool FastMode()const;
bool ViewStatusBar()const;
bool ViewDocumentTree()const;
bool RestoreFilePosition()const;
CString GetKeyPath()const;
CString GetDefaultEncoding()const;
DWORD GetSearchOptions()const;
DWORD GetColorBG()const;
DWORD GetColorFG()const;
DWORD GetFontSize()const;
CString GetFont()const;
CString GetSrcFont()const;
DWORD GetSplitterPos()const;
CString GetToolbarsSettings()const;
const CRegKey& GetKey()const;
// added by SeNS
bool GetUseSpellChecker()const;
bool GetHighlightMisspells()const;
CString GetCustomDict()const;
DWORD GetCustomDictCodepage()const;
CString GetNBSPChar()const;
CString GetOldNBSPChar()const;
bool GetChangeKeybLayout()const;
DWORD GetKeybLayout()const;
bool XMLSrcShowLineNumbers()const;
DWORD GetImageType()const;
DWORD GetJpegQuality()const;
bool GetExtElementStyle(const CString& elem)const;
bool GetWindowPosition(WINDOWPLACEMENT& wpl)const;
DWORD GetInterfaceLanguageID()const;
CString GetInterfaceLanguageDllName()const;
CString GetLocalizedGenresFileName()const;
CString GetInterfaceLanguageName()const;
CString GetScriptsFolder() const;
CString GetDefaultScriptsFolder();
bool IsDefaultScriptsFolder();
bool GetInsImageAsking()const;
bool GetIsInsClearImage()const;
bool GetShowWordsExcls()const;
bool GetWordsDlgPosition(WINDOWPLACEMENT &wpl)const;
bool GetDocTreeItemState(const CString& item, bool default_state);
void SetKeepEncoding(bool keep, bool apply = false);
void SetDefaultEncoding(const CString& encoding, bool apply = false);
void SetSearchOptions(DWORD opt, bool apply = false);
void SetColorBG(DWORD color, bool apply = false);
void SetColorFG(DWORD color, bool apply = false);
void SetFontSize(DWORD size, bool apply = false);
void SetXmlSrcWrap(bool wrap, bool apply = false);
void SetXmlSrcSyntaxHL(bool hl, bool apply = false);
void SetXmlSrcTagHL(bool hl, bool apply = false);
void SetXmlSrcShowEOL(bool eol, bool apply = false);
void SetXmlSrcShowSpace(bool eol, bool apply = false);
void SetFastMode(bool mode, bool apply = false);
void SetFont(const CString& font, bool apply = false);
void SetSrcFont(const CString& font, bool apply = false);
void SetViewStatusBar(bool view, bool apply = false);
void SetViewDocumentTree(bool view, bool apply = false);
void SetSplitterPos(DWORD pos, bool apply = false);
void SetToolbarsSettings(CString& settings, bool apply = false);
void SetExtElementStyle(const CString& elem, bool ext, bool apply = false);
void SetWindowPosition(const WINDOWPLACEMENT& wpl, bool apply = false);
void SetRestoreFilePosition(bool restore, bool apply = false);
void SetInterfaceLanguage(DWORD Language, bool apply = false);
void SetScriptsFolder(const CString fullpath, bool apply = false);
void SetInsImageAsking(const bool value, bool apply = false);
void SetIsInsClearImage(const bool value, bool apply = false);
void SetDocTreeItemState(const CString& item, bool state);
void SetShowWordsExcls(const bool value, bool apply = false);
void SetWordsDlgPosition(const WINDOWPLACEMENT& wpl, bool apply = false);
void SetNeedRestart();
CString m_initial_scripts_folder;
// added by SeNS
void SetUseSpellChecker(const bool value, bool apply = false);
void SetHighlightMisspells(const bool value, bool apply = false);
void SetCustomDict(const ATL::CString &value, bool apply = false);
void SetCustomDictCodepage(const DWORD value, bool apply = false);
void SetNBSPChar(const ATL::CString &value, bool apply = false);
void SetChangeKeybLayout(const bool value, bool apply = false);
void SetKeybLayout(const DWORD value, bool apply = false);
void SetXMLSrcShowLineNumbers(const bool value, bool apply = false);
void SetImageType(const DWORD value, bool apply = false);
void SetJpegQuality(const DWORD value, bool apply = false);
void SetViewWidth(int width) { m_viewWidth = width; }
void SetViewHeight(int height) { m_viewHeight = height; }
int GetViewWidth() { return m_viewWidth; }
int GetViewHeight() { return m_viewHeight; }
void SetMainWindow(HWND hwnd) { m_hMainWindow = hwnd; }
HWND GetMainWindow() { return m_hMainWindow; }
};