-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathtoolbar_button_defs.cpp
More file actions
1532 lines (1414 loc) · 58.4 KB
/
Copy pathtoolbar_button_defs.cpp
File metadata and controls
1532 lines (1414 loc) · 58.4 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
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
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// SPDX-FileCopyrightText: 2023 Taskscape Ltd
// SPDX-License-Identifier: GPL-2.0-or-later
#include "precomp.h"
#include "bitmap.h"
#include "toolbar.h"
#include "mainwnd.h"
//#include "usermenu.h"
#include "cfgdlg.h"
#include "plugins.h"
#include "fileswnd.h"
#include <strsafe.h>
#include "nanosvg\nanosvg.h"
#include "nanosvg\nanosvgrast.h"
#include "svg.h"
struct CButtonData
{
unsigned int ImageIndex : 16; // zero base index
unsigned int Shell32ResID : 8; // 0: icon from image list; 1..254: icon resID from shell32.dll; 255: only allocate free space
unsigned int ToolTipResID : 16; // resource ID of the tooltip string
unsigned int ID : 16; // universal command
unsigned int LeftID : 16; // command for the left panel
unsigned int RightID : 16; // command for the right panel
unsigned int DropDown : 1; // will it have drop down?
unsigned int WholeDropDown : 1; // will it have whole drop down?
unsigned int Check : 1; // is this a checkbox?
DWORD* Enabler; // control variable for enabling the button
DWORD* LeftEnabler; // control variable for enabling the button
DWORD* RightEnabler; // control variable for enabling the button
const char* SVGName; // NULL if the button has no SVG representation
};
//****************************************************************************
//
// TBButtonEnum
//
// Unique indexes into the ToolBarButton array, used to address its entries.
// Items may only be appended to the end of this array.
//
#define TBBE_CONNECT_NET 0
#define TBBE_DISCONNECT_NET 1
#define TBBE_CREATE_DIR 2
#define TBBE_FIND_FILE 3
#define TBBE_VIEW_MODE 4 // drive brief
//#define TBBE_DETAILED 5 // removed
#define TBBE_SORT_NAME 6
#define TBBE_SORT_EXT 7
#define TBBE_SORT_SIZE 8
#define TBBE_SORT_DATE 9
//#define TBBE_SORT_ATTR 10 // removed
#define TBBE_PARENT_DIR 11
#define TBBE_ROOT_DIR 12
#define TBBE_FILTER 13
#define TBBE_BACK 14
#define TBBE_FORWARD 15
#define TBBE_REFRESH 16
#define TBBE_SWAP_PANELS 17
#define TBBE_PROPERTIES 18
#define TBBE_USER_MENU_DROP 19
#define TBBE_CMD 20
#define TBBE_COPY 21
#define TBBE_MOVE 22
#define TBBE_DELETE 23
#define TBBE_COMPRESS 24
#define TBBE_UNCOMPRESS 25
#define TBBE_QUICK_RENAME 26
#define TBBE_CHANGE_CASE 27
#define TBBE_VIEW 28
#define TBBE_EDIT 29
#define TBBE_CLIPBOARD_CUT 30
#define TBBE_CLIPBOARD_COPY 31
#define TBBE_CLIPBOARD_PASTE 32
#define TBBE_CHANGE_ATTR 33
#define TBBE_COMPARE_DIR 34
#define TBBE_DRIVE_INFO 35
#define TBBE_CHANGE_DRIVE_L 36
#define TBBE_SELECT 37
#define TBBE_UNSELECT 38
#define TBBE_INVERT_SEL 39
#define TBBE_SELECT_ALL 40
#define TBBE_PACK 41
#define TBBE_UNPACK 42
#define TBBE_OPEN_ACTIVE 43
#define TBBE_OPEN_DESKTOP 44
#define TBBE_OPEN_MYCOMP 45
#define TBBE_OPEN_CONTROL 46
#define TBBE_OPEN_PRINTERS 47
#define TBBE_OPEN_NETWORK 48
#define TBBE_OPEN_RECYCLE 49
#define TBBE_OPEN_FONTS 50
#define TBBE_CHANGE_DRIVE_R 51
#define TBBE_HELP_CONTENTS 52
#define TBBE_HELP_CONTEXT 53
#define TBBE_PERMISSIONS 54
#define TBBE_CONVERT 55
#define TBBE_UNSELECT_ALL 56
#define TBBE_MENU 57 // menu entry
#define TBBE_ALTVIEW 58
#define TBBE_EXIT 59
#define TBBE_OCCUPIEDSPACE 60
#define TBBE_EDITNEW 61
#define TBBE_CHANGEDIR 62
#define TBBE_HOTPATHS 63
#define TBBE_CONTEXTMENU 64
#define TBBE_VIEWWITH 65
#define TBBE_EDITWITH 66
#define TBBE_CALCDIRSIZES 67
#define TBBE_FILEHISTORY 68
#define TBBE_DIRHISTORY 69
#define TBBE_HOTPATHSDROP 70
#define TBBE_USER_MENU 71
#define TBBE_EMAIL 72
#define TBBE_ZOOM_PANEL 73
#define TBBE_SHARES 74
#define TBBE_FULLSCREEN 75
#define TBBE_PREV_SELECTED 76
#define TBBE_NEXT_SELECTED 77
#define TBBE_RESELECT 78
#define TBBE_PASTESHORTCUT 79
#define TBBE_FOCUSSHORTCUT 80
#define TBBE_SAVESELECTION 81
#define TBBE_LOADSELECTION 82
#define TBBE_NEW 83
#define TBBE_SEL_BY_EXT 84
#define TBBE_UNSEL_BY_EXT 85
#define TBBE_SEL_BY_NAME 86
#define TBBE_UNSEL_BY_NAME 87
#define TBBE_OPEN_FOLDER 88
#define TBBE_CONFIGRATION 89
#define TBBE_DIRMENU 90
#define TBBE_OPEN_IN_OTHER_ACT 91
#define TBBE_OPEN_IN_OTHER 92
#define TBBE_AS_OTHER_PANEL 93
#define TBBE_HIDE_SELECTED 94
#define TBBE_HIDE_UNSELECTED 95
#define TBBE_SHOW_ALL 96
#define TBBE_OPEN_MYDOC 97
#define TBBE_SMART_COLUMN_MODE 98
#define TBBE_TERMINATOR 99 // terminator
#define NIB1(x) x
#define NIB2(x) x,
#define NIB3(x) x
CButtonData ToolBarButtons[TBBE_TERMINATOR] =
{
// ImageIndex Shell32ResID ToolTipResID ID LeftID RightID DropDown WD Chk Enabler LeftEnabler RightEnabler SVGName
/*TBBE_CONNECT_NET*/ {NIB1(IDX_TB_CONNECTNET), 0, IDS_TBTT_CONNECTNET, CM_CONNECTNET, 0, 0, 0, 0, 0, NULL, NULL, NULL, "ConnectNetworkDrive"},
/*TBBE_DISCONNECT_NET*/ {IDX_TB_DISCONNECTNET, 0, IDS_TBTT_DISCONNECTNET, CM_DISCONNECTNET, 0, 0, 0, 0, 0, NULL, NULL, NULL, "Disconnect"},
/*TBBE_CREATE_DIR*/ {IDX_TB_CREATEDIR, 0, IDS_TBTT_CREATEDIR, CM_CREATEDIR, 0, 0, 0, 0, 0, &EnablerCreateDir, NULL, NULL, "CreateDirectory"},
/*TBBE_FIND_FILE*/ {IDX_TB_FINDFILE, 0, IDS_TBTT_FINDFILE, CM_FINDFILE, 0, 0, 0, 0, 0, NULL, NULL, NULL, "FindFilesAndDirectories"},
/*TBBE_VIEW_MODE*/ {IDX_TB_VIEW_MODE, 0, IDS_TBTT_VIEW_MODE, CM_ACTIVEVIEWMODE, CM_LEFTVIEWMODE, CM_RIGHTVIEWMODE, 0, 1, 0, NULL, NULL, NULL, "Views"},
/*TBBE_DETAILED*/ {0xFFFF, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL},
/*TBBE_SORT_NAME*/ {IDX_TB_SORTBYNAME, 0, IDS_TBTT_SORTBYNAME, CM_ACTIVENAME, CM_LEFTNAME, CM_RIGHTNAME, 0, 0, 1, NULL, NULL, NULL, "SortByName"},
/*TBBE_SORT_EXT*/ {IDX_TB_SORTBYEXT, 0, IDS_TBTT_SORTBYEXT, CM_ACTIVEEXT, CM_LEFTEXT, CM_RIGHTEXT, 0, 0, 1, NULL, NULL, NULL, "SortByExtension"},
/*TBBE_SORT_SIZE*/ {IDX_TB_SORTBYSIZE, 0, IDS_TBTT_SORTBYSIZE, CM_ACTIVESIZE, CM_LEFTSIZE, CM_RIGHTSIZE, 0, 0, 1, NULL, NULL, NULL, "SortBySize"},
/*TBBE_SORT_DATE*/ {IDX_TB_SORTBYDATE, 0, IDS_TBTT_SORTBYDATE, CM_ACTIVETIME, CM_LEFTTIME, CM_RIGHTTIME, 0, 0, 1, NULL, NULL, NULL, "SortByDate"},
/*TBBE_SORT_ATTR*/ {0xFFFF, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL},
/*TBBE_PARENT_DIR*/ {IDX_TB_PARENTDIR, 0, IDS_TBTT_PARENTDIR, CM_ACTIVEPARENTDIR, CM_LPARENTDIR, CM_RPARENTDIR, 0, 0, 0, &EnablerUpDir, &EnablerLeftUpDir, &EnablerRightUpDir, "ParentDirectory"},
/*TBBE_ROOT_DIR*/ {IDX_TB_ROOTDIR, 0, IDS_TBTT_ROOTDIR, CM_ACTIVEROOTDIR, CM_LROOTDIR, CM_RROOTDIR, 0, 0, 0, &EnablerRootDir, &EnablerLeftRootDir, &EnablerRightRootDir, "RootDirectory"},
/*TBBE_FILTER*/ {IDX_TB_FILTER, 0, IDS_TBTT_FILTER, CM_CHANGEFILTER, CM_LCHANGEFILTER, CM_RCHANGEFILTER, 0, 0, 0, NULL, NULL, NULL, "Filter"},
/*TBBE_BACK*/ {IDX_TB_BACK, 0, IDS_TBTT_BACK, CM_ACTIVEBACK, CM_LBACK, CM_RBACK, 1, 0, 0, &EnablerBackward, &EnablerLeftBackward, &EnablerRightBackward, "Back"},
/*TBBE_FORWARD*/ {IDX_TB_FORWARD, 0, IDS_TBTT_FORWARD, CM_ACTIVEFORWARD, CM_LFORWARD, CM_RFORWARD, 1, 0, 0, &EnablerForward, &EnablerLeftForward, &EnablerRightForward, "Forward"},
/*TBBE_REFRESH*/ {IDX_TB_REFRESH, 0, IDS_TBTT_REFRESH, CM_ACTIVEREFRESH, CM_LEFTREFRESH, CM_RIGHTREFRESH, 0, 0, 0, NULL, NULL, NULL, "Refresh"},
/*TBBE_SWAP_PANELS*/ {IDX_TB_SWAPPANELS, 0, IDS_TBTT_SWAPPANELS, CM_SWAPPANELS, 0, 0, 0, 0, 0, NULL, NULL, NULL, "SwapPanels"},
/*TBBE_PROPERTIES*/ {IDX_TB_PROPERTIES, 0, IDS_TBTT_PROPERTIES, CM_PROPERTIES, 0, 0, 0, 0, 0, &EnablerShowProperties, NULL, NULL, "Properties"},
/*TBBE_USER_MENU_DROP*/ {IDX_TB_USERMENU, 0, IDS_TBTT_USERMENU, CM_USERMENUDROP, 0, 0, 0, 1, 0, &EnablerOnDisk, NULL, NULL, "UserMenu"},
/*TBBE_CMD*/ {IDX_TB_COMMANDSHELL, 0, IDS_TBTT_COMMANDSHELL, CM_DOSSHELL, 0, 0, 0, 0, 0, NULL, NULL, NULL, "CommandShell"},
/*TBBE_COPY*/ {IDX_TB_COPY, 0, IDS_TBTT_COPY, CM_COPYFILES, 0, 0, 0, 0, 0, &EnablerFilesCopy, NULL, NULL, "Copy"},
/*TBBE_MOVE*/ {IDX_TB_MOVE, 0, IDS_TBTT_MOVE, CM_MOVEFILES, 0, 0, 0, 0, 0, &EnablerFilesMove, NULL, NULL, "Move"},
/*TBBE_DELETE*/ {IDX_TB_DELETE, 0, IDS_TBTT_DELETE, CM_DELETEFILES, 0, 0, 0, 0, 0, &EnablerFilesDelete, NULL, NULL, "Delete"},
/*TBBE_COMPRESS*/ {IDX_TB_COMPRESS, 0, IDS_TBTT_COMPRESS, CM_COMPRESS, 0, 0, 0, 0, 0, &EnablerFilesOnDiskCompress, NULL, NULL, "NTFSCompress"},
/*TBBE_UNCOMPRESS*/ {IDX_TB_UNCOMPRESS, 0, IDS_TBTT_UNCOMPRESS, CM_UNCOMPRESS, 0, 0, 0, 0, 0, &EnablerFilesOnDiskCompress, NULL, NULL, "NTFSUncompress"},
/*TBBE_QUICK_RENAME*/ {IDX_TB_QUICKRENAME, 0, IDS_TBTT_QUICKRENAME, CM_RENAMEFILE, 0, 0, 0, 0, 0, &EnablerQuickRename, NULL, NULL, "QuickRename"},
/*TBBE_CHANGE_CASE*/ {IDX_TB_CHANGECASE, 0, IDS_TBTT_CHANGECASE, CM_CHANGECASE, 0, 0, 0, 0, 0, &EnablerFilesOnDisk, NULL, NULL, "ChangeCase"},
/*TBBE_VIEW*/ {IDX_TB_VIEW, 0, IDS_TBTT_VIEW, CM_VIEW, 0, 0, 1, 0, 0, &EnablerViewFile, NULL, NULL, "View"},
/*TBBE_EDIT*/ {IDX_TB_EDIT, 0, IDS_TBTT_EDIT, CM_EDIT, 0, 0, 1, 0, 0, &EnablerFileOnDiskOrArchive, NULL, NULL, "Edit"},
/*TBBE_CLIPBOARD_CUT*/ {IDX_TB_CLIPBOARDCUT, 0, IDS_TBTT_CLIPBOARDCUT, CM_CLIPCUT, 0, 0, 0, 0, 0, &EnablerFilesOnDisk, NULL, NULL, "ClipboardCut"},
/*TBBE_CLIPBOARD_COPY*/ {IDX_TB_CLIPBOARDCOPY, 0, IDS_TBTT_CLIPBOARDCOPY, CM_CLIPCOPY, 0, 0, 0, 0, 0, &EnablerFilesOnDiskOrArchive, NULL, NULL, "ClipboardCopy"},
/*TBBE_CLIPBOARD_PASTE*/ {IDX_TB_CLIPBOARDPASTE, 0, IDS_TBTT_CLIPBOARDPASTE, CM_CLIPPASTE, 0, 0, 0, 0, 0, &EnablerPaste, NULL, NULL, "ClipboardPaste"},
/*TBBE_CHANGE_ATTR*/ {IDX_TB_CHANGEATTR, 0, IDS_TBTT_CHANGEATTR, CM_CHANGEATTR, 0, 0, 0, 0, 0, &EnablerChangeAttrs, NULL, NULL, "ChangeAttributes"},
/*TBBE_COMPARE_DIR*/ {IDX_TB_COMPAREDIR, 0, IDS_TBTT_COMPAREDIR, CM_COMPAREDIRS, 0, 0, 0, 0, 0, NULL, NULL, NULL, "CompareDirectories"},
/*TBBE_DRIVE_INFO*/ {IDX_TB_DRIVEINFO, 0, IDS_TBTT_DRIVEINFO, CM_DRIVEINFO, 0, 0, 0, 0, 0, &EnablerDriveInfo, NULL, NULL, "DriveInformation"},
/*TBBE_CHANGE_DRIVE_L*/ {IDX_TB_CHANGEDRIVEL, 0, IDS_TBTT_CHANGEDRIVE, CM_LCHANGEDRIVE, CM_LCHANGEDRIVE, 0, 0, 1, 0, NULL, NULL, NULL, "ChangeDrive"},
/*TBBE_SELECT*/ {IDX_TB_SELECT, 0, IDS_TBTT_SELECT, CM_ACTIVESELECT, 0, 0, 0, 0, 0, NULL, NULL, NULL, "Select"},
/*TBBE_UNSELECT*/ {IDX_TB_UNSELECT, 0, IDS_TBTT_UNSELECT, CM_ACTIVEUNSELECT, 0, 0, 0, 0, 0, &EnablerSelected, NULL, NULL, "Unselect"},
/*TBBE_INVERT_SEL*/ {IDX_TB_INVERTSEL, 0, IDS_TBTT_INVERTSEL, CM_ACTIVEINVERTSEL, 0, 0, 0, 0, 0, NULL, NULL, NULL, "InvertSelection"},
/*TBBE_SELECT_ALL*/ {IDX_TB_SELECTALL, 0, IDS_TBTT_SELECTALL, CM_ACTIVESELECTALL, 0, 0, 0, 0, 0, NULL, NULL, NULL, "SelectAll"},
/*TBBE_PACK*/ {IDX_TB_PACK, 0, IDS_TBTT_PACK, CM_PACK, 0, 0, 0, 0, 0, &EnablerFilesOnDisk, NULL, NULL, "Pack"},
/*TBBE_UNPACK*/ {IDX_TB_UNPACK, 0, IDS_TBTT_UNPACK, CM_UNPACK, 0, 0, 0, 0, 0, &EnablerFileOnDisk, NULL, NULL, "Unpack"},
// Core command visuals stay deterministic instead of inheriting version-specific shell32 artwork.
/*TBBE_OPEN_ACTIVE*/ {NIB1(IDX_TB_OPENACTIVE), 0, IDS_TBTT_OPENACTIVE, CM_OPENACTUALFOLDER, 0, 0, 0, 0, 0, &EnablerOpenActiveFolder, NULL, NULL, "OpenActiveFolder"},
/*TBBE_OPEN_DESKTOP*/ {NIB1(IDX_TB_OPENDESKTOP), 0, IDS_TBTT_OPENDESKTOP, CM_OPENDESKTOP, 0, 0, 0, 0, 0, NULL, NULL, NULL, "OpenDesktop"},
/*TBBE_OPEN_MYCOMP*/ {NIB1(IDX_TB_OPENMYCOMP), 0, IDS_TBTT_OPENMYCOMP, CM_OPENMYCOMP, 0, 0, 0, 0, 0, NULL, NULL, NULL, "OpenComputer"},
/*TBBE_OPEN_CONTROL*/ {NIB1(IDX_TB_OPENCONTROL), 0, IDS_TBTT_OPENCONTROL, CM_OPENCONROLPANEL, 0, 0, 0, 0, 0, NULL, NULL, NULL, "OpenControlPanel"},
/*TBBE_OPEN_PRINTERS*/ {NIB1(IDX_TB_OPENPRINTERS), 0, IDS_TBTT_OPENPRINTERS, CM_OPENPRINTERS, 0, 0, 0, 0, 0, NULL, NULL, NULL, "OpenPrinters"},
/*TBBE_OPEN_NETWORK*/ {NIB1(IDX_TB_OPENNETWORK), 0, IDS_TBTT_OPENNETWORK, CM_OPENNETNEIGHBOR, 0, 0, 0, 0, 0, NULL, NULL, NULL, "OpenNetwork"},
/*TBBE_OPEN_RECYCLE*/ {NIB1(IDX_TB_OPENRECYCLE), 0, IDS_TBTT_OPENRECYCLE, CM_OPENRECYCLEBIN, 0, 0, 0, 0, 0, NULL, NULL, NULL, "OpenRecycleBin"},
/*TBBE_OPEN_FONTS*/ {NIB1(IDX_TB_OPENFONTS), 0, IDS_TBTT_OPENFONTS, CM_OPENFONTS, 0, 0, 0, 0, 0, NULL, NULL, NULL, "OpenFonts"},
/*TBBE_CHANGE_DRIVE_R*/ {IDX_TB_CHANGEDRIVER, 0, IDS_TBTT_CHANGEDRIVE, CM_RCHANGEDRIVE, 0, CM_RCHANGEDRIVE, 0, 1, 0, NULL, NULL, NULL, "ChangeDrive"},
/*TBBE_HELP_CONTENTS*/ {NIB1(IDX_TB_HELP), 0, IDS_TBTT_HELP, CM_HELP_CONTENTS, 0, 0, 0, 0, 0, NULL, NULL, NULL, "HelpContents"},
/*TBBE_HELP_CONTEXT*/ {NIB1(IDX_TB_CONTEXTHELP), 0, IDS_TBTT_CONTEXTHELP, CM_HELP_CONTEXT, 0, 0, 0, 0, 0, NULL, NULL, NULL, "WhatIsThis"},
/*TBBE_PERMISSIONS*/ {IDX_TB_PERMISSIONS, 0, IDS_TBTT_PERMISSIONS, CM_SEC_PERMISSIONS, 0, 0, 0, 0, 0, &EnablerPermissions, NULL, NULL, "Security"},
/*TBBE_CONVERT*/ {IDX_TB_CONVERT, 0, IDS_TBTT_CONVERT, CM_CONVERTFILES, 0, 0, 0, 0, 0, &EnablerFilesOnDisk, NULL, NULL, "Convert"},
/*TBBE_UNSELECT_ALL*/ {IDX_TB_UNSELECTALL, 0, IDS_TBTT_UNSELECTALL, CM_ACTIVEUNSELECTALL, 0, 0, 0, 0, 0, &EnablerSelected, NULL, NULL, "UnselectAll"},
/*TBBE_MENU*/ {0xFFFF, 0, IDS_TBTT_MENU, CM_MENU, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL},
/*TBBE_ALTVIEW*/ {0xFFFF, 0, IDS_TBTT_ALTVIEW, CM_ALTVIEW, 0, 0, 0, 0, 0, &EnablerViewFile, NULL, NULL, NULL},
/*TBBE_EXIT*/ {0xFFFF, 0, IDS_TBTT_EXIT, CM_EXIT, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL},
/*TBBE_OCCUPIEDSPACE*/ {IDX_TB_OCCUPIEDSPACE, 0, IDS_TBTT_OCCUPIEDSPACE, CM_OCCUPIEDSPACE, 0, 0, 0, 0, 0, &EnablerOccupiedSpace, NULL, NULL, "CalculateOccupiedSpace"},
/*TBBE_EDITNEW*/ {IDX_TB_EDITNEW, 0, IDS_TBTT_EDITNEW, CM_EDITNEW, 0, 0, 0, 0, 0, &EnablerOnDisk, NULL, NULL, "EditNewFile"},
/*TBBE_CHANGEDIR*/ {IDX_TB_CHANGE_DIR, 0, IDS_TBTT_CHANGEDIR, CM_ACTIVE_CHANGEDIR, CM_LEFT_CHANGEDIR, CM_RIGHT_CHANGEDIR, 0, 0, 0, NULL, NULL, NULL, "ChangeDirectory"},
/*TBBE_HOTPATHS*/ {0xFFFF, 0, IDS_TBTT_HOTPATHS, CM_OPENHOTPATHS, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL},
/*TBBE_CONTEXTMENU*/ {0xFFFF, 0, IDS_TBTT_CONTEXTMENU, CM_CONTEXTMENU, 0, 0, 0, 0, 0, &EnablerItemsContextMenu, NULL, NULL, NULL},
/*TBBE_VIEWWITH*/ {0xFFFF, 0, IDS_TBTT_VIEWWITH, CM_VIEW_WITH, 0, 0, 0, 0, 0, &EnablerViewFile, NULL, NULL, NULL},
/*TBBE_EDITWITH*/ {0xFFFF, 0, IDS_TBTT_EDITWITH, CM_EDIT_WITH, 0, 0, 0, 0, 0, &EnablerFileOnDiskOrArchive, NULL, NULL, NULL},
/*TBBE_CALCDIRSIZES*/ {IDX_TB_CALCDIRSIZES, 0, IDS_TBTT_CALCDIRSIZES, CM_CALCDIRSIZES, 0, 0, 0, 0, 0, &EnablerCalcDirSizes, NULL, NULL, "CalculateDirectorySizes"},
/*TBBE_FILEHISTORY*/ {0xFFFF, 0, IDS_TBTT_FILEHISTORY, CM_FILEHISTORY, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL},
/*TBBE_DIRHISTORY*/ {0xFFFF, 0, IDS_TBTT_DIRHISTORY, CM_DIRHISTORY, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL},
/*TBBE_HOTPATHSDROP*/ {IDX_TB_HOTPATHS, 0, IDS_TBTT_HOTPATHSDROP, CM_OPENHOTPATHSDROP, 0, 0, 0, 1, 0, NULL, NULL, NULL, "GoToHotPath"},
/*TBBE_USER_MENU*/ {IDX_TB_USERMENU, 0, IDS_TBTT_USERMENU, CM_USERMENU, 0, 0, 0, 0, 0, &EnablerOnDisk, NULL, NULL, "UserMenu"},
/*TBBE_EMAIL*/ {IDX_TB_EMAIL, 0, IDS_TBTT_EMAIL, CM_EMAILFILES, 0, 0, 0, 0, 0, &EnablerFilesOnDisk, NULL, NULL, "Email"},
/*TBBE_ZOOM_PANEL*/ {0xFFFF, 0, IDS_TBTT_ZOOMPANEL, CM_ACTIVEZOOMPANEL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL},
/*TBBE_SHARES*/ {IDX_TB_SHARED_DIRS, 0, IDS_TBTT_SHARES, CM_SHARES, 0, 0, 0, 0, 0, NULL, NULL, NULL, "SharedDirectories"},
/*TBBE_FULLSCREEN*/ {0xFFFF, 0, IDS_TBTT_FULLSCREEN, CM_FULLSCREEN, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL},
/*TBBE_PREV_SELECTED*/ {IDX_TB_PREV_SELECTED, 0, IDS_TBTT_PREV_SEL, CM_GOTO_PREV_SEL, 0, 0, 0, 0, 0, &EnablerSelGotoPrev, NULL, NULL, "GoToPreviousSelectedName"},
/*TBBE_NEXT_SELECTED*/ {IDX_TB_NEXT_SELECTED, 0, IDS_TBTT_NEXT_SEL, CM_GOTO_NEXT_SEL, 0, 0, 0, 0, 0, &EnablerSelGotoNext, NULL, NULL, "GoToNextSelectedName"},
/*TBBE_RESELECT*/ {IDX_TB_RESELECT, 0, IDS_TBTT_RESELECT, CM_RESELECT, 0, 0, 0, 0, 0, &EnablerSelectionStored, NULL, NULL, "RestoreSelection"},
/*TBBE_PASTESHORTCUT*/ {IDX_TB_PASTESHORTCUT, 0, IDS_TBTT_PASTESHORTCUT, CM_CLIPPASTELINKS, 0, 0, 0, 0, 0, &EnablerPasteLinksOnDisk, NULL, NULL, "PasteShortcut"},
/*TBBE_FOCUSSHORTCUT*/ {IDX_TB_FOCUSSHORTCUT, 0, IDS_TBTT_FOCUSSHORTCUT, CM_AFOCUSSHORTCUT, 0, 0, 0, 0, 0, &EnablerFileOrDirLinkOnDisk, NULL, NULL, "GoToShortcutTarget"},
/*TBBE_SAVESELECTION*/ {IDX_TB_SAVESELECTION, 0, IDS_TBTT_SAVESELECTION, CM_STORESEL, 0, 0, 0, 0, 0, &EnablerSelected, NULL, NULL, "SaveSelection"},
/*TBBE_LOADSELECTION*/ {IDX_TB_LOADSELECTION, 0, IDS_TBTT_LOADSELECTION, CM_RESTORESEL, 0, 0, 0, 0, 0, &EnablerGlobalSelStored, NULL, NULL, "LoadSelection"},
/*TBBE_NEW*/ {IDX_TB_NEW, 0, IDS_TBTT_NEW, CM_NEWDROP, 0, 0, 0, 1, 0, &EnablerOnDisk, NULL, NULL, "New"},
/*TBBE_SEL_BY_EXT*/ {IDX_TB_SEL_BY_EXT, 0, IDS_TBTT_SEL_BY_EXT, CM_SELECTBYFOCUSEDEXT, 0, 0, 0, 0, 0, &EnablerFileDir, NULL, NULL, "SelectFilesWithSameExtension"},
/*TBBE_UNSEL_BY_EXT*/ {IDX_TB_UNSEL_BY_EXT, 0, IDS_TBTT_UNSEL_BY_EXT, CM_UNSELECTBYFOCUSEDEXT, 0, 0, 0, 0, 0, &EnablerFileDirANDSelected, NULL, NULL, "UnselectFilesWithSameExtension"},
/*TBBE_SEL_BY_NAME*/ {IDX_TB_SEL_BY_NAME, 0, IDS_TBTT_SEL_BY_NAME, CM_SELECTBYFOCUSEDNAME, 0, 0, 0, 0, 0, &EnablerFileDir, NULL, NULL, "SelectFilesWithSameName"},
/*TBBE_UNSEL_BY_NAME*/ {IDX_TB_UNSEL_BY_NAME, 0, IDS_TBTT_UNSEL_BY_NAME, CM_UNSELECTBYFOCUSEDNAME, 0, 0, 0, 0, 0, &EnablerFileDirANDSelected, NULL, NULL, "UnselectFilesWithSameName"},
/*TBBE_OPEN_FOLDER*/ {NIB1(IDX_TB_OPEN_FOLDER), 0, IDS_TBTT_OPEN_FOLDER, CM_OPEN_FOLDER_DROP, 0, 0, 0, 1, 0, NULL, NULL, NULL, "OpenFolder"},
/*TBBE_CONFIGRATION*/ {IDX_TB_CONFIGURARTION, 0, IDS_TBTT_CONFIGURATION, CM_CONFIGURATION, 0, 0, 0, 0, 0, NULL, NULL, NULL, "Configuration"},
/*TBBE_DIRMENU*/ {0xFFFF, 0, IDS_TBTT_DIRMENU, CM_DIRMENU, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL},
/*TBBE_OPEN_IN_OTHER_ACT*/ {IDX_TB_OPEN_IN_OTHER_ACT, 0, IDS_TBTT_OPENINOTHER_A, CM_OPEN_IN_OTHER_PANEL_ACT, 0, 0, 0, 0, 0, NULL, NULL, NULL, "FocusNameInOtherPanel"},
/*TBBE_OPEN_IN_OTHER*/ {IDX_TB_OPEN_IN_OTHER, 0, IDS_TBTT_OPENINOTHER, CM_OPEN_IN_OTHER_PANEL, 0, 0, 0, 0, 0, NULL, NULL, NULL, "OpenNameInOtherPanel"},
/*TBBE_AS_OTHER_PANEL*/ {IDX_TB_AS_OTHER_PANEL, 0, IDS_TBTT_ASOTHERPANEL, CM_ACTIVE_AS_OTHER, CM_LEFT_AS_OTHER, CM_RIGHT_AS_OTHER, 0, 0, 0, NULL, NULL, NULL, "GoToPathFromOtherPanel"},
/*TBBE_HIDE_SELECTED*/ {IDX_TB_HIDE_SELECTED, 0, IDS_TBTT_HIDE_SELECTED, CM_HIDE_SELECTED_NAMES, 0, 0, 0, 0, 0, &EnablerSelected, NULL, NULL, "HideSelectedNames"},
/*TBBE_HIDE_UNSELECTED*/ {IDX_TB_HIDE_UNSELECTED, 0, IDS_TBTT_HIDE_UNSELECTED, CM_HIDE_UNSELECTED_NAMES, 0, 0, 0, 0, 0, &EnablerUnselected, NULL, NULL, "HideUnselectedNames"},
/*TBBE_SHOW_ALL*/ {IDX_TB_SHOW_ALL, 0, IDS_TBTT_SHOW_ALL, CM_SHOW_ALL_NAME, 0, 0, 0, 0, 0, &EnablerHiddenNames, NULL, NULL, "ShowHiddenNames"},
/*TBBE_OPEN_MYDOC*/ {NIB1(IDX_TB_OPENMYDOC), 0, IDS_TBTT_OPENMYDOC, CM_OPENPERSONAL, 0, 0, 0, 0, 0, NULL, NULL, NULL, "OpenDocuments"},
/*TBBE_SMART_COLUMN_MODE*/ {IDX_TB_SMART_COLUMN_MODE, 0, IDS_TBTT_SMARTMODE, CM_ACTIVE_SMARTMODE, CM_LEFT_SMARTMODE, CM_RIGHT_SMARTMODE, 0, 0, 0, NULL, NULL, NULL, "SmartColumnMode"},
};
//
// TopToolbar
//
// Represents all possible buttons that TopToolbar can contain.
// Order defines button order in the toolbar configuration dialog and can
// be changed arbitrarily.
//
DWORD TopToolBarButtons[] =
{
TBBE_BACK,
TBBE_FORWARD,
TBBE_HOTPATHSDROP,
TBBE_PARENT_DIR,
TBBE_ROOT_DIR,
NIB2(TBBE_CONNECT_NET)
TBBE_DISCONNECT_NET,
TBBE_CREATE_DIR,
TBBE_FIND_FILE,
TBBE_CHANGEDIR,
TBBE_SHARES,
TBBE_VIEW_MODE,
TBBE_SORT_NAME,
TBBE_SORT_EXT,
TBBE_SORT_SIZE,
TBBE_SORT_DATE,
TBBE_FILTER,
TBBE_REFRESH,
TBBE_SWAP_PANELS,
TBBE_SMART_COLUMN_MODE,
TBBE_USER_MENU_DROP,
TBBE_CMD,
TBBE_COPY,
TBBE_MOVE,
TBBE_DELETE,
TBBE_EMAIL,
TBBE_COMPRESS,
TBBE_UNCOMPRESS,
TBBE_QUICK_RENAME,
TBBE_CHANGE_CASE,
TBBE_CONVERT,
TBBE_VIEW,
TBBE_EDIT,
TBBE_EDITNEW,
TBBE_NEW,
TBBE_CLIPBOARD_CUT,
TBBE_CLIPBOARD_COPY,
TBBE_CLIPBOARD_PASTE,
TBBE_PASTESHORTCUT,
TBBE_CHANGE_ATTR,
TBBE_COMPARE_DIR,
TBBE_DRIVE_INFO,
TBBE_CALCDIRSIZES,
TBBE_OCCUPIEDSPACE,
TBBE_PERMISSIONS,
TBBE_PROPERTIES,
TBBE_FOCUSSHORTCUT,
TBBE_OPEN_IN_OTHER_ACT,
TBBE_OPEN_IN_OTHER,
TBBE_AS_OTHER_PANEL,
TBBE_SELECT,
TBBE_UNSELECT,
TBBE_INVERT_SEL,
TBBE_SELECT_ALL,
TBBE_UNSELECT_ALL,
TBBE_RESELECT,
TBBE_SEL_BY_EXT,
TBBE_UNSEL_BY_EXT,
TBBE_SEL_BY_NAME,
TBBE_UNSEL_BY_NAME,
TBBE_PREV_SELECTED,
TBBE_NEXT_SELECTED,
TBBE_SAVESELECTION,
TBBE_LOADSELECTION,
TBBE_HIDE_SELECTED,
TBBE_HIDE_UNSELECTED,
TBBE_SHOW_ALL,
TBBE_PACK,
TBBE_UNPACK,
NIB2(TBBE_OPEN_FOLDER)
NIB2(TBBE_OPEN_ACTIVE)
NIB2(TBBE_OPEN_DESKTOP)
NIB2(TBBE_OPEN_MYCOMP)
NIB2(TBBE_OPEN_CONTROL)
NIB2(TBBE_OPEN_PRINTERS)
NIB2(TBBE_OPEN_NETWORK)
NIB2(TBBE_OPEN_RECYCLE)
NIB2(TBBE_OPEN_FONTS)
NIB2(TBBE_OPEN_MYDOC)
TBBE_CONFIGRATION,
NIB2(TBBE_HELP_CONTENTS)
NIB2(TBBE_HELP_CONTEXT)
TBBE_TERMINATOR // terminator - must be here!
};
DWORD LeftToolBarButtons[] =
{
TBBE_CHANGE_DRIVE_L,
TBBE_PARENT_DIR,
TBBE_ROOT_DIR,
TBBE_CHANGEDIR,
TBBE_AS_OTHER_PANEL,
TBBE_BACK,
TBBE_FORWARD,
TBBE_VIEW_MODE,
TBBE_SORT_NAME,
TBBE_SORT_EXT,
TBBE_SORT_SIZE,
TBBE_SORT_DATE,
TBBE_FILTER,
TBBE_REFRESH,
TBBE_SMART_COLUMN_MODE,
TBBE_TERMINATOR // terminator - must be here!
};
DWORD RightToolBarButtons[] =
{
TBBE_CHANGE_DRIVE_R,
TBBE_PARENT_DIR,
TBBE_ROOT_DIR,
TBBE_CHANGEDIR,
TBBE_AS_OTHER_PANEL,
TBBE_BACK,
TBBE_FORWARD,
TBBE_VIEW_MODE,
TBBE_SORT_NAME,
TBBE_SORT_EXT,
TBBE_SORT_SIZE,
TBBE_SORT_DATE,
TBBE_FILTER,
TBBE_REFRESH,
TBBE_SMART_COLUMN_MODE,
TBBE_TERMINATOR // terminator - must be here!
};
void GetSVGIconsMainToolbar(CSVGIcon** svgIcons, int* svgIconsCount)
{
// Cover the two find-window-only bitmap slots so every core toolbar/menu icon is SVG-backed.
static CSVGIcon SVGIcons[TBBE_TERMINATOR + 2];
for (auto i = 0; i < TBBE_TERMINATOR; i++)
{
SVGIcons[i].ImageIndex = ToolBarButtons[i].ImageIndex;
SVGIcons[i].SVGName = ToolBarButtons[i].SVGName;
}
SVGIcons[TBBE_TERMINATOR] = {IDX_TB_FOCUS, "Focus"};
SVGIcons[TBBE_TERMINATOR + 1] = {IDX_TB_STOP, "Stop"};
*svgIcons = SVGIcons;
*svgIconsCount = _countof(SVGIcons);
}
//****************************************************************************
//
// CreateGrayscaleAndMaskBitmaps
//
// Creates a new 24-bit bitmap, copies the source bitmap into it, and converts
// it to grayscale. It also prepares a second bitmap containing a mask based
// on the transparent color.
//
BOOL CreateGrayscaleAndMaskBitmaps(HBITMAP hSource, COLORREF transparent,
HBITMAP& hGrayscale, HBITMAP& hMask)
{
CALL_STACK_MESSAGE1("CreateGrayscaleAndMaskBitmaps(, , ,)");
BOOL ret = FALSE;
VOID* lpvBits = NULL;
VOID* lpvBitsMask = NULL;
hGrayscale = NULL;
hMask = NULL;
HDC hDC = HANDLES(GetDC(NULL));
// Retrieve the bitmap dimensions.
BITMAPINFO bi;
memset(&bi, 0, sizeof(bi));
bi.bmiHeader.biSize = sizeof(bi.bmiHeader);
bi.bmiHeader.biBitCount = 0; // no palette is required
if (!GetDIBits(hDC,
hSource,
0, 0,
NULL,
&bi,
DIB_RGB_COLORS))
{
TRACE_E("GetDIBits failed");
goto exitus;
}
if (bi.bmiHeader.biSizeImage == 0)
{
TRACE_E("bi.bmiHeader.biSizeImage = 0");
goto exitus;
}
// The requested color depth is 24 bits.
bi.bmiHeader.biSizeImage = ((((bi.bmiHeader.biWidth * 24) + 31) & ~31) >> 3) * bi.bmiHeader.biHeight;
// Allocate the required space.
lpvBits = malloc(bi.bmiHeader.biSizeImage);
if (lpvBits == NULL)
{
TRACE_E("malloc failed");
goto exitus;
}
lpvBitsMask = malloc(bi.bmiHeader.biSizeImage);
if (lpvBitsMask == NULL)
{
TRACE_E("malloc failed");
goto exitus;
}
bi.bmiHeader.biPlanes = 1;
bi.bmiHeader.biBitCount = 24;
bi.bmiHeader.biCompression = BI_RGB;
// Retrieve the pixel data.
if (!GetDIBits(hDC,
hSource,
0, bi.bmiHeader.biHeight,
lpvBits,
&bi,
DIB_RGB_COLORS))
{
TRACE_E("GetDIBits failed");
goto exitus;
}
// Retrieve the mask data.
if (!GetDIBits(hDC,
hSource,
0, bi.bmiHeader.biHeight,
lpvBitsMask,
&bi,
DIB_RGB_COLORS))
{
TRACE_E("GetDIBits failed");
goto exitus;
}
// Convert the image to grayscale.
BYTE* rgb;
BYTE* rgbMask;
rgb = (BYTE*)lpvBits;
rgbMask = (BYTE*)lpvBitsMask;
int i;
for (i = 0; i < bi.bmiHeader.biWidth * bi.bmiHeader.biHeight; i++)
{
BYTE r = rgb[2];
BYTE g = rgb[1];
BYTE b = rgb[0];
if (transparent != RGB(r, g, b))
{
BYTE brightness = GetGrayscaleFromRGB(r, g, b);
rgb[0] = rgb[1] = rgb[2] = brightness;
rgbMask[0] = rgbMask[1] = rgbMask[2] = (BYTE)0;
}
else
rgbMask[0] = rgbMask[1] = rgbMask[2] = (BYTE)255;
rgb += 3;
rgbMask += 3;
}
// Create a new bitmap from the grayscale data.
hGrayscale = HANDLES(CreateDIBitmap(hDC,
&bi.bmiHeader,
(LONG)CBM_INIT,
lpvBits,
&bi,
DIB_RGB_COLORS));
if (hGrayscale == NULL)
{
TRACE_E("CreateDIBitmap failed");
goto exitus;
}
// Create a new bitmap from the mask data.
hMask = HANDLES(CreateDIBitmap(hDC,
&bi.bmiHeader,
(LONG)CBM_INIT,
lpvBitsMask,
&bi,
DIB_RGB_COLORS));
if (hMask == NULL)
{
HANDLES(DeleteObject(hGrayscale));
hGrayscale = NULL;
TRACE_E("CreateDIBitmap failed");
goto exitus;
}
ret = TRUE;
exitus:
if (lpvBits != NULL)
free(lpvBits);
if (lpvBitsMask != NULL)
free(lpvBitsMask);
if (hDC != NULL)
HANDLES(ReleaseDC(NULL, hDC));
return ret;
}
// JRYFIXME - temporary during the transition to SVG
BOOL CreateGrayscaleAndMaskBitmaps_tmp(HBITMAP hSource, COLORREF transparent, COLORREF bkColorForAlpha,
HBITMAP& hGrayscale, HBITMAP& hMask)
{
CALL_STACK_MESSAGE1("CreateGrayscaleAndMaskBitmaps(, , ,)");
BOOL ret = FALSE;
VOID* lpvBits = NULL;
VOID* lpvBitsMask = NULL;
hGrayscale = NULL;
hMask = NULL;
HDC hDC = HANDLES(GetDC(NULL));
// Retrieve the bitmap dimensions.
BITMAPINFO bi;
memset(&bi, 0, sizeof(bi));
bi.bmiHeader.biSize = sizeof(bi.bmiHeader);
bi.bmiHeader.biBitCount = 0; // no palette is required
if (!GetDIBits(hDC,
hSource,
0, 0,
NULL,
&bi,
DIB_RGB_COLORS))
{
TRACE_E("GetDIBits failed");
goto exitus;
}
if (bi.bmiHeader.biSizeImage == 0)
{
TRACE_E("bi.bmiHeader.biSizeImage = 0");
goto exitus;
}
// The requested color depth is 24 bits.
bi.bmiHeader.biSizeImage = ((((bi.bmiHeader.biWidth * 24) + 31) & ~31) >> 3) * bi.bmiHeader.biHeight;
// Allocate the required space.
lpvBits = malloc(bi.bmiHeader.biSizeImage);
if (lpvBits == NULL)
{
TRACE_E("malloc failed");
goto exitus;
}
lpvBitsMask = malloc(bi.bmiHeader.biSizeImage);
if (lpvBitsMask == NULL)
{
TRACE_E("malloc failed");
goto exitus;
}
bi.bmiHeader.biPlanes = 1;
bi.bmiHeader.biBitCount = 24;
bi.bmiHeader.biCompression = BI_RGB;
// Retrieve the pixel data.
if (!GetDIBits(hDC,
hSource,
0, bi.bmiHeader.biHeight,
lpvBits,
&bi,
DIB_RGB_COLORS))
{
TRACE_E("GetDIBits failed");
goto exitus;
}
// Retrieve the mask data.
if (!GetDIBits(hDC,
hSource,
0, bi.bmiHeader.biHeight,
lpvBitsMask,
&bi,
DIB_RGB_COLORS))
{
TRACE_E("GetDIBits failed");
goto exitus;
}
// Convert the image to grayscale.
BYTE* rgb;
BYTE* rgbMask;
rgb = (BYTE*)lpvBits;
rgbMask = (BYTE*)lpvBitsMask;
int i;
for (i = 0; i < bi.bmiHeader.biWidth * bi.bmiHeader.biHeight; i++)
{
BYTE r = rgb[2];
BYTE g = rgb[1];
BYTE b = rgb[0];
if (transparent != RGB(r, g, b) && bkColorForAlpha != RGB(r, g, b))
{
BYTE brightness = GetGrayscaleFromRGB(r, g, b);
float alpha = 0.5;
float alphablended = (float)GetRValue(bkColorForAlpha) * alpha + (float)brightness * (1 - alpha);
rgb[0] = rgb[1] = rgb[2] = (BYTE)alphablended;
rgbMask[0] = rgbMask[1] = rgbMask[2] = (BYTE)0;
}
else
rgbMask[0] = rgbMask[1] = rgbMask[2] = (BYTE)255;
rgb += 3;
rgbMask += 3;
}
// Create a new bitmap from the grayscale data.
hGrayscale = HANDLES(CreateDIBitmap(hDC,
&bi.bmiHeader,
(LONG)CBM_INIT,
lpvBits,
&bi,
DIB_RGB_COLORS));
if (hGrayscale == NULL)
{
TRACE_E("CreateDIBitmap failed");
goto exitus;
}
// Create a new bitmap from the mask data.
hMask = HANDLES(CreateDIBitmap(hDC,
&bi.bmiHeader,
(LONG)CBM_INIT,
lpvBitsMask,
&bi,
DIB_RGB_COLORS));
if (hMask == NULL)
{
HANDLES(DeleteObject(hGrayscale));
hGrayscale = NULL;
TRACE_E("CreateDIBitmap failed");
goto exitus;
}
ret = TRUE;
exitus:
if (lpvBits != NULL)
free(lpvBits);
if (lpvBitsMask != NULL)
free(lpvBitsMask);
if (hDC != NULL)
HANDLES(ReleaseDC(NULL, hDC));
return ret;
}
void RenderSVGImages(HDC hDC, int iconSize, COLORREF bkColor, const CSVGIcon* svgIcons, int svgIconsCount)
{
NSVGrasterizer* rast = nsvgCreateRasterizer();
// JRYFIXME: files are loaded directly for now; move them to storage shared with the toolbars
for (int i = 0; i < svgIconsCount; i++)
if (svgIcons[i].SVGName != NULL)
RenderSVGImage(rast, hDC, svgIcons[i].ImageIndex * iconSize, 0, svgIcons[i].SVGName, iconSize, bkColor, TRUE);
nsvgDeleteRasterizer(rast);
}
//****************************************************************************
//
// CreateToolbarBitmaps
//
// Loads a bitmap from resID and copies it into a new bitmap whose colors are
// compatible with the display. It then appends icons from shell32.dll and
// honors the transparent color.
// bkColorForAlpha specifies the color that will show through under the transparent parts of icons (WinXP)
//
BOOL CreateToolbarBitmaps(HINSTANCE hInstance, int resID, COLORREF transparent, COLORREF bkColorForAlpha,
HBITMAP& hMaskBitmap, HBITMAP& hGrayBitmap, HBITMAP& hColorBitmap, BOOL appendIcons,
const CSVGIcon* svgIcons, int svgIconsCount, int iconSize)
{
CALL_STACK_MESSAGE5("CreateToolbarBitmaps(%p, %d, %x, %x, , , )", hInstance, resID, transparent, bkColorForAlpha);
BOOL ret = FALSE;
HDC hDC = NULL;
HBITMAP hOldSrcBitmap = NULL;
HBITMAP hOldTgtBitmap = NULL;
HDC hTgtMemDC = NULL;
HDC hSrcMemDC = NULL;
hMaskBitmap = NULL;
hGrayBitmap = NULL;
hColorBitmap = NULL;
// The caller chooses the target size so compact menus and configurable toolbars can share this renderer.
int iconCount = 0;
int sourceIconCount = 0;
// Windows XP and later use transparent icons. Render them into this temporary
// bitmap through a mask so the transparent area contains the toolbar's gray
// background instead of the purple masking color.
HBITMAP hTmpBitmap = NULL;
HDC hTmpMemDC = NULL;
HBITMAP hOldTmpBitmap = NULL;
// Load the source bitmap.
HBITMAP hSource;
if (resID == IDB_TOOLBAR_256) // dirty hack, this should detect by resource type (RCDATA), or possibly by PNG signature
hSource = LoadPNGBitmap(hInstance, MAKEINTRESOURCE(resID), 0);
else
hSource = HANDLES(LoadBitmap(hInstance, MAKEINTRESOURCE(resID)));
if (hSource == NULL)
{
TRACE_E("LoadBitmap failed on redID " << resID);
goto exitus;
}
hDC = HANDLES(GetDC(NULL));
// Retrieve the bitmap dimensions.
BITMAPINFO bi;
memset(&bi, 0, sizeof(bi));
bi.bmiHeader.biSize = sizeof(bi.bmiHeader);
bi.bmiHeader.biBitCount = 0; // no palette is required
if (!GetDIBits(hDC,
hSource,
0, 0,
NULL,
&bi,
DIB_RGB_COLORS))
{
TRACE_E("GetDIBits failed");
goto exitus;
}
int tbbe_BMPCOUNT;
int i;
sourceIconCount = bi.bmiHeader.biWidth / 16;
// Reserve every stable command slot; SVGs now replace the old shell32-dependent tail.
iconCount = appendIcons ? IDX_TB_COUNT : sourceIconCount;
tbbe_BMPCOUNT = iconCount - sourceIconCount;
// Prepare a new bitmap large enough for hSource and the DLL icons.
// Extend its width to accommodate the DLL icons.
// hColorBitmap = HANDLES(CreateBitmap(width, height, bh.bV4Planes, bh.bV4BitCount, NULL));
// because CreateBitmap() is suitable only for creating B&W bitmaps (see MSDN)
// Salamander 2.5b7 and later use the faster CreateCompatibleBitmap().
hColorBitmap = HANDLES(CreateCompatibleBitmap(hDC, iconSize * iconCount, iconSize));
hTgtMemDC = HANDLES(CreateCompatibleDC(NULL));
hSrcMemDC = HANDLES(CreateCompatibleDC(NULL));
hOldTgtBitmap = (HBITMAP)SelectObject(hTgtMemDC, hColorBitmap);
hOldSrcBitmap = (HBITMAP)SelectObject(hSrcMemDC, hSource);
// Used to transfer icons, including transparent ones.
hTmpBitmap = HANDLES(CreateBitmap(iconSize, iconSize, 1, 1, NULL));
hTmpMemDC = HANDLES(CreateCompatibleDC(NULL));
hOldTmpBitmap = (HBITMAP)SelectObject(hTmpMemDC, hTmpBitmap);
// transfer the original bitmap into the new bitmap
if (!StretchBlt(hTgtMemDC, 0, 0, (iconCount - tbbe_BMPCOUNT) * iconSize, iconSize,
hSrcMemDC, 0, 0, bi.bmiHeader.biWidth, bi.bmiHeader.biHeight,
SRCCOPY))
{
TRACE_E("BitBlt failed");
goto exitus;
}
// Discard the source bitmap.
SelectObject(hSrcMemDC, hOldSrcBitmap);
hOldSrcBitmap = NULL;
// if we have an SVG version, use it
if (svgIcons != NULL)
{
RenderSVGImages(hTgtMemDC, iconSize, bkColorForAlpha, svgIcons, svgIconsCount);
}
// Used by BitBlt from hTmpMemDC to hTgtMemDC.
//SetBkColor(hTgtMemDC, transparent);
//SetTextColor(hTgtMemDC, bkColorForAlpha);
if (appendIcons)
{
// Load the requested icons from shell32.dll.
HICON hIcon;
for (i = 0; i < TBBE_TERMINATOR; i++)
{
BYTE resID2 = ToolBarButtons[i].Shell32ResID;
if (resID2 == 0 || resID2 == 255)
continue;
if ((resID2 == 21 && (resID2 = 112) != 0 || // Documents
resID2 == 33 && (resID2 = 54) != 0 || // Recycle Bin
resID2 == 138 && (resID2 = 26) != 0 || // Printers
resID2 == 39 && (resID2 = 77) != 0 || // Fonts
resID2 == 18 && (resID2 = 152) != 0)) // Network
{
hIcon = SalLoadIcon(ImageResDLL, resID2, iconSize);
}
else
{
// The Documents icon moved in Windows XP.
if (resID2 == 21)
resID2 = 235;
hIcon = SalLoadIcon(Shell32DLL, resID2, iconSize);
}
if (hIcon == NULL)
{
TRACE_E("LoadImage failed on resID2 " << resID2);
continue;
}
// Prepare the background for alpha-channel icons on Windows XP.
DrawIconEx(hTmpMemDC, 0, 0, hIcon, iconSize, iconSize, 0, 0, DI_MASK);
// Used by BitBlt from hTmpMemDC to hTgtMemDC.
SetBkColor(hTgtMemDC, transparent);
SetTextColor(hTgtMemDC, bkColorForAlpha);
BitBlt(hTgtMemDC, iconSize * ToolBarButtons[i].ImageIndex, 0, iconSize, iconSize,
hTmpMemDC, 0, 0,
SRCCOPY);
if (!DrawIconEx(hTgtMemDC, iconSize * ToolBarButtons[i].ImageIndex, 0, hIcon,
iconSize, iconSize, 0, 0, DI_NORMAL))
{
HANDLES(DestroyIcon(hIcon));
TRACE_E("DrawIconEx failed on resID2 " << resID2);
continue;
}
else
{
/*
// --- ugly patch BEGIN
// John: on Windows 2000, DrawIconEx with DI_NORMAL did not work for icon 21 (Documents).
// For an unknown reason it saturated the transparent area, changing the 'transparent' color.
SetBkColor(hTgtMemDC, RGB(0, 0, 0));
SetTextColor(hTgtMemDC, RGB(255, 255, 255));
BitBlt(hTgtMemDC, ICON16_CX * ToolBarButtons[i].ImageIndex, 0, ICON16_CX, ICON16_CX,
hTmpMemDC, 0, 0,
SRCAND);
SetBkColor(hTgtMemDC, RGB(255, 0, 255));
SetTextColor(hTgtMemDC, RGB(0, 0, 0));
BitBlt(hTgtMemDC, ICON16_CX * ToolBarButtons[i].ImageIndex, 0, ICON16_CX, ICON16_CX,
hTmpMemDC, 0, 0,
SRCPAINT);
// --- ugly patch END
*/
HANDLES(DestroyIcon(hIcon));
}
}
}
ret = TRUE;
exitus:
if (hOldSrcBitmap != NULL)
SelectObject(hSrcMemDC, hOldSrcBitmap);
if (hOldTgtBitmap != NULL)
SelectObject(hTgtMemDC, hOldTgtBitmap);
if (hSrcMemDC != NULL)
HANDLES(DeleteDC(hSrcMemDC));
if (hTgtMemDC != NULL)
HANDLES(DeleteDC(hTgtMemDC));
if (hSource != NULL)
HANDLES(DeleteObject(hSource));
if (hDC != NULL)
HANDLES(ReleaseDC(NULL, hDC));
if (hOldTmpBitmap != NULL)
SelectObject(hTmpMemDC, hOldTmpBitmap);
if (hTmpBitmap != NULL)
HANDLES(DeleteObject(hTmpBitmap));
if (hTmpMemDC != NULL)
HANDLES(DeleteDC(hTmpMemDC));
if (ret)
{
ret = CreateGrayscaleAndMaskBitmaps_tmp(hColorBitmap, transparent, bkColorForAlpha, hGrayBitmap, hMaskBitmap);
if (!ret)
{
HANDLES(DeleteObject(hColorBitmap));
hColorBitmap = NULL;
}
}
return ret;
}
//****************************************************************************
//
// PrepareToolTipText
//
// Searches buff for the first '\t'. If stripHotKey is set, replaces it with a
// terminator and returns. Otherwise, replaces it with a space, shifts the
// remainder one character to the right, and encloses it in parentheses.
//
void PrepareToolTipText(char* buff, BOOL stripHotKey)
{
CALL_STACK_MESSAGE2("PrepareToolTipText(, %d)", stripHotKey);
char* p = buff;
while (*p != '\t' && *p != 0)
p++;
if (*p == '\t')
{
if (!stripHotKey && *(p + 1) != 0)
{
// Toolbar tooltip callers provide the fixed reply field needed for the parentheses.
char hotKey[TOOLTIP_TEXT_MAX];
if (FAILED(StringCchCopyA(hotKey, _countof(hotKey), p + 1)) ||
FAILED(StringCchPrintfA(p, TOOLTIP_TEXT_MAX - (p - buff), " (%s)", hotKey)))
*p = 0;
}
else
*p = 0;
}
}
//*****************************************************************************
//
// CMainToolBar
//
CMainToolBar::CMainToolBar(HWND hNotifyWindow, CMainToolBarType type, CObjectOrigin origin)
: CToolBar(hNotifyWindow, origin)
{
CALL_STACK_MESSAGE_NONE
Type = type;
}
BOOL CMainToolBar::FillTII(int tbbeIndex, TLBI_ITEM_INFO2* tii, BOOL fillName)
{
CALL_STACK_MESSAGE3("CMainToolBar::FillTII(%d, , %d)", tbbeIndex, fillName);
if (tbbeIndex < -1 || tbbeIndex >= TBBE_TERMINATOR)
{
TRACE_E("tbbeIndex = " << tbbeIndex);
return FALSE;
}
if (ToolBarButtons[tbbeIndex].ImageIndex == 0xFFFF)
{
// Legacy item removed in this version.
return FALSE;
}