diff --git a/docs/changes.txt b/docs/changes.txt index 4d57524fd9..7fd8d7de54 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -27,6 +27,10 @@ Changes in behaviour not resulting in compilation errors - Using invalid flags with wxBoxSizer or wxGridSizer items now triggers asserts when done from the code or error messages when done in XRC. +- wxWS_EX_VALIDATE_RECURSIVELY is now the default behaviour, i.e. calling + Validate() or TransferData{From,To}Window() will now also call the same + function for all children. + - wxOSX/Carbon port doesn't exist any more, wxOSX/Cocoa will be silently used instead even if configure --with-osx_carbon option is used. diff --git a/docs/doxygen/overviews/validator.h b/docs/doxygen/overviews/validator.h index cf2b843898..580602615d 100644 --- a/docs/doxygen/overviews/validator.h +++ b/docs/doxygen/overviews/validator.h @@ -48,8 +48,8 @@ The second type of validation is performed when the dialog is about to be dismis so if the default string contained invalid characters already, a dialog box is shown giving the error, and the dialog is not dismissed. -Note that any wxWindow may have a validator; using the @c wxWS_EX_VALIDATE_RECURSIVELY -style (see wxWindow extended styles) you can also implement recursive validation. +Note that any wxWindow may have a validator and it will be used when +transferring data to or from the parent window. @see wxValidator, wxTextValidator, wxGenericValidator, wxIntegerValidator, wxFloatingPointValidator diff --git a/include/wx/defs.h b/include/wx/defs.h index 5049fa30df..d63daf8e86 100644 --- a/include/wx/defs.h +++ b/include/wx/defs.h @@ -1872,10 +1872,9 @@ enum wxBorder * should be passed to wxWindow::SetExtraStyle(), not SetWindowStyle()) */ -/* by default, TransferDataTo/FromWindow() only work on direct children of the */ -/* window (compatible behaviour), set this flag to make them recursively */ -/* descend into all subwindows */ -#define wxWS_EX_VALIDATE_RECURSIVELY 0x00000001 +/* This flag is obsolete as recursive validation is now the default (and only + * possible) behaviour. Simply don't use it any more in the new code. */ +#define wxWS_EX_VALIDATE_RECURSIVELY 0x00000000 /* used to be 1 */ /* wxCommandEvents and the objects of the derived classes are forwarded to the */ /* parent window and so on recursively by default. Using this flag for the */ diff --git a/include/wx/generic/textdlgg.h b/include/wx/generic/textdlgg.h index 8743bd7936..a3749844fd 100644 --- a/include/wx/generic/textdlgg.h +++ b/include/wx/generic/textdlgg.h @@ -27,7 +27,7 @@ class WXDLLIMPEXP_FWD_CORE wxTextCtrl; extern WXDLLIMPEXP_DATA_CORE(const char) wxGetTextFromUserPromptStr[]; extern WXDLLIMPEXP_DATA_CORE(const char) wxGetPasswordFromUserPromptStr[]; -#define wxTextEntryDialogStyle (wxOK | wxCANCEL | wxCENTRE | wxWS_EX_VALIDATE_RECURSIVELY) +#define wxTextEntryDialogStyle (wxOK | wxCANCEL | wxCENTRE) // ---------------------------------------------------------------------------- // wxTextEntryDialog: a dialog with text control, [ok] and [cancel] buttons diff --git a/interface/wx/defs.h b/interface/wx/defs.h index baf0dd7b7c..bf693f68e9 100644 --- a/interface/wx/defs.h +++ b/interface/wx/defs.h @@ -290,11 +290,6 @@ enum wxBorder * should be passed to wxWindow::SetExtraStyle(), not SetWindowStyle()) */ -/* by default, TransferDataTo/FromWindow() only work on direct children of the */ -/* window (compatible behaviour), set this flag to make them recursively */ -/* descend into all subwindows */ -#define wxWS_EX_VALIDATE_RECURSIVELY 0x00000001 - /* wxCommandEvents and the objects of the derived classes are forwarded to the */ /* parent window and so on recursively by default. Using this flag for the */ /* given window allows to block this propagation at this window, i.e. prevent */ diff --git a/interface/wx/textdlg.h b/interface/wx/textdlg.h index 911ffbf9c3..dc0283dcaf 100644 --- a/interface/wx/textdlg.h +++ b/interface/wx/textdlg.h @@ -8,7 +8,7 @@ /** Default text dialog style. */ -#define wxTextEntryDialogStyle (wxOK | wxCANCEL | wxCENTRE | wxWS_EX_VALIDATE_RECURSIVELY) +#define wxTextEntryDialogStyle (wxOK | wxCANCEL | wxCENTRE) /// Default text dialog caption. const char wxGetTextFromUserPromptStr[] = "Input Text"; diff --git a/interface/wx/window.h b/interface/wx/window.h index 9037d3dc3d..5c145e7464 100644 --- a/interface/wx/window.h +++ b/interface/wx/window.h @@ -190,11 +190,6 @@ enum wxWindowVariant @endStyleTable @beginExtraStyleTable - @style{wxWS_EX_VALIDATE_RECURSIVELY} - By default, wxWindow::Validate(), wxWindow::TransferDataTo() and - wxWindow::TransferDataFromWindow() only work on - direct children of the window (compatible behaviour). - Set this flag to make them recursively descend into all subwindows. @style{wxWS_EX_BLOCK_EVENTS} wxCommandEvents and the objects of the derived classes are forwarded to the parent window and so on recursively by default. @@ -2936,8 +2931,8 @@ public: Transfers values from child controls to data areas specified by their validators. Returns @false if a transfer failed. - If the window has @c wxWS_EX_VALIDATE_RECURSIVELY extra style flag set, - the method will also call TransferDataFromWindow() of all child windows. + Notice that this also calls TransferDataFromWindow() for all children + recursively. @see TransferDataToWindow(), wxValidator, Validate() */ @@ -2947,8 +2942,8 @@ public: Transfers values to child controls from data areas specified by their validators. - If the window has @c wxWS_EX_VALIDATE_RECURSIVELY extra style flag set, - the method will also call TransferDataToWindow() of all child windows. + Notice that this also calls TransferDataToWindow() for all children + recursively. @return Returns @false if a transfer failed. @@ -2958,8 +2953,8 @@ public: /** Validates the current values of the child controls using their validators. - If the window has @c wxWS_EX_VALIDATE_RECURSIVELY extra style flag set, - the method will also call Validate() of all child windows. + + Notice that this also calls Validate() for all children recursively. @return Returns @false if any of the validations failed. diff --git a/samples/dialogs/dialogs.cpp b/samples/dialogs/dialogs.cpp index 5f20670fd6..5ee454bb09 100644 --- a/samples/dialogs/dialogs.cpp +++ b/samples/dialogs/dialogs.cpp @@ -101,6 +101,7 @@ #include "wx/spinctrl.h" #include "wx/propdlg.h" +#include "wx/valgen.h" #include "dialogs.h" @@ -1885,7 +1886,7 @@ void MyFrame::ShowTip(wxCommandEvent& WXUNUSED(event)) #if USE_SETTINGS_DIALOG void MyFrame::OnPropertySheet(wxCommandEvent& event) { - SettingsDialog dialog(this, event.GetId()); + SettingsDialog dialog(this, m_settingsData, event.GetId()); dialog.ShowModal(); } #endif // USE_SETTINGS_DIALOG @@ -2960,9 +2961,10 @@ wxIMPLEMENT_CLASS(SettingsDialog, wxPropertySheetDialog); wxBEGIN_EVENT_TABLE(SettingsDialog, wxPropertySheetDialog) wxEND_EVENT_TABLE() -SettingsDialog::SettingsDialog(wxWindow* win, int dialogType) +SettingsDialog::SettingsDialog(wxWindow* win, SettingsData& settingsData, int dialogType) + : m_settingsData(settingsData) { - SetExtraStyle(wxDIALOG_EX_CONTEXTHELP|wxWS_EX_VALIDATE_RECURSIVELY); + SetExtraStyle(wxDIALOG_EX_CONTEXTHELP); int tabImage1 = -1; int tabImage2 = -1; @@ -3040,6 +3042,7 @@ wxPanel* SettingsDialog::CreateGeneralSettingsPage(wxWindow* parent) wxBoxSizer* itemSizer3 = new wxBoxSizer( wxHORIZONTAL ); wxCheckBox* checkBox3 = new wxCheckBox(panel, ID_LOAD_LAST_PROJECT, _("&Load last project on startup"), wxDefaultPosition, wxDefaultSize); + checkBox3->SetValidator(wxGenericValidator(&m_settingsData.m_loadLastOnStartup)); itemSizer3->Add(checkBox3, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5); item0->Add(itemSizer3, 0, wxGROW|wxALL, 0); @@ -3054,6 +3057,7 @@ wxPanel* SettingsDialog::CreateGeneralSettingsPage(wxWindow* parent) #if wxUSE_SPINCTRL wxSpinCtrl* spinCtrl12 = new wxSpinCtrl(panel, ID_AUTO_SAVE_MINS, wxEmptyString, wxDefaultPosition, wxSize(40, wxDefaultCoord), wxSP_ARROW_KEYS, 1, 60, 1); + spinCtrl12->SetValidator(wxGenericValidator(&m_settingsData.m_autoSaveInterval)); #endif itemSizer12->Add(checkBox12, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5); @@ -3067,6 +3071,7 @@ wxPanel* SettingsDialog::CreateGeneralSettingsPage(wxWindow* parent) wxBoxSizer* itemSizer8 = new wxBoxSizer( wxHORIZONTAL ); wxCheckBox* checkBox6 = new wxCheckBox(panel, ID_SHOW_TOOLTIPS, _("Show &tooltips"), wxDefaultPosition, wxDefaultSize); + checkBox6->SetValidator(wxGenericValidator(&m_settingsData.m_showToolTips)); itemSizer8->Add(checkBox6, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5); item0->Add(itemSizer8, 0, wxGROW|wxALL, 0); @@ -3091,6 +3096,7 @@ wxPanel* SettingsDialog::CreateAestheticSettingsPage(wxWindow* parent) wxRadioBox* projectOrGlobal = new wxRadioBox(panel, ID_APPLY_SETTINGS_TO, _("&Apply settings to:"), wxDefaultPosition, wxDefaultSize, 2, globalOrProjectChoices); + projectOrGlobal->SetValidator(wxGenericValidator(&m_settingsData.m_applyTo)); item0->Add(projectOrGlobal, 0, wxGROW|wxALL, 5); projectOrGlobal->SetSelection(0); @@ -3107,6 +3113,7 @@ wxPanel* SettingsDialog::CreateAestheticSettingsPage(wxWindow* parent) wxBoxSizer* itemSizer2 = new wxBoxSizer( wxHORIZONTAL ); wxChoice* choice2 = new wxChoice(panel, ID_BACKGROUND_STYLE, wxDefaultPosition, wxDefaultSize, backgroundStyleChoices); + choice2->SetValidator(wxGenericValidator(&m_settingsData.m_bgStyle)); itemSizer2->Add(new wxStaticText(panel, wxID_ANY, _("&Window:")), 0, wxALL|wxALIGN_CENTER_VERTICAL, 5); itemSizer2->Add(5, 5, 1, wxALL, 0); @@ -3122,6 +3129,7 @@ wxPanel* SettingsDialog::CreateAestheticSettingsPage(wxWindow* parent) wxSpinCtrl* spinCtrl = new wxSpinCtrl(panel, ID_FONT_SIZE, wxEmptyString, wxDefaultPosition, wxSize(80, wxDefaultCoord)); + spinCtrl->SetValidator(wxGenericValidator(&m_settingsData.m_titleFontSize)); itemSizer5->Add(spinCtrl, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5); item0->Add(itemSizer5, 0, wxGROW|wxLEFT|wxRIGHT, 5); diff --git a/samples/dialogs/dialogs.h b/samples/dialogs/dialogs.h index f3428bf56c..c3f8b4cfda 100644 --- a/samples/dialogs/dialogs.h +++ b/samples/dialogs/dialogs.h @@ -301,12 +301,34 @@ private: #if USE_SETTINGS_DIALOG + +// Struct containing properties edited by SettingsDialog. +struct SettingsData +{ + SettingsData() : + m_loadLastOnStartup(false), + m_autoSaveInterval(1), + m_showToolTips(false), + m_applyTo(0), + m_bgStyle(0), + m_titleFontSize(10) + { + } + + bool m_loadLastOnStartup; + int m_autoSaveInterval; + bool m_showToolTips; + int m_applyTo; + int m_bgStyle; + int m_titleFontSize; +}; + // Property sheet dialog class SettingsDialog: public wxPropertySheetDialog { wxDECLARE_CLASS(SettingsDialog); public: - SettingsDialog(wxWindow* parent, int dialogType); + SettingsDialog(wxWindow* parent, SettingsData& settingsData, int dialogType); ~SettingsDialog(); wxPanel* CreateGeneralSettingsPage(wxWindow* parent); @@ -327,6 +349,8 @@ protected: wxImageList* m_imageList; + SettingsData& m_settingsData; + wxDECLARE_EVENT_TABLE(); }; @@ -509,6 +533,10 @@ private: *m_infoBarAdvanced; #endif // wxUSE_INFOBAR +#if USE_SETTINGS_DIALOG + SettingsData m_settingsData; +#endif // USE_SETTINGS_DIALOG + wxDECLARE_EVENT_TABLE(); }; diff --git a/src/common/dlgcmn.cpp b/src/common/dlgcmn.cpp index 3d97fbb64a..5067471b11 100644 --- a/src/common/dlgcmn.cpp +++ b/src/common/dlgcmn.cpp @@ -78,7 +78,6 @@ wxFLAGS_MEMBER(wxTAB_TRAVERSAL) wxFLAGS_MEMBER(wxCLIP_CHILDREN) // dialog styles -wxFLAGS_MEMBER(wxWS_EX_VALIDATE_RECURSIVELY) wxFLAGS_MEMBER(wxSTAY_ON_TOP) wxFLAGS_MEMBER(wxCAPTION) wxFLAGS_MEMBER(wxSYSTEM_MENU) diff --git a/src/common/wincmn.cpp b/src/common/wincmn.cpp index 4f2a0b3d29..d9f52733c7 100644 --- a/src/common/wincmn.cpp +++ b/src/common/wincmn.cpp @@ -422,14 +422,6 @@ bool wxWindowBase::CreateBase(wxWindowBase *parent, SetValidator(validator); #endif // wxUSE_VALIDATORS - // if the parent window has wxWS_EX_VALIDATE_RECURSIVELY set, we want to - // have it too - like this it's possible to set it only in the top level - // dialog/frame and all children will inherit it by defult - if ( parent && (parent->GetExtraStyle() & wxWS_EX_VALIDATE_RECURSIVELY) ) - { - SetExtraStyle(GetExtraStyle() | wxWS_EX_VALIDATE_RECURSIVELY); - } - return true; } @@ -2036,12 +2028,9 @@ public: } // Traverse all the direct children calling OnDo() on them and also all - // grandchildren if wxWS_EX_VALIDATE_RECURSIVELY is used, calling - // OnRecurse() for them. + // grandchildren, calling OnRecurse() for them. bool DoForAllChildren() { - const bool recurse = m_win->HasExtraStyle(wxWS_EX_VALIDATE_RECURSIVELY); - wxWindowList& children = m_win->GetChildren(); for ( wxWindowList::iterator i = children.begin(); i != children.end(); @@ -2057,7 +2046,7 @@ public: // Notice that validation should never recurse into top level // children, e.g. some other dialog which might happen to be // currently shown. - if ( recurse && !child->IsTopLevel() && !OnRecurse(child) ) + if ( !child->IsTopLevel() && !OnRecurse(child) ) { return false; } diff --git a/src/generic/preferencesg.cpp b/src/generic/preferencesg.cpp index c75ac4caa7..fc6fc0cc34 100644 --- a/src/generic/preferencesg.cpp +++ b/src/generic/preferencesg.cpp @@ -48,8 +48,6 @@ public: wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE & ~(wxRESIZE_BORDER | wxMAXIMIZE_BOX | wxMINIMIZE_BOX)) { - SetExtraStyle(wxWS_EX_VALIDATE_RECURSIVELY); - wxSizer *sizer = new wxBoxSizer(wxVERTICAL); m_notebook = new wxNotebook(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxNB_MULTILINE); diff --git a/src/osx/cocoa/preferences.mm b/src/osx/cocoa/preferences.mm index 534da38010..2590bd24df 100644 --- a/src/osx/cocoa/preferences.mm +++ b/src/osx/cocoa/preferences.mm @@ -62,12 +62,6 @@ public: m_toolbarRealized(false), m_visiblePage(NULL) { - // For consistency with the generic version, transfer data recursively: - // this ensures that all controls, even deep inside our pages, get - // correct values from their validators initially and transfer them - // back at the end. - SetExtraStyle(wxWS_EX_VALIDATE_RECURSIVELY); - m_toolbar = new wxToolBar(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTB_FLAT | wxTB_TEXT); m_toolbar->SetToolBitmapSize(wxSize(32,32)); diff --git a/src/richtext/richtextbackgroundpage.cpp b/src/richtext/richtextbackgroundpage.cpp index 6acf9f3b8b..b39b99d631 100644 --- a/src/richtext/richtextbackgroundpage.cpp +++ b/src/richtext/richtextbackgroundpage.cpp @@ -74,7 +74,6 @@ wxRichTextBackgroundPage::wxRichTextBackgroundPage( wxWindow* parent, wxWindowID bool wxRichTextBackgroundPage::Create( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style ) { ////@begin wxRichTextBackgroundPage creation - SetExtraStyle(wxWS_EX_VALIDATE_RECURSIVELY); wxRichTextDialogPage::Create( parent, id, pos, size, style ); CreateControls(); diff --git a/src/richtext/richtextborderspage.cpp b/src/richtext/richtextborderspage.cpp index 0d56833f9e..3e05476c05 100644 --- a/src/richtext/richtextborderspage.cpp +++ b/src/richtext/richtextborderspage.cpp @@ -122,7 +122,6 @@ wxRichTextBordersPage::wxRichTextBordersPage( wxWindow* parent, wxWindowID id, c bool wxRichTextBordersPage::Create( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style ) { ////@begin wxRichTextBordersPage creation - SetExtraStyle(wxWS_EX_VALIDATE_RECURSIVELY); wxRichTextDialogPage::Create( parent, id, pos, size, style ); CreateControls(); @@ -221,7 +220,6 @@ void wxRichTextBordersPage::CreateControls() wxNotebook* itemNotebook4 = new wxNotebook( itemRichTextDialogPage1, ID_RICHTEXTBORDERSPAGE_NOTEBOOK, wxDefaultPosition, wxDefaultSize, wxBK_DEFAULT ); wxPanel* itemPanel5 = new wxPanel( itemNotebook4, ID_RICHTEXTBORDERSPAGE_BORDERS, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); - itemPanel5->SetExtraStyle(wxWS_EX_VALIDATE_RECURSIVELY); wxBoxSizer* itemBoxSizer6 = new wxBoxSizer(wxVERTICAL); itemPanel5->SetSizer(itemBoxSizer6); @@ -390,7 +388,6 @@ void wxRichTextBordersPage::CreateControls() itemNotebook4->AddPage(itemPanel5, _("Border")); wxPanel* itemPanel48 = new wxPanel( itemNotebook4, ID_RICHTEXTBORDERSPAGE_OUTLINE, wxDefaultPosition, wxDefaultSize, wxNO_BORDER|wxTAB_TRAVERSAL ); - itemPanel48->SetExtraStyle(wxWS_EX_VALIDATE_RECURSIVELY); wxBoxSizer* itemBoxSizer49 = new wxBoxSizer(wxVERTICAL); itemPanel48->SetSizer(itemBoxSizer49); diff --git a/src/richtext/richtextformatdlg.cpp b/src/richtext/richtextformatdlg.cpp index b6733d6d34..30017cf012 100644 --- a/src/richtext/richtextformatdlg.cpp +++ b/src/richtext/richtextformatdlg.cpp @@ -115,7 +115,7 @@ wxRichTextFormattingDialog::~wxRichTextFormattingDialog() bool wxRichTextFormattingDialog::Create(long flags, wxWindow* parent, const wxString& title, wxWindowID id, const wxPoint& pos, const wxSize& sz, long style) { - SetExtraStyle(wxDIALOG_EX_CONTEXTHELP|wxWS_EX_VALIDATE_RECURSIVELY|wxWS_EX_BLOCK_EVENTS); + SetExtraStyle(wxDIALOG_EX_CONTEXTHELP|wxWS_EX_BLOCK_EVENTS); #ifdef __WXMAC__ SetWindowVariant(wxWINDOW_VARIANT_SMALL); #endif