X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/255c07b4df512ff4f844f4d604787b5ea8999530..fe94d0d06a2305845f0cb0c0b8fc0edbde2e2b68:/include/wx/textwrapper.h diff --git a/include/wx/textwrapper.h b/include/wx/textwrapper.h index cb2c0972f8..a708cebd75 100644 --- a/include/wx/textwrapper.h +++ b/include/wx/textwrapper.h @@ -3,7 +3,6 @@ // Purpose: declaration of wxTextWrapper class // Author: Vadim Zeitlin // Created: 2009-05-31 (extracted from dlgcmn.cpp via wx/private/stattext.h) -// RCS-ID: $Id$ // Copyright: (c) 1999, 2009 Vadim Zeitlin // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -11,13 +10,15 @@ #ifndef _WX_TEXTWRAPPER_H_ #define _WX_TEXTWRAPPER_H_ +#include "wx/window.h" + // ---------------------------------------------------------------------------- // wxTextWrapper // ---------------------------------------------------------------------------- // this class is used to wrap the text on word boundary: wrapping is done by // calling OnStartLine() and OnOutputLine() functions -class wxTextWrapper +class WXDLLIMPEXP_CORE wxTextWrapper { public: wxTextWrapper() { m_eol = false; } @@ -64,5 +65,64 @@ private: 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, + wxControl::EscapeMnemonics(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_