ultimatepp/uppsrc/ScatterCtrl/PopUpText.cpp
koldo 320094983f ScatterCtrl: Updated namespace
git-svn-id: svn://ultimatepp.org/upp/trunk@13712 f0d560ea-af0d-0410-9eb7-867de7ffcac7
2019-11-24 11:16:10 +00:00

47 lines
No EOL
1,019 B
C++

#include <CtrlLib/CtrlLib.h>
#include "PopUpText.h"
namespace Upp {
static Size GetEditSize(const String &_str, const Font &font) {
WString str(_str);
Size ret(0, 0);
int retx = 0, nlines = 1;
for (int i = 0; i < str.GetCount(); ++i) {
int c = str[i];
if (c == '\n') {
nlines++;
ret.cx = max(ret.cx, retx);
retx = 0;
} else
retx += font.GetWidth(c);
}
ret.cx = max(ret.cx, retx);
ret.cy = nlines*font.GetHeight() + font.GetDescent();
return ret;
}
PopUpText &PopUpText::SetText(String _text) {
text = _text;
sz = GetEditSize(text, font);
return *this;
}
void PopUpInfo::Paint(Draw& w) {
Size sz = GetSize();
if(!IsTransparent())
w.DrawRect(0, 0, sz.cx, sz.cy, color);
PaintLabel(w, 0, 0, sz.cx, sz.cy, !IsShowEnabled(), false, false, VisibleAccessKeys());
}
PopUpInfo::PopUpInfo(): color(SColorInfo()) {
Transparent(false);
NoWantFocus();
IgnoreMouse();
SetAlign(ALIGN_CENTER);
SetFrame(BlackFrame());
opened = false;
}
}