Make wxWS_EX_VALIDATE_RECURSIVELY default (and only) behaviour
In practice, almost everybody using validators also seems to use this style, so make it the default (this hadn't been done when it was originally introduced because of compatibility concerns, but now, 15+ years later, it's probably safe enough to change this).
This commit is contained in:
parent
088d8cbed5
commit
d50abc2d3e
@ -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.
|
||||
|
||||
|
@ -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
|
||||
|
@ -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 */
|
||||
|
@ -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
|
||||
|
@ -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 */
|
||||
|
@ -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";
|
||||
|
@ -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.
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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();
|
||||
};
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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));
|
||||
|
@ -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();
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user