Package pyjamas :: Package ui :: Module DropWidget
[hide private]
[frames] | no frames]

Source Code for Module pyjamas.ui.DropWidget

 1  # Copyright (C) 2010 Jim Washington 
 2  # 
 3  # Licensed under the Apache License, Version 2.0 (the "License"); 
 4  # you may not use this file except in compliance with the License. 
 5  # You may obtain a copy of the License at 
 6  # 
 7  #     http://www.apache.org/licenses/LICENSE-2.0 
 8  # 
 9  # Unless required by applicable law or agreed to in writing, software 
10  # distributed under the License is distributed on an "AS IS" BASIS, 
11  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
12  # See the License for the specific language governing permissions and 
13  # limitations under the License. 
14   
15   
16  from pyjamas import Factory 
17  from pyjamas import DOM 
18  from pyjamas.dnd.DNDHelper import dndHelper 
19  from pyjamas.ui.Widget import Widget 
20  from pyjamas.ui.DropHandler import DropHandler 
21  import pyjd 
22   
23 -class DropWidget(object):
24 """ 25 Mix-in class for a drop-target widget 26 """ 27 pass
28 29
30 -class Html5DropWidget(Widget, DropHandler):
31 - def __init__(self, **kw):
32 if (not hasattr(self, 'attached')) or kw: 33 Widget.__init__(self, **kw) 34 DropHandler.__init__(self) 35 self.addDropListener(self)
36 37
38 -class EmulatedDropWidget(Html5DropWidget):
39 - def __init__(self, **kw):
42 43
44 -def init(is_native=None):
45 global DropWidget 46 if is_native is None: 47 html5_dnd = hasattr(DOM.createElement('span'), 'draggable') 48 else: 49 html5_dnd = is_native 50 if html5_dnd: 51 DropWidget = Html5DropWidget 52 else: 53 DropWidget = EmulatedDropWidget
54 55 if pyjd.is_desktop: 56 init(pyjd.native_dnd) 57 else: 58 init(None) 59 60 Factory.registerClass('pyjamas.ui.DropWidget', 'DropWidget', DropWidget) 61