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
|
2015-10-20 10:19:53 +00:00
|
|
|
// Copyright (C) 2015 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
|
|
|
|
2017-04-08 06:54:49 +00:00
|
|
|
#ifndef BOINC_BOINCLISTCTRL_H
|
|
|
|
#define BOINC_BOINCLISTCTRL_H
|
2004-09-21 01:30:29 +00:00
|
|
|
|
|
|
|
#if defined(__GNUG__) && !defined(__APPLE__)
|
|
|
|
#pragma interface "BOINCListCtrl.cpp"
|
|
|
|
#endif
|
|
|
|
|
2014-06-05 10:43:46 +00:00
|
|
|
#ifdef __WXMSW__
|
2008-06-24 10:52:12 +00:00
|
|
|
#define USE_NATIVE_LISTCONTROL 1
|
|
|
|
#else
|
|
|
|
#define USE_NATIVE_LISTCONTROL 0
|
|
|
|
#endif
|
|
|
|
|
2014-05-28 08:52:33 +00:00
|
|
|
|
|
|
|
// Virtual wxListCtrl does not reliably generate selection and
|
|
|
|
// deselection events, so we must check for these differently.
|
2014-06-05 09:49:20 +00:00
|
|
|
// We get more events than we need using EVT_LIST_CACHE_HINT,
|
|
|
|
// so testing on mouse events is more efficient, but it doesn't
|
|
|
|
// work on Windows.
|
|
|
|
#ifdef __WXMSW__
|
2014-05-28 08:52:33 +00:00
|
|
|
// On Windows, check for selection / deselection on EVT_LIST_CACHE_HINT.
|
|
|
|
#define USE_LIST_CACHE_HINT 1
|
2014-06-05 09:49:20 +00:00
|
|
|
#else
|
|
|
|
// On Mac & Linux, check for selection / deselection on EVT_LEFT_DOWN.
|
|
|
|
#define USE_LIST_CACHE_HINT 0
|
2014-05-28 08:52:33 +00:00
|
|
|
#endif
|
|
|
|
|
2008-06-24 10:52:12 +00:00
|
|
|
#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
|
|
|
|
2010-03-05 07:04:58 +00:00
|
|
|
#include "BOINCBaseView.h"
|
|
|
|
|
|
|
|
|
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
|
|
|
|
2014-12-05 12:37:07 +00:00
|
|
|
void TokenizedStringToArray(wxString tokenized, char * delimiters, wxArrayString* array);
|
2014-12-11 14:18:47 +00:00
|
|
|
void SetListColumnOrder(wxArrayString& orderArray);
|
2014-12-05 12:37:07 +00:00
|
|
|
void SetStandardColumnOrder();
|
2014-12-11 14:18:47 +00:00
|
|
|
bool IsColumnOrderStandard();
|
2014-12-15 05:47:37 +00:00
|
|
|
void SetDefaultColumnDisplay();
|
2014-12-11 14:18:47 +00:00
|
|
|
void InsertShownColumns(wxString tokenized, char * delimiters);
|
2014-12-05 12:37:07 +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
|
|
|
|
2004-09-21 01:30:29 +00:00
|
|
|
private:
|
2005-04-10 19:01:23 +00:00
|
|
|
virtual wxString OnGetItemText(long item, long column) const;
|
|
|
|
virtual int OnGetItemImage(long item) const;
|
2010-03-05 07:04:58 +00:00
|
|
|
#if BASEVIEW_STRIPES
|
|
|
|
virtual wxListItemAttr* OnGetItemAttr(long item) const;
|
|
|
|
#endif
|
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
|
|
|
|
2014-05-28 19:28:11 +00:00
|
|
|
#if ! USE_LIST_CACHE_HINT
|
|
|
|
void OnMouseDown(wxMouseEvent& event);
|
|
|
|
#endif
|
|
|
|
|
2013-09-09 23:31:49 +00:00
|
|
|
#if USE_NATIVE_LISTCONTROL
|
2008-06-24 10:52:12 +00:00
|
|
|
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;
|
2013-09-09 23:31:49 +00:00
|
|
|
#else
|
2008-06-24 10:52:12 +00:00
|
|
|
public:
|
2013-09-09 23:31:49 +00:00
|
|
|
void DrawProgressBars(void);
|
2008-06-24 11:56:06 +00:00
|
|
|
wxScrolledWindow* GetMainWin(void) { return (wxScrolledWindow*) m_mainWin; }
|
2013-09-09 23:31:49 +00:00
|
|
|
wxCoord GetHeaderHeight(void) { return ((wxWindow *)m_headerWin)->GetSize().y; }
|
|
|
|
wxEvtHandler* savedHandler;
|
2009-10-29 11:13:48 +00:00
|
|
|
#ifdef __WXMAC__
|
2009-11-25 12:43:22 +00:00
|
|
|
void SetupMacAccessibilitySupport();
|
|
|
|
void RemoveMacAccessibilitySupport();
|
2013-10-24 12:49:59 +00:00
|
|
|
void OnSize( wxSizeEvent &event );
|
2013-09-12 11:27:04 +00:00
|
|
|
|
|
|
|
void* m_fauxHeaderView;
|
|
|
|
void* m_fauxBodyView;
|
2009-10-29 11:13:48 +00:00
|
|
|
#endif
|
2008-06-24 10:52:12 +00:00
|
|
|
#endif
|
2013-09-12 11:27:04 +00:00
|
|
|
|
|
|
|
DECLARE_EVENT_TABLE()
|
2008-06-24 10:52:12 +00:00
|
|
|
};
|
|
|
|
|
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
|
|
|
};
|
|
|
|
|
2014-05-22 02:11:22 +00:00
|
|
|
class CCheckSelectionChangedEvent : public wxEvent
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CCheckSelectionChangedEvent(wxEventType evtType, CBOINCListCtrl* myCtrl)
|
|
|
|
: wxEvent(-1, evtType)
|
|
|
|
{
|
|
|
|
SetEventObject(myCtrl);
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual wxEvent * Clone() const { return new CCheckSelectionChangedEvent(*this); }
|
|
|
|
};
|
|
|
|
|
|
|
|
|
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 )
|
2014-05-22 02:11:22 +00:00
|
|
|
DECLARE_EVENT_TYPE( wxEVT_CHECK_SELECTION_CHANGED, 12002 )
|
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
|
|
|
|
2014-05-22 02:11:22 +00:00
|
|
|
#define EVT_CHECK_SELECTION_CHANGED(fn) DECLARE_EVENT_TABLE_ENTRY(wxEVT_CHECK_SELECTION_CHANGED, -1, -1, (wxObjectEventFunction) (wxEventFunction) &fn, NULL),
|
|
|
|
|
2008-06-24 10:52:12 +00:00
|
|
|
|
|
|
|
// Define a custom event handler
|
|
|
|
class MyEvtHandler : public wxEvtHandler
|
|
|
|
{
|
2015-01-14 10:32:34 +00:00
|
|
|
DECLARE_DYNAMIC_CLASS(MyEvtHandler)
|
|
|
|
|
2008-06-24 10:52:12 +00:00
|
|
|
public:
|
2015-01-14 10:32:34 +00:00
|
|
|
MyEvtHandler();
|
|
|
|
MyEvtHandler(CBOINCListCtrl *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;
|
2015-01-14 10:32:34 +00:00
|
|
|
|
|
|
|
#if !USE_NATIVE_LISTCONTROL
|
|
|
|
#ifdef __WXGTK__
|
|
|
|
int m_view_startX;
|
|
|
|
#endif
|
|
|
|
#endif
|
2008-06-24 10:52:12 +00:00
|
|
|
|
|
|
|
DECLARE_EVENT_TABLE()
|
|
|
|
};
|
2004-09-21 01:30:29 +00:00
|
|
|
|
|
|
|
#endif
|