// Refresh the tab's title void TabsOnChangedDoc(WindowInfo* win) { TabInfo* tab = win->currentTab; CrashIf(!tab != !win->tabs.size()); if (!tab) return; CrashIf(win->tabs.Find(tab) != TabCtrl_GetCurSel(win->hwndTabBar)); VerifyTabInfo(win, tab); SetTabTitle(win, tab); }
// Refresh the tab's title void TabsOnChangedDoc(WindowInfo *win) { if (win->tabs.Count() == 0) return; int current = TabCtrl_GetCurSel(win->hwndTabBar); TabInfo *tdata = win->currentTab; CrashIf(!tdata); VerifyTabInfo(win, tdata); TCITEM tcs; tcs.mask = TCIF_TEXT; tcs.pszText = (WCHAR *)tdata->tabTitle; TabCtrl_SetItem(win->hwndTabBar, current, &tcs); UpdateCurrentTabBgColor(win); }
// On load of a new document we insert a new tab item in the tab bar. void TabsOnLoadedDoc(WindowInfo *win) { if (!win) return; TabInfo *tab = win->tabs.Last(); VerifyTabInfo(win, tab); TCITEM tcs; tcs.mask = TCIF_TEXT; tcs.pszText = (WCHAR *)tab->GetTabTitle(); int index = (int)win->tabs.Count() - 1; if (-1 != TabCtrl_InsertItem(win->hwndTabBar, index, &tcs)) { TabCtrl_SetCurSel(win->hwndTabBar, index); UpdateTabWidth(win); } else { // TODO: what now? CrashIf(true); } }
// Must be called when the active tab is losing selection. // This happens when a new document is loaded or when another tab is selected. void SaveCurrentTabInfo(WindowInfo* win) { if (!win) return; int current = TabCtrl_GetCurSel(win->hwndTabBar); if (-1 == current) return; CrashIf(win->currentTab != win->tabs.at(current)); TabInfo* tdata = win->currentTab; CrashIf(!tdata); if (win->tocLoaded) { tdata->tocState.Reset(); HTREEITEM hRoot = win->tocTreeCtrl->GetRoot(); if (hRoot) UpdateTocExpansionState(tdata, win->tocTreeCtrl, hRoot); } VerifyTabInfo(win, tdata); // update the selection history win->tabSelectionHistory->Remove(tdata); win->tabSelectionHistory->Push(tdata); }