X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/dec48aa578d886cf26559dc80141fac5f628ff08..224021239085a3c1d71fc865c14ee45e1adc87f2:/src/common/dlgcmn.cpp diff --git a/src/common/dlgcmn.cpp b/src/common/dlgcmn.cpp index 91e11accb1..ba4e88cbbe 100644 --- a/src/common/dlgcmn.cpp +++ b/src/common/dlgcmn.cpp @@ -17,10 +17,6 @@ // headers // ---------------------------------------------------------------------------- -#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) - #pragma implementation "dialogbase.h" -#endif - // For compilers that support precompilation, includes "wx.h". #include "wx/wxprec.h" @@ -112,7 +108,8 @@ void wxDialogBase::Init() { m_returnCode = 0; m_affirmativeId = wxID_OK; - + m_escapeId = wxID_ANY; + // the dialogs have this flag on by default to prevent the events from the // dialog controls from reaching the parent frame which is usually // undesirable and can lead to unexpected and hard to find bugs @@ -177,6 +174,44 @@ void wxTextWrapper::Wrap(wxWindow *win, const wxString& text, int widthMax) } } +class wxTextSizerWrapper : public wxTextWrapper +{ +public: + wxTextSizerWrapper(wxWindow *win) + { + m_win = win; + m_hLine = 0; + } + + wxSizer *CreateSizer(const wxString& text, int widthMax) + { + m_sizer = new wxBoxSizer(wxVERTICAL); + Wrap(m_win, text, widthMax); + return m_sizer; + } + +protected: + virtual void OnOutputLine(const wxString& line) + { + if ( !line.empty() ) + { + m_sizer->Add(new wxStaticText(m_win, wxID_ANY, line)); + } + else // empty line, no need to create a control for it + { + if ( !m_hLine ) + m_hLine = m_win->GetCharHeight(); + + m_sizer->Add(5, m_hLine); + } + } + +private: + wxWindow *m_win; + wxSizer *m_sizer; + int m_hLine; +}; + wxSizer *wxDialogBase::CreateTextSizer(const wxString& message) { // I admit that this is complete bogus, but it makes @@ -194,84 +229,45 @@ wxSizer *wxDialogBase::CreateTextSizer(const wxString& message) wxString text(message); text.Replace(_T("&"), _T("&&")); + wxTextSizerWrapper wrapper(this); - class TextSizerWrapper : public wxTextWrapper - { - public: - TextSizerWrapper(wxWindow *win) - { - m_win = win; - m_hLine = 0; - } - - wxSizer *CreateSizer(const wxString& text, int widthMax) - { - m_sizer = new wxBoxSizer(wxVERTICAL); - Wrap(m_win, text, widthMax); - return m_sizer; - } - - protected: - virtual void OnOutputLine(const wxString& line) - { - if ( !line.empty() ) - { - m_sizer->Add(new wxStaticText(m_win, wxID_ANY, line)); - } - else // empty line, no need to create a control for it - { - if ( !m_hLine ) - m_hLine = m_win->GetCharHeight(); + return wrapper.CreateSizer(text, widthMax); +} - m_sizer->Add(5, m_hLine); - } - } +class wxLabelWrapper : public wxTextWrapper +{ +public: + void WrapLabel(wxWindow *text, int widthMax) + { + m_text.clear(); + Wrap(text, text->GetLabel(), widthMax); + text->SetLabel(m_text); + } - private: - wxWindow *m_win; - wxSizer *m_sizer; - int m_hLine; - }; +protected: + virtual void OnOutputLine(const wxString& line) + { + m_text += line; + } - TextSizerWrapper wrapper(this); + virtual void OnNewLine() + { + m_text += _T('\n'); + } - return wrapper.CreateSizer(text, widthMax); -} +private: + wxString m_text; +}; void -#ifdef __WXGTK__ +#if defined(__WXGTK__) && !defined(__WXUNIVERSAL__) wxStaticText #else wxStaticTextBase #endif ::Wrap(int width) { - class LabelWrapper : public wxTextWrapper - { - public: - void WrapLabel(wxWindow *text, int widthMax) - { - m_text.clear(); - Wrap(text, text->GetLabel(), widthMax); - text->SetLabel(m_text); - } - - protected: - virtual void OnOutputLine(const wxString& line) - { - m_text += line; - } - - virtual void OnNewLine() - { - m_text += _T('\n'); - } - - private: - wxString m_text; - }; - - LabelWrapper wrapper; + wxLabelWrapper wrapper; wrapper.WrapLabel(this, width); } @@ -337,8 +333,6 @@ wxStdDialogButtonSizer *wxDialogBase::CreateStdDialogButtonSizer( long flags ) sizer->AddButton(help); } - sizer->Realize(); - if (flags & wxNO_DEFAULT) { if (no) @@ -360,12 +354,14 @@ wxStdDialogButtonSizer *wxDialogBase::CreateStdDialogButtonSizer( long flags ) yes->SetFocus(); } } - + if (flags & wxOK) SetAffirmativeId(wxID_OK); else if (flags & wxYES) SetAffirmativeId(wxID_YES); + sizer->Realize(); + return sizer; }