2002-11-04 18:57:47 +00:00
|
|
|
// The contents of this file are subject to the Mozilla Public License
|
|
|
|
// Version 1.0 (the "License"); you may not use this file except in
|
|
|
|
// compliance with the License. You may obtain a copy of the License at
|
|
|
|
// http://www.mozilla.org/MPL/
|
|
|
|
//
|
|
|
|
// Software distributed under the License is distributed on an "AS IS"
|
|
|
|
// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
|
|
|
// License for the specific language governing rights and limitations
|
|
|
|
// under the License.
|
|
|
|
//
|
|
|
|
// The Original Code is the Berkeley Open Infrastructure for Network Computing.
|
|
|
|
//
|
|
|
|
// The Initial Developer of the Original Code is the SETI@home project.
|
|
|
|
// Portions created by the SETI@home project are Copyright (C) 2002
|
|
|
|
// University of California at Berkeley. All Rights Reserved.
|
|
|
|
//
|
|
|
|
// Contributor(s):
|
|
|
|
//
|
|
|
|
|
2002-10-06 01:14:37 +00:00
|
|
|
#ifndef __WINGUI_H_
|
|
|
|
#define __WINGUI_H_
|
|
|
|
|
|
|
|
// includes
|
|
|
|
|
|
|
|
#include <afxwin.h>
|
2002-10-05 23:10:46 +00:00
|
|
|
#include <afxcmn.h>
|
|
|
|
#include <afxtempl.h>
|
|
|
|
#include <afxcoll.h>
|
2002-11-04 18:57:47 +00:00
|
|
|
#include <afxext.h>
|
2002-12-06 19:45:38 +00:00
|
|
|
#include <Tlhelp32.h>
|
2002-11-04 18:57:47 +00:00
|
|
|
#include <math.h>
|
|
|
|
#include "filesys.h"
|
2002-10-06 01:14:37 +00:00
|
|
|
#include "log_flags.h"
|
|
|
|
#include "client_state.h"
|
|
|
|
#include "account.h"
|
|
|
|
#include "resource.h"
|
|
|
|
#include "win_net.h"
|
|
|
|
|
|
|
|
// constants
|
|
|
|
|
2002-12-06 19:45:38 +00:00
|
|
|
#define WND_TITLE "BOINC" // window's title
|
|
|
|
|
|
|
|
#ifndef IDC_HAND
|
|
|
|
#define IDC_HAND MAKEINTRESOURCE(32649) // hand pointer, the "hidden resource"
|
|
|
|
#endif
|
|
|
|
|
2002-11-23 00:52:21 +00:00
|
|
|
#define ICON_OFF 0 // remove icon
|
|
|
|
#define ICON_NORMAL 1 // normal icon
|
|
|
|
#define ICON_HIGHLIGHT 2 // highlighted icon
|
|
|
|
|
2002-11-04 18:57:47 +00:00
|
|
|
#define DEF_COL_WIDTH 80 // default width of list columns
|
|
|
|
|
2002-10-06 01:14:37 +00:00
|
|
|
#define SORT_ASCEND 0 // sorting orders
|
|
|
|
#define SORT_DESCEND 1
|
|
|
|
|
|
|
|
#define EDGE_BUFFER 2 // buffer pixels around edge of client
|
|
|
|
|
2002-11-04 18:57:47 +00:00
|
|
|
#define MAX_MESSAGE_LINES 20 // the maximum lines in the message control
|
|
|
|
|
2002-10-06 01:14:37 +00:00
|
|
|
#define ID_TIMER 104 // timer id
|
2002-10-05 23:10:46 +00:00
|
|
|
|
2002-12-06 19:45:38 +00:00
|
|
|
#define PIE_MAJOR_MAX 0.25 // max size of the screen of the pie's major axis
|
|
|
|
#define PIE_MINOR_MAX 0.25 // max size of the screen of the pie's minor axis
|
2002-11-04 18:57:47 +00:00
|
|
|
#define PIE_BUFFER 20 // buffer pixels around edge of pie chart
|
|
|
|
#define PIE_DEPTH 0.25 // depth of pie chart
|
|
|
|
#define PI 3.14159 // pi
|
|
|
|
|
2002-11-18 22:15:21 +00:00
|
|
|
// typedefs
|
|
|
|
|
|
|
|
typedef BOOL (CALLBACK* InitFn)();
|
|
|
|
typedef void (CALLBACK* TermFn)();
|
|
|
|
typedef DWORD (CALLBACK* GetFn)();
|
|
|
|
|
2002-10-06 01:14:37 +00:00
|
|
|
// classes
|
2002-10-05 23:10:46 +00:00
|
|
|
|
2002-11-04 18:57:47 +00:00
|
|
|
//////////
|
|
|
|
// class: CProgressBarCtrl
|
|
|
|
// parent: CProgressCtrl
|
|
|
|
// description: forwards specific mouse messages to parent window.
|
2002-10-05 23:10:46 +00:00
|
|
|
class CProgressBarCtrl : public CProgressCtrl
|
|
|
|
{
|
2002-08-12 00:51:42 +00:00
|
|
|
public:
|
2002-10-05 23:10:46 +00:00
|
|
|
CProgressBarCtrl();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
afx_msg void OnLButtonDown(UINT, CPoint);
|
|
|
|
afx_msg void OnLButtonUp(UINT, CPoint);
|
2002-12-06 19:45:38 +00:00
|
|
|
afx_msg void OnRButtonDown(UINT, CPoint);
|
2002-10-05 23:10:46 +00:00
|
|
|
DECLARE_MESSAGE_MAP()
|
2002-08-12 00:51:42 +00:00
|
|
|
};
|
|
|
|
|
2002-11-04 18:57:47 +00:00
|
|
|
//////////
|
|
|
|
// class: CProgressHeaderCtrl
|
|
|
|
// parent: CHeaderCtrl
|
|
|
|
// description: forwards specific mouse messages to parent window.
|
2002-10-05 23:10:46 +00:00
|
|
|
class CProgressHeaderCtrl : public CHeaderCtrl
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CProgressHeaderCtrl();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
afx_msg void OnRButtonDown(UINT, CPoint);
|
2002-11-04 18:57:47 +00:00
|
|
|
afx_msg void OnRButtonUp(UINT, CPoint);
|
2002-10-05 23:10:46 +00:00
|
|
|
DECLARE_MESSAGE_MAP()
|
|
|
|
};
|
2002-08-12 00:51:42 +00:00
|
|
|
|
2002-11-04 18:57:47 +00:00
|
|
|
//////////
|
|
|
|
// class: CProgressListCtrl
|
|
|
|
// parent: CListCtrl
|
|
|
|
// description: extends basic functionality of standard list control by
|
|
|
|
// allowind embedded progress controls, sorting by columns,
|
|
|
|
// and hiding columns.
|
2002-10-05 23:10:46 +00:00
|
|
|
class CProgressListCtrl : public CListCtrl
|
|
|
|
{
|
2002-08-12 00:51:42 +00:00
|
|
|
public:
|
2002-10-05 23:10:46 +00:00
|
|
|
CProgressListCtrl();
|
2002-11-13 05:37:55 +00:00
|
|
|
~CProgressListCtrl();
|
2002-11-09 01:17:05 +00:00
|
|
|
BOOL DeleteItem(int);
|
2002-10-05 23:10:46 +00:00
|
|
|
void SetItemProgress(int, int, int);
|
|
|
|
void RepositionProgress();
|
|
|
|
int InsertColumn(int, LPCTSTR, int, int, int);
|
2002-12-06 19:45:38 +00:00
|
|
|
int InsertItem(int, LPCTSTR);
|
|
|
|
void GetTextRect(int, int, LPRECT);
|
2002-11-04 18:57:47 +00:00
|
|
|
int GetColumnWidth(int);
|
2002-10-05 23:10:46 +00:00
|
|
|
BOOL SetColumnWidth(int, int);
|
2002-12-06 19:45:38 +00:00
|
|
|
void SetItemColor(int, COLORREF);
|
|
|
|
void SetProjectURL(int, char*);
|
2002-10-05 23:10:46 +00:00
|
|
|
|
2002-08-12 00:51:42 +00:00
|
|
|
protected:
|
2002-11-04 18:57:47 +00:00
|
|
|
CMenu m_PopupMenu; // context menu for header
|
|
|
|
CMapStringToOb m_Progs; // maps coordinate string to progress control
|
|
|
|
CProgressHeaderCtrl m_Header; // header for subclassing
|
|
|
|
CArray<int,int> m_ColWidths; // column widths for hiding and unhiding; a[i] > 0: col i shown; a[i] < 0: col i hidden, previous width -(a[i] - 1)
|
|
|
|
int m_iSort; // column and order of last sort: i = 0: no sort; i > 0: sorted ascending by col i - 1; < 0 sorted descending by col -(i-1)
|
2002-12-06 19:45:38 +00:00
|
|
|
CFont* m_OldFont; // old font for setting subitem font
|
|
|
|
CArray<COLORREF,COLORREF> m_ItemColors; // special colors of items
|
|
|
|
CArray<CString,CString> m_ProjectURLs; // urls for project links
|
2002-10-05 23:10:46 +00:00
|
|
|
|
|
|
|
void SwapItems(int, int);
|
2002-11-04 18:57:47 +00:00
|
|
|
// TODO: fix selection sort algorithm
|
2002-10-05 23:10:46 +00:00
|
|
|
void Sort(int, int);
|
|
|
|
void SwapColumnVisibility(int);
|
|
|
|
|
|
|
|
afx_msg BOOL OnCommand(WPARAM, LPARAM);
|
|
|
|
afx_msg int OnCreate(LPCREATESTRUCT);
|
|
|
|
afx_msg void OnDestroy();
|
|
|
|
afx_msg BOOL OnNotify(WPARAM, LPARAM, LRESULT*);
|
2002-12-06 19:45:38 +00:00
|
|
|
afx_msg void OnCustomDraw(NMHDR*, LRESULT*);
|
2002-10-05 23:10:46 +00:00
|
|
|
afx_msg void OnPaint();
|
2002-11-04 18:57:47 +00:00
|
|
|
// TODO: context menu for items?
|
2002-12-06 19:45:38 +00:00
|
|
|
afx_msg BOOL OnSetCursor(CWnd*, UINT, UINT);
|
|
|
|
afx_msg void OnLButtonDown(UINT, CPoint);
|
2002-10-05 23:10:46 +00:00
|
|
|
afx_msg void OnRButtonDown(UINT, CPoint);
|
|
|
|
DECLARE_MESSAGE_MAP()
|
2002-08-12 00:51:42 +00:00
|
|
|
};
|
|
|
|
|
2002-11-04 18:57:47 +00:00
|
|
|
//////////
|
|
|
|
// class: CPieChartCtrl
|
|
|
|
// parent: CWnd
|
|
|
|
// description: contains the functionality of a pie chart
|
|
|
|
class CPieChartCtrl : public CWnd
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CPieChartCtrl();
|
2002-12-06 19:45:38 +00:00
|
|
|
void AddPiece(LPTSTR, COLORREF, double);
|
|
|
|
void SetPiece(int, double);
|
2002-11-04 18:57:47 +00:00
|
|
|
BOOL Create(DWORD, const RECT&, CWnd*, UINT);
|
|
|
|
void SetFont(CFont*);
|
2002-12-06 19:45:38 +00:00
|
|
|
void SetTotal(double);
|
2002-11-04 18:57:47 +00:00
|
|
|
|
|
|
|
protected:
|
2002-12-06 19:45:38 +00:00
|
|
|
double m_total; // total amount of pie
|
|
|
|
CArray<double,double> m_Values; // specific values of pieces
|
2002-11-04 18:57:47 +00:00
|
|
|
CArray<COLORREF,COLORREF> m_Colors; // colors of pieces
|
|
|
|
CArray<CString,CString> m_Labels; // labels of pieces
|
|
|
|
CFont* m_Font; // font for control
|
|
|
|
|
2002-12-06 19:45:38 +00:00
|
|
|
void DrawPiePiece(CDC*, double, double);
|
|
|
|
void CirclePoint(CPoint*, int, double, CPoint*);
|
|
|
|
void EllipsePoint(CRect*, double, CPoint*);
|
2002-11-04 18:57:47 +00:00
|
|
|
|
|
|
|
afx_msg void OnPaint();
|
|
|
|
DECLARE_MESSAGE_MAP()
|
|
|
|
};
|
|
|
|
|
|
|
|
//////////
|
|
|
|
// class: CMyApp
|
|
|
|
// parent: CWinApp
|
|
|
|
// description: subclasses CWinApp to create main window.
|
2002-10-05 23:10:46 +00:00
|
|
|
class CMyApp : public CWinApp
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual BOOL InitInstance();
|
|
|
|
};
|
2002-08-12 00:51:42 +00:00
|
|
|
|
2002-11-04 18:57:47 +00:00
|
|
|
//////////
|
|
|
|
// class: CMainWindow
|
|
|
|
// parent: CWnd
|
|
|
|
// description: the main window, organizes child control windows and client
|
|
|
|
// state, handles timer updates, some display features.
|
|
|
|
class CMainWindow : public CWnd
|
2002-10-05 23:10:46 +00:00
|
|
|
{
|
2002-08-12 00:51:42 +00:00
|
|
|
public:
|
2002-11-04 18:57:47 +00:00
|
|
|
CMainWindow ();
|
2002-10-05 23:10:46 +00:00
|
|
|
static void CALLBACK TimerProc(HWND, UINT, UINT, DWORD);
|
2002-11-04 18:57:47 +00:00
|
|
|
void UpdateGUI(CLIENT_STATE*);
|
2002-12-06 19:45:38 +00:00
|
|
|
void MessageUser(char*,char*,char*);
|
2002-11-23 00:52:21 +00:00
|
|
|
BOOL IsSuspended();
|
2002-10-05 23:10:46 +00:00
|
|
|
|
2002-08-12 00:51:42 +00:00
|
|
|
protected:
|
2002-11-04 18:57:47 +00:00
|
|
|
CMenu m_MainMenu; // window's main menu
|
|
|
|
CProgressListCtrl m_ProjectListCtrl; // list control
|
|
|
|
CProgressListCtrl m_XferListCtrl; // list control
|
|
|
|
CProgressListCtrl m_ResultListCtrl; // list control
|
2002-12-09 23:53:37 +00:00
|
|
|
CProgressListCtrl m_MessageListCtrl; // list control for messages to user
|
2002-11-04 18:57:47 +00:00
|
|
|
CPieChartCtrl m_UsagePieCtrl; // pie chart control
|
|
|
|
CFont m_Font; // window's font
|
|
|
|
CTabCtrl m_TabCtrl; // tab control for choosing display
|
|
|
|
CImageList m_TabIL; // image list for tab control
|
|
|
|
CBitmap m_TabBMP[5]; // bitmaps for tab image list
|
2002-11-18 22:15:21 +00:00
|
|
|
HINSTANCE m_IdleDll; // handle to dll for user idle
|
2002-11-23 00:52:21 +00:00
|
|
|
int m_IconState; // state of the status icon
|
|
|
|
BOOL m_Message; // does the user have a new message?
|
|
|
|
BOOL m_Suspend; // should apps be suspended?
|
2002-12-06 19:45:38 +00:00
|
|
|
int m_ContextItem; // item selected for context menu
|
2002-11-04 18:57:47 +00:00
|
|
|
|
2002-11-23 00:52:21 +00:00
|
|
|
void SetStatusIcon(DWORD);
|
2002-11-04 18:57:47 +00:00
|
|
|
void SaveUserSettings();
|
|
|
|
void LoadUserSettings();
|
2002-11-18 22:15:21 +00:00
|
|
|
DWORD GetUserIdleTime();
|
2002-11-04 18:57:47 +00:00
|
|
|
void Syncronize(CProgressListCtrl*, vector<void*>*);
|
|
|
|
virtual void PostNcDestroy();
|
|
|
|
|
|
|
|
afx_msg void OnClose();
|
2002-12-09 23:53:37 +00:00
|
|
|
afx_msg void OnCommandSettingsQuit();
|
|
|
|
afx_msg void OnCommandSettingsLogin();
|
|
|
|
afx_msg void OnCommandSettingsProxyServer();
|
2002-10-05 23:10:46 +00:00
|
|
|
afx_msg void OnCommandHelpAbout();
|
2002-12-06 19:45:38 +00:00
|
|
|
afx_msg void OnCommandProjectRelogin();
|
|
|
|
afx_msg void OnCommandProjectQuit();
|
2002-12-09 23:53:37 +00:00
|
|
|
afx_msg void OnCommandFileClearInactive();
|
|
|
|
afx_msg void OnCommandFileClearMessages();
|
2002-12-06 19:45:38 +00:00
|
|
|
afx_msg void OnCommandHide();
|
2002-11-25 20:17:24 +00:00
|
|
|
afx_msg void OnCommandSuspend();
|
2002-12-06 19:45:38 +00:00
|
|
|
afx_msg void OnCommandExit();
|
2002-10-05 23:10:46 +00:00
|
|
|
afx_msg int OnCreate(LPCREATESTRUCT);
|
|
|
|
afx_msg BOOL OnNotify(WPARAM, LPARAM, LRESULT*);
|
2002-12-06 19:45:38 +00:00
|
|
|
afx_msg void OnRButtonDown(UINT, CPoint);
|
2002-11-23 00:52:21 +00:00
|
|
|
afx_msg void OnSetFocus(CWnd*);
|
2002-10-05 23:10:46 +00:00
|
|
|
afx_msg void OnSize(UINT, int, int);
|
2002-11-13 05:37:55 +00:00
|
|
|
afx_msg LRESULT OnStatusIcon(WPARAM, LPARAM);
|
2002-10-05 23:10:46 +00:00
|
|
|
DECLARE_MESSAGE_MAP()
|
2002-08-12 00:51:42 +00:00
|
|
|
};
|
|
|
|
|
2002-11-04 18:57:47 +00:00
|
|
|
//////////
|
|
|
|
// class: CLoginDialog
|
|
|
|
// parent: CDialog
|
|
|
|
// description: gets login information from user.
|
2002-10-05 23:10:46 +00:00
|
|
|
class CLoginDialog : public CDialog
|
|
|
|
{
|
2002-08-12 00:51:42 +00:00
|
|
|
public:
|
2002-12-06 19:45:38 +00:00
|
|
|
CLoginDialog(UINT, LPCTSTR, LPCTSTR);
|
2002-10-05 23:10:46 +00:00
|
|
|
afx_msg BOOL OnInitDialog();
|
|
|
|
CString m_url;
|
|
|
|
CString m_auth;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
afx_msg void OnOK();
|
2002-11-25 20:17:24 +00:00
|
|
|
afx_msg BOOL OnToolTipNotify(UINT, NMHDR*, LRESULT*);
|
2002-10-05 23:10:46 +00:00
|
|
|
DECLARE_MESSAGE_MAP()
|
2002-08-12 00:51:42 +00:00
|
|
|
};
|
2002-10-05 23:10:46 +00:00
|
|
|
|
2002-11-20 20:06:40 +00:00
|
|
|
//////////
|
|
|
|
// class: CQuitDialog
|
|
|
|
// parent: CDialog
|
|
|
|
// description: gets project quit information from user.
|
|
|
|
class CQuitDialog : public CDialog
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CQuitDialog(UINT);
|
|
|
|
afx_msg BOOL OnInitDialog();
|
|
|
|
int m_sel;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
afx_msg void OnOK();
|
2002-11-25 20:17:24 +00:00
|
|
|
afx_msg BOOL OnToolTipNotify(UINT, NMHDR*, LRESULT*);
|
2002-11-20 20:06:40 +00:00
|
|
|
DECLARE_MESSAGE_MAP()
|
|
|
|
};
|
|
|
|
|
2002-12-09 23:53:37 +00:00
|
|
|
//////////
|
|
|
|
// class: CProxyDialog
|
|
|
|
// parent: CDialog
|
|
|
|
// description: allows user to set up proxy information
|
|
|
|
class CProxyDialog : public CDialog
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CProxyDialog(UINT);
|
|
|
|
afx_msg BOOL OnInitDialog();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void EnableHttp(BOOL bEnable);
|
|
|
|
void EnableSocks(BOOL bEnable);
|
|
|
|
afx_msg void OnHttp();
|
|
|
|
afx_msg void OnSocks();
|
|
|
|
afx_msg void OnOK();
|
|
|
|
DECLARE_MESSAGE_MAP()
|
|
|
|
};
|
|
|
|
|
2002-11-04 18:57:47 +00:00
|
|
|
// globals
|
|
|
|
|
2002-11-25 20:17:24 +00:00
|
|
|
extern CMyApp g_myApp;
|
2002-11-23 00:52:21 +00:00
|
|
|
extern CMainWindow* g_myWnd;
|
2002-11-04 18:57:47 +00:00
|
|
|
|
2002-10-06 01:14:37 +00:00
|
|
|
#endif
|