2005-01-20 23:22:22 +00:00
|
|
|
// Berkeley Open Infrastructure for Network Computing
|
|
|
|
// http://boinc.berkeley.edu
|
|
|
|
// Copyright (C) 2005 University of California
|
2004-09-21 01:30:29 +00:00
|
|
|
//
|
2005-01-20 23:22:22 +00:00
|
|
|
// This 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 2.1 of the License, or (at your option) any later version.
|
2004-09-21 01:30:29 +00:00
|
|
|
//
|
2005-01-20 23:22:22 +00:00
|
|
|
// This software 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.
|
2004-09-21 01:30:29 +00:00
|
|
|
//
|
2005-01-20 23:22:22 +00:00
|
|
|
// To view the GNU Lesser General Public License visit
|
|
|
|
// http://www.gnu.org/copyleft/lesser.html
|
|
|
|
// or write to the Free Software Foundation, Inc.,
|
|
|
|
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
2004-09-21 01:30:29 +00:00
|
|
|
|
|
|
|
#if defined(__GNUG__) && !defined(__APPLE__)
|
|
|
|
#pragma implementation "BOINCListCtrl.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "stdwx.h"
|
|
|
|
#include "BOINCBaseView.h"
|
|
|
|
#include "BOINCListCtrl.h"
|
2004-09-24 02:01:53 +00:00
|
|
|
#include "Events.h"
|
2004-09-21 01:30:29 +00:00
|
|
|
|
|
|
|
|
|
|
|
IMPLEMENT_DYNAMIC_CLASS(CBOINCListCtrl, wxListView)
|
|
|
|
|
|
|
|
|
2005-04-08 16:58:55 +00:00
|
|
|
CBOINCListCtrl::CBOINCListCtrl() {}
|
2004-09-21 01:30:29 +00:00
|
|
|
|
|
|
|
|
2005-04-08 16:58:55 +00:00
|
|
|
CBOINCListCtrl::CBOINCListCtrl(
|
|
|
|
CBOINCBaseView* pView, wxWindowID iListWindowID, wxInt32 iListWindowFlags
|
|
|
|
) : wxListView(
|
|
|
|
pView, iListWindowID, wxDefaultPosition, wxSize(-1, -1), iListWindowFlags
|
|
|
|
) {
|
2004-09-21 01:30:29 +00:00
|
|
|
m_pParentView = pView;
|
2004-12-10 20:46:43 +00:00
|
|
|
|
2005-04-07 07:04:50 +00:00
|
|
|
m_bIsSingleSelection = (iListWindowFlags & wxLC_SINGLE_SEL) ? true : false ;
|
2004-12-10 20:46:43 +00:00
|
|
|
|
2005-04-07 07:04:50 +00:00
|
|
|
Connect(
|
2004-12-10 20:46:43 +00:00
|
|
|
iListWindowID,
|
|
|
|
wxEVT_COMMAND_LEFT_CLICK,
|
2004-12-10 21:29:22 +00:00
|
|
|
(wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) &CBOINCListCtrl::OnClick
|
2005-04-08 16:58:55 +00:00
|
|
|
);
|
2004-09-21 01:30:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
CBOINCListCtrl::~CBOINCListCtrl()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-04-07 07:04:50 +00:00
|
|
|
bool CBOINCListCtrl::OnSaveState(wxConfigBase* pConfig) {
|
2004-10-26 01:59:44 +00:00
|
|
|
wxString strBaseConfigLocation = wxEmptyString;
|
2004-09-21 01:30:29 +00:00
|
|
|
wxListItem liColumnInfo;
|
|
|
|
wxInt32 iIndex = 0;
|
|
|
|
wxInt32 iColumnCount = 0;
|
|
|
|
|
|
|
|
|
2005-04-27 06:55:28 +00:00
|
|
|
wxASSERT(pConfig);
|
2004-09-21 01:30:29 +00:00
|
|
|
|
|
|
|
|
|
|
|
// Retrieve the base location to store configuration information
|
|
|
|
// Should be in the following form: "/Projects/"
|
2004-10-05 02:55:26 +00:00
|
|
|
strBaseConfigLocation = pConfig->GetPath() + wxT("/");
|
2004-09-21 01:30:29 +00:00
|
|
|
|
|
|
|
// Convert to a zero based index
|
|
|
|
iColumnCount = GetColumnCount() - 1;
|
|
|
|
|
|
|
|
// Which fields are we interested in?
|
2005-04-07 07:04:50 +00:00
|
|
|
liColumnInfo.SetMask(
|
|
|
|
wxLIST_MASK_TEXT |
|
|
|
|
wxLIST_MASK_WIDTH |
|
|
|
|
wxLIST_MASK_FORMAT
|
|
|
|
);
|
2004-09-21 01:30:29 +00:00
|
|
|
|
|
|
|
// Cycle through the columns recording anything interesting
|
2005-04-07 07:04:50 +00:00
|
|
|
for (iIndex = 0; iIndex <= iColumnCount; iIndex++) {
|
2004-09-21 01:30:29 +00:00
|
|
|
GetColumn(iIndex, liColumnInfo);
|
|
|
|
|
|
|
|
pConfig->SetPath(strBaseConfigLocation + liColumnInfo.GetText());
|
|
|
|
|
2004-10-05 02:55:26 +00:00
|
|
|
pConfig->Write(wxT("Width"), liColumnInfo.GetWidth());
|
2004-09-21 01:30:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-04-07 07:04:50 +00:00
|
|
|
bool CBOINCListCtrl::OnRestoreState(wxConfigBase* pConfig) {
|
2004-10-26 01:59:44 +00:00
|
|
|
wxString strBaseConfigLocation = wxEmptyString;
|
2004-09-21 01:30:29 +00:00
|
|
|
wxListItem liColumnInfo;
|
|
|
|
wxInt32 iIndex = 0;
|
|
|
|
wxInt32 iColumnCount = 0;
|
|
|
|
wxInt32 iTempValue = 0;
|
|
|
|
|
|
|
|
|
2005-04-27 06:55:28 +00:00
|
|
|
wxASSERT(pConfig);
|
2004-09-21 01:30:29 +00:00
|
|
|
|
|
|
|
|
|
|
|
// Retrieve the base location to store configuration information
|
|
|
|
// Should be in the following form: "/Projects/"
|
2004-10-05 02:55:26 +00:00
|
|
|
strBaseConfigLocation = pConfig->GetPath() + wxT("/");
|
2004-09-21 01:30:29 +00:00
|
|
|
|
|
|
|
// Convert to a zero based index
|
|
|
|
iColumnCount = GetColumnCount() - 1;
|
|
|
|
|
|
|
|
// Which fields are we interested in?
|
2005-04-08 16:58:55 +00:00
|
|
|
liColumnInfo.SetMask(
|
|
|
|
wxLIST_MASK_TEXT | wxLIST_MASK_WIDTH | wxLIST_MASK_FORMAT
|
|
|
|
);
|
2004-09-21 01:30:29 +00:00
|
|
|
|
|
|
|
// Cycle through the columns recording anything interesting
|
2005-04-07 07:04:50 +00:00
|
|
|
for (iIndex = 0; iIndex <= iColumnCount; iIndex++) {
|
2004-09-21 01:30:29 +00:00
|
|
|
GetColumn(iIndex, liColumnInfo);
|
|
|
|
|
|
|
|
pConfig->SetPath(strBaseConfigLocation + liColumnInfo.GetText());
|
|
|
|
|
2004-10-05 02:55:26 +00:00
|
|
|
pConfig->Read(wxT("Width"), &iTempValue, 80);
|
2004-09-21 01:30:29 +00:00
|
|
|
liColumnInfo.SetWidth(iTempValue);
|
|
|
|
|
2004-10-05 02:55:26 +00:00
|
|
|
pConfig->Read(wxT("Format"), &iTempValue, 0);
|
2004-09-21 01:30:29 +00:00
|
|
|
liColumnInfo.SetAlign((wxListColumnFormat)iTempValue);
|
|
|
|
|
|
|
|
SetColumn(iIndex, liColumnInfo);
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-04-07 07:04:50 +00:00
|
|
|
void CBOINCListCtrl::OnClick(wxCommandEvent& event) {
|
2005-04-27 06:55:28 +00:00
|
|
|
wxASSERT(m_pParentView);
|
2004-12-10 20:46:43 +00:00
|
|
|
wxASSERT(wxDynamicCast(m_pParentView, CBOINCBaseView));
|
|
|
|
|
|
|
|
wxListEvent leEvent(wxEVT_COMMAND_LIST_ITEM_DESELECTED, m_windowId);
|
|
|
|
leEvent.SetEventObject(this);
|
|
|
|
|
2005-04-07 07:04:50 +00:00
|
|
|
if (m_bIsSingleSelection) {
|
2005-04-08 16:58:55 +00:00
|
|
|
if (GetFocusedItem() != GetFirstSelected()) {
|
2005-04-21 23:14:10 +00:00
|
|
|
m_pParentView->FireOnListDeselected(leEvent);
|
2005-04-08 16:58:55 +00:00
|
|
|
}
|
2005-04-07 07:04:50 +00:00
|
|
|
} else {
|
2005-04-08 16:58:55 +00:00
|
|
|
if (-1 == GetFirstSelected()) {
|
2005-04-21 23:14:10 +00:00
|
|
|
m_pParentView->FireOnListDeselected(leEvent);
|
2005-04-08 16:58:55 +00:00
|
|
|
}
|
2004-12-10 20:46:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
event.Skip();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-04-07 07:04:50 +00:00
|
|
|
wxString CBOINCListCtrl::OnGetItemText(long item, long column) const {
|
2005-04-27 06:55:28 +00:00
|
|
|
wxASSERT(m_pParentView);
|
2004-09-21 01:30:29 +00:00
|
|
|
wxASSERT(wxDynamicCast(m_pParentView, CBOINCBaseView));
|
|
|
|
|
2005-04-07 07:04:50 +00:00
|
|
|
return m_pParentView->FireOnListGetItemText(item, column);
|
2004-09-21 01:30:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-04-07 07:04:50 +00:00
|
|
|
int CBOINCListCtrl::OnGetItemImage(long item) const {
|
2005-04-27 06:55:28 +00:00
|
|
|
wxASSERT(m_pParentView);
|
2004-09-21 01:30:29 +00:00
|
|
|
wxASSERT(wxDynamicCast(m_pParentView, CBOINCBaseView));
|
|
|
|
|
2005-04-07 07:04:50 +00:00
|
|
|
return m_pParentView->FireOnListGetItemImage(item);
|
2004-09-21 01:30:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-04-07 07:04:50 +00:00
|
|
|
wxListItemAttr* CBOINCListCtrl::OnGetItemAttr(long item) const {
|
2005-04-27 06:55:28 +00:00
|
|
|
wxASSERT(m_pParentView);
|
2004-09-21 01:30:29 +00:00
|
|
|
wxASSERT(wxDynamicCast(m_pParentView, CBOINCBaseView));
|
|
|
|
|
2005-04-07 07:04:50 +00:00
|
|
|
return m_pParentView->FireOnListGetItemAttr(item);
|
2004-09-21 01:30:29 +00:00
|
|
|
}
|
|
|
|
|
2004-12-08 00:40:19 +00:00
|
|
|
|
2005-01-02 18:29:53 +00:00
|
|
|
const char *BOINC_RCSID_5cf411daa0 = "$Id$";
|