/*
* 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.
*/
// FIXME: implement multi-select
/*
* Class to paint a list of items, possibly with scrollbars
* This class paints all items with the same font
* For now, this class manages the list of items and painting thereof, but not
* posting of Item or ActionEvents
*/
// of items
// of items and and item's bg, and between
// items
// the text
// TODO: maybe this would be better as a simple int[]
// at once?
private int focusedIndex;
private boolean vsbVis;
private boolean hsbVis;
// on notifyValue()
// Holds the true if mouse is dragging outside of the area of the list
// The flag is used at the moment of the dragging and releasing mouse
// See 6243382 for more information
boolean mouseDraggedOutVertically = false;
private volatile boolean vsbVisibilityChanged = false;
/*
* Comment
*/
int initialSize,
boolean multiSelect,
boolean scrollVert,
boolean scrollHoriz,
int maxVisItems,
int SPACE,
int MARGIN,
int BORDER,
int SCROLLBAR) {
this.multiSelect = multiSelect;
this.maxVisItems = maxVisItems;
if (scrollVert) {
vsb = new XVerticalScrollbar(this);
}
if (scrollHoriz) {
hsb = new XHorizontalScrollbar(this);
}
TEXT_SPACE = SPACE;
}
return peer.getEventSource();
}
/**********************************************************************/
/* List management methods */
/**********************************************************************/
}
}
// FIXME: need to clean up select list, too?
// Is vsb visible now?
}
// FIXME: need to clean up select list, too?
// Is vsb visible now?
}
public void removeAll() {
}
multiSelect = ms;
}
/*
* docs.....definitely docs
* merely keeps internal track of which items are selected for painting
* dealing with target Components happens elsewhere
*/
}
if (multiSelect) {
assert false : "Implement ListHelper.select() for multiselect";
}
else if (getSelectedIndex() != index) {
}
}
/* docs */
assert(false);
}
/* docs */
/* if called for multiselect, return -1 */
public int getSelectedIndex() {
if (!multiSelect) {
}
return -1;
}
/*
* A getter method for XChoicePeer.
* Returns vsbVisiblityChanged value and sets it to false.
*/
public boolean checkVsbVisibilityChangedAndReset(){
boolean returnVal = vsbVisibilityChanged;
vsbVisibilityChanged = false;
return returnVal;
}
public boolean isEmpty() {
}
public int getItemCount() {
}
}
/**********************************************************************/
/* GUI-related methods */
/**********************************************************************/
}
return index == focusedIndex;
}
// Also cache stuff like fontHeight?
}
}
/*
* Returns width of the text of the longest item
*/
public int getMaxItemWidth() {
int m = 0;
int end = getItemCount();
for(int i = 0 ; i < end ; i++) {
}
return m;
}
/*
* Height of an item (this doesn't include ITEM_MARGIN)
*/
int getItemHeight() {
}
public int y2index(int y) {
+ ",item_margin=" + ITEM_MARGIN);
}
// See 6243382 for more information
return newIdx;
}
/* write these
int index2y(int);
public int numItemsDisplayed() {}
*/
public int firstDisplayedIndex() {
if (vsbVis) {
}
return 0;
}
public int lastDisplayedIndex() {
// FIXME: need to account for horiz scroll bar
if (hsbVis) {
assert false : "Implement for horiz scroll bar";
}
}
/*
* If the given index is not visible in the List, scroll so that it is.
*/
if (vsbVis) {
if (index < firstDisplayedIndex()) {
}
else if (index > lastDisplayedIndex()) {
}
}
}
// FIXME: multi-select needs separate focused index
public void up() {
int curIdx = getSelectedIndex();
int numItems = getItemCount();
int newIdx;
assert curIdx >= 0;
if (curIdx == 0) {
}
else {
}
// focus(newIdx);
}
public void down() {
}
public void pageUp() {
// FIXME: for multi-select, move the focused item, not the selected item
if (multiSelect) {
assert false : "Implement pageUp() for multiSelect";
}
else {
// the vsb does bounds checking
}
}
}
public void pageDown() {
if (multiSelect) {
assert false : "Implement pageDown() for multiSelect";
}
else {
// the vsb does bounds checking
int newIdx = lastDisplayedIndex();
}
}
}
public void home() {}
public void end() {}
if (vsbVis) {
(y >= 0) &&
(y <= sbHeight);
}
return false;
}
if (hsbVis) {
return (x <= sbWidth) &&
(x >= 0) &&
}
return false;
}
e.getModifiers(),
y);
}
/*
* Update whether the scrollbar is visible or not, scrollbar values
*/
void updateScrollbars() {
if (vsbVis) {
}
// 6405689. If Vert Scrollbar gets disappeared from the dropdown menu we should repaint whole dropdown even if
// no actual resize gets invoked. This is needed because some painting artifacts remained between dropdown items
// but draw3DRect doesn't clear the area inside. Instead it just paints lines as borders.
// FIXME: check if added item makes a hsb necessary (if supported, that of course)
}
public int getNumItemsDisplayed() {
}
}
}
g.dispose();
}
// See 6243382 for more information
int oldItemValue = getSelectedIndex();
}
// FIXME: how are we going to paint!?
int first = v;
v + maxVisItems);
if (needRepaint) {
}
g.dispose();
}
// FIXME: how are we going to paint!?
}
}
}
/*
public void paintItems(Graphics g,
Color[] colors,
Rectangle bounds,
Font font,
int first,
int last,
XVerticalScrollbar vsb,
XHorizontalScrollbar hsb) {
*/
// paint border
// paint items
// paint scrollbars
// paint focus?
}
}
int first,
int last) {
int x = BORDER_WIDTH + ITEM_MARGIN;
int height = getItemHeight();
int y = BORDER_WIDTH + ITEM_MARGIN;
isItemSelected(i),
isFocusedIndex(i));
}
if (vsbVis) {
}
if (hsbVis) {
}
// FIXME: if none of the items were focused, paint focus around the
// entire list. This is how java.awt.List should work.
}
/*
* comment about what is painted (i.e. the focus rect
*/
boolean selected,
boolean focused) {
//System.out.println("LP.pI(): x="+x+" y="+y+" w="+width+" h="+height);
//g.setColor(colors[BACKGROUND_COLOR]);
// FIXME: items shouldn't draw into the scrollbar
if (selected) {
}
else {
}
if (focused) {
//g.setColor(colors[XComponentPeer.FOREGROUND_COLOR]);
g.drawRect(x + FOCUS_INSET,
y + FOCUS_INSET,
}
if (selected) {
}
else {
}
//Rectangle clip = g.getClipBounds();
//g.clipRect(x, y, width, height);
//g.drawString(string, x + TEXT_SPACE, y + TEXT_SPACE + ITEM_MARGIN);
//g.clipRect(clip.x, clip.y, clip.width, clip.height);
}
return true;
}
}
return false;
}
try {
// Update scrollbar's size
} finally {
}
}
}
/*
* Helper method for Components with integrated scrollbars.
* and the MouseWheelEvent, and the appropriate scrollbar will be scrolled
* correctly.
* Returns whether or not scrolling actually took place. This will indicate
* whether or not repainting is required.
*/
MouseWheelEvent e) {
int wheelRotation;
// Determine which, if any, sb to scroll
}
}
else { // Neither scrollbar is showing
return false;
}
wheelRotation = e.getWheelRotation();
// Check if scroll is necessary
wheelRotation != 0) {
int type = e.getScrollType();
int incr;
}
else { // type is WHEEL_UNIT_SCROLL
}
return true;
}
return false;
}
/*
* Helper method for XChoicePeer with integrated vertical scrollbar.
* Start or stop vertical scrolling when mouse dragged in / out the area of the list if it's required
* Restoring Motif behavior
* See 6243382 for more information
*/
if (!mouseDraggedOutVertically){
} else {
}
}
mouseDraggedOutVertically = true;
}
if (mouseDraggedOutVertically && mouseY >= 0 && mouseY < listHeight && mouseX >= 0 && mouseX < listWidth){
mouseDraggedOutVertically = false;
}
}
/*
* Helper method for XChoicePeer with integrated vertical scrollbar.
* Stop vertical scrolling when mouse released in / out the area of the list if it's required
* Restoring Motif behavior
* see 6243382 for more information
*/
void trackMouseReleasedScroll(){
mouseDraggedOutVertically = false;
}
}
}