01: /*
02: * Copyright 2007 Google Inc.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License"); you may not
05: * use this file except in compliance with the License. You may obtain a copy of
06: * the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12: * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13: * License for the specific language governing permissions and limitations under
14: * the License.
15: */
16: package com.google.gwt.user.client.ui.impl;
17:
18: import com.google.gwt.user.client.DOM;
19: import com.google.gwt.user.client.Element;
20: import com.google.gwt.user.client.Event;
21:
22: /**
23: * Base class for RichText platform implementations. The default version
24: * simply creates a text area with no rich text support.
25: *
26: * This is not currently used by any user-agent, but will provide a
27: * <textarea> fallback in the event a future browser fails to implement
28: * rich text editing.
29: */
30: public class RichTextAreaImpl {
31:
32: protected Element elem;
33:
34: public RichTextAreaImpl() {
35: elem = createElement();
36: }
37:
38: public Element getElement() {
39: return elem;
40: }
41:
42: public String getHTML() {
43: return DOM.getElementProperty(elem, "value");
44: }
45:
46: public String getText() {
47: return DOM.getElementProperty(elem, "value");
48: }
49:
50: public void initElement() {
51: onElementInitialized();
52: }
53:
54: public boolean isBasicEditingSupported() {
55: return false;
56: }
57:
58: public boolean isExtendedEditingSupported() {
59: return false;
60: }
61:
62: public native void setFocus(boolean focused) /*-{
63: if (focused) {
64: this.@com.google.gwt.user.client.ui.impl.RichTextAreaImpl::elem.focus();
65: } else {
66: this.@com.google.gwt.user.client.ui.impl.RichTextAreaImpl::elem.blur();
67: }
68: }-*/;
69:
70: public void setHTML(String html) {
71: DOM.setElementProperty(elem, "value", html);
72: }
73:
74: public void setText(String text) {
75: DOM.setElementProperty(elem, "value", text);
76: }
77:
78: public void uninitElement() {
79: }
80:
81: protected Element createElement() {
82: return DOM.createTextArea();
83: }
84:
85: protected void hookEvents() {
86: DOM.sinkEvents(elem, Event.MOUSEEVENTS | Event.KEYEVENTS
87: | Event.ONCHANGE | Event.ONCLICK | Event.FOCUSEVENTS);
88: }
89:
90: protected void onElementInitialized() {
91: hookEvents();
92: }
93: }
|