Make wxValidator::SetWindow() virtual
Allow overriding the method called when the validator is associated with the window, this can be convenient to perform some initialization on the validator instance actually used as it can't be done on the initially created object itself because it will be cloned by SetValidator(), creating a new instance. Also change SetWindow() to take wxWindow instead of wxWindowBase, this still requires the cast in wxWindow::SetValidator(), but it's better to have it there rather than in wxValidator and use the simpler type in the public function signature.
This commit is contained in:
@@ -62,9 +62,12 @@ public:
|
||||
// Called to transfer data from the window
|
||||
virtual bool TransferFromWindow() { return false; }
|
||||
|
||||
// Called when the validator is associated with a window, may be useful to
|
||||
// override if it needs to somehow initialize the window.
|
||||
virtual void SetWindow(wxWindow *win) { m_validatorWindow = win; }
|
||||
|
||||
// accessors
|
||||
wxWindow *GetWindow() const { return (wxWindow *)m_validatorWindow; }
|
||||
void SetWindow(wxWindowBase *win) { m_validatorWindow = win; }
|
||||
wxWindow *GetWindow() const { return m_validatorWindow; }
|
||||
|
||||
// validators beep by default if invalid key is pressed, this function
|
||||
// allows to change this
|
||||
@@ -85,7 +88,7 @@ public:
|
||||
#endif
|
||||
|
||||
protected:
|
||||
wxWindowBase *m_validatorWindow;
|
||||
wxWindow *m_validatorWindow;
|
||||
|
||||
private:
|
||||
static bool ms_isSilent;
|
||||
|
Reference in New Issue
Block a user