2008-08-06 18:36:30 +00:00
|
|
|
// This file is part of BOINC.
|
2005-01-20 23:22:22 +00:00
|
|
|
// http://boinc.berkeley.edu
|
2008-08-06 18:36:30 +00:00
|
|
|
// Copyright (C) 2008 University of California
|
2004-09-21 01:30:29 +00:00
|
|
|
//
|
2008-08-06 18:36:30 +00:00
|
|
|
// 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.
|
2004-09-21 01:30:29 +00:00
|
|
|
//
|
2008-08-06 18:36:30 +00:00
|
|
|
// BOINC is distributed in the hope that it will be useful,
|
2005-01-20 23:22:22 +00:00
|
|
|
// 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
|
|
|
//
|
2008-08-06 18:36:30 +00:00
|
|
|
// You should have received a copy of the GNU Lesser General Public License
|
|
|
|
// along with BOINC. If not, see <http://www.gnu.org/licenses/>.
|
2004-09-21 01:30:29 +00:00
|
|
|
|
|
|
|
#ifndef _BOINCLISTCTRL_H_
|
|
|
|
#define _BOINCLISTCTRL_H_
|
|
|
|
|
|
|
|
#if defined(__GNUG__) && !defined(__APPLE__)
|
|
|
|
#pragma interface "BOINCListCtrl.cpp"
|
|
|
|
#endif
|
|
|
|
|
2008-06-24 10:52:12 +00:00
|
|
|
#ifdef __WXMSW__
|
|
|
|
#define USE_NATIVE_LISTCONTROL 1
|
|
|
|
#else
|
|
|
|
#define USE_NATIVE_LISTCONTROL 0
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if USE_NATIVE_LISTCONTROL
|
|
|
|
#define LISTCTRL_BASE wxListCtrl
|
|
|
|
#include "wx/listctrl.h"
|
|
|
|
#else
|
2008-09-11 23:14:36 +00:00
|
|
|
// In wxMac-2.8.7, default wxListCtrl::RefreshItem() does not work
|
|
|
|
// so use traditional generic implementation.
|
|
|
|
// This has been fixed in wxMac-2.8.8, but the Mac native implementation:
|
|
|
|
// - takes 3 times the CPU time as the Mac generic version.
|
|
|
|
// - seems to always redraw entire control even if asked to refresh only one row.
|
|
|
|
// - causes major flicker of progress bars, (probably due to full redraws.)
|
2008-06-24 10:52:12 +00:00
|
|
|
#define LISTCTRL_BASE wxGenericListCtrl
|
|
|
|
#include "wx/generic/listctrl.h"
|
|
|
|
#endif
|
2004-09-21 01:30:29 +00:00
|
|
|
|
|
|
|
class CBOINCBaseView;
|
2008-10-06 11:33:28 +00:00
|
|
|
class CDrawProgressBarEvent;
|
2004-09-21 01:30:29 +00:00
|
|
|
|
2008-06-24 10:52:12 +00:00
|
|
|
class CBOINCListCtrl : public LISTCTRL_BASE {
|
2005-04-10 19:01:23 +00:00
|
|
|
DECLARE_DYNAMIC_CLASS(CBOINCListCtrl)
|
2004-09-21 01:30:29 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
CBOINCListCtrl();
|
2005-04-10 19:01:23 +00:00
|
|
|
CBOINCListCtrl(CBOINCBaseView* pView, wxWindowID iListWindowID, int iListWindowFlags);
|
2004-09-21 01:30:29 +00:00
|
|
|
|
|
|
|
~CBOINCListCtrl();
|
|
|
|
|
2005-04-10 19:01:23 +00:00
|
|
|
virtual bool OnSaveState(wxConfigBase* pConfig);
|
|
|
|
virtual bool OnRestoreState(wxConfigBase* pConfig);
|
2004-09-21 01:30:29 +00:00
|
|
|
|
2008-06-27 04:34:47 +00:00
|
|
|
long GetFocusedItem() { return GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_FOCUSED); }
|
2008-06-24 11:47:34 +00:00
|
|
|
long GetFirstSelected() { return GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED); }
|
2008-09-04 13:00:24 +00:00
|
|
|
long GetNextSelected(int i) { return GetNextItem(i, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED); }
|
|
|
|
void SelectRow(int row, bool setSelected);
|
2008-10-06 11:33:28 +00:00
|
|
|
void AddPendingProgressBar(int row);
|
2008-10-10 08:47:02 +00:00
|
|
|
void RefreshCell(int row, int col);
|
2008-09-04 13:00:24 +00:00
|
|
|
|
2008-06-27 04:34:47 +00:00
|
|
|
bool m_bIsSingleSelection;
|
|
|
|
|
2004-09-21 01:30:29 +00:00
|
|
|
private:
|
2005-04-10 19:01:23 +00:00
|
|
|
virtual void OnClick(wxCommandEvent& event);
|
2004-12-10 20:46:43 +00:00
|
|
|
|
2005-04-10 19:01:23 +00:00
|
|
|
virtual wxString OnGetItemText(long item, long column) const;
|
|
|
|
virtual int OnGetItemImage(long item) const;
|
|
|
|
virtual wxListItemAttr* OnGetItemAttr(long item) const;
|
2004-09-24 02:01:53 +00:00
|
|
|
|
2004-09-21 01:30:29 +00:00
|
|
|
CBOINCBaseView* m_pParentView;
|
2008-09-09 10:09:54 +00:00
|
|
|
wxArrayInt m_iRowsNeedingProgressBars;
|
2004-09-21 01:30:29 +00:00
|
|
|
|
2008-06-24 10:52:12 +00:00
|
|
|
#if USE_NATIVE_LISTCONTROL
|
|
|
|
public:
|
2008-10-06 11:33:28 +00:00
|
|
|
void PostDrawProgressBarEvent();
|
2008-06-24 10:52:12 +00:00
|
|
|
private:
|
2008-10-06 11:33:28 +00:00
|
|
|
void OnDrawProgressBar(CDrawProgressBarEvent& event);
|
|
|
|
void DrawProgressBars(void);
|
2008-06-24 10:52:12 +00:00
|
|
|
|
2008-10-06 11:33:28 +00:00
|
|
|
bool m_bProgressBarEventPending;
|
2008-06-24 11:47:34 +00:00
|
|
|
|
|
|
|
DECLARE_EVENT_TABLE()
|
2008-06-24 10:52:12 +00:00
|
|
|
#else
|
|
|
|
public:
|
2008-10-06 11:33:28 +00:00
|
|
|
void DrawProgressBars(void);
|
2008-06-24 11:56:06 +00:00
|
|
|
wxScrolledWindow* GetMainWin(void) { return (wxScrolledWindow*) m_mainWin; }
|
|
|
|
wxCoord GetHeaderHeight(void) { return m_headerHeight; }
|
2009-10-29 11:13:48 +00:00
|
|
|
#ifdef __WXMAC__
|
2009-11-25 12:43:22 +00:00
|
|
|
void SetupMacAccessibilitySupport();
|
|
|
|
void RemoveMacAccessibilitySupport();
|
2009-10-29 11:13:48 +00:00
|
|
|
CBOINCBaseView* GetParentView() { return m_pParentView; }
|
|
|
|
|
|
|
|
HIViewRef m_headerView;
|
|
|
|
HIViewRef m_bodyView;
|
|
|
|
|
|
|
|
EventHandlerRef m_pHeaderAccessibilityEventHandlerRef;
|
|
|
|
EventHandlerRef m_pBodyAccessibilityEventHandlerRef;
|
|
|
|
#endif
|
2008-06-24 10:52:12 +00:00
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
2008-10-06 11:33:28 +00:00
|
|
|
class CDrawProgressBarEvent : public wxEvent
|
2008-06-24 10:52:12 +00:00
|
|
|
{
|
|
|
|
public:
|
2008-10-06 11:33:28 +00:00
|
|
|
CDrawProgressBarEvent(wxEventType evtType, CBOINCListCtrl* myCtrl)
|
2008-06-24 10:52:12 +00:00
|
|
|
: wxEvent(-1, evtType)
|
|
|
|
{
|
|
|
|
SetEventObject(myCtrl);
|
|
|
|
}
|
|
|
|
|
2008-10-06 11:33:28 +00:00
|
|
|
virtual wxEvent * Clone() const { return new CDrawProgressBarEvent(*this); }
|
2004-09-21 01:30:29 +00:00
|
|
|
};
|
|
|
|
|
2008-06-24 10:52:12 +00:00
|
|
|
BEGIN_DECLARE_EVENT_TYPES()
|
2008-10-06 11:33:28 +00:00
|
|
|
DECLARE_EVENT_TYPE( wxEVT_DRAW_PROGRESSBAR, 12000 )
|
2008-06-24 10:52:12 +00:00
|
|
|
END_DECLARE_EVENT_TYPES()
|
|
|
|
|
2008-10-06 11:33:28 +00:00
|
|
|
#define EVT_DRAW_PROGRESSBAR(fn) DECLARE_EVENT_TABLE_ENTRY(wxEVT_DRAW_PROGRESSBAR, -1, -1, (wxObjectEventFunction) (wxEventFunction) &fn, NULL),
|
2008-06-24 10:52:12 +00:00
|
|
|
|
|
|
|
|
|
|
|
// Define a custom event handler
|
|
|
|
class MyEvtHandler : public wxEvtHandler
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
MyEvtHandler(CBOINCListCtrl *theListControl) { m_listCtrl = theListControl; }
|
2008-06-24 11:56:06 +00:00
|
|
|
void OnPaint(wxPaintEvent & event);
|
2008-06-24 10:52:12 +00:00
|
|
|
|
|
|
|
private:
|
2008-06-24 11:56:06 +00:00
|
|
|
CBOINCListCtrl * m_listCtrl;
|
2008-06-24 10:52:12 +00:00
|
|
|
|
|
|
|
DECLARE_EVENT_TABLE()
|
|
|
|
};
|
2004-09-21 01:30:29 +00:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|