/*
* 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.
*/
/************************************************
*
* Data members
*
************************************************/
/*
* Primary members
*/
/*
* dimension constants
*/
/*
* Checkmark
*/
/************************************************
*
* Mapping data
*
************************************************/
/**
* Rectangle for the caption
* Necessary to fix 6267144: PIT: Popup menu label is not shown, XToolkit
*/
/**
* Desired size of menu window
*/
/**
* Width of largest checkmark
* At the same time the left origin
* of all item's text
*/
private int leftMarkWidth;
/**
* Left origin of all shortcut labels
*/
private int shortcutOrigin;
/**
* The origin of right mark
* (submenu's arrow)
*/
private int rightMarkOrigin;
MappingData(XMenuItemPeer[] items, Rectangle captionRect, Dimension desiredSize, int leftMarkWidth, int shortcutOrigin, int rightMarkOrigin) {
super(items);
this.captionRect = captionRect;
this.desiredSize = desiredSize;
this.leftMarkWidth = leftMarkWidth;
this.shortcutOrigin = shortcutOrigin;
this.rightMarkOrigin = rightMarkOrigin;
}
/**
* Constructs MappingData without items
* This constructor should be used in case of errors
*/
MappingData() {
this.leftMarkWidth = 0;
this.shortcutOrigin = 0;
this.rightMarkOrigin = 0;
}
return this.captionRect;
}
return this.desiredSize;
}
public int getShortcutOrigin() {
return this.shortcutOrigin;
}
public int getLeftMarkWidth() {
return this.leftMarkWidth;
}
public int getRightMarkOrigin() {
return this.rightMarkOrigin;
}
}
/************************************************
*
* Construction
*
************************************************/
/**
* Constructs XMenuWindow for specified XMenuPeer
* null for XPopupMenuWindow
*/
// Get menus from the target.
}
}
/************************************************
*
* Initialization
*
************************************************/
/*
* Overriden initialization
*/
//Fixed 6267182: PIT: Menu is not visible after
//showing and disposing a file dialog, XToolkit
//toFront() is called on every show
}
/************************************************
*
* Implementation of abstract methods
*
************************************************/
/**
* @see XBaseMenuWindow.getParentMenuWindow()
*/
}
/**
* @see XBaseMenuWindow.map()
*/
//TODO:Implement popup-menu caption mapping and painting and tear-off
int itemCnt;
if (!isCreated()) {
MappingData mappingData = new MappingData(new XMenuItemPeer[0], new Rectangle(0, 0, 0, 0), new Dimension(0, 0), 0, 0, 0);
return mappingData;
}
//We need maximum width of components before calculating item's bounds
int maxLeftIndent = 0;
int maxRightIndent = 0;
int maxShortcutWidth = 0;
for (int i = 0; i < itemCnt; i++) {
if (itemVector[i] instanceof XCheckboxMenuItemPeer) {
} else if (itemVector[i] instanceof XMenuPeer) {
}
}
}
//Calculate bounds
int nextOffset = WINDOW_SPACING_TOP;
if (maxShortcutWidth > 0) {
}
//Caption rectangle
if (captionSize != null) {
} else {
}
//Item rectangles
for (int i = 0; i < itemCnt; i++) {
Point textOrigin = new Point(WINDOW_SPACING_LEFT + WINDOW_ITEM_MARGIN_LEFT + maxLeftIndent, nextOffset + y);
nextOffset += itemHeight;
} else {
//Text metrics could not be determined because of errors
//Map item with empty rectangle
Point textOrigin = new Point(WINDOW_SPACING_LEFT + WINDOW_ITEM_MARGIN_LEFT + maxLeftIndent, nextOffset);
}
}
MappingData mappingData = new MappingData(itemVector, captionRect, new Dimension(width, height), maxLeftIndent, shortcutOrigin, rightMarkOrigin);
return mappingData;
}
/**
* @see XBaseMenuWindow.getSubmenuBounds()
*/
return res;
}
return res;
}
return res;
}
return res;
}
}
/**
* It's likely that size of items was changed
* invoke resizing of window on eventHandlerThread
*/
protected void updateSize() {
resetMapping();
if (isShowing()) {
public void run() {
}
});
}
}
/************************************************
*
* Overridable caption-painting functions
* Necessary to fix 6267144: PIT: Popup menu label is not shown, XToolkit
*
************************************************/
/**
* Returns size of menu window's caption or null
* if window has no caption.
* Can be overriden for popup menus and tear-off menus
*/
return null;
}
/**
* Paints menu window's caption.
* Can be overriden for popup menus and tear-off menus.
* Default implementation does nothing
*/
}
/************************************************
*
* General-purpose utility functions
*
************************************************/
/**
* Returns corresponding menu peer
*/
return menuPeer;
}
/**
* Reads vector of items from target
* This function is overriden in XPopupMenuPeer
*/
return menuPeer.getTargetItems();
}
/**
* Returns desired size calculated while mapping
*/
return mappingData.getDesiredSize();
}
/**
* Checks if menu window is created
*/
boolean isCreated() {
return getWindow() != 0;
}
/**
* Performs delayed creation of menu window if necessary
*/
boolean ensureCreated() {
if (!isCreated()) {
}
return true;
}
/**
* Init window if it's not inited yet
* and show it at specified coordinates
* @param bounds bounding rectangle of window
* in global coordinates
*/
if (!isCreated()) {
return;
}
}
try {
xSetVisible(true);
//Fixed 6267182: PIT: Menu is not visible after
//showing and disposing a file dialog, XToolkit
toFront();
selectItem(getFirstSelectableItem(), false);
} finally {
}
}
/**
* Hides menu window
*/
void hide() {
selectItem(null, false);
xSetVisible(false);
}
/************************************************
*
* Painting
*
************************************************/
/**
* Paints menu window
*/
resetColors();
flush();
//Fill background of rectangle
g.setColor(getBackgroundColor());
//Mapping data
//Paint caption
//Paint menus
if (item.isSeparator()) {
} else {
//paint item
if (item == selectedItem) {
g.setColor(getSelectedColor());
}
if (shortcutText != null) {
}
//calculate arrow coordinates
//draw arrow
} else if (item instanceof XCheckboxMenuItemPeer) {
//calculate checkmark coordinates
//draw checkmark
if (checkState) {
g.setColor(getSelectedColor());
}
} else {
g.setColor(getBackgroundColor());
}
}
}
}
flush();
}
}