Some cleanup.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@6020 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -145,9 +145,9 @@ public:
|
|||||||
// Reset the value in the control back to its starting value
|
// Reset the value in the control back to its starting value
|
||||||
virtual void Reset() = 0;
|
virtual void Reset() = 0;
|
||||||
|
|
||||||
// If the editor is enabled by pressing keys on the grid, this
|
// If the editor is enabled by pressing keys on the grid,
|
||||||
// will be called to let the editor do something about that key
|
// this will be called to let the editor do something about
|
||||||
// if desired.
|
// that first key if desired.
|
||||||
virtual void StartingKey(wxKeyEvent& event);
|
virtual void StartingKey(wxKeyEvent& event);
|
||||||
|
|
||||||
// Some types of controls on some platforms may need some help
|
// Some types of controls on some platforms may need some help
|
||||||
@@ -547,42 +547,6 @@ WX_DECLARE_EXPORTED_OBJARRAY(wxGridCellCoords, wxGridCellCoordsArray);
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
// This set of classes is to provide for the use of different types of
|
|
||||||
// cell edit controls in the grid while avoiding the wx class info
|
|
||||||
// system in deference to wxPython
|
|
||||||
|
|
||||||
class WXDLLEXPORT wxGridTextCtrl : public wxTextCtrl
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
wxGridTextCtrl() {}
|
|
||||||
wxGridTextCtrl( wxWindow *,
|
|
||||||
wxGrid *,
|
|
||||||
bool isCellControl,
|
|
||||||
wxWindowID id,
|
|
||||||
const wxString& value = wxEmptyString,
|
|
||||||
const wxPoint& pos = wxDefaultPosition,
|
|
||||||
const wxSize& size = wxDefaultSize,
|
|
||||||
long style = 0 );
|
|
||||||
|
|
||||||
void SetStartValue( const wxString& );
|
|
||||||
wxString GetStartValue() { return startValue; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
wxGrid *m_grid;
|
|
||||||
|
|
||||||
// TRUE for controls placed over cells,
|
|
||||||
// FALSE for a control on a grid control panel
|
|
||||||
bool m_isCellControl;
|
|
||||||
|
|
||||||
wxString startValue;
|
|
||||||
|
|
||||||
void OnKeyDown( wxKeyEvent& );
|
|
||||||
|
|
||||||
DECLARE_DYNAMIC_CLASS( wxGridTextCtrl )
|
|
||||||
DECLARE_EVENT_TABLE()
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// wxGrid
|
// wxGrid
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
@@ -1354,117 +1354,6 @@ void wxGridStringTable::SetColLabelValue( int col, const wxString& value )
|
|||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
IMPLEMENT_DYNAMIC_CLASS( wxGridTextCtrl, wxTextCtrl )
|
|
||||||
|
|
||||||
BEGIN_EVENT_TABLE( wxGridTextCtrl, wxTextCtrl )
|
|
||||||
EVT_KEY_DOWN( wxGridTextCtrl::OnKeyDown )
|
|
||||||
END_EVENT_TABLE()
|
|
||||||
|
|
||||||
|
|
||||||
wxGridTextCtrl::wxGridTextCtrl( wxWindow *par,
|
|
||||||
wxGrid *grid,
|
|
||||||
bool isCellControl,
|
|
||||||
wxWindowID id,
|
|
||||||
const wxString& value,
|
|
||||||
const wxPoint& pos,
|
|
||||||
const wxSize& size,
|
|
||||||
long style )
|
|
||||||
: wxTextCtrl( par, id, value, pos, size, style )
|
|
||||||
{
|
|
||||||
m_grid = grid;
|
|
||||||
m_isCellControl = isCellControl;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void wxGridTextCtrl::OnKeyDown( wxKeyEvent& event )
|
|
||||||
{
|
|
||||||
switch ( event.KeyCode() )
|
|
||||||
{
|
|
||||||
#if 0
|
|
||||||
case WXK_ESCAPE:
|
|
||||||
m_grid->SetEditControlValue( startValue );
|
|
||||||
SetInsertionPointEnd();
|
|
||||||
break;
|
|
||||||
#else
|
|
||||||
case WXK_ESCAPE:
|
|
||||||
m_grid->EnableCellEditControl( FALSE );
|
|
||||||
#endif
|
|
||||||
case WXK_UP:
|
|
||||||
case WXK_DOWN:
|
|
||||||
case WXK_LEFT:
|
|
||||||
case WXK_RIGHT:
|
|
||||||
case WXK_PRIOR:
|
|
||||||
case WXK_NEXT:
|
|
||||||
case WXK_SPACE:
|
|
||||||
if ( m_isCellControl )
|
|
||||||
{
|
|
||||||
// send the event to the parent grid, skipping the
|
|
||||||
// event if nothing happens
|
|
||||||
//
|
|
||||||
event.Skip( m_grid->ProcessEvent( event ) );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// default text control response within the top edit
|
|
||||||
// control
|
|
||||||
//
|
|
||||||
event.Skip();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case WXK_RETURN:
|
|
||||||
if ( m_isCellControl )
|
|
||||||
{
|
|
||||||
if ( !m_grid->ProcessEvent( event ) )
|
|
||||||
{
|
|
||||||
#if defined(__WXMOTIF__) || defined(__WXGTK__)
|
|
||||||
// wxMotif needs a little extra help...
|
|
||||||
//
|
|
||||||
int pos = GetInsertionPoint();
|
|
||||||
wxString s( GetValue() );
|
|
||||||
s = s.Left(pos) + "\n" + s.Mid(pos);
|
|
||||||
SetValue(s);
|
|
||||||
SetInsertionPoint( pos );
|
|
||||||
#else
|
|
||||||
// the other ports can handle a Return key press
|
|
||||||
//
|
|
||||||
event.Skip();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case WXK_HOME:
|
|
||||||
case WXK_END:
|
|
||||||
if ( m_isCellControl )
|
|
||||||
{
|
|
||||||
// send the event to the parent grid, skipping the
|
|
||||||
// event if nothing happens
|
|
||||||
//
|
|
||||||
event.Skip( m_grid->ProcessEvent( event ) );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// default text control response within the top edit
|
|
||||||
// control
|
|
||||||
//
|
|
||||||
event.Skip();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
event.Skip();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void wxGridTextCtrl::SetStartValue( const wxString& s )
|
|
||||||
{
|
|
||||||
startValue = s;
|
|
||||||
wxTextCtrl::SetValue(s);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
IMPLEMENT_DYNAMIC_CLASS( wxGridRowLabelWindow, wxWindow )
|
IMPLEMENT_DYNAMIC_CLASS( wxGridRowLabelWindow, wxWindow )
|
||||||
@@ -1813,6 +1702,11 @@ bool wxGrid::SetTable( wxGridTableBase *table, bool takeOwnership )
|
|||||||
{
|
{
|
||||||
if ( m_created )
|
if ( m_created )
|
||||||
{
|
{
|
||||||
|
// RD: Actually, this should probably be allowed. I think it would be
|
||||||
|
// nice to be able to switch multiple Tables in and out of a single
|
||||||
|
// View at runtime. Is there anything in the implmentation that would
|
||||||
|
// prevent this?
|
||||||
|
|
||||||
wxFAIL_MSG( wxT("wxGrid::CreateGrid or wxGrid::SetTable called more than once") );
|
wxFAIL_MSG( wxT("wxGrid::CreateGrid or wxGrid::SetTable called more than once") );
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
@@ -3678,7 +3572,7 @@ void wxGrid::SetCurrentCell( const wxGridCellCoords& coords )
|
|||||||
|
|
||||||
// Clear the old current cell highlight
|
// Clear the old current cell highlight
|
||||||
wxRect r = BlockToDeviceRect(m_currentCellCoords, m_currentCellCoords);
|
wxRect r = BlockToDeviceRect(m_currentCellCoords, m_currentCellCoords);
|
||||||
m_currentCellCoords = coords; // Otherwise refresh redraws the hilit!
|
m_currentCellCoords = coords; // Otherwise refresh redraws the highlight!
|
||||||
m_gridWin->Refresh( FALSE, &r );
|
m_gridWin->Refresh( FALSE, &r );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3688,13 +3582,9 @@ void wxGrid::SetCurrentCell( const wxGridCellCoords& coords )
|
|||||||
|
|
||||||
if ( m_displayed )
|
if ( m_displayed )
|
||||||
{
|
{
|
||||||
#if 0
|
|
||||||
ShowCellEditControl();
|
|
||||||
#else
|
|
||||||
wxClientDC dc(m_gridWin);
|
wxClientDC dc(m_gridWin);
|
||||||
PrepareDC(dc);
|
PrepareDC(dc);
|
||||||
DrawCellHighlight(dc);
|
DrawCellHighlight(dc);
|
||||||
#endif
|
|
||||||
|
|
||||||
if ( IsSelection() )
|
if ( IsSelection() )
|
||||||
{
|
{
|
||||||
@@ -3811,7 +3701,6 @@ void wxGrid::DrawCellHighlight( wxDC& dc )
|
|||||||
|
|
||||||
dc.SetPen(wxPen(m_gridLineColour, 3, wxSOLID));
|
dc.SetPen(wxPen(m_gridLineColour, 3, wxSOLID));
|
||||||
dc.SetBrush(*wxTRANSPARENT_BRUSH);
|
dc.SetBrush(*wxTRANSPARENT_BRUSH);
|
||||||
//dc.SetLogicalFunction(wxINVERT);
|
|
||||||
|
|
||||||
dc.DrawRectangle(rect);
|
dc.DrawRectangle(rect);
|
||||||
}
|
}
|
||||||
@@ -4258,6 +4147,8 @@ void wxGrid::HideCellEditControl()
|
|||||||
|
|
||||||
void wxGrid::SetEditControlValue( const wxString& value )
|
void wxGrid::SetEditControlValue( const wxString& value )
|
||||||
{
|
{
|
||||||
|
// RD: The new Editors get the value from the table themselves now. This
|
||||||
|
// method can probably be removed...
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user