KissCount/src/view/grid/wxMyGrid.cpp

49 lines
1.6 KiB
C++
Raw Normal View History

#include "wxMyGrid.h"
BEGIN_EVENT_TABLE(wxMyGrid, wxGrid)
EVT_GRID_CELL_LEFT_CLICK(wxMyGrid::OnCellLeftClick )
END_EVENT_TABLE()
wxMyGrid::wxMyGrid(wxWindow* parent, int id, int* clicks, int size) : wxGrid(parent, id)
{
for(int i=0; i<size; i++)
_clicks.push_back(clicks[i]);
}
// From http://nomadsync.cvs.sourceforge.net/nomadsync/nomadsync/src/
void wxMyGrid::OnCellLeftClick(wxGridEvent& evt)
{
std::vector<int>::iterator it;
for(it = _clicks.begin(); it != _clicks.end(); it++)
{
if (*it == evt.GetCol())
{
// This forces the cell to go into edit mode directly
//m_waitForSlowClick = TRUE;
SetGridCursor(evt.GetRow(), evt.GetCol());
// Store the click co-ordinates in the editor if possible
// if an editor has created a ClientData area, we presume it's
// a wxPoint and we store the click co-ordinates
wxGridCellEditor* pEditor = GetCellEditor(evt.GetRow(), evt.GetCol());
wxPoint* pClickPoint = (wxPoint*)pEditor->GetClientData();
if (pClickPoint)
{
*pClickPoint = ClientToScreen(evt.GetPosition());
#ifndef __WINDOWS__
EnableCellEditControl(true);
#endif
}
// hack to prevent selection from being lost when click combobox
if (evt.GetCol() == 0 && IsInSelection(evt.GetRow(), evt.GetCol()))
{
//m_selTemp = m_selection;
m_selection = NULL;
}
pEditor->DecRef();
break;
}
}
evt.Skip();
}