Merge branch 'cst-next' of git://coolstreamtech.de/cst-public-gui-neutrino into ni/cst-next

Origin commit data
------------------
Branch: ni/coolstream
Commit: 1484a7fa94
Author: vanhofen <vanhofen@gmx.de>
Date: 2016-08-13 (Sat, 13 Aug 2016)


------------------
No further description and justification available within origin commit message!

------------------
This commit was generated by Migit
This commit is contained in:
vanhofen
2016-08-13 22:25:18 +02:00
4 changed files with 15 additions and 13 deletions

View File

@@ -44,6 +44,7 @@
#include <linux/hdreg.h>
#include <linux/fs.h>
#include "debug.h"
#include <global.h>
#include <system/helpers.h>
#include <gui/update_ext.h>
using namespace std;
@@ -567,21 +568,22 @@ std::string trim(std::string &str, const std::string &trimChars /*= " \n\r\t"*/)
return result.erase(0, result.find_first_not_of(trimChars));
}
std::string cutString(const std::string str, Font *msgFont, const int width)
std::string cutString(const std::string str, int msgFont, const int width)
{
Font *msgFont_ = g_Font[msgFont];
std::string ret = str;
ret = trim(ret);
int sw = msgFont->getRenderWidth(ret);
int sw = msgFont_->getRenderWidth(ret);
if (sw <= width)
return ret;
else {
std::string z = "...";
int zw = msgFont->getRenderWidth(z);
int zw = msgFont_->getRenderWidth(z);
if (width <= 2*zw)
return ret;
do {
ret = ret.substr(0, ret.length()-1);
sw = msgFont->getRenderWidth(ret);
sw = msgFont_->getRenderWidth(ret);
} while (sw+zw > width);
ret = trim(ret) + z;
}