Package muntjac :: Package ui :: Module list_select
[hide private]
[frames] | no frames]

Source Code for Module muntjac.ui.list_select

 1  # Copyright (C) 2012 Vaadin Ltd.  
 2  # Copyright (C) 2012 Richard Lincoln 
 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   
16  """Defines a simple list.""" 
17   
18  from muntjac.ui.abstract_select import AbstractSelect 
19   
20   
21 -class ListSelect(AbstractSelect):
22 """This is a simple list select without, for instance, support for 23 new items, lazyloading, and other advanced features. 24 """ 25 26 CLIENT_WIDGET = None #ClientWidget(VListSelect) 27
28 - def __init__(self, *args):
29 self._columns = 0 30 self._rows = 0 31 32 super(ListSelect, self).__init__(*args)
33 34
35 - def setColumns(self, columns):
36 """Sets the number of columns in the editor. If the number of columns 37 is set 0, the actual number of displayed columns is determined 38 implicitly by the adapter. 39 40 @param columns: 41 the number of columns to set. 42 """ 43 if columns < 0: 44 columns = 0 45 46 if self._columns != columns: 47 self._columns = columns 48 self.requestRepaint()
49 50
51 - def getColumns(self):
52 return self._columns
53 54
55 - def getRows(self):
56 return self._rows
57 58
59 - def setRows(self, rows):
60 """Sets the number of rows in the editor. If the number of rows is 61 set 0, the actual number of displayed rows is determined implicitly 62 by the adapter. 63 64 @param rows: 65 the number of rows to set. 66 """ 67 if rows < 0: 68 rows = 0 69 70 if self._rows != rows: 71 self._rows = rows 72 self.requestRepaint()
73 74
75 - def paintContent(self, target):
76 target.addAttribute('type', 'list') 77 78 # Adds the number of columns 79 if self._columns != 0: 80 target.addAttribute('cols', self._columns) 81 82 # Adds the number of rows 83 if self._rows != 0: 84 target.addAttribute('rows', self._rows) 85 86 super(ListSelect, self).paintContent(target)
87