virtual void Execute() { if (!WindowInfoStillValid(win)) return; if (win->printThread != thread) return; win->printThread = NULL; }
static void TabNotification(WindowInfo *win, UINT code, int idx1, int idx2) { if (!WindowInfoStillValid(win)) { return; } NMHDR nmhdr = { nullptr, 0, code }; if (TabsOnNotify(win, (LPARAM)&nmhdr, idx1, idx2)) { return; } TabPainter *tab = (TabPainter *)GetWindowLongPtr(win->hwndTabBar, GWLP_USERDATA); if (T_CLOSING == code) { // if we have permission to close the tab tab->Invalidate(tab->nextTab); tab->xClicked = tab->nextTab; return; } if (TCN_SELCHANGING == code) { // if we have permission to select the tab tab->Invalidate(tab->current); tab->Invalidate(tab->nextTab); tab->current = tab->nextTab; // send notification that the tab is selected nmhdr.code = TCN_SELCHANGE; TabsOnNotify(win, (LPARAM)&nmhdr); } }
// called when printing has been canceled virtual void RemoveNotification(NotificationWnd *wnd) { isCanceled = true; cookie.Abort(); this->wnd = NULL; if (WindowInfoStillValid(win)) win->notifications->RemoveNotification(wnd); }
virtual void UpdateProgress(int current, int total) { uitask::Post([=] { if (WindowInfoStillValid(win) && win->notifications->Contains(wnd)) { wnd->UpdateProgress(current, total); } }); }
virtual void Execute() { if (WindowInfoStillValid(win) && !win->findCanceled) { if (win->notifications->Contains(wnd)) { wnd->UpdateProgress(current, total); } else { // the search has been canceled by closing the notification win->findCanceled = true; } } }
static void GoToFavorite(WindowInfo* win, int pageNo) { if (!WindowInfoStillValid(win)) { return; } if (win->IsDocLoaded() && win->ctrl->ValidPageNo(pageNo)) { win->ctrl->GoToPage(pageNo, true); } // we might have been invoked by clicking on a tree view // switch focus so that keyboard navigation works, which enables // a fluid experience win->Focus(); }
static void GoToTocLinkTask(WindowInfo *win, DocTocItem *tocItem, TabInfo *tab, Controller *ctrl) { // tocItem is invalid if the Controller has been replaced if (!WindowInfoStillValid(win) || win->currentTab != tab || tab->ctrl != ctrl) return; // make sure that the tree item that the user selected // isn't unselected in UpdateTocSelection right again win->tocKeepSelection = true; if (tocItem->GetLink()) win->linkHandler->GotoLink(tocItem->GetLink()); else if (tocItem->pageNo) ctrl->GoToPage(tocItem->pageNo, true); win->tocKeepSelection = false; }
static DWORD WINAPI PrintThread(LPVOID data) { PrintThreadData *threadData = (PrintThreadData *)data; WindowInfo *win = threadData->win; // wait for PrintToDeviceOnThread to return so that we // close the correct handle to the current printing thread while (!win->printThread) Sleep(1); HANDLE thread = threadData->thread = win->printThread; PrintToDevice(*threadData->data, threadData, &threadData->cookie); uitask::Post([=] { if (WindowInfoStillValid(win) && thread == win->printThread) { win->printThread = nullptr; } delete threadData; }); return 0; }
virtual void Execute() { if (!WindowInfoStillValid(win)) return; if (win->findThread != thread) { // Race condition: FindTextOnThread/AbortFinding was // called after the previous find thread ended but // before this FindEndTask could be executed return; } if (!win->IsDocLoaded()) { // the UI has already been disabled and hidden } else if (textSel) { ShowSearchResult(*win, textSel, wasModifiedCanceled); ftd->HideUI(true, loopedAround); } else { // nothing found or search canceled ClearSearchResult(win); ftd->HideUI(false, !wasModifiedCanceled); } win->findThread = NULL; }
virtual bool WasCanceled() { return isCanceled || !WindowInfoStillValid(win) || win->printCanceled; }
virtual void Execute() { if (WindowInfoStillValid(win) && win->notifications->Contains(wnd)) wnd->UpdateProgress(current, total); }
virtual bool WasCanceled() { return !WindowInfoStillValid(win) || win->findCanceled; }