// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
-// For compilers that support precompilatixon, includes "wx/wx.h".
+// For compilers that support precompilation, includes "wx/wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
private:
wxGrid *m_owner;
- void OnPaint( wxPaintEvent &event );
+ void OnPaint( wxPaintEvent& event );
void OnMouseEvent( wxMouseEvent& event );
void OnMouseWheel( wxMouseEvent& event );
void OnKeyDown( wxKeyEvent& event );
public:
wxGridWindow()
{
- m_owner = (wxGrid *)NULL;
- m_rowLabelWin = (wxGridRowLabelWindow *)NULL;
- m_colLabelWin = (wxGridColLabelWindow *)NULL;
+ m_owner = NULL;
+ m_rowLabelWin = NULL;
+ m_colLabelWin = NULL;
}
wxGridWindow( wxGrid *parent,
END_EVENT_TABLE()
-
// ----------------------------------------------------------------------------
// the internal data representation used by wxGridCellAttrProvider
// ----------------------------------------------------------------------------
wxGridDataTypeInfoArray m_typeinfo;
};
+
// ----------------------------------------------------------------------------
// conditional compilation
// ----------------------------------------------------------------------------
{
if (m_control)
{
- m_control->PopEventHandler(true /* delete it*/);
+ m_control->PopEventHandler( true /* delete it*/ );
m_control->Destroy();
m_control = NULL;
m_fontOld = m_control->GetFont();
m_control->SetFont(attr->GetFont());
#endif
+
// can't do anything more in the base class version, the other
// attributes may only be used by the derived classes
}
int key = 0;
bool keyOk = true;
+#ifdef __WXGTK20__
+ // If it's a F-Key or other special key then it shouldn't start the
+ // editor.
+ if (event.GetKeyCode() >= WXK_START)
+ return false;
+#endif
#if wxUSE_UNICODE
// if the unicode key code is not really a unicode character (it may
// be a function key or etc., the platforms appear to always give us a
void wxGridCellTextEditor::PaintBackground(const wxRect& WXUNUSED(rectCell),
wxGridCellAttr * WXUNUSED(attr))
{
- // as we fill the entire client area, don't do anything here to minimize
- // flicker
+ // as we fill the entire client area,
+ // don't do anything here to minimize flicker
}
void wxGridCellTextEditor::SetSize(const wxRect& rectOrig)
grid->GetTable()->SetValue(row, col, value);
m_startValue = wxEmptyString;
+
// No point in setting the text of the hidden control
//Text()->SetValue(m_startValue);
else
{
long tmp;
- if ( !params.ToLong(&tmp) )
+ if ( params.ToLong(&tmp) )
{
- wxLogDebug(_T("Invalid wxGridCellTextEditor parameter string '%s' ignored"), params.c_str());
+ m_maxChars = (size_t)tmp;
}
else
{
- m_maxChars = (size_t)tmp;
+ wxLogDebug( _T("Invalid wxGridCellTextEditor parameter string '%s' ignored"), params.c_str() );
}
}
}
#if wxUSE_VALIDATORS
Text()->SetValidator(wxTextValidator(wxFILTER_NUMERIC));
-#endif // wxUSE_VALIDATORS
+#endif
}
}
#if wxUSE_VALIDATORS
Text()->SetValidator(wxTextValidator(wxFILTER_NUMERIC));
-#endif // wxUSE_VALIDATORS
+#endif
}
void wxGridCellFloatEditor::BeginEdit(int row, int col, wxGrid* grid)
void wxGridCellBoolEditor::BeginEdit(int row, int col, wxGrid* grid)
{
wxASSERT_MSG(m_control,
- wxT("The wxGridCellEditor must be Created first!"));
+ wxT("The wxGridCellEditor must be created first!"));
if (grid->GetTable()->CanGetValueAs(row, col, wxGRID_VALUE_BOOL))
{
wxGrid* grid)
{
wxASSERT_MSG(m_control,
- wxT("The wxGridCellEditor must be Created first!"));
+ wxT("The wxGridCellEditor must be created first!"));
bool changed = false;
bool value = CBox()->GetValue();
void wxGridCellBoolEditor::Reset()
{
wxASSERT_MSG(m_control,
- wxT("The wxGridCellEditor must be Created first!"));
+ wxT("The wxGridCellEditor must be created first!"));
CBox()->SetValue(m_startValue);
}
// flicker
// TODO: It doesn't actually fill the client area since the height of a
- // combo always defaults to the standard... Until someone has time to
- // figure out the right rectangle to paint, just do it the normal way...
+ // combo always defaults to the standard. Until someone has time to
+ // figure out the right rectangle to paint, just do it the normal way.
wxGridCellEditor::PaintBackground(rectCell, attr);
}
void wxGridCellChoiceEditor::BeginEdit(int row, int col, wxGrid* grid)
{
wxASSERT_MSG(m_control,
- wxT("The wxGridCellEditor must be Created first!"));
+ wxT("The wxGridCellEditor must be created first!"));
wxGridCellEditorEvtHandler* evtHandler = NULL;
if (m_control)
event.Skip();
break;
}
+
case WXK_END:
{
if ( wholeCellVisible )
default:
event.Skip();
+ break;
}
}
// different coloured text when the grid is disabled
if ( grid.IsEnabled() )
{
- if ( isSelected )
- {
- dc.SetTextBackground( grid.GetSelectionBackground() );
- dc.SetTextForeground( grid.GetSelectionForeground() );
- }
- else
- {
- dc.SetTextBackground( attr.GetBackgroundColour() );
- dc.SetTextForeground( attr.GetTextColour() );
- }
+ if ( isSelected )
+ {
+ dc.SetTextBackground( grid.GetSelectionBackground() );
+ dc.SetTextForeground( grid.GetSelectionForeground() );
+ }
+ else
+ {
+ dc.SetTextBackground( attr.GetBackgroundColour() );
+ dc.SetTextForeground( attr.GetTextColour() );
+ }
}
else
{
- dc.SetTextBackground(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE));
- dc.SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_GRAYTEXT));
+ dc.SetTextBackground(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE));
+ dc.SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_GRAYTEXT));
}
dc.SetFont( attr.GetFont() );
}
if (is_empty)
+ {
rect.width += grid.GetColSize(i);
+ }
else
{
i--;
wxRect clip = rect;
clip.x += rectCell.width;
// draw each overflow cell individually
- int col_end = col+cell_cols + overflowCols;
+ 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++)
+ for (int i = col + cell_cols; i <= col_end; i++)
{
clip.width = grid.GetColSize(i) - 1;
dc.DestroyClippingRegion();
// draw a border around checkmark
int vAlign, hAlign;
- attr.GetAlignment(& hAlign, &vAlign);
+ attr.GetAlignment(&hAlign, &vAlign);
wxRect rectBorder;
if (hAlign == wxALIGN_CENTRE)
bool value;
if ( grid.GetTable()->CanGetValueAs(row, col, wxGRID_VALUE_BOOL) )
+ {
value = grid.GetTable()->GetValueAsBool(row, col);
+ }
else
{
wxString cellval( grid.GetTable()->GetValue(row, col) );
*vAlign = m_vAlign;
}
else if (m_defGridAttr && m_defGridAttr != this)
+ {
m_defGridAttr->GetAlignment(hAlign, vAlign);
+ }
else
{
wxFAIL_MSG(wxT("Missing default cell attribute"));
// used, otherwise the default editor or renderer is fetched from the grid and
// used. It should be the default for the data type of the cell. If it is
// NULL (because the table has a type that the grid does not have in its
-// registry,) then the grid's default editor or renderer is used.
+// registry), then the grid's default editor or renderer is used.
wxGridCellRenderer* wxGridCellAttr::GetRenderer(wxGrid* grid, int row, int col) const
{
- wxGridCellRenderer *renderer;
+ wxGridCellRenderer *renderer = NULL;
if ( m_renderer && this != m_defGridAttr )
{
// GetDefaultRendererForCell() will do IncRef() for us
renderer = grid->GetDefaultRendererForCell(row, col);
}
- else
- {
- renderer = NULL;
- }
- if ( !renderer )
+ if ( renderer == NULL )
{
- if (m_defGridAttr && this != m_defGridAttr )
+ if ( (m_defGridAttr != NULL) && (m_defGridAttr != this) )
{
// if we still don't have one then use the grid default
// (no need for IncRef() here neither)
// same as above, except for s/renderer/editor/g
wxGridCellEditor* wxGridCellAttr::GetEditor(wxGrid* grid, int row, int col) const
{
- wxGridCellEditor *editor;
+ wxGridCellEditor *editor = NULL;
if ( m_editor && this != m_defGridAttr )
{
// GetDefaultEditorForCell() will do IncRef() for us
editor = grid->GetDefaultEditorForCell(row, col);
}
- else
- {
- editor = NULL;
- }
- if ( !editor )
+ if ( editor == NULL )
{
- if ( m_defGridAttr && this != m_defGridAttr )
+ if ( (m_defGridAttr != NULL) && (m_defGridAttr != this) )
{
// if we still don't have one then use the grid default
// (no need for IncRef() here neither)
// reverse the string...
wxString s2;
- for ( i = 0; i < n; i++ )
+ for ( i = 0; i < n; i++ )
{
s2 += s[n - i - 1];
}
{
numCols = m_data[0].GetCount();
- for ( row = 0; row < numRows; row++ )
+ for ( row = 0; row < numRows; row++ )
{
- for ( col = 0; col < numCols; col++ )
+ for ( col = 0; col < numCols; col++ )
{
m_data[row][col] = wxEmptyString;
}
return AppendCols( numCols );
}
- for ( row = 0; row < curNumRows; row++ )
+ for ( row = 0; row < curNumRows; row++ )
{
- for ( col = pos; col < pos + numCols; col++ )
+ for ( col = pos; col < pos + numCols; col++ )
{
m_data[row].Insert( wxEmptyString, col );
}
}
#endif
- for ( row = 0; row < curNumRows; row++ )
+ for ( row = 0; row < curNumRows; row++ )
{
m_data[row].Add( wxEmptyString, numCols );
}
numCols = curNumCols - pos;
}
- for ( row = 0; row < curNumRows; row++ )
+ for ( row = 0; row < curNumRows; row++ )
{
if ( numCols >= curNumCols )
{
int n = m_rowLabels.GetCount();
int i;
- for ( i = n; i <= row; i++ )
+ for ( i = n; i <= row; i++ )
{
m_rowLabels.Add( wxGridTableBase::GetRowLabelValue(i) );
}
int n = m_colLabels.GetCount();
int i;
- for ( i = n; i <= col; i++ )
+ for ( i = n; i <= col; i++ )
{
m_colLabels.Add( wxGridTableBase::GetColLabelValue(i) );
}
BEGIN_EVENT_TABLE( wxGridRowLabelWindow, wxWindow )
EVT_PAINT( wxGridRowLabelWindow::OnPaint )
- EVT_MOUSEWHEEL( wxGridRowLabelWindow::OnMouseWheel)
+ EVT_MOUSEWHEEL( wxGridRowLabelWindow::OnMouseWheel )
EVT_MOUSE_EVENTS( wxGridRowLabelWindow::OnMouseEvent )
EVT_KEY_DOWN( wxGridRowLabelWindow::OnKeyDown )
EVT_KEY_UP( wxGridRowLabelWindow::OnKeyUp )
- EVT_CHAR ( wxGridRowLabelWindow::OnChar )
+ EVT_CHAR( wxGridRowLabelWindow::OnChar )
END_EVENT_TABLE()
wxGridRowLabelWindow::wxGridRowLabelWindow( wxGrid *parent,
wxWindowID id,
const wxPoint &pos, const wxSize &size )
- : wxWindow( parent, id, pos, size, wxWANTS_CHARS|wxBORDER_NONE|wxFULL_REPAINT_ON_RESIZE )
+ : wxWindow( parent, id, pos, size, wxWANTS_CHARS | wxBORDER_NONE | wxFULL_REPAINT_ON_RESIZE )
{
m_owner = parent;
}
dc.SetDeviceOrigin( 0, -y );
wxArrayInt rows = m_owner->CalcRowLabelsExposed( GetUpdateRegion() );
- m_owner->DrawRowLabels( dc , rows );
+ m_owner->DrawRowLabels( dc, rows );
}
void wxGridRowLabelWindow::OnMouseEvent( wxMouseEvent& event )
void wxGridRowLabelWindow::OnMouseWheel( wxMouseEvent& event )
{
- m_owner->GetEventHandler()->ProcessEvent(event);
+ m_owner->GetEventHandler()->ProcessEvent( event );
}
// This seems to be required for wxMotif otherwise the mouse
BEGIN_EVENT_TABLE( wxGridColLabelWindow, wxWindow )
EVT_PAINT( wxGridColLabelWindow::OnPaint )
- EVT_MOUSEWHEEL( wxGridColLabelWindow::OnMouseWheel)
+ EVT_MOUSEWHEEL( wxGridColLabelWindow::OnMouseWheel )
EVT_MOUSE_EVENTS( wxGridColLabelWindow::OnMouseEvent )
EVT_KEY_DOWN( wxGridColLabelWindow::OnKeyDown )
EVT_KEY_UP( wxGridColLabelWindow::OnKeyUp )
- EVT_CHAR ( wxGridColLabelWindow::OnChar )
+ EVT_CHAR( wxGridColLabelWindow::OnChar )
END_EVENT_TABLE()
wxGridColLabelWindow::wxGridColLabelWindow( wxGrid *parent,
wxWindowID id,
const wxPoint &pos, const wxSize &size )
- : wxWindow( parent, id, pos, size, wxWANTS_CHARS|wxBORDER_NONE|wxFULL_REPAINT_ON_RESIZE )
+ : wxWindow( parent, id, pos, size, wxWANTS_CHARS | wxBORDER_NONE | wxFULL_REPAINT_ON_RESIZE )
{
m_owner = parent;
}
dc.SetDeviceOrigin( -x, 0 );
wxArrayInt cols = m_owner->CalcColLabelsExposed( GetUpdateRegion() );
- m_owner->DrawColLabels( dc , cols );
+ m_owner->DrawColLabels( dc, cols );
}
void wxGridColLabelWindow::OnMouseEvent( wxMouseEvent& event )
void wxGridColLabelWindow::OnMouseWheel( wxMouseEvent& event )
{
- m_owner->GetEventHandler()->ProcessEvent(event);
+ m_owner->GetEventHandler()->ProcessEvent( event );
}
// This seems to be required for wxMotif otherwise the mouse
IMPLEMENT_DYNAMIC_CLASS( wxGridCornerLabelWindow, wxWindow )
BEGIN_EVENT_TABLE( wxGridCornerLabelWindow, wxWindow )
- EVT_MOUSEWHEEL( wxGridCornerLabelWindow::OnMouseWheel)
+ EVT_MOUSEWHEEL( wxGridCornerLabelWindow::OnMouseWheel )
EVT_MOUSE_EVENTS( wxGridCornerLabelWindow::OnMouseEvent )
- EVT_PAINT( wxGridCornerLabelWindow::OnPaint)
+ EVT_PAINT( wxGridCornerLabelWindow::OnPaint )
EVT_KEY_DOWN( wxGridCornerLabelWindow::OnKeyDown )
EVT_KEY_UP( wxGridCornerLabelWindow::OnKeyUp )
- EVT_CHAR ( wxGridCornerLabelWindow::OnChar )
+ EVT_CHAR( wxGridCornerLabelWindow::OnChar )
END_EVENT_TABLE()
wxGridCornerLabelWindow::wxGridCornerLabelWindow( wxGrid *parent,
wxWindowID id,
const wxPoint &pos, const wxSize &size )
- : wxWindow( parent, id, pos, size, wxWANTS_CHARS|wxBORDER_NONE|wxFULL_REPAINT_ON_RESIZE )
+ : wxWindow( parent, id, pos, size, wxWANTS_CHARS | wxBORDER_NONE | wxFULL_REPAINT_ON_RESIZE )
{
m_owner = parent;
}
BEGIN_EVENT_TABLE( wxGridWindow, wxWindow )
EVT_PAINT( wxGridWindow::OnPaint )
- EVT_MOUSEWHEEL( wxGridWindow::OnMouseWheel)
+ EVT_MOUSEWHEEL( wxGridWindow::OnMouseWheel )
EVT_MOUSE_EVENTS( wxGridWindow::OnMouseEvent )
EVT_KEY_DOWN( wxGridWindow::OnKeyDown )
EVT_KEY_UP( wxGridWindow::OnKeyUp )
- EVT_CHAR ( wxGridWindow::OnChar )
+ EVT_CHAR( wxGridWindow::OnChar )
EVT_SET_FOCUS( wxGridWindow::OnFocus )
EVT_KILL_FOCUS( wxGridWindow::OnFocus )
EVT_ERASE_BACKGROUND( wxGridWindow::OnEraseBackground )
void wxGridWindow::OnMouseWheel( wxMouseEvent& event )
{
- m_owner->GetEventHandler()->ProcessEvent(event);
+ m_owner->GetEventHandler()->ProcessEvent( event );
}
// This seems to be required for wxMotif/wxGTK otherwise the mouse
long style, const wxString& name)
{
if (!wxScrolledWindow::Create(parent, id, pos, size,
- style | wxWANTS_CHARS , name))
+ style | wxWANTS_CHARS, name))
return false;
m_colMinWidths = wxLongToLongHashMap(GRID_HASH_SIZE);
void wxGrid::Create()
{
- m_created = false; // set to true by CreateGrid
+ // set to true by CreateGrid
+ m_created = false;
+
+ // create the type registry
+ m_typeRegistry = new wxGridTypeRegistry;
+ m_selection = NULL;
- m_table = (wxGridTableBase *) NULL;
- m_ownTable = false;
+ m_table = (wxGridTableBase *) NULL;
+ m_ownTable = false;
m_cellEditCtrlEnabled = false;
m_rowLabelWidth = WXGRID_DEFAULT_ROW_LABEL_WIDTH;
m_colLabelHeight = WXGRID_DEFAULT_COL_LABEL_HEIGHT;
- // create the type registry
- m_typeRegistry = new wxGridTypeRegistry;
- m_selection = NULL;
-
// subwindow components that make up the wxGrid
- m_cornerLabelWin = new wxGridCornerLabelWindow( this,
- wxID_ANY,
- wxDefaultPosition,
- wxDefaultSize );
-
m_rowLabelWin = new wxGridRowLabelWindow( this,
wxID_ANY,
wxDefaultPosition,
wxDefaultPosition,
wxDefaultSize );
+ m_cornerLabelWin = new wxGridCornerLabelWindow( this,
+ wxID_ANY,
+ wxDefaultPosition,
+ wxDefaultSize );
+
m_gridWin = new wxGridWindow( this,
m_rowLabelWin,
m_colLabelWin,
if (m_ownTable)
{
- wxGridTableBase *t=m_table;
- m_table=0;
+ wxGridTableBase *t = m_table;
+ m_table = NULL;
delete t;
}
delete m_selection;
- m_table = 0;
- m_selection = 0;
+ m_table = NULL;
+ m_selection = NULL;
m_numRows = 0;
m_numCols = 0;
}
}
else
{
- m_labelBackgroundColour = wxColour( wxT("WHITE") );
+ m_labelBackgroundColour = *wxWHITE;
}
- m_labelTextColour = wxColour( wxT("BLACK") );
+ m_labelTextColour = *wxBLACK;
// init attr cache
m_attrCache.row = -1;
m_rowHeights.Add( m_defaultRowHeight, m_numRows );
- for ( int i = 0; i < m_numRows; i++ )
+ for ( int i = 0; i < m_numRows; i++ )
{
rowBottom += m_defaultRowHeight;
m_rowBottoms.Add( rowBottom );
m_colWidths.Add( m_defaultColWidth, m_numCols );
- for ( int i = 0; i < m_numCols; i++ )
+ for ( int i = 0; i < m_numCols; i++ )
{
colRight += m_defaultColWidth;
m_colRights.Add( colRight );
// take into account editor if shown
if ( IsCellEditControlShown() )
{
- int w2, h2;
- int r = m_currentCellCoords.GetRow();
- int c = m_currentCellCoords.GetCol();
- int x = GetColLeft(c);
- int y = GetRowTop(r);
-
- // how big is the editor
- wxGridCellAttr* attr = GetCellAttr(r, c);
- wxGridCellEditor* editor = attr->GetEditor(this, r, c);
- editor->GetControl()->GetSize(&w2, &h2);
- w2 += x;
- h2 += y;
- if ( w2 > w )
- w = w2;
- if ( h2 > h )
- h = h2;
- editor->DecRef();
- attr->DecRef();
+ int w2, h2;
+ int r = m_currentCellCoords.GetRow();
+ int c = m_currentCellCoords.GetCol();
+ int x = GetColLeft(c);
+ int y = GetRowTop(r);
+
+ // how big is the editor
+ wxGridCellAttr* attr = GetCellAttr(r, c);
+ wxGridCellEditor* editor = attr->GetEditor(this, r, c);
+ editor->GetControl()->GetSize(&w2, &h2);
+ w2 += x;
+ h2 += y;
+ if ( w2 > w )
+ w = w2;
+ if ( h2 > h )
+ h = h2;
+ editor->DecRef();
+ attr->DecRef();
}
// preserve (more or less) the previous position
CalcWindowSizes();
}
-
void wxGrid::CalcWindowSizes()
{
// escape if the window is has not been fully created yet
if ( m_cornerLabelWin && m_cornerLabelWin->IsShown() )
m_cornerLabelWin->SetSize( 0, 0, m_rowLabelWidth, m_colLabelHeight );
- if ( m_colLabelWin && m_colLabelWin->IsShown() )
- m_colLabelWin->SetSize( m_rowLabelWidth, 0, cw - m_rowLabelWidth, m_colLabelHeight);
+ if ( m_colLabelWin && m_colLabelWin->IsShown() )
+ m_colLabelWin->SetSize( m_rowLabelWidth, 0, cw - m_rowLabelWidth, m_colLabelHeight );
if ( m_rowLabelWin && m_rowLabelWin->IsShown() )
- m_rowLabelWin->SetSize( 0, m_colLabelHeight, m_rowLabelWidth, ch - m_colLabelHeight);
+ m_rowLabelWin->SetSize( 0, m_colLabelHeight, m_rowLabelWidth, ch - m_colLabelHeight );
if ( m_gridWin && m_gridWin->IsShown() )
- m_gridWin->SetSize( m_rowLabelWidth, m_colLabelHeight, cw - m_rowLabelWidth, ch - m_colLabelHeight);
+ m_gridWin->SetSize( m_rowLabelWidth, m_colLabelHeight, cw - m_rowLabelWidth, ch - m_colLabelHeight );
}
-
-// this is called when the grid table sends a message to say that it
-// has been redimensioned
+// this is called when the grid table sends a message
+// to indicate that it has been redimensioned
//
bool wxGrid::Redimension( wxGridTableMessage& msg )
{
if ( pos > 0 )
bottom = m_rowBottoms[pos - 1];
- for ( i = pos; i < m_numRows; i++ )
+ for ( i = pos; i < m_numRows; i++ )
{
bottom += m_rowHeights[i];
m_rowBottoms[i] = bottom;
if ( oldNumRows > 0 )
bottom = m_rowBottoms[oldNumRows - 1];
- for ( i = oldNumRows; i < m_numRows; i++ )
+ for ( i = oldNumRows; i < m_numRows; i++ )
{
bottom += m_rowHeights[i];
m_rowBottoms[i] = bottom;
m_rowBottoms.RemoveAt( pos, numRows );
int h = 0;
- for ( i = 0; i < m_numRows; i++ )
+ for ( i = 0; i < m_numRows; i++ )
{
h += m_rowHeights[i];
m_rowBottoms[i] = h;
}
}
+
if ( !m_numRows )
{
m_currentCellCoords = wxGridNoCellCoords;
if (attrProvider)
{
attrProvider->UpdateAttrRows( pos, -((int)numRows) );
+
// ifdef'd out following patch from Paul Gammans
#if 0
// No need to touch column attributes, unless we
if ( pos > 0 )
right = m_colRights[pos - 1];
- for ( i = pos; i < m_numCols; i++ )
+ for ( i = pos; i < m_numCols; i++ )
{
right += m_colWidths[i];
m_colRights[i] = right;
CalcDimensions();
m_colLabelWin->Refresh();
}
-
}
result = true;
break;
if ( oldNumCols > 0 )
right = m_colRights[oldNumCols - 1];
- for ( i = oldNumCols; i < m_numCols; i++ )
+ for ( i = oldNumCols; i < m_numCols; i++ )
{
right += m_colWidths[i];
m_colRights[i] = right;
m_colRights.RemoveAt( pos, numCols );
int w = 0;
- for ( i = 0; i < m_numCols; i++ )
+ for ( i = 0; i < m_numCols; i++ )
{
w += m_colWidths[i];
m_colRights[i] = w;
#if defined(__WXMOTIF__)
int cw, ch;
m_gridWin->GetClientSize( &cw, &ch );
- if ( r.GetTop() > ch ) r.SetTop( 0 );
+ if ( r.GetTop() > ch )
+ r.SetTop( 0 );
r.SetBottom( wxMin( r.GetBottom(), ch ) );
#endif
// find the row labels within these bounds
//
int row;
- for ( row = internalYToRow(top); row < m_numRows; row++ )
+ for ( row = internalYToRow(top); row < m_numRows; row++ )
{
if ( GetRowBottom(row) < top )
continue;
#if defined(__WXMOTIF__)
int cw, ch;
m_gridWin->GetClientSize( &cw, &ch );
- if ( r.GetLeft() > cw ) r.SetLeft( 0 );
+ if ( r.GetLeft() > cw )
+ r.SetLeft( 0 );
r.SetRight( wxMin( r.GetRight(), cw ) );
#endif
// find the cells within these bounds
//
int col;
- for ( col = internalXToCol(left); col < m_numCols; col++ )
+ for ( col = internalXToCol(left); col < m_numCols; col++ )
{
if ( GetColRight(col) < left )
continue;
// find the cells within these bounds
//
int row, col;
- for ( row = internalYToRow(top); row < m_numRows; row++ )
+ for ( row = internalYToRow(top); row < m_numRows; row++ )
{
if ( GetRowBottom(row) <= top )
continue;
if ( GetRowTop(row) > bottom )
break;
- for ( col = internalXToCol(left); col < m_numCols; col++ )
+ for ( col = internalXToCol(left); col < m_numCols; col++ )
{
if ( GetColRight(col) <= left )
continue;
{
if ( m_selectingKeyboard == wxGridNoCellCoords)
m_selectingKeyboard = coords;
- HighlightBlock ( m_selectingKeyboard, coords );
+ HighlightBlock( m_selectingKeyboard, coords );
}
else if ( CanDragCell() )
{
dc.SetLogicalFunction(wxINVERT);
if ( m_dragLastPos >= 0 )
{
- dc.DrawLine( m_dragLastPos, top, m_dragLastPos, top+ch );
+ dc.DrawLine( m_dragLastPos, top, m_dragLastPos, top + ch );
}
- dc.DrawLine( x, top, x, top+ch );
+ dc.DrawLine( x, top, x, top + ch );
m_dragLastPos = x;
}
}
}
-
// ------------ Left double click
//
else if ( event.LeftDClick() && coords != wxGridNoCellCoords )
}
}
-
// ------------ Left button released
//
else if ( event.LeftUp() )
wxClientDC dc( m_gridWin );
PrepareDC( dc );
dc.SetLogicalFunction( wxINVERT );
- dc.DrawLine( left, m_dragLastPos, left+cw, m_dragLastPos );
+ dc.DrawLine( left, m_dragLastPos, left + cw, m_dragLastPos );
HideCellEditControl();
SaveEditControlValue();
{
int i, cell_rows, cell_cols, subtract_rows = 0;
int leftCol = XToCol(left);
- int rightCol = internalXToCol(left+cw);
+ int rightCol = internalXToCol(left + cw);
if (leftCol >= 0)
{
for (i=leftCol; i<rightCol; i++)
wxClientDC dc( m_gridWin );
PrepareDC( dc );
dc.SetLogicalFunction( wxINVERT );
- dc.DrawLine( m_dragLastPos, top, m_dragLastPos, top+ch );
+ dc.DrawLine( m_dragLastPos, top, m_dragLastPos, top + ch );
HideCellEditControl();
SaveEditControlValue();
{
int i, cell_rows, cell_cols, subtract_cols = 0;
int topRow = YToRow(top);
- int bottomRow = internalYToRow(top+cw);
+ int bottomRow = internalYToRow(top + cw);
if (topRow >= 0)
{
for (i=topRow; i<bottomRow; i++)
if (cell_cols < subtract_cols)
subtract_cols = cell_cols;
}
+
rect.x = GetColLeft(m_dragRowOrCol + subtract_cols);
CalcScrolledPosition(rect.x, 0, &rect.x, &dummy);
rect.width = cw - rect.x;
}
// The behaviour of this function depends on the grid table class
-// Clear() function. For the default wxGridStringTable class the
+// Clear() function. For the default wxGridStringTable class the
// behavious is to replace all cell contents with wxEmptyString but
// not to change the number of rows or cols.
//
DisableCellEditControl();
m_table->Clear();
- if ( !GetBatchCount() ) m_gridWin->Refresh();
+ if (!GetBatchCount())
+ m_gridWin->Refresh();
}
}
// the table will have sent the results of the insert row
// operation to this view object as a grid table message
}
+
return false;
}
{
bool done = m_table && m_table->AppendRows( numRows );
return done;
+
// the table will have sent the results of the append row
// operation to this view object as a grid table message
}
+
return false;
}
// the table will have sent the results of the delete row
// operation to this view object as a grid table message
}
+
return false;
}
int wxGrid::SendEvent( const wxEventType type,
int row, int col )
{
- bool claimed;
- bool vetoed;
+ bool claimed, vetoed;
if ( type == wxEVT_GRID_ROW_SIZE || type == wxEVT_GRID_COL_SIZE )
{
int rowOrCol = (row == -1 ? col : row);
- wxGridSizeEvent gridEvt( GetId(),
- type,
- this,
- rowOrCol );
+ wxGridSizeEvent gridEvt( GetId(), type, this, rowOrCol );
claimed = GetEventHandler()->ProcessEvent(gridEvt);
vetoed = !gridEvt.IsAllowed();
}
else
{
- wxGridEvent gridEvt( GetId(),
- type,
- this,
- row, col );
+ wxGridEvent gridEvt( GetId(), type, this, row, col );
claimed = GetEventHandler()->ProcessEvent(gridEvt);
vetoed = !gridEvt.IsAllowed();
void wxGrid::OnPaint( wxPaintEvent& WXUNUSED(event) )
{
- wxPaintDC dc(this); // needed to prevent zillions of paint events on MSW
+ // needed to prevent zillions of paint events on MSW
+ wxPaintDC dc(this);
}
void wxGrid::Refresh(bool eraseb, const wxRect* rect)
width_label = rectWidth;
height_label = m_colLabelHeight - rect_y;
- if (height_label > rectHeight) height_label = rectHeight;
+ if (height_label > rectHeight)
+ height_label = rectHeight;
if (rect_x > m_rowLabelWidth)
{
m_inOnKeyDown = true;
// propagate the event up and see if it gets processed
- //
wxWindow *parent = GetParent();
wxKeyEvent keyEvt( event );
keyEvt.SetEventObject( parent );
if ( !parent->GetEventHandler()->ProcessEvent( keyEvt ) )
{
// try local handlers
- //
switch ( event.GetKeyCode() )
{
case WXK_UP:
case WXK_END:
if ( event.ControlDown() )
{
- MakeCellVisible( m_numRows-1, m_numCols - 1 );
- SetCurrentCell( m_numRows-1, m_numCols - 1 );
+ MakeCellVisible( m_numRows - 1, m_numCols - 1 );
+ SetCurrentCell( m_numRows - 1, m_numCols - 1 );
}
else
{
{
if ( m_selection )
{
- m_selection->ToggleCellSelection( m_currentCellCoords.GetRow(),
- m_currentCellCoords.GetCol(),
- event.ControlDown(),
- event.ShiftDown(),
- event.AltDown(),
- event.MetaDown() );
+ m_selection->ToggleCellSelection(
+ m_currentCellCoords.GetRow(),
+ m_currentCellCoords.GetCol(),
+ event.ControlDown(),
+ event.ShiftDown(),
+ event.AltDown(),
+ event.MetaDown() );
}
break;
}
{
if ( m_selection )
{
- m_selection->SelectBlock( m_selectingTopLeft.GetRow(),
- m_selectingTopLeft.GetCol(),
- m_selectingBottomRight.GetRow(),
- m_selectingBottomRight.GetCol(),
- event.ControlDown(),
- true,
- event.AltDown(),
- event.MetaDown() );
+ m_selection->SelectBlock(
+ m_selectingTopLeft.GetRow(),
+ m_selectingTopLeft.GetCol(),
+ m_selectingBottomRight.GetRow(),
+ m_selectingBottomRight.GetCol(),
+ event.ControlDown(),
+ true,
+ event.AltDown(),
+ event.MetaDown() );
}
}
int i;
// Store intermediate values
- wxCoord oldLeft = m_selectingTopLeft.GetCol();
- wxCoord oldTop = m_selectingTopLeft.GetRow();
- wxCoord oldRight = m_selectingBottomRight.GetCol();
+ wxCoord oldLeft = m_selectingTopLeft.GetCol();
+ wxCoord oldTop = m_selectingTopLeft.GetRow();
+ wxCoord oldRight = m_selectingBottomRight.GetCol();
wxCoord oldBottom = m_selectingBottomRight.GetRow();
// Determine the outer/inner coordinates.
// Refresh the newly selected or deselected
// area to the left of the old or new selection.
need_refresh[0] = true;
- rect[0] = BlockToDeviceRect( wxGridCellCoords ( oldTop,
- oldLeft ),
- wxGridCellCoords ( oldBottom,
- leftCol - 1 ) );
+ rect[0] = BlockToDeviceRect(
+ wxGridCellCoords( oldTop, oldLeft ),
+ wxGridCellCoords( oldBottom, leftCol - 1 ) );
}
if ( oldTop < topRow )
// area to the right of the old or new selection.
need_refresh[2] = true;
rect[2] = BlockToDeviceRect(
- wxGridCellCoords ( oldTop, rightCol + 1 ),
- wxGridCellCoords ( oldBottom, oldRight ) );
+ wxGridCellCoords( oldTop, rightCol + 1 ),
+ wxGridCellCoords( oldBottom, oldRight ) );
}
if ( oldBottom > bottomRow )
// area below the old or new selection.
need_refresh[3] = true;
rect[3] = BlockToDeviceRect(
- wxGridCellCoords ( bottomRow + 1, leftCol ),
- wxGridCellCoords ( oldBottom, rightCol ) );
+ wxGridCellCoords( bottomRow + 1, leftCol ),
+ wxGridCellCoords( oldBottom, rightCol ) );
}
// various Refresh() calls
if ( m_table )
{
- for ( row = 0; row < m_numRows; row++ )
+ for ( row = 0; row < m_numRows; row++ )
{
- for ( col = 0; col < m_numCols; col++ )
+ for ( col = 0; col < m_numCols; col++ )
{
m_table->SetValue( row, col, GetCellValue(row, col) );
}
int row, col, cell_rows, cell_cols;
wxGridCellCoordsArray redrawCells;
- for ( i = numCells-1; i >= 0; i-- )
+ for ( i = numCells - 1; i >= 0; i-- )
{
row = cells[i].GetRow();
col = cells[i].GetCol();
// If this cell is part of a multicell block, find owner for repaint
if ( cell_rows <= 0 || cell_cols <= 0 )
{
- wxGridCellCoords cell(row+cell_rows, col+cell_cols);
+ wxGridCellCoords cell( row + cell_rows, col + cell_cols );
bool marked = false;
- for ( int j = 0; j < numCells; j++ )
+ for ( int j = 0; j < numCells; j++ )
{
if ( cell == cells[j] )
{
{
for ( int l = 0; l < cell_rows; l++ )
{
- // find a cell in this row to left alreay marked for repaint
+ // find a cell in this row to leave already marked for repaint
int left = col;
for (int k = 0; k < int(redrawCells.GetCount()); k++)
if ((redrawCells[k].GetCol() < left) &&
numCells = redrawCells.GetCount();
- for ( i = numCells - 1; i >= 0; i-- )
+ for ( i = numCells - 1; i >= 0; i-- )
{
DrawCell( dc, redrawCells[i] );
}
if ( right > rightCol )
{
- dc.DrawRectangle( rightCol, top, right - rightCol, ch);
+ dc.DrawRectangle( rightCol, top, right - rightCol, ch );
}
if ( bottom > bottomRow )
{
- dc.DrawRectangle( left, bottomRow, cw, bottom - bottomRow);
+ dc.DrawRectangle( left, bottomRow, cw, bottom - bottomRow );
}
}
}
// Note: However, only if it is really _shown_, i.e. not hidden!
if ( isCurrent && IsCellEditControlShown() )
{
- // OSAF NB: this "#if..." is temporary and fixes a problem where the
+ // NB: this "#if..." is temporary and fixes a problem where the
// edit control is erased by this code after being rendered.
// On wxMac (QD build only), the cell editor is a wxTextCntl and is rendered
// implicitly, causing this out-of order render.
}
else
{
- // but all the rest is drawn by the cell renderer and hence may be
- // customized
+ // but all the rest is drawn by the cell renderer and hence may be customized
wxGridCellRenderer *renderer = attr->GetRenderer(this, row, col);
renderer->Draw(*this, *attr, dc, rect, row, col, IsInSelection(coords));
renderer->DecRef();
if (penWidth > 0)
{
- // The center of th drawn line is where the position/width/height of
- // the rectangle is actually at, (on wxMSW atr least,) so we will
- // reduce the size of the rectangle to compensate for the thickness of
- // the line. If this is too strange on non wxMSW platforms then
+ // The center of the drawn line is where the position/width/height of
+ // the rectangle is actually at (on wxMSW at least), so the
+ // size of the rectangle is reduced to compensate for the thickness of
+ // the line. If this is too strange on non-wxMSW platforms then
// please #ifdef this appropriately.
rect.x += penWidth / 2;
rect.y += penWidth / 2;
dc.SetPen(*wxBLACK_PEN);
dc.DrawLine(x1, y2, x2, y2);
dc.DrawLine(x2, y1, x2, y2 + 1);
-#endif // 0
+#endif
}
void wxGrid::DrawCellBorder( wxDC& dc, const wxGridCellCoords& coords )
wxRect rect = CellToRect( row, col );
// right hand border
- //
dc.DrawLine( rect.x + rect.width, rect.y,
rect.x + rect.width, rect.y + rect.height + 1 );
// bottom border
- //
dc.DrawLine( rect.x, rect.y + rect.height,
rect.x + rect.width, rect.y + rect.height);
}
bottom = wxMin( bottom, GetRowBottom(m_numRows - 1) );
// no gridlines inside multicells, clip them out
- int leftCol = internalXToCol(left);
- int topRow = internalYToRow(top);
- int rightCol = internalXToCol(right);
+ int leftCol = internalXToCol(left);
+ int topRow = internalYToRow(top);
+ int rightCol = internalXToCol(right);
int bottomRow = internalYToRow(bottom);
#ifndef __WXMAC__
}
else if ((cell_rows < 0) || (cell_cols < 0))
{
- rect = CellToRect(j+cell_rows, i+cell_cols);
+ rect = CellToRect(j + cell_rows, i + cell_cols);
CalcScrolledPosition( rect.x, rect.y, &rect.x, &rect.y );
clippedcells.Subtract(rect);
}
}
}
#else
- wxRegion clippedcells( left , top, right - left, bottom - top);
+ wxRegion clippedcells( left, top, right - left, bottom - top );
int i, j, cell_rows, cell_cols;
wxRect rect;
}
}
#endif
+
dc.SetClippingRegion( clippedcells );
dc.SetPen( wxPen(GetGridLineColour(), 1, wxSOLID) );
dc.DrawLine( colRight, top, colRight, bottom );
}
}
+
dc.DestroyClippingRegion();
}
-void wxGrid::DrawRowLabels( wxDC& dc ,const wxArrayInt& rows)
+void wxGrid::DrawRowLabels( wxDC& dc, const wxArrayInt& rows)
{
if ( !m_numRows )
return;
int rowTop = GetRowTop(row),
rowBottom = GetRowBottom(row) - 1;
- dc.SetPen( wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_3DDKSHADOW),1, wxSOLID) );
- dc.DrawLine( m_rowLabelWidth-1, rowTop,
- m_rowLabelWidth-1, rowBottom );
-
+ dc.SetPen( wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_3DDKSHADOW), 1, wxSOLID) );
+ dc.DrawLine( m_rowLabelWidth - 1, rowTop, m_rowLabelWidth - 1, rowBottom );
dc.DrawLine( 0, rowTop, 0, rowBottom );
-
dc.DrawLine( 0, rowBottom, m_rowLabelWidth, rowBottom );
dc.SetPen( *wxWHITE_PEN );
dc.DrawLine( 1, rowTop, 1, rowBottom );
- dc.DrawLine( 1, rowTop, m_rowLabelWidth-1, rowTop );
+ dc.DrawLine( 1, rowTop, m_rowLabelWidth - 1, rowTop );
#endif
dc.SetBackgroundMode( wxTRANSPARENT );
size_t i;
size_t numLabels = cols.GetCount();
- for ( i = 0; i < numLabels; i++ )
+ for ( i = 0; i < numLabels; i++ )
{
DrawColLabel( dc, cols[i] );
}
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 );
StringToLines( value, lines );
// Forward to new API.
- DrawTextRectangle( dc,
+ DrawTextRectangle( dc,
lines,
rect,
horizAlign,
textOrientation );
}
-void wxGrid::DrawTextRectangle( wxDC& dc,
+// VZ: this should be replaced with wxDC::DrawLabel() to which we just have to
+// add textOrientation support
+void wxGrid::DrawTextRectangle(wxDC& dc,
const wxArrayString& lines,
const wxRect& rect,
int horizAlign,
int vertAlign,
- int textOrientation )
+ int textOrientation)
{
- long textWidth = 0, textHeight = 0;
- long lineWidth = 0, lineHeight = 0;
- int nLines;
+ if ( lines.empty() )
+ return;
- dc.SetClippingRegion( rect );
+ wxDCClipper clip(dc, rect);
- nLines = lines.GetCount();
- if ( nLines > 0 )
- {
- int l;
- float x = 0.0, y = 0.0;
+ long textWidth,
+ textHeight;
- if ( textOrientation == wxHORIZONTAL )
- GetTextBoxSize(dc, lines, &textWidth, &textHeight);
- else
- GetTextBoxSize( dc, lines, &textHeight, &textWidth );
+ if ( textOrientation == wxHORIZONTAL )
+ GetTextBoxSize( dc, lines, &textWidth, &textHeight );
+ else
+ GetTextBoxSize( dc, lines, &textHeight, &textWidth );
- switch ( vertAlign )
- {
+ int x = 0,
+ y = 0;
+ switch ( vertAlign )
+ {
case wxALIGN_BOTTOM:
if ( textOrientation == wxHORIZONTAL )
y = rect.y + (rect.height - textHeight - 1);
case wxALIGN_CENTRE:
if ( textOrientation == wxHORIZONTAL )
- y = rect.y + ((rect.height - textHeight)/2);
+ y = rect.y + ((rect.height - textHeight) / 2);
else
- x = rect.x + ((rect.width - textWidth)/2);
+ x = rect.x + ((rect.width - textWidth) / 2);
break;
case wxALIGN_TOP:
else
x = rect.x + 1;
break;
- }
+ }
+
+ // Align each line of a multi-line label
+ size_t nLines = lines.GetCount();
+ for ( size_t l = 0; l < nLines; l++ )
+ {
+ const wxString& line = lines[l];
- // Align each line of a multi-line label
- for ( l = 0; l < nLines; l++ )
+ if ( line.empty() )
{
- dc.GetTextExtent(lines[l], &lineWidth, &lineHeight);
+ *(textOrientation == wxHORIZONTAL ? &y : &x) += dc.GetCharHeight();
+ continue;
+ }
- switch ( horizAlign )
- {
+ long lineWidth,
+ lineHeight;
+ dc.GetTextExtent(line, &lineWidth, &lineHeight);
+
+ switch ( horizAlign )
+ {
case wxALIGN_RIGHT:
if ( textOrientation == wxHORIZONTAL )
x = rect.x + (rect.width - lineWidth - 1);
else
y = rect.y + rect.height - 1;
break;
- }
+ }
- if ( textOrientation == wxHORIZONTAL )
- {
- dc.DrawText( lines[l], (int)x, (int)y );
- y += lineHeight;
- }
- else
- {
- dc.DrawRotatedText( lines[l], (int)x, (int)y, 90.0 );
- x += lineHeight;
- }
+ if ( textOrientation == wxHORIZONTAL )
+ {
+ dc.DrawText( line, x, y );
+ y += lineHeight;
+ }
+ else
+ {
+ dc.DrawRotatedText( line, x, y, 90.0 );
+ x += lineHeight;
}
}
-
- dc.DestroyClippingRegion();
}
// Split multi-line text up into an array of strings.
{
lines.Add( value.Mid(startPos, pos) );
}
+
startPos += pos + 1;
}
long lineW = 0, lineH = 0;
size_t i;
- for ( i = 0; i < lines.GetCount(); i++ )
+ for ( i = 0; i < lines.GetCount(); i++ )
{
dc.GetTextExtent( lines[i], &lineW, &lineH );
w = wxMax( w, lineW );
return;
// this should be checked by the caller!
- wxASSERT_MSG( CanEnableCellControl(),
- _T("can't enable editing for this cell!") );
+ wxASSERT_MSG( CanEnableCellControl(), _T("can't enable editing for this cell!") );
// do it before ShowCellEditControl()
m_cellEditCtrlEnabled = enable;
else
{
//FIXME:add veto support
- SendEvent( wxEVT_GRID_EDITOR_HIDDEN);
+ SendEvent( wxEVT_GRID_EDITOR_HIDDEN );
HideCellEditControl();
SaveEditControlValue();
{
return m_editable && (m_currentCellCoords != wxGridNoCellCoords) &&
!IsCurrentCellReadOnly();
-
}
bool wxGrid::IsCellEditControlEnabled() const
}
// convert to scrolled coords
- //
CalcScrolledPosition( rect.x, rect.y, &rect.x, &rect.y );
int nXMove = 0;
if (rect.x < 0)
nXMove = rect.x;
- // done in PaintBackground()
+ // performed in PaintBackground()
#if 0
// erase the highlight and the cell contents because the editor
// might not cover the entire cell
dc.SetBrush(*wxLIGHT_GREY_BRUSH); //wxBrush(attr->GetBackgroundColour(), wxSOLID));
dc.SetPen(*wxTRANSPARENT_PEN);
dc.DrawRectangle(rect);
-#endif // 0
+#endif
// cell is shifted by one pixel
// However, don't allow x or y to become negative
editor->SetCellAttr( attr );
editor->SetSize( rect );
- editor->GetControl()->Move(
- editor->GetControl()->GetPosition().x + nXMove,
- editor->GetControl()->GetPosition().y );
+ if (nXMove != 0)
+ editor->GetControl()->Move(
+ editor->GetControl()->GetPosition().x + nXMove,
+ editor->GetControl()->GetPosition().y );
editor->Show( true, attr );
- int colXPos = 0;
- for (int i = 0; i < m_currentCellCoords.GetCol(); i++)
- {
- colXPos += GetColSize( i );
- }
-
- int xUnit = 1, yUnit = 1;
- GetScrollPixelsPerUnit( &xUnit, &yUnit );
- if (m_currentCellCoords.GetCol() != 0)
- Scroll( colXPos / xUnit - 1, GetScrollPos( wxVERTICAL ) );
- else
- Scroll( colXPos / xUnit, GetScrollPos( wxVERTICAL ) );
-
// recalc dimensions in case we need to
// expand the scrolled window to account for editor
CalcDimensions();
int row = YToRow(y);
int col = XToCol(x);
- if ( row == -1 || col == -1 )
+ if ( row == -1 || col == -1 )
{
coords = wxGridNoCellCoords;
}
if ( GetColWidth(i) > WXGRID_LABEL_EDGE_ZONE )
{
- // We know that we are in column i, test whether we are
+ // We know that we are in column i; test whether we are
// close enough to right or left border, respectively.
if ( abs(GetColRight(i) - x) < WXGRID_LABEL_EDGE_ZONE )
return i;
if ( wholeCellVisible )
{
// is the cell wholly visible ?
- //
return ( left >= 0 && right <= cw &&
top >= 0 && bottom <= ch );
}
{
int h = r.GetHeight();
ypos = r.GetTop();
- for ( i = row-1; i >= 0; i-- )
+ for ( i = row - 1; i >= 0; i-- )
{
int rowHeight = GetRowHeight(i);
if ( h + rowHeight > ch )
}
// we divide it later by GRID_SCROLL_LINE, make sure that we don't
- // have rounding errors (this is important, because if we do, we
- // might not scroll at all and some cells won't be redrawn)
+ // have rounding errors (this is important, because if we do,
+ // we might not scroll at all and some cells won't be redrawn)
//
- // Sometimes GRID_SCROLL_LINE/2 is not enough, so just add a full
- // scroll unit...
+ // Sometimes GRID_SCROLL_LINE / 2 is not enough,
+ // so just add a full scroll unit...
ypos += m_scrollLineY;
}
if ( newRow == row )
{
- //row > 0 , so newrow can never be less than 0 here.
+ // row > 0, so newRow can never be less than 0 here.
newRow = row - 1;
}
int newRow = internalYToRow( y + ch );
if ( newRow == row )
{
- // row < m_numRows , so newrow can't overflow here.
+ // row < m_numRows, so newRow can't overflow here.
newRow = row + 1;
}
else if ( m_colLabelHeight == 0 )
{
m_colLabelWin->Show( true );
- if ( m_rowLabelWidth > 0 ) m_cornerLabelWin->Show( true );
+ if ( m_rowLabelWidth > 0 )
+ m_cornerLabelWin->Show( true );
}
m_colLabelHeight = height;
void wxGrid::SetColLabelTextOrientation( int textOrientation )
{
if ( textOrientation == wxHORIZONTAL || textOrientation == wxVERTICAL )
- {
m_colLabelTextOrientation = textOrientation;
- }
if ( !GetBatchCount() )
- {
m_colLabelWin->Refresh();
- }
}
void wxGrid::SetRowLabelValue( int row, const wxString& s )
{
if ( !LookupAttr(row, col, &attr) )
{
- attr = m_table ? m_table->GetAttr(row, col , wxGridCellAttr::Any)
+ attr = m_table ? m_table->GetAttr(row, col, wxGridCellAttr::Any)
: (wxGridCellAttr *)NULL;
CacheAttr(row, col, attr);
}
}
-wxGridCellEditor* wxGrid::GetDefaultEditorForCell(int row, int col) const
+wxGridCellEditor * wxGrid::GetDefaultEditorForCell(int row, int col) const
{
wxString typeName = m_table->GetTypeName(row, col);
return GetDefaultEditorForType(typeName);
}
-wxGridCellRenderer* wxGrid::GetDefaultRendererForCell(int row, int col) const
+wxGridCellRenderer * wxGrid::GetDefaultRendererForCell(int row, int col) const
{
wxString typeName = m_table->GetTypeName(row, col);
return GetDefaultRendererForType(typeName);
}
-wxGridCellEditor* wxGrid::GetDefaultEditorForType(const wxString& typeName) const
+wxGridCellEditor * wxGrid::GetDefaultEditorForType(const wxString& typeName) const
{
int index = m_typeRegistry->FindOrCloneDataType(typeName);
if ( index == wxNOT_FOUND )
return m_typeRegistry->GetEditor(index);
}
-wxGridCellRenderer* wxGrid::GetDefaultRendererForType(const wxString& typeName) const
+wxGridCellRenderer * wxGrid::GetDefaultRendererForType(const wxString& typeName) const
{
int index = m_typeRegistry->FindOrCloneDataType(typeName);
if ( index == wxNOT_FOUND )
m_rowHeights[row] = h;
int i;
- for ( i = row; i < m_numRows; i++ )
+ for ( i = row; i < m_numRows; i++ )
{
m_rowBottoms[i] += diff;
}
InitColWidths();
}
- // if < 0 calc new width from label
+ // if < 0 then calculate new width from label
if ( width < 0 )
{
- long w, h;
- wxArrayString lines;
- wxClientDC dc(m_colLabelWin);
- dc.SetFont(GetLabelFont());
- StringToLines(GetColLabelValue(col), lines);
- GetTextBoxSize(dc, lines, &w, &h);
- width = w + 6;
+ long w, h;
+ wxArrayString lines;
+ wxClientDC dc(m_colLabelWin);
+ dc.SetFont(GetLabelFont());
+ StringToLines(GetColLabelValue(col), lines);
+ GetTextBoxSize(dc, lines, &w, &h);
+ width = w + 6;
}
int w = wxMax( 0, width );
m_colWidths[col] = w;
int i;
- for ( i = col; i < m_numCols; i++ )
+ for ( i = col; i < m_numCols; i++ )
{
m_colRights[i] += diff;
}
wxSize size = renderer->GetBestSize(*this, *attr, dc, row, col);
extent = column ? size.x : size.y;
if ( extent > extentMax )
- {
extentMax = extent;
- }
renderer->DecRef();
}
extent = column ? w : h;
if ( extent > extentMax )
- {
extentMax = extent;
- }
if ( !extentMax )
{
for ( int col = 0; col < m_numCols; col++ )
{
if ( !calcOnly )
- {
AutoSizeColumn(col, setAsMin);
- }
width += GetColWidth(col);
}
// scrollbar steps
wxSize sizeFit(
GetScrollX(size.x + m_extraWidth + 1) * m_scrollLineX,
- GetScrollY(size.y + m_extraHeight + 1) * m_scrollLineY);
+ GetScrollY(size.y + m_extraHeight + 1) * m_scrollLineY );
// distribute the extra space between the columns/rows to avoid having
// extra white space
long w, h;
// Hide the edit control, so it
- // won't interfer with drag-shrinking.
+ // won't interfere with drag-shrinking.
if ( IsCellEditControlShown() )
{
HideCellEditControl();
height = 80;
// Round up to a multiple the scroll rate
- // NOTE: this still doesn't get rid of the scrollbars;
+ // NOTE: this still doesn't get rid of the scrollbars;
// is there any magic incantation for that?
int xpu, ypu;
GetScrollPixelsPerUnit(&xpu, &ypu);