1 // This file is part of BOINC.
2 // http://boinc.berkeley.edu
3 // Copyright (C) 2008 University of California
4 //
5 // BOINC is free software; you can redistribute it and/or modify it
6 // under the terms of the GNU Lesser General Public License
7 // as published by the Free Software Foundation,
8 // either version 3 of the License, or (at your option) any later version.
9 //
10 // BOINC is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 // See the GNU Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public License
16 // along with BOINC.  If not, see <http://www.gnu.org/licenses/>.
17 
18 #ifndef BOINC_VIEWWORK_H
19 #define BOINC_VIEWWORK_H
20 
21 #if defined(__GNUG__) && !defined(__APPLE__)
22 #pragma interface "ViewWork.cpp"
23 #endif
24 
25 
26 #include "BOINCBaseView.h"
27 
28 
29 class CWork : public wxObject
30 {
31 public:
32     CWork();
33     ~CWork();
34 
35     wxString m_strProjectName;
36     wxString m_strApplicationName;
37     wxString m_strName;
38     double m_fCPUTime;
39     double m_fProgress;
40     double m_fTimeToCompletion;
41     time_t m_tReportDeadline;
42     wxString m_strStatus;
43     wxString m_strProjectURL;   // Used internally, not displayed
44     wxString m_strCPUTime;
45     wxString m_strProgress;
46     wxString m_strTimeToCompletion;
47     wxString m_strReportDeadline;
48 };
49 
50 
51 class CViewWork : public CBOINCBaseView
52 {
53     DECLARE_DYNAMIC_CLASS( CViewWork )
54 
55 public:
56     CViewWork();
57     CViewWork(wxNotebook* pNotebook);
58 
59     ~CViewWork();
60 
61     void                    AppendColumn(int columnID);
62     virtual wxString&       GetViewName();
63     virtual wxString&       GetViewDisplayName();
64     virtual const char**    GetViewIcon();
65     virtual int             GetViewCurrentViewPage();
66 
67     virtual wxString        GetKeyValue1(int iRowIndex);
68     virtual wxString        GetKeyValue2(int iRowIndex);
69     virtual int             FindRowIndexByKeyValues(wxString& key1, wxString& key2);
70 
71     void                    OnWorkSuspend( wxCommandEvent& event );
72     void                    OnWorkShowGraphics( wxCommandEvent& event );
73     void                    OnWorkShowVMConsole( wxCommandEvent& event );
74     void                    OnWorkAbort( wxCommandEvent& event );
75     void                    OnShowItemProperties( wxCommandEvent& event );
76     void                    OnActiveTasksOnly( wxCommandEvent& event );
77 
78     void                    OnProjectWebsiteClicked( wxEvent& event );
79     void                    OnColResize( wxListEvent& event);
80 
81     std::vector<CWork*>     m_WorkCache;
82 
83 protected:
84 
85     virtual wxInt32         GetDocCount();
86 
87     virtual wxString        OnListGetItemText( long item, long column ) const;
88 
89     virtual bool            OnSaveState( wxConfigBase* pConfig );
90     virtual bool            OnRestoreState( wxConfigBase* pConfig );
91 
92     virtual wxInt32         AddCacheElement();
93     virtual wxInt32         EmptyCache();
94     virtual wxInt32         GetCacheCount();
95     virtual wxInt32         RemoveCacheElement();
96     virtual bool            SynchronizeCacheItem(wxInt32 iRowIndex, wxInt32 iColumnIndex);
97 
98     virtual bool            IsSelectionManagementNeeded();
99 
100     virtual void            UpdateSelection();
101 
102     void                    GetDocProjectName(wxInt32 item, wxString& strBuffer) const;
103     void                    GetDocApplicationName(wxInt32 item, wxString& strBuffer) const;
104     void                    GetDocName(wxInt32 item, wxString& strBuffer) const;
105     void                    GetDocCPUTime(wxInt32 item, double& fBuffer) const;
106     void                    GetDocProgress(wxInt32 item, double& fBuffer) const;
107     wxInt32                 FormatProgress( double fBuffer, wxString& strBuffer ) const;
108     void                    GetDocTimeToCompletion(wxInt32 item, double& fBuffer) const;
109     void                    GetDocReportDeadline(wxInt32 item, time_t& time) const;
110     wxInt32                 FormatReportDeadline( time_t deadline, wxString& strBuffer ) const;
111     wxInt32                 FormatStatus( wxInt32 item, wxString& strBuffer ) const;
112     void                    GetDocProjectURL(wxInt32 item, wxString& strBuffer) const;
113     virtual double          GetProgressValue(long item);
114     virtual wxString        GetProgressText( long item);
115 
116     int                     GetWorkCacheAtIndex(CWork*& workPtr, int index);
117 
118     DECLARE_EVENT_TABLE()
119 };
120 
121 #endif
122