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
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
|
/////////////////////////////////////////////////////////////////////////////////////////
// Miranda NG: the free IM client for Microsoft* Windows*
//
// Copyright (C) 2012-24 Miranda NG team,
// Copyright (c) 2000-09 Miranda ICQ/IM project,
// all portions of this codebase are copyrighted to the people
// listed in contributors.txt.
//
// 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.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// you should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
// part of tabSRMM messaging plugin for Miranda.
//
// (C) 2005-2010 by silvercircle _at_ gmail _dot_ com and contributors
//
// group chat options and generic font handling
#include "stdafx.h"
#define FONTF_BOLD 1
#define FONTF_ITALIC 2
struct FontOptionsList
{
wchar_t *szDescr;
COLORREF defColour;
wchar_t *szDefFace;
uint8_t defCharset, defStyle;
char defSize;
COLORREF colour;
wchar_t szFace[LF_FACESIZE];
uint8_t charset, style;
char size;
};
struct ColorOptionsList
{
int order;
wchar_t *tszGroup;
wchar_t *tszName;
char *szSetting;
COLORREF def;
};
/*
* note: bits 24-31 in default color indicates that color is a system color index
* (GetSysColor(default_color & 0x00ffffff)), not a rgb value.
*/
static ColorOptionsList _clrs[] = {
{ 0, LPGENW("Message sessions"), LPGENW("Input area background"), "inputbg", SRMSGDEFSET_BKGCOLOUR },
{ 1, LPGENW("Message sessions"), LPGENW("Log background"), SRMSGSET_BKGCOLOUR, SRMSGDEFSET_BKGCOLOUR },
{ 0, LPGENW("Message sessions") L"/" LPGENW("Single Messaging"), LPGENW("Outgoing background"), "outbg", SRMSGDEFSET_BKGOUTCOLOUR },
{ 1, LPGENW("Message sessions") L"/" LPGENW("Single Messaging"), LPGENW("Incoming background"), "inbg", SRMSGDEFSET_BKGINCOLOUR },
{ 2, LPGENW("Message sessions") L"/" LPGENW("Single Messaging"), LPGENW("Status background"), "statbg", SRMSGDEFSET_BKGCOLOUR },
{ 3, LPGENW("Message sessions") L"/" LPGENW("Single Messaging"), LPGENW("Incoming background(old)"), "oldinbg", SRMSGDEFSET_BKGINCOLOUR },
{ 4, LPGENW("Message sessions") L"/" LPGENW("Single Messaging"), LPGENW("Outgoing background(old)"), "oldoutbg", SRMSGDEFSET_BKGOUTCOLOUR },
{ 5, LPGENW("Message sessions") L"/" LPGENW("Single Messaging"), LPGENW("Horizontal Grid Lines"), "hgrid", RGB(224, 224, 224) },
{ 0, LPGENW("Message sessions") L"/" LPGENW("Info Panel"), LPGENW("Panel background low"), "ipfieldsbg", 0x62caff },
{ 1, LPGENW("Message sessions") L"/" LPGENW("Info Panel"), LPGENW("Panel background high"), "ipfieldsbgHigh", 0xf0f0f0 },
{ 0, LPGENW("Message sessions") L"/" LPGENW("Common colors"), LPGENW("Toolbar background high"), "tbBgHigh", 0 },
{ 1, LPGENW("Message sessions") L"/" LPGENW("Common colors"), LPGENW("Toolbar background low"), "tbBgLow", 0 },
{ 2, LPGENW("Message sessions") L"/" LPGENW("Common colors"), LPGENW("Window fill color"), "fillColor", 0 },
{ 3, LPGENW("Message sessions") L"/" LPGENW("Common colors"), LPGENW("Text area borders"), "cRichBorders", 0 },
{ 4, LPGENW("Message sessions") L"/" LPGENW("Common colors"), LPGENW("Aero glow effect"), "aeroGlow", RGB(40, 40, 255) },
{ 4, LPGENW("Message sessions") L"/" LPGENW("Common colors"), LPGENW("Generic text color (only when fill color is set)"), "genericTxtClr", 0xff000000 | COLOR_BTNTEXT },
};
static ColorOptionsList _tabclrs[] = {
{ 0, LPGENW("Message sessions") L"/" LPGENW("Tabs"), LPGENW("Normal text"), "tab_txt_normal", 0xff000000 | COLOR_BTNTEXT },
{ 1, LPGENW("Message sessions") L"/" LPGENW("Tabs"), LPGENW("Active text"), "tab_txt_active", 0xff000000 | COLOR_BTNTEXT },
{ 2, LPGENW("Message sessions") L"/" LPGENW("Tabs"), LPGENW("Hovered text"), "tab_txt_hottrack", 0xff000000 | COLOR_HOTLIGHT },
{ 3, LPGENW("Message sessions") L"/" LPGENW("Tabs"), LPGENW("Unread text"), "tab_txt_unread", 0xff000000 | COLOR_HOTLIGHT },
{ 4, LPGENW("Message sessions") L"/" LPGENW("Tabs"), LPGENW("Normal background"), "tab_bg_normal", 0xff000000 | COLOR_3DFACE },
{ 5, LPGENW("Message sessions") L"/" LPGENW("Tabs"), LPGENW("Active background"), "tab_bg_active", 0xff000000 | COLOR_3DFACE },
{ 6, LPGENW("Message sessions") L"/" LPGENW("Tabs"), LPGENW("Hovered background"), "tab_bg_hottrack", 0xff000000 | COLOR_3DFACE },
{ 7, LPGENW("Message sessions") L"/" LPGENW("Tabs"), LPGENW("Unread background"), "tab_bg_unread", 0xff000000 | COLOR_3DFACE }
};
extern LOGFONT lfDefault;
static FontOptionsList IM_fontOptionsList[] =
{
{ LPGENW(">> Outgoing messages"), RGB(50, 50, 50), lfDefault.lfFaceName, DEFAULT_CHARSET, 0, -12 },
{ LPGENW(">> Outgoing misc events"), RGB(50, 50, 50), lfDefault.lfFaceName, DEFAULT_CHARSET, 0, -12 },
{ LPGENW("<< Incoming messages"), RGB(50, 50, 50), lfDefault.lfFaceName, DEFAULT_CHARSET, 0, -12 },
{ LPGENW("<< Incoming misc events"), RGB(50, 50, 50), lfDefault.lfFaceName, DEFAULT_CHARSET, 0, -12 },
{ LPGENW(">> Outgoing name"), RGB(50, 50, 50), lfDefault.lfFaceName, DEFAULT_CHARSET, FONTF_BOLD, -12 },
{ LPGENW(">> Outgoing timestamp"), RGB(50, 50, 50), lfDefault.lfFaceName, DEFAULT_CHARSET, FONTF_BOLD, -12 },
{ LPGENW("<< Incoming name"), RGB(50, 50, 50), lfDefault.lfFaceName, DEFAULT_CHARSET, FONTF_BOLD, -12 },
{ LPGENW("<< Incoming timestamp"), RGB(50, 50, 50), lfDefault.lfFaceName, DEFAULT_CHARSET, FONTF_BOLD, -12 },
{ LPGENW(">> Outgoing messages (old)"), RGB(50, 50, 50), lfDefault.lfFaceName, DEFAULT_CHARSET, 0, -12 },
{ LPGENW(">> Outgoing misc events (old)"), RGB(50, 50, 50), lfDefault.lfFaceName, DEFAULT_CHARSET, 0, -12 },
{ LPGENW("<< Incoming messages (old)"), RGB(50, 50, 50), lfDefault.lfFaceName, DEFAULT_CHARSET, 0, -12 },
{ LPGENW("<< Incoming misc events (old)"), RGB(50, 50, 50), lfDefault.lfFaceName, DEFAULT_CHARSET, 0, -12 },
{ LPGENW(">> Outgoing name (old)"), RGB(50, 50, 50), lfDefault.lfFaceName, DEFAULT_CHARSET, FONTF_BOLD, -12 },
{ LPGENW(">> Outgoing timestamp (old)"), RGB(50, 50, 50), lfDefault.lfFaceName, DEFAULT_CHARSET, FONTF_BOLD, -12 },
{ LPGENW("<< Incoming name (old)"), RGB(50, 50, 50), lfDefault.lfFaceName, DEFAULT_CHARSET, FONTF_BOLD, -12 },
{ LPGENW("<< Incoming timestamp (old)"), RGB(50, 50, 50), lfDefault.lfFaceName, DEFAULT_CHARSET, FONTF_BOLD, -12 },
{ LPGENW("* Message Input Area"), RGB(50, 50, 50), lfDefault.lfFaceName, DEFAULT_CHARSET, 0, -12 },
{ LPGENW("* Status changes"), RGB(50, 50, 50), lfDefault.lfFaceName, DEFAULT_CHARSET, 0, -12 },
{ LPGENW("* Dividers"), RGB(50, 50, 50), lfDefault.lfFaceName, DEFAULT_CHARSET, 0, -12 },
{ LPGENW("* Error and warning messages"), RGB(50, 50, 50), lfDefault.lfFaceName, DEFAULT_CHARSET, 0, -12 },
{ LPGENW("* Symbols (incoming)"), RGB(50, 50, 50), L"Webdings", SYMBOL_CHARSET, 0, -12 },
{ LPGENW("* Symbols (outgoing)"), RGB(50, 50, 50), L"Webdings", SYMBOL_CHARSET, 0, -12 },
};
static FontOptionsList IP_fontOptionsList[] =
{
{ LPGENW("Nickname"), RGB(0, 0, 0), lfDefault.lfFaceName, DEFAULT_CHARSET, 0, -12 },
{ LPGENW("UIN"), RGB(0, 0, 0), lfDefault.lfFaceName, DEFAULT_CHARSET, 0, -12 },
{ LPGENW("Status"), RGB(0, 0, 0), lfDefault.lfFaceName, DEFAULT_CHARSET, 0, -12 },
{ LPGENW("Protocol"), RGB(0, 0, 0), lfDefault.lfFaceName, DEFAULT_CHARSET, 0, -12 },
{ LPGENW("Contacts local time"), RGB(0, 0, 0), lfDefault.lfFaceName, DEFAULT_CHARSET, 0, -12 },
{ LPGENW("Window caption (skinned mode)"), RGB(255, 255, 255), lfDefault.lfFaceName, DEFAULT_CHARSET, 0, -12 },
};
void LoadMsgDlgFont(int section, int i, LOGFONTW *lf, COLORREF* colour)
{
char str[32];
int db_idx = (section == FONTSECTION_IM) ? i : i + 100;
FontOptionsList *fol;
switch (section) {
case FONTSECTION_IM: fol = IM_fontOptionsList; break;
case FONTSECTION_IP: fol = IP_fontOptionsList; break;
default:
return;
}
if (colour) {
mir_snprintf(str, "Font%dCol", db_idx);
*colour = db_get_dw(0, FONTMODULE, str, fol[i].defColour);
}
if (lf) {
mir_snprintf(str, "Font%dSize", db_idx);
lf->lfHeight = (char)db_get_b(0, FONTMODULE, str, fol[i].defSize);
lf->lfWidth = 0;
lf->lfEscapement = 0;
lf->lfOrientation = 0;
mir_snprintf(str, "Font%dSty", db_idx);
int style = db_get_b(0, FONTMODULE, str, fol[i].defStyle);
if (i == MSGFONTID_MESSAGEAREA && section == FONTSECTION_IM && M.GetByte("inputFontFix", 1) == 1) {
lf->lfWeight = FW_NORMAL;
lf->lfItalic = 0;
lf->lfUnderline = 0;
lf->lfStrikeOut = 0;
}
else {
lf->lfWeight = style & FONTF_BOLD ? FW_BOLD : FW_NORMAL;
lf->lfItalic = style & FONTF_ITALIC ? 1 : 0;
lf->lfUnderline = style & FONTF_UNDERLINE ? 1 : 0;
lf->lfStrikeOut = style & FONTF_STRIKEOUT ? 1 : 0;
}
mir_snprintf(str, "Font%dSet", db_idx);
lf->lfCharSet = db_get_b(0, FONTMODULE, str, fol[i].defCharset);
lf->lfOutPrecision = OUT_DEFAULT_PRECIS;
lf->lfClipPrecision = CLIP_DEFAULT_PRECIS;
lf->lfQuality = DEFAULT_QUALITY;
lf->lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE;
mir_snprintf(str, "Font%d", db_idx);
if (i == 20 || i == 21) {
lf->lfCharSet = SYMBOL_CHARSET;
wcsncpy_s(lf->lfFaceName, L"Webdings", _TRUNCATE);
}
else wcsncpy_s(lf->lfFaceName, ptrW(db_get_wsa(0, FONTMODULE, str, fol[i].szDefFace)), _TRUNCATE);
}
}
static IconItem _icons[] =
{
{ LPGEN("Window Icon"), "chat_window", IDI_CHANMGR },
{ LPGEN("Icon overlay"), "chat_overlay", IDI_OVERLAY },
};
static IconItem _logicons[] =
{
{ LPGEN("Message in (10x10)"), "chat_log_message_in", IDI_MESSAGE },
{ LPGEN("Message out (10x10)"), "chat_log_message_out", IDI_MESSAGEOUT },
{ LPGEN("Action (10x10)"), "chat_log_action", IDI_ACTION },
{ LPGEN("Add Status (10x10)"), "chat_log_addstatus", IDI_ADDSTATUS },
{ LPGEN("Remove Status (10x10)"), "chat_log_removestatus", IDI_REMSTATUS },
{ LPGEN("Join (10x10)"), "chat_log_join", IDI_JOIN },
{ LPGEN("Leave (10x10)"), "chat_log_part", IDI_PART },
{ LPGEN("Quit (10x10)"), "chat_log_quit", IDI_QUIT },
{ LPGEN("Kick (10x10)"), "chat_log_kick", IDI_KICK },
{ LPGEN("Notice (10x10)"), "chat_log_notice", IDI_NOTICE },
{ LPGEN("Nick change (10x10)"), "chat_log_nick", IDI_NICK },
{ LPGEN("Topic (10x10)"), "chat_log_topic", IDI_TOPIC },
{ LPGEN("Highlight (10x10)"), "chat_log_highlight", IDI_HIGHLIGHT },
{ LPGEN("Information (10x10)"), "chat_log_info", IDI_INFO }
};
// add icons to the skinning module
void Chat_AddIcons(HINSTANCE hIconDll)
{
Icon_Register(hIconDll, LPGEN("Messaging") "/" LPGEN("Group chat windows"), _icons, _countof(_icons), 0, &g_plugin);
Icon_Register(hIconDll, LPGEN("Messaging") "/" LPGEN("Group chat log"), _logicons, _countof(_logicons), 0, &g_plugin);
g_chatApi.MM_IconsChanged();
}
// get icon by name from the core icon library service
HICON LoadIconEx(char *pszIcoLibName)
{
char szTemp[256];
mir_snprintf(szTemp, "chat_%s", pszIcoLibName);
return IcoLib_GetIcon(szTemp);
}
static wchar_t *chatcolorsnames[] =
{
LPGENW("Voiced"),
LPGENW("Half operators"),
LPGENW("Channel operators"),
LPGENW("Extended mode 1"),
LPGENW("Extended mode 2"),
LPGENW("Selected nick list background"),
LPGENW("Selected nick list text"),
LPGENW("Incremental search highlight")
};
void RegisterFontServiceFonts()
{
LOGFONT lf;
FontIDW fid = {};
ColourIDW cid = {};
strncpy_s(fid.dbSettingsGroup, FONTMODULE, _TRUNCATE);
int i = 0;
for (auto &it : IM_fontOptionsList) {
fid.flags = FIDF_DEFAULTVALID | FIDF_ALLOWEFFECTS;
LoadMsgDlgFont(FONTSECTION_IM, i, &lf, &it.colour);
mir_snprintf(fid.setting, "Font%d", i);
fid.order = i;
wcsncpy_s(fid.name, it.szDescr, _TRUNCATE);
fid.deffontsettings.colour = it.colour;
fid.deffontsettings.size = (char)lf.lfHeight;
fid.deffontsettings.style = (lf.lfWeight >= FW_BOLD ? FONTF_BOLD : 0) | (lf.lfItalic ? FONTF_ITALIC : 0);
fid.deffontsettings.charset = lf.lfCharSet;
fid.flags = fid.flags & ~FIDF_CLASSMASK | (fid.deffontsettings.style & FONTF_BOLD ? FIDF_CLASSHEADER : FIDF_CLASSGENERAL);
wcsncpy_s(fid.deffontsettings.szFace, lf.lfFaceName, _TRUNCATE);
wcsncpy_s(fid.backgroundGroup, LPGENW("Message sessions") L"/" LPGENW("Single Messaging"), _TRUNCATE);
wcsncpy_s(fid.group, LPGENW("Message sessions") L"/" LPGENW("Single Messaging"), _TRUNCATE);
switch (i) {
case MSGFONTID_MYMSG:
case MSGFONTID_MYMISC:
case MSGFONTID_MYNAME:
case MSGFONTID_MYTIME:
case MSGFONTID_SYMBOLS_OUT:
wcsncpy_s(fid.backgroundName, LPGENW("Outgoing background"), _TRUNCATE);
break;
case H_MSGFONTID_MYMSG:
case H_MSGFONTID_MYMISC:
case H_MSGFONTID_MYNAME:
case H_MSGFONTID_MYTIME:
wcsncpy_s(fid.backgroundName, LPGENW("Outgoing background(old)"), _TRUNCATE);
break;
case MSGFONTID_YOURMSG:
case MSGFONTID_YOURMISC:
case MSGFONTID_YOURNAME:
case MSGFONTID_YOURTIME:
case MSGFONTID_SYMBOLS_IN:
wcsncpy_s(fid.backgroundName, LPGENW("Incoming background"), _TRUNCATE);
break;
case H_MSGFONTID_YOURMSG:
case H_MSGFONTID_YOURMISC:
case H_MSGFONTID_YOURNAME:
case H_MSGFONTID_YOURTIME:
wcsncpy_s(fid.backgroundName, LPGENW("Incoming background(old)"), _TRUNCATE);
break;
case MSGFONTID_MESSAGEAREA:
wcsncpy_s(fid.group, LPGENW("Message sessions"), _TRUNCATE);
wcsncpy_s(fid.backgroundGroup, LPGENW("Message sessions"), _TRUNCATE);
wcsncpy_s(fid.backgroundName, LPGENW("Input area background"), _TRUNCATE);
break;
case H_MSGFONTID_STATUSCHANGES:
wcsncpy_s(fid.backgroundName, LPGENW("Status background"), _TRUNCATE);
break;
case H_MSGFONTID_DIVIDERS:
wcsncpy_s(fid.backgroundGroup, LPGENW("Message sessions"), _TRUNCATE);
wcsncpy_s(fid.backgroundName, LPGENW("Log background"), _TRUNCATE);
break;
case MSGFONTID_ERROR:
fid.backgroundName[0] = 0;
break;
}
g_plugin.addFont(&fid);
i++;
}
i = 0;
fid.flags = FIDF_DEFAULTVALID | FIDF_ALLOWEFFECTS;
wcsncpy_s(fid.group, LPGENW("Message sessions") L"/" LPGENW("Info Panel"), _TRUNCATE);
wcsncpy_s(fid.backgroundGroup, LPGENW("Message sessions") L"/" LPGENW("Info Panel"), _TRUNCATE);
wcsncpy_s(fid.backgroundName, LPGENW("Fields background"), _TRUNCATE);
for (auto &it : IP_fontOptionsList) {
LoadMsgDlgFont(FONTSECTION_IP, i, &lf, &it.colour);
mir_snprintf(fid.setting, "Font%d", i+100);
fid.order = i+100;
wcsncpy_s(fid.name, it.szDescr, _TRUNCATE);
fid.deffontsettings.colour = it.colour;
fid.deffontsettings.size = (char)lf.lfHeight;
fid.deffontsettings.style = (lf.lfWeight >= FW_BOLD ? FONTF_BOLD : 0) | (lf.lfItalic ? FONTF_ITALIC : 0);
fid.deffontsettings.charset = lf.lfCharSet;
fid.flags = fid.flags & ~FIDF_CLASSMASK | (fid.deffontsettings.style&FONTF_BOLD ? FIDF_CLASSHEADER : FIDF_CLASSGENERAL);
fid.deffontsettings.charset = lf.lfCharSet;
wcsncpy_s(fid.deffontsettings.szFace, lf.lfFaceName, _TRUNCATE);
if (i == IPFONTCOUNT - 1) {
fid.backgroundGroup[0] = 0;
fid.backgroundName[0] = 0;
wcsncpy_s(fid.group, LPGENW("Message sessions"), _TRUNCATE);
}
g_plugin.addFont(&fid);
i++;
}
wcsncpy_s(cid.group, LPGENW("Message sessions") L"/" LPGENW("Group chats"), _TRUNCATE);
strncpy_s(cid.dbSettingsGroup, CHAT_MODULE, _TRUNCATE);
for (i = 0; i <= 7; i++) {
mir_snprintf(cid.setting, "NickColor%d", i);
wcsncpy_s(cid.name, chatcolorsnames[i], _TRUNCATE);
cid.order = i + 1;
switch (i) {
case 5:
cid.defcolour = GetSysColor(COLOR_HIGHLIGHT);
break;
case 6:
cid.defcolour = GetSysColor(COLOR_HIGHLIGHTTEXT);
break;
default:
cid.defcolour = RGB(0, 0, 0);
break;
}
g_plugin.addColor(&cid);
}
cid.order++;
wcsncpy_s(cid.name, LPGENW("Nick list background"), _TRUNCATE);
strncpy_s(cid.setting, "ColorNicklistBG", _TRUNCATE);
cid.defcolour = SRMSGDEFSET_BKGCOLOUR;
g_plugin.addColor(&cid);
cid.order++;
wcsncpy_s(cid.name, LPGENW("Group chat log background"), _TRUNCATE);
strncpy_s(cid.setting, "ColorLogBG", _TRUNCATE);
g_plugin.addColor(&cid);
// static colors (info panel, tool bar background etc...)
strncpy_s(fid.dbSettingsGroup, FONTMODULE, _TRUNCATE);
strncpy_s(cid.dbSettingsGroup, FONTMODULE, _TRUNCATE);
for (auto &it : _clrs) {
cid.order = it.order;
wcsncpy_s(cid.group, it.tszGroup, _TRUNCATE);
wcsncpy_s(cid.name, it.tszName, _TRUNCATE);
strncpy_s(cid.setting, it.szSetting, _TRUNCATE);
if (it.def & 0xff000000)
cid.defcolour = GetSysColor(it.def & 0x000000ff);
else
cid.defcolour = it.def;
g_plugin.addColor(&cid);
}
strncpy_s(cid.dbSettingsGroup, SRMSGMOD_T, _TRUNCATE);
// text and background colors for tabs
for (auto &it : _tabclrs) {
cid.order = it.order;
wcsncpy_s(cid.group, it.tszGroup, _TRUNCATE);
wcsncpy_s(cid.name, it.tszName, _TRUNCATE);
strncpy_s(cid.setting, it.szSetting, _TRUNCATE);
if (it.def & 0xff000000)
cid.defcolour = GetSysColor(it.def & 0x000000ff);
else
cid.defcolour = it.def;
g_plugin.addColor(&cid);
}
}
int FontServiceFontsChanged(WPARAM, LPARAM)
{
g_chatApi.ReloadSettings();
g_chatApi.MM_IconsChanged();
PluginConfig.reloadSettings();
CSkin::initAeroEffect();
CacheMsgLogIcons();
CacheLogFonts();
FreeTabConfig();
ReloadTabConfig();
Skin->setupAeroSkins();
Srmm_ApplyOptions();
return 0;
}
/////////////////////////////////////////////////////////////////////////////////////////
static INT CALLBACK BrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM lp, LPARAM)
{
char szDir[MAX_PATH];
switch (uMsg) {
case BFFM_INITIALIZED:
SendMessage(hwnd, BFFM_SETSELECTION, TRUE, (LPARAM)M.getUserDir());
break;
case BFFM_SELCHANGED:
if (SHGetPathFromIDListA((LPITEMIDLIST)lp, szDir))
SendMessage(hwnd, BFFM_SETSTATUSTEXT, 0, (LPARAM)szDir);
break;
}
return 0;
}
static HWND CreateToolTip(HWND hwndParent, LPCWSTR ptszText, LPCTSTR ptszTitle)
{
HWND hwndTT = CreateWindowEx(WS_EX_TOPMOST,
TOOLTIPS_CLASS, nullptr,
WS_POPUP | TTS_NOPREFIX,
CW_USEDEFAULT, CW_USEDEFAULT,
CW_USEDEFAULT, CW_USEDEFAULT,
hwndParent, nullptr, g_plugin.getInst(), nullptr);
SetWindowPos(hwndTT, HWND_TOPMOST, 0, 0, 0, 0,
SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
TOOLINFO ti = { 0 };
ti.cbSize = sizeof(TOOLINFO);
ti.uFlags = TTF_SUBCLASS | TTF_CENTERTIP;
ti.hwnd = hwndParent;
ti.hinst = g_plugin.getInst();
ti.lpszText = (LPWSTR)ptszText;
GetClientRect(hwndParent, &ti.rect);
ti.rect.left = -65;
SendMessage(hwndTT, TTM_ADDTOOL, 0, (LPARAM)&ti);
SendMessage(hwndTT, TTM_SETTITLE, 1, (LPARAM)ptszTitle);
SendMessage(hwndTT, TTM_SETMAXTIPWIDTH, 0, (LPARAM)640);
return hwndTT;
}
/////////////////////////////////////////////////////////////////////////////////////////
// base class for chat options
class CChatBaseOptionDlg : public CDlgBase
{
protected:
CChatBaseOptionDlg(int iDlg) :
CDlgBase(g_plugin, iDlg)
{
m_OnFinishWizard = Callback(this, &CChatBaseOptionDlg::onFinalOptions);
}
void onFinalOptions(void*)
{
g_chatApi.ReloadSettings();
g_chatApi.MM_IconsChanged();
Chat_UpdateOptions();
Chat_ReconfigureFilters();
PluginConfig.reloadSettings();
CacheMsgLogIcons();
CacheLogFonts();
}
};
/////////////////////////////////////////////////////////////////////////////////////////
// Group chat - Settings
class CChatSettingsDlg : public CChatBaseOptionDlg
{
HTREEITEM hListHeading1 = nullptr;
HTREEITEM hListHeading2 = nullptr;
CCtrlTreeOpts treeCheck;
CCtrlEdit edtGroup, edtAutocomplete;
public:
CChatSettingsDlg() :
CChatBaseOptionDlg(IDD_OPTIONS1),
edtGroup(this, IDC_GROUP),
edtAutocomplete(this, IDC_AUTOCOMPLETE),
treeCheck(this, IDC_CHECKBOXES)
{
auto *pwszSection = LPGENW("Appearance and functionality of chat room windows");
treeCheck.AddOption(pwszSection, LPGENW("Open new chat rooms in the default container"), g_plugin.bOpenInDefault);
treeCheck.AddOption(pwszSection, LPGENW("Flash window when someone speaks"), Chat::bFlashWindow);
treeCheck.AddOption(pwszSection, LPGENW("Flash window when a word is highlighted"), Chat::bFlashWindowHighlight);
treeCheck.AddOption(pwszSection, LPGENW("Create tabs or windows for highlight events"), g_plugin.bCreateWindowOnHighlight);
treeCheck.AddOption(pwszSection, LPGENW("Activate chat window on highlight"), g_plugin.bAnnoyingHighlight);
treeCheck.AddOption(pwszSection, LPGENW("Show list of users in the chat room"), Chat::bShowNicklist);
treeCheck.AddOption(pwszSection, LPGENW("Colorize nicknames in member list (you need to adjust colors)"), g_plugin.bColorizeNicks);
treeCheck.AddOption(pwszSection, LPGENW("Show topic as status message on the contact list"), Chat::bTopicOnClist);
treeCheck.AddOption(pwszSection, LPGENW("Do not pop up the window when joining a chat room"), Chat::bPopupOnJoin);
treeCheck.AddOption(pwszSection, LPGENW("Show contact's status modes if supported by the protocol"), Chat::bShowContactStatus);
treeCheck.AddOption(pwszSection, LPGENW("Display contact's status icon before user role icon"), Chat::bContactStatusFirst);
treeCheck.AddOption(pwszSection, LPGENW("Use IRC style status indicators in the nick list"), g_plugin.bClassicIndicators);
treeCheck.AddOption(pwszSection, LPGENW("Use alternative sorting method in member list"), g_plugin.bAlternativeSorting);
pwszSection = LPGENW("Appearance of the message log");
treeCheck.AddOption(pwszSection, LPGENW("Prefix all events with a timestamp"), Chat::bShowTime);
treeCheck.AddOption(pwszSection, LPGENW("Only prefix with timestamp if it has changed"), Chat::bShowTimeIfChanged);
treeCheck.AddOption(pwszSection, LPGENW("Timestamp has same color as the event"), Chat::bTimeStampEventColour);
treeCheck.AddOption(pwszSection, LPGENW("Indent the second line of a message"), Chat::bLogIndentEnabled);
treeCheck.AddOption(pwszSection, LPGENW("Limit user names in the message log to 20 characters"), Chat::bLogLimitNames);
treeCheck.AddOption(pwszSection, LPGENW("Start private conversation on double click in nick list (insert nick if unchecked)"), Chat::bDoubleClick4Privat);
treeCheck.AddOption(pwszSection, LPGENW("Strip colors from messages in the log"), Chat::bStripFormat);
treeCheck.AddOption(pwszSection, LPGENW("Enable the 'event filter' for new rooms"), Chat::bFilterEnabled);
treeCheck.AddOption(pwszSection, LPGENW("Use IRC style status indicators in the log"), g_plugin.bLogClassicIndicators);
treeCheck.AddOption(pwszSection, LPGENW("Allow clickable user names in the message log"), g_plugin.bClickableNicks);
treeCheck.AddOption(pwszSection, LPGENW("Add new line after names"), g_plugin.bNewLineAfterNames);
treeCheck.AddOption(pwszSection, LPGENW("Colorize user names in message log"), g_plugin.bColorizeNicksInLog);
treeCheck.AddOption(pwszSection, LPGENW("Scale down icons to 10x10 pixels in the chat log"), g_plugin.bScaleIcons);
}
bool OnInitDialog() override
{
SetWindowLongPtr(treeCheck.GetHwnd(), GWL_STYLE, GetWindowLongPtr(treeCheck.GetHwnd(), GWL_STYLE) | TVS_NOHSCROLL);
if (mir_wstrlen(g_Settings.pwszAutoText))
edtAutocomplete.SetText(g_Settings.pwszAutoText);
edtGroup.SetText(ptrW(Chat_GetGroup()));
return true;
}
bool OnApply() override
{
Chat_SetGroup(ptrW(edtGroup.GetText()));
replaceStrW(g_Settings.pwszAutoText, edtAutocomplete.GetText());
db_set_ws(0, CHAT_MODULE, "TextAutocomplete", g_Settings.pwszAutoText);
return true;
}
void OnDestroy() override
{
uint8_t b = treeCheck.GetItemState(hListHeading1, TVIS_EXPANDED) & TVIS_EXPANDED ? 1 : 0;
db_set_b(0, CHAT_MODULE, "Branch1Exp", b);
b = treeCheck.GetItemState(hListHeading2, TVIS_EXPANDED) & TVIS_EXPANDED ? 1 : 0;
db_set_b(0, CHAT_MODULE, "Branch2Exp", b);
}
};
/////////////////////////////////////////////////////////////////////////////////////////
// Group chat - Log
class CChatLogOptionDlg : public CChatBaseOptionDlg
{
CTimer m_timer;
CCtrlButton btnBaseDir, btnFontChoose;
CCtrlCheck chkLogging;
CCtrlCombo cmbIconType;
HWND hPathTip = nullptr;
public:
CChatLogOptionDlg() :
CChatBaseOptionDlg(Srmm_IsCustomLogUsed(true) ? IDD_OPTIONS3 : IDD_OPTIONS2),
m_timer(this, 1),
btnBaseDir(this, IDC_MUC_OPENLOGBASEDIR),
chkLogging(this, IDC_LOGGING),
btnFontChoose(this, IDC_FONTCHOOSE),
cmbIconType(this, IDC_LOGICONTYPE)
{
btnBaseDir.OnClick = Callback(this, &CChatLogOptionDlg::onClick_BaseDir);
btnFontChoose.OnClick = Callback(this, &CChatLogOptionDlg::onClick_FontChoose);
chkLogging.OnChange = Callback(this, &CChatLogOptionDlg::onChange_Logging);
m_timer.OnEvent = Callback(this, &CChatLogOptionDlg::onTimer);
}
bool OnInitDialog() override
{
SendDlgItemMessage(m_hwnd, IDC_CHAT_SPIN2, UDM_SETRANGE, 0, MAKELONG(5000, 0));
SendDlgItemMessage(m_hwnd, IDC_CHAT_SPIN2, UDM_SETPOS, 0, MAKELONG(db_get_w(0, CHAT_MODULE, "LogLimit", 100), 0));
SendDlgItemMessage(m_hwnd, IDC_CHAT_SPIN3, UDM_SETRANGE, 0, MAKELONG(255, 10));
SendDlgItemMessage(m_hwnd, IDC_CHAT_SPIN3, UDM_SETPOS, 0, MAKELONG(db_get_b(0, CHAT_MODULE, "NicklistRowDist", 12), 0));
SetDlgItemText(m_hwnd, IDC_LOGTIMESTAMP, g_Settings.pszTimeStampLog);
SetDlgItemText(m_hwnd, IDC_TIMESTAMP, g_Settings.pszTimeStamp);
SetDlgItemText(m_hwnd, IDC_OUTSTAMP, g_Settings.pszOutgoingNick);
SetDlgItemText(m_hwnd, IDC_INSTAMP, g_Settings.pszIncomingNick);
CheckDlgButton(m_hwnd, IDC_LOGGING, g_Settings.bLoggingEnabled ? BST_CHECKED : BST_UNCHECKED);
SetDlgItemText(m_hwnd, IDC_LOGDIRECTORY, g_Settings.pszLogDir);
Utils::enableDlgControl(m_hwnd, IDC_LOGDIRECTORY, g_Settings.bLoggingEnabled);
Utils::enableDlgControl(m_hwnd, IDC_FONTCHOOSE, g_Settings.bLoggingEnabled);
SendDlgItemMessage(m_hwnd, IDC_CHAT_SPIN4, UDM_SETRANGE, 0, MAKELONG(10000, 0));
SendDlgItemMessage(m_hwnd, IDC_CHAT_SPIN4, UDM_SETPOS, 0, MAKELONG(db_get_w(0, CHAT_MODULE, "LoggingLimit", 100), 0));
Utils::enableDlgControl(m_hwnd, IDC_LIMIT, g_Settings.bLoggingEnabled);
cmbIconType.AddString(TranslateT("No markers"));
cmbIconType.AddString(TranslateT("Show as icons"));
cmbIconType.AddString(TranslateT("Show as text symbols"));
cmbIconType.SetCurSel((g_Settings.bLogSymbols ? 2 : (g_Settings.dwIconFlags ? 1 : 0)));
CMStringW tszTooltipText(FORMAT,
L"%s - %s\n%s - %s\n%s - %s\n%s - %s\n\n"
L"%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n\n"
L"%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s",
// contact vars
L"%nick%", TranslateT("nick of current contact (if defined)"),
L"%proto%", TranslateT("protocol name of current contact (if defined). Account name is used when protocol supports multiple accounts"),
L"%accountname%", TranslateT("user-defined account name of current contact (if defined)."),
L"%userid%", TranslateT("user ID of current contact (if defined). It is like UIN for ICQ, JID for Jabber, etc."),
// global vars
L"%miranda_path%", TranslateT("path to Miranda root folder"),
L"%miranda_profilesdir%", TranslateT("path to folder containing Miranda profiles"),
L"%miranda_profilename%", TranslateT("name of current Miranda profile (filename, without extension)"),
L"%miranda_userdata%", TranslateT("will return parsed string %miranda_profilesdir%\\%miranda_profilename%"),
L"%miranda_logpath%", TranslateT("will return parsed string %miranda_userdata%\\Logs"),
L"%appdata%", TranslateT("same as environment variable %APPDATA% for currently logged-on Windows user"),
L"%username%", TranslateT("username for currently logged-on Windows user"),
L"%mydocuments%", TranslateT("\"My Documents\" folder for currently logged-on Windows user"),
L"%desktop%", TranslateT("\"Desktop\" folder for currently logged-on Windows user"),
L"%xxxxxxx%", TranslateT("any environment variable defined in current Windows session (like %systemroot%, %allusersprofile%, etc.)"),
// date/time vars
L"%d%", TranslateT("day of month, 1-31"),
L"%dd%", TranslateT("day of month, 01-31"),
L"%m%", TranslateT("month number, 1-12"),
L"%mm%", TranslateT("month number, 01-12"),
L"%mon%", TranslateT("abbreviated month name"),
L"%month%", TranslateT("full month name"),
L"%yy%", TranslateT("year without century, 01-99"),
L"%yyyy%", TranslateT("year with century, 1901-9999"),
L"%wday%", TranslateT("abbreviated weekday name"),
L"%weekday%", TranslateT("full weekday name"));
hPathTip = CreateToolTip(GetDlgItem(m_hwnd, IDC_LOGDIRECTORY), tszTooltipText, TranslateT("Variables"));
if (hPathTip)
m_timer.Start(3000);
return true;
}
bool OnApply() override
{
char *pszText = nullptr;
int iLen = GetWindowTextLength(GetDlgItem(m_hwnd, IDC_LOGDIRECTORY));
if (iLen > 0) {
wchar_t *pszText1 = (wchar_t*)mir_alloc(iLen * sizeof(wchar_t) + 2);
GetDlgItemText(m_hwnd, IDC_LOGDIRECTORY, pszText1, iLen + 1);
db_set_ws(0, CHAT_MODULE, "LogDirectory", pszText1);
mir_free(pszText1);
g_Settings.bLoggingEnabled = IsDlgButtonChecked(m_hwnd, IDC_LOGGING) == BST_CHECKED;
db_set_b(0, CHAT_MODULE, "LoggingEnabled", g_Settings.bLoggingEnabled);
}
else {
db_unset(0, CHAT_MODULE, "LogDirectory");
db_set_b(0, CHAT_MODULE, "LoggingEnabled", 0);
}
g_chatApi.SM_InvalidateLogDirectories();
iLen = SendDlgItemMessage(m_hwnd, IDC_CHAT_SPIN4, UDM_GETPOS, 0, 0);
db_set_w(0, CHAT_MODULE, "LoggingLimit", (uint16_t)iLen);
iLen = SendDlgItemMessage(m_hwnd, IDC_CHAT_SPIN3, UDM_GETPOS, 0, 0);
if (iLen > 0)
db_set_b(0, CHAT_MODULE, "NicklistRowDist", (uint8_t)iLen);
else
db_unset(0, CHAT_MODULE, "NicklistRowDist");
iLen = GetWindowTextLength(GetDlgItem(m_hwnd, IDC_LOGTIMESTAMP));
if (iLen > 0) {
pszText = (char *)mir_realloc(pszText, iLen + 1);
GetDlgItemTextA(m_hwnd, IDC_LOGTIMESTAMP, pszText, iLen + 1);
db_set_s(0, CHAT_MODULE, "LogTimestamp", pszText);
}
else db_unset(0, CHAT_MODULE, "LogTimestamp");
iLen = GetWindowTextLength(GetDlgItem(m_hwnd, IDC_TIMESTAMP));
if (iLen > 0) {
pszText = (char *)mir_realloc(pszText, iLen + 1);
GetDlgItemTextA(m_hwnd, IDC_TIMESTAMP, pszText, iLen + 1);
db_set_s(0, CHAT_MODULE, "HeaderTime", pszText);
}
else db_unset(0, CHAT_MODULE, "HeaderTime");
iLen = GetWindowTextLength(GetDlgItem(m_hwnd, IDC_INSTAMP));
if (iLen > 0) {
pszText = (char *)mir_realloc(pszText, iLen + 1);
GetDlgItemTextA(m_hwnd, IDC_INSTAMP, pszText, iLen + 1);
db_set_s(0, CHAT_MODULE, "HeaderIncoming", pszText);
}
else db_unset(0, CHAT_MODULE, "HeaderIncoming");
iLen = GetWindowTextLength(GetDlgItem(m_hwnd, IDC_OUTSTAMP));
if (iLen > 0) {
pszText = (char *)mir_realloc(pszText, iLen + 1);
GetDlgItemTextA(m_hwnd, IDC_OUTSTAMP, pszText, iLen + 1);
db_set_s(0, CHAT_MODULE, "HeaderOutgoing", pszText);
}
else db_unset(0, CHAT_MODULE, "HeaderOutgoing");
LRESULT lr = cmbIconType.GetCurSel();
db_set_dw(0, CHAT_MODULE, "IconFlags", lr == 1);
db_set_b(0, CHAT_MODULE, "LogSymbols", lr == 2);
iLen = SendDlgItemMessage(m_hwnd, IDC_CHAT_SPIN2, UDM_GETPOS, 0, 0);
db_set_w(0, CHAT_MODULE, "LogLimit", (uint16_t)iLen);
mir_free(pszText);
if (g_chatApi.hListBkgBrush)
DeleteObject(g_chatApi.hListBkgBrush);
g_chatApi.hListBkgBrush = CreateSolidBrush(db_get_dw(0, CHAT_MODULE, "ColorNicklistBG", SRMSGDEFSET_BKGCOLOUR));
return true;
}
void OnDestroy() override
{
if (hPathTip) {
KillTimer(m_hwnd, 0);
DestroyWindow(hPathTip);
hPathTip = nullptr;
}
}
// open the base directory for MUC logs, using a standard file selector
// dialog. Simply allows the user to view what log files are there
// and possibly delete archived logs.
void onClick_BaseDir(CCtrlButton*)
{
wchar_t tszTemp[MAX_PATH + 20];
wcsncpy_s(tszTemp, g_Settings.pszLogDir, _TRUNCATE);
wchar_t *p = tszTemp;
while (*p && (*p == '\\' || *p == '.'))
p++;
if (*p)
if (wchar_t *p1 = wcschr(p, '\\'))
*p1 = 0;
wchar_t tszInitialDir[_MAX_DRIVE + _MAX_PATH + 10];
mir_snwprintf(tszInitialDir, L"%s%s", M.getChatLogPath(), p);
if (!PathFileExists(tszInitialDir))
wcsncpy_s(tszInitialDir, M.getChatLogPath(), _TRUNCATE);
wchar_t tszReturnName[MAX_PATH]; tszReturnName[0] = 0;
mir_snwprintf(tszTemp, L"%s%c*.*%c%c", TranslateT("All files"), 0, 0, 0);
OPENFILENAME ofn = { 0 };
ofn.lpstrInitialDir = tszInitialDir;
ofn.lpstrFilter = tszTemp;
ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400;
ofn.lpstrFile = tszReturnName;
ofn.nMaxFile = MAX_PATH;
ofn.nMaxFileTitle = MAX_PATH;
ofn.Flags = OFN_HIDEREADONLY | OFN_DONTADDTORECENT;
ofn.lpstrDefExt = L"log";
GetOpenFileName(&ofn);
}
void onClick_FontChoose(CCtrlButton*)
{
wchar_t tszDirectory[MAX_PATH];
LPMALLOC psMalloc;
if (FAILED(CoGetMalloc(1, &psMalloc)))
return;
BROWSEINFO bi = {};
bi.hwndOwner = m_hwnd;
bi.pszDisplayName = tszDirectory;
bi.lpszTitle = TranslateT("Select folder");
bi.ulFlags = BIF_NEWDIALOGSTYLE | BIF_EDITBOX | BIF_RETURNONLYFSDIRS;
bi.lpfn = BrowseCallbackProc;
bi.lParam = (LPARAM)tszDirectory;
LPITEMIDLIST idList = SHBrowseForFolder(&bi);
if (idList) {
const wchar_t *szUserDir = M.getUserDir();
SHGetPathFromIDList(idList, tszDirectory);
mir_wstrcat(tszDirectory, L"\\");
wchar_t tszTemp[MAX_PATH];
PathToRelativeW(tszDirectory, tszTemp, szUserDir);
SetDlgItemText(m_hwnd, IDC_LOGDIRECTORY, mir_wstrlen(tszTemp) > 1 ? tszTemp : DEFLOGFILENAME);
}
psMalloc->Free(idList);
psMalloc->Release();
}
void onChange_Logging(CCtrlCheck*)
{
bool bChecked = chkLogging.GetState();
Utils::enableDlgControl(m_hwnd, IDC_LOGDIRECTORY, bChecked);
Utils::enableDlgControl(m_hwnd, IDC_FONTCHOOSE, bChecked);
Utils::enableDlgControl(m_hwnd, IDC_LIMIT, bChecked);
}
void onTimer(CTimer*)
{
if (IsWindow(hPathTip))
KillTimer(hPathTip, 4); // It will prevent tooltip autoclosing
}
};
/////////////////////////////////////////////////////////////////////////////////////////
// Group chat - Highlight
class CHighlighOptionDlg : public CChatBaseOptionDlg
{
CCtrlEdit edtNick, edtText;
CCtrlCheck chkNick, chkText;
public:
CHighlighOptionDlg() :
CChatBaseOptionDlg(IDD_OPTIONS4),
edtNick(this, IDC_HIGHLIGHTNICKPATTERN),
edtText(this, IDC_HIGHLIGHTTEXTPATTERN),
chkNick(this, IDC_HIGHLIGHTNICKENABLE),
chkText(this, IDC_HIGHLIGHTTEXTENABLE)
{
chkNick.OnChange = Callback(this, &CHighlighOptionDlg::onChange_Nick);
chkText.OnChange = Callback(this, &CHighlighOptionDlg::onChange_Text);
}
bool OnInitDialog() override
{
ptrW wszText(db_get_wsa(0, CHAT_MODULE, "HighlightWords"));
if (wszText)
edtText.SetText(wszText);
wszText = db_get_wsa(0, CHAT_MODULE, "HighlightNames");
if (wszText)
edtNick.SetText(wszText);
uint32_t dwFlags = db_get_b(0, CHAT_MODULE, "HighlightEnabled", CMUCHighlight::MATCH_TEXT);
chkNick.SetState(dwFlags & CMUCHighlight::MATCH_NICKNAME); onChange_Nick(0);
chkText.SetState(dwFlags & CMUCHighlight::MATCH_TEXT); onChange_Text(0);
::CheckDlgButton(m_hwnd, IDC_HIGHLIGHTNICKUID, dwFlags & CMUCHighlight::MATCH_UIN ? BST_CHECKED : BST_UNCHECKED);
::CheckDlgButton(m_hwnd, IDC_HIGHLIGHTME, db_get_b(0, CHAT_MODULE, "HighlightMe", 1) ? BST_CHECKED : BST_UNCHECKED);
return true;
}
void onChange_Text(CCtrlCheck*)
{
bool bChecked = chkText.GetState();
edtText.Enable(bChecked);
Utils::enableDlgControl(m_hwnd, IDC_HIGHLIGHTME, bChecked);
}
void onChange_Nick(CCtrlCheck*)
{
bool bChecked = chkNick.GetState();
edtNick.Enable(bChecked);
Utils::enableDlgControl(m_hwnd, IDC_HIGHLIGHTNICKUID, chkNick.GetState());
}
bool OnApply() override
{
db_set_ws(0, CHAT_MODULE, "HighlightNames", ptrW(edtNick.GetText()));
db_set_ws(0, CHAT_MODULE, "HighlightWords", ptrW(edtText.GetText()));
uint8_t dwFlags = (chkNick.GetState() ? CMUCHighlight::MATCH_NICKNAME : 0) | (chkText.GetState() ? CMUCHighlight::MATCH_TEXT : 0);
if (dwFlags & CMUCHighlight::MATCH_NICKNAME)
dwFlags |= (::IsDlgButtonChecked(m_hwnd, IDC_HIGHLIGHTNICKUID) ? CMUCHighlight::MATCH_UIN : 0);
db_set_b(0, CHAT_MODULE, "HighlightEnabled", dwFlags);
db_set_b(0, CHAT_MODULE, "HighlightMe", ::IsDlgButtonChecked(m_hwnd, IDC_HIGHLIGHTME) ? 1 : 0);
g_Settings.Highlight->init();
return true;
}
};
/////////////////////////////////////////////////////////////////////////////////////////
void Chat_Options(WPARAM wParam)
{
OPTIONSDIALOGPAGE odp = {};
odp.flags = ODPF_BOLDGROUPS;
odp.position = 910000000;
odp.szGroup.a = LPGEN("Message sessions");
odp.szTitle.a = LPGEN("Group chats");
odp.szTab.a = LPGEN("Settings");
odp.pDialog = new CChatSettingsDlg();
g_plugin.addOptions(wParam, &odp);
odp.szTab.a = LPGEN("Log formatting");
odp.pDialog = new CChatLogOptionDlg();
g_plugin.addOptions(wParam, &odp);
odp.szTab.a = LPGEN("Highlighting");
odp.pDialog = new CHighlighOptionDlg();
g_plugin.addOptions(wParam, &odp);
}
|