class WXDLLIMPEXP_FWD_CORE wxDialog;
class WXDLLIMPEXP_FWD_CORE wxButton;
class WXDLLIMPEXP_FWD_CORE wxScrolledWindow;
+class wxTextSizerWrapper;
// Also see the bit summary table in wx/toplevel.h.
}
#if wxUSE_STATTEXT // && wxUSE_TEXTCTRL
- // splits text up at newlines and places the
- // lines into a vertical wxBoxSizer
- wxSizer *CreateTextSizer( const wxString &message );
+ // splits text up at newlines and places the lines into a vertical
+ // wxBoxSizer
+ wxSizer *CreateTextSizer( const wxString& message );
+
+ // same as above but uses a customized wxTextSizerWrapper to create
+ // non-standard controls for the lines
+ wxSizer *CreateTextSizer( const wxString& message,
+ wxTextSizerWrapper& wrapper );
#endif // wxUSE_STATTEXT // && wxUSE_TEXTCTRL
// returns a horizontal wxBoxSizer containing the given buttons
wxDECLARE_NO_COPY_CLASS(wxTextWrapper);
};
+#if wxUSE_STATTEXT
+
+#include "wx/sizer.h"
+#include "wx/stattext.h"
+
+// A class creating a sizer with one static text per line of text. Creation of
+// the controls used for each line can be customized by overriding
+// OnCreateLine() function.
+//
+// This class is currently private to wxWidgets and used only by wxDialog
+// itself. We may make it public later if there is sufficient interest.
+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;
+ }
+
+ wxWindow *GetParent() const { return m_win; }
+
+protected:
+ virtual wxWindow *OnCreateLine(const wxString& line)
+ {
+ return new wxStaticText(m_win, wxID_ANY, line);
+ }
+
+ virtual void OnOutputLine(const wxString& line)
+ {
+ if ( !line.empty() )
+ {
+ m_sizer->Add(OnCreateLine(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;
+};
+
+#endif // wxUSE_STATTEXT
+
#endif // _WX_TEXTWRAPPER_H_
#if wxUSE_STATTEXT
-class wxTextSizerWrapper : public wxTextWrapper
+wxSizer *wxDialogBase::CreateTextSizer(const wxString& message)
{
-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);
- }
- }
+ wxTextSizerWrapper wrapper(this);
-private:
- wxWindow *m_win;
- wxSizer *m_sizer;
- int m_hLine;
-};
+ return CreateTextSizer(message, wrapper);
+}
-wxSizer *wxDialogBase::CreateTextSizer(const wxString& message)
+wxSizer *wxDialogBase::CreateTextSizer(const wxString& message,
+ wxTextSizerWrapper& wrapper)
{
// I admit that this is complete bogus, but it makes
// message boxes work for pda screens temporarily..
wxString text(message);
text.Replace(wxT("&"), wxT("&&"));
- wxTextSizerWrapper wrapper(this);
-
return wrapper.CreateSizer(text, widthMax);
}
#define __WX_COMPILING_MSGDLGG_CPP__ 1
#include "wx/msgdlg.h"
#include "wx/artprov.h"
+#include "wx/textwrapper.h"
#if wxUSE_STATLINE
#include "wx/statline.h"
#endif
+// ----------------------------------------------------------------------------
+// wxTitleTextWrapper: simple class to create wrapped text in "title font"
+// ----------------------------------------------------------------------------
+
+class wxTitleTextWrapper : public wxTextSizerWrapper
+{
+public:
+ wxTitleTextWrapper(wxWindow *win)
+ : wxTextSizerWrapper(win)
+ {
+ }
+
+protected:
+ virtual wxWindow *OnCreateLine(const wxString& s)
+ {
+ wxWindow * const win = wxTextSizerWrapper::OnCreateLine(s);
+
+ win->SetFont(win->GetFont().Larger().MakeBold());
+
+ return win;
+ }
+};
+
// ----------------------------------------------------------------------------
// icons
// ----------------------------------------------------------------------------
#if wxUSE_STATTEXT
// 2) text
- icon_text->Add( CreateTextSizer( GetFullMessage() ), 0, wxALIGN_CENTER | wxLEFT, 10 );
+ wxBoxSizer * const textsizer = new wxBoxSizer(wxVERTICAL);
+
+ // We want to show the main message in a different font to make it stand
+ // out if the extended message is used as well. This looks better and is
+ // more consistent with the native dialogs under MSW and GTK.
+ wxString lowerMessage;
+ if ( !m_extendedMessage.empty() )
+ {
+ wxTitleTextWrapper titleWrapper(this);
+ textsizer->Add(CreateTextSizer(GetMessage(), titleWrapper),
+ wxSizerFlags().Border(wxBOTTOM, 20));
+
+ lowerMessage = GetExtendedMessage();
+ }
+ else // no extended message
+ {
+ lowerMessage = GetMessage();
+ }
+
+ textsizer->Add(CreateTextSizer(lowerMessage));
+
+ icon_text->Add(textsizer, 0, wxALIGN_CENTER, 10);
topsizer->Add( icon_text, 1, wxCENTER | wxLEFT|wxRIGHT|wxTOP, 10 );
#endif // wxUSE_STATTEXT