diff --git a/client/win/resource.h b/client/win/resource.h index b5712510ce..963519b293 100755 --- a/client/win/resource.h +++ b/client/win/resource.h @@ -67,6 +67,7 @@ #define ID_FILE_HIDE 40020 #define ID_PROJECT_RELOGIN 40021 #define ID_PROJECT_QUIT 40022 +#define ID_PROJECT_DETACH 40022 #define ID_PROJECT_CLEAR 40023 #define ID_RESULT_CLEAR 40024 #define ID_XFER_CLEAR 40025 @@ -82,13 +83,16 @@ #define ID_CONNECTION_CONFIRMBEFORECONNECTING 40034 #define ID_CONNECTION_CONNECTNOW 40035 #define ID_WORK_SHOWGRAPHICS 40036 +#define ID_PROJECT_WEB_SITE 40037 +#define ID_PROJECT_GET_PREFS 40038 +#define ID_PROJECT_RESET 40039 // Next default values for new objects // #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_NEXT_RESOURCE_VALUE 130 -#define _APS_NEXT_COMMAND_VALUE 40037 +#define _APS_NEXT_COMMAND_VALUE 40040 #define _APS_NEXT_CONTROL_VALUE 1035 #define _APS_NEXT_SYMED_VALUE 101 #endif diff --git a/client/win/resource.rc b/client/win/resource.rc index 3e4af1ad64..159e50a7ef 100755 --- a/client/win/resource.rc +++ b/client/win/resource.rc @@ -205,14 +205,9 @@ BEGIN POPUP "&Settings" BEGIN MENUITEM "&Login to Project...", ID_SETTINGS_LOGIN - MENUITEM "&Quit Project...", ID_SETTINGS_QUIT MENUITEM SEPARATOR MENUITEM "&Proxy Server...", ID_SETTINGS_PROXYSERVER END - POPUP "&Connection" - BEGIN - MENUITEM "&Connect To Scheduling Server", ID_CONNECTION_CONNECTNOW - END POPUP "&Help" BEGIN MENUITEM "&About...", ID_HELP_ABOUT @@ -230,7 +225,10 @@ BEGIN END POPUP "Project" BEGIN - MENUITEM "Quit Project...", ID_PROJECT_QUIT + MENUITEM "Web site", ID_PROJECT_WEB_SITE + MENUITEM "Get preferences", ID_PROJECT_GET_PREFS + MENUITEM "Detach...", ID_PROJECT_DETACH + MENUITEM "Reset project...", ID_PROJECT_RESET END POPUP "Work" BEGIN diff --git a/client/win/wingui_dialog.cpp b/client/win/wingui_dialog.cpp index 47d2d48655..942a4333f5 100755 --- a/client/win/wingui_dialog.cpp +++ b/client/win/wingui_dialog.cpp @@ -151,125 +151,6 @@ BOOL CLoginDialog::OnToolTipNotify(UINT id, NMHDR *pNMHDR, LRESULT *pResult) return TRUE; } -///////////////////////////////////////////////////////////////////////// -// CQuitDialog message map and member functions - -BEGIN_MESSAGE_MAP(CQuitDialog, CDialog) - ON_BN_CLICKED(IDOK, OnOK) - ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTW, 0, 0xFFFF, OnToolTipNotify) - ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTA, 0, 0xFFFF, OnToolTipNotify) -END_MESSAGE_MAP() - -////////// -// CQuitDialog::CQuitDialog -// arguments: y: dialog box resource id -// returns: void -// function: calls parents contructor. -CQuitDialog::CQuitDialog(UINT y) : CDialog(y) -{ -} - -////////// -// CQuitDialog::LoadLanguage -// arguments: void -// returns: void -// function: loads new captions from language file -void CQuitDialog::LoadLanguage() -{ - char szPath[256]; - CString strSection; - GetCurrentDirectory(256, szPath); - strcat(szPath, "\\"); - strcat(szPath, LANGUAGE_FILE_NAME); - CString strKey; - char szVal[256]; - GetWindowText(strKey); - GetPrivateProfileString("DIALOG-QUIT", "Title", strKey, szVal, 256, szPath); - SetWindowText(szVal); - GetDlgItemText(IDOK, strKey); - GetPrivateProfileString("DIALOG-QUIT", strKey, strKey, szVal, 256, szPath); - SetDlgItemText(IDOK, szVal); - GetDlgItemText(IDCANCEL, strKey); - GetPrivateProfileString("DIALOG-QUIT", strKey, strKey, szVal, 256, szPath); - SetDlgItemText(IDCANCEL, szVal); - - GetPrivateProfileString("DIALOG-QUIT", m_strSelTT, m_strSelTT, szVal, 256, szPath); - m_strSelTT.Format("%s", szVal); -} - -////////// -// CQuitDialog::OnInitDialog -// arguments: void -// returns: true if windows needs to give dialog focus, false if dialog has taken focus -// function: initializes and centers dialog box -BOOL CQuitDialog::OnInitDialog() -{ - CDialog::OnInitDialog(); - m_strSelTT.Format("Select the project you wish to quit."); - LoadLanguage(); - CListBox* pListBox = (CListBox*)GetDlgItem(IDC_LIST); - if(pListBox) { - for(int i = 0; i < gstate.projects.size(); i ++) { - pListBox->AddString(gstate.projects[i]->get_project_name()); - } - pListBox->SetFocus(); - } - CenterWindow(); - EnableToolTips(TRUE); - return TRUE; -} - -////////// -// CQuitDialog::OnOK -// arguments: void -// returns: void -// function: sets member variables, selected project to quit -void CQuitDialog::OnOK() -{ - m_nSel = -1; - CListBox* pListBox = (CListBox*)GetDlgItem(IDC_LIST); - if(pListBox) { - m_nSel = pListBox->GetCurSel(); - } - if(m_nSel >= 0) CDialog::OnOK(); - else CDialog::OnCancel(); -} - -////////// -// CQuitDialog::OnToolTipNotify -// arguments: id: id of the window, actually its hwnd -// pNMHDR: pointer to notification message header -// pResult: pointer to result of notification -// returns: true if the notification is processed, otherwise false -// function: handles notifications of tool tips by filling in -// text for tool tips -BOOL CQuitDialog::OnToolTipNotify(UINT id, NMHDR *pNMHDR, LRESULT *pResult) -{ - // need to handle both ANSI and UNICODE versions of the message - TOOLTIPTEXTA* pTTTA = (TOOLTIPTEXTA*)pNMHDR; - TOOLTIPTEXTW* pTTTW = (TOOLTIPTEXTW*)pNMHDR; - CString strTipText; - UINT nID = pNMHDR->idFrom; - if(pNMHDR->code == TTN_NEEDTEXTA && (pTTTA->uFlags & TTF_IDISHWND) || - pNMHDR->code == TTN_NEEDTEXTW && (pTTTW->uFlags & TTF_IDISHWND)) { - - // idFrom is actually the HWND of the tool - CWnd* wnd = CWnd::FromHandle((HWND)nID); - if(wnd) nID = wnd->GetDlgCtrlID(); - } - - if(nID == IDC_LIST) strTipText = m_strSelTT; - if(pNMHDR->code == TTN_NEEDTEXTA) { - lstrcpyn(pTTTA->szText, strTipText, sizeof(pTTTA->szText)); - } else { - _mbstowcsz(pTTTW->szText, strTipText, sizeof(pTTTW->szText)); - } - *pResult = 0; - - // message was handled - return TRUE; -} - ///////////////////////////////////////////////////////////////////////// // CProxyDialog message map and member functions diff --git a/client/win/wingui_dialog.h b/client/win/wingui_dialog.h index 5c53a0a092..51fab500df 100755 --- a/client/win/wingui_dialog.h +++ b/client/win/wingui_dialog.h @@ -44,26 +44,6 @@ protected: DECLARE_MESSAGE_MAP() }; -////////// -// class: CQuitDialog -// parent: CDialog -// description: gets project quit information from user. -class CQuitDialog : public CDialog -{ -public: - CQuitDialog(UINT); - afx_msg BOOL OnInitDialog(); - int m_nSel; - -protected: - CString m_strSelTT; - void LoadLanguage(); - - afx_msg void OnOK(); - afx_msg BOOL OnToolTipNotify(UINT, NMHDR*, LRESULT*); - DECLARE_MESSAGE_MAP() -}; - ////////// // class: CProxyDialog // parent: CDialog diff --git a/client/win/wingui_listctrl.cpp b/client/win/wingui_listctrl.cpp index cc208736b2..6daac55e34 100755 --- a/client/win/wingui_listctrl.cpp +++ b/client/win/wingui_listctrl.cpp @@ -296,9 +296,9 @@ int CProgressListCtrl::InsertColumn(int nCol, LPCTSTR lpszColumnHeading, int nFo // function: adds a new item to the list control int CProgressListCtrl::InsertItem(int nItem, LPCTSTR lpszItem) { - m_ItemColors.InsertAt(nItem, RGB(0, 0, 0)); - CString StrEmpty; - m_ProjectURLs.InsertAt(nItem, StrEmpty); + //m_ItemColors.InsertAt(nItem, RGB(0, 0, 0)); + //CString StrEmpty; + //m_ProjectURLs.InsertAt(nItem, StrEmpty); return CListCtrl::InsertItem(nItem, lpszItem); } @@ -373,11 +373,6 @@ BOOL CProgressListCtrl::DeleteItem(int nItem) { int i, si; - // remove array info - m_ItemColors.RemoveAt(nItem); - CString empty; - m_ProjectURLs.RemoveAt(nItem); - CString strbuf; CProgressBarCtrl* pProgCtrl = NULL; @@ -502,51 +497,6 @@ void CProgressListCtrl::SwapItems(int nItem1, int nItem2) return; } - // swap url data - bool bOk1 = false, bOk2 = false; - CString StrTemp1, StrTemp2, StrEmpty; - if(nItem1 < m_ProjectURLs.GetSize()) { - StrTemp1 = m_ProjectURLs.GetAt(nItem1); - bOk1 = true; - } - if(nItem2 < m_ProjectURLs.GetSize()) { - StrTemp2 = m_ProjectURLs.GetAt(nItem2); - bOk2 = true; - } - if(bOk1) { - m_ProjectURLs.SetAtGrow(nItem2, StrTemp1); - } else { - m_ProjectURLs.SetAtGrow(nItem2, StrEmpty); - } - if(bOk2) { - m_ProjectURLs.SetAtGrow(nItem1, StrTemp2); - } else { - m_ProjectURLs.SetAtGrow(nItem1, StrEmpty); - } - - // swap color data - bOk1 = false; - bOk2 = false; - COLORREF tempclr1, tempclr2, emptyclr = RGB(0, 0, 0); - if(nItem1 < m_ItemColors.GetSize()) { - tempclr1 = m_ItemColors.GetAt(nItem1); - bOk1 = true; - } - if(nItem2 < m_ItemColors.GetSize()) { - tempclr2 = m_ItemColors.GetAt(nItem2); - bOk2 = true; - } - if(bOk1) { - m_ItemColors.SetAtGrow(nItem2, tempclr1); - } else { - m_ItemColors.SetAtGrow(nItem2, emptyclr); - } - if(bOk2) { - m_ItemColors.SetAtGrow(nItem1, tempclr2); - } else { - m_ItemColors.SetAtGrow(nItem1, emptyclr); - } - // swap indices dwData1 = GetItemData(nItem1); dwData2 = GetItemData(nItem2); @@ -673,7 +623,7 @@ void CProgressListCtrl::SwapColumnVisibility(int nCol) // function: causes an item to be displayed in the given color void CProgressListCtrl::SetItemColor(int nItem, COLORREF newclr) { - m_ItemColors.SetAtGrow(nItem, newclr); + //m_ItemColors.SetAtGrow(nItem, newclr); CProgressBarCtrl *pProgCtrl; CString strBuf; @@ -688,21 +638,6 @@ void CProgressListCtrl::SetItemColor(int nItem, COLORREF newclr) } } -////////// -// CProgressListCtrl::SetProjectURL -// arguments: nItem: the item to set the url for -// szUrl: the url for the link -// returns: void -// function: sets the url for a project's link, causing the text of -// the first subitem for the given item to be displayed -// as a link -void CProgressListCtrl::SetProjectURL(int nItem, char* szUrl) -{ - CString StrUrl; - StrUrl.Format("%s", szUrl); - m_ProjectURLs.SetAtGrow(nItem, StrUrl); -} - ////////// // CProgressListCtrl::GetTextRect // arguments: nItem: item to get the rect of @@ -853,15 +788,6 @@ void CProgressListCtrl::OnCustomDraw(NMHDR* pNMHDR, LRESULT* pResult) CFont* curFont = cdc->GetCurrentFont(); LOGFONT lf; curFont->GetLogFont(&lf); - if(pLVCD->nmcd.dwItemSpec < m_ItemColors.GetSize()) { - pLVCD->clrText = m_ItemColors.GetAt(pLVCD->nmcd.dwItemSpec); - } - if(pLVCD->nmcd.dwItemSpec < m_ProjectURLs.GetSize() && !m_ProjectURLs.GetAt(pLVCD->nmcd.dwItemSpec).IsEmpty()) { - if(pLVCD->iSubItem == 0) { - lf.lfUnderline = true; - pLVCD->clrText = RGB(0, 0, 255); - } - } CFont* pNewFont = new CFont; pNewFont->CreateFontIndirect(&lf); m_OldFont = cdc->SelectObject(pNewFont); @@ -899,35 +825,6 @@ void CProgressListCtrl::OnDestroy() } } -////////// -// CProgressListCtrl::OnSetCursor -// arguments: pWnd: window containing the cursor -// nHitTest: hit test area code -// message: mouse message number -// returns: true if the message should not be processed further, false otherwise -// function: checks if the cursor is over a link, if so, -// changes it to the hand -BOOL CProgressListCtrl::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message) -{ - CPoint point; - GetCursorPos(&point); - ScreenToClient(&point); - CRect hit; - for(int i = 0; i < GetItemCount(); i ++) { - if(i < m_ProjectURLs.GetSize() && !m_ProjectURLs.GetAt(i).IsEmpty()) { - GetTextRect(i, 0, &hit); - if(hit.PtInRect(point)) { - HCURSOR hand = LoadCursor(NULL, IDC_HAND); - if(hand) { - SetCursor(hand); - return TRUE; - } - } - } - } - return CWnd::OnSetCursor(pWnd, nHitTest, message); -} - ////////// // CProgressListCtrl::OnLButtonDown // arguments: nFlags: message flags (keys down) @@ -936,15 +833,6 @@ BOOL CProgressListCtrl::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message) // function: stops control from highlighting items, opens links void CProgressListCtrl::OnLButtonDown(UINT nFlags, CPoint point) { - CRect hit; - for(int i = 0; i < GetItemCount(); i ++) { - if(i < m_ProjectURLs.GetSize() && !m_ProjectURLs.GetAt(i).IsEmpty()) { - GetTextRect(i, 0, &hit); - if(hit.PtInRect(point)) { - ShellExecute(GetSafeHwnd(), "open", m_ProjectURLs.GetAt(i).GetBuffer(0), "", "", SW_SHOWNORMAL); - } - } - } } ////////// diff --git a/client/win/wingui_listctrl.h b/client/win/wingui_listctrl.h index bfaf13a5a2..f3b0f092e3 100755 --- a/client/win/wingui_listctrl.h +++ b/client/win/wingui_listctrl.h @@ -95,7 +95,6 @@ public: CString GetItemTextOrPos(int, int); BOOL SetColumnWidth(int, int); void SetItemColor(int, COLORREF); - void SetProjectURL(int, char*); void SetMenuItems(char**, int); void SaveInactive(char*, char*); void LoadInactive(char*, char*); @@ -107,8 +106,6 @@ protected: CArray 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_nSort; // 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) CFont* m_OldFont; // old font for setting subitem font - CArray m_ItemColors; // special colors of items - CArray m_ProjectURLs; // urls for project links void SwapItems(int, int); void QSort(int, int, int, int); @@ -121,7 +118,6 @@ protected: afx_msg BOOL OnNotify(WPARAM, LPARAM, LRESULT*); afx_msg void OnCustomDraw(NMHDR*, LRESULT*); afx_msg void OnPaint(); - afx_msg BOOL OnSetCursor(CWnd*, UINT, UINT); afx_msg void OnLButtonDown(UINT, CPoint); afx_msg void OnRButtonDown(UINT, CPoint); DECLARE_MESSAGE_MAP() diff --git a/client/win/wingui_mainwindow.cpp b/client/win/wingui_mainwindow.cpp index 79ad8c8bc1..696abdde82 100755 --- a/client/win/wingui_mainwindow.cpp +++ b/client/win/wingui_mainwindow.cpp @@ -70,12 +70,13 @@ BEGIN_MESSAGE_MAP(CMainWindow, CWnd) ON_COMMAND(ID_FILE_SUSPEND, OnCommandSuspend) ON_COMMAND(ID_FILE_RESUME, OnCommandResume) ON_COMMAND(ID_FILE_EXIT, OnCommandExit) - ON_COMMAND(ID_CONNECTION_CONNECTNOW, OnCommandConnectionConnectNow) ON_COMMAND(ID_SETTINGS_LOGIN, OnCommandSettingsLogin) - ON_COMMAND(ID_SETTINGS_QUIT, OnCommandSettingsQuit) ON_COMMAND(ID_SETTINGS_PROXYSERVER, OnCommandSettingsProxyServer) ON_COMMAND(ID_HELP_ABOUT, OnCommandHelpAbout) - ON_COMMAND(ID_PROJECT_QUIT, OnCommandProjectQuit) + ON_COMMAND(ID_PROJECT_WEB_SITE, OnCommandProjectWebSite) + ON_COMMAND(ID_PROJECT_GET_PREFS, OnCommandProjectGetPrefs) + ON_COMMAND(ID_PROJECT_DETACH, OnCommandProjectDetach) + ON_COMMAND(ID_PROJECT_RESET, OnCommandProjectReset) ON_COMMAND(ID_WORK_SHOWGRAPHICS, OnCommandWorkShowGraphics) ON_COMMAND(ID_STATUSICON_HIDE, OnCommandHide) ON_COMMAND(ID_STATUSICON_SUSPEND, OnCommandSuspend) @@ -941,24 +942,6 @@ void CMainWindow::OnClose() ShowWindow(SW_HIDE); } -////////// -// CMainWindow::OnCommandSettingsQuit -// arguments: void -// returns: void -// function: shows the account quit dialog box -void CMainWindow::OnCommandSettingsQuit() -{ - CQuitDialog dlg(IDD_QUIT); - int nResult = dlg.DoModal(); - if(nResult == IDOK) { - CString str; - str.Format("Are you sure you want to quit the project %s?", gstate.projects[dlg.m_nSel]->get_project_name()); - if(AfxMessageBox(str, MB_YESNO, 0) == IDYES) { - gstate.quit_project(gstate.projects[dlg.m_nSel]); - } - } -} - ////////// // CMainWindow::OnCommandSettingsLogin // arguments: void @@ -1044,37 +1027,83 @@ void CMainWindow::OnCommandFileClearMessages() // arguments: void // returns: void // function: causes the client to connect to the network -void CMainWindow::OnCommandConnectionConnectNow() +/*void CMainWindow::OnCommandConnectionConnectNow() { for(int ii = 0; ii < gstate.projects.size(); ii ++) { gstate.projects[ii]->sched_rpc_pending = true; } +}*/ + +////////// +// CMainWindow::GetProjectFromContextMenu +// arguments: void +// returns: PROJECT * +// function: returns the project associated with the most +// recently selected context menu item +PROJECT* CMainWindow::GetProjectFromContextMenu() { + if(m_nContextItem < 0 || m_nContextItem > m_ProjectListCtrl.GetItemCount()) return NULL; + PROJECT* proj = (PROJECT*)m_ProjectListCtrl.GetItemData(m_nContextItem); + m_nContextItem = -1; + return proj; } ////////// -// CMainWindow::OnCommandProjectQuit +// CMainWindow::OnCommandProjectWebSite // arguments: void // returns: void // function: lets the user quit a project -void CMainWindow::OnCommandProjectQuit() +void CMainWindow::OnCommandProjectWebSite() { - if(m_nContextItem < 0 || m_nContextItem > m_ProjectListCtrl.GetItemCount()) return; - PROJECT* pToQuit = (PROJECT*)m_ProjectListCtrl.GetItemData(m_nContextItem); - m_nContextItem = -1; - if(!pToQuit) return; + PROJECT *proj; + proj = GetProjectFromContextMenu(); + if (proj) ShellExecute(GetSafeHwnd(), "open", proj->master_url, "", "", SW_SHOWNORMAL); +} - // find project index - int i; - for(i = 0; i < gstate.projects.size(); i ++) { - if(gstate.projects[i] == pToQuit) break; - } - if(i == gstate.projects.size()) return; +////////// +// CMainWindow::OnCommandProjectGetPrefs +// arguments: void +// returns: void +// function: lets the user quit a project +void CMainWindow::OnCommandProjectGetPrefs() +{ + PROJECT *proj; + proj = GetProjectFromContextMenu(); + if (proj) proj->sched_rpc_pending = true; +} - // confirm and quit +////////// +// CMainWindow::OnCommandProjectDetach +// arguments: void +// returns: void +// function: lets the user quit a project +void CMainWindow::OnCommandProjectDetach() +{ + PROJECT *proj; CString strBuf; - strBuf.Format("Are you sure you want to quit the project %s?", gstate.projects[i]->get_project_name()); + proj = GetProjectFromContextMenu(); + if (!proj) return; + strBuf.Format("Are you sure you want to detach from the project %s?", + proj->get_project_name()); if(AfxMessageBox(strBuf, MB_YESNO, 0) == IDYES) { - gstate.quit_project(gstate.projects[i]); + gstate.detach_project(proj); + } +} + +////////// +// CMainWindow::OnCommandProjectReset +// arguments: void +// returns: void +// function: lets the user quit a project +void CMainWindow::OnCommandProjectReset() +{ + PROJECT *proj; + CString strBuf; + proj = GetProjectFromContextMenu(); + if (!proj) return; + strBuf.Format("Are you sure you want to reset the project %s?", + proj->get_project_name()); + if(AfxMessageBox(strBuf, MB_YESNO, 0) == IDYES) { + gstate.reset_project(proj); } } @@ -1488,9 +1517,10 @@ void CMainWindow::OnSetFocus(CWnd* pOldWnd) m_bMessage = false; SetStatusIcon(ICON_NORMAL); } + // TODO: review this if(m_bRequest) { m_bRequest = false; - if(RequestNetConnect()) OnCommandConnectionConnectNow(); +// if(RequestNetConnect()) OnCommandConnectionConnectNow(); } } diff --git a/client/win/wingui_mainwindow.h b/client/win/wingui_mainwindow.h index 0c45b666e3..5fe9a65b6a 100755 --- a/client/win/wingui_mainwindow.h +++ b/client/win/wingui_mainwindow.h @@ -122,6 +122,7 @@ protected: void SaveUserSettings(); void LoadUserSettings(); void LoadLanguage(); + PROJECT* GetProjectFromContextMenu(); DWORD GetUserIdleTime(); void Syncronize(CProgressListCtrl*, vector*); virtual void PostNcDestroy(); @@ -132,11 +133,14 @@ protected: afx_msg void OnCommandSettingsLogin(); afx_msg void OnCommandSettingsProxyServer(); afx_msg void OnCommandHelpAbout(); - afx_msg void OnCommandProjectQuit(); + afx_msg void OnCommandProjectWebSite(); + afx_msg void OnCommandProjectGetPrefs(); + afx_msg void OnCommandProjectDetach(); + afx_msg void OnCommandProjectReset(); afx_msg void OnCommandWorkShowGraphics(); afx_msg void OnCommandFileClearInactive(); afx_msg void OnCommandFileClearMessages(); - afx_msg void OnCommandConnectionConnectNow(); +// afx_msg void OnCommandConnectionConnectNow(); afx_msg void OnCommandConnectionHangupIfDialed(); afx_msg void OnCommandConnectionConfirmBeforeConnecting(); afx_msg void OnCommandHide();