summaryrefslogtreecommitdiff
path: root/helpers.c
diff options
context:
space:
mode:
authorlouis <louis.braun@gmx.de>2013-05-03 12:34:23 +0200
committerlouis <louis.braun@gmx.de>2013-05-03 12:34:23 +0200
commitdaa47b6183a78bc01513a387849b8fb5364cd04a (patch)
tree4033f0faa9144209eaf724a0c086917b39199713 /helpers.c
parentd0cd4a3d202f3bc5987dfdf5d5ff39d863a11a32 (diff)
downloadskin-nopacity-daa47b6183a78bc01513a387849b8fb5364cd04a.tar.gz
skin-nopacity-daa47b6183a78bc01513a387849b8fb5364cd04a.tar.bz2
Added previous and next Channel Group in Channel Display
Diffstat (limited to 'helpers.c')
-rw-r--r--helpers.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/helpers.c b/helpers.c
index 425ebd6..54f717f 100644
--- a/helpers.c
+++ b/helpers.c
@@ -1,3 +1,6 @@
+#include <string>
+#include <sstream>
+
static cOsd *CreateOsd(int Left, int Top, int Width, int Height) {
cOsd *osd = cOsdProvider::NewOsd(Left, Top);
if (osd) {
@@ -45,4 +48,30 @@ static int Minimum(int a, int b, int c, int d, int e, int f) {
if (e < min) min = e;
if (f < min) min = f;
return min;
+}
+
+static std::string CutText(std::string text, int width, const cFont *font) {
+ if (width <= font->Size())
+ return text.c_str();
+ cTextWrapper twText;
+ twText.Set(text.c_str(), font, width);
+ std::string cuttedTextNative = twText.GetLine(0);
+ std::stringstream sstrText;
+ sstrText << cuttedTextNative << "...";
+ std::string cuttedText = sstrText.str();
+ int actWidth = font->Width(cuttedText.c_str());
+ if (actWidth > width) {
+ int overlap = actWidth - width;
+ int charWidth = font->Width(".");
+ if (charWidth == 0)
+ charWidth = 1;
+ int cutChars = overlap / charWidth;
+ if (cutChars > 0) {
+ cuttedTextNative = cuttedTextNative.substr(0, cuttedTextNative.length() - cutChars);
+ std::stringstream sstrText2;
+ sstrText2 << cuttedTextNative << "...";
+ cuttedText = sstrText2.str();
+ }
+ }
+ return cuttedText;
} \ No newline at end of file