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

Source Code for Module library.pyjamas.ui.TextArea

 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 JS 
16  from pyjamas import Factory 
17  from pyjamas import DOM 
18   
19  from pyjamas.ui.TextBoxBase import TextBoxBase 
20 21 -class TextArea(TextBoxBase):
22 """ 23 HTML textarea widget, allowing multi-line text entry. 24 Use setText/getText to 25 get and access the current text. 26 """ 27 28 _props = [("rows", "Rows", "VisibleLines", None), 29 ("cols", "Columns", "CharacterWidth", None), 30 ] 31
32 - def __init__(self, **ka):
33 ka['StyleName'] = ka.get('StyleName', "gwt-TextArea") 34 element = ka.pop('Element', None) or DOM.createTextArea() 35 TextBoxBase.__init__(self, element, **ka)
36 37 @classmethod
38 - def _getProps(self):
39 return TextBoxBase._getProps() + self._props
40
41 - def getCharacterWidth(self):
42 return DOM.getIntAttribute(self.getElement(), "cols")
43
44 - def getCursorPos(self):
45 return TextBoxBase.getCursorPos(self)
46
47 - def getVisibleLines(self):
48 return DOM.getIntAttribute(self.getElement(), "rows")
49
50 - def setCharacterWidth(self, width):
51 DOM.setIntAttribute(self.getElement(), "cols", width)
52
53 - def setVisibleLines(self, lines):
54 DOM.setIntAttribute(self.getElement(), "rows", lines)
55 56 Factory.registerClass('pyjamas.ui.TextArea', 'TextArea', TextArea) 57