#define WXGRID_MIN_ROW_HEIGHT 15
#define WXGRID_MIN_COL_WIDTH 15
#define WXGRID_DEFAULT_SCROLLBAR_WIDTH 16
-#define WXGRID_DEFAULT_TOPEDIT_WIDTH 300
-#define WXGRID_DEFAULT_TOPEDIT_HEIGHT 60
class WXDLLEXPORT wxGrid;
int m_numCols;
wxGridCellCoords m_currentCellCoords;
- bool m_currentCellHighlighted;
wxGridCellCoords m_selectedTopLeft;
wxGridCellCoords m_selectedBottomRight;
int m_editCtrlType; // for current cell
wxWindow* m_cellEditCtrl;
bool m_cellEditCtrlEnabled;
- wxWindow* m_topEditCtrl;
- bool m_topEditCtrlEnabled;
void Create();
void DrawCell( wxDC& dc, const wxGridCellCoords& );
void DrawCellBackground( wxDC& dc, const wxGridCellCoords& );
void DrawCellValue( wxDC& dc, const wxGridCellCoords& );
-
+
void DrawRowLabels( wxDC& dc );
void DrawRowLabel( wxDC& dc, int row );
void DrawColLabels( wxDC& dc );
bool IsEditable() { return m_editable; }
void EnableEditing( bool edit );
+#if 0 // at the moment the cell edit control is always active
void EnableCellEditControl( bool enable );
+#endif
bool IsCellEditControlEnabled()
{ return (m_cellEditCtrl && m_cellEditCtrlEnabled); }
- void EnableTopEditControl( bool enable );
-
- bool IsTopEditControlEnabled()
- { return (m_topEditCtrl && m_topEditCtrlEnabled); }
-
void ShowCellEditControl();
void HideCellEditControl();
void SetEditControlValue( const wxString& s = wxEmptyString );
wxColour GetCellBackgroundColour( int row, int col );
wxColour GetDefaultCellTextColour();
wxColour GetCellTextColour( int row, int col );
- wxColour GetCellHighlightColour();
wxFont GetDefaultCellFont();
wxFont GetCellFont( int row, int col );
void GetDefaultCellAlignment( int *horiz, int *vert );
void SetCellBackgroundColour( int row, int col, const wxColour& );
void SetDefaultCellTextColour( const wxColour& );
void SetCellTextColour( int row, int col, const wxColour& );
- void SetCellHighlightColour( const wxColour& );
void SetDefaultCellFont( const wxFont& );
void SetCellFont( int row, int col, const wxFont& );
void SetDefaultCellAlignment( int horiz, int vert );
bool GetEditable() { return IsEditable(); }
void SetEditable( bool edit = TRUE ) { EnableEditing( edit ); }
bool GetEditInPlace() { return IsCellEditControlEnabled(); }
- void SetEditInPlace(bool edit = TRUE) { EnableCellEditControl( edit ); }
+ void SetEditInPlace(bool edit = TRUE) { }
void SetCellAlignment( int align, int row, int col)
{ SetCellAlignment(row, col, align, wxCENTER); }
m_colLabelWin = (wxGridColLabelWindow *) NULL;
m_cornerLabelWin = (wxGridCornerLabelWindow *) NULL;
m_cellEditCtrl = (wxWindow *) NULL;
-
- // TODO: do we need this or should the top edit control be an add-on ?
- //
- m_topEditCtrl = (wxWindow *) NULL;
}
m_colLabelVertAlign = wxTOP;
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_rowBottoms.Alloc( m_numRows );
int rowBottom = 0;
m_colResizeCursor = wxCursor( wxCURSOR_SIZEWE );
m_currentCellCoords = wxGridNoCellCoords;
- m_currentCellHighlighted = FALSE;
m_selectedTopLeft = wxGridNoCellCoords;
m_selectedBottomRight = wxGridNoCellCoords;
m_cellEditCtrl->Show( FALSE );
m_cellEditCtrlEnabled = TRUE;
m_editCtrlType = wxGRID_TEXTCTRL;
-
- // TODO: do we need this or should the top edit control be an add-on ?
- //
- m_topEditCtrlEnabled = FALSE;
}
{
m_table->Clear();
SetEditControlValue();
- if ( !GetBatchCount() ) Refresh();
+ if ( !GetBatchCount() ) m_gridWin->Refresh();
}
}
if ( m_currentCellCoords != wxGridNoCellCoords )
{
- // HideCurrentCellHighlight( dc );
HideCellEditControl();
SaveEditControlValue();
}
SetEditControlValue();
ShowCellEditControl();
- // ShowCurrentCellHighlight( dc );
if ( IsSelection() )
{
if ( edit != m_editable )
{
m_editable = edit;
- if ( !m_editable ) HideCellEditControl();
- m_cellEditCtrlEnabled = m_editable;
- if ( m_editable ) ShowCellEditControl();
+
+ // TODO: extend this for other edit control types
+ //
+ 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 )
{
if ( m_cellEditCtrl &&
{
SetEditControlValue();
ShowCellEditControl();
- // ShowCurrentCellHighlight( dc );
}
else
{
- // HideCurrentCellHighlight( dc );
HideCellEditControl();
SaveEditControlValue();
}
}
}
-
-
-// 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 ?
-}
+#endif
void wxGrid::ShowCellEditControl()
int cw, ch;
m_gridWin->GetClientSize( &cw, &ch );
-
- rect.SetLeft( wxMax(0, left) );
- rect.SetTop( wxMax(0, top) );
+
+ // Make the edit control large enough to allow for internal margins
+ // 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->Show( TRUE );
else
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() )
{
switch ( m_editCtrlType )
{
ctrl = m_cellEditCtrl;
}
- else if ( IsTopEditControlEnabled() )
- {
- ctrl = m_topEditCtrl;
- }
else
{
return;
}
-wxColour wxGrid::GetCellHighlightColour()
-{
- // TODO: replace this temp test code
- //
- return wxColour( 0, 0, 0 );
-}
-
-
wxFont wxGrid::GetDefaultCellFont()
{
return m_defaultCellFont;
//
}
-void wxGrid::SetCellHighlightColour( const wxColour& )
-{
- // TODO: everything !!!
- //
-}
-
void wxGrid::SetDefaultCellFont( const wxFont& )
{
// TODO: everything !!!