// Responds to the OK button in a PocketPC titlebar. This // can be overridden, or you can change the id used for // sending the event, by calling SetAffirmativeId. bool wxDialog::DoOK() { const int idOk = GetAffirmativeId(); if ( EmulateButtonClickIfPresent(idOk) ) return true; wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, GetAffirmativeId()); event.SetEventObject(this); return GetEventHandler()->ProcessEvent(event); }
// Responds to the OK button in a PocketPC titlebar. This // can be overridden, or you can change the id used for // sending the event, by calling SetAffirmativeId. bool wxDialog::DoOK() { const int idOk = GetAffirmativeId(); if ( EmulateButtonClickIfPresent(idOk) ) return true; wxCommandEvent event(wxEVT_BUTTON, GetAffirmativeId()); event.SetEventObject(this); return HandleWindowEvent(event); }
bool wxDialogBase::SendCloseButtonClickEvent() { int idCancel = GetEscapeId(); switch ( idCancel ) { case wxID_NONE: // The user doesn't want this dialog to close "implicitly". break; case wxID_ANY: // this value is special: it means translate Esc to wxID_CANCEL // but if there is no such button, then fall back to wxID_OK if ( EmulateButtonClickIfPresent(wxID_CANCEL) ) return true; idCancel = GetAffirmativeId(); wxFALLTHROUGH; default: // translate Esc to button press for the button with given id if ( EmulateButtonClickIfPresent(idCancel) ) return true; } return false; }
void wxDialogBase::OnCharHook(wxKeyEvent& event) { if ( event.GetKeyCode() == WXK_ESCAPE ) { int idCancel = GetEscapeId(); switch ( idCancel ) { case wxID_NONE: // don't handle Esc specially at all break; case wxID_ANY: // this value is special: it means translate Esc to wxID_CANCEL // but if there is no such button, then fall back to wxID_OK if ( EmulateButtonClickIfPresent(wxID_CANCEL) ) return; idCancel = GetAffirmativeId(); // fall through default: // translate Esc to button press for the button with given id if ( EmulateButtonClickIfPresent(idCancel) ) return; } } event.Skip(); }
void CConfigurationDialog::OnButton(wxCommandEvent& event) { if(event.GetId() == GetAffirmativeId()) { m_config.Write(_T("LogDirectory"), m_pLogDirPicker->GetPath()); m_config.Write(_T("FilenameFormat"), m_pFilenameInput->GetValue()); m_config.Write(_T("ReplacementChar"), m_pReplacementInput->GetValue()); m_config.Write(_T("MessageFormat"), m_pMessageInput->GetValue()); m_config.Write(_T("EmoteFormat"), m_pEmoteInput->GetValue()); m_config.Write(_T("SeparationString"), m_pSeparationInput->GetValue()); m_config.Write(_T("DateFormat"), m_pDateInput->GetValue()); m_config.Write(_T("TimeFormat"), m_pTimeInput->GetValue()); m_config.Write(_T("Unstable"), pUnstableCheckBox->IsChecked()); CLogger* pLogger = wxGetApp().GetLogger(); pLogger->SetLogDirectory(m_pLogDirPicker->GetPath()); pLogger->SetFilenameFormat(m_pFilenameInput->GetValue()); pLogger->SetReplacementChar(m_pReplacementInput->GetValue()[0]); pLogger->SetMessageFormat(m_pMessageInput->GetValue()); pLogger->SetEmoteFormat(m_pEmoteInput->GetValue()); pLogger->SetSeparationString(m_pSeparationInput->GetValue()); pLogger->SetDateFormat(m_pDateInput->GetValue()); pLogger->SetTimeFormat(m_pTimeInput->GetValue()); pLogger->UseClientInterfaces(pUnstableCheckBox->IsChecked()); } this->Close(); }
void LoginDialog::OnPasswordEnter(wxCommandEvent& event) { if (usernameTextBox->GetValue().empty()) { usernameTextBox->SetFocus(); } else { EndModal(GetAffirmativeId()); } }
void wxDialogBase::OnButton(wxCommandEvent& event) { const int id = event.GetId(); if ( id == GetAffirmativeId() ) { AcceptAndClose(); } else if ( id == wxID_APPLY ) { if ( Validate() ) TransferDataFromWindow(); // TODO: disable the Apply button until things change again } else if ( id == GetEscapeId() || (id == wxID_CANCEL && GetEscapeId() == wxID_ANY) ) { EndDialog(wxID_CANCEL); } else // not a standard button { event.Skip(); } }
void frmExtract::onExtract(wxCommandEvent &e) { if(m_bIsDirectory) { RainString sFolder = m_pDestinationPath->GetValue(); if(!_ensureDirectoryExists(sFolder)) return; wxSizer *pMainSizer = GetSizer(); if(m_pButtonsSizer) { FindWindow(wxID_OK)->Hide(); FindWindow(wxID_CANCEL)->Hide(); pMainSizer->Detach(m_pButtonsSizer); } pMainSizer->Add(new wxStaticLine(this), 0, wxEXPAND | wxALL, 4); wxGauge *pProgressBar = new wxGauge(this, wxID_ANY, 1, wxDefaultPosition, wxDefaultSize, wxGA_HORIZONTAL | wxGA_SMOOTH); wxStaticText *pCurrentItem = new wxStaticText(this, wxID_ANY, L"Initialising extraction..."); pMainSizer->Add(pProgressBar, 0, wxEXPAND | wxALL, 2); pMainSizer->Add(pCurrentItem, 0, wxEXPAND | wxALL, 2); pMainSizer->RecalcSizes(); SetSize(pMainSizer->GetMinSize()); Layout(); ::wxSafeYield(this); int iTotalCount = 1, iDoneCount = 0; std::queue<IDirectory*> qTodo; try { qTodo.push(m_pArchive->openDirectory(m_sPathToExtract)); iTotalCount += static_cast<int>(qTodo.front()->getItemCount()); size_t iSkipLength = qTodo.front()->getPath().length(); pProgressBar->SetRange(iTotalCount); while(!qTodo.empty()) { IDirectory *pDirectory = qTodo.front(); pCurrentItem->SetLabel(pDirectory->getPath()); pProgressBar->SetValue(++iDoneCount); ::wxSafeYield(this); RainString sDirectoryBase = pDirectory->getPath(); sDirectoryBase = sFolder + sDirectoryBase.mid(iSkipLength, sDirectoryBase.length() - iSkipLength); if(!RainDoesDirectoryExist(sDirectoryBase)) RainCreateDirectory(sDirectoryBase); for(IDirectory::iterator itr = pDirectory->begin(), itrEnd = pDirectory->end(); itr != itrEnd; ++itr) { if(itr->isDirectory()) { IDirectory *pChild = itr->open(); iTotalCount += 1 + static_cast<int>(pChild->getItemCount()); qTodo.push(pChild); pProgressBar->SetRange(iTotalCount); } else { std::auto_ptr<IFile> pFile; pCurrentItem->SetLabel(pDirectory->getPath() + itr->name()); pProgressBar->SetValue(++iDoneCount); ::wxSafeYield(this); pFile.reset(RainOpenFile(sDirectoryBase + itr->name(), FM_Write)); itr->pump(&*pFile); } } delete pDirectory; qTodo.pop(); } } catch(RainException *pE) { while(!qTodo.empty()) { delete qTodo.front(); qTodo.pop(); } EXCEPTION_MESSAGE_BOX_1(L"Error extracting directory \'%s\'", m_sPathToExtract.getCharacters(), pE); SetReturnCode(GetEscapeId()); return; } } else { wxFileName oFilename(m_pDestinationPath->GetValue()); RainString sFolder = oFilename.GetPath(); IFile *pFile = 0; try { if(!_ensureDirectoryExists(sFolder)) return; pFile = RainOpenFile(m_pDestinationPath->GetValue(), FM_Write); m_pArchive->pumpFile(m_sPathToExtract, pFile); } catch(RainException *pE) { delete pFile; EXCEPTION_MESSAGE_BOX_1(L"Error extracting \'%s\'", m_sPathToExtract.getCharacters(), pE); return; } delete pFile; } wxString sMessage = L"Extracted " + m_sPathToExtract; if(m_pPositiveResultNoficiationBar) m_pPositiveResultNoficiationBar->SetStatusText(sMessage); else ::wxMessageBox(sMessage, GetLabel(), wxOK | wxCENTER | wxICON_INFORMATION, this); EndModal(GetAffirmativeId()); }