Go to the documentation of this file.00001
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include "MyGUI_Precompiled.h"
00025 #include "MyGUI_RenderOut.h"
00026 #include "MyGUI_Utility.h"
00027
00028 #include "MyGUI_Gui.h"
00029 #include "MyGUI_FontManager.h"
00030 #include "MyGUI_LayerManager.h"
00031 #include "MyGUI_SkinManager.h"
00032 #include "MyGUI_StaticText.h"
00033
00034 namespace MyGUI
00035 {
00036 namespace implement
00037 {
00038
00039
00040 struct info
00041 {
00042 info() : num(0), count(1) { }
00043 info(size_t _num, const std::string& _line) : num(_num), count(1), line(_line) { }
00044
00045 size_t num;
00046 size_t count;
00047 std::string line;
00048 };
00049
00050 void render_out(const std::string& _value)
00051 {
00052
00053 typedef std::deque<info> DequeInfo;
00054
00055
00056 static size_t num = 0;
00057
00058 static DequeInfo lines;
00059
00060 const int offset = 10;
00061 const size_t count_lines = 20;
00062 static const std::string font = "DejaVuSans.14";
00063 static const std::string layer = "Statistic";
00064 static const std::string skin = "StaticText";
00065
00066 static StaticTextPtr widget = nullptr;
00067 static StaticTextPtr widget_shadow = nullptr;
00068
00069 if (widget == nullptr) {
00070 Gui * gui = Gui::getInstancePtr();
00071 if (gui == nullptr) return;
00072
00073 const IntSize& size = gui->getViewSize();
00074
00075 if (!LayerManager::getInstance().isExist(layer)) return;
00076 if (!SkinManager::getInstance().isExist(skin)) return;
00077
00078
00079 widget_shadow = gui->createWidget<StaticText>(skin, IntCoord(offset + 1, offset + 1, size.width - offset - offset, size.height - offset - offset), Align::Stretch, layer);
00080 widget_shadow->setNeedMouseFocus(false);
00081 widget_shadow->setTextAlign(Align::Default);
00082 widget_shadow->setTextColour(Colour::Black);
00083
00084 widget = gui->createWidget<StaticText>(skin, IntCoord(offset, offset, size.width - offset - offset, size.height - offset - offset), Align::Stretch, layer);
00085 widget->setNeedMouseFocus(false);
00086 widget->setTextAlign(Align::Default);
00087 widget->setTextColour(Colour::White);
00088
00089 if (FontManager::getInstance().getByName(font) != nullptr)
00090 {
00091 widget_shadow->setFontName(font);
00092 widget->setFontName(font);
00093 }
00094 }
00095
00096 if (lines.empty()) {
00097 lines.push_back(info(num++, _value));
00098
00099 }
00100 else {
00101
00102 if (lines.back().line == _value) lines.back().count ++;
00103 else {
00104 lines.push_back(info(num++, _value));
00105
00106 if (lines.size() > count_lines) lines.pop_front();
00107 }
00108
00109 }
00110
00111
00112 std::string str_out;
00113 str_out.reserve(2048);
00114
00115 for (DequeInfo::iterator iter=lines.begin(); iter != lines.end(); ++iter) {
00116 str_out += utility::toString("[ ", (unsigned int)iter->num, (iter->count > 1) ? (" , " + utility::toString((unsigned int)iter->count)) : "", " ] ", iter->line, "\n");
00117 }
00118
00119
00120 widget_shadow->setCaption(str_out);
00121 widget->setCaption(str_out);
00122 }
00123 }
00124
00125 }