tricheckbox.py (2590B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\control\tricheckbox.py 2 from carbon.client.script.environment.AudioUtil import PlaySound 3 from carbonui.primitives.base import Base 4 from carbonui.primitives.container import Container 5 from carbonui.primitives.sprite import Sprite 6 import carbonui.const as uiconst 7 from carbonui.const import NOT_CHECKED, HALF_CHECKED, FULL_CHECKED 8 from eve.client.script.ui.control.themeColored import SpriteThemeColored 9 import trinity 10 11 class TriCheckbox(Container): 12 __guid__ = 'uicontrols.TriCheckbox' 13 default_state = uiconst.UI_NORMAL 14 15 def ApplyAttributes(self, attributes): 16 Container.ApplyAttributes(self, attributes) 17 self.OnChange = attributes.get('callback', None) 18 self.checked = False 19 self.checkMark = Sprite(parent=self, pos=(0, 0, 16, 16), name='self_ok', state=uiconst.UI_DISABLED, texturePath='res:/UI/Texture/Shared/checkboxChecked.png') 20 self.underlay = SpriteThemeColored(name='frame', bgParent=self, colorType=uiconst.COLORTYPE_UIHILIGHT, blendMode=trinity.TR2_SBM_ADD, texturePath='res:/UI/Texture/Shared/checkbox_comp.png', opacity=0.2, padding=2) 21 22 def SetChecked(self, checkState): 23 checkState = checkState or NOT_CHECKED 24 self.checked = checkState 25 if self.checked == NOT_CHECKED: 26 self.checkMark.display = False 27 elif self.checked == HALF_CHECKED: 28 self.checkMark.texturePath = 'res:/UI/Texture/Shared/checkboxHalfChecked.png' 29 self.checkMark.display = True 30 elif self.checked == FULL_CHECKED: 31 self.checkMark.texturePath = 'res:/UI/Texture/Shared/checkboxChecked.png' 32 self.checkMark.display = True 33 if self.OnChange: 34 self.OnChange(self) 35 36 def OnMouseEnter(self, *args): 37 PlaySound(uiconst.SOUND_BUTTON_HOVER) 38 39 def GetValue(self): 40 return self.checked 41 42 def OnClick(self, *args): 43 if self.checked == NOT_CHECKED: 44 PlaySound(uiconst.SOUND_SETSELECTED) 45 self.SetChecked(HALF_CHECKED) 46 elif self.checked == HALF_CHECKED: 47 PlaySound(uiconst.SOUND_SETSELECTED) 48 self.SetChecked(FULL_CHECKED) 49 elif self.checked == FULL_CHECKED: 50 PlaySound(uiconst.SOUND_SETDESELECTED) 51 self.SetChecked(NOT_CHECKED) 52 53 def Enable(self): 54 Base.Enable(self) 55 self.opacity = 1.0 56 57 def Disable(self): 58 Base.Disable(self) 59 self.opacity = 0.3 60 61 def SetCallback(self, callback): 62 self.OnChange = callback