taskpanel.h

00001 
00002 // Name:        taskpanel.h
00003 // Purpose:     wxPackageTaskQueuePanel definition
00004 // Author:      Francesco Montorsi
00005 // Modified by: 
00006 // Created:     Fri 23 Jun 2006 14:45:00 CEST
00007 // RCS-ID:      $Id: taskpanel.h,v 1.7 2007/02/01 11:57:24 frm Exp $
00008 // Copyright:   (c) 2006 Francesco Montorsi
00009 // Licence:     wxWidgets license
00011 
00012 #ifndef _PMBUILDPANEL_H_
00013 #define _PMBUILDPANEL_H_
00014 
00015 
00020 #include "wx/htmllbox.h"
00021 #include "guipm/extcmdprogresspanel.h"
00022 
00027 class wxTaskListBox;
00028 class wxTaskListBox;
00029 class wxBitmapButton;
00030 
00035 
00036 #define SYMBOL_WXPACKAGETASKQUEUEPANEL_STYLE wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU|wxCLOSE_BOX
00037 #define SYMBOL_WXPACKAGETASKQUEUEPANEL_TITLE _("Task queue panel")
00038 #define SYMBOL_WXPACKAGETASKQUEUEPANEL_IDNAME wxID_ANY
00039 #define SYMBOL_WXPACKAGETASKQUEUEPANEL_SIZE wxSize(400, 300)
00040 #define SYMBOL_WXPACKAGETASKQUEUEPANEL_POSITION wxDefaultPosition
00041 #define ID_BUILDPANEL_QUEUED 10000
00042 #define ID_BUILDPANEL_START 10110
00043 #define ID_BUILDPANEL_STOP 10026
00044 #define ID_BUILDPANEL_DELETEQUEUED 10032
00045 #define ID_BUILDPANEL_COMPLETED 10002
00046 #define ID_BUILDPANEL_SHOWLOG 10043
00047 #define ID_BUILDPANEL_DELETECOMPLETED 10031
00048 #define ID_BUILDPANEL_CURRENT 10049
00050 
00052 #ifdef __WXGTK20__
00053     #define ID_BUILDPANEL_BITMAP_WIDTH       30
00054 #else
00055     #define ID_BUILDPANEL_BITMAP_WIDTH       17
00056 #endif
00057 
00058 
00059 // ----------------------------------------------------------------------------
00060 // wxPackageTaskQueuePanel
00061 // ----------------------------------------------------------------------------
00062 
00063 class wxPackageTaskQueuePanel: public wxPanel
00064 {    
00065     DECLARE_EVENT_TABLE()
00066 
00067 public:
00069     wxPackageTaskQueuePanel( );
00070     wxPackageTaskQueuePanel( wxWindow* parent, 
00071                              wxWindowID id = SYMBOL_WXPACKAGETASKQUEUEPANEL_IDNAME, 
00072                              const wxString& caption = SYMBOL_WXPACKAGETASKQUEUEPANEL_TITLE, 
00073                              const wxPoint& pos = SYMBOL_WXPACKAGETASKQUEUEPANEL_POSITION, 
00074                              const wxSize& size = SYMBOL_WXPACKAGETASKQUEUEPANEL_SIZE, 
00075                              long style = SYMBOL_WXPACKAGETASKQUEUEPANEL_STYLE );
00076 
00078     bool Create( wxWindow* parent, 
00079                  wxWindowID id = SYMBOL_WXPACKAGETASKQUEUEPANEL_IDNAME, 
00080                  const wxString& caption = SYMBOL_WXPACKAGETASKQUEUEPANEL_TITLE, 
00081                  const wxPoint& pos = SYMBOL_WXPACKAGETASKQUEUEPANEL_POSITION, 
00082                  const wxSize& size = SYMBOL_WXPACKAGETASKQUEUEPANEL_SIZE, 
00083                  long style = SYMBOL_WXPACKAGETASKQUEUEPANEL_STYLE );
00084 
00086     void CreateControls();
00087 
00088 public:     // abstracts
00089 
00090         virtual bool CreateProgressPanel() = 0;
00091         virtual int GetCurrentOperationProportion() const = 0;
00092 
00093 public:     // event handlers
00094 
00095     void OnIdle(wxIdleEvent &ev);
00096     void OnUpdateUI(wxUpdateUIEvent &ev);
00097 
00098     void OnProgressPanelEnd(wxCommandEvent &);
00099     void OnProgressPanelFailed(wxCommandEvent &);
00100 
00101     // buttons
00102     void OnStart(wxCommandEvent &ev);
00103     void OnStop(wxCommandEvent &);
00104     void OnDeleteQueuedBuild(wxCommandEvent &);
00105     void OnShowLog(wxCommandEvent &);
00106     void OnDeleteCompletedBuild(wxCommandEvent &);
00107 
00108 public:
00109 
00110     void Start();
00111     void Stop();
00112 
00113     virtual void RemoveFirstQueuedPackage();
00114 
00117     void SetEventHandler(wxEvtHandler *evt)
00118         { m_pProgressEndHandler=evt; }
00119 
00120 
00121 protected:      // internal utilities
00122 
00123     // called when a new task is going to be queued.
00124     virtual void OnQueueTask();
00125 
00126     wxBitmap GetBitmapResource( const wxString& name );
00127     static bool ShowToolTips();
00128 
00129 protected:      // controls
00130 
00131     // our internal panel
00132     wxProgressPanel *m_pProgressPanel;
00133 
00134     wxTaskListBox *m_pQueuedList;
00135     wxTaskListBox *m_pCompletedList;
00136 
00137     // buttons in the "queued operations" static box
00138     wxBitmapButton *m_pStartBtn, *m_pStopBtn, *m_pDeleteQueuedBtn;
00139 
00140     // buttons in the "completed operations" static box
00141     wxBitmapButton *m_pShowLogBtn, *m_pDeleteCompletedBtn;
00142 
00143 protected:      // other variables
00144 
00145     // the queue of commands to run
00146     wxPackageArray m_arrQueue;
00147 
00148     // the name of the build in progress
00149     wxString m_currentBuild;
00150 
00151     // was the queue stopped by the user ?
00152     bool m_bUserStopped;
00153 
00154     // to which item should we forward wxEVT_COMMAND_PROGRESS_END events ?
00155     wxEvtHandler *m_pProgressEndHandler;
00156 };
00157 
00158 
00159 
00160 
00161 // ----------------------------------------------------------------------------
00162 // wxPackageDownloadQueuePanel
00163 // ----------------------------------------------------------------------------
00164 
00165 class wxPackageDownloadQueuePanel: public wxPackageTaskQueuePanel
00166 {
00167 public:
00169     wxPackageDownloadQueuePanel( );
00170     wxPackageDownloadQueuePanel( wxWindow* parent, wxWindowID id = SYMBOL_WXPACKAGETASKQUEUEPANEL_IDNAME, const wxString& caption = SYMBOL_WXPACKAGETASKQUEUEPANEL_TITLE, const wxPoint& pos = SYMBOL_WXPACKAGETASKQUEUEPANEL_POSITION, const wxSize& size = SYMBOL_WXPACKAGETASKQUEUEPANEL_SIZE, long style = SYMBOL_WXPACKAGETASKQUEUEPANEL_STYLE );
00171 
00173     bool CreateProgressPanel();
00174 
00175 public:
00176 
00177         int GetCurrentOperationProportion() const
00178             { return 2;}
00179 
00180         void QueueDownloadOf(const wxPackage &pkg);
00181     void QueueDownloadOf(const wxPackageArray &arr);
00182 };
00183 
00184 
00185 
00186 
00187 // ----------------------------------------------------------------------------
00188 // wxPackageCommandQueuePanel
00189 // ----------------------------------------------------------------------------
00190 
00191 class wxPackageCommandQueuePanel: public wxPackageTaskQueuePanel
00192 {
00193 public:
00195     wxPackageCommandQueuePanel( );
00196     wxPackageCommandQueuePanel( wxWindow* parent, wxWindowID id = SYMBOL_WXPACKAGETASKQUEUEPANEL_IDNAME, const wxString& caption = SYMBOL_WXPACKAGETASKQUEUEPANEL_TITLE, const wxPoint& pos = SYMBOL_WXPACKAGETASKQUEUEPANEL_POSITION, const wxSize& size = SYMBOL_WXPACKAGETASKQUEUEPANEL_SIZE, long style = SYMBOL_WXPACKAGETASKQUEUEPANEL_STYLE );
00197 
00199     bool CreateProgressPanel();
00200 
00201 public:
00202         int GetCurrentOperationProportion() const
00203             { return 3;}
00204 
00205     void QueueBuildOf(const wxPackage &pkg);
00206     void QueueInstallationOf(const wxPackage &pkg);
00207     void QueueUninstallationOf(const wxPackage &pkg);
00208 };
00209 
00210 
00211 
00212 // ----------------------------------------------------------------------------
00213 // wxTaskListBox
00214 // ----------------------------------------------------------------------------
00215 
00216 class wxTaskListBox : public wxHtmlListBox
00217 {
00218 public:
00219     wxTaskListBox(wxWindow* parent, wxWindowID id = wxID_ANY, 
00220                   const wxPoint& pos = wxDefaultPosition, 
00221                   const wxSize& size = wxDefaultSize, 
00222                   long style = 0, const wxString& name = wxT("tasklistbox"));
00223 
00224 
00225 public:     // public API
00226 
00227     void Append(const wxString &item, 
00228                 const wxString &logdata = wxEmptyString, 
00229                 const wxString &loglabel = wxEmptyString,
00230                 int success = -1)
00231     { 
00232         m_items.Add(item); 
00233         m_logs.Add(logdata); 
00234         m_loglabels.Add(loglabel);
00235         m_success.Add(success); 
00236         SetItemCount(m_items.GetCount()); 
00237     }
00238 
00239     void Prepend(const wxString &item, 
00240                  const wxString &logdata = wxEmptyString, 
00241                  const wxString &loglabel = wxEmptyString,
00242                  int success = -1)
00243     { 
00244         m_items.Insert(item, 0); 
00245         m_logs.Insert(logdata, 0); 
00246         m_loglabels.Insert(loglabel, 0);
00247         m_success.Insert(success, 0); 
00248         SetItemCount(m_items.GetCount()); 
00249     }
00250 
00251     wxString GetString(unsigned int n) const
00252         { return m_items[n]; }
00253 
00254     wxString GetLog(unsigned int n) const
00255         { return m_logs[n]; }
00256     wxString GetLogLabel(unsigned int n) const
00257         { return m_loglabels[n]; }
00258 
00259     void Delete(unsigned int n);
00260 
00261     // NB: call RefreshAll() after all calls to SetString !!
00262     void SetString(unsigned int n, const wxString &item)
00263         { m_items[n] = item; }
00264 
00265     unsigned int GetCount() const
00266         { return m_items.GetCount(); }
00267 
00268     void SetTaskInProgress(unsigned int n)
00269         { m_nInProgress=n; RefreshLine(n); }
00270 
00271 protected:
00272     virtual wxString OnGetItem(size_t n) const;
00273     virtual wxString OnGetItemMarkup(size_t n) const;
00274     //virtual wxColour GetSelectedTextColour(const wxColour& colFg) const;
00275     //virtual void OnDrawSeparator(wxDC& dc, wxRect& rect, size_t n) const;
00276 
00277 protected:
00278     wxArrayString m_items, m_logs, m_loglabels;
00279     wxArrayInt m_success;
00280 
00281     int m_nInProgress;
00282 
00283 private:
00284     DECLARE_NO_COPY_CLASS(wxTaskListBox)
00285 };
00286 
00287 
00288 #endif
00289     // _PMBUILDPANEL_H_

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