Home | Trees | Indices | Help |
|
---|
|
1 # Copyright 2006 James Tauber and contributors 2 # Copyright (C) 2009 Luke Kenneth Casson Leighton <lkcl@lkcl.net> 3 # 4 # Licensed under the Apache License, Version 2.0 (the "License"); 5 # you may not use this file except in compliance with the License. 6 # You may obtain a copy of the License at 7 # 8 # http://www.apache.org/licenses/LICENSE-2.0 9 # 10 # Unless required by applicable law or agreed to in writing, software 11 # distributed under the License is distributed on an "AS IS" BASIS, 12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 # See the License for the specific language governing permissions and 14 # limitations under the License. 15 from pyjamas import DOM 16 from pyjamas import Factory 17 18 from PopupPanel import PopupPanel 19 from HTML import HTML 20 from FlexTable import FlexTable 21 from pyjamas.ui import HasHorizontalAlignment 22 from pyjamas.ui import HasVerticalAlignment 23115 116 Factory.registerClass('pyjamas.ui.DialogBox', DialogBox) 11726 27 PopupPanel.__init__(self, autoHide, modal, **kwargs) 28 self.caption = HTML() 29 self.child = None 30 self.dragging = False 31 self.dragStartX = 0 32 self.dragStartY = 0 33 self.panel = FlexTable(Height="100%", BorderWidth="0", 34 CellPadding="0", CellSpacing="0") 35 self.panel.setWidget(0, 0, self.caption) 36 self.panel.getCellFormatter().setHeight(1, 0, "100%") 37 self.panel.getCellFormatter().setWidth(1, 0, "100%") 38 self.panel.getCellFormatter().setAlignment(1, 0, HasHorizontalAlignment.ALIGN_CENTER, HasVerticalAlignment.ALIGN_MIDDLE) 39 PopupPanel.setWidget(self, self.panel) 40 41 self.setStyleName("gwt-DialogBox") 42 self.caption.setStyleName("Caption") 43 self.caption.addMouseListener(self)4446 return self.caption.getHTML()4749 return self.caption.getText()5052 # preventDefault on mousedown events, outside of the 53 # dialog, to stop text-selection on dragging 54 type = DOM.eventGetType(event) 55 if type == 'mousedown': 56 target = DOM.eventGetTarget(event) 57 elem = self.caption.getElement() 58 event_targets_popup = target and DOM.isOrHasChild(elem, target) 59 if event_targets_popup: 60 DOM.eventPreventDefault(event) 61 return PopupPanel.onEventPreview(self, event)6264 self.dragging = True 65 DOM.setCapture(self.caption.getElement()) 66 self.dragStartX = x 67 self.dragStartY = y68 71 7476 if self.dragging: 77 absX = x + self.getAbsoluteLeft() 78 absY = y + self.getAbsoluteTop() 79 self.setPopupPosition(absX - self.dragStartX, absY - self.dragStartY)80 8486 if self.child != widget: 87 return False 88 89 self.panel.remove(widget) 90 self.child = None 91 return True9294 self.caption.setHTML(html)9597 self.caption.setText(text)98 102 106
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Wed Jun 16 12:42:29 2010 | http://epydoc.sourceforge.net |