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

Source Code for Module library.pyjamas.ui.RichTextArea

  1  """ 
  2  * Copyright 2007 Google Inc. 
  3  # Copyright (C) 2009 Luke Kenneth Casson Leighton <lkcl@lkcl.net> 
  4  * 
  5  * Licensed under the Apache License, Version 2.0 (the "License"); you may not 
  6  * use this file except in compliance with the License. You may obtain a copy of 
  7  * the License at 
  8  * 
  9  * http:#www.apache.org/licenses/LICENSE-2.0 
 10  * 
 11  * Unless required by applicable law or agreed to in writing, software 
 12  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 
 13  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 
 14  * License for the specific language governing permissions and limitations under 
 15  * the License. 
 16  """ 
 17   
 18   
 19   
 20   
 21  from pyjamas.ui.FocusWidget import FocusWidget 
 22  from pyjamas.ui.RichTextAreaImplStandard import RichTextAreaImplStandard 
 23   
 24   
 25   
 26  """* 
 27  * A rich text editor that allows complex styling and formatting. 
 28  * 
 29  * Because some browsers do not support rich text editing, and others support 
 30  * only a limited subset of functionality, there are two formatter interfaces, 
 31  * accessed via {@link #getBasicFormatter()} and {@link #getExtendedFormatter()}. 
 32  * A browser that does not support rich text editing at all will return 
 33  * <code>None</code> for both of these, while one that supports only the basic 
 34  * functionality will return <code>None</code> for the latter. 
 35  * 
 36  * <p> 
 37  * <img class='gallery' src='RichTextArea.png'/> 
 38  * </p> 
 39  * 
 40  * <h3>CSS Style Rules</h3> 
 41  * <ul class="css"> 
 42  * <li>.gwt-RichTextArea { }</li> 
 43  * </ul> 
 44  """ 
45 -class RichTextArea (FocusWidget) :
46 47 """* 48 * Creates a new, blank {@link RichTextArea} object with no stylesheet. 49 """
50 - def __init__(self, **kwargs):
51 if not kwargs.has_key('StyleName'): kwargs['StyleName']="gwt-RichTextArea" 52 self.impl = RichTextAreaImplStandard() 53 FocusWidget.__init__(self, self.impl.getElement(), **kwargs)
54 55
56 - def setCssStyling(self, style):
57 """ sets whether cloning is to be done of the main document's 58 CSS Style elements into the iframe of the editor 59 """ 60 if style: 61 self.impl.setCssStyling()
62 63 """* 64 * Gets the basic rich text formatting interface. 65 * 66 * @return <code>None</code> if basic formatting is not supported 67 """
68 - def getBasicFormatter(self):
69 if self.impl.isBasicEditingSupported(): 70 return self.impl 71 72 return None
73 74 75 """* 76 * Gets the full rich text formatting interface. 77 * 78 * @return <code>None</code> if full formatting is not supported 79 """
80 - def getExtendedFormatter(self):
81 if self.impl.isExtendedEditingSupported(): 82 return self.impl 83 84 return None
85 86
87 - def getHTML(self):
88 return self.impl.getHTML()
89 90
91 - def getText(self):
92 return self.impl.getText()
93 94
95 - def setFocus(self, focused):
96 # There are different problems on each browser when you try to focus an 97 # unattached rich text iframe, so just cut it off early. 98 if self.isAttached(): 99 self.impl.setFocus(focused)
100 101 102
103 - def setHTML(self, html):
104 self.impl.setHTML(html)
105 106
107 - def setText(self, text):
108 self.impl.setText(text)
109 110
111 - def onAttach(self):
112 FocusWidget.onAttach(self) 113 self.impl.initElement()
114 115
116 - def onDetach(self):
117 FocusWidget.onDetach(self) 118 self.impl.uninitElement()
119 120 121 # TODO: sort out Element **kwargs for Factory.createWidgetOnElement 122 #Factory.registerClass('pyjamas.ui.RichTextArea', 'RichTextArea', RichTextArea) 123