mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-07-24 11:22:07 +00:00
ENH: vertical layout button
Change-Id: I0b205298688c9df88dcfe6eb6e72cc887a9ed5be Jira: none (cherry picked from commit 56ed912c3ee12fb0ee39f1dad191c4d379aa3015)
This commit is contained in:
@@ -117,11 +117,12 @@ public:
|
||||
Wrap(dc, text, widthMax);
|
||||
}
|
||||
|
||||
void Wrap(wxDC const & dc, const wxString &text, int widthMax)
|
||||
void Wrap(wxDC const &dc, const wxString &text, int widthMax, int maxCount = 0)
|
||||
{
|
||||
const wxArrayString ls = wxSplit(text, '\n', '\0');
|
||||
for (wxArrayString::const_iterator i = ls.begin(); i != ls.end(); ++i) {
|
||||
wxString line = *i;
|
||||
int count = 0;
|
||||
|
||||
if (i != ls.begin()) {
|
||||
// Do this even if the line is empty, except if it's the first one.
|
||||
@@ -181,6 +182,12 @@ public:
|
||||
// And redo the layout with the rest.
|
||||
if (line[lastSpace] == ' ') ++lastSpace;
|
||||
line = line.substr(lastSpace);
|
||||
|
||||
if (maxCount > 0 && ++count == maxCount - 1) {
|
||||
OnNewLine();
|
||||
DoOutputLine(line);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -246,10 +253,10 @@ private:
|
||||
};
|
||||
|
||||
|
||||
wxSize Label::split_lines(wxDC &dc, int width, const wxString &text, wxString &multiline_text)
|
||||
wxSize Label::split_lines(wxDC &dc, int width, const wxString &text, wxString &multiline_text, int max_count)
|
||||
{
|
||||
wxLabelWrapper2 wrap;
|
||||
wrap.Wrap(dc, text, width);
|
||||
wrap.Wrap(dc, text, width, max_count);
|
||||
multiline_text = wrap.GetText();
|
||||
return dc.GetMultiLineTextExtent(multiline_text);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user