OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
wxLabelWrapper2 Class Reference
Inheritance diagram for wxLabelWrapper2:
Collaboration diagram for wxLabelWrapper2:

Public Member Functions

void WrapLabel (wxDC const &dc, wxString const &label, int widthMax)
void WrapLabel (wxWindow *text, wxString const &label, int widthMax)
wxString GetText () const
void Wrap (wxWindow *win, const wxString &text, int widthMax)
void Wrap (wxDC const &dc, const wxString &text, int widthMax, int maxCount=0)

Protected Member Functions

virtual void OnOutputLine (const wxString &line) wxOVERRIDE
virtual void OnNewLine () wxOVERRIDE

Private Member Functions

void DoOutputLine (const wxString &line)
bool IsStartOfNewLine ()

Private Attributes

wxString m_text
bool m_eol

Detailed Description

Member Function Documentation

◆ DoOutputLine()

void wxTextWrapper2::DoOutputLine ( const wxString & line)
inlineprivateinherited
245 {
246 OnOutputLine(line);
247
248 m_eol = true;
249 }
bool m_eol
Definition Label.cpp:263
virtual void OnOutputLine(const wxString &line)=0

References m_eol, and OnOutputLine().

Referenced by Wrap().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetText()

wxString wxLabelWrapper2::GetText ( ) const
inline
281{ return m_text; }
wxString m_text
Definition Label.cpp:289

References m_text.

Referenced by Label::split_lines(), and Label::Wrap().

Here is the caller graph for this function:

◆ IsStartOfNewLine()

bool wxTextWrapper2::IsStartOfNewLine ( )
inlineprivateinherited
255 {
256 if (!m_eol) return false;
257
258 m_eol = false;
259
260 return true;
261 }

References m_eol.

◆ OnNewLine()

virtual void wxLabelWrapper2::OnNewLine ( )
inlineprotectedvirtual

Reimplemented from wxTextWrapper2.

286{ m_text += wxT('\n'); }

References m_text.

◆ OnOutputLine()

virtual void wxLabelWrapper2::OnOutputLine ( const wxString & line)
inlineprotectedvirtual

Implements wxTextWrapper2.

284{ m_text += line; }

References m_text.

◆ Wrap() [1/2]

void wxTextWrapper2::Wrap ( wxDC const & dc,
const wxString & text,
int widthMax,
int maxCount = 0 )
inlineinherited
158 {
159 const wxArrayString ls = wxSplit(text, '\n', '\0');
160 for (wxArrayString::const_iterator i = ls.begin(); i != ls.end(); ++i) {
161 wxString line = *i;
162 int count = 0;
163
164 if (i != ls.begin()) {
165 // Do this even if the line is empty, except if it's the first one.
166 OnNewLine();
167 }
168
169 // Is this a special case when wrapping is disabled?
170 if (widthMax < 0) {
171 DoOutputLine(line);
172 continue;
173 }
174
175 for (bool newLine = false; !line.empty(); newLine = true) {
176 if (newLine) OnNewLine();
177
178 if (1 == line.length()) {
179 DoOutputLine(line);
180 break;
181 }
182
183 wxArrayInt widths;
184 dc.GetPartialTextExtents(line, widths);
185
186 const size_t posEnd = std::lower_bound(widths.begin(), widths.end(), widthMax) - widths.begin();
187
188 // Does the entire remaining line fit?
189 if (posEnd == line.length()) {
190 DoOutputLine(line);
191 break;
192 }
193
194 // Find the last word to chop off.
195 size_t lastSpace = posEnd;
196 while (lastSpace > 0) {
197 auto c = line[lastSpace];
198 if (c == ' ')
199 break;
200 if (c > 0x4E00) {
201 if (lastSpace != posEnd)
202 ++lastSpace;
203 break;
204 }
205 --lastSpace;
206 }
207 if (lastSpace == 0) {
208 // No spaces, so can't wrap.
209 lastSpace = posEnd;
210 }
211 if (lastSpace == 0) {
212 // Break at least one char
213 lastSpace = 1;
214 }
215
216 // Output the part that fits.
217 DoOutputLine(line.substr(0, lastSpace));
218
219 // And redo the layout with the rest.
220 if (line[lastSpace] == ' ') ++lastSpace;
221 line = line.substr(lastSpace);
222
223 if (maxCount > 0 && ++count == maxCount - 1) {
224 OnNewLine();
225 DoOutputLine(line);
226 break;
227 }
228 }
229 }
230 }
static unsigned int count
Definition AuxiliaryDataViewModel.cpp:246
void DoOutputLine(const wxString &line)
Definition Label.cpp:244
virtual void OnNewLine()
Definition Label.cpp:240

References count, DoOutputLine(), and OnNewLine().

Here is the call graph for this function:

◆ Wrap() [2/2]

void wxTextWrapper2::Wrap ( wxWindow * win,
const wxString & text,
int widthMax )
inlineinherited
152 {
153 const wxClientDC dc(win);
154 Wrap(dc, text, widthMax);
155 }
void Wrap(wxWindow *win, const wxString &text, int widthMax)
Definition Label.cpp:151

References Wrap().

Referenced by Label::split_lines(), Label::Wrap(), Wrap(), wxLabelWrapper2::WrapLabel(), and wxLabelWrapper2::WrapLabel().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ WrapLabel() [1/2]

void wxLabelWrapper2::WrapLabel ( wxDC const & dc,
wxString const & label,
int widthMax )
inline
270 {
271 m_text.clear();
272 Wrap(dc, label, widthMax);
273 }

References m_text, and wxTextWrapper2::Wrap().

Here is the call graph for this function:

◆ WrapLabel() [2/2]

void wxLabelWrapper2::WrapLabel ( wxWindow * text,
wxString const & label,
int widthMax )
inline
276 {
277 m_text.clear();
278 Wrap(text, label, widthMax);
279 }

References m_text, and wxTextWrapper2::Wrap().

Here is the call graph for this function:

Member Data Documentation

◆ m_eol

bool wxTextWrapper2::m_eol
privateinherited

◆ m_text

wxString wxLabelWrapper2::m_text
private

The documentation for this class was generated from the following file:
  • /home/runner/work/OrcaSlicer/OrcaSlicer/src/slic3r/GUI/Widgets/Label.cpp