#include "wx/checkbox.h"
#include "wx/combobox.h"
#include "wx/valtext.h"
+ #include "wx/intl.h"
#endif
#include "wx/textfile.h"
void OnKeyDown( wxKeyEvent& );
void OnKeyUp( wxKeyEvent& );
void OnEraseBackground( wxEraseEvent& );
-
+ void OnFocus( wxFocusEvent& );
DECLARE_DYNAMIC_CLASS(wxGridWindow)
DECLARE_EVENT_TABLE()
grid->GetTable()->SetValue(row, col, value);
m_startValue = wxEmptyString;
- Text()->SetValue(m_startValue);
+ // No point in setting the text of the hidden control
+ //Text()->SetValue(m_startValue);
return changed;
}
void wxGridCellFloatEditor::StartingKey(wxKeyEvent& event)
{
int keycode = event.GetKeyCode();
- if ( wxIsdigit(keycode) || keycode == '+' || keycode == '-' || keycode == '.'
+ char tmpbuf[2];
+ tmpbuf[0] = (char) keycode;
+ tmpbuf[1] = '\0';
+ bool is_decimal_point = ( wxString(tmpbuf, *wxConvCurrent) ==
+ wxLocale::GetInfo(wxLOCALE_DECIMAL_POINT, wxLOCALE_CAT_NUMBER) );
+ if ( wxIsdigit(keycode) || keycode == '+' || keycode == '-'
+ || is_decimal_point
|| keycode == WXK_NUMPAD0
|| keycode == WXK_NUMPAD1
|| keycode == WXK_NUMPAD2
case WXK_NUMPAD_DECIMAL:
return TRUE;
- default:
- // additionally accept 'e' as in '1e+6'
+ default:
+ {
+ // additionally accept 'e' as in '1e+6', also '-', '+', and '.'
+ char tmpbuf[2];
+ tmpbuf[0] = (char) keycode;
+ tmpbuf[1] = '\0';
+ bool is_decimal_point =
+ ( wxString(tmpbuf, *wxConvCurrent) ==
+ wxLocale::GetInfo(wxLOCALE_DECIMAL_POINT,
+ wxLOCALE_CAT_NUMBER) );
if ( (keycode < 128) &&
- (wxIsdigit(keycode) || tolower(keycode) == 'e') )
+ (wxIsdigit(keycode) || tolower(keycode) == 'e' ||
+ is_decimal_point || keycode == '+' || keycode == '-') )
return TRUE;
+ }
}
}
wxWindowID id,
wxEvtHandler* evtHandler)
{
- size_t count = m_choices.GetCount();
- wxString *choices = new wxString[count];
- for ( size_t n = 0; n < count; n++ )
- {
- choices[n] = m_choices[n];
- }
-
m_control = new wxComboBox(parent, id, wxEmptyString,
wxDefaultPosition, wxDefaultSize,
- count, choices,
+ m_choices,
m_allowOthers ? 0 : wxCB_READONLY);
- delete [] choices;
-
wxGridCellEditor::Create(parent, id, evtHandler);
}
unsigned int i, n;
for ( n = 1; ; n++ )
{
- s += (_T('A') + (wxChar)( col%26 ));
+ s += (wxChar) (_T('A') + (wxChar)( col%26 ));
col = col/26 - 1;
if ( col < 0 ) break;
}
wxGridRowLabelWindow::wxGridRowLabelWindow( wxGrid *parent,
wxWindowID id,
const wxPoint &pos, const wxSize &size )
- : wxWindow( parent, id, pos, size, wxWANTS_CHARS|wxBORDER_NONE )
+ : wxWindow( parent, id, pos, size, wxWANTS_CHARS|wxBORDER_NONE|wxFULL_REPAINT_ON_RESIZE )
{
m_owner = parent;
}
wxGridColLabelWindow::wxGridColLabelWindow( wxGrid *parent,
wxWindowID id,
const wxPoint &pos, const wxSize &size )
- : wxWindow( parent, id, pos, size, wxWANTS_CHARS|wxBORDER_NONE )
+ : wxWindow( parent, id, pos, size, wxWANTS_CHARS|wxBORDER_NONE|wxFULL_REPAINT_ON_RESIZE )
{
m_owner = parent;
}
wxGridCornerLabelWindow::wxGridCornerLabelWindow( wxGrid *parent,
wxWindowID id,
const wxPoint &pos, const wxSize &size )
- : wxWindow( parent, id, pos, size, wxWANTS_CHARS|wxBORDER_NONE )
+ : wxWindow( parent, id, pos, size, wxWANTS_CHARS|wxBORDER_NONE|wxFULL_REPAINT_ON_RESIZE )
{
m_owner = parent;
}
EVT_MOUSE_EVENTS( wxGridWindow::OnMouseEvent )
EVT_KEY_DOWN( wxGridWindow::OnKeyDown )
EVT_KEY_UP( wxGridWindow::OnKeyUp )
+ EVT_SET_FOCUS( wxGridWindow::OnFocus )
+ EVT_KILL_FOCUS( wxGridWindow::OnFocus )
EVT_ERASE_BACKGROUND( wxGridWindow::OnEraseBackground )
END_EVENT_TABLE()
wxWindowID id,
const wxPoint &pos,
const wxSize &size )
- : wxWindow( parent, id, pos, size, wxWANTS_CHARS | wxBORDER_NONE | wxCLIP_CHILDREN,
+ : wxWindow( parent, id, pos, size, wxWANTS_CHARS | wxBORDER_NONE | wxCLIP_CHILDREN|wxFULL_REPAINT_ON_RESIZE,
wxT("grid window") )
{
{
}
+void wxGridWindow::OnFocus(wxFocusEvent& event)
+{
+ if ( !m_owner->GetEventHandler()->ProcessEvent( event ) )
+ event.Skip();
+}
//////////////////////////////////////////////////////////////////////
int x, y;
GetViewStart( &x, &y );
- // maybe we don't need scrollbars at all?
- //
- // also adjust the position to be valid for the new scroll rangs
- if ( w <= cw )
- {
- w = x = 0;
- }
- else
- {
- if ( x >= w )
- x = w - 1;
- }
-
- if ( h <= ch )
- {
- h = y = 0;
- }
- else
- {
- if ( y >= h )
- y = h - 1;
- }
+ // ensure the position is valid for the new scroll ranges
+ if ( x >= w )
+ x = wxMax( w - 1, 0 );
+ if ( y >= h )
+ y = wxMax( h - 1, 0 );
// do set scrollbar parameters
SetScrollbars( GRID_SCROLL_LINE_X, GRID_SCROLL_LINE_Y,