1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 from pyjamas import DOM
16 from pyjamas import Factory
17
18 from pyjamas.ui.PopupPanel import PopupPanel
19 from pyjamas.ui.HTML import HTML
20 from pyjamas.ui.FlexTable import FlexTable
21 from pyjamas.ui import HasHorizontalAlignment
22 from pyjamas.ui import HasVerticalAlignment
23 from pyjamas.ui import GlassWidget
27 _props = [
28 ("caption", "Caption", "HTML", None),
29 ]
30
31 - def __init__(self, autoHide=None, modal=True, centered=False,
32 **kwargs):
33
34 self.dragging = False
35 self.dragStartX = 0
36 self.dragStartY = 0
37 self.child = None
38 self.panel = FlexTable(
39 Height="100%",
40 BorderWidth="0",
41 CellPadding="0",
42 CellSpacing="0",
43 )
44 cf = self.panel.getCellFormatter()
45 cf.setHeight(1, 0, "100%")
46 cf.setWidth(1, 0, "100%")
47 cf.setAlignment(
48 1, 0,
49 HasHorizontalAlignment.ALIGN_CENTER,
50 HasVerticalAlignment.ALIGN_MIDDLE,
51 )
52
53
54 self.modal = modal
55 self.caption = HTML()
56 self.panel.setWidget(0, 0, self.caption)
57 self.caption.setStyleName("Caption")
58 self.caption.addMouseListener(self)
59
60
61 kwargs['StyleName'] = kwargs.get('StyleName', "gwt-DialogBox")
62 PopupPanel.__init__(self, autoHide, modal, **kwargs)
63 PopupPanel.setWidget(self, self.panel)
64
65 self.centered = centered
66
71
76
77 @classmethod
80
92
95
97 return self.caption.getText()
98
101
102 - def setText(self, text):
103 self.caption.setText(text)
104
106 self.dragging = True
107 GlassWidget.show(self.caption)
108 self.dragStartX = x
109 self.dragStartY = y
110
113
116
124
127
130
133
135 if not self.dragging:
136 return
137 self.dragging = False
138 GlassWidget.hide()
139
141 if self.child != widget:
142 return False
143
144 self.panel.remove(widget)
145 self.child = None
146 return True
147
151
155
164
165 Factory.registerClass('pyjamas.ui.DialogBox', 'DialogBox', DialogBox)
166