summaryrefslogtreecommitdiff
path: root/odk
diff options
context:
space:
mode:
authorAriel Constenla-Haile <arielch@apache.org>2012-12-23 11:29:21 +0000
committerCaolán McNamara <caolanm@redhat.com>2013-06-23 21:16:14 +0100
commit9052caae53ef6ec7eeab20f1ac56bd6310b4451b (patch)
treee3fa07a8a4bee383d9d17ae7e75500fdf88ac2da /odk
parent1a07be5dbcd6010cd5f9a4b71c2a7648974bd6ba (diff)
Resolves: #i121542# Unify the Menu API
(cherry picked from commit 399946b82f5efec19cd82d1c320d5aa9295d235d) Conflicts: chart2/source/controller/main/ChartController_Window.cxx framework/source/uielement/langselectionmenucontroller.cxx framework/source/uielement/popupmenucontroller.cxx framework/source/uielement/recentfilesmenucontroller.cxx framework/source/uielement/toolbarsmenucontroller.cxx odk/examples/DevelopersGuide/GUI/UnoMenu.java odk/examples/DevelopersGuide/GUI/UnoMenu2.java odk/examples/cpp/StatusbarController/SelectionModeStatusbarController/SelectionModeStatusbarController.cxx offapi/com/sun/star/awt/MenuBar.idl offapi/com/sun/star/awt/MenuEvent.idl offapi/com/sun/star/awt/MenuItemStyle.idl offapi/com/sun/star/awt/MenuItemType.idl offapi/com/sun/star/awt/MenuLogo.idl offapi/com/sun/star/awt/PopupMenu.idl offapi/com/sun/star/awt/PopupMenuDirection.idl offapi/com/sun/star/awt/XMenu.idl offapi/com/sun/star/awt/XMenuBar.idl offapi/com/sun/star/awt/XMenuBarExtended.idl offapi/com/sun/star/awt/XMenuExtended.idl offapi/com/sun/star/awt/XMenuExtended2.idl offapi/com/sun/star/awt/XMenuListener.idl offapi/com/sun/star/awt/XPopupMenu.idl offapi/com/sun/star/awt/XPopupMenuExtended.idl offapi/com/sun/star/awt/makefile.mk offapi/type_reference/types.rdb svtools/inc/svtools/popupmenucontrollerbase.hxx svtools/source/uno/popupmenucontrollerbase.cxx svx/source/tbxctrls/extrusioncontrols.cxx toolkit/inc/pch/precompiled_toolkit.hxx toolkit/inc/toolkit/awt/vclxmenu.hxx toolkit/inc/toolkit/helper/listenermultiplexer.hxx toolkit/source/awt/vclxmenu.cxx Change-Id: I3d9a1e109b9ff35901a3075b44a4c27e7c12b5c7 Related: #i121542# css::awt::XPopupMenu::execute() needs a Rectangle (cherry picked from commit c01a6f4f370b72f0751cf4f5c11310682e2b3248) Conflicts: odk/examples/DevelopersGuide/GUI/UnoMenu2.java offapi/type_reference/types.rdb toolkit/inc/toolkit/awt/vclxmenu.hxx Change-Id: I2cccc95086fe3d1522d03346e3c577fb2f21f621
Diffstat (limited to 'odk')
-rw-r--r--odk/examples/DevelopersGuide/GUI/UnoMenu.java56
-rw-r--r--odk/examples/DevelopersGuide/GUI/UnoMenu2.java4
2 files changed, 32 insertions, 28 deletions
diff --git a/odk/examples/DevelopersGuide/GUI/UnoMenu.java b/odk/examples/DevelopersGuide/GUI/UnoMenu.java
index 86942f91c0d6..87e7fce68085 100644
--- a/odk/examples/DevelopersGuide/GUI/UnoMenu.java
+++ b/odk/examples/DevelopersGuide/GUI/UnoMenu.java
@@ -22,7 +22,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;
@@ -64,21 +63,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 = UnoRuntime.queryInterface(XPopupMenu.class, oPopupMenu);
- 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...");
@@ -90,12 +94,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 = 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 ) {
@@ -154,31 +158,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 0edae176bd71..ea53a99f02d8 100644
--- a/odk/examples/DevelopersGuide/GUI/UnoMenu2.java
+++ b/odk/examples/DevelopersGuide/GUI/UnoMenu2.java
@@ -95,9 +95,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);
+ Rectangle aPos = new Rectangle(mouseEvent.X, mouseEvent.Y, 0, 0);
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);
}
}