MCPcopy Create free account
hub / github.com/SOUI2/soui / InsertMenu

Method InsertMenu

SOUI/src/helper/SMenuEx.cpp:1117–1161  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1115 }
1116
1117 BOOL SMenuEx::InsertMenu(UINT uPos, UINT uFlag, int nId, LPCTSTR lpNewItem)
1118 {
1119 SMenuExRoot *pMenuRoot = sobj_cast<SMenuExRoot>(GetRoot()->GetWindow(GSW_FIRSTCHILD));
1120 SASSERT(pMenuRoot);
1121 SWindow * pItemRef = FindItem(uPos,uFlag);
1122
1123 if (uFlag & MF_BYCOMMAND && !pItemRef)
1124 return FALSE;
1125
1126 SMenuExItem *pMenuItem = (SMenuExItem*)pMenuRoot->CreateMenuItem((uFlag & MF_SEPARATOR) ? SMenuExSep::GetClassName() : SMenuExItem::GetClassName());
1127
1128 if (pItemRef)
1129 {
1130 SWindow *pRefPrev = pItemRef->GetWindow(GSW_PREVSIBLING);
1131 if (pRefPrev)
1132 {
1133 pRefPrev->GetParent()->InsertChild(pMenuItem, pRefPrev);
1134 }
1135 else
1136 {
1137 pItemRef->GetParent()->InsertChild(pMenuItem, ICWND_FIRST);
1138 }
1139 }
1140 else
1141 {
1142 pMenuRoot->InsertChild(pMenuItem);
1143 }
1144 if (!(uFlag & MF_SEPARATOR))
1145 {
1146 pMenuItem->SetWindowText(lpNewItem);
1147 if (uFlag & MF_POPUP)
1148 {
1149 pMenuItem->m_pSubMenu = new SMenuEx(pMenuItem);
1150 pMenuItem->m_pSubMenu->IniNullMenu(pMenuRoot);
1151 }
1152
1153 pMenuItem->SetAttribute(L"ID", SStringW().Format(L"%d",nId));
1154 if (uFlag & MF_CHECKED)
1155 {
1156 pMenuItem->SetAttribute(L"check", L"1");
1157 }
1158 }
1159
1160 return TRUE;
1161 }
1162
1163 BOOL SMenuEx::IniNullMenu(SMenuExRoot *ParentRoot)
1164 {

Callers

nothing calls this directly

Calls 11

GetRootFunction · 0.85
GetClassNameFunction · 0.85
CreateMenuItemMethod · 0.80
IniNullMenuMethod · 0.80
FindItemFunction · 0.50
GetWindowMethod · 0.45
InsertChildMethod · 0.45
GetParentMethod · 0.45
SetWindowTextMethod · 0.45
SetAttributeMethod · 0.45
FormatMethod · 0.45

Tested by

no test coverage detected