diff options
| author | build.powdertoy.co.uk <admin@powdertoy.co.uk> | 2012-07-20 19:10:56 (GMT) |
|---|---|---|
| committer | build.powdertoy.co.uk <admin@powdertoy.co.uk> | 2012-07-20 19:10:56 (GMT) |
| commit | e77a43d9a4c8c149b26037ce0751bb944c63b3c4 (patch) | |
| tree | 411058fe9d2a8e0d034c3d9eb64dd831ecfa9f5e /src/interface | |
| parent | d328b84b1330b0e8f3a7f87ce48b9b20ea4b6d01 (diff) | |
| parent | 0064152442cef712e940b1abce246da9c698f6d3 (diff) | |
| download | powder-e77a43d9a4c8c149b26037ce0751bb944c63b3c4.zip powder-e77a43d9a4c8c149b26037ce0751bb944c63b3c4.tar.gz | |
Merge branch 'master' of github.com:FacialTurd/PowderToypp
Diffstat (limited to 'src/interface')
| -rw-r--r-- | src/interface/Label.cpp | 65 | ||||
| -rw-r--r-- | src/interface/Textbox.cpp | 2 |
2 files changed, 40 insertions, 27 deletions
diff --git a/src/interface/Label.cpp b/src/interface/Label.cpp index 35b2000..76ea45f 100644 --- a/src/interface/Label.cpp +++ b/src/interface/Label.cpp @@ -48,40 +48,51 @@ void Label::SetText(std::string text) void Label::updateMultiline() { - char * rawText = new char[text.length()+1]; - std::copy(text.begin(), text.end(), rawText); - rawText[text.length()] = 0; - int lines = 1; - int currentWidth = 0; - char * lastSpace = NULL; - char * currentWord = rawText; - char * nextSpace; - while(true) + if(text.length()>0) { - nextSpace = strchr(currentWord+1, ' '); - if(nextSpace) - nextSpace[0] = 0; - int width = Graphics::textwidth(currentWord); - if(width+currentWidth > Size.X-6) + char * rawText = new char[text.length()+1]; + std::copy(text.begin(), text.end(), rawText); + rawText[text.length()] = 0; + + int currentWidth = 0; + char * lastSpace = NULL; + char * currentWord = rawText; + char * nextSpace; + while(true) { - currentWidth = width; - currentWord[0] = '\n'; - lines++; + nextSpace = strchr(currentWord+1, ' '); + if(nextSpace) + nextSpace[0] = 0; + int width = Graphics::textwidth(currentWord); + if(width+currentWidth > Size.X-6) + { + currentWidth = width; + currentWord[0] = '\n'; + lines++; + } + else + currentWidth += width; + if(nextSpace) + nextSpace[0] = ' '; + if(!currentWord[0] || !currentWord[1] || !(currentWord = strchr(currentWord+1, ' '))) + break; } - else - currentWidth += width; - if(nextSpace) - nextSpace[0] = ' '; - if(!(currentWord = strchr(currentWord+1, ' '))) - break; + if(autoHeight) + { + Size.Y = lines*12; + } + textLines = std::string(rawText); + delete[] rawText; } - if(autoHeight) + else { - Size.Y = lines*12; + if(autoHeight) + { + Size.Y = 12; + } + textLines = std::string(""); } - textLines = std::string(rawText); - delete[] rawText; } std::string Label::GetText() diff --git a/src/interface/Textbox.cpp b/src/interface/Textbox.cpp index 7d939fd..fbe3c6b 100644 --- a/src/interface/Textbox.cpp +++ b/src/interface/Textbox.cpp @@ -244,6 +244,8 @@ void Textbox::Draw(const Point& screenPos) } if(border) g->drawrect(screenPos.X, screenPos.Y, Size.X, Size.Y, 160, 160, 160, 255); } + if(Appearance.icon) + g->draw_icon(screenPos.X+iconPosition.X, screenPos.Y+iconPosition.Y, Appearance.icon); } /* |
