Changeset 1307
- Timestamp:
- 11/09/07 18:54:51 (11 months ago)
- Location:
- trunk/src/buzelib
- Files:
-
- 20 modified
-
BuzeConfiguration.cpp (modified) (1 diff)
-
BuzeConfiguration.h (modified) (1 diff)
-
Document.cpp (modified) (1 diff)
-
Document.h (modified) (1 diff)
-
MachineDropTarget.cpp (modified) (1 diff)
-
MachineDropTarget.h (modified) (2 diffs)
-
MachineFolderView.cpp (modified) (8 diffs)
-
MachineFolderView.h (modified) (2 diffs)
-
MachineView.cpp (modified) (1 diff)
-
MachineView.h (modified) (1 diff)
-
MainFrm.cpp (modified) (12 diffs)
-
MainFrm.h (modified) (4 diffs)
-
Properties.cpp (modified) (2 diffs)
-
Properties.h (modified) (1 diff)
-
Utils/DragDropImpl.cpp (modified) (2 diffs)
-
Utils/DragDropImpl.h (modified) (1 diff)
-
Utils/MachineIndex.cpp (modified) (5 diffs)
-
Utils/MachineIndex.h (modified) (3 diffs)
-
buze.rc (modified) (2 diffs)
-
resource.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/buzelib/BuzeConfiguration.cpp
r1304 r1307 186 186 } 187 187 188 std::string CConfiguration::getRecentSong(int index) { 189 string recent; 190 191 if (!getConfigString("Settings", "RecentSong" + stringFromInt(index), &recent)) 192 return ""; 193 return recent; 194 } 195 196 void CConfiguration::insertRecentSong(std::string fileName) { 197 std::vector<std::string> recs; 198 std::string str; 199 int i; 200 201 for (i = 0; i < getMaxRecentSongs(); ++i) { 202 str.clear(); 203 getConfigString("Settings", "RecentSong" + stringFromInt(i), &(str)); 204 if (str == fileName) { 205 if(!i) 206 return; 207 continue; 208 } 209 if (str.size()) 210 recs.push_back(str); 211 } 212 213 recs.insert(recs.begin(), fileName); 214 215 // resave all recent songs 216 217 for(i = 0; i < getMaxRecentSongs() && i < recs.size(); ++i) { 218 setConfigString("Settings", "RecentSong" + stringFromInt(i), recs[i]); 219 } 220 } 221 222 int CConfiguration::getMaxRecentSongs() { 223 DWORD dw = 10; 224 getConfigNumber("Settings", "MaxRecentSongs", &dw); 225 if(dw > 100) 226 dw = 100; 227 return dw; 228 } 229 230 void CConfiguration::setMaxRecentSongs(int max) { 231 setConfigNumber("Settings", "MaxRecentSongs", max); 232 } 233 188 234 std::string CConfiguration::getExternalWaveEditor() { 189 235 string cmd; -
trunk/src/buzelib/BuzeConfiguration.h
r1304 r1307 28 28 std::string getTheme(); 29 29 void setTheme(std::string theme); 30 31 std::string getRecentSong(int index); 32 void insertRecentSong(std::string fileName); 33 int getMaxRecentSongs(); 34 void setMaxRecentSongs(int max); 30 35 31 36 void setMachineParameterVisibility(std::string uri, int parameterIndex, bool state); -
trunk/src/buzelib/Document.cpp
r1297 r1307 1021 1021 } 1022 1022 1023 void CDocument::setWaveLevelSampleRate(zzub::wave_level* entry, int rate) { 1024 entry->samples_per_second = rate; 1025 updateAllViews(0, UpdateSelectedWaveEntry, entry); 1026 1027 } 1028 1029 int CDocument::getWaveLevelSampleRate(zzub::wave_level* entry) { 1030 return entry->samples_per_second; 1031 } 1032 1023 1033 1024 1034 -
trunk/src/buzelib/Document.h
r1293 r1307 243 243 void setWaveLevelType(zzub::wave_level* entry, int bits); 244 244 int getWaveLevelType(zzub::wave_level* entry); 245 void setWaveLevelSampleRate(zzub::wave_level* entry, int rate); 246 int getWaveLevelSampleRate(zzub::wave_level* entry); 245 247 246 248 // machine loading properties -
trunk/src/buzelib/MachineDropTarget.cpp
r1273 r1307 26 26 CDropTarget::CDropTarget(CDropTargetWindow* dtw):CIDropTarget(dtw->hWndTarget) { 27 27 dropTargetWindow = dtw; 28 } 29 30 bool CDropTarget::OnDragOver(const POINTL& pt, FORMATETC* pFmtEtc, STGMEDIUM& medium, DWORD *pdwEffect) { 31 return dropTargetWindow->OnDragOver(pt, pFmtEtc, medium, pdwEffect); 32 } 33 34 void CDropTarget::OnDragLeave() { 35 dropTargetWindow->OnDragLeave(); 28 36 } 29 37 -
trunk/src/buzelib/MachineDropTarget.h
r1218 r1307 6 6 7 7 virtual bool OnDrop(const POINTL& pt, FORMATETC* pFmtEtc, STGMEDIUM& medium, DWORD *pdwEffect) = 0; 8 virtual bool OnDragOver(const POINTL& pt, FORMATETC* pFmtEtc, STGMEDIUM& medium,DWORD *pdwEffect) = 0; 9 virtual void OnDragLeave() = 0; 8 10 }; 9 11 … … 13 15 CDropTarget(CDropTargetWindow* dtw); 14 16 virtual bool OnDrop(const POINTL& pt, FORMATETC* pFmtEtc, STGMEDIUM& medium, DWORD *pdwEffect); 15 17 virtual bool OnDragOver(const POINTL& pt, FORMATETC* pFmtEtc, STGMEDIUM& medium,DWORD *pdwEffect); 18 virtual void OnDragLeave(); 16 19 }; 17 20 -
trunk/src/buzelib/MachineFolderView.cpp
r1273 r1307 39 39 } 40 40 41 HTREEITEM g_hCurrentDragItem = 0; 42 extern MachineMenu* g_effectMenu; 43 extern MachineMenu* g_generatorMenu; 44 41 45 LRESULT MachineFolderView::OnBeginDrag(int idCtrl, LPNMHDR pnmh, BOOL& bHandled) { 42 46 43 47 NMTREEVIEW* pnmtv = (NMTREEVIEW*)pnmh; 44 48 45 const char* machineFileName = (const char*)treeCtrl.GetItemData(pnmtv->itemNew.hItem); 49 g_hCurrentDragItem = pnmtv->itemNew.hItem; 50 const char* machineFileName = (const char*)treeCtrl.GetItemData(g_hCurrentDragItem); 46 51 if (machineFileName == 0) return 0; 47 52 … … 79 84 } 80 85 81 void MachineFolderView::bindMachineItems(MachineMenu* item, HTREEITEM parent) { 86 int MachineFolderView::bindMachineItems(MachineMenu* item, HTREEITEM parent) { 87 88 DWORD dwEnabled = 0; 89 mainFrame->document->configuration->getConfigNumber("Settings", "IndexEditing", &dwEnabled); 90 91 int machineCounter = 0; 82 92 83 93 for (size_t i = 0; i < item->items.size(); i++) { … … 113 123 strcat(fileName, mi->instrumentName.c_str()); 114 124 } 125 machineCounter++; 115 126 } 116 127 … … 118 129 treeCtrl.SetItemData(treeItem, (DWORD)fileName); 119 130 120 if (ii->type == 0) 121 bindMachineItems((MachineMenu*)ii, treeItem); 122 } 123 } 131 ii->userData = treeItem; 132 133 if (ii->type == 0) { 134 int bindCount = bindMachineItems((MachineMenu*)ii, treeItem); 135 // keep even machine menus because we might want to drop something into them 136 137 if (!bindCount && dwEnabled!=0) { 138 HTREEITEM placeholder = treeCtrl.InsertItem( "(drop on me)", treeItem, TVI_LAST); 139 treeCtrl.SetItemData(treeItem, (DWORD)0); 140 } 141 machineCounter += bindCount; 142 } 143 } 144 } 145 return machineCounter; 124 146 } 125 147 … … 154 176 LRESULT MachineFolderView::OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) { 155 177 using namespace std; 156 treeCtrl.Create(this->m_hWnd, rcDefault, NULL, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | TVS_HASLINES | TVS_LINESATROOT | TVS_SHOWSELALWAYS |TVS_HASBUTTONS, WS_EX_CLIENTEDGE, IDC_MACHINETREE);178 treeCtrl.Create(this->m_hWnd, rcDefault, NULL, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | TVS_HASLINES | TVS_LINESATROOT | TVS_SHOWSELALWAYS | TVS_HASBUTTONS | TVS_TRACKSELECT, WS_EX_CLIENTEDGE, IDC_MACHINETREE); 157 179 158 180 CImageList il; … … 163 185 CreateThread(0, 0, PopulateMachinesThread, this, 0, &dwId); 164 186 165 /* 166 bindMachineItems(&mainFrame->document->machineIndex.root, hMachines); 167 168 treeCtrl.Expand(hMachines); 169 170 for (int i = 0; i<player->getMachineLoaders(); i++) { 171 pluginloader* loader = player->getMachineLoader(i); 172 HTREEITEM hmachineItem; 173 if (loader->getType() == plugin_type_effect) 174 hmachineItem = treeCtrl.InsertItem( loader->getName(), hEffectItem, TVI_LAST); else 175 hmachineItem = treeCtrl.InsertItem( loader->getName(), hGeneratorItem, TVI_LAST); 176 treeCtrl.SetItemData(hmachineItem, (DWORD)loader->getUri()); 177 }*/ 178 179 /* 180 if (!createDropTarget(*this)) return 0; 187 if (!createDropTarget(*this)) return 0; 181 188 FORMATETC ftetc = {0}; 182 189 ftetc.cfFormat = CF_TEXT; … … 187 194 ftetc.cfFormat=CF_HDROP; 188 195 dropTarget->AddSuportedFormat(ftetc); 189 */ 196 190 197 return 0; 191 198 } … … 220 227 221 228 LRESULT MachineFolderView::OnViewProperties(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) { 222 return 0;229 return 0; 223 230 } 224 231 225 232 LRESULT MachineFolderView::OnMouseMove(UINT /*uMsg*/, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/) { 226 /* 227 not called while dragging - update CIDropTarget 228 229 POINT pt = { LOWORD(lParam), HIWORD(lParam) }; 230 UINT flags; 233 return 0; 234 } 235 236 LRESULT MachineFolderView::OnLButtonUp(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) { 237 return 0; 238 } 239 240 241 // copyitem / copybranch by Zafir Anjum 242 // http://www.codeguru.com/cpp/controls/treeview/dragdrop/article.php/c695/ 243 244 HTREEITEM CopyItem(CTreeViewCtrl& treeView, HTREEITEM hItem, HTREEITEM htiNewParent, HTREEITEM htiAfter = TVI_LAST) { 245 TV_INSERTSTRUCT tvstruct; 246 HTREEITEM hNewItem; 247 248 // get information of the source item 249 tvstruct.item.hItem = hItem; 250 tvstruct.item.mask = TVIF_CHILDREN | TVIF_HANDLE | TVIF_IMAGE | TVIF_SELECTEDIMAGE; 251 treeView.GetItem(&tvstruct.item); 252 char itemText[1024]; 253 treeView.GetItemText( hItem, itemText, 1024 ); 254 255 tvstruct.item.cchTextMax = strlen(itemText); 256 tvstruct.item.pszText = itemText; 257 258 // Insert the item at proper location 259 tvstruct.hParent = htiNewParent; 260 tvstruct.hInsertAfter = htiAfter; 261 tvstruct.item.mask = TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_TEXT; 262 hNewItem = treeView.InsertItem(&tvstruct); 263 264 // Now copy item data and item state. 265 treeView.SetItemData( hNewItem, treeView.GetItemData( hItem )); 266 treeView.SetItemState( hNewItem, treeView.GetItemState( hItem, TVIS_STATEIMAGEMASK ), TVIS_STATEIMAGEMASK ); 267 268 return hNewItem; 269 } 270 271 HTREEITEM CopyBranch(CTreeViewCtrl& treeView, HTREEITEM htiBranch, HTREEITEM htiNewParent, HTREEITEM htiAfter = TVI_LAST) { 272 HTREEITEM hChild; 273 274 HTREEITEM hNewItem = CopyItem(treeView, htiBranch, htiNewParent, htiAfter); 275 hChild = treeView.GetChildItem(htiBranch); 276 while (hChild != NULL) { 277 // recursively transfer all the items 278 CopyBranch(treeView, hChild, hNewItem); 279 hChild = treeView.GetNextSiblingItem( hChild ); 280 } 281 return hNewItem; 282 } 283 284 CMenuHandle FindMenuItem(CMenuHandle menuItem, std::string text, int& pos) { 285 char menuText[1024]; 286 287 pos = -1; 288 for (UINT i = 0; i < menuItem.GetMenuItemCount(); i++) { 289 menuItem.GetMenuString(i, menuText, 1024, MF_BYPOSITION); 290 if (text == menuText) { 291 pos = i; 292 return menuItem; 293 } 294 CMenuHandle submenu = menuItem.GetSubMenu(i); 295 if (submenu.m_hMenu == 0) continue; 296 297 submenu = FindMenuItem(submenu, text, pos); 298 if (submenu.m_hMenu != 0) return submenu; 299 300 } 301 return CMenuHandle(); 302 } 303 304 void* GetMenuItemData(CMenuHandle menu, int pos) { 305 MENUITEMINFO mii; 306 memset(&mii, 0, sizeof(MENUITEMINFO)); 307 mii.cbSize = sizeof(MENUITEMINFO); 308 mii.fMask = MIIM_DATA; 309 menu.GetMenuItemInfo(pos, TRUE, &mii); 310 return (void*)mii.dwItemData; 311 } 312 313 CMenuHandle FindMenuItemByData(CMenuHandle menuItem, void* data, int& pos) { 314 char menuText[1024]; 315 316 pos = -1; 317 for (UINT i = 0; i < menuItem.GetMenuItemCount(); i++) { 318 void* itemData = GetMenuItemData(menuItem, i); 319 if (itemData == data) { 320 pos = i; 321 return menuItem; 322 } 323 CMenuHandle submenu = menuItem.GetSubMenu(i); 324 if (submenu.m_hMenu == 0) continue; 325 326 submenu = FindMenuItemByData(submenu, data, pos); 327 if (submenu.m_hMenu != 0) return submenu; 328 329 } 330 return CMenuHandle(); 331 } 332 333 int CountTreeItems(CTreeViewCtrl& tree, HTREEITEM hItem = NULL, BOOL recurse = TRUE) { 334 int count = 0; 335 if (hItem == NULL) 336 hItem = tree.GetSelectedItem(); 337 338 if (tree.ItemHasChildren(hItem)) { 339 hItem = tree.GetNextItem(hItem, TVGN_CHILD); 340 while (hItem) { 341 count++; 342 if (recurse) 343 count += CountTreeItems(tree, hItem, recurse); 344 hItem = tree.GetNextItem(hItem, TVGN_NEXT); 345 } 346 } 347 return count; 348 } 349 350 #include "Utils/MachineIndex.h" 351 352 extern void InsertMenuItemFromIndexItem(IndexItem* ii, CMenuHandle parentMenu, int pos); 353 354 bool MachineFolderView::OnDropMachine(std::string machineName, std::string instrumentName, int x, int y) { 355 treeCtrl.RemoveInsertMark(); 356 357 DWORD dwEnabled = 0; 358 mainFrame->document->configuration->getConfigNumber("Settings", "IndexEditing", &dwEnabled); 359 if (!dwEnabled) return true; 360 361 POINT pt = { x, y }; 362 UINT flags; 363 HTREEITEM dropItem = treeCtrl.HitTest(pt, &flags); 364 if (dropItem == 0) return true; 365 366 // TODO: if dropped item is an expandable thing and its expanded, we want to add the dragItem as the first child here 367 368 IndexItem* dropIndex = mainFrame->document->machineIndex.root.getItemByData(dropItem); 369 IndexItem* dragIndex = mainFrame->document->machineIndex.root.getItemByData(g_hCurrentDragItem); 370 371 if (dropIndex == dragIndex) return true; 372 373 // are we dropping in a machine list? 374 if (dropIndex && dropIndex->type == 0) { 375 MachineMenu* mm = (MachineMenu*)dropIndex; 376 // are we dropping on a preloaded machine? 377 if (mm->preloadReplaced != 0) return true; 378 } else 379 if (dropIndex && dropIndex->type == 1) { 380 if (dropIndex->parent->type == 0) { 381 MachineMenu* mm = (MachineMenu*)dropIndex->parent; 382 // are we dropping inside a preloaded machine? 383 if (mm->preloadReplaced != 0) return true; 384 } 385 } 386 387 HTREEITEM dropParent = treeCtrl.GetParentItem(dropItem); 388 HTREEITEM dragParent = treeCtrl.GetParentItem(g_hCurrentDragItem); 389 390 char dragItemText[1024]; 391 treeCtrl.GetItemText(g_hCurrentDragItem, dragItemText, 1024); 392 char dropItemText[1024]; 393 treeCtrl.GetItemText(dropItem, dropItemText, 1024); 394 395 treeCtrl.SetRedraw(FALSE); 396 397 HTREEITEM dragCopy = CopyBranch(treeCtrl, g_hCurrentDragItem, dropParent, dropItem); 398 if (dragIndex != 0) { 399 treeCtrl.DeleteItem(g_hCurrentDragItem); 400 int dragFromSiblings = CountTreeItems(treeCtrl, dragParent); 401 if (dragFromSiblings == 0) { 402 HTREEITEM placeholder = treeCtrl.InsertItem("(drop on me)", dragParent, TVI_LAST); 403 treeCtrl.SetItemData(dragParent, (DWORD)0); 404 } 405 } 406 407 bool created = false; 408 if (dragIndex == 0) { 409 // we dragged an item from out-of-index into the index, so we create a new item for it 410 zzub::pluginloader* loader = mainFrame->player->getMachineLoader(machineName); 411 412 MachineItem* mi = new MachineItem(); 413 mi->label = loader->plugin_info->name; 414 mi->fileName = loader->plugin_info->name; 415 mi->fullMachineName = machineName; 416 mi->instrumentName = instrumentName; 417 dragIndex = mi; 418 419 created = true; 420 } 421 dragIndex->userData = dragCopy; 422 423 if (!created) dragIndex->parent->removeItem(dragIndex); 424 if (dropIndex != 0) { 425 dropIndex->parent->insertAfter(dragIndex, dropIndex); 426 } else { 427 // need to find parent of where we are dropping, in case it is a drop target 428 if ((std::string)dropItemText == "(drop on me)") { 429 treeCtrl.DeleteItem(dropItem); 430 } 431 IndexItem* parentIndex = mainFrame->document->machineIndex.root.getItemByData(dropParent); 432 if (parentIndex == 0) return true; 433 parentIndex->append(dragIndex); 434 } 435 436 treeCtrl.SetRedraw(TRUE); 437 438 IndexItem* generatorParent = g_generatorMenu->parent; 439 IndexItem* effectParent = g_effectMenu->parent; 440 441 // temporarily remove the Unsorted Generators and Unsorted Effects 442 generatorParent->removeItem(g_generatorMenu); 443 effectParent->removeItem(g_effectMenu); 444 445 // we could also revert the PlaceGeneratorHere-thing but its not needed 446 mainFrame->document->machineIndex.save(_Module.mapPath("Gear/index.txt").c_str()); 447 448 generatorParent->append(g_generatorMenu); 449 effectParent->append(g_effectMenu); 450 451 g_hCurrentDragItem = 0; 452 453 // rebuild right-click menu in machine view because we are now out of sync 454 455 int machines = 0; 456 if (mainFrame->createMachineMenu.IsMenu()) mainFrame->createMachineMenu.DestroyMenu(); 457 mainFrame->createMachineMenu.CreatePopupMenu(); 458 mainFrame->insertMachineMenu(mainFrame->createMachineMenu.m_hMenu, mainFrame->document->machineIndex.root, machines); 459 460 return true; 461 } 462 463 bool MachineFolderView::OnDragOver(const POINTL& ptl, FORMATETC* pFmtEtc, STGMEDIUM& medium,DWORD *pdwEffect) { 464 POINT pt = { ptl.x, ptl.y }; 465 treeCtrl.ScreenToClient(&pt); 466 UINT flags; 231 467 HTREEITEM item = treeCtrl.HitTest(pt, &flags); 232 if (item != 0) { 233 treeCtrl.SetInsertMark(item, TRUE);//TVM_SETINSERTMARK 234 }*/ 235 return 0; 236 } 237 238 LRESULT MachineFolderView::OnLButtonUp(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) { 239 return 0; 240 } 241 242 243 bool MachineFolderView::OnDropMachine(std::string machineName, std::string instrumentName, int x, int y) { 244 245 return true; 246 } 468 if (item == 0) return true; 469 470 treeCtrl.SetInsertMark(item, TRUE); 471 472 return true; 473 } 474 475 void MachineFolderView::OnDragLeave() { 476 treeCtrl.RemoveInsertMark(); 477 } -
trunk/src/buzelib/MachineFolderView.h
r1273 r1307 54 54 MachineFolderView(CMainFrame* mainFrm, ClientViewListener* clientViewListener); 55 55 ~MachineFolderView(void); 56 voidbindMachineItems(MachineMenu* item, HTREEITEM parent);56 int bindMachineItems(MachineMenu* item, HTREEITEM parent); 57 57 58 58 void loadFromIndex(); … … 70 70 LRESULT OnViewProperties(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/); 71 71 bool OnDropMachine(std::string machineName, std::string instrumentName, int x, int y); 72 bool OnDragOver(const POINTL& pt, FORMATETC* pFmtEtc, STGMEDIUM& medium,DWORD *pdwEffect); 73 void OnDragLeave(); 72 74 73 75 public: -
trunk/src/buzelib/MachineView.cpp
r1304 r1307 1690 1690 } 1691 1691 1692 bool CMachineView::OnDragOver(const POINTL& pt, FORMATETC* pFmtEtc, STGMEDIUM& medium,DWORD *pdwEffect) { 1693 // TODO: maybe check if we are over a connection, a group machine or something 1694 return true; 1695 } 1696 1697 void CMachineView::OnDragLeave() { 1698 } 1699 1692 1700 bool CMachineView::OnDropMachine(std::string machineName, std::string instrumentName, int x, int y) { 1693 1701 -
trunk/src/buzelib/MachineView.h
r1302 r1307 147 147 void OnUpdate(CView* pSender, LPARAM lHint, LPVOID pHint); 148 148 149 bool OnDragOver(const POINTL& pt, FORMATETC* pFmtEtc, STGMEDIUM& medium,DWORD *pdwEffect); 150 void OnDragLeave(); 149 151 bool OnDropMachine(std::string machineName, std::string instrumentName, int x, int y); 150 152 -
trunk/src/buzelib/MainFrm.cpp
r1304 r1307 1350 1350 1351 1351 initializeThemes(); 1352 initializeRecent(); 1352 1353 1353 1354 if (!deserializeFromFile(_Module.mapPath("Gear/gui.xml"))) { … … 1547 1548 document->setCurrentFile(fileName); 1548 1549 setWindowTitle(document->currentFileName); 1550 setMostRecent(fileName); 1549 1551 } 1550 1552 //player->getMaster()->releaseEvent(progressEventID); … … 2136 2138 } 2137 2139 2140 void SetMenuItemData(CMenuHandle menu, int pos, void* data) { 2141 MENUITEMINFO mii; 2142 memset(&mii, 0, sizeof(MENUITEMINFO)); 2143 mii.cbSize = sizeof(MENUITEMINFO); 2144 mii.fMask = MIIM_DATA; 2145 mii.dwItemData = (DWORD)data; 2146 menu.SetMenuItemInfo(pos, TRUE, &mii); 2147 } 2148 2138 2149 2139 2150 int CMainFrame::insertMachineMenu(CMenuHandle parentMenu, MachineMenu& parentMachineMenu, int& index) { 2140 2151 2141 int visibleCounter=0; 2142 int maxEntriesPerPage=40; 2143 2144 bool prevWasSep=false; 2152 int visibleCounter = 0; 2153 int maxEntriesPerPage; 2145 2154 2146 2155 CWindow desktop(GetDesktopWindow()); … … 2148 2157 RECT rcClient; 2149 2158 desktop.GetClientRect(&rcClient); 2150 maxEntriesPerPage =(rcClient.bottom-100)/16;2151 2152 for (size_t i =0; i<parentMachineMenu.items.size(); i++) {2159 maxEntriesPerPage = (rcClient.bottom-100)/16; 2160 2161 for (size_t i = 0; i < parentMachineMenu.items.size(); i++) { 2153 2162 2154 2163 DWORD extraFlags = ((visibleCounter%maxEntriesPerPage)==(maxEntriesPerPage-1)?MF_MENUBARBREAK:0); 2155 2164 2156 IndexItem* ii =parentMachineMenu.items[i];2157 if (ii->hide ==true) continue;2158 if (ii->type ==0) {2159 MachineMenu& mmenu =*(MachineMenu*)ii;2165 IndexItem* ii = parentMachineMenu.items[i]; 2166 if (ii->hide == true) continue; 2167 if (ii->type == 0) { 2168 MachineMenu& mmenu = *(MachineMenu*)ii; 2160 2169 2161 2170 CMenuHandle newMenu; 2162 2171 newMenu.CreatePopupMenu(); 2163 2172 2164 // TODO: only insert if there are any child nodes worth mentioning 2165 if (!insertMachineMenu(newMenu.m_hMenu, mmenu, index)) continue; 2173 // only insert if there are any child nodes worth mentioning 2174 int insertedCount = insertMachineMenu(newMenu.m_hMenu, mmenu, index); 2175 if (!insertedCount) continue; 2166 2176 2167 2177 parentMenu.InsertMenu(-1, MF_BYPOSITION|MF_POPUP|extraFlags, (UINT_PTR)newMenu.m_hMenu, ii->label.c_str()); 2168 visibleCounter++;2169 prevWasSep=false;2178 SetMenuItemData(parentMenu, parentMenu.GetMenuItemCount() - 1, ii); 2179 visibleCounter +=
