static HTREEITEM InsertFavTopLevelNode(HWND hwnd, DisplayState* fav, bool isExpanded) { WCHAR* s = nullptr; bool collapsed = fav->favorites->Count() == 1; if (collapsed) { isExpanded = false; } TV_INSERTSTRUCT tvinsert; tvinsert.hParent = nullptr; tvinsert.hInsertAfter = TVI_LAST; tvinsert.itemex.mask = TVIF_TEXT | TVIF_STATE | TVIF_PARAM; tvinsert.itemex.state = isExpanded ? TVIS_EXPANDED : 0; tvinsert.itemex.stateMask = TVIS_EXPANDED; tvinsert.itemex.lParam = 0; if (collapsed) { Favorite* fn = fav->favorites->At(0); tvinsert.itemex.lParam = (LPARAM)fn; s = FavCompactReadableName(fav, fn); tvinsert.itemex.pszText = s; } else { tvinsert.itemex.pszText = (WCHAR*)path::GetBaseName(fav->filePath); } HTREEITEM ret = TreeView_InsertItem(hwnd, &tvinsert); free(s); return ret; }
static void AppendFavMenuItems(HMENU m, DisplayState* f, UINT& idx, bool combined, bool isCurrent) { for (size_t i = 0; i < f->favorites->Count(); i++) { if (i >= MAX_FAV_MENUS) { return; } Favorite* fn = f->favorites->At(i); fn->menuId = idx++; ScopedMem<WCHAR> s; if (combined) { s.Set(FavCompactReadableName(f, fn, isCurrent)); } else { s.Set(FavReadableName(fn)); } AppendMenu(m, MF_STRING, (UINT_PTR)fn->menuId, win::menu::ToSafeString(s, s)); } }
static void AppendFavMenuItems(HMENU m, DisplayState* f, UINT& idx, bool combined, bool isCurrent) { for (size_t i = 0; i < f->favorites->size(); i++) { if (i >= MAX_FAV_MENUS) { return; } Favorite* fn = f->favorites->at(i); fn->menuId = idx++; AutoFreeW s; if (combined) { s.Set(FavCompactReadableName(f, fn, isCurrent)); } else { s.Set(FavReadableName(fn)); } auto str = win::menu::ToSafeString(s); AppendMenuW(m, MF_STRING, (UINT_PTR)fn->menuId, str); } }