~ubuntu-branches/ubuntu/quantal/boinc/quantal

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
// This file is part of BOINC.
// http://boinc.berkeley.edu
// Copyright (C) 2008 University of California
//
// BOINC is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License
// as published by the Free Software Foundation,
// either version 3 of the License, or (at your option) any later version.
//
// BOINC is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with BOINC.  If not, see <http://www.gnu.org/licenses/>.

#ifndef _VIEWTABPAGE_H_
#define _VIEWTABPAGE_H_

#if defined(__GNUG__) && !defined(__APPLE__)
#pragma interface "sg_ViewTabPage.cpp"
#endif

#ifdef __WXMAC__
#define SMALL_FONT 12
#define MEDIUM_FONT 16
#define LARGE_FONT 20
#else
#define SMALL_FONT 9
#define MEDIUM_FONT 12
#define LARGE_FONT 16
#endif

class MyCanvas : public wxWindow
{
public:
	MyCanvas(wxWindow *parent, const wxPoint& pos, const wxSize& size, std::vector<wxBitmap> images);
    void OnPaint(wxPaintEvent& event);
	void AdvanceSlide();
	void ReloadSlideShow(std::vector<wxBitmap> images);

private:
	std::vector<ImageLoader*> vSlideShow;
	int currentImageIndex;
	std::vector<wxBitmap> ssImages;
	bool reloadSlideShow;
	void LoadSlideShow();
    DECLARE_EVENT_TABLE()
};

class CProgressBar;
class CTransparentStaticLine;
class CImageButton;
class WorkunitNotebook;

class CViewTabPage : public wxPanel {
    DECLARE_DYNAMIC_CLASS( CViewTabPage )

public:
	
	bool isAlive;
	// btns ////////////
	////////////////////
	// animation
	wxBitmap* btmpBgAnim;
	CImageButton * btnAminBg;
    //line
	CTransparentStaticLine *lnProjName;
	//strings
	wxString projName;
	wxString projectFrName;
	wxString wrkUnitName;
	wxString gaugePercent;
	wxString elapsedTimeValue;
	wxString timeRemainingValue;
	//wxGauge *gaugeWUMain;
	CProgressBar *gaugeWUMain;
	wxStaticText *lblWrkUnitName;
	wxStaticText *lblProjectFrName;
	wxString percStr;
	wxFloat64 percNum;
	// bg
	RESULT* resultWU;

    CViewTabPage();
    CViewTabPage(
		WorkunitNotebook* parent, RESULT* result, std::string name, char* url
    );
    ~CViewTabPage();

    void CreatePage();
	void UpdateInterface();
	void ReskinInterface();
	void OnWorkShowGraphics();
 	void OnPaint(wxPaintEvent& event); 
	void OnLeftUp(wxMouseEvent& event);
	void DrawText();
	void OnImageButton();
    
	// Setters
	void SetTabName(const std::string nme) { m_name = nme; }
    // Getters
	std::string GetTabName() { return  m_name; }
		
	// Animation
    MyCanvas* GetCanvas() const { return m_canvas; }
	
	DECLARE_EVENT_TABLE()

protected:

    //tab identifier
	std::string m_name;
    char project_url[256];
	bool m_hasGraphic;

	wxInt32 FormatCPUTime( RESULT* rslt, wxString& strBuffer ) const;
    wxInt32 FormatTimeToCompletion( RESULT* rslt, wxString& strBuffer ) const;
	void SGUITimeFormat( float fBuffer, wxString& strBuffer) const;

	void OnEraseBackground(wxEraseEvent& event);

private:

	void CreateSlideShowWindow();
	void LoadSlideShow(std::vector<wxBitmap> *vSlideShow);
	bool Downloading();
	int ComputeState();
	void WriteText(wxDC* dc);
	void FormatText(const wxString& title, const wxString& text, wxDC* dc, wxPoint pos, int col_width = 0, wxFont font = wxFont(SMALL_FONT,74,90,90,0,wxT("Arial")));
	std::vector<wxBitmap> GetSlideShow();
	wxWindow* wSlideShow;
	MyCanvas* m_canvas;
	double project_files_downloaded_time;

};

class WorkunitNotebook : public wxFlatNotebook {

public:
	WorkunitNotebook(wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = 0, const wxString& name = wxT("FlatNotebook"));
	~WorkunitNotebook();
	void ReskinAppGUI();
	void Update();
	void OnChangeSlide(wxTimerEvent& WXUNUSED(event));
	void OnTabChanged(wxFlatNotebookEvent& WXUNUSED(event));


protected:

private:
	wxFlatNotebookImageList m_ImageList;
	wxTimer* changeSlideTimer;
	std::vector<CViewTabPage*> m_windows; // vector of all window tabs created for notebook
	void AddTab(RESULT* result);
	DECLARE_EVENT_TABLE()

};
#endif