// Function to save all events to file. Without filter day / month / year. Filtering isn't implemented yet. void save_to_file() { std::ofstream the_file("My Events.txt", std::ios::app); for (unsigned int o = 0; o < myVector.size(); o++) the_file << "Event #" << o + 1 << "\nTitle\t\t: " << myVector[o].name << "\nDate\t\t: " << std::setw(2) << std::setfill('0') << myVector[o].day << ' ' << mon_name(myVector[o].nmon) << ' ' << myVector[o].year << "\nTime\t\t: " << std::setw(2) << std::setfill('0') << myVector[o].hour << ":" << std::setw(2) << std::setfill('0') << myVector[o].min << "\nLocation\t: " << myVector[o].loc << "\n\n"; the_file.close(); }
int DefaultMimeHandler::OpenFile(const wxString& filename) { wxFileName the_file(filename); cbMimeType* mt = FindMimeTypeFor(filename); if (mt) return DoOpenFile(mt, filename); else if (the_file.GetExt().CmpNoCase(_T("htm")) == 0 || the_file.GetExt().CmpNoCase(_T("html")) == 0) { // embedded help viewer (unless the user has added an explicit association manually) m_Html->Open(filename); CodeBlocksDockEvent evt(cbEVT_SHOW_DOCK_WINDOW); evt.pWindow = m_Html; Manager::Get()->ProcessEvent(evt); return 0; } else { // not yet supported. ask the user how to open it. wxString choices[3] = {_("Select an external program to open it"), _("Open it with the associated application"), _("Open it inside the Em::Blocks editor")}; wxSingleChoiceDialog dlg(Manager::Get()->GetAppWindow(), _("Em::Blocks does not yet know how to open this kind of file.\n" "Please select what you want to do with it:"), _("What to do?"), sizeof(choices) / sizeof(choices[0]), choices); dlg.SetSelection(0); PlaceWindow(&dlg); int answer = dlg.ShowModal(); if (answer == wxID_OK) { wxString ext = the_file.GetExt().Lower(); wxString wild = ext.IsEmpty() ? the_file.GetName().Lower() : wxString(_T("*.")) + ext; switch (dlg.GetSelection()) { case 0: // choose external program { wxString prg = ChooseExternalProgram(); if (!prg.IsEmpty()) { mt = new cbMimeType; mt->wildcard = wild; mt->useEditor = false; mt->useAssoc = false; mt->program = prg; mt->programIsModal = cbMessageBox(_("Do you want Em::Blocks to be disabled while the external program is running?"), _("Question"), wxICON_QUESTION | wxYES_NO) == wxID_YES; m_MimeTypes.Add(mt); return DoOpenFile(mt, filename); } break; } case 1: // open with associated app mt = new cbMimeType; mt->wildcard = wild; mt->useEditor = false; mt->useAssoc = true; m_MimeTypes.Add(mt); return DoOpenFile(mt, filename); break; case 2: // open in editor { mt = new cbMimeType; mt->wildcard = wild; mt->useEditor = true; mt->useAssoc = false; m_MimeTypes.Add(mt); return DoOpenFile(mt, filename); break; } default: break; } } else if (answer == wxID_CANCEL) { return 0; // Cancel is interpreted as success, too } else { return -1; } } return -1; }