1 /*******************************************************************************
\r
2 TPI - flexible but useless plug-in framework.
\r
3 Copyright (C) 2002-2009 Silky
\r
5 This library is free software; you can redistribute it and/or modify it under
\r
6 the terms of the GNU Lesser General Public License as published by the Free
\r
7 Software Foundation; either version 2.1 of the License, or (at your option)
\r
10 This library is distributed in the hope that it will be useful, but WITHOUT
\r
11 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
\r
12 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
\r
15 You should have received a copy of the GNU Lesser General Public License along
\r
16 with this library; if not, write to the Free Software Foundation, Inc.,
\r
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
\r
19 $Id: dlg_process.cpp,v 1.6 2009/09/01 12:20:49 sirakaba Exp $
\r
20 *******************************************************************************/
\r
22 #include "frontend.h"
\r
23 #include "dlg_process.h"
\r
25 ProcessDialog * g_procDlg = NULL;
\r
27 //******************************************************************************
\r
29 //******************************************************************************
\r
31 ProcessDialog::ProcessDialog(): wxDialog()
\r
33 ::wxXmlResource::Get()->Load(FE_DIR_S_XRC wxT("dlg_process.xrc"));
34 ::wxXmlResource::Get()->LoadDialog(this, this->GetParent(), wxT("dlg_process"));
37 ProcessDialog::~ProcessDialog()
\r
42 //******************************************************************************
\r
44 //******************************************************************************
\r
46 BEGIN_EVENT_TABLE(ProcessDialog, wxDialog)
\r
47 EVT_INIT_DIALOG(ProcessDialog::OnInit)
\r
48 EVT_CLOSE( ProcessDialog::OnClose)
\r
51 //******************************************************************************
\r
53 //******************************************************************************
\r
55 void ProcessDialog::OnInit(wxInitDialogEvent &)
\r
57 // XRC
\82Æ
\8c\8b\82Ñ
\82Â
\82¯
\81B
\r
58 this->ebSource = XRCCTRL(* this, "ebSource", wxTextCtrl);
\r
59 this->ebTarget = XRCCTRL(* this, "ebTarget", wxTextCtrl);
\r
60 this->gauge = XRCCTRL(* this, "gauge", wxGauge);
\r
61 this->fCancel = false;
\r
64 ::wxXmlResource::Get()->Unload(FE_DIR_S_XRC wxT("dlg_process.xrc"));
\r
67 void ProcessDialog::OnClose(wxCloseEvent & e)
\r
69 if (e.CanVeto() && ::AskDlg(wxT("Really do you want to cancel this operation?"), this) == wxYES)
\r
71 this->fCancel = true;
\r
76 //******************************************************************************
\r
77 //
\83_
\83C
\83A
\83\8d\83O
\83v
\83\8d\83V
\81[
\83W
\83\83\r
78 //******************************************************************************
\r
80 int __stdcall TPICallbackProc(unsigned int _uMsg, void * _pStructure)
\r
82 if (_uMsg != TPI_NOTIFY_COMMON)
\r
84 return TPI_CALLBACK_UNSUPPORTED;
\r
87 TPI_PROCESSINFO * piInfo = (TPI_PROCESSINFO *) _pStructure;
\r
88 if (g_procDlg == NULL || piInfo == NULL || piInfo->uMessage != TPI_MESSAGE_STATUS || ! g_procDlg->IsShown())
\r
90 return TPI_CALLBACK_CONTINUE;
\r
93 static int s_nGaugeCounter = 0;
\r
94 switch (piInfo->uStatus)
\r
96 case TPI_STATUS_OPENARCHIVE:
\r
97 g_procDlg->ebSource->ChangeValue(piInfo->fiInfo.fnFileName.GetFullPath());
\r
99 case TPI_STATUS_BEGINPROCESS:
\r
100 g_procDlg->ebTarget->ChangeValue((piInfo->fnDestination.IsOk() ? piInfo->fnDestination : piInfo->fiInfo.fnFileName).GetFullPath());
\r
101 if (piInfo->fiInfo.llUnpackedSize > 10000)
\r
103 g_procDlg->gauge->SetRange(piInfo->fiInfo.llUnpackedSize.ToULong());
\r
104 g_procDlg->gauge->SetValue(0);
\r
106 ::wxSafeYield(g_procDlg, true);
\r
108 case TPI_STATUS_INPROCESS:
\r
109 if (s_nGaugeCounter++ > 100)
\r
111 if (piInfo->fiInfo.llUnpackedSize > 10000)
\r
113 g_procDlg->gauge->SetValue(piInfo->llProcessedSize.ToULong());
\r
115 ::wxSafeYield(g_procDlg, true);
\r
116 s_nGaugeCounter = 0;
\r
119 case TPI_STATUS_ENDPROCESS:
\r
120 // g_procDlg->gauge->SetValue(piInfo->fiInfo.llUnpackedSize.ToULong());
\r
122 //
\8f\91\8cÉ
\83\8d\81[
\83h
\8e\9e\97p
\82Ì
\93Æ
\8e©
\8ed
\97l
\81B
\r
124 g_procDlg->ebSource->ChangeValue(piInfo->fiInfo.fnFileName.GetFullPath());
\r
125 g_procDlg->gauge->SetRange(piInfo->fiInfo.llUnpackedSize.ToULong());
\r
126 g_procDlg->gauge->SetValue(0);
\r
129 //
\8dX
\90V
\82µ
\82·
\82¬
\82é
\82Æ
\92á
\91¬
\82È
\82Ì
\82Å100
\83t
\83@
\83C
\83\8b\96\88\82É
\8dX
\90V
\82·
\82é
\81B
\r
130 if (piInfo->llProcessedSize > g_procDlg->gauge->GetValue() + 100)
\r
132 g_procDlg->ebTarget->ChangeValue(piInfo->fiInfo.fnFileName.GetFullPath());
\r
133 g_procDlg->gauge->SetValue(piInfo->llProcessedSize.ToULong());
\r
134 ::wxSafeYield(g_procDlg, true);
\r
139 return g_procDlg->fCancel ? TPI_CALLBACK_CANCEL : TPI_CALLBACK_CONTINUE;
\r