-#ifndef ITEM_LABEL_H
-#define ITEM_LABEL_H
-#include "../item.qc"
-CLASS(Label, Item)
- METHOD(Label, configureLabel, void(entity, string, float, float))
- METHOD(Label, draw, void(entity))
- METHOD(Label, resizeNotify, void(entity, vector, vector, vector, vector))
- METHOD(Label, setText, void(entity, string))
- METHOD(Label, toString, string(entity))
- METHOD(Label, recalcPositionWithText, void(entity, string))
- ATTRIB(Label, isBold, float, 0)
- ATTRIB(Label, text, string, string_null)
- ATTRIB(Label, currentText, string, string_null)
- ATTRIB(Label, fontSize, float, 8)
- ATTRIB(Label, align, float, 0.5)
- ATTRIB(Label, allowCut, float, 0)
- ATTRIB(Label, allowColors, float, 0)
- ATTRIB(Label, keepspaceLeft, float, 0) // for use by subclasses (radiobuttons for example)
- ATTRIB(Label, keepspaceRight, float, 0)
- ATTRIB(Label, marginLeft, float, 0) // alternate way to specify keepspace* (in characters from the font)
- ATTRIB(Label, marginRight, float, 0)
- ATTRIB(Label, realFontSize, vector, '0 0 0')
- ATTRIB(Label, realOrigin, vector, '0 0 0')
- ATTRIB(Label, alpha, float, 0.7)
- ATTRIB(Label, colorL, vector, SKINCOLOR_TEXT)
- ATTRIB(Label, disabled, float, 0)
- ATTRIB(Label, disabledAlpha, float, 0.3)
- ATTRIB(Label, textEntity, entity, NULL)
- ATTRIB(Label, allowWrap, float, 0)
- ATTRIB(Label, recalcPos, float, 0)
- ATTRIB(Label, condenseFactor, float, 1)
- ATTRIB(Label, overrideRealOrigin, vector, '0 0 0')
- ATTRIB(Label, overrideCondenseFactor, float, 0)
-ENDCLASS(Label)
-#endif
-
-#ifdef IMPLEMENTATION
-string Label_toString(entity me)
-{
- return me.text;
-}
-void Label_setText(entity me, string txt)
-{
- me.text = txt;
- if(txt != me.currentText)
- {
- if(me.currentText)
- strunzone(me.currentText);
- me.currentText = strzone(txt);
- me.recalcPos = 1;
- }
-}
-void Label_recalcPositionWithText(entity me, string t)
-{
- float spaceAvail;
- spaceAvail = 1 - me.keepspaceLeft - me.keepspaceRight;
-
- if(me.isBold)
- draw_beginBoldFont();
-
- float spaceUsed;
- spaceUsed = draw_TextWidth(t, me.allowColors, me.realFontSize);