Here is an example function using this class which inserts hard line breaks
into a string of text at the positions where it would be wrapped:
+
@code
-wxString WrapText(wxWindow *win, const wxString& text, int widthMax)
-{
- class HardBreakWrapper : public wxTextWrapper
+ wxString WrapText(wxWindow *win, const wxString& text, int widthMax)
{
- public:
- HardBreakWrapper(wxWindow *win, const wxString& text, int widthMax)
- {
- Wrap(win, text, widthMax);
- }
-
- wxString const& GetWrapped() const { return m_wrapped; }
-
- protected:
- virtual void OnOutputLine(const wxString& line)
+ class HardBreakWrapper : public wxTextWrapper
{
- m_wrapped += line;
- }
-
- virtual void OnNewLine()
- {
- m_wrapped += '\n';
- }
-
- private:
- wxString m_wrapped;
- };
-
- HardBreakWrapper wrapper(win, text, widthMax);
- return wrapper.GetWrapped();
-}
+ public:
+ HardBreakWrapper(wxWindow *win, const wxString& text, int widthMax)
+ {
+ Wrap(win, text, widthMax);
+ }
+
+ wxString const& GetWrapped() const { return m_wrapped; }
+
+ protected:
+ virtual void OnOutputLine(const wxString& line)
+ {
+ m_wrapped += line;
+ }
+
+ virtual void OnNewLine()
+ {
+ m_wrapped += '\n';
+ }
+
+ private:
+ wxString m_wrapped;
+ };
+
+ HardBreakWrapper wrapper(win, text, widthMax);
+ return wrapper.GetWrapped();
+ }
@endcode
- @library{none}
+ @nolibrary
@category{gdi}
*/
class wxTextWrapper