void CardViewer::onPaint(wxPaintEvent&) { #ifdef _DEBUG // we don't want recursion if (inOnPaint()) { wxTrap(); } WITH_DYNAMIC_ARG(inOnPaint, true); #endif wxSize cs = GetClientSize(); if (!buffer.Ok() || buffer.GetWidth() != cs.GetWidth() || buffer.GetHeight() != cs.GetHeight()) { buffer = Bitmap(cs.GetWidth(), cs.GetHeight()); up_to_date = false; } wxBufferedPaintDC dc(this, buffer); // scrolling // int dx = GetScrollPos(wxHORIZONTAL), dy = GetScrollPos(wxVERTICAL); // dc.SetDeviceOrigin(-dx, -dy); wxRegion clip = GetUpdateRegion(); // clip.Offset(dx, dy); dc.SetDeviceClippingRegion(clip); // draw if (!up_to_date) { up_to_date = true; try { draw(dc); } CATCH_ALL_ERRORS(false); // don't show message boxes in onPaint! }
void CApplicationImpl::OpenLastDataFile() { // open last datafile CString csLastFile; CApplicationImpl::Get().m_mru.GetFromList(ID_FILE_MRU_FIRST, csLastFile); CString csDefFileName = GetDefaultDataFileName(); if (csLastFile.IsEmpty()) { csLastFile = csDefFileName; } else if (csLastFile != csDefFileName && !::PathFileExists(csLastFile)) { GuiUtils::ErrorMessage(resutils::resstring_fmt(IDS_FILE_NOT_FOUND, csLastFile).c_str()); csLastFile = csDefFileName; } try { OpenDataFile(csLastFile); return; // no error } CATCH_ALL_ERRORS(GetMainViewHwnd()) // error opening default datafile - show open dialog CSSFileDialog dlg(TRUE, _T("*.adx"), GetDefaultDataFileName(), OFN_HIDEREADONLY, CResString<64>(IDS_DATA_FILE_FILTER), NULL); if (dlg.DoModal() == IDOK) { OpenDataFile(dlg.m_szFileName); } else { ThrowError(_T("No file selected")); } }