CLChoice.java revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* ident "%Z%%M% %I% %E% SMI"
*
* Copyright (c) 2000 by Sun Microsystems, Inc.
* All rights reserved.
*/
/**
* Copyright 1996 Active Software Inc.
*
* @version @(#)CLChoice.java 1.13 97/06/18
*/
public class CLChoice extends CLIconLabel
{
private int selectedIndex = -1;
private int itemsVisible = 12;
private boolean allowSuffix;
private boolean dragging;
private Window menuWindow;
private int menuWindowX, menuWindowY;
private boolean forwarding;
public CLChoice() {
}
}
}
}
this.selectedIndex = 0;
} else {
}
}
this.selectedIndex = 0;
} else {
}
}
boolean allowSuffix) {
this.allowSuffix = allowSuffix;
this.selectedIndex = 0;
} else {
}
}
public void setItemsVisible(int num) {
if (num <= 0)
num = 1;
itemsVisible = num;
}
public int getItemsVisible() {
return itemsVisible;
}
}
public int countItems() {
}
for (int i = 0; i < length; i++)
return s;
}
this.items.removeAllElements();
}
}
}
public void removeItem(int index) {
return;
menu.updateView();
}
int selectedIndex = getSelectedIndex();
if (selectedIndex != -1) {
if (selectedIndex == index)
select(0);
else if (selectedIndex > index)
}
}
public int getSelectedIndex() {
return -1;
else
return selectedIndex;
}
public String getSelectedItem() {
return null;
else
}
}
return;
int index = -1;
if (allowSuffix) {
for (int i = 0; i < length; i++) {
index = i;
break;
}
}
} else {
}
}
}
if (index < 0)
index = 0;
if (index != selectedIndex) {
} else {
}
}
}
}
return getSelectedItem();
}
public void setAllowSuffix(boolean allowSuffix) {
this.allowSuffix = allowSuffix;
}
public boolean getAllowSuffix() {
return allowSuffix;
}
return false;
showMenu();
dragging = true;
return true;
} else {
return false;
}
}
void cancelEdit() {
hideMenu();
}
// Events are sent here subsequent to the mouseDown.
return false;
dragging = false;
hideMenu();
} else if (dragging) {
canvas.getEditColumn());
dragging = false;
canvas.cancelEdit();
}
}
} else {
return false;
}
return true;
}
private void showMenu() {
} else {
}
} else {
// Don't remove the menu from the canvas on Windows. If you do,
// you start getting spurious double-clicks! But you do want
// to remove it on Motif, otherwise the canvas becomes incapable
// of getting the keyboard focus.
}
while (e.hasMoreElements())
}
} else {
menuWindow.show();
}
}
private void hideMenu() {
// Don't remove the menu from the canvas on Windows. If you do,
// you start getting spurious double-clicks! But you do want
// to remove it on Motif, otherwise the canvas becomes incapable
// of getting the keyboard focus.
} else {
menuWindow.hide();
menuWindow = null;
menuWindowX = 0;
menuWindowY = 0;
}
}
}
int column) {
if (forwarding)
return;
} else {
return;
offset.x = menuWindowX;
offset.y = menuWindowY;
}
forwarding = true;
// Don't set the menuDrag flag based on a forwarded event.
forwarding = false;
}
int hPad = 6;
int spaceAbove = y;
int availableHeight;
boolean below;
below = true;
} else {
below = false;
}
if (below)
else
r.y = y - r.height;
return r;
}
int hPad = 6;
r.height = prefHeight;
// The Window instance cannot be resized narrower than 112 or shorter
// than 27. This is a lame AWT restriction for Windows95.
// Subtract for taskbar
if (r.x < 0)
r.x = 0;
r.y -= (r.height + lineHeight);
if (r.y < 0)
r.y = 0;
menuWindowX = r.x - offset.x;
menuWindowY = r.y - offset.y;
return r;
}
}
break;
}
return offset;
}
}