caption.py (2188B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\packages\carbonui\window\header\caption.py 2 from carbonui import uiconst 3 from carbonui.primitives.base import ReverseScaleDpi 4 from carbonui.primitives.container import Container 5 from eve.client.script.ui.control import eveLabel 6 7 class WindowCaption(Container): 8 9 def __init__(self, parent, text, font_size, color, state = uiconst.UI_DISABLED, padding = None): 10 self._label = None 11 super(WindowCaption, self).__init__(parent=parent, align=uiconst.TOLEFT, state=state, padding=padding) 12 self._label = eveLabel.Label(parent=self, align=uiconst.CENTERLEFT, state=uiconst.UI_DISABLED, text=text, fontsize=font_size, maxLines=1, autoFadeSides=24, color=color) 13 14 @property 15 def text(self): 16 if self._label is not None: 17 return self._label.text 18 19 @text.setter 20 def text(self, value): 21 if self._label is not None: 22 self._label.text = value 23 24 @property 25 def color(self): 26 if self._label is not None: 27 if hasattr(self._label.color, 'GetRGBA'): 28 return self._label.color.GetRGBA() 29 else: 30 return self._label.color 31 32 @color.setter 33 def color(self, value): 34 if self._label is not None: 35 self._label.color = value 36 37 @property 38 def font_size(self): 39 if self._label is not None: 40 return self._label.fontsize 41 42 @font_size.setter 43 def font_size(self, value): 44 if self._label is not None: 45 self._label.fontsize = value 46 47 def UpdateAlignment(self, budgetLeft = 0, budgetTop = 0, budgetWidth = 0, budgetHeight = 0, updateChildrenOnly = False): 48 result = super(WindowCaption, self).UpdateAlignment(budgetLeft, budgetTop, budgetWidth, budgetHeight, updateChildrenOnly) 49 if not updateChildrenOnly: 50 self.width = min(self._label.width, max(ReverseScaleDpi(budgetWidth) - self.padLeft - self.padRight, 0)) 51 if self._alignmentDirty: 52 result = super(WindowCaption, self).UpdateAlignment(budgetLeft, budgetTop, budgetWidth, budgetHeight, updateChildrenOnly) 53 return result