2004-09-21 01:30:29 +00:00
|
|
|
// $Id$
|
|
|
|
//
|
|
|
|
// The contents of this file are subject to the BOINC 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://boinc.berkeley.edu/license_1.0.txt
|
|
|
|
//
|
|
|
|
// 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):
|
|
|
|
//
|
|
|
|
// Revision History:
|
|
|
|
//
|
|
|
|
|
|
|
|
#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)
|
|
|
|
|
|
|
|
|
|
|
|
CBOINCListCtrl::CBOINCListCtrl()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-10-27 21:10:22 +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;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
CBOINCListCtrl::~CBOINCListCtrl()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-10-05 02:55:26 +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;
|
|
|
|
|
|
|
|
|
|
|
|
wxASSERT(NULL != pConfig);
|
|
|
|
|
|
|
|
|
|
|
|
// 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?
|
|
|
|
liColumnInfo.SetMask( wxLIST_MASK_TEXT |
|
|
|
|
wxLIST_MASK_WIDTH |
|
|
|
|
wxLIST_MASK_FORMAT );
|
|
|
|
|
|
|
|
// Cycle through the columns recording anything interesting
|
2004-10-26 01:59:44 +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;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-10-05 02:55:26 +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;
|
|
|
|
|
|
|
|
|
|
|
|
wxASSERT(NULL != pConfig);
|
|
|
|
|
|
|
|
|
|
|
|
// 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?
|
|
|
|
liColumnInfo.SetMask( wxLIST_MASK_TEXT |
|
|
|
|
wxLIST_MASK_WIDTH |
|
|
|
|
wxLIST_MASK_FORMAT );
|
|
|
|
|
|
|
|
// Cycle through the columns recording anything interesting
|
2004-10-26 01:59:44 +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;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wxString CBOINCListCtrl::OnGetItemText( long item, long column ) const
|
|
|
|
{
|
|
|
|
wxASSERT(NULL != m_pParentView);
|
|
|
|
wxASSERT(wxDynamicCast(m_pParentView, CBOINCBaseView));
|
|
|
|
|
2004-10-26 18:36:47 +00:00
|
|
|
return m_pParentView->FireOnListGetItemText( item, column );
|
2004-09-21 01:30:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int CBOINCListCtrl::OnGetItemImage( long item ) const
|
|
|
|
{
|
|
|
|
wxASSERT(NULL != m_pParentView);
|
|
|
|
wxASSERT(wxDynamicCast(m_pParentView, CBOINCBaseView));
|
|
|
|
|
2004-10-26 18:36:47 +00:00
|
|
|
return m_pParentView->FireOnListGetItemImage( item );
|
2004-09-21 01:30:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wxListItemAttr* CBOINCListCtrl::OnGetItemAttr( long item ) const
|
|
|
|
{
|
|
|
|
wxASSERT(NULL != m_pParentView);
|
|
|
|
wxASSERT(wxDynamicCast(m_pParentView, CBOINCBaseView));
|
|
|
|
|
2004-10-26 18:36:47 +00:00
|
|
|
return m_pParentView->FireOnListGetItemAttr( item );
|
2004-09-21 01:30:29 +00:00
|
|
|
}
|
|
|
|
|