From d98ed65005a776f50d94a7b273cab7b0e46ddd37 Mon Sep 17 00:00:00 2001 From: sirakaba Date: Sun, 1 Nov 2009 08:35:27 +0000 Subject: [PATCH] =?utf8?q?=E5=87=A6=E7=90=86=E4=B8=AD=E3=81=AB=E3=83=91?= =?utf8?q?=E3=82=B9=E3=83=AF=E3=83=BC=E3=83=89=E3=82=92=E6=B1=82=E3=82=81?= =?utf8?q?=E3=82=89=E3=82=8C=E3=81=9F=E9=9A=9B=E3=80=81=E3=83=80=E3=82=A4?= =?utf8?q?=E3=82=A2=E3=83=AD=E3=82=B0=E3=82=92=E8=A1=A8=E7=A4=BA=E3=81=97?= =?utf8?q?=E3=81=A6=E3=83=91=E3=82=B9=E3=83=AF=E3=83=BC=E3=83=89=E3=82=92?= =?utf8?q?=E5=85=A5=E5=8A=9B=E3=81=A7=E3=81=8D=E3=82=8B=E3=82=88=E3=81=86?= =?utf8?q?=E5=A4=89=E6=9B=B4=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit git-svn-id: svn+ssh://svn.sourceforge.jp/svnroot/tpi/tpi@84 9df91469-1e22-0410-86e7-ea8537beb833 --- doc/history.html | 11 ++ src/frontend/dlg_process.cpp | 301 +++++++++++++++++++++++-------------------- 2 files changed, 174 insertions(+), 138 deletions(-) diff --git a/doc/history.html b/doc/history.html index 4abf896..80354b7 100644 --- a/doc/history.html +++ b/doc/history.html @@ -17,11 +17,22 @@
Frontend
+
+
Frontend
+
+ diff --git a/src/frontend/dlg_process.cpp b/src/frontend/dlg_process.cpp index 94185d2..76361fc 100644 --- a/src/frontend/dlg_process.cpp +++ b/src/frontend/dlg_process.cpp @@ -1,140 +1,165 @@ -/******************************************************************************* - TPI - flexible but useless plug-in framework. - Copyright (C) 2002-2009 Silky - - This library is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License as published by the Free - Software Foundation; either version 2.1 of the License, or (at your option) - any later version. - - This library is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - for more details. - - You should have received a copy of the GNU Lesser General Public License along - with this library; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - $Id: dlg_process.cpp,v 1.6 2009/09/01 12:20:49 sirakaba Exp $ -*******************************************************************************/ - -#include "frontend.h" -#include "dlg_process.h" - -ProcessDialog * g_procDlg = NULL; - -//****************************************************************************** -// ProcessDialog -//****************************************************************************** - -ProcessDialog::ProcessDialog(): wxDialog() -{ +/******************************************************************************* + TPI - flexible but useless plug-in framework. + Copyright (C) 2002-2009 Silky + + This library is free software; you can redistribute it and/or modify it under + the terms of the GNU Lesser General Public License as published by the Free + Software Foundation; either version 2.1 of the License, or (at your option) + any later version. + + This library is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License + for more details. + + You should have received a copy of the GNU Lesser General Public License along + with this library; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + + $Id: dlg_process.cpp,v 1.6 2009/09/01 12:20:49 sirakaba Exp $ +*******************************************************************************/ + +#include "frontend.h" +#include "dlg_process.h" + +ProcessDialog * g_procDlg = NULL; + +//****************************************************************************** +// ProcessDialog +//****************************************************************************** + +ProcessDialog::ProcessDialog(): wxDialog() +{ ::wxXmlResource::Get()->Load(FE_DIR_S_XRC wxT("dlg_process.xrc")); ::wxXmlResource::Get()->LoadDialog(this, this->GetParent(), wxT("dlg_process")); -} - -ProcessDialog::~ProcessDialog() -{ - g_procDlg = NULL; -} - -//****************************************************************************** -// Event table. -//****************************************************************************** - -BEGIN_EVENT_TABLE(ProcessDialog, wxDialog) - EVT_INIT_DIALOG(ProcessDialog::OnInit) - EVT_CLOSE( ProcessDialog::OnClose) -END_EVENT_TABLE() - -//****************************************************************************** -// Event handler. -//****************************************************************************** - -void ProcessDialog::OnInit(wxInitDialogEvent &) -{ - // XRC‚ÆŒ‹‚т‚¯B - this->ebSource = XRCCTRL(* this, "ebSource", wxTextCtrl); - this->ebTarget = XRCCTRL(* this, "ebTarget", wxTextCtrl); - this->gauge = XRCCTRL(* this, "gauge", wxGauge); - this->fCancel = false; - g_procDlg = this; - - ::wxXmlResource::Get()->Unload(FE_DIR_S_XRC wxT("dlg_process.xrc")); -} - -void ProcessDialog::OnClose(wxCloseEvent & e) -{ - if (e.CanVeto() && ::AskDlg(wxT("Really do you want to cancel this operation?"), this) == wxYES) - { - this->fCancel = true; - } - e.Veto(); -} - -//****************************************************************************** -// ƒ_ƒCƒAƒƒOƒvƒƒV[ƒWƒƒ -//****************************************************************************** - -int __stdcall TPICallbackProc(unsigned int _uMsg, void * _pStructure) -{ - if (_uMsg != TPI_NOTIFY_COMMON) - { - return TPI_CALLBACK_UNSUPPORTED; - } - - TPI_PROCESSINFO * piInfo = (TPI_PROCESSINFO *) _pStructure; - if (g_procDlg == NULL || piInfo == NULL || piInfo->uMessage != TPI_MESSAGE_STATUS || ! g_procDlg->IsShown()) - { - return TPI_CALLBACK_CONTINUE; - } - - static int s_nGaugeCounter = 0; - switch (piInfo->uStatus) - { - case TPI_STATUS_OPENARCHIVE: - g_procDlg->ebSource->ChangeValue(piInfo->fiInfo.fnFileName.GetFullPath()); - break; - case TPI_STATUS_BEGINPROCESS: - g_procDlg->ebTarget->ChangeValue((piInfo->fnDestination.IsOk() ? piInfo->fnDestination : piInfo->fiInfo.fnFileName).GetFullPath()); - if (piInfo->fiInfo.llUnpackedSize > 10000) - { - g_procDlg->gauge->SetRange(piInfo->fiInfo.llUnpackedSize.ToULong()); - g_procDlg->gauge->SetValue(0); - } - ::wxSafeYield(g_procDlg, true); - break; - case TPI_STATUS_INPROCESS: - if (s_nGaugeCounter++ > 100) - { - if (piInfo->fiInfo.llUnpackedSize > 10000) - { - g_procDlg->gauge->SetValue(piInfo->llProcessedSize.ToULong()); - } - ::wxSafeYield(g_procDlg, true); - s_nGaugeCounter = 0; - } - break; - case TPI_STATUS_ENDPROCESS: -// g_procDlg->gauge->SetValue(piInfo->fiInfo.llUnpackedSize.ToULong()); - break; - // ‘ŒÉƒ[ƒhŽž—p‚Ì“ÆŽ©Žd—lB - case 0x1000: - g_procDlg->ebSource->ChangeValue(piInfo->fiInfo.fnFileName.GetFullPath()); - g_procDlg->gauge->SetRange(piInfo->fiInfo.llUnpackedSize.ToULong()); - g_procDlg->gauge->SetValue(0); - break; - case 0x1001: - // XV‚µ‚·‚¬‚邃ᑬ‚È‚Ì‚Å100ƒtƒ@ƒCƒ‹–ˆ‚ɍXV‚·‚éB - if (piInfo->llProcessedSize > g_procDlg->gauge->GetValue() + 100) - { - g_procDlg->ebTarget->ChangeValue(piInfo->fiInfo.fnFileName.GetFullPath()); - g_procDlg->gauge->SetValue(piInfo->llProcessedSize.ToULong()); - ::wxSafeYield(g_procDlg, true); - } - break; - } - - return g_procDlg->fCancel ? TPI_CALLBACK_CANCEL : TPI_CALLBACK_CONTINUE; -} +} + +ProcessDialog::~ProcessDialog() +{ + g_procDlg = NULL; +} + +//****************************************************************************** +// Event table. +//****************************************************************************** + +BEGIN_EVENT_TABLE(ProcessDialog, wxDialog) + EVT_INIT_DIALOG(ProcessDialog::OnInit) + EVT_CLOSE( ProcessDialog::OnClose) +END_EVENT_TABLE() + +//****************************************************************************** +// Event handler. +//****************************************************************************** + +void ProcessDialog::OnInit(wxInitDialogEvent &) +{ + // XRC‚ÆŒ‹‚т‚¯B + this->ebSource = XRCCTRL(* this, "ebSource", wxTextCtrl); + this->ebTarget = XRCCTRL(* this, "ebTarget", wxTextCtrl); + this->gauge = XRCCTRL(* this, "gauge", wxGauge); + this->fCancel = false; + g_procDlg = this; + + ::wxXmlResource::Get()->Unload(FE_DIR_S_XRC wxT("dlg_process.xrc")); +} + +void ProcessDialog::OnClose(wxCloseEvent & e) +{ + if (e.CanVeto() && ::AskDlg(wxT("Really do you want to cancel this operation?"), this) == wxYES) + { + this->fCancel = true; + } + e.Veto(); +} + +//****************************************************************************** +// ƒ_ƒCƒAƒƒOƒvƒƒV[ƒWƒƒ +//****************************************************************************** + +int __stdcall TPICallbackProc(unsigned int _uMsg, void * _pStructure) +{ + if (_uMsg != TPI_NOTIFY_COMMON) + { + return TPI_CALLBACK_UNSUPPORTED; + } + + TPI_PROCESSINFO * piInfo = (TPI_PROCESSINFO *) _pStructure; + if (g_procDlg == NULL || piInfo == NULL || ! g_procDlg->IsShown()) + { + return TPI_CALLBACK_CONTINUE; + } + + switch (piInfo->uMessage) + { + case TPI_MESSAGE_STATUS: + { + static int s_nGaugeCounter = 0; + switch (piInfo->uStatus) + { + case TPI_STATUS_OPENARCHIVE: + g_procDlg->ebSource->ChangeValue(piInfo->fiInfo.fnFileName.GetFullPath()); + break; + case TPI_STATUS_BEGINPROCESS: + g_procDlg->ebTarget->ChangeValue((piInfo->fnDestination.IsOk() ? piInfo->fnDestination : piInfo->fiInfo.fnFileName).GetFullPath()); + if (piInfo->fiInfo.llUnpackedSize > 10000) + { + g_procDlg->gauge->SetRange(piInfo->fiInfo.llUnpackedSize.ToULong()); + g_procDlg->gauge->SetValue(0); + } + ::wxSafeYield(g_procDlg, true); + break; + case TPI_STATUS_INPROCESS: + if (s_nGaugeCounter++ > 100) + { + if (piInfo->fiInfo.llUnpackedSize > 10000) + { + g_procDlg->gauge->SetValue(piInfo->llProcessedSize.ToULong()); + } + ::wxSafeYield(g_procDlg, true); + s_nGaugeCounter = 0; + } + break; + case TPI_STATUS_ENDPROCESS: +// g_procDlg->gauge->SetValue(piInfo->fiInfo.llUnpackedSize.ToULong()); + break; + // ‘ŒÉƒ[ƒhŽž—p‚Ì“ÆŽ©Žd—lB + case 0x1000: + g_procDlg->ebSource->ChangeValue(piInfo->fiInfo.fnFileName.GetFullPath()); + g_procDlg->gauge->SetRange(piInfo->fiInfo.llUnpackedSize.ToULong()); + g_procDlg->gauge->SetValue(0); + break; + case 0x1001: + // XV‚µ‚·‚¬‚邃ᑬ‚È‚Ì‚Å100ƒtƒ@ƒCƒ‹–ˆ‚ɍXV‚·‚éB + if (piInfo->llProcessedSize > g_procDlg->gauge->GetValue() + 100) + { + g_procDlg->ebTarget->ChangeValue(piInfo->fiInfo.fnFileName.GetFullPath()); + g_procDlg->gauge->SetValue(piInfo->llProcessedSize.ToULong()); + ::wxSafeYield(g_procDlg, true); + } + break; + } + break; + } + case TPI_MESSAGE_ASK: + { + switch (piInfo->uStatus) + { + case TPI_PARAM_PASSWORD: + piInfo->szParam = ::wxGetPasswordFromUser(wxT("Password for:\n") + piInfo->fiInfo.fnFileName.GetFullPath(), wxT("Frontend"), wxEmptyString, g_procDlg); + if (piInfo->szParam.IsEmpty()) + { + g_procDlg->fCancel = true; + } + break; + default: + return TPI_CALLBACK_UNSUPPORTED; + } + break; + } + default: + return TPI_CALLBACK_UNSUPPORTED; + } + + return g_procDlg->fCancel ? TPI_CALLBACK_CANCEL : TPI_CALLBACK_CONTINUE; +} -- 2.11.0