NovaBryan/EVE_Dump
Log | Files | 📦 下载最新源码 (.zip) | Refs | README

hybridWindow.py (6855B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\control\hybridWindow.py
      2 import uthread
      3 from carbonui import uiconst
      4 from carbonui.control.window import Window
      5 from carbonui.primitives.container import Container
      6 from carbonui.uicore import uicore
      7 from eve.client.script.ui.control.themeColored import SpriteThemeColored
      8 from eve.client.script.ui.util.form import FormWnd
      9 from eve.client.script.ui.util.uix import GetDialogIconTexturePath
     10 
     11 class HybridWindow(Window):
     12     __guid__ = 'form.HybridWindow'
     13 
     14     def ApplyAttributes(self, attributes):
     15         Window.ApplyAttributes(self, attributes)
     16         self.ResetSelf()
     17         format = attributes.format
     18         caption = attributes.caption
     19         modal = attributes.modal
     20         buttons = attributes.buttons
     21         minw = attributes.get('minW', 320)
     22         minh = attributes.get('minH', 240)
     23         icon = attributes.icon
     24         blockconfirm = attributes.get('blockconfirm', False)
     25         self.name = caption
     26         self.result = {}
     27         self.isModal = modal
     28         self.blockconfirmonreturn = blockconfirm
     29         Container(name='push', parent=self.GetMainArea(), align=uiconst.TORIGHT, width=const.defaultPadding)
     30         Container(name='push', parent=self.GetMainArea(), align=uiconst.TOTOP, height=const.defaultPadding)
     31         if icon:
     32             self.icon = GetDialogIconTexturePath(icon)
     33         self.state = uiconst.UI_HIDDEN
     34         self.DefineButtons(buttons)
     35         self.MakeUnMinimizable()
     36         self.MakeUncollapseable()
     37         self.SetCaption(caption)
     38         self.SetMinSize([minw, minh], 1)
     39         self.form, self.retfields, self.reqresult, self.panels, self.errorcheck, refresh = sm.GetService('form').GetForm(format, FormWnd(name='form', align=uiconst.TOTOP, parent=self.GetMainArea()))
     40         self.form.OnChange = self.OnChange
     41         for each in self.form.sr.panels.itervalues():
     42             each.OnChange = self.OnChange
     43 
     44         self.refresh = refresh
     45         for each in refresh:
     46             for textControl in each[1:]:
     47                 textControl.OnSizeChanged = self.UpdateTextControlSize
     48 
     49         self.state = self.form.state = uiconst.UI_NORMAL
     50         self.width = self.minsize[0]
     51         if self.form.sr.focus:
     52             uicore.registry.SetFocus(self.form.sr.focus)
     53         else:
     54             uicore.registry.SetFocus(self)
     55         uthread.new(self.RefreshSize_, 1)
     56 
     57     def UpdateTextControlSize(self, *args):
     58         self.RefreshSize_()
     59 
     60     def ResetSelf(self):
     61         self.scrolllist = None
     62         self.listentry = None
     63         self.reqresult = []
     64         self.retfields = []
     65         self.tabpanels = []
     66         self.tabparents = []
     67         self.result = {}
     68         self.tabs = []
     69         self.minh = 0
     70         self.minw = 240
     71         self.refreshHeight = []
     72         self.onconfirmargs = ()
     73         self.checkingtabs = 0
     74         self.settingheight = 0
     75         self.activetab = None
     76         self.refresh = None
     77         self.form = None
     78         self.sr.queue = None
     79         self.locked = 0
     80 
     81     def Close(self, *args, **kwds):
     82         if self.HasPendingModalResult():
     83             return Window.Close(self, *args, **kwds)
     84         if self.sr.queue is not None:
     85             self.sr.queue.send(None)
     86         self.form.OnChange = None
     87         self.form.sr.focus = None
     88         for each in self.form.sr.panels.itervalues():
     89             each.OnChange = None
     90 
     91         self.form.Close()
     92         self.form = None
     93         self.retfields = None
     94         self.reqresult = None
     95         self.panels = None
     96         self.errorcheck = None
     97         self.ResetSelf()
     98         Window.Close(self, *args, **kwds)
     99 
    100     def OnChange(self, *args):
    101         self.OnScale_(*args)
    102 
    103     def OnScale_(self, *args):
    104         self.RefreshSize_()
    105 
    106     def OnEndScale_(self, *args):
    107         self.RefreshSize_()
    108 
    109     def RefreshSize_(self, update = 0, *args):
    110         self.RefreshTextControls(self.refresh)
    111         if self.locked:
    112             return
    113         minformheight = 0
    114         notformheight = 0
    115         hasTab = 0
    116         minw = 0
    117         for each in self.form.children:
    118             if each.name == 'form':
    119                 for each2 in each.children:
    120                     if each2.name == 'form':
    121                         self.RefreshHeight(each2)
    122 
    123                 self.RefreshHeight(each)
    124                 minformheight = max(minformheight, each.height + each.padTop + each.padBottom)
    125             elif each.name == 'tabparent':
    126                 hasTab = 1
    127                 if each.width > minw:
    128                     minw = each.width
    129             else:
    130                 notformheight += each.height + each.padTop + each.padBottom
    131 
    132         if self.form.align in (uiconst.TOTOP, uiconst.TOBOTTOM):
    133             self.form.height = minformheight + notformheight
    134         totHeight = minformheight + sum([ each.height + each.padTop + each.padBottom for each in self.form.parent.children if each.align in (uiconst.TOTOP, uiconst.TOBOTTOM) ])
    135         if hasTab == 1:
    136             if self.minsize[0] < minw:
    137                 self.minsize[0] = minw
    138         minHeight = totHeight + 70
    139         if self.stacked:
    140             minHeight += 6
    141         if minHeight > self.minsize[1]:
    142             self.SetMinSize([self.minsize[0], minHeight], 1)
    143 
    144     def RefreshHeight(self, w):
    145         w.height = sum([ x.height for x in w.children if x.state != uiconst.UI_HIDDEN and x.align in (uiconst.TOBOTTOM, uiconst.TOTOP) ])
    146 
    147     def RefreshTextControls(self, rlist):
    148         for each in rlist:
    149             itemToUpdate = each[0]
    150             m = 0
    151             for textcontrol in each[1:]:
    152                 if textcontrol.GetAlign() in (uiconst.TOTOP, uiconst.TOBOTTOM, uiconst.TOALL):
    153                     m = max(m, textcontrol.textheight + textcontrol.padTop + textcontrol.padBottom)
    154                 else:
    155                     m = max(m, textcontrol.textheight + textcontrol.top * 2)
    156 
    157             itemToUpdate.height = m
    158 
    159     def Execute(self):
    160         if self.sr.queue is not None:
    161             raise RuntimeError('already executing?')
    162         self.sr.queue = uthread.Channel()
    163         ret = self.sr.queue.receive()
    164         self.sr.queue = None
    165         return ret
    166 
    167     def Confirm(self, sender = None, *args):
    168         uicore.registry.SetFocus(uicore.desktop)
    169         if sender is None:
    170             if getattr(uicore.registry.GetFocus(), 'stopconfirm', 0):
    171                 return
    172         self.result = sm.GetService('form').ProcessForm(self.retfields, self.reqresult, self.errorcheck)
    173         if self.result is None:
    174             return
    175         if uicore.registry.GetModalWindow() == self:
    176             import triui
    177             self.SetModalResult(triui.ID_OK)
    178         else:
    179             if self.sr.queue is not None:
    180                 self.sr.queue.send(self.result)
    181             ret = self.result
    182             self.Close()
    183             return ret
    184 
    185     ConfirmFunction = Confirm