1 from Components.HTMLSkin import HTMLSkin
2 from Components.GUISkin import GUISkin
3 from Components.Sources.Source import Source
4 from Components.GUIComponent import GUIComponent
6 class Screen(dict, HTMLSkin, GUISkin):
12 def __init__(self, session, parent = None):
13 self.skinName = self.__class__.__name__
14 self.session = session
16 GUISkin.__init__(self)
19 self.onFirstExecBegin = [ ]
20 self.onExecBegin = [ ]
29 # already shown is false until the screen is really shown (after creation)
30 self.already_shown = False
34 # in order to support screens *without* a help,
35 # we need the list in every screen. how ironic.
38 self.close_on_next_exec = None
40 # stand alone screens (for example web screens)
41 # don't care about having or not having focus.
42 self.stand_alone = False
45 self.active_components = [ ]
46 if self.close_on_next_exec is not None:
47 tmp = self.close_on_next_exec
48 self.close_on_next_exec = None
52 single = self.onFirstExecBegin
53 self.onFirstExecBegin = []
54 for x in self.onExecBegin + single:
56 if not self.stand_alone and self.session.current_dialog != self:
59 # assert self.session == None, "a screen can only exec once per time"
60 # self.session = session
62 for val in self.values() + self.renderer:
64 if not self.stand_alone and self.session.current_dialog != self:
66 self.active_components.append(val)
70 for x in self.onShown:
74 # for (name, val) in self.items():
75 for val in self.active_components:
77 del self.active_components
78 # assert self.session != None, "execEnd on non-execing screen!"
82 # never call this directly - it will be called from the session!
85 for x in self.onClose:
88 # fixup circular references
92 # first disconnect all render from their sources.
93 # we might split this out into a "unskin"-call,
94 # but currently we destroy the screen afterwards
96 for val in self.renderer:
97 val.disconnectAll() # disconnected converter/sources and probably destroy them
100 for (name, val) in self.items():
104 for val in self.renderer:
109 # really delete all elements now
110 self.__dict__.clear()
112 def close(self, *retval):
114 self.close_on_next_exec = retval
116 self.session.close(self, *retval)
118 def setFocus(self, o):
119 self.instance.setFocus(o.instance)
122 if (self.shown and self.already_shown) or not self.instance:
125 self.already_shown = True
127 for x in self.onShow:
129 for val in self.values() + self.renderer:
130 if isinstance(val, GUIComponent) or isinstance(val, Source):
134 if not self.shown or not self.instance:
138 for x in self.onHide:
140 for val in self.values() + self.renderer:
141 if isinstance(val, GUIComponent) or isinstance(val, Source):
145 return str(type(self))
147 def getRelatedScreen(self, name):
148 if name == "session":
149 return self.session.screen
150 elif name == "parent":
152 elif name == "global":
153 return self.global_screen