00001
00002
00003
00004
00005
00006
00007
00008
00010
00011 #ifndef _WXCURL_DIALOG_H_
00012 #define _WXCURL_DIALOG_H_
00013
00014 #include "wx/dialog.h"
00015 #include "wx/curl/thread.h"
00016 #include "wx/curl/panel.h"
00017
00018
00019 class WXDLLIMPEXP_CORE wxStaticText;
00020 class WXDLLIMPEXP_CORE wxTextCtrl;
00021 class WXDLLIMPEXP_CORE wxGauge;
00022 class WXDLLIMPEXP_CORE wxStaticBitmap;
00023
00024
00026 enum wxCurlTransferDialogStyle
00027 {
00028 wxCTDS_ELAPSED_TIME = 0x0001,
00029 wxCTDS_ESTIMATED_TIME = 0x0002,
00030 wxCTDS_REMAINING_TIME = 0x0004,
00031 wxCTDS_SPEED = 0x0008,
00032 wxCTDS_SIZE = 0x0010,
00033 wxCTDS_URL = 0x0020,
00034
00035
00036
00037 wxCTDS_CONN_SETTINGS_AUTH = 0x0040,
00038 wxCTDS_CONN_SETTINGS_PORT = 0x0080,
00039 wxCTDS_CONN_SETTINGS_PROXY = 0x0100,
00040
00041 wxCTDS_CONN_SETTINGS_ALL = wxCTDS_CONN_SETTINGS_AUTH|wxCTDS_CONN_SETTINGS_PORT|wxCTDS_CONN_SETTINGS_PROXY,
00042
00043 wxCTDS_SHOW_ALL = wxCTDS_ELAPSED_TIME|wxCTDS_ESTIMATED_TIME|wxCTDS_REMAINING_TIME|
00044 wxCTDS_SPEED|wxCTDS_SIZE|wxCTDS_URL|wxCTDS_CONN_SETTINGS_ALL,
00045
00046 wxCTDS_CAN_ABORT = 0x0200,
00047 wxCTDS_CAN_START = 0x0400,
00048 wxCTDS_CAN_PAUSE = 0x0800,
00049
00050 wxCTDS_AUTO_CLOSE = 0x1000,
00051
00052
00053 wxCTDS_DEFAULT_STYLE = wxCTDS_CAN_START|wxCTDS_CAN_PAUSE|wxCTDS_CAN_ABORT|wxCTDS_SHOW_ALL|wxCTDS_AUTO_CLOSE
00054 };
00055
00057 enum wxCurlDialogReturnFlag
00058 {
00059 wxCDRF_SUCCESS,
00060 wxCDRF_USER_ABORTED,
00061 wxCDRF_FAILED
00062 };
00063
00064
00065
00066
00067
00068
00070 class WXDLLIMPEXP_CURL wxCurlTransferDialog : public wxDialog
00071 {
00072 public:
00073 wxCurlTransferDialog()
00074 {
00075 m_bTransferComplete = false;
00076 #ifdef __WXDEBUG__
00077 m_bVerbose = true;
00078 #else
00079 m_bVerbose = false;
00080 #endif
00081
00082
00083 m_pElapsedTime = m_pEstimatedTime = m_pRemainingTime = NULL;
00084 m_pSpeed = m_pSize = NULL;
00085 m_pBitmap = NULL;
00086 m_pURL = NULL;
00087 m_pGauge = NULL;
00088 m_pLastEvent = NULL;
00089 m_pThread = NULL;
00090 }
00091
00092 bool Create(const wxString &url,
00093 const wxString& title,
00094 const wxString& message = wxEmptyString,
00095 const wxString& sizeLabel = _("Transferred:"),
00096 const wxBitmap& bitmap = wxNullBitmap,
00097 wxWindow *parent = NULL,
00098 long style = wxCTDS_DEFAULT_STYLE);
00099
00100 ~wxCurlTransferDialog()
00101 {
00102 wxDELETE(m_pLastEvent);
00103 wxDELETE(m_pThread);
00104 }
00105
00106
00110 wxCurlDialogReturnFlag RunModal();
00111
00112
00114
00115
00116
00118 bool IsOk() const { return m_pThread != NULL && m_pThread->IsOk(); }
00119
00121 virtual wxCurlDialogReturnFlag GetReturnCode() const
00122 { return (wxCurlDialogReturnFlag)wxDialog::GetReturnCode(); }
00123
00125 void SetVerbose(bool enable)
00126 { m_bVerbose=enable; }
00127
00129 bool IsVerbose() const
00130 { return m_bVerbose; }
00131
00132 protected:
00133
00134 virtual void EndModal(wxCurlDialogReturnFlag retCode);
00135
00136 wxStaticText *AddSizerRow(wxSizer *sz, const wxString &name);
00137 void CreateControls(const wxString &url, const wxString &msg,
00138 const wxString& sizeLabel, const wxBitmap &bitmap);
00139 void UpdateLabels(wxCurlProgressBaseEvent *ev);
00140
00141
00142 bool HandleCurlThreadError(wxCurlThreadError err, wxCurlBaseThread *p,
00143 const wxString &url = wxEmptyString);
00144
00145 bool HasFlag(wxCurlTransferDialogStyle flag) const
00146 { return (m_nStyle & flag) != 0; }
00147
00148
00149
00150
00151 virtual int ShowModal()
00152 { return wxDialog::ShowModal(); }
00153
00154 virtual void SetReturnCode(wxCurlDialogReturnFlag ret)
00155 { wxDialog::SetReturnCode(ret); }
00156
00157 public:
00158
00159 void OnEndPerform(wxCurlEndPerformEvent &);
00160
00161 void OnAbort(wxCommandEvent &);
00162 void OnConnSettings(wxCommandEvent &);
00163 void OnPauseResume(wxCommandEvent &);
00164 void OnStart(wxCommandEvent &);
00165
00166 void OnAbortUpdateUI(wxUpdateUIEvent &);
00167 void OnConnSettingsUpdateUI(wxUpdateUIEvent &);
00168 void OnStartUpdateUI(wxUpdateUIEvent &);
00169 void OnPauseResumeUpdateUI(wxUpdateUIEvent &);
00170
00171 void OnClose(wxCloseEvent &ev);
00172
00173 protected:
00174
00175 wxCurlBaseThread *m_pThread;
00176 wxCurlProgressBaseEvent *m_pLastEvent;
00177 bool m_bTransferComplete;
00178
00179
00180
00181 long m_nStyle;
00182
00183
00184 bool m_bVerbose;
00185
00186 protected:
00187
00188 wxTextCtrl* m_pURL;
00189 wxStaticText* m_pSpeed;
00190 wxStaticText* m_pSize;
00191 wxGauge* m_pGauge;
00192 wxStaticBitmap* m_pBitmap;
00193
00194 wxStaticText* m_pElapsedTime;
00195 wxStaticText* m_pRemainingTime;
00196 wxStaticText* m_pEstimatedTime;
00197
00198 private:
00199 DECLARE_EVENT_TABLE()
00200 };
00201
00202
00203
00204
00205
00206
00208 class WXDLLIMPEXP_CURL wxCurlDownloadDialog : public wxCurlTransferDialog
00209 {
00210 public:
00211 wxCurlDownloadDialog() { }
00212
00213 wxCurlDownloadDialog(const wxString &url,
00214 wxOutputStream *out,
00215 const wxString& title = wxT("Downloading..."),
00216 const wxString& message = wxEmptyString,
00217 const wxBitmap& bitmap = wxNullBitmap,
00218 wxWindow *parent = NULL,
00219 long style = wxCTDS_DEFAULT_STYLE)
00220 { Create(url, out, title, message, bitmap, parent, style); }
00221
00222 bool Create(const wxString &url,
00223 wxOutputStream *out,
00224 const wxString& title = wxT("Downloading..."),
00225 const wxString& message = wxEmptyString,
00226 const wxBitmap& bitmap = wxNullBitmap,
00227 wxWindow *parent = NULL,
00228 long style = wxCTDS_DEFAULT_STYLE);
00229
00232 wxOutputStream *GetOutputStream() const
00233 { return wx_static_cast(wxCurlDownloadThread*, m_pThread)->GetOutputStream(); }
00234
00235 public:
00236
00237 void OnDownload(wxCurlDownloadEvent &);
00238
00239 private:
00240 DECLARE_EVENT_TABLE()
00241 DECLARE_DYNAMIC_CLASS(wxCurlDownloadDialog)
00242 };
00243
00244
00245
00246
00247
00248
00250 class WXDLLIMPEXP_CURL wxCurlUploadDialog : public wxCurlTransferDialog
00251 {
00252 public:
00253 wxCurlUploadDialog() { }
00254
00255 wxCurlUploadDialog(const wxString &url,
00256 wxInputStream *in,
00257 const wxString& title = wxT("Uploading..."),
00258 const wxString& message = wxEmptyString,
00259 const wxBitmap& bitmap = wxNullBitmap,
00260 wxWindow *parent = NULL,
00261 long style = wxCTDS_DEFAULT_STYLE)
00262 { Create(url, in, title, message, bitmap, parent, style); }
00263
00264 bool Create(const wxString &url,
00265 wxInputStream *in,
00266 const wxString& title = wxT("Uploading..."),
00267 const wxString& message = wxEmptyString,
00268 const wxBitmap& bitmap = wxNullBitmap,
00269 wxWindow *parent = NULL,
00270 long style = wxCTDS_DEFAULT_STYLE);
00271
00272
00273 public:
00274
00275 void OnUpload(wxCurlUploadEvent &);
00276
00277 private:
00278 DECLARE_EVENT_TABLE()
00279 DECLARE_DYNAMIC_CLASS(wxCurlUploadDialog)
00280 };
00281
00282
00283
00284
00285
00286
00289 class WXDLLIMPEXP_CURL wxCurlConnectionSettingsDialog : public wxDialog
00290 {
00291 public:
00292 wxCurlConnectionSettingsDialog() { }
00293
00294 wxCurlConnectionSettingsDialog(const wxString& title,
00295 const wxString& message = wxEmptyString,
00296 wxWindow *parent = NULL,
00297 long style = wxCCSP_DEFAULT_STYLE)
00298 { Create(title, message, parent, style); }
00299
00300 bool Create(const wxString& title = wxT("Connection settings..."),
00301 const wxString& message = wxEmptyString,
00302 wxWindow *parent = NULL,
00303 long style = wxCCSP_DEFAULT_STYLE);
00304
00305 public:
00306
00309 void RunModal(wxCurlBase *pcurl);
00310
00311 protected:
00312
00313 wxCurlConnectionSettingsPanel *m_pPanel;
00314
00315
00316
00317 virtual int ShowModal()
00318 { return wxDialog::ShowModal(); }
00319
00320 private:
00321 DECLARE_DYNAMIC_CLASS(wxCurlConnectionSettingsDialog)
00322 };
00323
00324
00325 #endif // _WXCURL_DIALOG_H_
00326