2006-12-27 18:33:44 +00:00
|
|
|
// Berkeley Open Infrastructure for Network Computing
|
|
|
|
// http://boinc.berkeley.edu
|
|
|
|
// Copyright (C) 2005 University of California
|
|
|
|
//
|
|
|
|
// 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.
|
|
|
|
//
|
|
|
|
// 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.
|
|
|
|
//
|
|
|
|
// To view the GNU Lesser General Public License visit
|
|
|
|
// http://www.gnu.org/copyleft/lesser.html
|
|
|
|
// or write to the Free Software Foundation, Inc.,
|
2007-10-09 11:35:47 +00:00
|
|
|
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
2006-12-27 18:33:44 +00:00
|
|
|
|
|
|
|
#if defined(__GNUG__) && !defined(__APPLE__)
|
|
|
|
#pragma implementation "BOINCGridCtrl.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "stdwx.h"
|
|
|
|
#include "BOINCGridCtrl.h"
|
2007-01-29 09:38:17 +00:00
|
|
|
#include "BOINCBaseView.h"
|
2007-01-07 16:15:04 +00:00
|
|
|
#include "res/sortascending.xpm"
|
|
|
|
#include "res/sortdescending.xpm"
|
|
|
|
|
|
|
|
/* static compare functions and helper variable */
|
|
|
|
static bool reverseCompareOrder=false;
|
|
|
|
/* compare Strings that contains floats */
|
|
|
|
static int CompareFloatString(const wxString& first,const wxString& second) {
|
|
|
|
double dFirst;
|
|
|
|
double dSecond;
|
|
|
|
first.ToDouble(&dFirst);
|
|
|
|
second.ToDouble(&dSecond);
|
|
|
|
if(dFirst < dSecond) {
|
|
|
|
return reverseCompareOrder ? 1 : -1 ;
|
|
|
|
}
|
|
|
|
if(dSecond < dFirst) {
|
|
|
|
return reverseCompareOrder ? -1 : 1 ;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
2007-01-08 17:29:02 +00:00
|
|
|
|
|
|
|
/* compare Strings case insensitive */
|
|
|
|
static int CompareStringStringNoCase(const wxString& first,const wxString& second) {
|
|
|
|
int ret = first.CmpNoCase(second);
|
|
|
|
return reverseCompareOrder ? ret * (-1) : ret;
|
|
|
|
}
|
|
|
|
|
2007-01-07 16:15:04 +00:00
|
|
|
/* compare Strings that contains int/long numbers */
|
|
|
|
static int CompareLongString(const wxString& first,const wxString& second) {
|
|
|
|
long lFirst;
|
|
|
|
long lSecond;
|
|
|
|
first.ToLong(&lFirst);
|
|
|
|
second.ToLong(&lSecond);
|
|
|
|
if(lFirst < lSecond) {
|
|
|
|
return reverseCompareOrder ? 1 : -1 ;
|
|
|
|
}
|
|
|
|
if(lSecond < lFirst) {
|
|
|
|
return reverseCompareOrder ? -1 : 1 ;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* compare strings that contains time periods in format 00:00:00 */
|
|
|
|
static int CompareTimeString(const wxString& first,const wxString& second) {
|
|
|
|
long dtFirst,dtSecond;
|
|
|
|
|
|
|
|
wxString hours,minutes,seconds;
|
|
|
|
long lHours,lMinutes,lSeconds;
|
|
|
|
|
|
|
|
//converting the first string to long value
|
|
|
|
hours = first.BeforeFirst(':');
|
|
|
|
seconds = first.AfterLast(':');
|
|
|
|
minutes = first.AfterFirst(':').BeforeFirst(':');
|
|
|
|
hours.ToLong(&lHours);
|
|
|
|
minutes.ToLong(&lMinutes);
|
|
|
|
seconds.ToLong(&lSeconds);
|
|
|
|
dtFirst = lSeconds + lMinutes * 60 + lHours * 3600;
|
|
|
|
//converting the second string
|
|
|
|
hours = second.BeforeFirst(':');
|
|
|
|
seconds = second.AfterLast(':');
|
|
|
|
minutes = second.AfterFirst(':').BeforeFirst(':');
|
|
|
|
hours.ToLong(&lHours);
|
|
|
|
minutes.ToLong(&lMinutes);
|
|
|
|
seconds.ToLong(&lSeconds);
|
|
|
|
dtSecond = lSeconds + lMinutes * 60 + lHours * 3600;
|
|
|
|
|
|
|
|
if(dtFirst < dtSecond) {
|
|
|
|
return reverseCompareOrder ? 1 : -1 ;
|
|
|
|
}
|
|
|
|
if(dtSecond < dtFirst) {
|
|
|
|
return reverseCompareOrder ? -1 : 1 ;
|
2007-01-08 17:29:02 +00:00
|
|
|
}
|
2007-01-07 16:15:04 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2006-12-27 18:33:44 +00:00
|
|
|
|
2007-01-07 16:15:04 +00:00
|
|
|
/* compare Strings that contains dateTime*/
|
|
|
|
static int CompareDateString(const wxString& first,const wxString& second) {
|
|
|
|
wxDateTime dtFirst,dtSecond;
|
2006-12-27 18:33:44 +00:00
|
|
|
|
2007-01-07 16:15:04 +00:00
|
|
|
//dtFirst.ParseDateTime(first);
|
|
|
|
//dtSecond.ParseDateTime(second);
|
|
|
|
dtFirst.ParseFormat(first,wxT(" %x %X"));
|
|
|
|
dtSecond.ParseFormat(second,wxT(" %x %X"));
|
|
|
|
|
|
|
|
if(dtFirst < dtSecond) {
|
|
|
|
return reverseCompareOrder ? 1 : -1 ;
|
|
|
|
}
|
|
|
|
if(dtSecond < dtFirst) {
|
|
|
|
return reverseCompareOrder ? -1 : 1 ;
|
2007-01-08 17:29:02 +00:00
|
|
|
}
|
2007-01-07 16:15:04 +00:00
|
|
|
return 0;
|
2006-12-27 18:33:44 +00:00
|
|
|
}
|
|
|
|
|
2007-01-10 22:19:29 +00:00
|
|
|
/* ########## grid ctrl implementation ############### */
|
2007-01-07 16:15:04 +00:00
|
|
|
BEGIN_EVENT_TABLE (CBOINCGridCtrl, wxGrid)
|
|
|
|
EVT_GRID_LABEL_LEFT_CLICK(CBOINCGridCtrl::OnLabelLClick)
|
|
|
|
END_EVENT_TABLE ()
|
|
|
|
|
2007-01-10 22:19:29 +00:00
|
|
|
/* Constructor, don't call any grid methods here, because they could raise events,
|
|
|
|
which couldn't be handled correctly while the grid isn't constructed completly.
|
|
|
|
Instead call Setup() and place all further initialization there
|
|
|
|
*/
|
2007-01-07 16:15:04 +00:00
|
|
|
CBOINCGridCtrl::CBOINCGridCtrl(wxWindow* parent, wxWindowID iGridWindowID) : wxGrid(parent, iGridWindowID) {
|
2007-01-10 22:19:29 +00:00
|
|
|
//init members
|
2007-01-07 16:15:04 +00:00
|
|
|
sortColumn=-1;
|
2007-01-08 17:29:02 +00:00
|
|
|
sortAscending=true;
|
2007-07-16 18:09:54 +00:00
|
|
|
sortNeededByLabelClick=false;
|
2008-03-05 07:13:53 +00:00
|
|
|
m_pkColumnIndex1=-1;
|
|
|
|
m_pkColumnIndex2=-1;
|
2007-01-10 22:19:29 +00:00
|
|
|
m_cursorcol=-1;
|
2008-03-05 07:13:53 +00:00
|
|
|
m_cursorrow=-1;
|
|
|
|
m_arrSelectedKeys1.Clear();
|
|
|
|
m_arrSelectedKeys2.Clear();
|
|
|
|
|
2007-01-07 16:15:04 +00:00
|
|
|
//load sorting bitmaps
|
|
|
|
ascBitmap = wxBitmap(sortascending_xpm);
|
|
|
|
descBitmap = wxBitmap(sortdescending_xpm);
|
2007-01-10 22:19:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* make settings for the grid here instead in the constructor */
|
|
|
|
void CBOINCGridCtrl::Setup() {
|
2007-01-08 17:29:02 +00:00
|
|
|
//make grid cursor invisible
|
2007-01-07 16:15:04 +00:00
|
|
|
SetCellHighlightPenWidth(0);
|
|
|
|
SetCellHighlightROPenWidth(0);
|
|
|
|
//change default selection colours
|
|
|
|
SetSelectionBackground(*wxLIGHT_GREY);
|
|
|
|
SetSelectionForeground(*wxBLACK);
|
|
|
|
//
|
|
|
|
SetRowLabelSize(1);//hide row labels
|
2007-01-10 22:19:29 +00:00
|
|
|
SetColLabelSize(20); //make header row smaller as default
|
2007-01-08 17:29:02 +00:00
|
|
|
SetColLabelAlignment(wxALIGN_LEFT,wxALIGN_CENTER);
|
2007-01-07 16:15:04 +00:00
|
|
|
EnableGridLines(false);
|
|
|
|
EnableDragRowSize(false);//prevent the user from changing the row height with the mouse
|
|
|
|
EnableDragCell(false);
|
2007-01-10 22:19:29 +00:00
|
|
|
EnableEditing(false);//make the whole grid read-only
|
2007-01-07 16:15:04 +00:00
|
|
|
SetDefaultCellBackgroundColour(*wxWHITE);
|
2007-01-08 17:29:02 +00:00
|
|
|
#ifdef __WXMAC__
|
2007-01-07 16:15:04 +00:00
|
|
|
SetLabelFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT));
|
|
|
|
SetDefaultCellFont(wxFont(12, wxSWISS, wxNORMAL, wxNORMAL, FALSE));
|
|
|
|
#else
|
|
|
|
SetLabelFont(*wxNORMAL_FONT);
|
|
|
|
#endif
|
2007-01-29 09:38:17 +00:00
|
|
|
this->SetScrollLineX(5);
|
|
|
|
this->SetScrollLineY(5);
|
2007-01-07 16:15:04 +00:00
|
|
|
}
|
2006-12-27 18:33:44 +00:00
|
|
|
|
|
|
|
CBOINCGridCtrl::~CBOINCGridCtrl() {
|
|
|
|
}
|
|
|
|
|
2007-01-10 22:19:29 +00:00
|
|
|
/* use this method instead of wxGrid::GetSelectedRows()
|
|
|
|
because a bug in wxGrid::GetSelectedRows() doesn't return anything although some rows are selected */
|
2007-01-07 16:15:04 +00:00
|
|
|
wxArrayInt CBOINCGridCtrl::GetSelectedRows2() {
|
|
|
|
wxArrayInt ret;
|
|
|
|
for(int i= 0; i< this->GetRows();i++) {
|
|
|
|
for(int j=0; j< this->GetCols();j++) {
|
|
|
|
if(this->IsInSelection(i,j)) {
|
|
|
|
ret.Add(i);
|
|
|
|
//break the inner loop here to prevent adding the same row twice
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2007-01-08 17:29:02 +00:00
|
|
|
}
|
2007-01-07 16:15:04 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2007-01-10 22:19:29 +00:00
|
|
|
/* sets the column with unique values */
|
2008-03-05 07:13:53 +00:00
|
|
|
void CBOINCGridCtrl::SetPrimaryKeyColumns(int col1,int col2) {
|
|
|
|
m_pkColumnIndex1 = col1;
|
|
|
|
m_pkColumnIndex2 = col2;
|
2007-01-10 22:19:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* If the user clicked inside the grid, the former selected cells must be deselected.
|
|
|
|
Because the code in OnListRender() of the GridViews raises SelectionEvents too,
|
|
|
|
call to GetBatchCount() here is necessary to decide what to do
|
|
|
|
*/
|
|
|
|
void CBOINCGridCtrl::ClearSavedSelection() {
|
|
|
|
if(this->GetBatchCount()<=0) {
|
2008-03-05 07:13:53 +00:00
|
|
|
m_arrSelectedKeys1.Empty();
|
|
|
|
m_arrSelectedKeys2.Empty();
|
2007-01-10 22:19:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* save the key values of the currently selected rows for later restore */
|
|
|
|
void CBOINCGridCtrl::SaveSelection() {
|
2008-03-05 07:13:53 +00:00
|
|
|
if(m_pkColumnIndex1>=0) {
|
2007-01-10 22:19:29 +00:00
|
|
|
wxArrayInt arrSelRows = GetSelectedRows2();
|
2008-03-05 07:13:53 +00:00
|
|
|
m_arrSelectedKeys1.Empty();
|
|
|
|
m_arrSelectedKeys2.Empty();
|
2007-01-10 22:19:29 +00:00
|
|
|
for(unsigned int i=0; i< arrSelRows.GetCount();i++) {
|
2008-03-05 07:13:53 +00:00
|
|
|
m_arrSelectedKeys1.Add(GetCellValue(arrSelRows[i],m_pkColumnIndex1));
|
|
|
|
if (m_pkColumnIndex2 >= 0) {
|
|
|
|
m_arrSelectedKeys2.Add(GetCellValue(arrSelRows[i],m_pkColumnIndex2));
|
|
|
|
}
|
2007-01-10 22:19:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* select all rows, that were formerly selected
|
|
|
|
this raises selection events without user interaction */
|
|
|
|
void CBOINCGridCtrl::RestoreSelection() {
|
2008-03-05 14:41:24 +00:00
|
|
|
BeginBatch(); // To prevent flicker
|
|
|
|
ClearSelection();
|
2008-03-05 07:13:53 +00:00
|
|
|
for(unsigned int i=0;i < m_arrSelectedKeys1.size();i++) {
|
|
|
|
int index = GetTable()->FindRowIndexByColValue(
|
|
|
|
m_pkColumnIndex1,m_arrSelectedKeys1[i],m_pkColumnIndex2,m_arrSelectedKeys2[i]
|
|
|
|
);
|
2007-01-10 22:19:29 +00:00
|
|
|
if(index >=0) {
|
|
|
|
SelectRow(index,true);
|
|
|
|
}
|
|
|
|
}
|
2008-03-05 14:41:24 +00:00
|
|
|
EndBatch();
|
2007-01-10 22:19:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CBOINCGridCtrl::SaveGridCursorPosition() {
|
|
|
|
m_cursorcol = GetGridCursorCol();
|
|
|
|
m_cursorrow = GetGridCursorRow();
|
|
|
|
if(m_cursorrow>=0 && m_cursorcol >=0) {
|
2008-03-05 07:13:53 +00:00
|
|
|
m_szCursorKey1 = GetCellValue(m_cursorrow,m_pkColumnIndex1);
|
|
|
|
if (m_pkColumnIndex2 >= 0) {
|
|
|
|
m_szCursorKey2 = GetCellValue(m_cursorrow,m_pkColumnIndex2);
|
|
|
|
}
|
2007-01-10 22:19:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CBOINCGridCtrl::RestoreGridCursorPosition() {
|
2008-03-05 07:13:53 +00:00
|
|
|
int index = GetTable()->FindRowIndexByColValue(m_pkColumnIndex1,m_szCursorKey1,m_pkColumnIndex2,m_szCursorKey2);
|
2007-01-10 22:19:29 +00:00
|
|
|
if(index >=0) {
|
|
|
|
SetGridCursor(index,m_cursorcol);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-12-27 18:33:44 +00:00
|
|
|
int CBOINCGridCtrl::GetFirstSelectedRow() {
|
|
|
|
int ret= -1;
|
|
|
|
//Row mode ?
|
2007-01-10 22:19:29 +00:00
|
|
|
wxArrayInt selRows = this->GetSelectedRows2();
|
2006-12-27 18:33:44 +00:00
|
|
|
if(selRows.size() >0) {
|
|
|
|
return selRows[0];
|
|
|
|
}
|
|
|
|
//block mode ?
|
|
|
|
wxGridCellCoordsArray selBlocks = this->GetSelectionBlockTopLeft();
|
|
|
|
if(selBlocks.size()>0) {
|
|
|
|
return selBlocks[0].GetRow();
|
|
|
|
}
|
|
|
|
//cell mode
|
|
|
|
wxGridCellCoordsArray selCells = this->GetSelectionBlockTopLeft();
|
|
|
|
if(selCells.size()>0) {
|
|
|
|
return selCells[0].GetRow();
|
|
|
|
}
|
2007-01-06 01:07:35 +00:00
|
|
|
|
2006-12-27 18:33:44 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2007-01-07 16:15:04 +00:00
|
|
|
/* saves column widths and sorting attributes */
|
2006-12-29 21:55:23 +00:00
|
|
|
bool CBOINCGridCtrl::OnSaveState(wxConfigBase* pConfig) {
|
|
|
|
wxString strBaseConfigLocation = wxEmptyString;
|
|
|
|
wxInt32 iIndex = 0;
|
|
|
|
wxInt32 iColumnCount = this->GetCols();
|
|
|
|
|
|
|
|
wxASSERT(pConfig);
|
|
|
|
// Retrieve the base location to store configuration information
|
|
|
|
// Should be in the following form: "/Projects/"
|
|
|
|
strBaseConfigLocation = pConfig->GetPath() + wxT("/");
|
|
|
|
|
|
|
|
// Cycle through the columns recording anything interesting
|
|
|
|
for (iIndex = 0; iIndex < iColumnCount; iIndex++) {
|
2007-07-17 22:20:06 +00:00
|
|
|
wxString label = this->GetColLabelValue(iIndex);
|
|
|
|
// Don't save width for hidden / invisible columns
|
|
|
|
if (label.IsEmpty()) {
|
|
|
|
continue;
|
|
|
|
}
|
2006-12-29 21:55:23 +00:00
|
|
|
pConfig->SetPath(strBaseConfigLocation + label);
|
2007-01-08 17:29:02 +00:00
|
|
|
pConfig->Write(wxT("Width"), this->GetColumnWidth(iIndex));
|
2006-12-29 21:55:23 +00:00
|
|
|
}
|
2007-01-08 17:29:02 +00:00
|
|
|
//save sorting column
|
2007-01-07 16:15:04 +00:00
|
|
|
pConfig->SetPath(strBaseConfigLocation);
|
|
|
|
pConfig->Write(wxT("SortColumn"),this->sortColumn);
|
|
|
|
pConfig->Write(wxT("SortAscending"),this->sortAscending);
|
2006-12-29 21:55:23 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2007-01-07 16:15:04 +00:00
|
|
|
/* restores column widths and sorting attributes */
|
2006-12-29 21:55:23 +00:00
|
|
|
bool CBOINCGridCtrl::OnRestoreState(wxConfigBase* pConfig) {
|
|
|
|
wxString strBaseConfigLocation = wxEmptyString;
|
|
|
|
wxInt32 iIndex = 0;
|
|
|
|
wxInt32 iTempValue = 0;
|
- fixes #207 - HTML entities in BOINC Manager have to be decoded
BOINC Manager can now properly decode HTML entites for the
following elements:
Projects Tab:
Project Name
User Name
Team Name
Work Tab:
Project Name
Application Name
Transfers Tab:
Project Name
Messages Tab:
Project Name
Disk Tab:
Project Name
- fixes #212 - Info in columns misaligned on switching views
- Properly restore which tab view the user left from when going
to the advanced view from the simple view
- Fix the problem that caused the manager to wait for 7 seconds
to display anything on initial startup.
- Store the various Grid/List persisted data seperately so that
the different header sizes don't cause problems.
clientgui/
AdvancedFrame.cpp
BOINCBaseView.cpp, .h
BOINCGridCtrl.cpp
ViewMessages.cpp, .h
ViewMessagesGrid.cpp, .h
ViewProjects.cpp, .h
ViewProjectsGrid.cpp, .h
ViewResources.cpp, .h
ViewStatistics.cpp, .h
ViewTransfers.cpp, .h
ViewTransfersGrid.cpp, .h
ViewWork.cpp, .h
ViewWorkGrid.cpp, .h
lib/
gui_rpc_client_ops.C
svn path=/trunk/boinc/; revision=12761
2007-05-29 05:07:35 +00:00
|
|
|
wxInt32 iColumnCount = GetCols();
|
2006-12-29 21:55:23 +00:00
|
|
|
|
|
|
|
wxASSERT(pConfig);
|
|
|
|
|
|
|
|
// Retrieve the base location to store configuration information
|
|
|
|
// Should be in the following form: "/Projects/"
|
|
|
|
strBaseConfigLocation = pConfig->GetPath() + wxT("/");
|
|
|
|
|
|
|
|
// Cycle through the columns recording anything interesting
|
|
|
|
for (iIndex = 0; iIndex < iColumnCount; iIndex++) {
|
2007-07-17 22:20:06 +00:00
|
|
|
wxString label = GetColLabelValue(iIndex);
|
|
|
|
// Don't restore width for hidden / invisible columns
|
|
|
|
if (label.IsEmpty()) {
|
|
|
|
continue;
|
|
|
|
}
|
2006-12-29 21:55:23 +00:00
|
|
|
pConfig->SetPath(strBaseConfigLocation + label);
|
|
|
|
|
|
|
|
pConfig->Read(wxT("Width"), &iTempValue, -1);
|
|
|
|
if (-1 != iTempValue) {
|
- fixes #207 - HTML entities in BOINC Manager have to be decoded
BOINC Manager can now properly decode HTML entites for the
following elements:
Projects Tab:
Project Name
User Name
Team Name
Work Tab:
Project Name
Application Name
Transfers Tab:
Project Name
Messages Tab:
Project Name
Disk Tab:
Project Name
- fixes #212 - Info in columns misaligned on switching views
- Properly restore which tab view the user left from when going
to the advanced view from the simple view
- Fix the problem that caused the manager to wait for 7 seconds
to display anything on initial startup.
- Store the various Grid/List persisted data seperately so that
the different header sizes don't cause problems.
clientgui/
AdvancedFrame.cpp
BOINCBaseView.cpp, .h
BOINCGridCtrl.cpp
ViewMessages.cpp, .h
ViewMessagesGrid.cpp, .h
ViewProjects.cpp, .h
ViewProjectsGrid.cpp, .h
ViewResources.cpp, .h
ViewStatistics.cpp, .h
ViewTransfers.cpp, .h
ViewTransfersGrid.cpp, .h
ViewWork.cpp, .h
ViewWorkGrid.cpp, .h
lib/
gui_rpc_client_ops.C
svn path=/trunk/boinc/; revision=12761
2007-05-29 05:07:35 +00:00
|
|
|
SetColSize(iIndex, iTempValue);
|
2006-12-29 21:55:23 +00:00
|
|
|
}
|
|
|
|
}
|
2007-01-08 17:29:02 +00:00
|
|
|
//read sorting
|
2007-01-07 16:15:04 +00:00
|
|
|
pConfig->SetPath(strBaseConfigLocation);
|
|
|
|
pConfig->Read(wxT("SortColumn"),&iTempValue,-1);
|
|
|
|
if(-1 != iTempValue) {
|
- fixes #207 - HTML entities in BOINC Manager have to be decoded
BOINC Manager can now properly decode HTML entites for the
following elements:
Projects Tab:
Project Name
User Name
Team Name
Work Tab:
Project Name
Application Name
Transfers Tab:
Project Name
Messages Tab:
Project Name
Disk Tab:
Project Name
- fixes #212 - Info in columns misaligned on switching views
- Properly restore which tab view the user left from when going
to the advanced view from the simple view
- Fix the problem that caused the manager to wait for 7 seconds
to display anything on initial startup.
- Store the various Grid/List persisted data seperately so that
the different header sizes don't cause problems.
clientgui/
AdvancedFrame.cpp
BOINCBaseView.cpp, .h
BOINCGridCtrl.cpp
ViewMessages.cpp, .h
ViewMessagesGrid.cpp, .h
ViewProjects.cpp, .h
ViewProjectsGrid.cpp, .h
ViewResources.cpp, .h
ViewStatistics.cpp, .h
ViewTransfers.cpp, .h
ViewTransfersGrid.cpp, .h
ViewWork.cpp, .h
ViewWorkGrid.cpp, .h
lib/
gui_rpc_client_ops.C
svn path=/trunk/boinc/; revision=12761
2007-05-29 05:07:35 +00:00
|
|
|
sortColumn = iTempValue;
|
2007-01-07 16:15:04 +00:00
|
|
|
}
|
|
|
|
pConfig->Read(wxT("SortAscending"),&iTempValue,-1);
|
|
|
|
if(-1 != iTempValue) {
|
- fixes #207 - HTML entities in BOINC Manager have to be decoded
BOINC Manager can now properly decode HTML entites for the
following elements:
Projects Tab:
Project Name
User Name
Team Name
Work Tab:
Project Name
Application Name
Transfers Tab:
Project Name
Messages Tab:
Project Name
Disk Tab:
Project Name
- fixes #212 - Info in columns misaligned on switching views
- Properly restore which tab view the user left from when going
to the advanced view from the simple view
- Fix the problem that caused the manager to wait for 7 seconds
to display anything on initial startup.
- Store the various Grid/List persisted data seperately so that
the different header sizes don't cause problems.
clientgui/
AdvancedFrame.cpp
BOINCBaseView.cpp, .h
BOINCGridCtrl.cpp
ViewMessages.cpp, .h
ViewMessagesGrid.cpp, .h
ViewProjects.cpp, .h
ViewProjectsGrid.cpp, .h
ViewResources.cpp, .h
ViewStatistics.cpp, .h
ViewTransfers.cpp, .h
ViewTransfersGrid.cpp, .h
ViewWork.cpp, .h
ViewWorkGrid.cpp, .h
lib/
gui_rpc_client_ops.C
svn path=/trunk/boinc/; revision=12761
2007-05-29 05:07:35 +00:00
|
|
|
sortAscending = iTempValue != 0 ? true : false;
|
2007-01-07 16:15:04 +00:00
|
|
|
}
|
2006-12-29 21:55:23 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2007-01-07 16:15:04 +00:00
|
|
|
/* for convienience purpose only */
|
2006-12-29 21:55:23 +00:00
|
|
|
void CBOINCGridCtrl::SetColAlignment(int col,int hAlign,int vAlign) {
|
|
|
|
wxGridCellAttr *attr = m_table->GetAttr(-1, col, wxGridCellAttr::Col );
|
|
|
|
if(!attr) {
|
2007-01-06 01:07:35 +00:00
|
|
|
attr = new wxGridCellAttr;
|
2006-12-29 21:55:23 +00:00
|
|
|
}
|
|
|
|
attr->SetAlignment(hAlign,vAlign);
|
|
|
|
SetColAttr(col, attr);
|
|
|
|
}
|
|
|
|
|
2007-01-07 16:15:04 +00:00
|
|
|
/* copied source code from wxGrid to make overloading possible */
|
2007-01-06 01:07:35 +00:00
|
|
|
void CBOINCGridCtrl::DrawTextRectangle( wxDC& dc,
|
|
|
|
const wxString& value,
|
|
|
|
const wxRect& rect,
|
|
|
|
int horizAlign,
|
|
|
|
int vertAlign,
|
|
|
|
int textOrientation )
|
|
|
|
{
|
|
|
|
wxArrayString lines;
|
|
|
|
|
|
|
|
StringToLines( value, lines );
|
|
|
|
//Forward to new API.
|
|
|
|
DrawTextRectangle( dc,
|
|
|
|
lines,
|
|
|
|
rect,
|
|
|
|
horizAlign,
|
|
|
|
vertAlign,
|
|
|
|
textOrientation );
|
|
|
|
|
|
|
|
}
|
2006-12-29 21:55:23 +00:00
|
|
|
|
2007-01-07 16:15:04 +00:00
|
|
|
/* draws text with ellipses instead cutting it */
|
2006-12-29 21:55:23 +00:00
|
|
|
void CBOINCGridCtrl::DrawTextRectangle( wxDC& dc,
|
|
|
|
const wxArrayString& lines,
|
|
|
|
const wxRect& rect,
|
|
|
|
int horizAlign,
|
|
|
|
int vertAlign,
|
|
|
|
int textOrientation )
|
|
|
|
{
|
|
|
|
long textWidth, textHeight;
|
|
|
|
long lineWidth, lineHeight;
|
2007-01-07 16:15:04 +00:00
|
|
|
unsigned int nLines;
|
2006-12-29 21:55:23 +00:00
|
|
|
|
|
|
|
dc.SetClippingRegion( rect );
|
|
|
|
|
2007-01-08 17:29:02 +00:00
|
|
|
nLines = (unsigned int)lines.GetCount();
|
2006-12-29 21:55:23 +00:00
|
|
|
if( nLines > 0 )
|
|
|
|
{
|
2007-01-07 16:15:04 +00:00
|
|
|
unsigned int l;
|
2006-12-29 21:55:23 +00:00
|
|
|
float x = 0.0, y = 0.0;
|
|
|
|
|
|
|
|
if( textOrientation == wxHORIZONTAL )
|
|
|
|
GetTextBoxSize(dc, lines, &textWidth, &textHeight);
|
|
|
|
else
|
|
|
|
GetTextBoxSize( dc, lines, &textHeight, &textWidth );
|
|
|
|
|
|
|
|
switch( vertAlign )
|
|
|
|
{
|
|
|
|
case wxALIGN_BOTTOM:
|
|
|
|
if( textOrientation == wxHORIZONTAL )
|
|
|
|
y = rect.y + (rect.height - textHeight - 1);
|
|
|
|
else
|
|
|
|
x = rect.x + rect.width - textWidth;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case wxALIGN_CENTRE:
|
|
|
|
if( textOrientation == wxHORIZONTAL )
|
|
|
|
y = rect.y + ((rect.height - textHeight)/2);
|
|
|
|
else
|
|
|
|
x = rect.x + ((rect.width - textWidth)/2);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case wxALIGN_TOP:
|
|
|
|
default:
|
|
|
|
if( textOrientation == wxHORIZONTAL )
|
|
|
|
y = rect.y + 1;
|
|
|
|
else
|
|
|
|
x = rect.x + 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Align each line of a multi-line label
|
|
|
|
for( l = 0; l < nLines; l++ )
|
|
|
|
{
|
|
|
|
dc.GetTextExtent(lines[l], &lineWidth, &lineHeight);
|
|
|
|
|
|
|
|
switch( horizAlign )
|
|
|
|
{
|
|
|
|
case wxALIGN_RIGHT:
|
|
|
|
if( textOrientation == wxHORIZONTAL )
|
|
|
|
x = rect.x + (rect.width - lineWidth - 1);
|
|
|
|
else
|
|
|
|
y = rect.y + lineWidth + 1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case wxALIGN_CENTRE:
|
|
|
|
if( textOrientation == wxHORIZONTAL )
|
|
|
|
x = rect.x + ((rect.width - lineWidth)/2);
|
|
|
|
else
|
|
|
|
y = rect.y + rect.height - ((rect.height - lineWidth)/2);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case wxALIGN_LEFT:
|
|
|
|
default:
|
|
|
|
if( textOrientation == wxHORIZONTAL )
|
|
|
|
x = rect.x + 1;
|
|
|
|
else
|
|
|
|
y = rect.y + rect.height - 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( textOrientation == wxHORIZONTAL )
|
|
|
|
{
|
2007-01-06 01:07:35 +00:00
|
|
|
//changes applies here
|
2006-12-29 21:55:23 +00:00
|
|
|
wxString formattedText = FormatTextWithEllipses(dc,lines[l],rect.width);
|
|
|
|
dc.DrawText( formattedText, (int)x, (int)y );
|
|
|
|
y += lineHeight;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
dc.DrawRotatedText( lines[l], (int)x, (int)y, 90.0 );
|
|
|
|
x += lineHeight;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
dc.DestroyClippingRegion();
|
|
|
|
}
|
|
|
|
|
|
|
|
wxString CBOINCGridCtrl::FormatTextWithEllipses(wxDC& dc,const wxString &text,int width)
|
|
|
|
{
|
|
|
|
wxString retText;
|
|
|
|
wxString drawntext, ellipsis;
|
|
|
|
wxCoord w, h, base_w;
|
|
|
|
wxListItem item;
|
|
|
|
|
|
|
|
// determine if the string can fit inside the current width
|
|
|
|
dc.GetTextExtent(text, &w, &h);
|
|
|
|
if (w <= width)
|
|
|
|
{
|
|
|
|
retText = text;
|
|
|
|
}
|
|
|
|
else // otherwise, truncate and add an ellipsis if possible
|
|
|
|
{
|
|
|
|
// determine the base width
|
|
|
|
ellipsis = wxString(wxT("..."));
|
|
|
|
dc.GetTextExtent(ellipsis, &base_w, &h);
|
|
|
|
|
|
|
|
// continue until we have enough space or only one character left
|
|
|
|
wxCoord w_c, h_c;
|
|
|
|
size_t len = text.Length();
|
|
|
|
drawntext = text.Left(len);
|
|
|
|
while (len > 1)
|
|
|
|
{
|
|
|
|
dc.GetTextExtent(drawntext.Last(), &w_c, &h_c);
|
|
|
|
drawntext.RemoveLast();
|
|
|
|
len--;
|
|
|
|
w -= w_c;
|
|
|
|
if (w + base_w <= width)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// if still not enough space, remove ellipsis characters
|
|
|
|
while (ellipsis.Length() > 0 && w + base_w > width)
|
|
|
|
{
|
|
|
|
ellipsis = ellipsis.Left(ellipsis.Length() - 1);
|
|
|
|
dc.GetTextExtent(ellipsis, &base_w, &h);
|
|
|
|
}
|
|
|
|
|
|
|
|
// now draw the text
|
|
|
|
retText = drawntext + ellipsis;
|
|
|
|
}
|
|
|
|
|
|
|
|
return retText;
|
|
|
|
}
|
|
|
|
|
2007-01-07 16:15:04 +00:00
|
|
|
/* not virtual in wxGrid, so code copied and modified her for painting sorting icons */
|
2007-01-06 01:07:35 +00:00
|
|
|
void CBOINCGridCtrl::DrawColLabel( wxDC& dc, int col )
|
|
|
|
{
|
|
|
|
if ( GetColWidth(col) <= 0 || m_colLabelHeight <= 0 )
|
|
|
|
return;
|
|
|
|
|
|
|
|
int colLeft = GetColLeft(col);
|
|
|
|
|
|
|
|
wxRect rect;
|
|
|
|
int colRight = GetColRight(col) - 1;
|
|
|
|
|
|
|
|
dc.SetPen( wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_3DDKSHADOW),1, wxSOLID) );
|
|
|
|
dc.DrawLine( colRight, 0,
|
|
|
|
colRight, m_colLabelHeight-1 );
|
|
|
|
|
|
|
|
dc.DrawLine( colLeft, 0, colRight, 0 );
|
|
|
|
|
|
|
|
dc.DrawLine( colLeft, m_colLabelHeight-1,
|
|
|
|
colRight+1, m_colLabelHeight-1 );
|
|
|
|
|
|
|
|
dc.SetPen( *wxWHITE_PEN );
|
|
|
|
dc.DrawLine( colLeft, 1, colLeft, m_colLabelHeight-1 );
|
|
|
|
dc.DrawLine( colLeft, 1, colRight, 1 );
|
|
|
|
dc.SetBackgroundMode( wxTRANSPARENT );
|
|
|
|
dc.SetTextForeground( GetLabelTextColour() );
|
|
|
|
dc.SetFont( GetLabelFont() );
|
|
|
|
|
|
|
|
int hAlign, vAlign, orient;
|
|
|
|
GetColLabelAlignment( &hAlign, &vAlign );
|
|
|
|
orient = GetColLabelTextOrientation();
|
|
|
|
|
|
|
|
rect.SetX( colLeft + 2 );
|
|
|
|
rect.SetY( 2 );
|
|
|
|
rect.SetWidth( GetColWidth(col) - 4 );
|
|
|
|
rect.SetHeight( m_colLabelHeight - 4 );
|
|
|
|
DrawTextRectangle( dc, GetColLabelValue( col ), rect, hAlign, vAlign, orient );
|
2007-01-07 16:15:04 +00:00
|
|
|
//paint sorting indicators, if needed
|
2007-04-04 19:37:54 +00:00
|
|
|
if(col == sortColumn) {
|
2007-01-07 16:15:04 +00:00
|
|
|
int x = rect.GetRight() - ascBitmap.GetWidth() - 2;
|
2007-01-08 17:29:02 +00:00
|
|
|
int y = rect.GetY();
|
2007-01-26 04:10:47 +00:00
|
|
|
dc.DrawBitmap(this->sortAscending ? descBitmap : ascBitmap,x,y,true);
|
2007-01-07 16:15:04 +00:00
|
|
|
}
|
2007-01-06 01:07:35 +00:00
|
|
|
}
|
2006-12-29 21:55:23 +00:00
|
|
|
|
2007-01-07 16:15:04 +00:00
|
|
|
/* handles left mouse click on column header */
|
|
|
|
void CBOINCGridCtrl::OnLabelLClick(wxGridEvent& ev) {
|
2007-04-04 19:37:54 +00:00
|
|
|
if(ev.GetCol() != -1) {
|
|
|
|
//same column as last time, then change only sort direction
|
|
|
|
if(sortColumn == ev.GetCol()) {
|
|
|
|
sortAscending = ! sortAscending;
|
|
|
|
} else {
|
|
|
|
int tmpOldColumn = sortColumn;
|
|
|
|
|
|
|
|
sortColumn = ev.GetCol();
|
|
|
|
sortAscending = true;
|
|
|
|
|
|
|
|
// Force a repaint of the label
|
2007-04-10 20:21:43 +00:00
|
|
|
if ( -1 != tmpOldColumn ) {
|
|
|
|
SetColLabelValue(tmpOldColumn, GetColLabelValue(tmpOldColumn));
|
|
|
|
}
|
2007-01-07 16:15:04 +00:00
|
|
|
}
|
2007-04-04 19:37:54 +00:00
|
|
|
|
|
|
|
// Force a repaint of the label
|
|
|
|
SetColLabelValue(ev.GetCol(), GetColLabelValue(ev.GetCol()));
|
2007-07-16 18:09:54 +00:00
|
|
|
//
|
|
|
|
sortNeededByLabelClick=true;
|
2007-04-04 19:37:54 +00:00
|
|
|
// Update and sort data
|
2007-01-29 09:38:17 +00:00
|
|
|
wxTimerEvent tEvent;
|
2007-04-04 19:37:54 +00:00
|
|
|
wxDynamicCast(GetParent(),CBOINCBaseView)->FireOnListRender(tEvent);
|
2007-01-07 16:15:04 +00:00
|
|
|
}
|
2008-03-05 07:13:53 +00:00
|
|
|
// The base class calls ClearSelection(), so do NOT call ev.Skip();
|
2007-01-07 16:15:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CBOINCGridCtrl::SortData() {
|
2007-04-04 19:37:54 +00:00
|
|
|
GetTable()->SortData(sortColumn,sortAscending);
|
2007-07-16 18:09:54 +00:00
|
|
|
sortNeededByLabelClick=false;
|
2007-01-07 16:15:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CBOINCGridCtrl::SetColumnSortType(int col,int sortType/*=CST_STRING*/) {
|
2007-04-04 19:37:54 +00:00
|
|
|
GetTable()->SetColumnSortType(col,sortType);
|
2007-01-07 16:15:04 +00:00
|
|
|
}
|
|
|
|
|
2007-01-10 22:19:29 +00:00
|
|
|
/* ################### generic grid cell renderer #################### */
|
2007-01-08 17:29:02 +00:00
|
|
|
CBOINCGridCellRenderer::CBOINCGridCellRenderer() : wxGridCellStringRenderer() {
|
2006-12-27 18:33:44 +00:00
|
|
|
}
|
|
|
|
|
2007-01-08 17:29:02 +00:00
|
|
|
void CBOINCGridCellRenderer::Draw(wxGrid& grid, wxGridCellAttr& attr, wxDC& dc, const wxRect& rect, int row, int col, bool isSelected) {
|
|
|
|
DoNormalTextDrawing(grid,attr,dc,rect,row,col,isSelected);
|
2006-12-27 18:33:44 +00:00
|
|
|
}
|
|
|
|
|
2007-01-07 16:15:04 +00:00
|
|
|
/* draws alternating background colours */
|
2007-01-08 17:29:02 +00:00
|
|
|
void CBOINCGridCellRenderer::DrawBackground(wxGrid& grid,
|
2007-01-06 01:07:35 +00:00
|
|
|
wxDC& dc,
|
|
|
|
const wxRect& rect,
|
2007-01-08 17:29:02 +00:00
|
|
|
int row,
|
2007-01-06 01:07:35 +00:00
|
|
|
bool isSelected)
|
|
|
|
{
|
|
|
|
dc.SetBackgroundMode( wxSOLID );
|
|
|
|
|
|
|
|
// grey out fields if the grid is disabled
|
|
|
|
if( grid.IsEnabled() )
|
|
|
|
{
|
|
|
|
if ( isSelected )
|
|
|
|
{
|
|
|
|
dc.SetBrush( wxBrush(grid.GetSelectionBackground(), wxSOLID) );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-01-07 16:15:04 +00:00
|
|
|
//alternate background colours
|
2007-01-06 01:07:35 +00:00
|
|
|
if(row % 2 == 0) {
|
|
|
|
dc.SetBrush(wxBrush(wxColour(240,240,240)));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
dc.SetBrush(*wxWHITE_BRUSH);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
dc.SetBrush(wxBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE), wxSOLID));
|
|
|
|
}
|
|
|
|
|
|
|
|
dc.SetPen( *wxTRANSPARENT_PEN );
|
|
|
|
dc.DrawRectangle(rect);
|
|
|
|
}
|
|
|
|
|
2007-01-08 17:29:02 +00:00
|
|
|
void CBOINCGridCellRenderer::DoNormalTextDrawing(wxGrid& grid, wxGridCellAttr& attr, wxDC& dc, const wxRect& rectCell, int row, int col, bool isSelected) {
|
2006-12-27 18:33:44 +00:00
|
|
|
wxRect rect = rectCell;
|
|
|
|
rect.Inflate(-1);
|
|
|
|
|
|
|
|
// erase only this cells background, overflow cells should have been erased
|
2007-01-08 17:29:02 +00:00
|
|
|
this->DrawBackground(grid, dc, rectCell, row, isSelected);
|
2006-12-27 18:33:44 +00:00
|
|
|
|
|
|
|
int hAlign, vAlign;
|
|
|
|
attr.GetAlignment(&hAlign, &vAlign);
|
|
|
|
|
2007-01-06 01:07:35 +00:00
|
|
|
int overflowCols = 0;
|
|
|
|
|
|
|
|
if (attr.GetOverflow())
|
|
|
|
{
|
|
|
|
int cols = grid.GetNumberCols();
|
|
|
|
int best_width = GetBestSize(grid,attr,dc,row,col).GetWidth();
|
|
|
|
int cell_rows, cell_cols;
|
|
|
|
attr.GetSize( &cell_rows, &cell_cols ); // shouldn't get here if <=0
|
|
|
|
if ((best_width > rectCell.width) && (col < cols) && grid.GetTable())
|
|
|
|
{
|
|
|
|
int i, c_cols, c_rows;
|
|
|
|
for (i = col+cell_cols; i < cols; i++)
|
|
|
|
{
|
|
|
|
bool is_empty = true;
|
|
|
|
for (int j=row; j<row+cell_rows; j++)
|
|
|
|
{
|
|
|
|
// check w/ anchor cell for multicell block
|
|
|
|
grid.GetCellSize(j, i, &c_rows, &c_cols);
|
|
|
|
if (c_rows > 0) c_rows = 0;
|
|
|
|
if (!grid.GetTable()->IsEmptyCell(j+c_rows, i))
|
|
|
|
{
|
|
|
|
is_empty = false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (is_empty)
|
|
|
|
rect.width += grid.GetColSize(i);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
i--;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (rect.width >= best_width) break;
|
|
|
|
}
|
|
|
|
overflowCols = i - col - cell_cols + 1;
|
|
|
|
if (overflowCols >= cols) overflowCols = cols - 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (overflowCols > 0) // redraw overflow cells w/ proper hilight
|
|
|
|
{
|
|
|
|
hAlign = wxALIGN_LEFT; // if oveflowed then it's left aligned
|
|
|
|
wxRect clip = rect;
|
|
|
|
clip.x += rectCell.width;
|
|
|
|
// draw each overflow cell individually
|
|
|
|
int col_end = col+cell_cols+overflowCols;
|
|
|
|
if (col_end >= grid.GetNumberCols())
|
|
|
|
col_end = grid.GetNumberCols() - 1;
|
|
|
|
for (int i = col+cell_cols; i <= col_end; i++)
|
|
|
|
{
|
|
|
|
clip.width = grid.GetColSize(i) - 1;
|
|
|
|
dc.DestroyClippingRegion();
|
|
|
|
dc.SetClippingRegion(clip);
|
|
|
|
|
|
|
|
SetTextColoursAndFont(grid, attr, dc,
|
|
|
|
grid.IsInSelection(row,i));
|
|
|
|
|
|
|
|
grid.DrawTextRectangle(dc, grid.GetCellValue(row, col),
|
|
|
|
rect, hAlign, vAlign);
|
|
|
|
clip.x += grid.GetColSize(i) - 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
rect = rectCell;
|
|
|
|
rect.Inflate(-1);
|
|
|
|
rect.width++;
|
|
|
|
dc.DestroyClippingRegion();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-12-27 18:33:44 +00:00
|
|
|
// now we only have to draw the text
|
|
|
|
SetTextColoursAndFont(grid, attr, dc, isSelected);
|
|
|
|
|
2007-01-06 01:07:35 +00:00
|
|
|
//get a real grid class pointer
|
2007-01-13 21:08:50 +00:00
|
|
|
CBOINCGridCtrl* bgrid = wxDynamicCast(&grid, CBOINCGridCtrl);
|
|
|
|
|
2007-01-06 01:07:35 +00:00
|
|
|
//use the overloaded method here
|
|
|
|
bgrid->DrawTextRectangle(dc, grid.GetCellValue(row, col),
|
|
|
|
rect, hAlign, vAlign);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2007-01-10 22:19:29 +00:00
|
|
|
/* ############# message cell renderer ######################## */
|
|
|
|
|
|
|
|
/* Constructor
|
|
|
|
prio argument - the column index, that holds prio values
|
|
|
|
*/
|
2007-01-08 17:29:02 +00:00
|
|
|
CBOINCGridCellMessageRenderer::CBOINCGridCellMessageRenderer(int priocol){
|
|
|
|
column = priocol;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CBOINCGridCellMessageRenderer::Draw(wxGrid& grid, wxGridCellAttr& attr, wxDC& dc, const wxRect& rect, int row, int col, bool isSelected) {
|
2007-05-04 16:34:50 +00:00
|
|
|
wxString szError(wxT("Error"));
|
2007-01-08 17:29:02 +00:00
|
|
|
if(grid.GetCellValue(row,column).Trim(false).IsSameAs(szError)) {
|
|
|
|
attr.SetTextColour(*wxRED);
|
|
|
|
}
|
2007-01-10 22:19:29 +00:00
|
|
|
else {
|
|
|
|
attr.SetTextColour(*wxBLACK);
|
|
|
|
}
|
2007-01-08 17:29:02 +00:00
|
|
|
CBOINCGridCellRenderer::Draw(grid,attr,dc,rect,row,col,isSelected);
|
|
|
|
}
|
|
|
|
|
2007-01-10 22:19:29 +00:00
|
|
|
/* ############# progress cell renderer ########################## */
|
2007-01-08 17:29:02 +00:00
|
|
|
CBOINCGridCellProgressRenderer::CBOINCGridCellProgressRenderer(int col,bool percentAppending/*=true*/) : CBOINCGridCellRenderer()
|
|
|
|
{
|
|
|
|
column = col;
|
|
|
|
m_bDoPercentAppending = percentAppending;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CBOINCGridCellProgressRenderer::Draw(wxGrid& grid, wxGridCellAttr& attr, wxDC& dc, const wxRect& rect, int row, int col, bool isSelected) {
|
|
|
|
if(col==column) {
|
|
|
|
DoProgressDrawing(grid,attr,dc,rect,row,col,isSelected);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
DoNormalTextDrawing(grid,attr,dc,rect,row,col,isSelected);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-01-10 22:19:29 +00:00
|
|
|
/* paints the progress bar */
|
2007-01-06 01:07:35 +00:00
|
|
|
void CBOINCGridCellProgressRenderer::DoProgressDrawing(wxGrid& grid, wxGridCellAttr& attr, wxDC& dc, const wxRect& rectCell, int row, int col, bool isSelected) {
|
|
|
|
wxRect rect = rectCell;
|
|
|
|
rect.Inflate(-1);
|
|
|
|
|
|
|
|
// erase only this cells background, overflow cells should have been erased
|
2007-01-08 17:29:02 +00:00
|
|
|
this->DrawBackground(grid, dc, rectCell, row, isSelected);
|
2007-01-06 01:07:35 +00:00
|
|
|
// set text attributes
|
|
|
|
int hAlign, vAlign;
|
|
|
|
attr.GetAlignment(&hAlign, &vAlign);
|
|
|
|
SetTextColoursAndFont(grid, attr, dc, isSelected);
|
|
|
|
|
|
|
|
//calculate the two parts of the progress rect
|
2007-05-03 16:17:54 +00:00
|
|
|
//
|
|
|
|
double dv = 0.0;
|
|
|
|
wxString strValue = grid.GetCellValue(row,col);
|
2007-01-08 17:29:02 +00:00
|
|
|
if(m_bDoPercentAppending) {
|
2007-05-04 16:34:50 +00:00
|
|
|
strValue = strValue + wxT(" %");
|
2007-01-08 17:29:02 +00:00
|
|
|
}
|
2007-05-03 16:17:54 +00:00
|
|
|
|
|
|
|
// Project view uses the format: %0.0f (%0.2f%%)
|
|
|
|
// Everyone else uses: %.3f%%
|
2007-05-04 16:34:50 +00:00
|
|
|
if (strValue.Find(wxT("(")) != wxNOT_FOUND) {
|
|
|
|
strValue.SubString(strValue.Find(wxT("(")) + 1, strValue.Find(wxT(")")) - 1).ToDouble( &dv );
|
2007-05-03 16:17:54 +00:00
|
|
|
} else {
|
|
|
|
strValue.ToDouble ( &dv ); // NOTE: we should do error-checking/reporting here!!
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-12-27 18:33:44 +00:00
|
|
|
wxRect p1(rect);
|
|
|
|
wxRect p2(rect);
|
|
|
|
int r = (int)((rect.GetRight()-rect.GetLeft())*dv / 100.0);
|
|
|
|
p1.SetRight(rect.GetLeft()+r);
|
|
|
|
p2.SetLeft(rect.GetLeft()+r+1);
|
2007-01-06 01:07:35 +00:00
|
|
|
p2.SetRight(rect.GetRight()-1);
|
|
|
|
//start drawing
|
2006-12-27 18:33:44 +00:00
|
|
|
dc.SetClippingRegion(rect);
|
|
|
|
wxBrush old = dc.GetBrush();
|
2007-05-04 16:34:50 +00:00
|
|
|
wxColour progressColour = wxTheColourDatabase->Find(wxT("LIGHT BLUE"));
|
2007-01-06 01:07:35 +00:00
|
|
|
wxBrush* progressBrush = wxTheBrushList->FindOrCreateBrush(progressColour);
|
|
|
|
wxPen* progressPen = wxThePenList->FindOrCreatePen(progressColour,1,wxSOLID);
|
|
|
|
//draw the outline rectangle
|
|
|
|
dc.SetBrush(*wxTRANSPARENT_BRUSH);
|
|
|
|
dc.SetPen(*progressPen);
|
|
|
|
dc.DrawRectangle(rect);
|
|
|
|
// Draw the left part
|
|
|
|
dc.SetBrush(*progressBrush);
|
2006-12-27 18:33:44 +00:00
|
|
|
dc.DrawRectangle(p1);
|
2007-01-06 01:07:35 +00:00
|
|
|
//draw the right part
|
2006-12-27 18:33:44 +00:00
|
|
|
dc.SetBrush(old);
|
2007-01-06 01:07:35 +00:00
|
|
|
dc.DrawRectangle(p2);
|
|
|
|
//
|
2006-12-27 18:33:44 +00:00
|
|
|
dc.DestroyClippingRegion();
|
2007-01-06 01:07:35 +00:00
|
|
|
// draw the text
|
2006-12-27 18:33:44 +00:00
|
|
|
grid.DrawTextRectangle(dc, strValue, rect, hAlign, vAlign);
|
|
|
|
}
|
2007-01-06 01:07:35 +00:00
|
|
|
|
2007-01-08 17:29:02 +00:00
|
|
|
/* enables or disbale the appendign of the percent sign to the progress text */
|
|
|
|
void CBOINCGridCellProgressRenderer::SetPercentAppending(bool enable/*=true*/) {
|
|
|
|
m_bDoPercentAppending = enable;
|
|
|
|
}
|
|
|
|
|
2007-01-07 16:15:04 +00:00
|
|
|
|
|
|
|
/* ############ GridTable class ############ */
|
|
|
|
CBOINCGridTable::CBOINCGridTable(int rows, int cols) : wxGridStringTable(rows,cols) {
|
|
|
|
//init column sort types with CST_STRING
|
|
|
|
for(int i=0; i< cols; i++) {
|
|
|
|
arrColumnSortTypes.Add(CST_STRING);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
CBOINCGridTable::~CBOINCGridTable() {
|
|
|
|
}
|
|
|
|
|
2007-01-08 17:29:02 +00:00
|
|
|
|
2007-01-07 16:15:04 +00:00
|
|
|
void CBOINCGridTable::SetColumnSortType(int col,int sortType/*=CST_STRING*/) {
|
2007-01-08 17:29:02 +00:00
|
|
|
if(col>=0 && col < ((int)arrColumnSortTypes.GetCount())) {
|
2007-01-07 16:15:04 +00:00
|
|
|
arrColumnSortTypes[col] = sortType;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CBOINCGridTable::SortData(int col,bool ascending) {
|
|
|
|
//valid column index ?
|
|
|
|
if(col<0) {
|
|
|
|
return;
|
|
|
|
}
|
2007-01-08 17:29:02 +00:00
|
|
|
wxArrayString arColValues;
|
2007-01-07 16:15:04 +00:00
|
|
|
//get the values of the sorting column
|
2007-01-08 17:29:02 +00:00
|
|
|
for(int i=0; i < this->GetNumberRows(); i++) {
|
2007-01-07 16:15:04 +00:00
|
|
|
arColValues.Add(this->GetValue(i,col));
|
|
|
|
}
|
2007-01-08 17:29:02 +00:00
|
|
|
//sort the sorting column values
|
2007-01-07 16:15:04 +00:00
|
|
|
reverseCompareOrder = !ascending;
|
2007-01-10 22:19:29 +00:00
|
|
|
//decide, which sort function to call
|
2007-01-07 16:15:04 +00:00
|
|
|
switch(arrColumnSortTypes[col]) {
|
2007-01-08 17:29:02 +00:00
|
|
|
case CST_FLOAT:
|
2007-01-07 16:15:04 +00:00
|
|
|
arColValues.Sort(CompareFloatString);
|
|
|
|
break;
|
2007-01-08 17:29:02 +00:00
|
|
|
case CST_LONG:
|
2007-01-07 16:15:04 +00:00
|
|
|
arColValues.Sort(CompareLongString);
|
|
|
|
break;
|
2007-01-08 17:29:02 +00:00
|
|
|
case CST_TIME:
|
2007-01-07 16:15:04 +00:00
|
|
|
arColValues.Sort(CompareTimeString);
|
|
|
|
break;
|
|
|
|
case CST_DATETIME:
|
|
|
|
arColValues.Sort(CompareDateString);
|
|
|
|
break;
|
|
|
|
default:
|
2007-01-08 17:29:02 +00:00
|
|
|
arColValues.Sort(CompareStringStringNoCase);
|
2007-01-07 16:15:04 +00:00
|
|
|
break;
|
|
|
|
}
|
2007-01-08 17:29:02 +00:00
|
|
|
//rebuild the underlaying 2-dimensional string array
|
2007-01-07 16:15:04 +00:00
|
|
|
wxGridStringArray newArray;
|
2007-01-08 17:29:02 +00:00
|
|
|
for(unsigned int i=0; i< arColValues.GetCount();i++) {
|
2007-01-07 16:15:04 +00:00
|
|
|
//find the original row index
|
2008-03-05 07:13:53 +00:00
|
|
|
int indexold = FindRowIndexByColValue(col,arColValues[i],-1,arColValues[i]);
|
2007-01-07 16:15:04 +00:00
|
|
|
wxArrayString rowArray;
|
|
|
|
for(int j=0; j < this->GetNumberCols(); j++) {
|
|
|
|
rowArray.Add(this->GetValue(indexold,j));
|
2007-01-08 17:29:02 +00:00
|
|
|
//delete the value in the original string array
|
2007-01-07 16:15:04 +00:00
|
|
|
//to prevent finding the wrong index in case of identical values
|
|
|
|
//f.e. the project name is the same for multiple work units or transfers
|
|
|
|
this->SetValue(indexold,j,wxEmptyString);
|
|
|
|
}
|
|
|
|
newArray.Add(rowArray);
|
|
|
|
}
|
|
|
|
//fill the table data array with the sorted values
|
|
|
|
for(unsigned int i=0; i< newArray.GetCount(); i++) {
|
|
|
|
for(unsigned int j=0; j < newArray[i].GetCount();j++) {
|
|
|
|
this->SetValue(i,j,newArray[i][j]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-03-05 07:13:53 +00:00
|
|
|
/* finds the first row index for the cell with value value1 in column col1 and value2 in col2
|
|
|
|
ignores col2 and value2 if col2 < 0
|
|
|
|
!! only use this (outside sorting method) with a pair of columns, that have unique value pairs !!
|
2007-01-07 16:15:04 +00:00
|
|
|
*/
|
2008-03-05 07:13:53 +00:00
|
|
|
int CBOINCGridTable::FindRowIndexByColValue(int col1,wxString& value1,int col2,wxString& value2) {
|
2007-01-08 17:29:02 +00:00
|
|
|
|
2007-01-07 16:15:04 +00:00
|
|
|
for(int i=0; i < this->GetNumberRows(); i++) {
|
2008-03-05 07:13:53 +00:00
|
|
|
if(! this->GetValue(i,col1).IsSameAs(value1)) continue;
|
|
|
|
if (col2 < 0) return i;
|
|
|
|
if(this->GetValue(i,col2).IsSameAs(value2)) return i;
|
2007-01-07 16:15:04 +00:00
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* for convinience purposes only */
|
|
|
|
CBOINCGridTable* CBOINCGridCtrl::GetTable() {
|
2007-01-13 21:08:50 +00:00
|
|
|
return wxDynamicCast(wxGrid::GetTable(), CBOINCGridTable);
|
2007-01-07 16:15:04 +00:00
|
|
|
}
|