2 #include "../item/label.qh"
4 entity makeXonoticTextBox()
7 me = NEW(XonoticTextBox);
8 me.configureXonoticListBox(me);
12 void XonoticTextBox_destroy(entity me)
14 if (me.stringList >= 0)
16 buf_del(me.stringList);
21 void XonoticTextBox_setText(entity me, string text)
23 if (me.stringList >= 0)
25 buf_del(me.stringList);
35 for (int i = 0, n = tokenizebyseparator(text, "\n"); i < n; ++i)
37 t = substring(argv(i), 0, -1);
38 getWrappedLine_remaining = t;
39 while (getWrappedLine_remaining)
41 t = getWrappedLine(1, me.realFontSize, draw_TextWidth_WithColors);
42 bufstr_set(buf, line, t);
51 string XonoticTextBox_getTextBoxLine(entity me, int i)
53 if (me.stringList >= 0)
55 return bufstr_get(me.stringList, i);
60 // mostly copied from playerlist
61 // FIXME: is this really needed
62 void XonoticTextBox_resizeNotify(entity me, vector relOrigin, vector relSize, vector absOrigin, vector absSize)
64 me.itemAbsSize = '0 0 0';
65 SUPER(XonoticTextBox).resizeNotify(me, relOrigin, relSize, absOrigin, absSize);
67 me.itemAbsSize.y = absSize.y * me.itemHeight;
68 me.itemAbsSize.x = absSize.x * (1 - me.controlWidth);
69 me.realFontSize.y = me.fontSize / me.itemAbsSize.y;
70 me.realFontSize.x = me.fontSize / me.itemAbsSize.x;
71 string temp = string_null;
72 for (int i = 0; i < me.nItems; ++i)
76 temp = me.getTextBoxLine(me, i);
80 temp = strcat(temp, "\n", me.getTextBoxLine(me, i));
86 void XonoticTextBox_drawListBoxItem(entity me, int i, vector absSize, bool isSelected, bool isFocused)
88 string s = me.getTextBoxLine(me, i);
89 draw_Text(vec2(0, 0), s, me.realFontSize, me.colorL, me.alpha, true);