Removed cell highlighting temporarily. Now wxGrid::EnableEditing(bool)
sets the cell edit control to be editable or read-only. Fixed row sizing problem where text was clipped in the cell edit control. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@5819 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -49,8 +49,6 @@
|
|||||||
#define WXGRID_MIN_ROW_HEIGHT 15
|
#define WXGRID_MIN_ROW_HEIGHT 15
|
||||||
#define WXGRID_MIN_COL_WIDTH 15
|
#define WXGRID_MIN_COL_WIDTH 15
|
||||||
#define WXGRID_DEFAULT_SCROLLBAR_WIDTH 16
|
#define WXGRID_DEFAULT_SCROLLBAR_WIDTH 16
|
||||||
#define WXGRID_DEFAULT_TOPEDIT_WIDTH 300
|
|
||||||
#define WXGRID_DEFAULT_TOPEDIT_HEIGHT 60
|
|
||||||
|
|
||||||
|
|
||||||
class WXDLLEXPORT wxGrid;
|
class WXDLLEXPORT wxGrid;
|
||||||
@@ -398,7 +396,6 @@ class WXDLLEXPORT wxGrid : public wxScrolledWindow
|
|||||||
int m_numCols;
|
int m_numCols;
|
||||||
|
|
||||||
wxGridCellCoords m_currentCellCoords;
|
wxGridCellCoords m_currentCellCoords;
|
||||||
bool m_currentCellHighlighted;
|
|
||||||
|
|
||||||
wxGridCellCoords m_selectedTopLeft;
|
wxGridCellCoords m_selectedTopLeft;
|
||||||
wxGridCellCoords m_selectedBottomRight;
|
wxGridCellCoords m_selectedBottomRight;
|
||||||
@@ -462,8 +459,6 @@ class WXDLLEXPORT wxGrid : public wxScrolledWindow
|
|||||||
int m_editCtrlType; // for current cell
|
int m_editCtrlType; // for current cell
|
||||||
wxWindow* m_cellEditCtrl;
|
wxWindow* m_cellEditCtrl;
|
||||||
bool m_cellEditCtrlEnabled;
|
bool m_cellEditCtrlEnabled;
|
||||||
wxWindow* m_topEditCtrl;
|
|
||||||
bool m_topEditCtrlEnabled;
|
|
||||||
|
|
||||||
|
|
||||||
void Create();
|
void Create();
|
||||||
@@ -553,7 +548,7 @@ class WXDLLEXPORT wxGrid : public wxScrolledWindow
|
|||||||
void DrawCell( wxDC& dc, const wxGridCellCoords& );
|
void DrawCell( wxDC& dc, const wxGridCellCoords& );
|
||||||
void DrawCellBackground( wxDC& dc, const wxGridCellCoords& );
|
void DrawCellBackground( wxDC& dc, const wxGridCellCoords& );
|
||||||
void DrawCellValue( wxDC& dc, const wxGridCellCoords& );
|
void DrawCellValue( wxDC& dc, const wxGridCellCoords& );
|
||||||
|
|
||||||
void DrawRowLabels( wxDC& dc );
|
void DrawRowLabels( wxDC& dc );
|
||||||
void DrawRowLabel( wxDC& dc, int row );
|
void DrawRowLabel( wxDC& dc, int row );
|
||||||
void DrawColLabels( wxDC& dc );
|
void DrawColLabels( wxDC& dc );
|
||||||
@@ -591,16 +586,13 @@ class WXDLLEXPORT wxGrid : public wxScrolledWindow
|
|||||||
bool IsEditable() { return m_editable; }
|
bool IsEditable() { return m_editable; }
|
||||||
void EnableEditing( bool edit );
|
void EnableEditing( bool edit );
|
||||||
|
|
||||||
|
#if 0 // at the moment the cell edit control is always active
|
||||||
void EnableCellEditControl( bool enable );
|
void EnableCellEditControl( bool enable );
|
||||||
|
#endif
|
||||||
|
|
||||||
bool IsCellEditControlEnabled()
|
bool IsCellEditControlEnabled()
|
||||||
{ return (m_cellEditCtrl && m_cellEditCtrlEnabled); }
|
{ return (m_cellEditCtrl && m_cellEditCtrlEnabled); }
|
||||||
|
|
||||||
void EnableTopEditControl( bool enable );
|
|
||||||
|
|
||||||
bool IsTopEditControlEnabled()
|
|
||||||
{ return (m_topEditCtrl && m_topEditCtrlEnabled); }
|
|
||||||
|
|
||||||
void ShowCellEditControl();
|
void ShowCellEditControl();
|
||||||
void HideCellEditControl();
|
void HideCellEditControl();
|
||||||
void SetEditControlValue( const wxString& s = wxEmptyString );
|
void SetEditControlValue( const wxString& s = wxEmptyString );
|
||||||
@@ -691,7 +683,6 @@ class WXDLLEXPORT wxGrid : public wxScrolledWindow
|
|||||||
wxColour GetCellBackgroundColour( int row, int col );
|
wxColour GetCellBackgroundColour( int row, int col );
|
||||||
wxColour GetDefaultCellTextColour();
|
wxColour GetDefaultCellTextColour();
|
||||||
wxColour GetCellTextColour( int row, int col );
|
wxColour GetCellTextColour( int row, int col );
|
||||||
wxColour GetCellHighlightColour();
|
|
||||||
wxFont GetDefaultCellFont();
|
wxFont GetDefaultCellFont();
|
||||||
wxFont GetCellFont( int row, int col );
|
wxFont GetCellFont( int row, int col );
|
||||||
void GetDefaultCellAlignment( int *horiz, int *vert );
|
void GetDefaultCellAlignment( int *horiz, int *vert );
|
||||||
@@ -705,7 +696,6 @@ class WXDLLEXPORT wxGrid : public wxScrolledWindow
|
|||||||
void SetCellBackgroundColour( int row, int col, const wxColour& );
|
void SetCellBackgroundColour( int row, int col, const wxColour& );
|
||||||
void SetDefaultCellTextColour( const wxColour& );
|
void SetDefaultCellTextColour( const wxColour& );
|
||||||
void SetCellTextColour( int row, int col, const wxColour& );
|
void SetCellTextColour( int row, int col, const wxColour& );
|
||||||
void SetCellHighlightColour( const wxColour& );
|
|
||||||
void SetDefaultCellFont( const wxFont& );
|
void SetDefaultCellFont( const wxFont& );
|
||||||
void SetCellFont( int row, int col, const wxFont& );
|
void SetCellFont( int row, int col, const wxFont& );
|
||||||
void SetDefaultCellAlignment( int horiz, int vert );
|
void SetDefaultCellAlignment( int horiz, int vert );
|
||||||
@@ -919,7 +909,7 @@ class WXDLLEXPORT wxGrid : public wxScrolledWindow
|
|||||||
bool GetEditable() { return IsEditable(); }
|
bool GetEditable() { return IsEditable(); }
|
||||||
void SetEditable( bool edit = TRUE ) { EnableEditing( edit ); }
|
void SetEditable( bool edit = TRUE ) { EnableEditing( edit ); }
|
||||||
bool GetEditInPlace() { return IsCellEditControlEnabled(); }
|
bool GetEditInPlace() { return IsCellEditControlEnabled(); }
|
||||||
void SetEditInPlace(bool edit = TRUE) { EnableCellEditControl( edit ); }
|
void SetEditInPlace(bool edit = TRUE) { }
|
||||||
|
|
||||||
void SetCellAlignment( int align, int row, int col)
|
void SetCellAlignment( int align, int row, int col)
|
||||||
{ SetCellAlignment(row, col, align, wxCENTER); }
|
{ SetCellAlignment(row, col, align, wxCENTER); }
|
||||||
|
@@ -941,10 +941,6 @@ void wxGrid::Create()
|
|||||||
m_colLabelWin = (wxGridColLabelWindow *) NULL;
|
m_colLabelWin = (wxGridColLabelWindow *) NULL;
|
||||||
m_cornerLabelWin = (wxGridCornerLabelWindow *) NULL;
|
m_cornerLabelWin = (wxGridCornerLabelWindow *) NULL;
|
||||||
m_cellEditCtrl = (wxWindow *) NULL;
|
m_cellEditCtrl = (wxWindow *) NULL;
|
||||||
|
|
||||||
// TODO: do we need this or should the top edit control be an add-on ?
|
|
||||||
//
|
|
||||||
m_topEditCtrl = (wxWindow *) NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -998,8 +994,14 @@ void wxGrid::Init()
|
|||||||
m_colLabelVertAlign = wxTOP;
|
m_colLabelVertAlign = wxTOP;
|
||||||
|
|
||||||
m_defaultColWidth = WXGRID_DEFAULT_COL_WIDTH;
|
m_defaultColWidth = WXGRID_DEFAULT_COL_WIDTH;
|
||||||
m_defaultRowHeight = m_gridWin->GetCharHeight() + 8;
|
m_defaultRowHeight = m_gridWin->GetCharHeight();
|
||||||
|
|
||||||
|
#if defined (__WXMOTIF__) // see also text ctrl sizing in ShowCellEditControl()
|
||||||
|
m_defaultRowHeight += 8;
|
||||||
|
#else
|
||||||
|
m_defaultRowHeight += 4;
|
||||||
|
#endif
|
||||||
|
|
||||||
m_rowHeights.Alloc( m_numRows );
|
m_rowHeights.Alloc( m_numRows );
|
||||||
m_rowBottoms.Alloc( m_numRows );
|
m_rowBottoms.Alloc( m_numRows );
|
||||||
int rowBottom = 0;
|
int rowBottom = 0;
|
||||||
@@ -1036,7 +1038,6 @@ void wxGrid::Init()
|
|||||||
m_colResizeCursor = wxCursor( wxCURSOR_SIZEWE );
|
m_colResizeCursor = wxCursor( wxCURSOR_SIZEWE );
|
||||||
|
|
||||||
m_currentCellCoords = wxGridNoCellCoords;
|
m_currentCellCoords = wxGridNoCellCoords;
|
||||||
m_currentCellHighlighted = FALSE;
|
|
||||||
|
|
||||||
m_selectedTopLeft = wxGridNoCellCoords;
|
m_selectedTopLeft = wxGridNoCellCoords;
|
||||||
m_selectedBottomRight = wxGridNoCellCoords;
|
m_selectedBottomRight = wxGridNoCellCoords;
|
||||||
@@ -1063,10 +1064,6 @@ void wxGrid::Init()
|
|||||||
m_cellEditCtrl->Show( FALSE );
|
m_cellEditCtrl->Show( FALSE );
|
||||||
m_cellEditCtrlEnabled = TRUE;
|
m_cellEditCtrlEnabled = TRUE;
|
||||||
m_editCtrlType = wxGRID_TEXTCTRL;
|
m_editCtrlType = wxGRID_TEXTCTRL;
|
||||||
|
|
||||||
// TODO: do we need this or should the top edit control be an add-on ?
|
|
||||||
//
|
|
||||||
m_topEditCtrlEnabled = FALSE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1970,7 +1967,7 @@ void wxGrid::ClearGrid()
|
|||||||
{
|
{
|
||||||
m_table->Clear();
|
m_table->Clear();
|
||||||
SetEditControlValue();
|
SetEditControlValue();
|
||||||
if ( !GetBatchCount() ) Refresh();
|
if ( !GetBatchCount() ) m_gridWin->Refresh();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2444,7 +2441,6 @@ void wxGrid::SetCurrentCell( const wxGridCellCoords& coords )
|
|||||||
|
|
||||||
if ( m_currentCellCoords != wxGridNoCellCoords )
|
if ( m_currentCellCoords != wxGridNoCellCoords )
|
||||||
{
|
{
|
||||||
// HideCurrentCellHighlight( dc );
|
|
||||||
HideCellEditControl();
|
HideCellEditControl();
|
||||||
SaveEditControlValue();
|
SaveEditControlValue();
|
||||||
}
|
}
|
||||||
@@ -2453,7 +2449,6 @@ void wxGrid::SetCurrentCell( const wxGridCellCoords& coords )
|
|||||||
|
|
||||||
SetEditControlValue();
|
SetEditControlValue();
|
||||||
ShowCellEditControl();
|
ShowCellEditControl();
|
||||||
// ShowCurrentCellHighlight( dc );
|
|
||||||
|
|
||||||
if ( IsSelection() )
|
if ( IsSelection() )
|
||||||
{
|
{
|
||||||
@@ -2909,13 +2904,18 @@ void wxGrid::EnableEditing( bool edit )
|
|||||||
if ( edit != m_editable )
|
if ( edit != m_editable )
|
||||||
{
|
{
|
||||||
m_editable = edit;
|
m_editable = edit;
|
||||||
if ( !m_editable ) HideCellEditControl();
|
|
||||||
m_cellEditCtrlEnabled = m_editable;
|
// TODO: extend this for other edit control types
|
||||||
if ( m_editable ) ShowCellEditControl();
|
//
|
||||||
|
if ( m_editCtrlType == wxGRID_TEXTCTRL )
|
||||||
|
{
|
||||||
|
((wxTextCtrl *)m_cellEditCtrl)->SetEditable( m_editable );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#if 0 // disabled for the moment - the cell control is always active
|
||||||
void wxGrid::EnableCellEditControl( bool enable )
|
void wxGrid::EnableCellEditControl( bool enable )
|
||||||
{
|
{
|
||||||
if ( m_cellEditCtrl &&
|
if ( m_cellEditCtrl &&
|
||||||
@@ -2927,26 +2927,15 @@ void wxGrid::EnableCellEditControl( bool enable )
|
|||||||
{
|
{
|
||||||
SetEditControlValue();
|
SetEditControlValue();
|
||||||
ShowCellEditControl();
|
ShowCellEditControl();
|
||||||
// ShowCurrentCellHighlight( dc );
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// HideCurrentCellHighlight( dc );
|
|
||||||
HideCellEditControl();
|
HideCellEditControl();
|
||||||
SaveEditControlValue();
|
SaveEditControlValue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// TODO: not implemented at the moment
|
|
||||||
// Do we want it ?
|
|
||||||
//
|
|
||||||
void wxGrid::EnableTopEditControl( bool enable )
|
|
||||||
{
|
|
||||||
// TODO: do we want this here or should the top edit
|
|
||||||
// control be an add-on class ?
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void wxGrid::ShowCellEditControl()
|
void wxGrid::ShowCellEditControl()
|
||||||
@@ -2971,9 +2960,21 @@ void wxGrid::ShowCellEditControl()
|
|||||||
|
|
||||||
int cw, ch;
|
int cw, ch;
|
||||||
m_gridWin->GetClientSize( &cw, &ch );
|
m_gridWin->GetClientSize( &cw, &ch );
|
||||||
|
|
||||||
rect.SetLeft( wxMax(0, left) );
|
// Make the edit control large enough to allow for internal margins
|
||||||
rect.SetTop( wxMax(0, top) );
|
// TODO: remove this if the text ctrl sizing is improved esp. for unix
|
||||||
|
//
|
||||||
|
#if defined (__WXMOTIF__)
|
||||||
|
rect.SetLeft( wxMax(0, left-4) );
|
||||||
|
rect.SetTop( wxMax(0, top-4) );
|
||||||
|
rect.SetRight( rect.GetRight() + 8 );
|
||||||
|
rect.SetBottom( rect.GetBottom() + 8 );
|
||||||
|
#else
|
||||||
|
rect.SetLeft( wxMax(0, left-2) );
|
||||||
|
rect.SetTop( wxMax(0, top-2) );
|
||||||
|
rect.SetRight( rect.GetRight() + 4 );
|
||||||
|
rect.SetBottom( rect.GetBottom() + 4 );
|
||||||
|
#endif
|
||||||
|
|
||||||
m_cellEditCtrl->SetSize( rect );
|
m_cellEditCtrl->SetSize( rect );
|
||||||
m_cellEditCtrl->Show( TRUE );
|
m_cellEditCtrl->Show( TRUE );
|
||||||
@@ -3025,34 +3026,6 @@ void wxGrid::SetEditControlValue( const wxString& value )
|
|||||||
else
|
else
|
||||||
s = value;
|
s = value;
|
||||||
|
|
||||||
// TODO: no top edit control implemented at the moment...
|
|
||||||
// Do we want it in this class ?
|
|
||||||
//
|
|
||||||
if ( IsTopEditControlEnabled() )
|
|
||||||
{
|
|
||||||
switch ( m_editCtrlType )
|
|
||||||
{
|
|
||||||
case wxGRID_TEXTCTRL:
|
|
||||||
((wxGridTextCtrl *)m_topEditCtrl)->SetStartValue(s);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case wxGRID_CHECKBOX:
|
|
||||||
// TODO: implement this
|
|
||||||
//
|
|
||||||
break;
|
|
||||||
|
|
||||||
case wxGRID_CHOICE:
|
|
||||||
// TODO: implement this
|
|
||||||
//
|
|
||||||
break;
|
|
||||||
|
|
||||||
case wxGRID_COMBOBOX:
|
|
||||||
// TODO: implement this
|
|
||||||
//
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( IsCellEditControlEnabled() )
|
if ( IsCellEditControlEnabled() )
|
||||||
{
|
{
|
||||||
switch ( m_editCtrlType )
|
switch ( m_editCtrlType )
|
||||||
@@ -3091,10 +3064,6 @@ void wxGrid::SaveEditControlValue()
|
|||||||
{
|
{
|
||||||
ctrl = m_cellEditCtrl;
|
ctrl = m_cellEditCtrl;
|
||||||
}
|
}
|
||||||
else if ( IsTopEditControlEnabled() )
|
|
||||||
{
|
|
||||||
ctrl = m_topEditCtrl;
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@@ -3952,14 +3921,6 @@ wxColour wxGrid::GetCellTextColour( int WXUNUSED(row), int WXUNUSED(col) )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
wxColour wxGrid::GetCellHighlightColour()
|
|
||||||
{
|
|
||||||
// TODO: replace this temp test code
|
|
||||||
//
|
|
||||||
return wxColour( 0, 0, 0 );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
wxFont wxGrid::GetDefaultCellFont()
|
wxFont wxGrid::GetDefaultCellFont()
|
||||||
{
|
{
|
||||||
return m_defaultCellFont;
|
return m_defaultCellFont;
|
||||||
@@ -4104,12 +4065,6 @@ void wxGrid::SetCellTextColour( int WXUNUSED(row), int WXUNUSED(col), const wxCo
|
|||||||
//
|
//
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxGrid::SetCellHighlightColour( const wxColour& )
|
|
||||||
{
|
|
||||||
// TODO: everything !!!
|
|
||||||
//
|
|
||||||
}
|
|
||||||
|
|
||||||
void wxGrid::SetDefaultCellFont( const wxFont& )
|
void wxGrid::SetDefaultCellFont( const wxFont& )
|
||||||
{
|
{
|
||||||
// TODO: everything !!!
|
// TODO: everything !!!
|
||||||
|
Reference in New Issue
Block a user