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

Source Code for Module library.pyjamas.ui.VerticalPanel

 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 pyjamas.ui.CellPanel import CellPanel 
19  from pyjamas.ui import HasHorizontalAlignment 
20  from pyjamas.ui import HasVerticalAlignment 
21   
22 -class VerticalPanel(CellPanel):
23
24 - def insert(self, widget, container, beforeIndex=None):
25 """ has two modes of operation: 26 widget, beforeIndex 27 widget, container, beforeIndex. 28 if beforeIndex argument is not given, the 1st mode is assumed. 29 this technique is less costly than using *args. 30 """ 31 if widget.getParent() == self: 32 return 33 34 if beforeIndex is None: 35 beforeIndex = container 36 container = self.getBody() 37 38 widget.removeFromParent() 39 40 tr = DOM.createTR() 41 td = DOM.createTD() 42 43 DOM.insertChild(container, tr, beforeIndex) 44 DOM.appendChild(tr, td) 45 46 CellPanel.insert(self, widget, td, beforeIndex) 47 48 self.setCellHorizontalAlignment(widget, self.horzAlign) 49 self.setCellVerticalAlignment(widget, self.vertAlign)
50
51 - def remove(self, widget):
52 if isinstance(widget, int): 53 widget = self.getWidget(widget) 54 55 if widget.getParent() != self: 56 return False 57 58 td = DOM.getParent(widget.getElement()) 59 tr = DOM.getParent(td) 60 DOM.removeChild(self.getBody(), tr) 61 62 CellPanel.remove(self, widget) 63 return True
64 65 66 Factory.registerClass('pyjamas.ui.VerticalPanel', 'VerticalPanel', VerticalPanel) 67