CViewReport::CViewReport(wxWindow* parent, CReport* pRpt) : wxDialog(parent, wxID_ANY, _("View Report"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER), m_pRpt(pRpt) { wxASSERT(pRpt); if (!pRpt) return; wxBoxSizer* dlgSizer = new wxBoxSizer(wxVERTICAL); wxTextCtrl* textCtrl = new wxTextCtrl(this, wxID_ANY, towxstring(pRpt->GetString()), wxDefaultPosition, wxSize(640,480), wxTE_MULTILINE|wxTE_READONLY); dlgSizer->Add(textCtrl, wxSizerFlags().Border(wxALL).Expand().Proportion(1)); wxStdDialogButtonSizer* bs = CreateStdDialogButtonSizer(0); wxASSERT_MSG(bs, wxT("Could not create an empty wxStdDlgButtonSizer")); if (!bs) return; bs->Add(new wxButton(this, wxID_SAVE, _("&Save to Disk"))); bs->AddSpacer(ColSeparation); bs->Add(new wxButton(this, wxID_COPY, _("&Copy to Clipboard"))); bs->AddSpacer(ColSeparation); wxButton* finishButton = new wxButton(this, wxID_CLOSE, _("&Finish")); finishButton->SetDefault(); bs->Add(finishButton); bs->Realize(); Connect(wxID_SAVE, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CViewReport::OnSave) ); Connect(wxID_COPY, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CViewReport::OnCopy) ); Connect(wxID_CLOSE, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CViewReport::OnClose) ); dlgSizer->Add(bs, wxSizerFlags().Border(wxLEFT|wxRIGHT|wxBOTTOM).Expand()); SetSizerAndFit(dlgSizer); }
wxMenu* SystemTray::GetRecentHistory() { //Must be on the heap. wxWidgets will delete it wxMenu* menu = new wxMenu; menu->Append(ID_SYSTRAY_CLEAR_RUE, _("&Clear Recent History")); menu->Append(ID_TRAYRECENT_ENTRY_HELP1, _("Note: Entry format is »Group»Title»Username»")); menu->Append(ID_TRAYRECENT_ENTRY_HELP2, _("Note: Empty fields are shown as »*»")); menu->AppendSeparator(); menu->Enable(ID_TRAYRECENT_ENTRY_HELP1, false); menu->Enable(ID_TRAYRECENT_ENTRY_HELP2, false); std::vector<RUEntryData> menulist; m_frame->GetAllMenuItemStrings(menulist); for (size_t idx = 0; idx < menulist.size(); ++idx) { if (menulist[idx].pci && !menulist[idx].string.empty()) { menu->AppendSubMenu(SetupRecentEntryMenu(menulist[idx].pci, idx), towxstring(menulist[idx].string)); } } return menu; }
bool DbSelectionPanel::DoValidation() { //the data has not been transferred from the window to our members yet, so get them from the controls if (wxWindow::Validate()) { wxFileName wxfn(m_filepicker->GetPath()); //Did the user enter a valid file path if (!wxfn.FileExists()) { wxMessageBox( _("File or path not found."), _("Error"), wxOK | wxICON_EXCLAMATION, this); return false; } //Did he enter the same file that's currently open? if (wxfn.SameAs(wxFileName(towxstring(m_core->GetCurFile())))) { // It is the same damn file wxMessageBox(_("That file is already open."), _("Error"), wxOK | wxICON_WARNING, this); return false; } StringX combination = m_sc->GetCombination(); //Does the combination match? if (m_core->CheckPasskey(tostringx(wxfn.GetFullPath()), combination) != PWScore::SUCCESS) { wxString errmess(_("Incorrect passkey, not a PasswordSafe database, or a corrupt database. (Backup database has same name as original, ending with '~')")); wxMessageBox(errmess, _("Error"), wxOK | wxICON_ERROR, this); SelectCombinationText(); return false; } return true; } else { return false; } }
void loadrom_menu::update() { CHECK_UI_THREAD; auto ents = core_type::get_core_types(); int id = wxid_range_low; for(auto i : items) Delete(i.second); items.clear(); std::map<std::string, core_type*> ents2; for(auto i : ents) ents2[i->get_hname() + " [" + i->get_core_identifier() + "]..."] = i; for(auto i : ents2) { if(id >= wxid_range_high) break; if(i.second->is_hidden()) continue; if(i.second->isnull()) continue; entries[id] = i.second; items[id] = Append(id, towxstring(i.first)); id++; } }
void CompareDlg::OnGridCellRightClick(wxGridEvent& evt) { wxGrid* grid = wxDynamicCast(evt.GetEventObject(), wxGrid); if (!grid) { evt.Skip(); return; } ComparisonData* cd = reinterpret_cast<ComparisonData*>(grid->GetClientData()); wxCHECK_RET(cd, wxT("ClientData object not found in grid")); ContextMenuData menuContext; menuContext.cdata = cd; if (!menuContext.cdata->grid->IsInSelection(evt.GetRow(), evt.GetCol())) { menuContext.cdata->grid->SelectRow(evt.GetRow(), false); } if (menuContext.cdata == m_conflicts) { menuContext.cdata->grid->SelectRow(evt.GetRow()%2 == 0? evt.GetRow()+1: evt.GetRow()-1, true); } menuContext.cdata->grid->SetGridCursor(evt.GetRow(), evt.GetCol()); menuContext.selectedRows = menuContext.cdata->grid->GetSelectedRows(); menuContext.selectedItems = menuContext.selectedRows; size_t selectionCount = menuContext.selectedRows.GetCount(); if (menuContext.cdata == m_conflicts) { selectionCount /= 2; wxCHECK_RET(menuContext.selectedItems.GetCount()%2 ==0, wxT("Conflicts grid should always select an even numer of items")); //Our alogo requires the indexes to be in order, and sometimes these are actually unsorted menuContext.selectedItems.Sort(pless); for( size_t idx = 1; idx <= selectionCount; ++idx) { wxCHECK_RET(menuContext.selectedItems[idx]%2 != 0, wxT("Selection indexes not in expected order")); wxLogDebug( wxString() << wxT("Removing index ") << menuContext.selectedItems.Item(idx) << wxT(" from selection at index ") << idx << wxT('\n')); menuContext.selectedItems.RemoveAt(idx, 1); } for( size_t idx = 0; idx < selectionCount; ++idx) { wxLogDebug(wxString() << wxT("Found index ") << menuContext.selectedItems.Item(idx) << wxT(" from selection at ") << idx << wxT('\n')); wxCHECK_RET(menuContext.selectedItems[idx]%2 == 0, wxT("Conflicts grid selection should only have even indexes after normalization")); menuContext.selectedItems[idx] /= 2; } } stringT itemStr; LoadAString(itemStr, selectionCount > 1? IDSC_ENTRIES: IDSC_ENTRY); wxString selCountStr(wxT(" ")); if (selectionCount > 1) selCountStr << selectionCount << wxT(" "); wxMenu itemEditMenu; wxString strSyncSelectedItemsMenu; if (selectionCount == 1) strSyncSelectedItemsMenu << _("Synchronize this item..."); else strSyncSelectedItemsMenu << _("Synchronize") << selCountStr << _("selected ") << towxstring(itemStr) << _("..."); itemEditMenu.Append(ID_SYNC_SELECTED_ITEMS_WITH_CURRENT_DB, strSyncSelectedItemsMenu); itemEditMenu.Append(ID_SYNC_ALL_ITEMS_WITH_CURRENT_DB, _("Synchronize all items...")); wxString strCopyItemsMenu; strCopyItemsMenu << _("Copy") << selCountStr << _("selected ") << towxstring(itemStr) << _(" to current db"); itemEditMenu.Append(ID_COPY_ITEMS_TO_CURRENT_DB, strCopyItemsMenu); wxString strDeleteItemsMenu; strDeleteItemsMenu << _("Delete") << selCountStr << _("selected ") << towxstring(itemStr) << _(" from current db"); itemEditMenu.Append(ID_DELETE_ITEMS_FROM_CURRENT_DB, strDeleteItemsMenu); if (selectionCount == 1) { itemEditMenu.AppendSeparator(); itemEditMenu.Append(ID_EDIT_IN_CURRENT_DB, _("&Edit entry in current db")); itemEditMenu.Append(ID_VIEW_IN_COMPARISON_DB, _("&View entry in comparison db")); } if (menuContext.cdata == m_conflicts) { wxString strCopyFieldMenu; ComparisonGridTable* table = wxDynamicCast(menuContext.cdata->grid->GetTable(), ComparisonGridTable); menuContext.field = table->ColumnToField(evt.GetCol()); if (selectionCount > 1) strCopyFieldMenu << _("&Copy ") << selectionCount << _(" selected ") << towxstring(CItemData::FieldName(menuContext.field)) << _(" fields to current db"); else strCopyFieldMenu << _("&Copy this ") << towxstring(CItemData::FieldName(menuContext.field)) << _(" to current db"); itemEditMenu.Insert(0, ID_COPY_FIELD_TO_CURRENT_DB, strCopyFieldMenu); itemEditMenu.InsertSeparator(1); itemEditMenu.Delete(ID_COPY_ITEMS_TO_CURRENT_DB); } else if (menuContext.cdata == m_current) { itemEditMenu.Delete(ID_SYNC_SELECTED_ITEMS_WITH_CURRENT_DB); itemEditMenu.Delete(ID_SYNC_ALL_ITEMS_WITH_CURRENT_DB); itemEditMenu.Delete(ID_COPY_ITEMS_TO_CURRENT_DB); if (selectionCount == 1) itemEditMenu.Delete(ID_VIEW_IN_COMPARISON_DB); } else if (menuContext.cdata == m_comparison) { itemEditMenu.Delete(ID_SYNC_SELECTED_ITEMS_WITH_CURRENT_DB); itemEditMenu.Delete(ID_SYNC_ALL_ITEMS_WITH_CURRENT_DB); itemEditMenu.Delete(ID_DELETE_ITEMS_FROM_CURRENT_DB); if (selectionCount == 1) itemEditMenu.Delete(ID_EDIT_IN_CURRENT_DB); } else if (menuContext.cdata == m_identical) { itemEditMenu.Delete(ID_SYNC_SELECTED_ITEMS_WITH_CURRENT_DB); itemEditMenu.Delete(ID_SYNC_ALL_ITEMS_WITH_CURRENT_DB); itemEditMenu.Delete(ID_COPY_ITEMS_TO_CURRENT_DB); } // Make the menuContext object available to the handlers EventDataInjector<wxCommandEvent> inject(&itemEditMenu, &menuContext, wxEVT_COMMAND_MENU_SELECTED); menuContext.cdata->grid->PopupMenu(&itemEditMenu); }
void PasswordSafeFrame::OnRestoreSafe(wxCommandEvent& /*evt*/) { if (SaveIfChanged() != PWScore::SUCCESS) return; const wxFileName currbackup(towxstring(PWSprefs::GetInstance()->GetPref(PWSprefs::CurrentBackup))); wxString dir; if (m_core.GetCurFile().empty()) dir = towxstring(PWSdirs::GetSafeDir()); else { wxFileName::SplitPath(towxstring(m_core.GetCurFile()), &dir, NULL, NULL); wxCHECK_RET(!dir.IsEmpty(), _("Could not parse current file path")); } //returns empty string if user cancels wxString wxbf = wxFileSelector(_("Please Choose a Backup to Restore:"), dir, currbackup.GetFullName(), wxT("bak"), _("Password Safe Backups (*.bak)|*.bak|Password Safe Intermediate Backups (*.ibak)|*.ibak||"), wxFD_OPEN|wxFD_FILE_MUST_EXIST, this); if (wxbf.empty()) return; #ifdef NOT_YET if (m_inExit) { // If U3ExitNow called while in CPWFileDialog, // PostQuitMessage makes us return here instead // of exiting the app. Try resignalling PostQuitMessage(0); return PWScore::USER_CANCEL; } #endif CSafeCombinationPrompt pwdprompt(this, m_core, wxbf); if (pwdprompt.ShowModal() == wxID_OK) { const StringX passkey = pwdprompt.GetPassword(); // unlock the file we're leaving if (!m_core.GetCurFile().empty()) { m_core.UnlockFile(m_core.GetCurFile().c_str()); } // Reset core and clear ALL associated data m_core.ReInit(); // clear the application data before restoring ClearAppData(); if (m_core.ReadFile(tostringx(wxbf), passkey, true, MAXTEXTCHARS) == PWScore::CANT_OPEN_FILE) { wxMessageBox(wxbf << wxT("\n\n") << _("Could not open file for reading!"), _("File Read Error"), wxOK | wxICON_ERROR, this); return /*PWScore::CANT_OPEN_FILE*/; } m_core.SetCurFile(wxEmptyString); // Force a Save As... m_bRestoredDBUnsaved = true; // So that the restored file will be saved SetTitle(_("Password Safe - <Untitled Restored Backup>")); #ifdef NOT_YET app.SetTooltipText(L"PasswordSafe"); #endif #ifdef NOT_YET ChangeOkUpdate(); #endif RefreshViews(); } }
wxString PWSGridTable::GetColLabelValue(int col) { return (size_t(col) < NumberOf(PWSGridCellData)) ? towxstring(CItemData::FieldName(PWSGridCellData[col].ft)) : wxString(); }