/*
* 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.
*/
// Very much based on XListPeer from javaos
// TODO: some input actions should do nothing if Shift or Control are down
// scrollbar
// scrollbar
private final static int PAINT_ALL =
// TODO: ick - Vector?
boolean multipleSelections;
// Holds the array of the indexes of the elements which is selected
// This array should be kept sorted, low to high.
int selected[];
int fontHeight;
int fontAscent;
int fontLeading;
// Holds the index of the item used in the previous operation (selectItem, deselectItem)
// Adding of an item or clearing of the list sets this index to -1
// The index is used at the moment of the post of ACTION_PERFORMED event after the mouse double click event.
// Used for tracking selection/deselection between mousePress/Release
// and for ItemEvents
// Holds the index of the item that receive focus
// This variable is reasonable only for multiple list
// since 'focusIndex' and 'selected[0]' are equal for single-selection list
int focusIndex;
int maxLength;
boolean hsbVis;
// (i.e. without scrollbars)
// Motif Lists don't seem to inherit the background color from their
// parent when an app is first started up. So, we track if the colors have
// been set. See getListBackground()/getListForeground().
boolean bgColorSet;
boolean fgColorSet;
// 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 mouseDraggedOutHorizontally = false;
boolean mouseDraggedOutVertically = false;
// Holds the true if a mouse event was originated on the scrollbar
// See 6300527 for more information
boolean isScrollBarOriginated = false;
// This variable is set to true after the "mouse pressed" event and to false after the "mouse released" event
// Fixed 6293432: Key events ('SPACE', 'UP', 'DOWN') aren't blocked if mouse is kept in 'PRESSED' state for List, XAWT
boolean isMousePressed = false;
/**
* Create a list
*/
super(target);
}
/**
* Overridden from XWindow
*/
// Stuff that must be initialized before layout() is called
painter = new ListPainter();
// See 6246467 for more information
}
// TODO: more efficient way?
// get all items from target
int stop = l.getItemCount();
for (int i = 0 ; i < stop; i++) {
}
/* make the visible position visible. */
int index = l.getVisibleIndex();
if (index >= 0) {
// Can't call makeVisible since it check scroll bar,
// initialize scroll bar instead
}
// NOTE: needs to have target set
// get the index containing all indexes to selected items
int sel[] = l.getSelectedIndexes();
// TODO: shouldn't this be arraycopy()?
}
// The select()ed item should become the focused item, but we don't
// get the select() call because the peer generally hasn't yet been
// created during app initialization.
// TODO: For multi-select lists, it should be the highest selected index
}
else {
setFocusIndex(0);
}
multipleSelections = l.isMultipleMode();
}
/**
* add Vertical Scrollbar
*/
void createVerScrollbar() {
vsb = new XVerticalScrollbar(this);
}
/**
* add Horizontal scrollbar
*/
void createHorScrollbar() {
hsb = new XHorizontalScrollbar(this);
}
/* New method name for 1.1 */
}
/* New method name for 1.1 */
public void removeAll() {
clear();
maxLength = 0;
}
/* New method name for 1.1 */
public void setMultipleMode (boolean b) {
}
/* New method name for 1.1 */
return preferredSize(rows);
}
/* New method name for 1.1 */
return minimumSize(rows);
}
/**
* Minimum size.
*/
return minimumSize(DEFAULT_VISIBLE_ROWS);
}
/**
* return the preferredSize
*/
return minimumSize(v);
}
/**
* return the minimumsize
*/
}
/**
* Calculate font metrics
*/
void initFontMetrics() {
}
/**
* return the length of the largest item in the list
*/
int maxLength() {
int m = 0;
for(int i = 0 ; i < end ; i++) {
}
return m;
}
/**
* Calculates the width of item's label
*/
int getItemWidth(int i) {
}
/**
* return the on-screen width of the given string "str"
*/
}
fgColorSet = true;
super.setForeground(c);
}
bgColorSet = true;
super.setBackground(c);
}
/**
* Returns the color that should be used to paint the background of
* the list of items. Note that this is not the same as
* target.getBackground() which is the color of the scrollbars, and the
* lower-right corner of the Component when the scrollbars are displayed.
*/
if (bgColorSet) {
return colors[BACKGROUND_COLOR];
}
else {
return SystemColor.text;
}
}
/**
* Returns the color that should be used to paint the list item text.
*/
if (fgColorSet) {
return colors[FOREGROUND_COLOR];
}
else {
return SystemColor.textText;
}
}
}
}
int getFirstVisibleItem() {
if (vsbVis) {
} else {
return 0;
}
}
int getLastVisibleItem() {
if (vsbVis) {
} else {
}
}
Graphics g = getGraphics();
}
}
}
/**
* Overridden for performance
*/
public void repaint() {
}
}
}
/**
* In most cases the entire area of the component doesn't have
* to be repainted. The method repaints the particular areas of
* the component. The areas to repaint is specified by the option
* parameter. The possible values of the option parameter are:
* PAINT_VSCROLL, PAINT_HSCROLL, PAINT_ITEMS, PAINT_FOCUS,
* PAINT_HIDEFOCUS, PAINT_BACKGROUND, PAINT_ALL, COPY_AREA.
*
* Note that the COPY_AREA value initiates copy of a source area
* of the component by a distance by means of the copyArea method
* of the Graphics class.
*
* @param firstItem the position of the first item of the range to repaint
* @param lastItem the position of the last item of the range to repaint
* @param options specifies the particular area of the component to repaint
* @param source the area of the component to copy
* @param distance the distance to copy the source area
*/
Graphics g = getGraphics();
try {
} finally {
g.dispose();
}
}
}
public boolean isFocusable() { return true; }
super.focusGained(e);
}
super.focusLost(e);
}
/**
* Layout the sub-components of the List - that is, the scrollbars and the
* list of items.
*/
public void layout() {
boolean vsbWasVisible;
int origVSBVal;
// Start with assumption there is not a horizontal scrollbar,
// see if we need a vertical scrollbar
// Bug: If the list DOES have a horiz scrollbar and the value is set to
// the very bottom value, value is reset in setValues() because it isn't
// a valid value for cases when the list DOESN'T have a horiz scrollbar.
// This is currently worked-around with origVSGVal.
vis = itemsInWindow(false);
listHeight = height;
// now see if we need a horizontal scrollbar
listWidth = getListWidth();
if (hsbVis) {
// do need a horizontal scrollbar, so recalculate height of
// vertical s crollbar
vis = itemsInWindow(true);
vsbVis = vsbIsVisible(true);
}
// now check to make sure we haven't changed need for vertical
// scrollbar - if we have, we need to
// recalculate horizontal scrollbar width - then we're done...
if (vsbWasVisible != vsbVis) {
listWidth = getListWidth();
}
}
int getItemWidth() {
}
/* Returns height of an item in the list */
int getItemHeight() {
}
int getItemX() {
}
}
int getFocusIndex() {
return focusIndex;
}
focusIndex = value;
}
/**
* Update and return the focus rectangle.
* Focus is around the focused item, if it is visible, or
* around the border of the list if the focused item is scrolled off the top
* or bottom of the list.
*/
// width is always only based on presence of vert sb
focusRect.x = 1;
// if focused item is not currently displayed in the list, paint
// focus around entire list (not including scrollbars)
if (isIndexDisplayed(getFocusIndex())) {
// focus rect is around the item
} else {
// focus rect is around the list
focusRect.y = 1;
}
return focusRect;
}
super.handleConfigureNotifyEvent(xev);
// Update buffer
}
public boolean handlesWheelScrolling() { return true; }
// FIXME: need to support MouseWheel scrolling, too
super.handleJavaMouseEvent(e);
int i = e.getID();
switch (i) {
case MouseEvent.MOUSE_PRESSED:
mousePressed(e);
break;
case MouseEvent.MOUSE_RELEASED:
mouseReleased(e);
break;
case MouseEvent.MOUSE_DRAGGED:
mouseDragged(e);
break;
}
}
repaint();
}
}
if (log.isLoggable(PlatformLogger.FINER)) log.finer(mouseEvent.toString() + ", hsb " + hsbVis + ", vsb " + vsbVis);
if (i >= 0) {
if (multipleSelections) {
if (isSelected(i)) {
// See 6243382 for more information
deselectItem(i);
eventIndex = i;
}
else {
selectItem(i);
eventIndex = i;
}
}
// Backward-compatible bug: even if a single-select
// item is already selected, we send an ITEM_STATE_CHANGED/
// SELECTED event. Engineer's Toolbox appears to rely on
// this.
//else if (!isSelected(i)) {
else {
selectItem(i);
eventIndex = i;
}
// Restoring Windows behaviour
// We should update focus index after "mouse pressed" event
setFocusIndex(i);
} else {
// 6426186: reset variable to prevent action event
// if user clicks on unoccupied area of list
currentIndex = -1;
}
mouseEvent.getY());
mouseEvent.getX(),
}
isMousePressed = true;
}
}
//winReleaseCursorFocus();
if (active == VERSCROLLBAR) {
mouseEvent.getY());
} else if(active == HORSCROLLBAR) {
mouseEvent.getX(),
// See 6243382 for more information
assert multipleSelections : "Shouldn't get a deselect for a single-select List";
// Paint deselection the release
}
eventType));
}
}
eventIndex = -1;
isMousePressed = false;
}
}
// TODO: can you drag w/ any other buttons? what about multiple buttons?
if (isEnabled() &&
if ((active == VERSCROLLBAR)) {
mouseEvent.getY());
} else if ((active == HORSCROLLBAR)) {
mouseEvent.getX(),
if (multipleSelections) {
// Multi-select only:
// If a selected item was pressed on and then dragged off
// of, cancel the pending deselect.
if (i != eventIndex) {
eventIndex = -1;
}
}
}
// Single-select only:
// If an unselected item was pressed on, track the drag
// and select the item under the mouse
// See 6243382 for more information
if (i >= 0 && !isSelected(i)) {
int oldSel = eventIndex;
selectItem(i);
eventIndex = i;
}
}
// Restoring Windows behaviour
// We should update focus index after "mouse dragged" event
if (i >= 0) {
setFocusIndex(i);
}
}
}
}
/*
* Helper method for XListPeer 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
*/
} else {
}
if (!mouseDraggedOutVertically){
mouseDraggedOutVertically = true;
}
}else{
mouseDraggedOutVertically = false;
}
}
} else {
}
if (!mouseDraggedOutHorizontally){
mouseDraggedOutHorizontally = true;
}
}else{
mouseDraggedOutHorizontally = false;
}
}
}
/*
* Helper method for XListPeer 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;
}
mouseDraggedOutHorizontally = false;
}
}
switch(e.getID()) {
case KeyEvent.KEY_PRESSED:
if (!isMousePressed){
keyPressed(e);
}
break;
}
}
int keyCode = e.getKeyCode();
switch(keyCode) {
if (getFocusIndex() > 0) {
// If single-select, select the item
if (!multipleSelections) {
}
if (isItemHidden(getFocusIndex())) {
}
else {
}
}
break;
// If single-select, select the item
if (!multipleSelections) {
}
if (isItemHidden(getFocusIndex())) {
}
else {
}
}
break;
case KeyEvent.VK_PAGE_UP: {
// Assumes that scrollbar does its own bounds-checking
// 6190768 pressing pg-up on AWT multiple selection lists the items but no item event is triggered, on XToolkit
// Restoring Motif behavior
if (previousValue!=currentValue) {
if (!multipleSelections){
}
}
repaint();
break;
}
case KeyEvent.VK_PAGE_DOWN: {
// Assumes that scrollbar does its own bounds-checking
// 6190768 pressing pg-down on AWT multiple selection list selects the items but no item event is triggered, on XToolkit
// Restoring Motif behavior
if (previousValue!=currentValue) {
if (!multipleSelections){
}
}
repaint();
break;
}
case KeyEvent.VK_KP_LEFT:
repaint();
}
break;
case KeyEvent.VK_KP_RIGHT:
if (hsbVis) { // Should check if already at end
repaint();
}
break;
// 6190778 CTRL + HOME, CTRL + END keys do not work properly for list on XToolkit
// Restoring Motif behavior
break;
if (vsbVis) {
}
setFocusIndex(0);
if (!multipleSelections) {
}
repaint();
break;
break;
if (vsbVis) {
}
if (!multipleSelections) {
}
repaint();
break;
// Fixed 6299853: XToolkit: Pressing space triggers ItemStateChanged event after List.removeAll called
// If getFocusIndex() is less than 0, the event will not be triggered when space pressed
break;
}
// Spacebar only deselects for multi-select Lists
if (multipleSelections && isSelected) {
}
else if (!isSelected) { // Note: this changes the Solaris/Linux
// behavior to match that of win32.
// That is, pressing space bar on a
// single-select list when the focused
// item is already selected does NOT
// send an ItemEvent.SELECTED event.
}
break;
// It looks to me like there are bugs as well as inconsistencies
// in the way the Enter key is handled by both Solaris and Windows.
// So for now in XAWT, I'm going to simply go by what the List docs
// say: "AWT also generates an action event when the user presses
// the return key while an item in the list is selected."
e.getWhen(),
e.getModifiers())); // ActionEvent doesn't have
// extended modifiers.
}
break;
}
}
/**
* return value from the scrollbar
*/
scrollVertical(v - value);
// See 6243382 for more information
int oldSel = eventIndex;
eventIndex = newSel;
// Scrolling select() should also set the focus index
// Otherwise, the updating of the 'focusIndex' variable will be incorrect
// if user drag mouse out of the area of the list
}
scrollHorizontal(v - value);
}
}
/**
* deselect all items in List
*/
private void deselectAllItems() {
selected = new int [0];
}
/**
* set multiple selections
*/
public void setMultipleSelections(boolean v) {
if (multipleSelections != v) {
if ( !v) {
if (selPos != -1){
}
}
multipleSelections = v;
}
}
/**
* add an item
* if the index of the item is < 0 or >= than items.size()
* then add the item to the end of the list
*/
int oldMaxLength = maxLength;
i = -1;
}
// Why we set this variable to -1 in spite of the fact that selected[] is changed in other way?
// It's not clear how to reproduce incorrect behaviour based on this assignment
// since before using this variable (mouseReleased) we certainly update it to correct value
// So we don't modify this behaviour now
currentIndex = -1;
if (i == -1) {
i = 0; // fix the math for the paintItems test
} else {
addedIndex = i;
if (selected[j] >= i) {
selected[j] += 1;
}
}
}
// Update maxLength
layout();
int options = 0;
// Scrollbars are being added or removed, so we must repaint all
}
else {
}
}
/**
* delete items starting with s (start position) to e (end position) including s and e
* if s < 0 then s = 0
* if e >= items.size() then e = items.size() - 1
*/
public void delItems(int s, int e) {
// save the current state of the scrollbars
boolean hsbWasVisible = hsbVis;
boolean vsbWasVisible = vsbVis;
int oldLastDisplayed = lastItemDisplayed();
if (log.isLoggable(PlatformLogger.FINEST)) log.finest("Last displayed item: " + oldLastDisplayed + ", items in window " + itemsInWindow() +
return;
}
// if user passed in flipped args, reverse them
if (s > e) {
int tmp = s;
s = e;
e = tmp;
}
// check for starting point less than zero
if (s < 0) {
s = 0;
}
// check for end point greater than the size of the list
}
// determine whether we're going to delete any visible elements
// can happen from removing a non-showing list item
/*
boolean repaintNeeded =
((s <= lastItemDisplayed()) && (e >= vsb.getValue()));
*/
// delete the items out of the items list and out of the selected list
for (int i = s ; i <= e ; i++) {
items.removeElementAt(s);
int j = posInSel(i);
if (j != -1) {
}
}
// update the indexes in the selected array
int diff = (e - s) + 1;
if (selected[i] > e) {
}
}
int options = PAINT_VSCROLL;
// focusedIndex updating according to native (Window, Motif) behaviour
if (getFocusIndex() > e) {
options |= PAINT_FOCUS;
} else if (getFocusIndex() >= s && getFocusIndex() <= e) {
// Fixed 6299858: PIT. Focused border not shown on List if selected item is removed, XToolkit
// We should set focus to new first item if the current first item was removed
// except if the list is empty
options |= PAINT_FOCUS;
}
if (log.isLoggable(PlatformLogger.FINEST)) log.finest("Multiple selections: " + multipleSelections);
// update vsb.val
} else {
}
}
int oldMaxLength = maxLength;
if (maxLength != oldMaxLength) {
// Width of the items changed affecting the range of
// horizontal scrollbar
options |= PAINT_HSCROLL;
}
layout();
repaintNeeded |= (vsbWasVisible ^ vsbVis) || (hsbWasVisible ^ hsbVis); // If scrollbars visibility changed
if (repaintNeeded) {
}
}
/**
* ListPeer method
*/
// Programmatic select() should also set the focus index
}
/**
* select the index
* redraw the list to the screen
*/
// NOTE: instead of recalculating and the calling repaint(), painting
// is done immediately
// 6190746 List does not trigger ActionEvent when double clicking a programmatically selected item, XToolkit
// If we invoke select(int) before setVisible(boolean), then variable currentIndex will equals -1. At the same time isSelected may be true.
// Restoring Motif behavior
if (isSelected(index)) {
return;
}
if (!multipleSelections) {
selected = new int[1];
}
else {
if (!isItemHidden(oldSel)) {
// Only bother painting if item is visible (4895367)
}
}
} else {
// insert "index" into the selection array
int i = 0;
i++;
}
}
if (!isItemHidden(index)) {
// Only bother painting if item is visible (4895367)
}
}
/**
* ListPeer method
* focusedIndex isn't updated according to native (Window, Motif) behaviour
*/
}
/**
* deselect the index
* redraw the list to the screen
*/
if (!isSelected(index)) {
return;
}
if (!multipleSelections) {
// TODO: keep an int[0] and int[1] around and just use them instead
// creating new ones all the time
selected = new int[0];
} else {
}
if (!isItemHidden(index)) {
// Only bother repainting if item is visible
}
}
/**
* ensure that the given index is visible, scrolling the List
* if necessary, or doing nothing if the item is already visible.
* The List must be repainted for changes to be visible.
*/
return;
}
// If index is above the top, scroll up
}
// If index is below the bottom, scroll down
else if (index > lastItemDisplayed()) {
}
}
}
/**
* clear
*/
public void clear() {
selected = new int[0];
currentIndex = -1;
// Fixed 6291736: ITEM_STATE_CHANGED triggered after List.removeAll(), XToolkit
// We should update 'focusIndex' variable more carefully
setFocusIndex(-1);
maxLength = 0;
layout();
repaint();
}
/**
* return the selected indexes
*/
public int[] getSelectedIndexes() {
return selected;
}
/**
* return the y value of the given index "i".
* the y value represents the top of the text
* NOTE: index can be larger than items.size as long
* as it can fit the window
*/
int h = getItemHeight();
//if (index < vsb.getValue() || index > vsb.getValue() + itemsInWindow()) {
}
/* return true if the y is a valid y coordinate for
* a VISIBLE list item, otherwise returns false
*/
boolean validY(int y) {
int shown = itemsDisplayed();
if (shown == itemsInWindow()) {
}
if (y < 0 || y >= lastY) {
return false;
}
return true;
}
/**
* return the position of the index in the selected array
* if the index isn't in the array selected return -1;
*/
return i;
}
}
return -1;
}
int lastDisplayed = lastItemDisplayed();
return idx <= lastDisplayed &&
}
/**
* returns index of last item displayed in the List
*/
int lastItemDisplayed() {
int n = itemsInWindow();
}
/**
* returns whether the given index is currently scrolled off the top or
* bottom of the List.
*/
}
/**
* returns the width of the list portion of the component (accounts for
* presence of vertical scrollbar)
*/
int getListWidth() {
}
/**
* returns number of items actually displayed in the List
*/
int itemsDisplayed() {
}
/**
* scrollVertical
* y is the number of items to scroll
*/
void scrollVertical(int y) {
int itemsInWin = itemsInWindow();
int h = getItemHeight();
int pixelsToScroll = y * h;
}
if (y > 0) {
if (y < itemsInWin) {
source = new Rectangle(MARGIN, MARGIN + pixelsToScroll, width - SCROLLBAR_AREA, h * (itemsInWin - y - 1)-1);
}
} else if (y < 0) {
if (y + itemsInWindow() > 0) {
}
}
}
/**
* scrollHorizontal
* x is the number of pixels to scroll
*/
void scrollHorizontal(int x) {
int w = getListWidth();
if (x < 0) {
} else if (x > 0) {
}
}
/**
* return the index
*/
int y2index(int y) {
if (!validY(y)) {
return -1;
}
int last = lastItemDisplayed();
if (i > last) {
i = last;
}
return i;
}
/**
* is the index "index" selected
*/
return true;
}
return true;
}
}
return false;
}
/**
* return the number of items that can fit
* in the current window
*/
int h;
if (scrollbarVisible) {
} else {
}
return (h / getItemHeight());
}
int itemsInWindow() {
return itemsInWindow(hsbVis);
}
/**
* return true if the x and y position is in the horizontal scrollbar
*/
boolean inHorizontalScrollbar(int x, int y) {
int w = getListWidth();
int h = height - SCROLLBAR_WIDTH;
return (hsbVis && (x >= 0) && (x <= w) && (y > h));
}
/**
* return true if the x and y position is in the verticalscrollbar
*/
boolean inVerticalScrollbar(int x, int y) {
int w = width - SCROLLBAR_WIDTH;
return (vsbVis && (x > w) && (y >= 0) && (y <= h));
}
/**
* return true if the x and y position is in the window
*/
boolean inWindow(int x, int y) {
int w = getListWidth();
return ((x >= 0) && (x <= w)) && ((y >= 0) && (y <= h));
}
/**
* return true if vertical scrollbar is visible and false otherwise;
* hsbVisible is the visibility of the horizontal scrollbar
*/
}
/**
* return true if horizontal scrollbar is visible and false otherwise;
* vsbVisible is the visibility of the vertical scrollbar
*/
return (maxLength > w);
}
/*
* Returns true if the event has been handled and should not be
* posted to Java
*/
if (e instanceof MouseEvent) {
return prePostMouseEvent((MouseEvent)e);
}
return super.prePostEvent(e);
}
/*
* Fixed 6240151: XToolkit: Dragging the List scrollbar initiates DnD
* To be compatible with Motif, MouseEvent originated on the scrollbar
* should be sent into Java in this way:
* - post: MOUSE_ENTERED, MOUSE_EXITED, MOUSE_MOVED
* - don't post: MOUSE_PRESSED, MOUSE_RELEASED, MOUSE_CLICKED, MOUSE_DRAGGED
*/
if (getToplevelXWindow().isModalBlocked()) {
return false;
}
{
// only for performance improvement
{
isScrollBarOriginated = false;
}
return true;
{
isScrollBarOriginated = true;
}
return true;
}
return false;
}
/*
* Do handleJavaMouseEvent on EDT
*/
public void run() {
}
});
}
/*
* Fixed 5010944: List's rows overlap one another
* The bug is due to incorrent caching of the list item size
* So we should recalculate font metrics on setFont
*/
super.setFont(f);
layout();
repaint();
}
/**
* Sometimes painter is called on Toolkit thread, so the lock sequence is:
* awtLock -> Painter -> awtLock
* Sometimes it is called on other threads:
* Painter -> awtLock
* Since we can't guarantee the sequence, use awtLock.
*/
class ListPainter {
if (fgColorSet) {
return colors[FOREGROUND_COLOR];
}
else {
return SystemColor.textText;
}
}
if (bgColorSet) {
return colors[BACKGROUND_COLOR];
}
else {
return SystemColor.text;
}
}
}
private boolean createBuffer() {
try {
} finally {
}
if (localBuffer == null) {
// use GraphicsConfig.cCVI() instead of Component.cVI(),
// because the latter may cause a deadlock with the tree lock
height+1);
}
try {
return true;
}
} finally {
}
return false;
}
public void invalidate() {
try {
}
} finally {
}
}
}
if (log.isLoggable(PlatformLogger.FINER)) log.finer("Repaint from " + firstItem + " to " + lastItem + " options " + options);
int t = lastItem;
firstItem = t;
}
if (firstItem < 0) {
firstItem = 0;
}
colors = getGUIcolors();
do {
try {
if (createBuffer()) {
// First time created buffer should be painted over at full.
}
} finally {
}
invalidate();
continue;
case VolatileImage.IMAGE_RESTORED:
}
// Note that the order of the following painting operations
// should not be modified
try {
// hiding the focus rectangle must be done prior to copying
// area and so this is the first action to be performed
}
/*
* The shift of the component contents occurs while someone
* scrolls the component, the only purpose of the shift is to
* increase the painting performance. The shift should be done
* prior to painting any area (except hiding focus) and actually
* it should never be done jointly with erase background.
*/
}
paintBackground(g);
// Since we made full erase update items
}
}
g.setClip(getVScrollBarRec());
paintVerScrollbar(g, true);
}
g.setClip(getHScrollBarRec());
paintHorScrollbar(g, true);
}
paintFocus(g, PAINT_FOCUS);
}
} finally {
g.dispose();
}
} while (localBuffer.contentsLost());
}
g.setColor(getListBackground());
}
if (log.isLoggable(PlatformLogger.FINER)) log.finer("Painting items from " + firstItem + " to " + lastItem + ", focused " + focusIndex + ", first " + getFirstVisibleItem() + ", last " + getLastVisibleItem());
int t = lastItem;
firstItem = t;
}
if (log.isLoggable(PlatformLogger.FINER)) log.finer("Actually painting items from " + firstItem + " to " + lastItem +
", items in window " + itemsInWindow());
paintItem(g, i);
}
}
// 4895367 - only paint items which are visible
if (!isItemHidden(index)) {
int w = getItemWidth();
int h = getItemHeight();
int x = getItemX();
if (log.isLoggable(PlatformLogger.FINEST)) log.finest("Setting clip " + new Rectangle(x, y, w - (SPACE*2), h-(SPACE*2)));
// Always paint the background so that focus is unpainted in
// multiselect mode
if (isSelected(index)) {
g.setColor(getListForeground());
} else {
g.setColor(getListBackground());
}
g.fillRect(x, y, w, h);
if (!isEnabled()){
g.setColor(getDisabledColor());
} else if (isSelected(index)) {
g.setColor(getListBackground());
} else {
g.setColor(getListForeground());
}
} else {
// Clear the remaining area around the item - focus area and the rest of border
g.setColor(getListBackground());
}
}
}
void paintScrollBar(XScrollbar scr, Graphics g, int x, int y, int width, int height, boolean paintAll) {
g.translate(x, y);
g.translate(-x, -y);
}
/**
* Paint the horizontal scrollbar to the screen
*
* @param g the graphics context to draw into
* @param colors the colors used to draw the scrollbar
* @param paintAll paint the whole scrollbar if true, just the thumb if false
*/
int w = getListWidth();
}
/**
* Paint the vertical scrollbar to the screen
*
* @param g the graphics context to draw into
* @param colors the colors used to draw the scrollbar
* @param paintAll paint the whole scrollbar if true, just the thumb if false
*/
}
if (paintFocus && !hasFocus()) {
paintFocus = false;
}
if (log.isLoggable(PlatformLogger.FINE)) log.fine("Painting focus, focus index " + getFocusIndex() + ", focus is " +
if (log.isLoggable(PlatformLogger.FINEST)) log.finest("Setting focus clip " + new Rectangle(0, 0, listWidth, listHeight));
if (prevFocusRect != null) {
// Erase focus rect
if (log.isLoggable(PlatformLogger.FINEST)) log.finest("Erasing previous focus rect " + prevFocusRect);
g.setColor(getListBackground());
}
if (paintFocus) {
// Paint new
}
}
}
}