001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017: /**
018: * @author Pavel Dolgov
019: * @version $Revision$
020: */package org.apache.harmony.awt;
021:
022: import java.awt.Component;
023: import java.awt.Container;
024: import java.awt.Dialog;
025: import java.awt.Dimension;
026: import java.awt.Image;
027: import java.awt.Insets;
028: import java.awt.Point;
029: import java.awt.Rectangle;
030: import java.awt.Window;
031: import java.awt.Choice;
032: import java.lang.reflect.InvocationTargetException;
033:
034: import org.apache.harmony.awt.gl.MultiRectArea;
035: import org.apache.harmony.awt.text.TextFieldKit;
036: import org.apache.harmony.awt.text.TextKit;
037: import org.apache.harmony.awt.wtk.NativeWindow;
038:
039: /**
040: * The accessor to AWT private API
041: */
042: public abstract class ComponentInternals {
043:
044: /**
045: * @return the ComponentInternals instance to serve the requests
046: */
047: public static ComponentInternals getComponentInternals() {
048: return ContextStorage.getComponentInternals();
049: }
050:
051: /**
052: * This method must be called by AWT to establish the connection
053: * @param internals - implementation of ComponentInternals created by AWT
054: */
055: public static void setComponentInternals(
056: ComponentInternals internals) {
057: ContextStorage.setComponentInternals(internals);
058: }
059:
060: /**
061: * The accessor to native resource connected to a component.
062: * It returns non-<code>null</code> value only if component
063: * already has the native resource
064: */
065: public abstract NativeWindow getNativeWindow(Component component);
066:
067: /**
068: * Connect Window object to existing native resource
069: * @param nativeWindowId - id of native window to attach
070: * @return Window object with special behaviour that
071: * restricts manupulation with that window
072: */
073: public abstract Window attachNativeWindow(long nativeWindowId);
074:
075: /**
076: * Start mouse grab in "client" mode.
077: * All mouse events in AWT components will be reported as usual,
078: * mouse events that occured outside of AWT components will be sent to
079: * the window passed as grabWindow parameter. When mouse grab is canceled
080: * (because of click in non-AWT window or by task switching)
081: * the whenCanceled callback is called
082: *
083: * @param grabWindow - window that will own the grab
084: * @param whenCanceled - callback called when grab is canceled by user's action
085: */
086: public abstract void startMouseGrab(Window grabWindow,
087: Runnable whenCanceled);
088:
089: /**
090: * End mouse grab and resume normal processing of mouse events
091: */
092: public abstract void endMouseGrab();
093:
094: /**
095: * Set the <code>popup</code> flag of the window to true.
096: * This window won't be controlled by window manager on Linux.
097: * Call this method before the window is shown first time
098: * @param window - the window that should become popup one
099: */
100: public abstract void makePopup(Window window);
101:
102: /**
103: * This method must be called by Graphics at the beginning of drawImage()
104: * to store image drawing parameters (defined by application developer) in component
105: *
106: * @param comp - component that draws the image
107: * @param image - image to be drawn
108: * @param destLocation - location of the image upon the component's surface. Never null.
109: * @param destSize - size of the component's area to be filled with the image.
110: * Equals to null if size parameters omitted in drawImage.
111: * @param source - area of the image to be drawn on the component.
112: * Equals to null if src parameters omitted in drawImage.
113: */
114: public abstract void onDrawImage(Component comp, Image image,
115: Point destLocation, Dimension destSize, Rectangle source);
116:
117: /**
118: * Sets system's caret position.
119: * This method should be called by text component to synchronize our caret position
120: * with system's caret position.
121: * @param x
122: * @param y
123: */
124: public abstract void setCaretPos(Component c, int x, int y);
125:
126: /**
127: * NEVER USE IT. FORGET IT. IT DOES NOT EXIST.
128: * See Toolkit.unsafeInvokeAndWait(Runnable).
129: *
130: * Accessor for Toolkit.unsafeInvokeAndWait(Runnable) method.
131: * For use in exceptional cases only.
132: * Read comments for Toolkit.unsafeInvokeAndWait(Runnable) before use.
133: */
134: public abstract void unsafeInvokeAndWait(Runnable runnable)
135: throws InterruptedException, InvocationTargetException;
136:
137: public abstract TextKit getTextKit(Component comp);
138:
139: public abstract void setTextKit(Component comp, TextKit kit);
140:
141: public abstract TextFieldKit getTextFieldKit(Component comp);
142:
143: public abstract void setTextFieldKit(Component comp,
144: TextFieldKit kit);
145:
146: /**
147: * Terminate event dispatch thread, completely destroy AWT context.<br>
148: * Intended for multi-context mode, in single-context mode does nothing.
149: *
150: */
151: public abstract void shutdown();
152:
153: /**
154: * Sets mouse events preprocessor for event queue
155: */
156: public abstract void setMouseEventPreprocessor(
157: MouseEventPreprocessor preprocessor);
158:
159: /**
160: * Create customized Choice using style
161: */
162: public abstract Choice createCustomChoice(ChoiceStyle style);
163:
164: public abstract Insets getNativeInsets(Window w);
165:
166: /**
167: * Region to be repainted (could be null). Use this in overridden repaint()
168: */
169: public abstract MultiRectArea getRepaintRegion(Component c);
170:
171: public abstract MultiRectArea subtractPendingRepaintRegion(
172: Component c, MultiRectArea mra);
173:
174: /**
175: * Returns true if the window was at least once painted due to native paint events
176: */
177: public abstract boolean wasPainted(Window w);
178:
179: /**
180: * The component's region hidden behind top-level windows
181: * (belonging to both this Java app and all other apps), and behind
182: * heavyweight components overlapping with passed component
183: */
184: public abstract MultiRectArea getObscuredRegion(Component c);
185:
186: /**
187: * An accessor to Container.addObscuredRegions() method
188: * @see java.awt.Container#addObscuredRegions(MultiRectArea, Component)
189: */
190: public abstract void addObscuredRegions(MultiRectArea mra,
191: Component c, Container container);
192:
193: /**
194: * Makes it possible to call protected Toolkit.setDesktopProperty()
195: * method from any class outside of java.awt package
196: */
197: public abstract void setDesktopProperty(String name, Object value);
198:
199: /**
200: * Makes it possible to start/stop dialog modal loop
201: * from anywhere outside of java.awt package
202: */
203: public abstract void runModalLoop(Dialog dlg);
204:
205: public abstract void endModalLoop(Dialog dlg);
206:
207: /**
208: * Sets component's visible flag only
209: * (the component is not actually shown/hidden)
210: */
211: public abstract void setVisibleFlag(Component comp, boolean visible);
212:
213: }
|