Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 110 lines (85 sloc) 3.304 kb
81d860e rename shell Popups
lkcl authored
1 from Popups import DialogBoxModal
d2d2524 modal dialog box creating a desktop-like application
lkcl authored
2 from pyjamas.ui.AbsolutePanel import AbsolutePanel
3 from pyjamas import Window
2f217fd Peter Bittner logging: migrated all references from pyjamas.log -> pyjamas.logging
bittner authored
4 from pyjamas import logging
5
6 log = logging.getAppendLogger(__name__, logging.DEBUG, logging.PLAIN_FORMAT)
d2d2524 modal dialog box creating a desktop-like application
lkcl authored
7
8 class Application(DialogBoxModal):
9 def __init__(self, screen, title, width, height):
8524c51 add screen to rootpanel duh
lkcl authored
10 DialogBoxModal.__init__(self, title, None, False, screen)
d2d2524 modal dialog box creating a desktop-like application
lkcl authored
11 self.screen = screen
12 self.setText(title)
c930b73 get shell example working under pyjd
lkcl authored
13 self.dragged = False
d2d2524 modal dialog box creating a desktop-like application
lkcl authored
14 #self.setWidth(width)
15 #self.setHeight(height)
16
17 def onMouseDown(self, sender, x, y):
2f217fd Peter Bittner logging: migrated all references from pyjamas.log -> pyjamas.logging
bittner authored
18 #log.debug("down %d %d" % (x, y))
d2d2524 modal dialog box creating a desktop-like application
lkcl authored
19 DialogBoxModal.onMouseDown(self, sender, x, y)
20 self.dragged = False
64eff55 C Anthony Risinger find * -name '*.py' | xargs sed -i -r 's,\s+$,,'
xtfxme authored
21
d2d2524 modal dialog box creating a desktop-like application
lkcl authored
22 def onMouseMove(self, sender, x, y):
2f217fd Peter Bittner logging: migrated all references from pyjamas.log -> pyjamas.logging
bittner authored
23 #log.debug("move %d %d" % (x, y))
d2d2524 modal dialog box creating a desktop-like application
lkcl authored
24 if self.dragStartX != x or self.dragStartY != y:
c220135 drag raise debugging
lkcl authored
25 if not self.dragged:
26 self.screen.raise_app(self)
d2d2524 modal dialog box creating a desktop-like application
lkcl authored
27 self.dragged = True
28 DialogBoxModal.onMouseMove(self, sender, x, y)
29
30 def onMouseUp(self, sender, x, y):
2f217fd Peter Bittner logging: migrated all references from pyjamas.log -> pyjamas.logging
bittner authored
31 #log.debug("up %d %d" % (x, y))
d2d2524 modal dialog box creating a desktop-like application
lkcl authored
32 DialogBoxModal.onMouseUp(self, sender, x, y)
c220135 drag raise debugging
lkcl authored
33 if not self.dragged:
d2d2524 modal dialog box creating a desktop-like application
lkcl authored
34 self.screen.raise_or_lower(self)
35
5b10b7b remove sender=None
lkcl authored
36 def onClick(self, sender):
d2d2524 modal dialog box creating a desktop-like application
lkcl authored
37 if sender == self.closeButton:
38 self.screen.close_app(self)
39
40 class Screen(AbsolutePanel):
41
42 def __init__(self, width, height):
43
44 AbsolutePanel.__init__(self)
45 self.setWidth(width)
46 self.setHeight(height)
47
48 self.window = {}
49 self.window_zindex = {}
50
51 def add_app(self, app, title, width, height):
52
53 sa = Application(self, title, width, height)
54 sa.setWidget(app)
55 self.window[title] = sa
56 self.window_zindex[title] = len(self.window)-1
57
58 return sa
59
60 def set_app_zindex(self, title, zi):
61 w = self.window[title]
62 self.window_zindex[title] = zi
63 w.setzIndex(zi)
64
65 def lower_app(self, app):
66 app_zi = self.window_zindex[app.identifier]
67 for t in self.window_zindex.keys():
68 w = self.window[t]
69 zi = self.window_zindex[t]
70 if zi < app_zi:
71 self.set_app_zindex(t, zi+1)
72
73 self.set_app_zindex(app.identifier, 0)
74
75 def raise_app(self, app):
76 app_zi = self.window_zindex[app.identifier]
77 for t in self.window_zindex.keys():
78 w = self.window[t]
79 zi = self.window_zindex[t]
80 if zi > app_zi:
81 self.set_app_zindex(t, zi-1)
82
83 app_zi = len(self.window)-1
84 self.set_app_zindex(app.identifier, app_zi)
85
86 def raise_or_lower(self, app):
64eff55 C Anthony Risinger find * -name '*.py' | xargs sed -i -r 's,\s+$,,'
xtfxme authored
87
d2d2524 modal dialog box creating a desktop-like application
lkcl authored
88 app_zi = self.window_zindex[app.identifier]
89 if app_zi != len(self.window)-1:
90 self.raise_app(app)
91 else:
92 self.lower_app(app)
93
94 def close_app(self, app):
64eff55 C Anthony Risinger find * -name '*.py' | xargs sed -i -r 's,\s+$,,'
xtfxme authored
95
d2d2524 modal dialog box creating a desktop-like application
lkcl authored
96 app_zi = self.window_zindex[app.identifier]
97 for t in self.window_zindex.keys():
98 w = self.window[t]
99 zi = self.window_zindex[t]
100 if zi > app_zi:
101 self.set_app_zindex(t, zi-1)
102
103 t = self.window[app.identifier]
104 if not self.remove(t):
105 Window.alert("%s not in app" % app.identifier)
8524c51 add screen to rootpanel duh
lkcl authored
106 t.hide()
d2d2524 modal dialog box creating a desktop-like application
lkcl authored
107 del self.window[app.identifier]
c930b73 get shell example working under pyjd
lkcl authored
108 del self.window_zindex[app.identifier]
d2d2524 modal dialog box creating a desktop-like application
lkcl authored
109
Something went wrong with that request. Please try again.