downloadprogresspanel.h

00001 
00002 // Name:        downloadprogresspanel.h
00003 // Purpose:     wxDownloadProgressPanel definition
00004 // Author:      Francesco Montorsi
00005 // Modified by: 
00006 // Created:     15/07/2006 16:25:14
00007 // RCS-ID:      $Id: downloadprogresspanel.h,v 1.3 2007/01/20 22:53:26 frm Exp $
00008 // Copyright:   (c) 2006 Francesco Montorsi
00009 // Licence:     wxWidgets license
00011 
00012 #ifndef _PMDOWNLOADPROGRESSPANEL_H_
00013 #define _PMDOWNLOADPROGRESSPANEL_H_
00014 
00019 #include "guipm/progresspanel.h"
00020 #include "wx/hyperlink.h"
00021 #include "wx/animate.h"
00022 #include "wx/oscopectrl.h"
00023 
00024 
00029 
00030 #define SYMBOL_WXDOWNLOADPROGRESSPANEL_STYLE 0
00031 #define SYMBOL_WXDOWNLOADPROGRESSPANEL_TITLE _("Dialog")
00032 #define SYMBOL_WXDOWNLOADPROGRESSPANEL_IDNAME wxID_ANY
00033 #define SYMBOL_WXDOWNLOADPROGRESSPANEL_SIZE wxSize(400, 300)
00034 #define SYMBOL_WXDOWNLOADPROGRESSPANEL_POSITION wxDefaultPosition
00035 #define ID_DOWNLOADPROGRESS_TIMELEFT 10015
00036 #define ID_DOWNLOADPROGRESS_ELAPSEDTIME 10042
00037 #define ID_DOWNLOADPROGRESS_SIZE 10070
00038 #define ID_DOWNLOADPROGRESS_SPEED 10071
00039 #define ID_DOWNLOADPROGRESS_SOURCE 10012
00040 #define ID_DOWNLOADPROGRESS_DESTINATION 10044
00041 #define ID_DOWNLOADPROGRESS_ANIMATION 10072
00042 #define ID_DOWNLOADPROGRESS_SPEEDLOG 10073
00043 #define ID_DOWNLOADPROGRESS_GAUGE 10001
00045 
00046 #define ID_DOWNLOADPROGRESS_THREAD               11000
00047 #define ID_DOWNLOADPROGRESS_TIMER                11001
00048 #define ID_DOWNLOADPROGRESS_TIMER_INTERVAL       1000   // 1 sec
00049 
00050 
00051 // ----------------------------------------------------------------------------
00052 // wxDownloadProgressPanel
00053 // ----------------------------------------------------------------------------
00054 
00055 class wxDownloadProgressPanel: public wxProgressPanel
00056 {    
00057     DECLARE_DYNAMIC_CLASS( wxDownloadProgressPanel )
00058     DECLARE_EVENT_TABLE()
00059 
00060 public:
00062     wxDownloadProgressPanel( );
00063     wxDownloadProgressPanel( wxWindow* parent, wxWindowID id = SYMBOL_WXDOWNLOADPROGRESSPANEL_IDNAME, const wxPoint& pos = SYMBOL_WXDOWNLOADPROGRESSPANEL_POSITION, const wxSize& size = SYMBOL_WXDOWNLOADPROGRESSPANEL_SIZE, long style = SYMBOL_WXDOWNLOADPROGRESSPANEL_STYLE );
00064 
00066     bool Create( wxWindow* parent, wxWindowID id = SYMBOL_WXDOWNLOADPROGRESSPANEL_IDNAME, const wxPoint& pos = SYMBOL_WXDOWNLOADPROGRESSPANEL_POSITION, const wxSize& size = SYMBOL_WXDOWNLOADPROGRESSPANEL_SIZE, long style = SYMBOL_WXDOWNLOADPROGRESSPANEL_STYLE );
00067 
00069     void CreateControls();
00070 
00072     static bool ShowToolTips();
00073 
00074     virtual ~wxDownloadProgressPanel()
00075     {
00076         // if not stopped, stop now
00077         Stop();
00078     }
00079 
00080 
00081 public:     // event handlers
00082 
00083     void OnDownloadUserAbort(wxDownloadEvent &ev);
00084     void OnDownloadAbort(wxDownloadEvent &ev);
00085     void OnDownloadComplete(wxDownloadEvent &ev);
00086     void OnDownloadProgress(wxDownloadEvent &ev);
00087     void OnTimer(wxTimerEvent &ev);
00088 
00089 public:
00090         
00091     virtual void Start();
00092     virtual void Stop();
00093     virtual bool IsProcessing() const;
00094 
00095     wxString GetLogData() const;
00096     wxString GetLogLabel() const;
00097 
00098     bool IsSuccessful() const
00099         { return m_bSuccess; }
00100 
00101         virtual void SetPackage(const wxPackage &pkg);
00102 
00103     void ClearControls();
00104 
00105     // little helper:
00106     void DoEnd(bool success);
00107 
00108 protected:
00109 
00110     // true if last download was successful
00111     bool m_bSuccess;
00112 
00113     // true if the download thread is currently running
00114     volatile bool m_bThreadExists;
00115 
00116     // current status of the download thread
00117     wxDownloadThreadFlag m_flag;
00118 
00119     // the animation which is played when downloading
00120     wxAnimation m_animation;
00121 
00122     // the timer used to update the oscope control
00123     wxTimer m_timer;
00124 
00125     // used on timer events to update the oscope control
00126     wxULongLong m_nLastSpeed;
00127 
00128 protected:              // controls
00129 
00130         wxHyperlinkCtrl *m_pSource;
00131     wxStaticText* m_pRemainingTime;
00132     wxStaticText* m_pElapsedTime;
00133     wxStaticText* m_pDestination;
00134     wxStaticText* m_pSize;
00135     wxStaticText* m_pSpeed;
00136     wxGauge* m_pGauge;
00137     wxAnimationCtrl* m_pAnimation;
00138     wxOScopeCtrl *m_pOScope;
00139 };
00140 
00141 #endif
00142     // _PMDOWNLOADPROGRESSPANEL_H_

Generated on Thu Feb 1 22:14:30 2007 for wxWidgets Package Manager by  doxygen 1.5.1-p1