MCPcopy Create free account
hub / github.com/WinMerge/winmerge / CreatePropertyMenu

Function CreatePropertyMenu

Src/PropertySystemMenu.cpp:9–87  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7#include "PropertySystem.h"
8
9static void CreatePropertyMenu(HMENU hMenu, const std::vector<String>& canonicalNames, UINT idFirst, const String& format)
10{
11 if (!hMenu) return;
12
13 std::map<String, HMENU> menuMap;
14 std::map<String, HMENU> groupMenus;
15 menuMap[L""] = hMenu;
16 UINT id = idFirst;
17
18 CMenu systemSubAtoI, systemSubJtoR, systemSubStoZ;
19 bool systemMenuCreated = false;
20
21 for (const auto& canonical : canonicalNames)
22 {
23 PropertySystem ps({ canonical });
24 std::vector<String> displayNames;
25 ps.GetDisplayNames(displayNames);
26 if (!canonical.empty() && !displayNames.empty() && !displayNames[0].empty())
27 {
28 auto partstmp = strutils::split(canonical, L'.');
29 String canonical2 = canonical;
30 if (partstmp.size() == 2 && partstmp[0] == _T("System"))
31 {
32 tchar_t ch = canonical[7];
33 if (ch >= 'A' && ch <= 'F')
34 canonical2 = L"System.A-F." + canonical.substr(7);
35 else if (ch >= 'G' && ch <= 'L')
36 canonical2 = L"System.G-L." + canonical.substr(7);
37 else if (ch >= 'M' && ch <= 'R')
38 canonical2 = L"System.M-R." + canonical.substr(7);
39 else if (ch >= 'S' && ch <= 'Z')
40 canonical2 = L"System.S-Z." + canonical.substr(7);
41 }
42
43 String path;
44 auto parts = strutils::split(canonical2, L'.');
45 for (size_t i = 0; i < parts.size(); ++i)
46 {
47 if (!path.empty())
48 path += L".";
49 path += parts[i];
50
51 String parentPath = (i == 0) ? L"" : path.substr(0, path.find_last_of(L'.'));
52
53 if (menuMap.find(path) != menuMap.end())
54 continue;
55
56 HMENU hParent = menuMap[parentPath];
57 if (!hParent) continue;
58
59 if (i < parts.size() - 1)
60 {
61 String str(parts[i].data(), parts[i].length());
62 HMENU hSubMenu = CreatePopupMenu();
63 menuMap[path] = hSubMenu;
64 if (parts[i] == L"S-Z" || parts[i] == L"M-R" || parts[i] == L"G-L" || parts[i] == L"A-F")
65 groupMenus[str] = hSubMenu;
66 else

Callers 1

ShowMenuMethod · 0.85

Calls 12

splitFunction · 0.85
GetDisplayNamesMethod · 0.80
trFunction · 0.70
format_string1Function · 0.50
emptyMethod · 0.45
sizeMethod · 0.45
findMethod · 0.45
endMethod · 0.45
dataMethod · 0.45
lengthMethod · 0.45
rbeginMethod · 0.45
rendMethod · 0.45

Tested by

no test coverage detected