Use wxWindow as a control for wxGridCellEditor
Use wxWindow instead of wxControl in wxGridCellEditor to allow using any window as an editor control, as it doesn't need to be a wxControl. Closes https://github.com/wxWidgets/wxWidgets/pull/1370
This commit is contained in:
committed by
Vadim Zeitlin
parent
ea68934b8e
commit
feacaf8714
@@ -220,8 +220,9 @@ public:
|
|||||||
wxGridCellEditor();
|
wxGridCellEditor();
|
||||||
|
|
||||||
bool IsCreated() const { return m_control != NULL; }
|
bool IsCreated() const { return m_control != NULL; }
|
||||||
wxControl* GetControl() const { return m_control; }
|
|
||||||
void SetControl(wxControl* control) { m_control = control; }
|
wxWindow* GetWindow() const { return m_control; }
|
||||||
|
void SetWindow(wxWindow* window) { m_control = window; }
|
||||||
|
|
||||||
wxGridCellAttr* GetCellAttr() const { return m_attr; }
|
wxGridCellAttr* GetCellAttr() const { return m_attr; }
|
||||||
void SetCellAttr(wxGridCellAttr* attr) { m_attr = attr; }
|
void SetCellAttr(wxGridCellAttr* attr) { m_attr = attr; }
|
||||||
@@ -301,12 +302,19 @@ public:
|
|||||||
// added GetValue so we can get the value which is in the control
|
// added GetValue so we can get the value which is in the control
|
||||||
virtual wxString GetValue() const = 0;
|
virtual wxString GetValue() const = 0;
|
||||||
|
|
||||||
|
|
||||||
|
// These functions exist only for backward compatibility, use Get and
|
||||||
|
// SetWindow() instead in the new code.
|
||||||
|
wxControl* GetControl() { return wxDynamicCast(m_control, wxControl); }
|
||||||
|
void SetControl(wxControl* control) { m_control = control; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// the dtor is private because only DecRef() can delete us
|
// the dtor is private because only DecRef() can delete us
|
||||||
virtual ~wxGridCellEditor();
|
virtual ~wxGridCellEditor();
|
||||||
|
|
||||||
// the control we show on screen
|
// the actual window we show on screen (this variable should actually be
|
||||||
wxControl* m_control;
|
// named m_window, but m_control is kept for backward compatibility)
|
||||||
|
wxWindow* m_control;
|
||||||
|
|
||||||
// a temporary pointer to the attribute being edited
|
// a temporary pointer to the attribute being edited
|
||||||
wxGridCellAttr* m_attr;
|
wxGridCellAttr* m_attr;
|
||||||
@@ -2615,25 +2623,30 @@ public:
|
|||||||
{
|
{
|
||||||
m_row = 0;
|
m_row = 0;
|
||||||
m_col = 0;
|
m_col = 0;
|
||||||
m_ctrl = NULL;
|
m_window = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxGridEditorCreatedEvent(int id, wxEventType type, wxObject* obj,
|
wxGridEditorCreatedEvent(int id, wxEventType type, wxObject* obj,
|
||||||
int row, int col, wxControl* ctrl);
|
int row, int col, wxWindow* window);
|
||||||
|
|
||||||
int GetRow() { return m_row; }
|
int GetRow() { return m_row; }
|
||||||
int GetCol() { return m_col; }
|
int GetCol() { return m_col; }
|
||||||
wxControl* GetControl() { return m_ctrl; }
|
wxWindow* GetWindow() { return m_window; }
|
||||||
void SetRow(int row) { m_row = row; }
|
void SetRow(int row) { m_row = row; }
|
||||||
void SetCol(int col) { m_col = col; }
|
void SetCol(int col) { m_col = col; }
|
||||||
void SetControl(wxControl* ctrl) { m_ctrl = ctrl; }
|
void SetWindow(wxWindow* window) { m_window = window; }
|
||||||
|
|
||||||
|
// These functions exist only for backward compatibility, use Get and
|
||||||
|
// SetWindow() instead in the new code.
|
||||||
|
wxControl* GetControl() { return wxDynamicCast(m_window, wxControl); }
|
||||||
|
void SetControl(wxControl* ctrl) { m_window = ctrl; }
|
||||||
|
|
||||||
virtual wxEvent *Clone() const wxOVERRIDE { return new wxGridEditorCreatedEvent(*this); }
|
virtual wxEvent *Clone() const wxOVERRIDE { return new wxGridEditorCreatedEvent(*this); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int m_row;
|
int m_row;
|
||||||
int m_col;
|
int m_col;
|
||||||
wxControl* m_ctrl;
|
wxWindow* m_window;
|
||||||
|
|
||||||
wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxGridEditorCreatedEvent);
|
wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxGridEditorCreatedEvent);
|
||||||
};
|
};
|
||||||
|
@@ -546,14 +546,39 @@ public:
|
|||||||
*/
|
*/
|
||||||
virtual wxString GetValue() const = 0;
|
virtual wxString GetValue() const = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Get the edit window used by this editor.
|
||||||
|
|
||||||
|
@since 3.1.3
|
||||||
|
*/
|
||||||
|
wxWindow* GetWindow() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Set the wxWindow that will be used by this cell editor for editing the
|
||||||
|
value.
|
||||||
|
|
||||||
|
@since 3.1.3
|
||||||
|
*/
|
||||||
|
void SetWindow(wxWindow* window);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Get the wxControl used by this editor.
|
Get the wxControl used by this editor.
|
||||||
|
|
||||||
|
This function is preserved for compatibility, but GetWindow() should be
|
||||||
|
preferred in the new code as the associated window doesn't need to be of
|
||||||
|
a wxControl-derived class.
|
||||||
|
|
||||||
|
Note that if SetWindow() had been called with an object not deriving
|
||||||
|
from wxControl, this method will return @NULL.
|
||||||
*/
|
*/
|
||||||
wxControl* GetControl() const;
|
wxControl* GetControl() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Set the wxControl that will be used by this cell editor for editing the
|
Set the wxControl that will be used by this cell editor for editing the
|
||||||
value.
|
value.
|
||||||
|
|
||||||
|
This function is preserved for compatibility, but SetWindow() should be
|
||||||
|
preferred in the new code, see GetControl().
|
||||||
*/
|
*/
|
||||||
void SetControl(wxControl* control);
|
void SetControl(wxControl* control);
|
||||||
|
|
||||||
@@ -5286,6 +5311,13 @@ public:
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
Returns the edit control.
|
Returns the edit control.
|
||||||
|
|
||||||
|
This function is preserved for compatibility, but GetWindow() should be
|
||||||
|
preferred in the new code as the associated window doesn't need to be of
|
||||||
|
a wxControl-derived class.
|
||||||
|
|
||||||
|
Note that if SetWindow() had been called with an object not deriving
|
||||||
|
from wxControl, this method will return @NULL.
|
||||||
*/
|
*/
|
||||||
wxControl* GetControl();
|
wxControl* GetControl();
|
||||||
|
|
||||||
@@ -5294,6 +5326,13 @@ public:
|
|||||||
*/
|
*/
|
||||||
int GetRow();
|
int GetRow();
|
||||||
|
|
||||||
|
/**
|
||||||
|
Returns the edit window.
|
||||||
|
|
||||||
|
@since 3.1.3
|
||||||
|
*/
|
||||||
|
wxWindow* GetWindow();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Sets the column at which the event occurred.
|
Sets the column at which the event occurred.
|
||||||
*/
|
*/
|
||||||
@@ -5301,6 +5340,9 @@ public:
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
Sets the edit control.
|
Sets the edit control.
|
||||||
|
|
||||||
|
This function is preserved for compatibility, but SetWindow() should be
|
||||||
|
preferred in the new code, see GetControl().
|
||||||
*/
|
*/
|
||||||
void SetControl(wxControl* ctrl);
|
void SetControl(wxControl* ctrl);
|
||||||
|
|
||||||
@@ -5308,6 +5350,13 @@ public:
|
|||||||
Sets the row at which the event occurred.
|
Sets the row at which the event occurred.
|
||||||
*/
|
*/
|
||||||
void SetRow(int row);
|
void SetRow(int row);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Sets the edit window.
|
||||||
|
|
||||||
|
@since 3.1.3
|
||||||
|
*/
|
||||||
|
void SetWindow(wxWindow* window);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@@ -9333,13 +9333,13 @@ wxIMPLEMENT_DYNAMIC_CLASS(wxGridEditorCreatedEvent, wxCommandEvent);
|
|||||||
|
|
||||||
wxGridEditorCreatedEvent::wxGridEditorCreatedEvent(int id, wxEventType type,
|
wxGridEditorCreatedEvent::wxGridEditorCreatedEvent(int id, wxEventType type,
|
||||||
wxObject* obj, int row,
|
wxObject* obj, int row,
|
||||||
int col, wxControl* ctrl)
|
int col, wxWindow* window)
|
||||||
: wxCommandEvent(type, id)
|
: wxCommandEvent(type, id)
|
||||||
{
|
{
|
||||||
SetEventObject(obj);
|
SetEventObject(obj);
|
||||||
m_row = row;
|
m_row = row;
|
||||||
m_col = col;
|
m_col = col;
|
||||||
m_ctrl = ctrl;
|
m_window = window;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user