1 #include <CtrlLib/CtrlLib.h>
2 
3 #include "PopUpText.h"
4 
5 namespace Upp {
6 
GetEditSize(const String & _str,const Font & font)7 static Size GetEditSize(const String &_str, const Font &font) {
8 	WString str(_str);
9 	Size ret(0, 0);
10 	int retx = 0, nlines = 1;
11 	for (int i = 0; i < str.GetCount(); ++i) {
12 		int c = str[i];
13 		if (c == '\n') {
14 			nlines++;
15 			ret.cx = max(ret.cx, retx);
16 			retx = 0;
17 		} else
18 			retx += font.GetWidth(c);
19 	}
20 	ret.cx = max(ret.cx, retx);
21 	ret.cy = nlines*font.GetHeight() + font.GetDescent();
22 	return ret;
23 }
24 
SetText(String _text)25 PopUpText &PopUpText::SetText(String _text) {
26 	text = _text;
27 	sz = GetEditSize(text, font);
28 	return *this;
29 }
30 
Paint(Draw & w)31 void PopUpInfo::Paint(Draw& w) {
32 	Size sz = GetSize();
33 	if(!IsTransparent())
34 		w.DrawRect(0, 0, sz.cx, sz.cy, color);
35 	PaintLabel(w, 0, 0, sz.cx, sz.cy, !IsShowEnabled(), false, false, VisibleAccessKeys());
36 }
37 
PopUpInfo()38 PopUpInfo::PopUpInfo(): color(SColorInfo()) {
39 	Transparent(false);
40 	NoWantFocus();
41 	IgnoreMouse();
42 	SetAlign(ALIGN_CENTER);
43 	SetFrame(BlackFrame());
44 	opened = false;
45 }
46 
47 }