LCOV - code coverage report
Current view: directory - layout/xul/base/src - nsMenuBarFrame.h (source / functions) Found Hit Coverage
Test: app.info Lines: 19 0 0.0 %
Date: 2012-06-02 Functions: 16 0 0.0 %

       1                 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
       2                 : /* ***** BEGIN LICENSE BLOCK *****
       3                 :  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
       4                 :  *
       5                 :  * The contents of this file are subject to the Mozilla Public License Version
       6                 :  * 1.1 (the "License"); you may not use this file except in compliance with
       7                 :  * the License. You may obtain a copy of the License at
       8                 :  * http://www.mozilla.org/MPL/
       9                 :  *
      10                 :  * Software distributed under the License is distributed on an "AS IS" basis,
      11                 :  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
      12                 :  * for the specific language governing rights and limitations under the
      13                 :  * License.
      14                 :  *
      15                 :  * The Original Code is mozilla.org code.
      16                 :  *
      17                 :  * The Initial Developer of the Original Code is
      18                 :  * Netscape Communications Corporation.
      19                 :  * Portions created by the Initial Developer are Copyright (C) 1998
      20                 :  * the Initial Developer. All Rights Reserved.
      21                 :  *
      22                 :  * Contributor(s):
      23                 :  *   Original Author: David W. Hyatt (hyatt@netscape.com)
      24                 :  *   Dean Tessman <dean_tessman@hotmail.com>
      25                 :  *   Dan Rosen <dr@netscape.com>
      26                 :  *
      27                 :  * Alternatively, the contents of this file may be used under the terms of
      28                 :  * either of the GNU General Public License Version 2 or later (the "GPL"),
      29                 :  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
      30                 :  * in which case the provisions of the GPL or the LGPL are applicable instead
      31                 :  * of those above. If you wish to allow use of your version of this file only
      32                 :  * under the terms of either the GPL or the LGPL, and not to allow others to
      33                 :  * use your version of this file under the terms of the MPL, indicate your
      34                 :  * decision by deleting the provisions above and replace them with the notice
      35                 :  * and other provisions required by the GPL or the LGPL. If you do not delete
      36                 :  * the provisions above, a recipient may use your version of this file under
      37                 :  * the terms of any one of the MPL, the GPL or the LGPL.
      38                 :  *
      39                 :  * ***** END LICENSE BLOCK ***** */
      40                 : 
      41                 : //
      42                 : // nsMenuBarFrame
      43                 : //
      44                 : 
      45                 : #ifndef nsMenuBarFrame_h__
      46                 : #define nsMenuBarFrame_h__
      47                 : 
      48                 : #include "prtypes.h"
      49                 : #include "nsIAtom.h"
      50                 : #include "nsCOMPtr.h"
      51                 : #include "nsBoxFrame.h"
      52                 : #include "nsMenuFrame.h"
      53                 : #include "nsMenuBarListener.h"
      54                 : #include "nsMenuParent.h"
      55                 : 
      56                 : class nsIContent;
      57                 : 
      58                 : nsIFrame* NS_NewMenuBarFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
      59                 : 
      60                 : class nsMenuBarFrame : public nsBoxFrame, public nsMenuParent
      61               0 : {
      62                 : public:
      63                 :   NS_DECL_QUERYFRAME_TARGET(nsMenuBarFrame)
      64                 :   NS_DECL_QUERYFRAME
      65                 :   NS_DECL_FRAMEARENA_HELPERS
      66                 : 
      67                 :   nsMenuBarFrame(nsIPresShell* aShell, nsStyleContext* aContext);
      68                 : 
      69                 :   // nsMenuParent interface
      70                 :   virtual nsMenuFrame* GetCurrentMenuItem();
      71                 :   NS_IMETHOD SetCurrentMenuItem(nsMenuFrame* aMenuItem);
      72                 :   virtual void CurrentMenuIsBeingDestroyed();
      73                 :   NS_IMETHOD ChangeMenuItem(nsMenuFrame* aMenuItem, bool aSelectFirstItem);
      74                 : 
      75                 :   NS_IMETHOD SetActive(bool aActiveFlag); 
      76                 : 
      77               0 :   virtual bool IsMenuBar() { return true; }
      78               0 :   virtual bool IsContextMenu() { return false; }
      79               0 :   virtual bool IsActive() { return mIsActive; }
      80               0 :   virtual bool IsMenu() { return false; }
      81               0 :   virtual bool IsOpen() { return true; } // menubars are considered always open
      82                 : 
      83               0 :   bool IsMenuOpen() { return mCurrentMenu && mCurrentMenu->IsOpen(); }
      84                 : 
      85                 :   void InstallKeyboardNavigator();
      86                 :   void RemoveKeyboardNavigator();
      87                 : 
      88                 :   NS_IMETHOD Init(nsIContent*      aContent,
      89                 :                   nsIFrame*        aParent,
      90                 :                   nsIFrame*        aPrevInFlow);
      91                 : 
      92                 :   virtual void DestroyFrom(nsIFrame* aDestructRoot);
      93                 : 
      94               0 :   virtual nsIAtom* GetType() const { return nsGkAtoms::menuBarFrame; }
      95                 : 
      96               0 :   virtual void LockMenuUntilClosed(bool aLock) {}
      97               0 :   virtual bool IsMenuLocked() { return false; }
      98                 : 
      99                 : // Non-interface helpers
     100                 : 
     101                 :   void
     102               0 :   SetStayActive(bool aStayActive) { mStayActive = aStayActive; }
     103                 : 
     104                 :   // Called when a menu on the menu bar is clicked on. Returns a menu if one
     105                 :   // needs to be closed.
     106                 :   nsMenuFrame* ToggleMenuActiveState();
     107                 : 
     108               0 :   bool IsActiveByKeyboard() { return mActiveByKeyboard; }
     109               0 :   void SetActiveByKeyboard() { mActiveByKeyboard = true; }
     110                 : 
     111                 :   // indicate that a menu on the menubar was closed. Returns true if the caller
     112                 :   // may deselect the menuitem.
     113                 :   virtual bool MenuClosed();
     114                 : 
     115                 :   // Called when Enter is pressed while the menubar is focused. If the current
     116                 :   // menu is open, let the child handle the key.
     117                 :   nsMenuFrame* Enter(nsGUIEvent* aEvent);
     118                 : 
     119                 :   // Used to handle ALT+key combos
     120                 :   nsMenuFrame* FindMenuWithShortcut(nsIDOMKeyEvent* aKeyEvent);
     121                 : 
     122               0 :   virtual bool IsFrameOfType(PRUint32 aFlags) const
     123                 :   {
     124                 :     // Override bogus IsFrameOfType in nsBoxFrame.
     125               0 :     if (aFlags & (nsIFrame::eReplacedContainsBlock | nsIFrame::eReplaced))
     126               0 :       return false;
     127               0 :     return nsBoxFrame::IsFrameOfType(aFlags);
     128                 :   }
     129                 : 
     130                 : #ifdef DEBUG
     131               0 :   NS_IMETHOD GetFrameName(nsAString& aResult) const
     132                 :   {
     133               0 :       return MakeFrameName(NS_LITERAL_STRING("MenuBar"), aResult);
     134                 :   }
     135                 : #endif
     136                 : 
     137                 : protected:
     138                 :   nsMenuBarListener* mMenuBarListener; // The listener that tells us about key and mouse events.
     139                 : 
     140                 :   // flag that is temporarily set when switching from one menu on the menubar to another
     141                 :   // to indicate that the menubar should not be deactivated.
     142                 :   bool mStayActive;
     143                 : 
     144                 :   bool mIsActive; // Whether or not the menu bar is active (a menu item is highlighted or shown).
     145                 : 
     146                 :   // whether the menubar was made active via the keyboard.
     147                 :   bool mActiveByKeyboard;
     148                 : 
     149                 :   // The current menu that is active (highlighted), which may not be open. This will
     150                 :   // be null if no menu is active.
     151                 :   nsMenuFrame* mCurrentMenu;
     152                 : 
     153                 :   nsIDOMEventTarget* mTarget;
     154                 : 
     155                 : }; // class nsMenuBarFrame
     156                 : 
     157                 : #endif

Generated by: LCOV version 1.7