-/////////////////////////////////////////////////////////////////////////////
-// Name: wx/generic/grideditors.h
-// Purpose: wxGridCellEditorEvtHandler and wxGrid editors
-// Author: Michael Bedward (based on code by Julian Smart, Robin Dunn)
-// Modified by: Santiago Palacios
-// Created: 1/08/1999
-// RCS-ID: $Id$
-// Copyright: (c) Michael Bedward
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-#ifndef _WX_GENERIC_GRID_EDITORS_H_
-#define _WX_GENERIC_GRID_EDITORS_H_
-
-#include "wx/defs.h"
-
-#if wxUSE_GRID
-
-class wxGridCellEditorEvtHandler : public wxEvtHandler
-{
-public:
- wxGridCellEditorEvtHandler(wxGrid* grid, wxGridCellEditor* editor)
- : m_grid(grid),
- m_editor(editor),
- m_inSetFocus(false)
- {
- }
-
- void OnKillFocus(wxFocusEvent& event);
- void OnKeyDown(wxKeyEvent& event);
- void OnChar(wxKeyEvent& event);
-
- void SetInSetFocus(bool inSetFocus) { m_inSetFocus = inSetFocus; }
-
-private:
- wxGrid *m_grid;
- wxGridCellEditor *m_editor;
-
- // Work around the fact that a focus kill event can be sent to
- // a combobox within a set focus event.
- bool m_inSetFocus;
-
- DECLARE_EVENT_TABLE()
- DECLARE_DYNAMIC_CLASS(wxGridCellEditorEvtHandler)
- wxDECLARE_NO_COPY_CLASS(wxGridCellEditorEvtHandler);
-};
-
-
-#if wxUSE_TEXTCTRL
-
-// the editor for string/text data
-class WXDLLIMPEXP_ADV wxGridCellTextEditor : public wxGridCellEditor
-{
-public:
- wxGridCellTextEditor();
-
- virtual void Create(wxWindow* parent,
- wxWindowID id,
- wxEvtHandler* evtHandler);
- virtual void SetSize(const wxRect& rect);
-
- virtual void PaintBackground(const wxRect& rectCell, wxGridCellAttr *attr);
-
- virtual bool IsAcceptedKey(wxKeyEvent& event);
- virtual void BeginEdit(int row, int col, wxGrid* grid);
- virtual bool EndEdit(const wxString& oldval, wxString *newval);
- virtual void ApplyEdit(int row, int col, wxGrid* grid);
-
- virtual void Reset();
- virtual void StartingKey(wxKeyEvent& event);
- virtual void HandleReturn(wxKeyEvent& event);
-
- // parameters string format is "max_width"
- virtual void SetParameters(const wxString& params);
-
- virtual wxGridCellEditor *Clone() const
- { return new wxGridCellTextEditor; }
-
- // added GetValue so we can get the value which is in the control
- virtual wxString GetValue() const;
-
-protected:
- wxTextCtrl *Text() const { return (wxTextCtrl *)m_control; }
-
- // parts of our virtual functions reused by the derived classes
- void DoCreate(wxWindow* parent, wxWindowID id, wxEvtHandler* evtHandler,
- long style = 0);
- void DoBeginEdit(const wxString& startValue);
- void DoReset(const wxString& startValue);
-
-private:
- size_t m_maxChars; // max number of chars allowed
- wxString m_value;
-
- wxDECLARE_NO_COPY_CLASS(wxGridCellTextEditor);
-};
-
-// the editor for numeric (long) data
-class WXDLLIMPEXP_ADV wxGridCellNumberEditor : public wxGridCellTextEditor
-{
-public:
- // allows to specify the range - if min == max == -1, no range checking is
- // done
- wxGridCellNumberEditor(int min = -1, int max = -1);
-
- virtual void Create(wxWindow* parent,
- wxWindowID id,
- wxEvtHandler* evtHandler);
-
- virtual bool IsAcceptedKey(wxKeyEvent& event);
- virtual void BeginEdit(int row, int col, wxGrid* grid);
- virtual bool EndEdit(const wxString& oldval, wxString *newval);
- virtual void ApplyEdit(int row, int col, wxGrid* grid);
-
- virtual void Reset();
- virtual void StartingKey(wxKeyEvent& event);
-
- // parameters string format is "min,max"
- virtual void SetParameters(const wxString& params);
-
- virtual wxGridCellEditor *Clone() const
- { return new wxGridCellNumberEditor(m_min, m_max); }
-
- // added GetValue so we can get the value which is in the control
- virtual wxString GetValue() const;
-
-protected:
-#if wxUSE_SPINCTRL
- wxSpinCtrl *Spin() const { return (wxSpinCtrl *)m_control; }
-#endif
-
- // if HasRange(), we use wxSpinCtrl - otherwise wxTextCtrl
- bool HasRange() const
- {
-#if wxUSE_SPINCTRL
- return m_min != m_max;
-#else
- return false;
-#endif
- }
-
- // string representation of our value
- wxString GetString() const
- { return wxString::Format(_T("%ld"), m_value); }
-
-private:
- int m_min,
- m_max;
-
- long m_value;
-
- wxDECLARE_NO_COPY_CLASS(wxGridCellNumberEditor);
-};
-
-// the editor for floating point numbers (double) data
-class WXDLLIMPEXP_ADV wxGridCellFloatEditor : public wxGridCellTextEditor
-{
-public:
- wxGridCellFloatEditor(int width = -1, int precision = -1);
-
- virtual void Create(wxWindow* parent,
- wxWindowID id,
- wxEvtHandler* evtHandler);
-
- virtual bool IsAcceptedKey(wxKeyEvent& event);
- virtual void BeginEdit(int row, int col, wxGrid* grid);
- virtual bool EndEdit(const wxString& oldval, wxString *newval);
- virtual void ApplyEdit(int row, int col, wxGrid* grid);
-
- virtual void Reset();
- virtual void StartingKey(wxKeyEvent& event);
-
- virtual wxGridCellEditor *Clone() const
- { return new wxGridCellFloatEditor(m_width, m_precision); }
-
- // parameters string format is "width,precision"
- virtual void SetParameters(const wxString& params);
-
-protected:
- // string representation of our value
- wxString GetString() const;
-
-private:
- int m_width,
- m_precision;
- double m_value;
-
- wxDECLARE_NO_COPY_CLASS(wxGridCellFloatEditor);
-};
-
-#endif // wxUSE_TEXTCTRL
-
-#if wxUSE_CHECKBOX
-
-// the editor for boolean data
-class WXDLLIMPEXP_ADV wxGridCellBoolEditor : public wxGridCellEditor
-{
-public:
- wxGridCellBoolEditor() { }
-
- virtual void Create(wxWindow* parent,
- wxWindowID id,
- wxEvtHandler* evtHandler);
-
- virtual void SetSize(const wxRect& rect);
- virtual void Show(bool show, wxGridCellAttr *attr = NULL);
-
- virtual bool IsAcceptedKey(wxKeyEvent& event);
- virtual void BeginEdit(int row, int col, wxGrid* grid);
- virtual bool EndEdit(const wxString& oldval, wxString *newval);
- virtual void ApplyEdit(int row, int col, wxGrid* grid);
-
- virtual void Reset();
- virtual void StartingClick();
- virtual void StartingKey(wxKeyEvent& event);
-
- virtual wxGridCellEditor *Clone() const
- { return new wxGridCellBoolEditor; }
-
- // added GetValue so we can get the value which is in the control, see
- // also UseStringValues()
- virtual wxString GetValue() const;
-
- // set the string values returned by GetValue() for the true and false
- // states, respectively
- static void UseStringValues(const wxString& valueTrue = _T("1"),
- const wxString& valueFalse = wxEmptyString);
-
- // return true if the given string is equal to the string representation of
- // true value which we currently use
- static bool IsTrueValue(const wxString& value);
-
-protected:
- wxCheckBox *CBox() const { return (wxCheckBox *)m_control; }
-
-private:
- bool m_value;
-
- static wxString ms_stringValues[2];
-
- wxDECLARE_NO_COPY_CLASS(wxGridCellBoolEditor);
-};
-
-#endif // wxUSE_CHECKBOX
-
-#if wxUSE_COMBOBOX
-
-// the editor for string data allowing to choose from the list of strings
-class WXDLLIMPEXP_ADV wxGridCellChoiceEditor : public wxGridCellEditor
-{
-public:
- // if !allowOthers, user can't type a string not in choices array
- wxGridCellChoiceEditor(size_t count = 0,
- const wxString choices[] = NULL,
- bool allowOthers = false);
- wxGridCellChoiceEditor(const wxArrayString& choices,
- bool allowOthers = false);
-
- virtual void Create(wxWindow* parent,
- wxWindowID id,
- wxEvtHandler* evtHandler);
-
- virtual void PaintBackground(const wxRect& rectCell, wxGridCellAttr *attr);
-
- virtual void BeginEdit(int row, int col, wxGrid* grid);
- virtual bool EndEdit(const wxString& oldval, wxString *newval);
- virtual void ApplyEdit(int row, int col, wxGrid* grid);
-
- virtual void Reset();
-
- // parameters string format is "item1[,item2[...,itemN]]"
- virtual void SetParameters(const wxString& params);
-
- virtual wxGridCellEditor *Clone() const;
-
- // added GetValue so we can get the value which is in the control
- virtual wxString GetValue() const;
-
-protected:
- wxComboBox *Combo() const { return (wxComboBox *)m_control; }
-
- wxString m_value;
- wxArrayString m_choices;
- bool m_allowOthers;
-
- wxDECLARE_NO_COPY_CLASS(wxGridCellChoiceEditor);
-};
-
-#endif // wxUSE_COMBOBOX
-
-#if wxUSE_COMBOBOX
-
-class WXDLLIMPEXP_ADV wxGridCellEnumEditor : public wxGridCellChoiceEditor
-{
-public:
- wxGridCellEnumEditor( const wxString& choices = wxEmptyString );
- virtual ~wxGridCellEnumEditor() {}
-
- virtual wxGridCellEditor* Clone() const;
-
- virtual void BeginEdit(int row, int col, wxGrid* grid);
- virtual bool EndEdit(const wxString& oldval, wxString *newval);
- virtual void ApplyEdit(int row, int col, wxGrid* grid);
-
-private:
- long m_index;
-
- wxDECLARE_NO_COPY_CLASS(wxGridCellEnumEditor);
-};
-
-#endif // wxUSE_COMBOBOX
-
-class WXDLLIMPEXP_ADV wxGridCellAutoWrapStringEditor : public wxGridCellTextEditor
-{
-public:
- wxGridCellAutoWrapStringEditor() : wxGridCellTextEditor() { }
- virtual void Create(wxWindow* parent,
- wxWindowID id,
- wxEvtHandler* evtHandler);
-
- virtual wxGridCellEditor *Clone() const
- { return new wxGridCellAutoWrapStringEditor; }
-
- wxDECLARE_NO_COPY_CLASS(wxGridCellAutoWrapStringEditor);
-};
-
-#endif // wxUSE_GRID
-#endif // _WX_GENERIC_GRID_EDITORS_H_
+/////////////////////////////////////////////////////////////////////////////\r
+// Name: wx/generic/grideditors.h\r
+// Purpose: wxGridCellEditorEvtHandler and wxGrid editors\r
+// Author: Michael Bedward (based on code by Julian Smart, Robin Dunn)\r
+// Modified by: Santiago Palacios\r
+// Created: 1/08/1999\r
+// RCS-ID: $Id$\r
+// Copyright: (c) Michael Bedward\r
+// Licence: wxWindows licence\r
+/////////////////////////////////////////////////////////////////////////////\r
+\r
+#ifndef _WX_GENERIC_GRID_EDITORS_H_\r
+#define _WX_GENERIC_GRID_EDITORS_H_\r
+\r
+#include "wx/defs.h"\r
+\r
+#if wxUSE_GRID\r
+\r
+class wxGridCellEditorEvtHandler : public wxEvtHandler\r
+{\r
+public:\r
+ wxGridCellEditorEvtHandler(wxGrid* grid, wxGridCellEditor* editor)\r
+ : m_grid(grid),\r
+ m_editor(editor),\r
+ m_inSetFocus(false)\r
+ {\r
+ }\r
+\r
+ void OnKillFocus(wxFocusEvent& event);\r
+ void OnKeyDown(wxKeyEvent& event);\r
+ void OnChar(wxKeyEvent& event);\r
+\r
+ void SetInSetFocus(bool inSetFocus) { m_inSetFocus = inSetFocus; }\r
+\r
+private:\r
+ wxGrid *m_grid;\r
+ wxGridCellEditor *m_editor;\r
+\r
+ // Work around the fact that a focus kill event can be sent to\r
+ // a combobox within a set focus event.\r
+ bool m_inSetFocus;\r
+\r
+ DECLARE_EVENT_TABLE()\r
+ DECLARE_DYNAMIC_CLASS(wxGridCellEditorEvtHandler)\r
+ wxDECLARE_NO_COPY_CLASS(wxGridCellEditorEvtHandler);\r
+};\r
+\r
+\r
+#if wxUSE_TEXTCTRL\r
+\r
+// the editor for string/text data\r
+class WXDLLIMPEXP_ADV wxGridCellTextEditor : public wxGridCellEditor\r
+{\r
+public:\r
+ wxGridCellTextEditor();\r
+\r
+ virtual void Create(wxWindow* parent,\r
+ wxWindowID id,\r
+ wxEvtHandler* evtHandler);\r
+ virtual void SetSize(const wxRect& rect);\r
+\r
+ virtual void PaintBackground(const wxRect& rectCell, wxGridCellAttr *attr);\r
+\r
+ virtual bool IsAcceptedKey(wxKeyEvent& event);\r
+ virtual void BeginEdit(int row, int col, wxGrid* grid);\r
+ virtual bool EndEdit(int row, int col, const wxGrid* grid,\r
+ const wxString& oldval, wxString *newval);\r
+ virtual void ApplyEdit(int row, int col, wxGrid* grid);\r
+\r
+ virtual void Reset();\r
+ virtual void StartingKey(wxKeyEvent& event);\r
+ virtual void HandleReturn(wxKeyEvent& event);\r
+\r
+ // parameters string format is "max_width"\r
+ virtual void SetParameters(const wxString& params);\r
+\r
+ virtual wxGridCellEditor *Clone() const\r
+ { return new wxGridCellTextEditor; }\r
+\r
+ // added GetValue so we can get the value which is in the control\r
+ virtual wxString GetValue() const;\r
+\r
+protected:\r
+ wxTextCtrl *Text() const { return (wxTextCtrl *)m_control; }\r
+\r
+ // parts of our virtual functions reused by the derived classes\r
+ void DoCreate(wxWindow* parent, wxWindowID id, wxEvtHandler* evtHandler,\r
+ long style = 0);\r
+ void DoBeginEdit(const wxString& startValue);\r
+ void DoReset(const wxString& startValue);\r
+\r
+private:\r
+ size_t m_maxChars; // max number of chars allowed\r
+ wxString m_value;\r
+\r
+ wxDECLARE_NO_COPY_CLASS(wxGridCellTextEditor);\r
+};\r
+\r
+// the editor for numeric (long) data\r
+class WXDLLIMPEXP_ADV wxGridCellNumberEditor : public wxGridCellTextEditor\r
+{\r
+public:\r
+ // allows to specify the range - if min == max == -1, no range checking is\r
+ // done\r
+ wxGridCellNumberEditor(int min = -1, int max = -1);\r
+\r
+ virtual void Create(wxWindow* parent,\r
+ wxWindowID id,\r
+ wxEvtHandler* evtHandler);\r
+\r
+ virtual bool IsAcceptedKey(wxKeyEvent& event);\r
+ virtual void BeginEdit(int row, int col, wxGrid* grid);\r
+ virtual bool EndEdit(int row, int col, const wxGrid* grid,\r
+ const wxString& oldval, wxString *newval);\r
+ virtual void ApplyEdit(int row, int col, wxGrid* grid);\r
+\r
+ virtual void Reset();\r
+ virtual void StartingKey(wxKeyEvent& event);\r
+\r
+ // parameters string format is "min,max"\r
+ virtual void SetParameters(const wxString& params);\r
+\r
+ virtual wxGridCellEditor *Clone() const\r
+ { return new wxGridCellNumberEditor(m_min, m_max); }\r
+\r
+ // added GetValue so we can get the value which is in the control\r
+ virtual wxString GetValue() const;\r
+\r
+protected:\r
+#if wxUSE_SPINCTRL\r
+ wxSpinCtrl *Spin() const { return (wxSpinCtrl *)m_control; }\r
+#endif\r
+\r
+ // if HasRange(), we use wxSpinCtrl - otherwise wxTextCtrl\r
+ bool HasRange() const\r
+ {\r
+#if wxUSE_SPINCTRL\r
+ return m_min != m_max;\r
+#else\r
+ return false;\r
+#endif\r
+ }\r
+\r
+ // string representation of our value\r
+ wxString GetString() const\r
+ { return wxString::Format(_T("%ld"), m_value); }\r
+\r
+private:\r
+ int m_min,\r
+ m_max;\r
+\r
+ long m_value;\r
+\r
+ wxDECLARE_NO_COPY_CLASS(wxGridCellNumberEditor);\r
+};\r
+\r
+// the editor for floating point numbers (double) data\r
+class WXDLLIMPEXP_ADV wxGridCellFloatEditor : public wxGridCellTextEditor\r
+{\r
+public:\r
+ wxGridCellFloatEditor(int width = -1, int precision = -1);\r
+\r
+ virtual void Create(wxWindow* parent,\r
+ wxWindowID id,\r
+ wxEvtHandler* evtHandler);\r
+\r
+ virtual bool IsAcceptedKey(wxKeyEvent& event);\r
+ virtual void BeginEdit(int row, int col, wxGrid* grid);\r
+ virtual bool EndEdit(int row, int col, const wxGrid* grid,\r
+ const wxString& oldval, wxString *newval);\r
+ virtual void ApplyEdit(int row, int col, wxGrid* grid);\r
+\r
+ virtual void Reset();\r
+ virtual void StartingKey(wxKeyEvent& event);\r
+\r
+ virtual wxGridCellEditor *Clone() const\r
+ { return new wxGridCellFloatEditor(m_width, m_precision); }\r
+\r
+ // parameters string format is "width,precision"\r
+ virtual void SetParameters(const wxString& params);\r
+\r
+protected:\r
+ // string representation of our value\r
+ wxString GetString() const;\r
+\r
+private:\r
+ int m_width,\r
+ m_precision;\r
+ double m_value;\r
+\r
+ wxDECLARE_NO_COPY_CLASS(wxGridCellFloatEditor);\r
+};\r
+\r
+#endif // wxUSE_TEXTCTRL\r
+\r
+#if wxUSE_CHECKBOX\r
+\r
+// the editor for boolean data\r
+class WXDLLIMPEXP_ADV wxGridCellBoolEditor : public wxGridCellEditor\r
+{\r
+public:\r
+ wxGridCellBoolEditor() { }\r
+\r
+ virtual void Create(wxWindow* parent,\r
+ wxWindowID id,\r
+ wxEvtHandler* evtHandler);\r
+\r
+ virtual void SetSize(const wxRect& rect);\r
+ virtual void Show(bool show, wxGridCellAttr *attr = NULL);\r
+\r
+ virtual bool IsAcceptedKey(wxKeyEvent& event);\r
+ virtual void BeginEdit(int row, int col, wxGrid* grid);\r
+ virtual bool EndEdit(int row, int col, const wxGrid* grid,\r
+ const wxString& oldval, wxString *newval);\r
+ virtual void ApplyEdit(int row, int col, wxGrid* grid);\r
+\r
+ virtual void Reset();\r
+ virtual void StartingClick();\r
+ virtual void StartingKey(wxKeyEvent& event);\r
+\r
+ virtual wxGridCellEditor *Clone() const\r
+ { return new wxGridCellBoolEditor; }\r
+\r
+ // added GetValue so we can get the value which is in the control, see\r
+ // also UseStringValues()\r
+ virtual wxString GetValue() const;\r
+\r
+ // set the string values returned by GetValue() for the true and false\r
+ // states, respectively\r
+ static void UseStringValues(const wxString& valueTrue = _T("1"),\r
+ const wxString& valueFalse = wxEmptyString);\r
+\r
+ // return true if the given string is equal to the string representation of\r
+ // true value which we currently use\r
+ static bool IsTrueValue(const wxString& value);\r
+\r
+protected:\r
+ wxCheckBox *CBox() const { return (wxCheckBox *)m_control; }\r
+\r
+private:\r
+ bool m_value;\r
+\r
+ static wxString ms_stringValues[2];\r
+\r
+ wxDECLARE_NO_COPY_CLASS(wxGridCellBoolEditor);\r
+};\r
+\r
+#endif // wxUSE_CHECKBOX\r
+\r
+#if wxUSE_COMBOBOX\r
+\r
+// the editor for string data allowing to choose from the list of strings\r
+class WXDLLIMPEXP_ADV wxGridCellChoiceEditor : public wxGridCellEditor\r
+{\r
+public:\r
+ // if !allowOthers, user can't type a string not in choices array\r
+ wxGridCellChoiceEditor(size_t count = 0,\r
+ const wxString choices[] = NULL,\r
+ bool allowOthers = false);\r
+ wxGridCellChoiceEditor(const wxArrayString& choices,\r
+ bool allowOthers = false);\r
+\r
+ virtual void Create(wxWindow* parent,\r
+ wxWindowID id,\r
+ wxEvtHandler* evtHandler);\r
+\r
+ virtual void PaintBackground(const wxRect& rectCell, wxGridCellAttr *attr);\r
+\r
+ virtual void BeginEdit(int row, int col, wxGrid* grid);\r
+ virtual bool EndEdit(int row, int col, const wxGrid* grid,\r
+ const wxString& oldval, wxString *newval);\r
+ virtual void ApplyEdit(int row, int col, wxGrid* grid);\r
+\r
+ virtual void Reset();\r
+\r
+ // parameters string format is "item1[,item2[...,itemN]]"\r
+ virtual void SetParameters(const wxString& params);\r
+\r
+ virtual wxGridCellEditor *Clone() const;\r
+\r
+ // added GetValue so we can get the value which is in the control\r
+ virtual wxString GetValue() const;\r
+\r
+protected:\r
+ wxComboBox *Combo() const { return (wxComboBox *)m_control; }\r
+\r
+ wxString m_value;\r
+ wxArrayString m_choices;\r
+ bool m_allowOthers;\r
+\r
+ wxDECLARE_NO_COPY_CLASS(wxGridCellChoiceEditor);\r
+};\r
+\r
+#endif // wxUSE_COMBOBOX\r
+\r
+#if wxUSE_COMBOBOX\r
+\r
+class WXDLLIMPEXP_ADV wxGridCellEnumEditor : public wxGridCellChoiceEditor\r
+{\r
+public:\r
+ wxGridCellEnumEditor( const wxString& choices = wxEmptyString );\r
+ virtual ~wxGridCellEnumEditor() {}\r
+\r
+ virtual wxGridCellEditor* Clone() const;\r
+\r
+ virtual void BeginEdit(int row, int col, wxGrid* grid);\r
+ virtual bool EndEdit(int row, int col, const wxGrid* grid,\r
+ const wxString& oldval, wxString *newval);\r
+ virtual void ApplyEdit(int row, int col, wxGrid* grid);\r
+\r
+private:\r
+ long m_index;\r
+\r
+ wxDECLARE_NO_COPY_CLASS(wxGridCellEnumEditor);\r
+};\r
+\r
+#endif // wxUSE_COMBOBOX\r
+\r
+class WXDLLIMPEXP_ADV wxGridCellAutoWrapStringEditor : public wxGridCellTextEditor\r
+{\r
+public:\r
+ wxGridCellAutoWrapStringEditor() : wxGridCellTextEditor() { }\r
+ virtual void Create(wxWindow* parent,\r
+ wxWindowID id,\r
+ wxEvtHandler* evtHandler);\r
+\r
+ virtual wxGridCellEditor *Clone() const\r
+ { return new wxGridCellAutoWrapStringEditor; }\r
+\r
+ wxDECLARE_NO_COPY_CLASS(wxGridCellAutoWrapStringEditor);\r
+};\r
+\r
+#endif // wxUSE_GRID\r
+\r
+#endif // _WX_GENERIC_GRID_EDITORS_H_\r