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_VIEWPROJECTS_H
19 #define BOINC_VIEWPROJECTS_H
20 
21 #if defined(__GNUG__) && !defined(__APPLE__)
22 #pragma interface "ViewProjects.cpp"
23 #endif
24 
25 
26 #include "BOINCBaseView.h"
27 
28 
29 class CProject : public wxObject
30 {
31 public:
32 	CProject();
33 	~CProject();
34 
35     wxString m_strProjectName;
36     wxString m_strAccountName;
37     wxString m_strTeamName;
38     double m_fTotalCredit;
39     double m_fAVGCredit;
40     double m_fResourceShare;
41     double m_fResourcePercent;
42     wxString m_strStatus;
43     wxString m_strProjectURL;   // Used internally, not displayed
44     wxString m_strTotalCredit;
45     wxString m_strAVGCredit;
46     wxString m_strResourceShare;
47 };
48 
49 
50 class CViewProjects : public CBOINCBaseView
51 {
52     DECLARE_DYNAMIC_CLASS( CViewProjects )
53 
54 public:
55     CViewProjects();
56     CViewProjects(wxNotebook* pNotebook);
57 
58     ~CViewProjects();
59 
60     void                    AppendColumn(int columnID);
61     virtual wxString&       GetViewName();
62     virtual wxString&       GetViewDisplayName();
63     virtual const char**    GetViewIcon();
64     virtual int             GetViewCurrentViewPage();
65 
66     virtual wxString        GetKeyValue1(int iRowIndex);
67     virtual int             FindRowIndexByKeyValues(wxString& key1, wxString& key2);
68 
69     void                    OnProjectUpdate( wxCommandEvent& event );
70     void                    OnProjectSuspend( wxCommandEvent& event );
71     void                    OnProjectNoNewWork( wxCommandEvent& event );
72     void                    OnProjectReset( wxCommandEvent& event );
73     void                    OnProjectDetach( wxCommandEvent& event );
74     void                    OnShowItemProperties( wxCommandEvent& event );
75 
76     void                    OnProjectWebsiteClicked( wxEvent& event );
77     void                    OnColResize( wxListEvent& event);
78 
79     std::vector<CProject*>  m_ProjectCache;
80 
81 protected:
82     virtual wxInt32         GetDocCount();
83 
84     virtual wxString        OnListGetItemText( long item, long column ) const;
85     virtual wxInt32         AddCacheElement();
86     virtual wxInt32         EmptyCache();
87     virtual wxInt32         GetCacheCount();
88     virtual wxInt32         RemoveCacheElement();
89     virtual bool            SynchronizeCacheItem(wxInt32 iRowIndex, wxInt32 iColumnIndex);
90 
91     virtual bool            IsSelectionManagementNeeded();
92 
93     virtual void            UpdateSelection();
94 
95     void                    GetDocProjectName(wxInt32 item, wxString& strBuffer) const;
96     wxInt32                 FormatProjectName( wxInt32 item, wxString& strBuffer ) const;
97     void                    GetDocAccountName(wxInt32 item, wxString& strBuffer) const;
98     wxInt32                 FormatAccountName( wxInt32 item, wxString& strBuffer ) const;
99     void                    GetDocTeamName(wxInt32 item, wxString& strBuffer) const;
100     wxInt32                 FormatTeamName( wxInt32 item, wxString& strBuffer ) const;
101     void                    GetDocTotalCredit(wxInt32 item, double& fBuffer) const;
102     void                    GetDocAVGCredit(wxInt32 item, double& fBuffer) const;
103     void                    GetDocResourceShare(wxInt32 item, double& fBuffer) const;
104     void                    GetDocResourcePercent(wxInt32 item, double& fBuffer) const;
105     wxInt32                 FormatResourceShare( double fBuffer, double fBufferPercent, wxString& strBuffer ) const;
106     void                    GetDocStatus(wxInt32 item, wxString& strBuffer) const;
107     wxInt32                 FormatStatus( wxInt32 item, wxString& strBuffer ) const;
108     void                    GetDocProjectURL(wxInt32 item, wxString& strBuffer) const;
109 
110     virtual double          GetProgressValue(long item);
111     virtual wxString        GetProgressText( long item);
112 
113     bool                    IsWebsiteLink( const wxString& strLink );
114     wxInt32                 ConvertWebsiteIndexToLink( wxInt32 iProjectIndex, wxInt32 iWebsiteIndex, wxString& strLink );
115     wxInt32                 ConvertLinkToWebsiteIndex( const wxString& strLink, wxInt32& iProjectIndex, wxInt32& iWebsiteIndex );
116 
117     int                     GetProjectCacheAtIndex(CProject*& projectPtr, int index);
118 
119     DECLARE_EVENT_TABLE()
120 };
121 
122 #endif
123