Back to index

lightning-sunbird  0.9+nobinonly
Classes | Functions | Variables
nsMenuX.cpp File Reference
#include "nsCOMPtr.h"
#include "nsIDocument.h"
#include "nsIContent.h"
#include "nsIDOMDocument.h"
#include "nsIDocumentViewer.h"
#include "nsIDocumentObserver.h"
#include "nsIComponentManager.h"
#include "nsIDocShell.h"
#include "prinrval.h"
#include "nsMenuX.h"
#include "nsMenuBarX.h"
#include "nsIMenu.h"
#include "nsIMenuBar.h"
#include "nsIMenuItem.h"
#include "nsIMenuListener.h"
#include "nsPresContext.h"
#include "nsIMenuCommandDispatcher.h"
#include "nsString.h"
#include "nsCRT.h"
#include "nsReadableUtils.h"
#include "nsUnicharUtils.h"
#include "plstr.h"
#include "nsINameSpaceManager.h"
#include "nsWidgetAtoms.h"
#include "nsIXBLService.h"
#include "nsIServiceManager.h"
#include <Appearance.h>
#include <ToolUtils.h>
#include <UnicodeConverter.h>
#include "nsGUIEvent.h"
#include "nsWidgetsCID.h"

Go to the source code of this file.

Classes

class  nsDummyMenuItemX

Functions

static OSStatus InstallMyMenuEventHandler (MenuRef menuRef, void *userData, EventHandlerRef *outHandler)
static NS_DEFINE_CID (kMenuCID, NS_MENU_CID)
static NS_DEFINE_CID (kMenuItemCID, NS_MENUITEM_CID)
 NS_IMETHODIMP_ (nsrefcnt) nsDummyMenuItemX
static pascal OSStatus MyMenuEventHandler (EventHandlerCallRef myHandler, EventRef event, void *userData)

Variables

static MenuID gCurrentlyTrackedMenuID = 0
const PRInt16 kMacMenuIDX = nsMenuBarX::kAppleMenuID + 1
static PRInt16 gMacMenuIDCountX = kMacMenuIDX
static PRBool gConstructingMenu = PR_FALSE
static nsDummyMenuItemX gDummyMenuItemX

Function Documentation

static OSStatus InstallMyMenuEventHandler ( MenuRef  menuRef,
void userData,
EventHandlerRef *  outHandler 
) [static]

Definition at line 715 of file nsMenuX.cpp.

{
  // install the event handler for the various carbon menu events.
  static EventTypeSpec eventList[] = {
      { kEventClassMenu, kEventMenuBeginTracking },
      { kEventClassMenu, kEventMenuEndTracking },
      { kEventClassMenu, kEventMenuChangeTrackingMode },
      { kEventClassMenu, kEventMenuOpening },
      { kEventClassMenu, kEventMenuClosed },
      { kEventClassMenu, kEventMenuTargetItem },
      { kEventClassMenu, kEventMenuMatchKey },
      { kEventClassMenu, kEventMenuEnableItems }
  };
  static EventHandlerUPP gMyMenuEventHandlerUPP = NewEventHandlerUPP(&MyMenuEventHandler);
  return ::InstallMenuEventHandler(menuRef, gMyMenuEventHandlerUPP,
                                   sizeof(eventList) / sizeof(EventTypeSpec), eventList,
                                   userData, outHandler);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static pascal OSStatus MyMenuEventHandler ( EventHandlerCallRef  myHandler,
EventRef  event,
void userData 
) [static]

Definition at line 683 of file nsMenuX.cpp.

{
  OSStatus result = eventNotHandledErr;

  UInt32 kind = ::GetEventKind(event);
  if (kind == kEventMenuOpening || kind == kEventMenuClosed) {
    nsISupports* supports = reinterpret_cast<nsISupports*>(userData);
    nsCOMPtr<nsIMenuListener> listener(do_QueryInterface(supports));
    if (listener) {
      MenuRef menuRef;
      ::GetEventParameter(event, kEventParamDirectObject, typeMenuRef, NULL, sizeof(menuRef), NULL, &menuRef);
      nsMenuEvent menuEvent(PR_TRUE, NS_MENU_SELECTED, nsnull);
      menuEvent.time = PR_IntervalNow();
      menuEvent.mCommand = (PRUint32) menuRef;
      if (kind == kEventMenuOpening) {
        gCurrentlyTrackedMenuID = ::GetMenuID(menuRef);    // remember which menu ID we're over for later
        listener->MenuSelected(menuEvent);
      }
      else
        listener->MenuDeselected(menuEvent);
    }
  }
  else if ( kind == kEventMenuTargetItem ) {
    // remember which menu ID we're over for later
    MenuRef menuRef;
    ::GetEventParameter(event, kEventParamDirectObject, typeMenuRef, NULL, sizeof(menuRef), NULL, &menuRef);
    gCurrentlyTrackedMenuID = ::GetMenuID(menuRef);
  }
  
  return result;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static NS_DEFINE_CID ( kMenuCID  ,
NS_MENU_CID   
) [static]
static NS_DEFINE_CID ( kMenuItemCID  ,
NS_MENUITEM_CID   
) [static]

Definition at line 101 of file nsMenuX.cpp.

{ return ++mRefCnt; }

Variable Documentation

Definition at line 84 of file nsMenuX.cpp.

MenuID gCurrentlyTrackedMenuID = 0 [static]

Definition at line 80 of file nsMenuX.cpp.

Definition at line 104 of file nsMenuX.cpp.

Definition at line 83 of file nsMenuX.cpp.

Definition at line 82 of file nsMenuX.cpp.