diff -urN ooo_SRC680_m179_src.orig/vcl/aqua/inc/salframe.h ooo_SRC680_m179_src/vcl/aqua/inc/salframe.h --- ooo_SRC680_m179_src.orig/vcl/aqua/inc/salframe.h 2006-08-01 20:21:38.000000000 +0200 +++ ooo_SRC680_m179_src/vcl/aqua/inc/salframe.h 2006-08-01 20:21:40.000000000 +0200 @@ -38,6 +38,8 @@ #include +#include + #ifndef _SV_SV_H #include #endif @@ -187,6 +189,9 @@ typedef std::pair SysWindowEventHandlerData_t; typedef std::vector SysWindowEventHandlerDataContainer_t; SysWindowEventHandlerDataContainer_t mSysWindowEventHandlerDataContainer; + + // Menu associated with this SalFrame + SalMenu *mpMenu; }; #endif // _SV_SALFRAME_H diff -urN ooo_SRC680_m179_src.orig/vcl/aqua/inc/salmenu.h ooo_SRC680_m179_src/vcl/aqua/inc/salmenu.h --- ooo_SRC680_m179_src.orig/vcl/aqua/inc/salmenu.h 1970-01-01 01:00:00.000000000 +0100 +++ ooo_SRC680_m179_src/vcl/aqua/inc/salmenu.h 2006-08-01 21:52:50.000000000 +0200 @@ -0,0 +1,98 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: salmenu.h,v $ + * + * $Revision: 1.4 $ + * + * last change: $Author: rt $ $Date: 2005/09/09 12:45:35 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +#ifndef _SV_SALMENU_H +#define _SV_SALMENU_H + +#include +#include +#include + +#ifndef _SV_SV_H +#include +#endif +#ifndef _SV_BITMAP_HXX +#include +#endif + +#ifndef _SV_SALMENU_HXX +#include +#endif + + +class AquaSalMenu : public SalMenu +{ +public: + AquaSalMenu() {} + virtual ~AquaSalMenu(); + + virtual BOOL VisibleMenuBar(); // must return TRUE to actually DISPLAY native menu bars + // otherwise only menu messages are processed (eg, OLE on Windows) + + virtual void InsertItem( SalMenuItem* pSalMenuItem, unsigned nPos ); + virtual void RemoveItem( unsigned nPos ); + virtual void SetSubMenu( SalMenuItem* pSalMenuItem, SalMenu* pSubMenu, unsigned nPos ); + virtual void SetFrame( const SalFrame* pFrame ); + virtual void CheckItem( unsigned nPos, BOOL bCheck ); + virtual void EnableItem( unsigned nPos, BOOL bEnable ); + virtual void SetItemText( unsigned nPos, SalMenuItem* pSalMenuItem, const XubString& rText ); + virtual void SetItemImage( unsigned nPos, SalMenuItem* pSalMenuItem, const Image& rImage); + virtual void SetAccelerator( unsigned nPos, SalMenuItem* pSalMenuItem, const KeyCode& rKeyCode, const XubString& rKeyName ); + virtual void GetSystemMenuData( SystemMenuData* pData ); + + XubString mText; // Title of this menu + MenuRef mrMenuRef; // The Carbon reference to this menu + BOOL mbMenuBar; // TRUE - Menubar, FALSE - Menu +}; + +class AquaSalMenuItem : public SalMenuItem +{ +public: + AquaSalMenuItem() {} + virtual ~AquaSalMenuItem(); + + USHORT mnId; // Item ID + Menu *mpMenu; // Menu into which this MenuItem is inserted + XubString mText; // Title of this menu item + MenuRef mrParentMenuRef; // The menu in which this menu item is inserted + + MenuItemIndex mnMenuItemIndex; // The menu index of this menu item in mpMenu + // It is 1 based, so the first menu + // item's MenuItemIndex in the menu has value 1 + + MenuItemAttributes maMenuAttributes; +}; + +#endif // _SV_SALMENU_H diff -urN ooo_SRC680_m179_src.orig/vcl/aqua/source/app/salinst.cxx ooo_SRC680_m179_src/vcl/aqua/source/app/salinst.cxx --- ooo_SRC680_m179_src.orig/vcl/aqua/source/app/salinst.cxx 2006-08-01 20:21:38.000000000 +0200 +++ ooo_SRC680_m179_src/vcl/aqua/source/app/salinst.cxx 2006-08-01 20:21:40.000000000 +0200 @@ -612,26 +612,6 @@ -SalMenu* AquaSalInstance::CreateMenu( BOOL bMenuBar ) -{ - return NULL; -} - -void AquaSalInstance::DestroyMenu( SalMenu* ) -{ - -} - -SalMenuItem* AquaSalInstance::CreateMenuItem( const SalItemParams* pItemData ) -{ - -} - -void AquaSalInstance::DestroyMenuItem( SalMenuItem* ) -{ - -} - SalSound* AquaSalInstance::CreateSalSound() { return new AquaSalSound(); diff -urN ooo_SRC680_m179_src.orig/vcl/aqua/source/window/makefile.mk ooo_SRC680_m179_src/vcl/aqua/source/window/makefile.mk --- ooo_SRC680_m179_src.orig/vcl/aqua/source/window/makefile.mk 2006-08-01 20:21:38.000000000 +0200 +++ ooo_SRC680_m179_src/vcl/aqua/source/window/makefile.mk 2006-08-01 20:21:40.000000000 +0200 @@ -59,6 +59,7 @@ SLOFILES= \ $(SLO)/salframe.obj \ + $(SLO)/salmenu.obj \ $(SLO)/salobj.obj .ENDIF # "$(GUIBASE)"!="aqua" diff -urN ooo_SRC680_m179_src.orig/vcl/aqua/source/window/salframe.cxx ooo_SRC680_m179_src/vcl/aqua/source/window/salframe.cxx --- ooo_SRC680_m179_src.orig/vcl/aqua/source/window/salframe.cxx 2006-08-01 20:21:38.000000000 +0200 +++ ooo_SRC680_m179_src/vcl/aqua/source/window/salframe.cxx 2006-08-01 21:58:52.000000000 +0200 @@ -47,6 +47,9 @@ #ifndef _SV_SALFRAME_H #include #endif +#ifndef _SV_SALMENU_H +#include +#endif #ifndef _SV_SALTIMER_H #include #endif @@ -93,6 +96,7 @@ // ======================================================================= AquaSalFrame::AquaSalFrame() : + mpMenu(NULL), mrWindow(NULL), mpGraphics(NULL), mpParent(NULL), @@ -111,6 +115,7 @@ } AquaSalFrame::AquaSalFrame(SalFrame* pParent, ULONG salFrameStyle, AquaSalInstance* pSalInstance) : + mpMenu(NULL), mpGraphics(NULL), mpParent(NULL), mpInst(NULL), @@ -297,6 +302,16 @@ ShowWindow(mrWindow); if(!bNoActivate) SelectWindow(mrWindow); //ActivateWindow(mrWindow, true); + + // FIXME: create empty menu bar for SalFrame without menu yet! + if (!mpMenu) + mpMenu = mpSalInstance->CreateMenu(TRUE); + + if (mpMenu) + { + AquaSalMenu *pAquaSalMenu = (AquaSalMenu *) mpMenu; + SetRootMenu(pAquaSalMenu->mrMenuRef); + } } else HideWindow(mrWindow); @@ -638,7 +653,9 @@ void AquaSalFrame::SetMenu( SalMenu* pSalMenu ) { fprintf(stderr, ">*>_> %s\n",__func__); - //TODO: implement + + fprintf(stderr, "PJ: AquaSalFrame::SetMenu (%p) for AquaSalFrame %p\n", pSalMenu, this); + mpMenu = pSalMenu; } void AquaSalFrame::SetExtendedFrameStyle( SalExtStyle nStyle ) @@ -718,6 +735,180 @@ //DbgPrintFrameGeometry(fullWindowRect, contentRect, titleBarRect, maGeometry); } +OSStatus HandleCommandProcessEvent(EventHandlerCallRef inHandlerCallRef, EventRef inEvent, void * inUserData) +{ + + ImplSalYieldMutexAcquire(); + AquaSalFrame* pSalFrame = reinterpret_cast(inUserData); + + OSStatus result = eventNotHandledErr; + HICommand commandStruct; + + GetEventParameter (inEvent, kEventParamDirectObject, typeHICommand, NULL, sizeof(HICommand), NULL, &commandStruct); + + // If the CommandProcess event is from menu, print its MenuRef and MenuItemIndex + if ( commandStruct.attributes & kHICommandFromMenu ) { + + fprintf(stderr, "PJ: CommandProcess, SALEVENT_MENUCOMMAND event!\n"); + + fprintf(stderr, "PJ: Menu item selected, MenuRef = %p, (%d. item)\n", + commandStruct.menu.menuRef, commandStruct.menu.menuItemIndex); + + // handling Quit from Application menu! + if (commandStruct.commandID == kHICommandQuit) + fprintf(stderr, "PJ: Quit from application menu received!\n"); + + SalMenuItem *pSalMenuItem; + + OSStatus err; + err = GetMenuItemProperty (commandStruct.menu.menuRef, commandStruct.menu.menuItemIndex, + APP_PROPERTY_CREATOR, APP_PROPERTY_TAG_MENU_POINTER, + sizeof(pSalMenuItem), NULL, &pSalMenuItem); + + // Only use pSalMenuItem value if the menu item property was found! + if ( (err == noErr) && pSalMenuItem) + { + fprintf(stderr, "PJ: pSalMenuItem = %p\n", pSalMenuItem); + fprintf(stderr, "PJ: mnId = %p\n", ((AquaSalMenuItem *)pSalMenuItem)->mnId); + + // Posting native menu event... + SalMenuEvent aMenuEvt; + aMenuEvt.mnId = ((AquaSalMenuItem *)pSalMenuItem)->mnId; + aMenuEvt.mpMenu = ((AquaSalMenuItem *)pSalMenuItem)->mpMenu; + pSalFrame->CallCallback(SALEVENT_MENUCOMMAND, &aMenuEvt); + + result = noErr; + } + } + + ImplSalYieldMutexRelease(); + + return result; +} + +OSStatus HandleMenuPopulateEvent(EventHandlerCallRef inHandlerCallRef, EventRef inEvent, void * inUserData) +{ + + ImplSalYieldMutexAcquire(); + AquaSalFrame* pSalFrame = reinterpret_cast(inUserData); + + fprintf(stderr, "PJ: MenuPopulate, SALEVENT_MENUACTIVATE event!\n"); + + MenuRef pMenuRef; + + GetEventParameter (inEvent, kEventParamDirectObject, typeMenuRef, NULL, sizeof(typeMenuRef), NULL, &pMenuRef); + fprintf(stderr, "PJ: MenuRef = %p\n", pMenuRef); + + SalMenu *pSalMenu; + OSStatus err; + + err = GetMenuItemProperty (pMenuRef, 0, + APP_PROPERTY_CREATOR, APP_PROPERTY_TAG_MENU_POINTER, + sizeof(pSalMenu), NULL, &pSalMenu); + + if ( (err == noErr) && pSalMenu) + { + fprintf(stderr, "PJ: SalMenu = %p\n", pSalMenu); + + // Posting native menu event... + SalMenuEvent aMenuEvt; + aMenuEvt.mpMenu = pSalMenu; + // FIXME: This does not propagate to the application yet. WHY? + // pSalFrame->CallCallback(SALEVENT_MENUACTIVATE, &aMenuEvt); + } + + ImplSalYieldMutexRelease(); + + return noErr; +} + +OSStatus HandleMenuClosedEvent(EventHandlerCallRef inHandlerCallRef, EventRef inEvent, void * inUserData) +{ + + ImplSalYieldMutexAcquire(); + AquaSalFrame* pSalFrame = reinterpret_cast(inUserData); + + fprintf(stderr, "PJ: MenuClosed, SALEVENT_MENUDEACTIVATE event!\n"); + + MenuRef pMenuRef; + + GetEventParameter (inEvent, kEventParamDirectObject, typeMenuRef, NULL, sizeof(typeMenuRef), NULL, &pMenuRef); + fprintf(stderr, "PJ: MenuRef = %p\n", pMenuRef); + + SalMenu *pSalMenu; + OSStatus err; + + err = GetMenuItemProperty (pMenuRef, 0, + APP_PROPERTY_CREATOR, APP_PROPERTY_TAG_MENU_POINTER, + sizeof(pSalMenu), NULL, &pSalMenu); + + if ( (err == noErr) && pSalMenu) + { + fprintf(stderr, "PJ: SalMenu = %p\n", pSalMenu); + + // Posting native menu event... + SalMenuEvent aMenuEvt; + aMenuEvt.mpMenu = pSalMenu; + // FIXME: This does not propagate to the application yet. WHY? + // pSalFrame->CallCallback(SALEVENT_MENUDEACTIVATE, &aMenuEvt); + } + + ImplSalYieldMutexRelease(); + + return noErr; +} + +OSStatus HandleMenuTargetItemEvent(EventHandlerCallRef inHandlerCallRef, EventRef inEvent, void * inUserData) +{ + + ImplSalYieldMutexAcquire(); + AquaSalFrame* pSalFrame = reinterpret_cast(inUserData); + OSStatus result = eventNotHandledErr; + + fprintf(stderr, "PJ: MenuTargetItem, SALEVENT_MENUHIGHLIGHT event!\n"); + + MenuRef pMenuRef; + MenuItemIndex mnMenuItemIndex; + + GetEventParameter (inEvent, kEventParamDirectObject, typeMenuRef, NULL, sizeof(typeMenuRef), NULL, &pMenuRef); + GetEventParameter (inEvent, kEventParamMenuItemIndex, typeMenuItemIndex, NULL, sizeof(typeMenuItemIndex), NULL, &mnMenuItemIndex); + fprintf(stderr, "PJ: MenuRef = %p\n", pMenuRef); + fprintf(stderr, "PJ: MenuItemIndex = %p\n", mnMenuItemIndex); + + // kEventMenutargetItem is sent also for top-level items. Ignore + // them (MenuItemIndex == 0 for them). Or should we send + // MENUACTIVATE events for them? + if (mnMenuItemIndex != 0) + { + SalMenuItem *pSalMenuItem; + OSStatus err; + + err = GetMenuItemProperty (pMenuRef, mnMenuItemIndex, + APP_PROPERTY_CREATOR, APP_PROPERTY_TAG_MENU_POINTER, + sizeof(pSalMenuItem), NULL, &pSalMenuItem); + + // We also receive kEventMenuTargetItem events for + // non-application menus (Apple menu or Application menu). But + // they do not have SalMenuItem attached with them. + if ( (err == noErr) && pSalMenuItem) + { + fprintf(stderr, "PJ: mnId = %p\n", ((AquaSalMenuItem *)pSalMenuItem)->mnId); + + // Posting native menu event... + SalMenuEvent aMenuEvt; + aMenuEvt.mnId = ((AquaSalMenuItem *)pSalMenuItem)->mnId; + aMenuEvt.mpMenu = ((AquaSalMenuItem *)pSalMenuItem)->mpMenu; + pSalFrame->CallCallback(SALEVENT_MENUHIGHLIGHT, &aMenuEvt); + + result = noErr; + } + } + + ImplSalYieldMutexRelease(); + + return result; +} + OSStatus HandleWindowCloseEvent(EventHandlerCallRef inHandlerCallRef, EventRef inEvent, void * inUserData) { BOOST_ASSERT(GetEventClass(inEvent) == kEventClassWindow && GetEventKind(inEvent) == kEventWindowClose && "Only WindowClose event expected"); @@ -817,6 +1008,7 @@ OSStatus HandleWindowActivatedEvent(EventHandlerCallRef inHandlerCallRef, EventRef inEvent, void* inUserData) { + // FIXME: fix displaying correct menu bar according to the activated window/frame return eventNotHandledErr; } @@ -1133,6 +1325,13 @@ InstallAndRegisterEventHandler(NewEventHandlerUPP(HandleMouseUpDownEvent), GetEventTypeCount(cMouseUpDownEvent), cMouseUpDownEvent); InstallAndRegisterEventHandler(NewEventHandlerUPP(HandleWindowResizeStarted), 1, &cWindowResizeStarted); InstallAndRegisterEventHandler(NewEventHandlerUPP(HandleWindowResizeCompleted), 1, &cWindowResizeCompleted); + + /* Menu event handlers */ + + InstallAndRegisterEventHandler(NewEventHandlerUPP(HandleCommandProcessEvent), 1, &cCommandProcessEvent); + InstallAndRegisterEventHandler(NewEventHandlerUPP(HandleMenuPopulateEvent), 1, &cMenuPopulateEvent); + InstallAndRegisterEventHandler(NewEventHandlerUPP(HandleMenuClosedEvent), 1, &cMenuClosedEvent); + InstallAndRegisterEventHandler(NewEventHandlerUPP(HandleMenuTargetItemEvent), 1, &cMenuTargetItemEvent); } OSStatus AquaSalFrame::InstallAndRegisterEventHandler(EventHandlerUPP upp, size_t nEvents, const EventTypeSpec* eventSpec) diff -urN ooo_SRC680_m179_src.orig/vcl/aqua/source/window/salmenu.cxx ooo_SRC680_m179_src/vcl/aqua/source/window/salmenu.cxx --- ooo_SRC680_m179_src.orig/vcl/aqua/source/window/salmenu.cxx 1970-01-01 01:00:00.000000000 +0100 +++ ooo_SRC680_m179_src/vcl/aqua/source/window/salmenu.cxx 2006-08-01 22:01:17.000000000 +0200 @@ -0,0 +1,247 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: salmenu.cxx,v $ + * + * $Revision: 1.6 $ + * + * last change: $Author: rt $ $Date: 2005/09/09 13:51:47 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +#ifndef _SV_SALDATA_HXX +#include +#endif +#ifndef _SV_SALINST_H +#include +#endif +#ifndef _SV_SALMENU_H +#include +#endif + +// ======================================================================= + +SalMenu* AquaSalInstance::CreateMenu( BOOL bMenuBar ) +{ + fprintf(stderr, "PJ: AquaSalInstance::CreateMenu(%d)\n", bMenuBar); + + AquaSalMenu *pAquaSalMenu = new AquaSalMenu(); + static MenuID inMenuID=0; + + pAquaSalMenu->mbMenuBar = bMenuBar; + + CreateNewMenu (inMenuID++, 0, &pAquaSalMenu->mrMenuRef); + + /* Associate the pointer to this SalMenu with the menu */ + fprintf(stderr, "PJ: Associating %p, 0 = %p\n", pAquaSalMenu->mrMenuRef, pAquaSalMenu); + + SetMenuItemProperty (pAquaSalMenu->mrMenuRef, 0, + APP_PROPERTY_CREATOR, APP_PROPERTY_TAG_MENU_POINTER, + sizeof(pAquaSalMenu), &pAquaSalMenu); + + fprintf(stderr, "PJ: returning %p (MenuRef = %p)\n", pAquaSalMenu, pAquaSalMenu->mrMenuRef); + + return pAquaSalMenu; +} + +void AquaSalInstance::DestroyMenu( SalMenu* pSalMenu ) +{ + delete pSalMenu; +} + +SalMenuItem* AquaSalInstance::CreateMenuItem( const SalItemParams* pItemData ) +{ + fprintf(stderr, "PJ: AquaSalInstance::CreateMenuItem()\n"); + + if( !pItemData ) + return NULL; + + AquaSalMenuItem *pSalMenuItem = new AquaSalMenuItem(); + + pSalMenuItem->maMenuAttributes = 0; + pSalMenuItem->mnId = pItemData->nId; + pSalMenuItem->mText = pItemData->aText; + + // Delete mnemonics + pSalMenuItem->mText.EraseAllChars( '~' ); + + pSalMenuItem->mpMenu = pItemData->pMenu; + + fprintf(stderr, "PJ: nId = %d\n", pItemData->nId); + fprintf(stderr, "PJ: mText = %s\n", + ByteString(pItemData->aText,RTL_TEXTENCODING_UTF8).GetBuffer()); + fprintf(stderr, "PJ: returning %p\n", pSalMenuItem); + + fprintf(stderr, "PJ: Separator = %d\n", pItemData->eType & MENUITEM_SEPARATOR); + + if (pItemData->eType == MENUITEM_SEPARATOR) + pSalMenuItem->maMenuAttributes |= kMenuItemAttrSeparator; + + return pSalMenuItem; +} + +void AquaSalInstance::DestroyMenuItem( SalMenuItem* pSalMenuItem ) +{ + delete pSalMenuItem; +} + + +// ======================================================================= + + +/* + * AquaSalMenu + */ + +AquaSalMenu::~AquaSalMenu() +{ + fprintf(stderr, "PJ: ~AquaSalMenu called for %p\n", this); + + if (this->mrMenuRef) + { + fprintf(stderr, "PJ: DisposeMenu (%p)\n", this->mrMenuRef); + DisposeMenu(this->mrMenuRef); + } +} + +BOOL AquaSalMenu::VisibleMenuBar() +{ + fprintf(stderr, "PJ: VisibleMenuBar called!\n"); + return TRUE; +} + +void AquaSalMenu::SetFrame( const SalFrame *pFrame ) +{ + fprintf(stderr, "PJ: SetFrame called!\n"); +} + +void AquaSalMenu::InsertItem( SalMenuItem* pSalMenuItem, unsigned nPos ) +{ + fprintf(stderr, "PJ: AquaSalMenu::InsertItem called (%p, nPos = %d)\n.", pSalMenuItem, nPos); + + AquaSalMenuItem *pAquaSalMenuItem = (AquaSalMenuItem *) pSalMenuItem; + fprintf(stderr, "PJ: pAquaSalMenuItem = %p\n", pAquaSalMenuItem); + + // save MenuRef of the menu for future reference + pAquaSalMenuItem->mrParentMenuRef = mrMenuRef; + + fprintf(stderr, "PJ: mbMenuBar = %d\n", mbMenuBar); + + if (mbMenuBar) + AppendMenuItemTextWithCFString( mrMenuRef, NULL, pAquaSalMenuItem->maMenuAttributes, 0, &pAquaSalMenuItem->mnMenuItemIndex); + else + { + CFStringRef menuText = CFStringCreateWithFormat(NULL, NULL, CFSTR("%s"), ByteString( pAquaSalMenuItem->mText, RTL_TEXTENCODING_UTF8).GetBuffer()); + + AppendMenuItemTextWithCFString( mrMenuRef, menuText, pAquaSalMenuItem->maMenuAttributes, 0, &pAquaSalMenuItem->mnMenuItemIndex); + } + + /* Associate the pointer to this SalMenuItem with the menu item */ + fprintf(stderr, "PJ: Associating %p, %d = %p\n", mrMenuRef, pAquaSalMenuItem->mnMenuItemIndex, pSalMenuItem); + + SetMenuItemProperty (mrMenuRef, pAquaSalMenuItem->mnMenuItemIndex, + APP_PROPERTY_CREATOR, APP_PROPERTY_TAG_MENU_POINTER, + sizeof(pSalMenuItem), &pSalMenuItem); +} + +void AquaSalMenu::RemoveItem( unsigned nPos ) +{ + fprintf(stderr, "PJ: RemoveItem (nPos = %d)\n", nPos); + + MenuRef menu = this->mrMenuRef; + + if (menu) + // nPos is 0 based, MenuItemIndex is 1 based + DeleteMenuItem (menu, nPos+1); +} + +void AquaSalMenu::SetSubMenu( SalMenuItem* pSalMenuItem, SalMenu* pSubMenu, unsigned nPos ) +{ + fprintf(stderr, "PJ: SetSubMenu called!\n"); + + AquaSalMenuItem *pAquaSalMenuItem = (AquaSalMenuItem *) pSalMenuItem; + + AquaSalMenu *subAquaSalMenu = (AquaSalMenu *) pSubMenu; + + CFStringRef menuText = CFStringCreateWithFormat(NULL, NULL, CFSTR("%s"), ByteString( pAquaSalMenuItem->mText, RTL_TEXTENCODING_UTF8).GetBuffer()); + + fprintf(stderr, "PJ: pSalMenuItem = %p\n", pSalMenuItem); + fprintf(stderr, "PJ: pSubMenu = %p\n", pSubMenu); + fprintf(stderr, "PJ: nPos = %d\n", nPos); + fprintf(stderr, "PJ: menuText = %s\n", ByteString( pAquaSalMenuItem->mText, RTL_TEXTENCODING_UTF8).GetBuffer()); + + // FIXME: in svtools - workben - svdem, pSubMenu is NULL! + if (subAquaSalMenu) + { + SetMenuTitleWithCFString(subAquaSalMenu->mrMenuRef, menuText); + SetMenuItemHierarchicalMenu (mrMenuRef, pAquaSalMenuItem->mnMenuItemIndex, subAquaSalMenu->mrMenuRef); + } +} + +void AquaSalMenu::CheckItem( unsigned nPos, BOOL bCheck ) +{ + // nPos is 0 based, MenuItemIndex is 1 based + CheckMenuItem(this->mrMenuRef, nPos+1, bCheck); +} + +void AquaSalMenu::EnableItem( unsigned nPos, BOOL bEnable ) +{ + // nPos is 0 based, MenuItemIndex is 1 based + if (bEnable) + EnableMenuItem(this->mrMenuRef, nPos+1); + else + DisableMenuItem(this->mrMenuRef, nPos+1); +} + +void AquaSalMenu::SetItemImage( unsigned nPos, SalMenuItem* pSalMenuItem, const Image& rImage ) +{ +} + +void AquaSalMenu::SetItemText( unsigned nPos, SalMenuItem* pSalMenuItem, const XubString& rText ) +{ + fprintf(stderr, "PJ: SetItemText (rText = %s).\n", rText.GetBuffer()); +} + +void AquaSalMenu::SetAccelerator( unsigned nPos, SalMenuItem* pSalMenuItem, const KeyCode& rKeyCode, const XubString& rKeyName ) +{ +} + +void AquaSalMenu::GetSystemMenuData( SystemMenuData* pData ) +{ +} + +// ======================================================================= + +/* + * SalMenuItem + */ + +AquaSalMenuItem::~AquaSalMenuItem() +{ +} + +// ------------------------------------------------------------------- diff -urN ooo_SRC680_m179_src.orig/vcl/workben/svdem.cxx ooo_SRC680_m179_src/vcl/workben/svdem.cxx --- ooo_SRC680_m179_src.orig/vcl/workben/svdem.cxx 2006-08-01 20:21:39.000000000 +0200 +++ ooo_SRC680_m179_src/vcl/workben/svdem.cxx 2006-08-01 22:04:34.000000000 +0200 @@ -42,6 +42,7 @@ #include #include #include +#include #include #include @@ -87,10 +88,87 @@ void KeyUp( const KeyEvent& rKEvt ); void Paint( const Rectangle& rRect ); void Resize(); + MenuBar aMenuBar; + PopupMenu aFileMenu; + PopupMenu aEditMenu; + + DECL_LINK(MyFileSelectHandler, Menu *); + DECL_LINK(MyEditSelectHandler, Menu *); + + DECL_LINK(MyFileHighlightHandler, Menu *); + DECL_LINK(MyEditHighlightHandler, Menu *); }; // ----------------------------------------------------------------------- +IMPL_LINK (MyWin, MyFileSelectHandler, Menu *, pMenu) +{ + fprintf (stderr, "MyFileSelectHandler called!\n"); + + USHORT nItemId = pMenu->GetCurItemId(); + fprintf(stderr, "PJ: nItemId = %d\n", nItemId); + + if ( nItemId == 1) + fprintf(stderr, "PJ: Open selected\n"); + else if ( nItemId == 4) + { + fprintf(stderr, "PJ: Exit selected -> Quit!\n"); + exit(0); + } +} + +// ----------------------------------------------------------------------- + +IMPL_LINK (MyWin, MyEditSelectHandler, Menu *, pMenu) +{ + fprintf (stderr, "MyEditSelectHandler called!\n"); + + USHORT nItemId = pMenu->GetCurItemId(); + fprintf(stderr, "PJ: nItemId = %d\n", nItemId); + + if ( nItemId == 1) + fprintf(stderr, "PJ: Search selected\n"); + else if ( nItemId == 2) + { + fprintf(stderr, "PJ: 'Remove itself from menu' selected\n"); + pMenu->RemoveItem (1); + } +} + +// ----------------------------------------------------------------------- + +IMPL_LINK (MyWin, MyFileHighlightHandler, Menu *, pMenu) +{ + fprintf (stderr, "MyFileHighlightHandler called!\n"); + + USHORT nItemId = pMenu->GetCurItemId(); + fprintf(stderr, "PJ: nItemId = %d\n", nItemId); + + if ( nItemId == 1) + fprintf(stderr, "PJ: Open highlighted\n"); + else if ( nItemId == 2) + fprintf(stderr, "PJ: Close highlighted\n"); + else if ( nItemId == 4) + fprintf(stderr, "PJ: Exit highlighted, take care when selecting it!\n"); +} + +// ----------------------------------------------------------------------- + +IMPL_LINK (MyWin, MyEditHighlightHandler, Menu *, pMenu) +{ + fprintf (stderr, "MyEditHighlightHandler called!\n"); + + USHORT nItemId = pMenu->GetCurItemId(); + fprintf(stderr, "PJ: nItemId = %d\n", nItemId); + + if ( nItemId == 1) + fprintf(stderr, "PJ: Search highlighted\n"); + else if ( nItemId == 2) + fprintf(stderr, "PJ: 'Remove itself from menu' highlighted - will remove itself from the menu!\n"); +} + +// ----------------------------------------------------------------------- + void Main() { /* @@ -104,6 +182,78 @@ aMainWin.SetText( XubString( RTL_CONSTASCII_USTRINGPARAM( "VCL - Workbench" ) ) ); aMainWin.Show(); +#define PJ_DEBUG(STRING) fprintf(stderr, "PJ: --- " STRING " ---\n"); + + PJ_DEBUG("1"); + + aMainWin.aMenuBar.InsertItem( 1, XubString( RTL_CONSTASCII_USTRINGPARAM( "File" ) ) ); + + PJ_DEBUG("2"); + + aMainWin.aMenuBar.InsertItem( 2, XubString( RTL_CONSTASCII_USTRINGPARAM( "Edit" ) ) ); + + PJ_DEBUG("3"); + + aMainWin.aMenuBar.SetPopupMenu( 1, &aMainWin.aFileMenu ); + + PJ_DEBUG("4"); + + aMainWin.aMenuBar.SetPopupMenu( 2, &aMainWin.aEditMenu ); + + PJ_DEBUG("5"); + + aMainWin.aFileMenu.InsertItem( 1, XubString( RTL_CONSTASCII_USTRINGPARAM( "Open" ) )); + + PJ_DEBUG("6"); + + aMainWin.aFileMenu.CheckItem( 1, TRUE); + + PJ_DEBUG("7"); + + aMainWin.aFileMenu.InsertItem( 2, XubString( RTL_CONSTASCII_USTRINGPARAM( "Close" ) )); + + PJ_DEBUG("8"); + + aMainWin.aFileMenu.EnableItem( 2, FALSE); + + PJ_DEBUG("9"); + + aMainWin.aFileMenu.InsertSeparator( 3 ); + + PJ_DEBUG("10"); + + aMainWin.aFileMenu.InsertItem( 4, XubString( RTL_CONSTASCII_USTRINGPARAM( "Exit" ) )); + + PJ_DEBUG("11"); + + aMainWin.aFileMenu.SetSelectHdl( LINK( &aMainWin, MyWin, MyFileSelectHandler)); + + PJ_DEBUG("12"); + + aMainWin.aFileMenu.SetHighlightHdl( LINK( &aMainWin, MyWin, MyFileHighlightHandler)); + + PJ_DEBUG("13"); + + aMainWin.aEditMenu.InsertItem( 1, XubString( RTL_CONSTASCII_USTRINGPARAM( "Search" ) )); + + PJ_DEBUG("14"); + + aMainWin.aEditMenu.InsertItem( 2, XubString( RTL_CONSTASCII_USTRINGPARAM( "Remove itself from menu" ) )); + + PJ_DEBUG("15"); + + aMainWin.aEditMenu.SetSelectHdl( LINK( &aMainWin, MyWin, MyEditSelectHandler)); + + PJ_DEBUG("16"); + + aMainWin.aEditMenu.SetHighlightHdl( LINK( &aMainWin, MyWin, MyEditHighlightHandler)); + + PJ_DEBUG("17"); + + aMainWin.SetMenuBar( &aMainWin.aMenuBar ); + + PJ_DEBUG("18"); + /* InfoBox ib(NULL, String((sal_Char*)"Test", sizeof("Test"))); ib.Execute();