summaryrefslogtreecommitdiff
path: root/odk
diff options
context:
space:
mode:
authorAriel Constenla-Haile <arielch@apache.org>2012-12-23 11:29:21 +0000
committerAriel Constenla-Haile <arielch@apache.org>2012-12-23 11:29:21 +0000
commit399946b82f5efec19cd82d1c320d5aa9295d235d (patch)
treededa9e189523c578be47e9b4f6d44edde5e55a57 /odk
parent9271c50c2d02b708cbe274568c455ff900595884 (diff)
i121542 - Unify the Menu API
Notes
Notes: merged as: 9052caae53ef6ec7eeab20f1ac56bd6310b4451b
Diffstat (limited to 'odk')
-rw-r--r--odk/examples/DevelopersGuide/GUI/UnoMenu.java56
-rw-r--r--odk/examples/DevelopersGuide/GUI/UnoMenu2.java6
-rw-r--r--odk/examples/cpp/StatusbarController/SelectionModeStatusbarController/SelectionModeStatusbarController.cxx7
3 files changed, 34 insertions, 35 deletions
diff --git a/odk/examples/DevelopersGuide/GUI/UnoMenu.java b/odk/examples/DevelopersGuide/GUI/UnoMenu.java
index b7499c9f99cb..29503b0ca311 100644
--- a/odk/examples/DevelopersGuide/GUI/UnoMenu.java
+++ b/odk/examples/DevelopersGuide/GUI/UnoMenu.java
@@ -25,7 +25,6 @@ import com.sun.star.awt.Rectangle;
import com.sun.star.awt.WindowAttribute;
import com.sun.star.awt.WindowClass;
import com.sun.star.awt.XMenuBar;
-import com.sun.star.awt.XMenuExtended;
import com.sun.star.awt.XMenuListener;
import com.sun.star.awt.XPopupMenu;
import com.sun.star.awt.XToolkit;
@@ -67,21 +66,26 @@ public UnoMenu(XComponentContext _xContext, XMultiComponentFactory _xMCF) {
XPopupMenu xPopupMenu = null;
try{
// create a popup menu
- Object oPopupMenu = m_xMCF.createInstanceWithContext("stardiv.Toolkit.VCLXPopupMenu", m_xContext);
+ Object oPopupMenu = m_xMCF.createInstanceWithContext("com.sun.star.awt.PopupMenu", m_xContext);
xPopupMenu = (XPopupMenu) UnoRuntime.queryInterface(XPopupMenu.class, oPopupMenu);
- XMenuExtended xMenuExtended = (XMenuExtended) UnoRuntime.queryInterface(XMenuExtended.class, xPopupMenu);
-
- xPopupMenu.insertItem((short) 0, "~First Entry", MenuItemStyle.AUTOCHECK, (short) 0);
- xPopupMenu.insertItem((short) 1, "First ~Radio Entry", (short) (MenuItemStyle.RADIOCHECK + MenuItemStyle.AUTOCHECK), (short) 1);
- xPopupMenu.insertItem((short) 2, "~Second Radio Entry", (short) (MenuItemStyle.RADIOCHECK + MenuItemStyle.AUTOCHECK), (short) 2);
- xPopupMenu.insertItem((short) 3, "~Third RadioEntry",(short) (MenuItemStyle.RADIOCHECK + MenuItemStyle.AUTOCHECK), (short) 3);
- xPopupMenu.insertSeparator((short)4);
- xPopupMenu.insertItem((short) 4, "F~ifth Entry", (short) (MenuItemStyle.CHECKABLE + MenuItemStyle.AUTOCHECK), (short) 5);
- xPopupMenu.insertItem((short) 5, "~Fourth Entry", (short) (MenuItemStyle.CHECKABLE + MenuItemStyle.AUTOCHECK), (short) 6);
- xPopupMenu.enableItem((short) 1, false);
- xPopupMenu.insertItem((short) 6, "~Sixth Entry", (short) 0, (short) 7);
- xPopupMenu.insertItem((short) 7, "~Close Dialog", (short) 0, (short) 8);
- xPopupMenu.checkItem((short) 2, true);
+
+ // ID must start be > 0
+ short nId = 1;
+ short nPos = 0;
+
+ xPopupMenu.insertItem(nId++, "First Entry", MenuItemStyle.AUTOCHECK, nPos++);
+ xPopupMenu.insertItem(nId++, "First Radio Entry", (short) (MenuItemStyle.RADIOCHECK + MenuItemStyle.AUTOCHECK), nPos++);
+ xPopupMenu.insertItem(nId++, "Second Radio Entry", (short) (MenuItemStyle.RADIOCHECK + MenuItemStyle.AUTOCHECK), nPos++);
+ xPopupMenu.insertItem(nId++, "Third RadioEntry",(short) (MenuItemStyle.RADIOCHECK + MenuItemStyle.AUTOCHECK), nPos++);
+ xPopupMenu.insertSeparator(nPos++);
+ xPopupMenu.insertItem(nId++, "Fifth Entry", (short) (MenuItemStyle.CHECKABLE + MenuItemStyle.AUTOCHECK), nPos++);
+ xPopupMenu.insertItem(nId++, "Fourth Entry", (short) (MenuItemStyle.CHECKABLE + MenuItemStyle.AUTOCHECK), nPos++);
+ xPopupMenu.insertItem(nId++, "Sixth Entry", (short) 0, nPos++);
+ xPopupMenu.insertItem(nId++, "Close Dialog", (short) 0, nPos++);
+
+ xPopupMenu.enableItem((short) 2, false);
+ xPopupMenu.checkItem((short) 3, true);
+
xPopupMenu.addMenuListener(this);
}catch( Exception e ) {
throw new java.lang.RuntimeException("cannot happen...");
@@ -93,12 +97,12 @@ public UnoMenu(XComponentContext _xContext, XMultiComponentFactory _xMCF) {
public void addMenuBar(XTopWindow _xTopWindow, XMenuListener _xMenuListener){
try{
// create a menubar at the global MultiComponentFactory...
- Object oMenuBar = m_xMCF.createInstanceWithContext("stardiv.Toolkit.VCLXMenuBar", m_xContext);
+ Object oMenuBar = m_xMCF.createInstanceWithContext("com.sun.star.awt.MenuBar", m_xContext);
// add the menu items...
XMenuBar xMenuBar = (XMenuBar) UnoRuntime.queryInterface(XMenuBar.class, oMenuBar);
- xMenuBar.insertItem((short) 0, "~First MenuBar Item", com.sun.star.awt.MenuItemStyle.AUTOCHECK, (short) 0);
- xMenuBar.insertItem((short) 1, "~Second MenuBar Item", com.sun.star.awt.MenuItemStyle.AUTOCHECK, (short) 1);
- xMenuBar.setPopupMenu((short) 0, getPopupMenu());
+ xMenuBar.insertItem((short) 1, "~First MenuBar Item", com.sun.star.awt.MenuItemStyle.AUTOCHECK, (short) 0);
+ xMenuBar.insertItem((short) 2, "~Second MenuBar Item", com.sun.star.awt.MenuItemStyle.AUTOCHECK, (short) 1);
+ xMenuBar.setPopupMenu((short) 1, getPopupMenu());
xMenuBar.addMenuListener(_xMenuListener);
_xTopWindow.setMenuBar(xMenuBar);
}catch( Exception e ) {
@@ -157,31 +161,31 @@ public UnoMenu(XComponentContext _xContext, XMultiComponentFactory _xMCF) {
addMenuBar(xTopWindow, this);
}
- public void select(MenuEvent menuEvent){
+ public void itemSelected(MenuEvent menuEvent){
// find out which menu item has been triggered,
// by getting the menu-id...
switch (menuEvent.MenuId){
- case 0:
+ case 1:
// add your menu-item-specific code here:
break;
- case 1:
+ case 2:
// add your menu-item-specific code here:
break;
- case 7:
+ case 8:
closeDialog();
default:
//..
}
}
- public void highlight(MenuEvent menuEvent) {
+ public void itemHighlighted(MenuEvent menuEvent) {
int i = 0;
}
- public void deactivate(MenuEvent menuEvent) {
+ public void itemDeactivated(MenuEvent menuEvent) {
int i = 0; }
- public void activate(MenuEvent menuEvent) {
+ public void itemActivated(MenuEvent menuEvent) {
int i = 0;
}
diff --git a/odk/examples/DevelopersGuide/GUI/UnoMenu2.java b/odk/examples/DevelopersGuide/GUI/UnoMenu2.java
index c1c87eb48527..2212c936d1cf 100644
--- a/odk/examples/DevelopersGuide/GUI/UnoMenu2.java
+++ b/odk/examples/DevelopersGuide/GUI/UnoMenu2.java
@@ -20,7 +20,7 @@
*************************************************************/
import com.sun.star.awt.MouseEvent;
-import com.sun.star.awt.Rectangle;
+import com.sun.star.awt.Point;
import com.sun.star.awt.XControl;
import com.sun.star.awt.XMouseListener;
import com.sun.star.awt.XTopWindow;
@@ -99,9 +99,9 @@ public UnoMenu2(XComponentContext _xContext, XMultiComponentFactory _xMCF) {
public void mousePressed(MouseEvent mouseEvent) {
if (mouseEvent.PopupTrigger){
- Rectangle aRectangle = new Rectangle(mouseEvent.X, mouseEvent.Y, 0, 0);
+ Point aPos = new Point(mouseEvent.X, mouseEvent.Y);
XControl xControl = (XControl) UnoRuntime.queryInterface(XControl.class, mouseEvent.Source);
- getPopupMenu().execute( xControl.getPeer(), aRectangle, com.sun.star.awt.PopupMenuDirection.DEFAULT);
+ getPopupMenu().execute( xControl.getPeer(), aPos, com.sun.star.awt.PopupMenuDirection.EXECUTE_DEFAULT);
}
}
diff --git a/odk/examples/cpp/StatusbarController/SelectionModeStatusbarController/SelectionModeStatusbarController.cxx b/odk/examples/cpp/StatusbarController/SelectionModeStatusbarController/SelectionModeStatusbarController.cxx
index 2727e66159fb..7d5d6f402118 100644
--- a/odk/examples/cpp/StatusbarController/SelectionModeStatusbarController/SelectionModeStatusbarController.cxx
+++ b/odk/examples/cpp/StatusbarController/SelectionModeStatusbarController/SelectionModeStatusbarController.cxx
@@ -186,13 +186,8 @@ void SelectionModeStatusbarController::ExecutePopupMenu( const Point &aPos )
xPopupMenu->checkItem( nIdOffset + m_eSelectionMode, sal_True );
- Rectangle aRect;
- aRect.X = aPos.X;
- aRect.Y = aPos.Y;
-
Reference< XWindowPeer > xParent( m_xStatusbarWindow, UNO_QUERY );
-
- const sal_Int16 nSelId = xPopupMenu->execute( xParent, aRect, PopupMenuDirection::EXECUTE_UP );
+ const sal_Int16 nSelId = xPopupMenu->execute( xParent, aPos, PopupMenuDirection::EXECUTE_UP );
if ( nSelId )
{
Sequence< PropertyValue > aArgs( 1 );