EbookController::~EbookController() { StopFormattingThread(); EventMgr *evtMgr = ctrls->mainWnd->evtMgr; evtMgr->RemoveEventsForControl(ctrls->next); evtMgr->RemoveEventsForControl(ctrls->prev); evtMgr->RemoveEventsForControl(ctrls->progress); evtMgr->RemoveEventsForControl(ctrls->page); CloseCurrentDocument(); }
static void CreateAboutMuiWindow(HWND hwnd) { if (!gCursorHand) gCursorHand = LoadCursor(NULL, IDC_HAND); if (!gButtonUrlHandler) gButtonUrlHandler = new ButtonUrlHandler(); CreateAboutStyles(); mainWnd = new HwndWrapper(hwnd); mainWnd->centerContent = true; mainWnd->SetStyle(styleMainWnd); EventMgr *em = mainWnd->evtMgr; CrashIf(!em); Grid *grid = new Grid(styleGrid); Grid::CellData ld; SumatraLogo *logo = new SumatraLogo(); logo->SetStyle(styleLogo); ld.Set(logo, 0, 0, ElAlignCenter); ld.colSpan = 2; grid->Add(ld); Button *b = new Button(VERSION_TXT, styleBtnVer, styleBtnVer); ld.Set(b, 1, 0, ElAlignCenter); ld.colSpan = 2; ld.SetStyle(styleCellVer); grid->Add(ld); int rows = dimof(gAboutLayoutInfo); for (int n = 0; n < rows; n++) { const WCHAR *left = gAboutLayoutInfo[n].leftTxt; const WCHAR *right = gAboutLayoutInfo[n].rightTxt; const WCHAR *url = gAboutLayoutInfo[n].url; int row = n + 2; b = new Button(left, styleBtnLeft, styleBtnLeft); ld.Set(b, row, 0, ElAlignRight); ld.SetStyle(styleCellLeft); grid->Add(ld); if (url) { b = new Button(right, styleBtnRight, styleBtnRight); b->SetToolTip(url); b->hCursor = gCursorHand; } else { b = new Button(right, styleBtnLeft, styleBtnLeft); } em->EventsForControl(b)->Clicked.connect(gButtonUrlHandler, &ButtonUrlHandler::Clicked); ld.Set(b, row, 1); grid->Add(ld); } mainWnd->AddChild(grid); }
EbookController::~EbookController() { StopFormattingThread(); EventMgr *evtMgr = ctrls->mainWnd->evtMgr; // we must manually disconnect all events becuase evtMgr is // destroyed after EbookController, and EbookController destructor // will disconnect slots without deleting them, causing leaks // TODO: this seems fragile evtMgr->DisconnectEvents(this); CloseCurrentDocument(); }
EbookController::EbookController(EbookControls *ctrls) : ctrls(ctrls), fileBeingLoaded(NULL), pagesFromBeginning(NULL), pagesFromPage(NULL), currPageNo(0), pageShown(NULL), deletePageShown(false), pageSize(0, 0), formattingThread(NULL), formattingThreadNo(-1), startReparseIdx(-1) { EventMgr *em = ctrls->mainWnd->evtMgr; em->EventsForControl(ctrls->next)->Clicked.connect(this, &EbookController::ClickedNext); em->EventsForControl(ctrls->prev)->Clicked.connect(this, &EbookController::ClickedPrev); em->EventsForControl(ctrls->progress)->Clicked.connect(this, &EbookController::ClickedProgress); em->EventsForControl(ctrls->page)->SizeChanged.connect(this, &EbookController::SizeChangedPage); UpdateStatus(); }
EbookController::EbookController(EbookControls *ctrls, ControllerCallback *cb) : Controller(cb), ctrls(ctrls), pages(nullptr), incomingPages(nullptr), currPageNo(0), pageSize(0, 0), formattingThread(nullptr), formattingThreadNo(-1), currPageReparseIdx(0), handleMsgs(true), pageAnchorIds(nullptr), pageAnchorIdxs(nullptr), navHistoryIx(0) { EventMgr *em = ctrls->mainWnd->evtMgr; // TODO: do I need lambada here, can I just pass EbookController::ClickedNext directly? em->EventsForName("next")->Clicked = [=](Control *c, int x, int y) { this->ClickedNext(c, x, y); }; em->EventsForName("prev")->Clicked = [=](Control *c, int x, int y) { this->ClickedPrev(c, x, y); }; em->EventsForControl(ctrls->progress)->Clicked = [=](Control *c, int x, int y) { this->ClickedProgress(c, x, y); }; PageControl *page1 = ctrls->pagesLayout->GetPage1(); PageControl *page2 = ctrls->pagesLayout->GetPage2(); em->EventsForControl(page1)->SizeChanged = [=](Control *c, int dx, int dy) { this->SizeChangedPage(c, dx, dy); }; em->EventsForControl(page2)->SizeChanged = [=](Control *c, int dx, int dy) { this->SizeChangedPage(c, dx, dy); }; em->EventsForControl(page1)->Clicked = [=](Control *c, int x, int y) { this->ClickedPage1(c, x, y); }; em->EventsForControl(page2)->Clicked = [=](Control *c, int x, int y) { this->ClickedPage2(c, x, y); }; }
EbookController::EbookController(EbookControls *ctrls) : ctrls(ctrls), fileBeingLoaded(NULL), pagesFromBeginning(NULL), pagesFromPage(NULL), currPageNo(0), pageShown(NULL), deletePageShown(false), pageSize(0, 0), formattingThread(NULL), formattingThreadNo(-1), startReparseIdx(-1) { EventMgr *em = ctrls->mainWnd->evtMgr; em->EventsForName("next")->Clicked.connect(this, &EbookController::ClickedNext); em->EventsForName("prev")->Clicked.connect(this, &EbookController::ClickedPrev); em->EventsForControl(ctrls->progress)->Clicked.connect(this, &EbookController::ClickedProgress); PageControl *page1 = ctrls->pagesLayout->GetPage1(); em->EventsForControl(page1)->SizeChanged.connect(this, &EbookController::SizeChangedPage); PageControl *page2 = ctrls->pagesLayout->GetPage2(); em->EventsForControl(page2)->SizeChanged.connect(this, &EbookController::SizeChangedPage); SetSinglePage(); // TODO: for now we force single page mode UpdateStatus(); }