OSDN Git Service

wxMessageBoxの呼び出しにを簡易なマクロを用いるよう変更。
authorsirakaba <sirakaba@9df91469-1e22-0410-86e7-ea8537beb833>
Fri, 9 Oct 2009 12:18:28 +0000 (12:18 +0000)
committersirakaba <sirakaba@9df91469-1e22-0410-86e7-ea8537beb833>
Fri, 9 Oct 2009 12:18:28 +0000 (12:18 +0000)
git-svn-id: svn+ssh://svn.sourceforge.jp/svnroot/tpi/tpi@30 9df91469-1e22-0410-86e7-ea8537beb833

src/frontend/dlg_make.cpp
src/frontend/dlg_process.cpp
src/frontend/frm_main.cpp
src/frontend/frontend.cpp
src/frontend/frontend.h

index 74abfff..c500462 100644 (file)
@@ -116,7 +116,7 @@ void MakeDialog::OnInit(wxInitDialogEvent&)
                this->cbFileName->SetValue(fnArchive.GetFullName());
 
                // \93W\8aJ\90æ\82ð\97\\91ª\81B\82½\82¾\82µDTV\83X\83L\83\83\83\93\82É\8e\9e\8aÔ\82ª\82©\82©\82é\8fê\8d\87\82Í\83X\83L\83b\83v\89Â\94\\81B
-               if (this->files.Count() < 3000 || ::wxMessageBox(wxT("This archive contains so many files that it takes long to check Directory Traversal Vulnerability(DTV) problem. If you are sure this archive is safe, you can skip this scanning process. Do you want to scan for DTV problem?"), wxMessageBoxCaptionStr, wxICON_EXCLAMATION | wxYES_NO | wxCENTRE) == wxYES)
+               if (this->files.Count() < 3000 || ::AskDlg(wxT("This archive contains so many files that it takes long to check Directory Traversal Vulnerability(DTV) problem. If you are sure this archive is safe, you can skip this scanning process. Do you want to scan for DTV problem?"), this) == wxYES)
                {
                        wxNotebookEvent e;
                        e.SetSelection(-3);
@@ -266,7 +266,7 @@ void MakeDialog::OnTabChanged(wxNotebookEvent& e)
                        }
                }
 
-               if (fDTVWarning && ::wxMessageBox(wxT("This archive may have Directory Traversal Vulnerability(DTV) problem, and some danger files may be extracted to the unexpected system directory! It is strongly recommended to ignore file path. Would you like to do so?"), wxMessageBoxCaptionStr, wxICON_EXCLAMATION | wxYES_NO | wxCENTRE) == wxYES)
+               if (fDTVWarning && ::AskDlg(wxT("This archive may have Directory Traversal Vulnerability(DTV) problem, and some danger files may be extracted to the unexpected system directory! It is strongly recommended to ignore file path. Would you like to do so?"), this) == wxYES)
                {
                        this->cbIgnorePath->SetValue(true);
                        if (bReallyShow)
index 9ab9676..86ff09a 100644 (file)
@@ -64,7 +64,7 @@ void ProcessDialog::OnInit(wxInitDialogEvent &)
 \r
 void ProcessDialog::OnClose(wxCloseEvent & e)\r
 {\r
-       if (e.CanVeto() && ::wxMessageBox(wxT("Really do you want to cancel this operation?"), wxMessageBoxCaptionStr, wxYES_NO | wxICON_EXCLAMATION, g_procDlg) == wxYES)\r
+       if (e.CanVeto() && ::AskDlg(wxT("Really do you want to cancel this operation?"), this) == wxYES)\r
        {\r
                this->fCancel = true;\r
        }\r
index 9e77e15..8b8e387 100644 (file)
@@ -252,7 +252,7 @@ void MainFrame::OnArcCreate(wxCommandEvent& e)
        fnArchive.SetExt(swInfo.fMakeSFX ? (wxString) EXE_EXT : mkDlg.defext[nSelected]);
        if (! tpi.InitLibrary(mkDlg.libname[nSelected], fnArchive.GetFullPath(), mkDlg.nLibNum[nSelected]))
        {
-               ::wxMessageBox(wxT("Fault: InitLibrary()!"));
+               ::ErrDlg(wxT("InitLibrary()!"), this);
                return;
        }
 
@@ -407,7 +407,7 @@ void MainFrame::OnArcExtract(wxCommandEvent&)
                swInfo.fnDestinationDirectory = MakeDirPath(swInfo.fnDestinationDirectory, wxFileName::FileName(this->statusbar->GetStatusText(5)).GetName(), true);
                if (! swInfo.fnDestinationDirectory.IsOk())
                {
-                       ::wxMessageBox(wxT("Fault: Unable to make the destination directory!"));
+                       ::ErrDlg(wxT("Unable to make the destination directory!"), this);
                        return;
                }
        }
@@ -443,7 +443,7 @@ void MainFrame::OnArcDelete(wxCommandEvent& e)
                return;
        }
 
-       if (::wxMessageBox(wxT("Are you sure to delete selected files?"), wxMessageBoxCaptionStr, wxYES_NO | wxICON_EXCLAMATION, this) == wxNO)
+       if (::AskDlg(wxT("Are you sure to delete selected files?"), this) == wxNO)
        {
                return;
        }
@@ -479,7 +479,7 @@ void MainFrame::OnArcTest(wxCommandEvent&)
        procDlg.Show(true);
        if (this->ErrorCheck(this->tpi.Command(TPI_COMMAND_TEST, & swInfo, this->statusbar->GetStatusText(5), files)) == TPI_ERROR_SUCCESS)
        {
-               ::wxMessageBox(wxT("This is a correct archive."), wxT("Frontend"), wxOK | wxCENTRE | wxICON_INFORMATION, this);
+               ::MsgDlg(wxT("This is a correct archive."), this, wxICON_INFORMATION);
        }
        procDlg.Show(false);
 }
@@ -561,7 +561,7 @@ void MainFrame::OnListItemDClick(wxListEvent&)
        wxFileType * ftFile = wxTheMimeTypesManager->GetFileTypeFromExtension(wxFileName::FileName(files[0]).GetExt());
        if (! ftFile)
        {
-               ::wxMessageBox(wxT("Fault: Unable to get the file type!"));
+               ::ErrDlg(wxT("Unable to get the file type!"), this);
                return;
        }
 
@@ -572,7 +572,7 @@ void MainFrame::OnListItemDClick(wxListEvent&)
        swInfo.fnDestinationDirectory = MakeDirPath(wxFileName::DirName(::wxGetCwd()), wxT("tpi_tmp"), true);
        if (! swInfo.fnDestinationDirectory.IsOk())
        {
-               ::wxMessageBox(wxT("Fault: Unable to make the temporary directory!"));
+               ::ErrDlg(wxT("Unable to make the temporary directory!"), this);
                return;
        }
 
@@ -611,7 +611,7 @@ void MainFrame::OnListBeginDrag(wxListEvent&)
        swInfo.fnDestinationDirectory = MakeDirPath(wxFileName::DirName(::wxGetCwd()), wxT("tpi_tmp"), true);
        if (! swInfo.fnDestinationDirectory.IsOk())
        {
-               ::wxMessageBox(wxT("Fault: Unable to make the temporary directory!"));
+               ::ErrDlg(wxT("Unable to make the temporary directory!"), this);
                return;
        }
 
@@ -679,7 +679,7 @@ void MainFrame::LoadArc(wxString szFileName)
        {
                procDlg.Show(false);
                tpi.FreeLibrary();
-               ::wxMessageBox(wxT("Fault : No plug-in supporting this archive was found!"));
+               ::ErrDlg(wxT("No plug-in supporting this archive was found!"), this);
                return;
        }
 
@@ -697,7 +697,7 @@ void MainFrame::LoadArc(wxString szFileName)
        {
                procDlg.Show(false);
                tpi.FreeLibrary();
-               ::wxMessageBox(wxT("Fault : OpenArchive()!"));
+               ::ErrDlg(wxT("OpenArchive()!"), this);
                return;
        }
 
@@ -735,7 +735,7 @@ void MainFrame::LoadArc(wxString szFileName)
                                tpi.CloseArchive();
                                wxCommandEvent e;
                                this->OnArcClose(e);
-                               ::wxMessageBox(wxT("Fault : Canceled by user!"));
+                               ::ErrDlg(wxT("Canceled by user!"), this);
                                return;
                        }
 
@@ -753,13 +753,13 @@ void MainFrame::LoadArc(wxString szFileName)
                        if (piInfo.fiInfo.fnFileName.GetPathWithSep().Find(wxT("..")) != wxNOT_FOUND)
                        {
                                piInfo.fiInfo.uDanger = TRUE;
-                               ::wxMessageBox(wxT("This archive may have Directory Traversal Vulnerability(DTV) problem, and some danger files may be extracted to the unexpected system directory! You should use the \"Ignore file pathes\" option when extracting this archive.\nDanger file is:\n" + piInfo.fiInfo.szStoredName), wxMessageBoxCaptionStr, wxICON_EXCLAMATION);
+                               ::WrnDlg(wxT("This archive may have Directory Traversal Vulnerability(DTV) problem, and some danger files may be extracted to the unexpected system directory! You should use the \"Ignore file pathes\" option when extracting this archive.\nDanger file is:\n") + piInfo.fiInfo.szStoredName, this);
                        }
                        // \8bó\94\92\82Ì\98A\91±\82É\82æ\82é\8ag\92£\8eq\8bU\91\95\82ð\8c\9f\8d¸\81B
                        if (piInfo.fiInfo.fnFileName.GetFullName().Find(wxT("        ")) != wxNOT_FOUND)
                        {
                                piInfo.fiInfo.uDanger = TRUE;
-                               ::wxMessageBox(wxT("This archive may contain extension-disguised files whose real extension is hidden by using many blank charactor and you may mistake that it is a \"safe\" file. Don\'t execute these files carelessly.\nDanger file is:\n" + piInfo.fiInfo.szStoredName), wxMessageBoxCaptionStr, wxICON_EXCLAMATION);
+                               ::WrnDlg(wxT("This archive may contain extension-disguised files whose real extension is hidden by using many blank charactor and you may mistake that it is a \"safe\" file. Don\'t execute these files carelessly.\nDanger file is:\n") + piInfo.fiInfo.szStoredName, this);
                        }
                        // Unicode\90§\8cä\95\8e\9a\82ð\8c\9f\8d¸\81B
                        for (wxChar c = 0x200c; c <= 0x206f; c++)
@@ -767,7 +767,7 @@ void MainFrame::LoadArc(wxString szFileName)
                                if (piInfo.fiInfo.fnFileName.GetFullName().Find(c) != wxNOT_FOUND)
                                {
                                        piInfo.fiInfo.uDanger = TRUE;
-                                       ::wxMessageBox(wxT("This archive may contain extension-disguised files whose real extension is hidden by using Unicode control character and you may mistake that it is a \"safe\" file. Don\'t execute these files carelessly.\nDanger file is:\n" + piInfo.fiInfo.szStoredName), wxMessageBoxCaptionStr, wxICON_EXCLAMATION);
+                                       ::WrnDlg(wxT("This archive may contain extension-disguised files whose real extension is hidden by using Unicode control character and you may mistake that it is a \"safe\" file. Don\'t execute these files carelessly.\nDanger file is:\n") + piInfo.fiInfo.szStoredName, this);
                                }
                                switch (c)
                                {
@@ -795,7 +795,7 @@ void MainFrame::LoadArc(wxString szFileName)
        {
                procDlg.Show(false);
                tpi.FreeLibrary();
-               ::wxMessageBox(wxT("Fault : GetArchiveInformation()!"));
+               ::ErrDlg(wxT("GetArchiveInformation()!"), this);
                return;
        }
 
@@ -810,13 +810,13 @@ void MainFrame::LoadArc(wxString szFileName)
        // \8f\91\8cÉ\82ð\95Â\82\82é\81B
        if (tpi.CloseArchive() != TPI_ERROR_SUCCESS)
        {
-               ::wxMessageBox(wxT("Fault : CloseArchive()!"));
+               ::ErrDlg(wxT("CloseArchive()!"), this);
        }
 
        // \83R\81[\83\8b\83o\83b\83N\8aÖ\90\94\82ð\90Ý\92è\81B
        if (tpi.SetCallbackProc(TPICallbackProc) != TPI_ERROR_SUCCESS)
        {
-               ::wxMessageBox(wxT("Fault : SetCallbackProc()!"));
+               ::ErrDlg(wxT("SetCallbackProc()!"), this);
        }
 
        // UI\8ae\8eí\90Ý\92è\81B
@@ -868,20 +868,18 @@ void MainFrame::ConvertArc(bool fToSFX)
 
 int MainFrame::ErrorCheck(int nErrorCode)
 {
-       wxString s;
        switch (nErrorCode)
        {
        case TPI_ERROR_SUCCESS:
-               return TPI_ERROR_SUCCESS;
+               break;
        case TPI_ERROR_D_UNSUPPORTED:
-               s = wxT("Sorry, this function is not supported yet.");
+               ::ErrDlg(wxT("Sorry, this function is not supported yet."), this);
                break;
        case TPI_ERROR_D_SKIPPED:
-               s = wxT("This operation is canceled by the user.");
+               ::ErrDlg(wxT("This operation is canceled by the user."), this);
                break;
        default:
-               s.Printf(wxT("ErrorCode:%d"), nErrorCode);
+               ::ErrDlg(wxT("ErrorCode:") + wxString::Format(wxT("%d"), nErrorCode), this);
        }
-       ::wxMessageBox(s, wxT("Frontend"), wxOK | wxCENTRE | wxICON_ERROR, this);
        return nErrorCode;
 }
index 5531085..849ae95 100644 (file)
@@ -51,7 +51,7 @@ bool Frontend::OnInit()
 
        if (! ::wxXmlResource::Get()->Load(FE_DIR_S_XRC wxT("frm_main.xrc")))
        {
-               ::wxMessageBox(wxT("Error: Unable to find XRC!"));
+               ::ErrDlg(wxT("Unable to find XRC!"), NULL);
                return false;
        }
 
index 990cba4..ced9f51 100644 (file)
@@ -52,4 +52,9 @@ WX_DECLARE_OBJARRAY(TPI_FILEINFO, ArrayTPI_FILEINFO);
 #define FE_DIR_S_XRC FE_DIR_SHR wxT("xrc/")\r
 #define FE_DIR_S_ICO FE_DIR_SHR wxT("ico/")\r
 \r
+#define MsgDlg(msg, parent, flag) wxMessageBox(msg, wxT("Frontend"), wxCENTRE | flag, parent)\r
+#define ErrDlg(msg, parent) MsgDlg(wxT("Error: ") msg, parent, wxOK | wxICON_ERROR)\r
+#define WrnDlg(msg, parent) MsgDlg(msg, parent, wxOK | wxICON_EXCLAMATION)\r
+#define AskDlg(msg, parent) MsgDlg(msg, parent, wxYES_NO | wxICON_QUESTION)\r
+\r
 #endif\r