/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* A composition area is used to display text that's being composed
* using an input method in its own user interface environment,
* typically in a root window.
*
* @author JavaSoft International
*/
// This class is final due to the 6607310 fix. Refer to the CR for details.
CompositionArea() {
// create composition window with localized title
setOpaque(true);
// if we get the focus, we still want to let the client's
// input context handle the event
enableInputMethods(true);
addInputMethodListener(this);
compositionWindow.enableInputMethods(false);
compositionWindow.setVisible(false);
}
/**
* Sets the composition area handler that currently owns this
* composition area, and its input context.
*/
}
/**
* @see java.awt.Component#getInputMethodRequests
*/
return handler;
}
// returns a 0-width rectangle
int caretLocation = 0;
}
Graphics g = getGraphics();
try {
metrics = g.getFontMetrics();
} finally {
g.dispose();
}
}
super.paint(g);
g.setColor(getForeground());
}
g.setXORMode(getBackground());
g.setPaintMode();
}
}
}
// returns true if composition area is visible
boolean isCompositionAreaVisible() {
return compositionWindow.isVisible();
}
// workaround for the Solaris focus lost problem
requestFocus();
}
}
// InputMethodListener methods - just forward to the current handler
}
}
/**
* Sets the text and caret to be displayed in this composition area.
* Shows the window if it contains text, hides it if not.
*/
if (composedText == null) {
// there's no composed text to display, so hide the window
compositionWindow.setVisible(false);
} else {
/* since we have composed text, make sure the window is shown.
This is necessary to get a valid graphics object. See 6181385.
*/
if (!compositionWindow.isVisible()) {
compositionWindow.setVisible(true);
}
Graphics g = getGraphics();
if (g == null) {
return;
}
try {
// Resize the composition area to just fit the text.
// If it's a passive client, set the width always to PASSIVE_WIDTH (480px)
// show the composed text
paint(g);
}
finally {
g.dispose();
}
}
}
/**
* Sets the caret to be displayed in this composition area.
* The text is not changed.
*/
if (compositionWindow.isVisible()) {
Graphics g = getGraphics();
try {
paint(g);
} finally {
g.dispose();
}
}
}
/**
* Positions the composition window near (usually below) the
* insertion point in the client component if the client
* component is an active client (below-the-spot input).
*/
void updateWindowLocation() {
// not an active client
return;
}
final int SPACING = 2;
} else {
windowLocation.x = caretRect.x;
}
} else {
}
}
// support for InputMethodRequests methods
return rectangle;
}
return null;
} else {
x -= location.x + TEXT_ORIGIN_X;
y -= location.y + TEXT_ORIGIN_Y;
return layout.hitTestChar(x, y);
} else {
return null;
}
}
}
// Disables or enables decorations of the composition window
if (compositionWindow.isDisplayable()){
}
}
}