// array classes
// ----------------------------------------------------------------------------
-WX_DEFINE_EXPORTED_ARRAY(wxGridCellAttr *, wxArrayAttrs);
+WX_DEFINE_ARRAY_WITH_DECL_NO_PTR(wxGridCellAttr *, wxArrayAttrs,
+ class WXDLLIMPEXP_ADV);
struct wxGridCellWithAttr
{
// without rewriting the macros, which require a public copy constructor.
};
-WX_DECLARE_EXPORTED_OBJARRAY(wxGridCellWithAttr, wxGridCellWithAttrArray);
+WX_DECLARE_OBJARRAY_WITH_DECL(wxGridCellWithAttr, wxGridCellWithAttrArray,
+ class WXDLLIMPEXP_ADV);
#include "wx/arrimpl.cpp"
// private classes
// ----------------------------------------------------------------------------
-class WXDLLEXPORT wxGridRowLabelWindow : public wxWindow
+class WXDLLIMPEXP_ADV wxGridRowLabelWindow : public wxWindow
{
public:
wxGridRowLabelWindow() { m_owner = (wxGrid *)NULL; }
};
-class WXDLLEXPORT wxGridColLabelWindow : public wxWindow
+class WXDLLIMPEXP_ADV wxGridColLabelWindow : public wxWindow
{
public:
wxGridColLabelWindow() { m_owner = (wxGrid *)NULL; }
};
-class WXDLLEXPORT wxGridCornerLabelWindow : public wxWindow
+class WXDLLIMPEXP_ADV wxGridCornerLabelWindow : public wxWindow
{
public:
wxGridCornerLabelWindow() { m_owner = (wxGrid *)NULL; }
DECLARE_NO_COPY_CLASS(wxGridCornerLabelWindow)
};
-class WXDLLEXPORT wxGridWindow : public wxWindow
+class WXDLLIMPEXP_ADV wxGridWindow : public wxWindow
{
public:
wxGridWindow()
// ----------------------------------------------------------------------------
// this class stores attributes set for cells
-class WXDLLEXPORT wxGridCellAttrData
+class WXDLLIMPEXP_ADV wxGridCellAttrData
{
public:
void SetAttr(wxGridCellAttr *attr, int row, int col);
};
// this class stores attributes set for rows or columns
-class WXDLLEXPORT wxGridRowOrColAttrData
+class WXDLLIMPEXP_ADV wxGridRowOrColAttrData
{
public:
// empty ctor to suppress warnings
// NB: this is just a wrapper around 3 objects: one which stores cell
// attributes, and 2 others for row/col ones
-class WXDLLEXPORT wxGridCellAttrProviderData
+class WXDLLIMPEXP_ADV wxGridCellAttrProviderData
{
public:
wxGridCellAttrData m_cellAttrs;
};
-WX_DEFINE_EXPORTED_ARRAY(wxGridDataTypeInfo*, wxGridDataTypeInfoArray);
+WX_DEFINE_ARRAY_WITH_DECL_NO_PTR(wxGridDataTypeInfo*, wxGridDataTypeInfoArray,
+ class WXDLLIMPEXP_ADV);
-class WXDLLEXPORT wxGridTypeRegistry
+class WXDLLIMPEXP_ADV wxGridTypeRegistry
{
public:
wxGridTypeRegistry() {}
#endif
);
- // TODO: use m_maxChars
+ // set max length allowed in the textctrl, if the parameter was set
+ if (m_maxChars != 0)
+ {
+ ((wxTextCtrl*)m_control)->SetMaxLength(m_maxChars);
+ }
wxGridCellEditor::Create(parent, id, evtHandler);
}
default:
// accept 8 bit chars too if isprint() agrees
- if ( (keycode < 255) && (isprint(keycode)) )
+ if ( (keycode < 255) && (wxIsprint(keycode)) )
return TRUE;
}
}
return TRUE;
default:
- if ( (keycode < 128) && isdigit(keycode) )
+ if ( (keycode < 128) && wxIsdigit(keycode) )
return TRUE;
}
}
if ( !HasRange() )
{
int keycode = event.GetKeyCode();
- if ( isdigit(keycode) || keycode == '+' || keycode == '-'
+ if ( wxIsdigit(keycode) || keycode == '+' || keycode == '-'
|| keycode == WXK_NUMPAD0
|| keycode == WXK_NUMPAD1
|| keycode == WXK_NUMPAD2
void wxGridCellFloatEditor::StartingKey(wxKeyEvent& event)
{
int keycode = event.GetKeyCode();
- if ( isdigit(keycode) || keycode == '+' || keycode == '-' || keycode == '.'
+ if ( wxIsdigit(keycode) || keycode == '+' || keycode == '-' || keycode == '.'
|| keycode == WXK_NUMPAD0
|| keycode == WXK_NUMPAD1
|| keycode == WXK_NUMPAD2
default:
// additionally accept 'e' as in '1e+6'
if ( (keycode < 128) &&
- (isdigit(keycode) || tolower(keycode) == 'e') )
+ (wxIsdigit(keycode) || tolower(keycode) == 'e') )
return TRUE;
}
}
SetReadOnly(mergefrom->IsReadOnly());
if (!HasOverflowMode() && mergefrom->HasOverflowMode() )
- SetReadOnly(mergefrom->GetOverflow());
+ SetOverflow(mergefrom->GetOverflow());
SetDefAttr(mergefrom->m_defGridAttr);
}
bool clipToMinMax);
#define internalXToCol(x) CoordToRowOrCol(x, m_defaultColWidth, \
- WXGRID_MIN_COL_WIDTH, \
+ m_minAcceptableColWidth, \
m_colRights, m_numCols, TRUE)
#define internalYToRow(y) CoordToRowOrCol(y, m_defaultRowHeight, \
- WXGRID_MIN_ROW_HEIGHT, \
+ m_minAcceptableRowHeight, \
m_rowBottoms, m_numRows, TRUE)
/////////////////////////////////////////////////////////////////////
{
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 implementation that
- // would prevent this?
+ // stop all processing
+ m_created = FALSE;
- // At least, you now have to cope with m_selection
- wxFAIL_MSG( wxT("wxGrid::CreateGrid or wxGrid::SetTable called more than once") );
- return FALSE;
+ if (m_ownTable)
+ {
+ wxGridTableBase *t=m_table;
+ m_table=0;
+ delete t;
+ }
+ delete m_selection;
+
+ m_table=0;
+ m_selection=0;
+ m_numRows=0;
+ m_numCols=0;
}
- else
+ if (table)
{
m_numRows = table->GetNumberRows();
m_numCols = table->GetNumberCols();
m_defaultColWidth = WXGRID_DEFAULT_COL_WIDTH;
m_defaultRowHeight = m_gridWin->GetCharHeight();
+ m_minAcceptableColWidth = WXGRID_MIN_COL_WIDTH;
+ m_minAcceptableRowHeight = WXGRID_MIN_ROW_HEIGHT;
+
#if defined(__WXMOTIF__) || defined(__WXGTK__) // see also text ctrl sizing in ShowCellEditControl()
m_defaultRowHeight += 8;
#else
m_winCapture = NULL;
}
- if ( m_selectingTopLeft != wxGridNoCellCoords &&
+ if ( coords == m_currentCellCoords && m_waitForSlowClick && CanEnableCellControl())
+ {
+ ClearSelection();
+ EnableCellEditControl();
+
+ wxGridCellAttr* attr = GetCellAttr(coords);
+ wxGridCellEditor *editor = attr->GetEditor(this, coords.GetRow(), coords.GetCol());
+ editor->StartingClick();
+ editor->DecRef();
+ attr->DecRef();
+
+ m_waitForSlowClick = FALSE;
+ }
+ else if ( m_selectingTopLeft != wxGridNoCellCoords &&
m_selectingBottomRight != wxGridNoCellCoords )
{
if ( m_selection )
// drag-shrinking.
ShowCellEditControl();
}
- else
- {
- if( m_waitForSlowClick && CanEnableCellControl())
- {
- EnableCellEditControl();
-
- wxGridCellAttr* attr = GetCellAttr(coords);
- wxGridCellEditor *editor = attr->GetEditor(this, coords.GetRow(), coords.GetCol());
- editor->StartingClick();
- editor->DecRef();
- attr->DecRef();
-
- m_waitForSlowClick = FALSE;
- }
- }
}
else if ( m_cursorMode == WXGRID_CURSOR_RESIZE_ROW )
{
int rowTop = GetRowTop(m_dragRowOrCol);
SetRowSize( m_dragRowOrCol,
- wxMax( m_dragLastPos - rowTop, WXGRID_MIN_ROW_HEIGHT ) );
+ wxMax( m_dragLastPos - rowTop, m_minAcceptableRowHeight ) );
if ( !GetBatchCount() )
{
if (IsCellEditControlEnabled())
DisableCellEditControl();
- return m_table->InsertRows( pos, numRows );
+ bool done = m_table->InsertRows( pos, numRows );
+ return done;
// the table will have sent the results of the insert row
// operation to this view object as a grid table message
return FALSE;
}
- return ( m_table && m_table->AppendRows( numRows ) );
- // the table will have sent the results of the append row
- // operation to this view object as a grid table message
+ if ( m_table )
+ {
+ 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;
}
if (IsCellEditControlEnabled())
DisableCellEditControl();
- return (m_table->DeleteRows( pos, numRows ));
+ bool done = m_table->DeleteRows( pos, numRows );
+ return done;
// the table will have sent the results of the delete row
// operation to this view object as a grid table message
}
if (IsCellEditControlEnabled())
DisableCellEditControl();
- return m_table->InsertCols( pos, numCols );
+ bool done = m_table->InsertCols( pos, numCols );
+ return done;
// the table will have sent the results of the insert col
// operation to this view object as a grid table message
}
return FALSE;
}
- return ( m_table && m_table->AppendCols( numCols ) );
- // the table will have sent the results of the append col
- // operation to this view object as a grid table message
+ if ( m_table )
+ {
+ bool done = m_table->AppendCols( numCols );
+ return done;
+ // the table will have sent the results of the append col
+ // operation to this view object as a grid table message
+ }
+ return FALSE;
}
if (IsCellEditControlEnabled())
DisableCellEditControl();
- return ( m_table->DeleteCols( pos, numCols ) );
+ bool done = m_table->DeleteCols( pos, numCols );
+ return done;
// the table will have sent the results of the delete col
// operation to this view object as a grid table message
}
int wxGrid::YToRow( int y )
{
return CoordToRowOrCol(y, m_defaultRowHeight,
- WXGRID_MIN_ROW_HEIGHT, m_rowBottoms, m_numRows, FALSE);
+ m_minAcceptableRowHeight, m_rowBottoms, m_numRows, FALSE);
}
int wxGrid::XToCol( int x )
{
return CoordToRowOrCol(x, m_defaultColWidth,
- WXGRID_MIN_COL_WIDTH, m_colRights, m_numCols, FALSE);
+ m_minAcceptableColWidth, m_colRights, m_numCols, FALSE);
}
void wxGrid::SetDefaultRowSize( int height, bool resizeExistingRows )
{
- m_defaultRowHeight = wxMax( height, WXGRID_MIN_ROW_HEIGHT );
+ m_defaultRowHeight = wxMax( height, m_minAcceptableRowHeight );
if ( resizeExistingRows )
{
{
wxCHECK_RET( row >= 0 && row < m_numRows, _T("invalid row index") );
+ // See comment in SetColSize
+ if ( height < GetRowMinimalAcceptableHeight()) { return; }
+
if ( m_rowHeights.IsEmpty() )
{
// need to really create the array
void wxGrid::SetDefaultColSize( int width, bool resizeExistingCols )
{
- m_defaultColWidth = wxMax( width, WXGRID_MIN_COL_WIDTH );
+ m_defaultColWidth = wxMax( width, m_minAcceptableColWidth );
if ( resizeExistingCols )
{
wxCHECK_RET( col >= 0 && col < m_numCols, _T("invalid column index") );
// should we check that it's bigger than GetColMinimalWidth(col) here?
-
+ // (VZ)
+ // No, because it is reasonable to assume the library user know's
+ // what he is doing. However whe should test against the weaker
+ // constariant of minimalAcceptableWidth, as this breaks rendering
+ //
+ // This test then fixes sf.net bug #645734
+
+ if ( width < GetColMinimalAcceptableWidth()) { return; }
+
if ( m_colWidths.IsEmpty() )
{
// need to really create the array
void wxGrid::SetColMinimalWidth( int col, int width )
{
- m_colMinWidths.Put(col, width);
+ if (width > GetColMinimalAcceptableWidth()) {
+ m_colMinWidths[col] = width;
+ }
}
void wxGrid::SetRowMinimalHeight( int row, int width )
{
- m_rowMinHeights.Put(row, width);
+ if (width > GetRowMinimalAcceptableHeight()) {
+ m_rowMinHeights[row] = width;
+ }
}
int wxGrid::GetColMinimalWidth(int col) const
{
- long value = m_colMinWidths.Get(col);
- return value != wxNOT_FOUND ? (int)value : WXGRID_MIN_COL_WIDTH;
+ wxLongToLongHashMap::const_iterator it = m_colMinWidths.find(col);
+ return it != m_colMinWidths.end() ? (int)it->second : m_minAcceptableColWidth;
}
int wxGrid::GetRowMinimalHeight(int row) const
{
- long value = m_rowMinHeights.Get(row);
- return value != wxNOT_FOUND ? (int)value : WXGRID_MIN_ROW_HEIGHT;
+ wxLongToLongHashMap::const_iterator it = m_rowMinHeights.find(row);
+ return it != m_rowMinHeights.end() ? (int)it->second : m_minAcceptableRowHeight;
+}
+
+void wxGrid::SetColMinimalAcceptableWidth( int width )
+{
+ if ( width<1 )
+ return;
+ m_minAcceptableColWidth = width;
+}
+
+void wxGrid::SetRowMinimalAcceptableHeight( int height )
+{
+ if ( height<1 )
+ return;
+ m_minAcceptableRowHeight = height;
+};
+
+int wxGrid::GetColMinimalAcceptableWidth() const
+{
+ return m_minAcceptableColWidth;
+}
+
+int wxGrid::GetRowMinimalAcceptableHeight() const
+{
+ return m_minAcceptableRowHeight;
}
// ----------------------------------------------------------------------------
return rect;
}
-
-
//
// ------ Grid event classes
//