OSDN Git Service

コールバック関数の実質的な処理を進捗状況表示ダイアログのクラス内に移動。
authorsirakaba <sirakaba@9df91469-1e22-0410-86e7-ea8537beb833>
Sat, 6 Feb 2010 11:51:47 +0000 (11:51 +0000)
committersirakaba <sirakaba@9df91469-1e22-0410-86e7-ea8537beb833>
Sat, 6 Feb 2010 11:51:47 +0000 (11:51 +0000)
git-svn-id: svn+ssh://svn.sourceforge.jp/svnroot/tpi/tpi@209 9df91469-1e22-0410-86e7-ea8537beb833

src/lychee/dlg_process.cpp
src/lychee/dlg_process.h

index c1df0f4..f3dab80 100644 (file)
@@ -73,11 +73,7 @@ void ProcessDialog::OnClose(wxCloseEvent & e)
        e.Veto();\r
 }\r
 \r
-//******************************************************************************\r
-//    ダイアログプロシージャ\r
-//******************************************************************************\r
-\r
-int __stdcall TPICallbackProc(unsigned int _uMsg, void * _pStructure)\r
+int ProcessDialog::CallbackProc(unsigned int _uMsg, void * _pStructure)\r
 {\r
        if (_uMsg != TPI_NOTIFY_COMMON)\r
        {\r
@@ -85,7 +81,7 @@ int __stdcall TPICallbackProc(unsigned int _uMsg, void * _pStructure)
        }\r
 \r
        TPI_PROCESSINFO * piInfo = (TPI_PROCESSINFO *) _pStructure;\r
-       if (g_procDlg == NULL || piInfo == NULL || ! g_procDlg->IsShown())\r
+       if (piInfo == NULL || ! g_procDlg->IsShown())\r
        {\r
                return TPI_CALLBACK_CONTINUE;\r
        }\r
@@ -98,44 +94,45 @@ int __stdcall TPICallbackProc(unsigned int _uMsg, void * _pStructure)
                switch (piInfo->uStatus)\r
                {\r
                case TPI_STATUS_OPENARCHIVE:\r
-                       g_procDlg->ebSource->ChangeValue(piInfo->fiInfo.fnFileName.GetFullPath());\r
+                       this->ebSource->ChangeValue(piInfo->fiInfo.fnFileName.GetFullPath());\r
                        break;\r
                case TPI_STATUS_BEGINPROCESS:\r
-                       g_procDlg->ebTarget->ChangeValue((piInfo->fnDestination.IsOk() ? piInfo->fnDestination : piInfo->fiInfo.fnFileName).GetFullPath());\r
+                       this->ebSource->ChangeValue(piInfo->fiInfo.fnFileName.GetFullPath());\r
+                       this->ebTarget->ChangeValue(piInfo->fnDestination.GetFullPath());\r
                        if (piInfo->fiInfo.llUnpackedSize > 10000)\r
                        {\r
-                               g_procDlg->gauge->SetRange(piInfo->fiInfo.llUnpackedSize.ToULong());\r
-                               g_procDlg->gauge->SetValue(0);\r
+                               this->gauge->SetRange(piInfo->fiInfo.llUnpackedSize.ToULong());\r
+                               this->gauge->SetValue(0);\r
                        }\r
-                       ::wxSafeYield(g_procDlg, true);\r
+                       ::wxSafeYield(this, true);\r
                        break;\r
                case TPI_STATUS_INPROCESS:\r
                        if (s_nGaugeCounter++ > 100)\r
                        {\r
                                if (piInfo->fiInfo.llUnpackedSize > 10000)\r
                                {\r
-                                       g_procDlg->gauge->SetValue(piInfo->llProcessedSize.ToULong());\r
+                                       this->gauge->SetValue(piInfo->llProcessedSize.ToULong());\r
                                }\r
-                               ::wxSafeYield(g_procDlg, true);\r
+                               ::wxSafeYield(this, true);\r
                                s_nGaugeCounter = 0;\r
                        }\r
                        break;\r
                case TPI_STATUS_ENDPROCESS:\r
-//                     g_procDlg->gauge->SetValue(piInfo->fiInfo.llUnpackedSize.ToULong());\r
+//                     this->gauge->SetValue(piInfo->fiInfo.llUnpackedSize.ToULong());\r
                        break;\r
                // 書庫ロード時用の独自仕様。\r
                case 0x1000:\r
-                       g_procDlg->ebSource->ChangeValue(piInfo->fiInfo.fnFileName.GetFullPath());\r
-                       g_procDlg->gauge->SetRange(piInfo->fiInfo.llUnpackedSize.ToULong());\r
-                       g_procDlg->gauge->SetValue(0);\r
+                       this->ebSource->ChangeValue(piInfo->fiInfo.fnFileName.GetFullPath());\r
+                       this->gauge->SetRange(piInfo->fiInfo.llUnpackedSize.ToULong());\r
+                       this->gauge->SetValue(0);\r
                        break;\r
                case 0x1001:\r
                        // 更新しすぎると低速なので100ファイル毎に更新する。\r
-                       if (piInfo->llProcessedSize > g_procDlg->gauge->GetValue() + 100)\r
+                       if (piInfo->llProcessedSize > this->gauge->GetValue() + 100)\r
                        {\r
-                               g_procDlg->ebTarget->ChangeValue(piInfo->fiInfo.fnFileName.GetFullPath());\r
-                               g_procDlg->gauge->SetValue(piInfo->llProcessedSize.ToULong());\r
-                               ::wxSafeYield(g_procDlg, true);\r
+                               this->ebTarget->ChangeValue(piInfo->fiInfo.fnFileName.GetFullPath());\r
+                               this->gauge->SetValue(piInfo->llProcessedSize.ToULong());\r
+                               ::wxSafeYield(this, true);\r
                        }\r
                        break;\r
                }\r
@@ -146,19 +143,19 @@ int __stdcall TPICallbackProc(unsigned int _uMsg, void * _pStructure)
                switch (piInfo->uStatus)\r
                {\r
                case TPI_PARAM_PASSWORD:\r
-                       piInfo->szParam = ::wxGetPasswordFromUser(_("Password for:\n") + piInfo->fiInfo.fnFileName.GetFullPath(), wxT("Lychee"), wxEmptyString, g_procDlg);\r
+                       piInfo->szParam = ::wxGetPasswordFromUser(_("Password for:\n") + piInfo->fiInfo.fnFileName.GetFullPath(), wxT("Lychee"), wxEmptyString, this);\r
                        if (piInfo->szParam.IsEmpty())\r
                        {\r
-                               g_procDlg->fCancel = true;\r
+                               this->fCancel = true;\r
                        }\r
                        break;\r
                case TPI_PARAM_NEXTVOLUME:\r
                {\r
-                       wxFileDialog fd(g_procDlg, _("Select next volume of: ") + piInfo->fiInfo.fnFileName.GetFullName());\r
+                       wxFileDialog fd(this, _("Select next volume of: ") + piInfo->fiInfo.fnFileName.GetFullName());\r
                        fd.SetWindowStyleFlag(wxFD_FILE_MUST_EXIST);\r
                        if (fd.ShowModal() == wxID_CANCEL)\r
                        {\r
-                               g_procDlg->fCancel = true;\r
+                               this->fCancel = true;\r
                        }\r
                        piInfo->szParam = fd.GetPath();\r
                        break;\r
@@ -172,5 +169,14 @@ int __stdcall TPICallbackProc(unsigned int _uMsg, void * _pStructure)
                return TPI_CALLBACK_UNSUPPORTED;\r
        }\r
 \r
-       return g_procDlg->fCancel ? TPI_CALLBACK_CANCEL : TPI_CALLBACK_CONTINUE;\r
+       return this->fCancel ? TPI_CALLBACK_CANCEL : TPI_CALLBACK_CONTINUE;\r
+}\r
+\r
+//******************************************************************************\r
+//    ダイアログプロシージャ\r
+//******************************************************************************\r
+\r
+int __stdcall TPICallbackProc(unsigned int _uMsg, void * _pStructure)\r
+{\r
+       return g_procDlg == NULL ? TPI_CALLBACK_CONTINUE : g_procDlg->CallbackProc(_uMsg, _pStructure);\r
 }\r
index 97de113..8412858 100644 (file)
@@ -31,6 +31,7 @@ public:
 \r
     void OnInit(wxInitDialogEvent &);\r
        void OnClose(wxCloseEvent &);\r
+       int CallbackProc(unsigned int, void *);\r
 \r
        ProcessDialog();\r
        ~ProcessDialog();\r