#include <MessageDialog.hh>
|
wxString | wordWrap (const wxString &string, unsigned int lineWidth) |
|
wxString | suppressLines (const wxString &string, int maxLines) |
|
MessageDialog is base class for all dialogs diaplaying a simple text message. MessageDialog extends wxMessageDialog functionality by word wrapping long lines to multiple lines, and suppressing lines of very long messages.
Definition at line 44 of file MessageDialog.hh.
◆ MessageDialog()
MessageDialog::MessageDialog |
( |
wxWindow * |
parent, |
|
|
const wxString & |
title, |
|
|
const wxString & |
message, |
|
|
long |
style |
|
) |
| |
◆ ~MessageDialog()
MessageDialog::~MessageDialog |
( |
| ) |
|
|
virtual |
◆ suppressLines()
wxString MessageDialog::suppressLines |
( |
const wxString & |
string, |
|
|
int |
maxLines |
|
) |
| |
|
private |
Truncates a string to given number of lines. If lines are suppressed, text '[n lines suppressed.]' is appended to the truncated string, where n is the number of lines suppressd.
- Parameters
-
string | String to truncate. |
maxLines | Maximum number of lines. |
- Returns
- Truncated string.
Definition at line 131 of file MessageDialog.cc.
136 wxStringTokenizer lines(
137 string, _T(
"\n"), wxTOKEN_RET_EMPTY|wxTOKEN_RET_DELIMS);
139 while (lineCount < maxLines && lines.HasMoreTokens()) {
142 truncated.Append(lines.GetNextToken());
145 if (!lines.HasMoreTokens()) {
151 while (lines.HasMoreTokens()) {
153 lines.GetNextToken();
157 truncated.Append(_T(
"\n [ "));
159 truncated.Append(_T(
" lines suppressed.]"));
References WxConversion::toWxString().
◆ wordWrap()
wxString MessageDialog::wordWrap |
( |
const wxString & |
string, |
|
|
unsigned int |
lineWidth |
|
) |
| |
|
private |
Wraps lines longer than given width to multiple lines. Existing line breaks aren't modified, but are taken to account when determining line lengths. Lines are wrapped at word boundaries only, unless a word is longer than the given line width.
- Parameters
-
string | String to wrap. |
lineWidth | Maximum line width. |
- Returns
- Word wrapped string.
Definition at line 80 of file MessageDialog.cc.
83 wxStringTokenizer lines(
string, _T(
"\n"), wxTOKEN_RET_EMPTY);
85 while (lines.HasMoreTokens()) {
87 wxString line = lines.GetNextToken();
88 wxStringTokenizer words(line, _T(
" \t"), wxTOKEN_RET_DELIMS);
91 while (words.HasMoreTokens()) {
93 wxString word = words.GetNextToken();
94 if (length + word.length() < lineWidth) {
96 wrappedLine.Append(word);
97 length = length + word.length();
98 }
else if (word.length() < lineWidth) {
101 wrappedLine.Append(_(
" \n"));
102 wrappedLine.Append(word);
103 length = word.length();
107 for (; i < word.length(); i = i + (lineWidth - 1)) {
108 wrappedLine.Append(_T(
" \n"));
109 wrappedLine.Append(word.Mid(i, lineWidth - 1));
110 length = word.length() - i;
114 wrappedLine.Append(_T(
"\n"));
115 wrapped.Append(wrappedLine);
The documentation for this class was generated from the following files: