/*
* 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
*/
/*
* Index of help menu
*/
/*
* dimension constants
*/
/************************************************
*
* Mapping data
*
************************************************/
/**
* XBaseMenuWindow's mappingData is extended with
* desired height of menu bar
*/
int desiredHeight;
super(items);
this.desiredHeight = desiredHeight;
}
/**
* Constructs MappingData without items
* This constructor should be used in case of errors
*/
MappingData() {
this.desiredHeight = 0;
}
public int getDesiredHeight() {
return this.desiredHeight;
}
}
/************************************************
*
* Construction
*
************************************************/
this.menuBarTarget = menuBarTarget;
}
/************************************************
*
* Implementaion of interface methods
*
************************************************/
/*
* From MenuComponentPeer
*/
resetMapping();
setItemsFont(f);
}
/*
* From MenuBarPeer
*/
/*
* Functions addMenu, delMenu, addHelpMenu
* need to have somewhat strange behaivour
* deduced from java.awt.MenuBar.
* We can not get index of particular item in
* MenuBar.menus array, because MenuBar firstly
* performs array operations and then calls peer.
* So we need to synchronize indicies in 'items'
* array with MenuBar.menus. We have to follow
* these rules:
* 1. Menus are always added to the end of array,
* even when helpMenu is present
* 2. Removal of any menu item acts as casual
* remove from array
* 3. MenuBar.setHelpMenu _firstly_ removes
* previous helpMenu by calling delMenu() if
* necessary, then it performs addMenu(),
* and then - addHelpMenu().
*
* Note that these functions don't perform
* type checks and checks for nulls or duplicates
*/
addItem(m);
}
synchronized(getMenuTreeLock()) {
}
}
}
synchronized(getMenuTreeLock()) {
}
}
/************************************************
*
* Initialization
*
************************************************/
/**
* called from XFramePeer.setMenuBar
*/
}
/**
* Overriden initialization
*/
// Get menus from the target.
if (targetHelpMenu != null) {
}
xSetVisible(true);
toFront();
}
/************************************************
*
* Implementation of abstract methods
*
************************************************/
/**
* Menu bar is always root window in menu window's
* hierarchy
*/
return null;
}
/**
* @see XBaseMenuWindow.map
*/
int helpMenuPos = -1;
//find helpMenu and move it to the end of array
//Fixed 6270847: PIT: HELP menu is not shown at the right place when normal menus added to MB are removed, XToolkit
for (int i = 0; i < itemCnt; i++) {
if (itemVector[i] == helpMenu) {
helpMenuPos = i;
break;
}
}
}
}
//We need maximum height before calculating item's bounds
int maxHeight = 0;
for (int i = 0; i < itemCnt; i++) {
}
}
//Calculate bounds
int nextOffset = 0;
for (int i = 0; i < itemCnt; i++) {
//Fix for 6270757: PIT: Menus and Sub-menus are shown outside the frame, XToolkit
//Cut-off items that don't fit in window
//At least one item must remain in menu
mappedCnt = i;
break;
}
//If this item is help menu, move it to the right edge
}
//text should be centered vertically in menu item's bounds
Point textOrigin = new Point(nextOffset + BAR_ITEM_MARGIN_LEFT, BAR_SPACING_TOP + BAR_ITEM_MARGIN_TOP + y);
} else {
Point textOrigin = new Point(nextOffset + BAR_ITEM_MARGIN_LEFT, BAR_SPACING_TOP + BAR_ITEM_MARGIN_TOP);
}
}
MappingData mappingData = new MappingData(mappedVector, BAR_SPACING_TOP + itemHeight + BAR_SPACING_BOTTOM);
return mappingData;
}
/**
* @see XBaseMenuWindow.getSubmenuBounds
*/
return res;
}
return res;
}
return res;
}
return res;
}
}
/**
* This function is called when it's likely that
* size of items has changed.
* Invokes framePeer's updateChildrenSizes()
*/
protected void updateSize() {
resetMapping();
}
}
/************************************************
*
* Utility functions
*
************************************************/
/**
* Returns desired height of menu bar
*/
int getDesiredHeight() {
return mappingData.getDesiredHeight();
}
/**
* Returns true if framePeer is not null and is enabled
* Used to fix 6185057: Disabling a frame does not disable
*/
boolean isFramePeerEnabled() {
}
return false;
}
/************************************************
*
* Overriden XBaseMenuWindow functions
*
************************************************/
/**
* @see XBaseMenuWindow.doDispose()
*/
protected void doDispose() {
super.doDispose();
}
/************************************************
*
* Overriden XWindow general-purpose functions
*
************************************************/
/**
* For menu bars this function is called from framePeer's
* reshape(...) and updateChildrenSizes()
*/
resetMapping();
}
}
/**
* Performs ungrabbing of input
* @see XBaseWindow.ungrabInputImpl()
*/
void ungrabInputImpl() {
selectItem(null, false);
super.ungrabInputImpl();
}
/************************************************
*
* Overriden XWindow painting & printing
*
************************************************/
resetColors();
/* Calculate menubar dimension. */
flush();
//Fill background of rectangle
g.setColor(getBackgroundColor());
//Paint menus
//paint item
if (item == selectedItem) {
g.setColor(getSelectedColor());
}
g.setColor(getForegroundColor());
} else {
g.setColor(getDisabledColor());
}
}
flush();
}
//TODO:Implement
}
/************************************************
*
* Overriden XBaseMenuWindow event handling
*
************************************************/
// explicitly block all events except PaintEvent.PAINT for menus,
// that are in the modal blocked window
{
if (framePeer.isModalBlocked()) {
return;
}
}
case MouseEvent.MOUSE_PRESSED:
case MouseEvent.MOUSE_RELEASED:
case MouseEvent.MOUSE_CLICKED:
case MouseEvent.MOUSE_MOVED:
case MouseEvent.MOUSE_ENTERED:
case MouseEvent.MOUSE_EXITED:
case MouseEvent.MOUSE_DRAGGED:
//Fix for 6185057: Disabling a frame does not disable
if (isFramePeerEnabled()) {
}
break;
case KeyEvent.KEY_PRESSED:
case KeyEvent.KEY_RELEASED:
//Fix for 6185057: Disabling a frame does not disable
if (isFramePeerEnabled()) {
}
break;
default:
super.handleEvent(event);
break;
}
}
/************************************************
*
* Overriden XWindow keyboard processing
*
************************************************/
/*
* This function is called from XWindow
* @see XWindow.handleF10onEDT()
*/
return;
}
grabInput();
selectItem(getFirstSelectableItem(), true);
}
/*
* In previous version keys were handled in handleKeyPress.
* Now we override this function do disable F10 explicit
* processing. All processing is done using KeyEvent.
*/
if (isEventDisabled(xev)) {
return;
}
//This is the only difference from XWindow.handleKeyPress
//Ancestor's function can invoke handleF10KeyPress here
}
} //class XMenuBarPeer