#if wxUSE_GRID
+#include "wx/grid.h"
+
#ifndef WX_PRECOMP
#include "wx/utils.h"
#include "wx/dcclient.h"
#include "wx/tokenzr.h"
#include "wx/renderer.h"
-#include "wx/grid.h"
#include "wx/generic/gridsel.h"
+const wxChar wxGridNameStr[] = wxT("grid");
+
#if defined(__WXMOTIF__)
#define WXUNUSED_MOTIF(identifier) WXUNUSED(identifier)
#else
wxGridRowLabelWindow *rowLblWin,
wxGridColLabelWindow *colLblWin,
wxWindowID id, const wxPoint &pos, const wxSize &size );
- ~wxGridWindow() {}
+ virtual ~wxGridWindow() {}
void ScrollWindow( int dx, int dy, const wxRect *rect );
{
if ( wxGridCellEditor::IsAcceptedKey(event) )
{
- int keycode = event.GetKeyCode();
- printf("%d\n", keycode);
- // accept digits, 'e' as in '1e+6', also '-', '+', and '.'
- char tmpbuf[2];
- tmpbuf[0] = (char) keycode;
- tmpbuf[1] = '\0';
- wxString strbuf(tmpbuf, *wxConvCurrent);
+ const int keycode = event.GetKeyCode();
+ if ( isascii(keycode) )
+ {
+ char tmpbuf[2];
+ tmpbuf[0] = (char) keycode;
+ tmpbuf[1] = '\0';
+ wxString strbuf(tmpbuf, *wxConvCurrent);
#if wxUSE_INTL
- bool is_decimal_point =
- ( strbuf == wxLocale::GetInfo(wxLOCALE_DECIMAL_POINT,
- wxLOCALE_CAT_NUMBER) );
+ const wxString decimalPoint =
+ wxLocale::GetInfo(wxLOCALE_DECIMAL_POINT, wxLOCALE_CAT_NUMBER);
#else
- bool is_decimal_point = ( strbuf == _T(".") );
+ const wxString decimalPoint(_T('.'));
#endif
- if ( (keycode < 128) &&
- (wxIsdigit(keycode) || tolower(keycode) == 'e' ||
- is_decimal_point || keycode == '+' || keycode == '-') )
- {
- return true;
+ // accept digits, 'e' as in '1e+6', also '-', '+', and '.'
+ if ( wxIsdigit(keycode) ||
+ tolower(keycode) == 'e' ||
+ keycode == decimalPoint ||
+ keycode == '+' ||
+ keycode == '-' )
+ {
+ return true;
+ }
}
}
if ( IsReadOnly() )
attr->SetReadOnly();
+ attr->SetOverflow( m_overflow == Overflow );
attr->SetKind( m_attrkind );
return attr;
int x, y;
m_owner->CalcUnscrolledPosition( 0, 0, &x, &y );
- dc.SetDeviceOrigin( 0, -y );
+ wxPoint pt = dc.GetDeviceOrigin();
+ dc.SetDeviceOrigin( pt.x, pt.y-y );
wxArrayInt rows = m_owner->CalcRowLabelsExposed( GetUpdateRegion() );
m_owner->DrawRowLabels( dc, rows );
int x, y;
m_owner->CalcUnscrolledPosition( 0, 0, &x, &y );
- dc.SetDeviceOrigin( -x, 0 );
+ wxPoint pt = dc.GetDeviceOrigin();
+ if (GetLayoutDirection() == wxLayout_RightToLeft)
+ dc.SetDeviceOrigin( pt.x+x, pt.y );
+ else
+ dc.SetDeviceOrigin( pt.x-x, pt.y );
wxArrayInt cols = m_owner->CalcColLabelsExposed( GetUpdateRegion() );
m_owner->DrawColLabels( dc, cols );
if ( !parent->GetEventHandler()->ProcessEvent( keyEvt ) )
{
+ if (GetLayoutDirection() == wxLayout_RightToLeft)
+ {
+ if (event.GetKeyCode() == WXK_RIGHT)
+ event.m_keyCode = WXK_LEFT;
+ else if (event.GetKeyCode() == WXK_LEFT)
+ event.m_keyCode = WXK_RIGHT;
+ }
+
// try local handlers
switch ( event.GetKeyCode() )
{
{
i = GetColAt( colPos );
- int colRight = GetColRight(i) - 1;
+ int colRight = GetColRight(i);
+#ifdef __WXGTK__
+ if (GetLayoutDirection() != wxLayout_RightToLeft)
+#endif
+ colRight--;
+
if ( colRight > right )
{
break;
continue;
}
- long lineWidth,
- lineHeight;
+ long lineWidth = 0,
+ lineHeight = 0;
dc.GetTextExtent(line, &lineWidth, &lineHeight);
switch ( horizAlign )
return GetColAt( maxPos );
}
-// return the row number that that the y coord is near the edge of, or
-// -1 if not near an edge
+// return the row number that that the y coord is near
+// the edge of, or -1 if not near an edge.
+// coords can only possibly be near an edge if
+// (a) the row/column is large enough to still allow for an "inner" area
+// that is _not_ nead the edge (i.e., if the height/width is smaller
+// than WXGRID_LABEL_EDGE_ZONE, coords are _never_ considered to be
+// near the edge).
+// and
+// (b) resizing rows/columns (the thing for which edge detection is
+// relevant at all) is enabled.
//
int wxGrid::YToEdgeOfRow( int y )
{
int i;
i = internalYToRow(y);
- if ( GetRowHeight(i) > WXGRID_LABEL_EDGE_ZONE )
+ if ( GetRowHeight(i) > WXGRID_LABEL_EDGE_ZONE && CanDragRowSize() )
{
// We know that we are in row i, test whether we are
// close enough to lower or upper border, respectively.
// return the col number that that the x coord is near the edge of, or
// -1 if not near an edge
+// See comment at YToEdgeOfRow for conditions on edge detection.
//
int wxGrid::XToEdgeOfCol( int x )
{
int i;
i = internalXToCol(x);
- if ( GetColWidth(i) > WXGRID_LABEL_EDGE_ZONE )
+ if ( GetColWidth(i) > WXGRID_LABEL_EDGE_ZONE && CanDragColSize() )
{
// We know that we are in column i; test whether we are
// close enough to right or left border, respectively.
if ( column )
{
- dc.GetTextExtent( GetColLabelValue(col), &w, &h );
+ dc.GetMultiLineTextExtent( GetColLabelValue(col), &w, &h );
if ( GetColLabelTextOrientation() == wxVERTICAL )
w = h;
}
else
- dc.GetTextExtent( GetRowLabelValue(row), &w, &h );
+ dc.GetMultiLineTextExtent( GetRowLabelValue(row), &w, &h );
extent = column ? w : h;
if ( extent > extentMax )