Back to index

lightning-sunbird  0.9+nobinonly
nsIMenuParent.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 /* ***** BEGIN LICENSE BLOCK *****
00003  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00004  *
00005  * The contents of this file are subject to the Mozilla Public License Version
00006  * 1.1 (the "License"); you may not use this file except in compliance with
00007  * the License. You may obtain a copy of the License at
00008  * http://www.mozilla.org/MPL/
00009  *
00010  * Software distributed under the License is distributed on an "AS IS" basis,
00011  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00012  * for the specific language governing rights and limitations under the
00013  * License.
00014  *
00015  * The Original Code is Mozilla Communicator client code.
00016  *
00017  * The Initial Developer of the Original Code is
00018  * Netscape Communications Corporation.
00019  * Portions created by the Initial Developer are Copyright (C) 1998
00020  * the Initial Developer. All Rights Reserved.
00021  *
00022  * Contributor(s):
00023  *   Dean Tessman <dean_tessman@hotmail.com>
00024  *
00025  * Alternatively, the contents of this file may be used under the terms of
00026  * either of the GNU General Public License Version 2 or later (the "GPL"),
00027  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00028  * in which case the provisions of the GPL or the LGPL are applicable instead
00029  * of those above. If you wish to allow use of your version of this file only
00030  * under the terms of either the GPL or the LGPL, and not to allow others to
00031  * use your version of this file under the terms of the MPL, indicate your
00032  * decision by deleting the provisions above and replace them with the notice
00033  * and other provisions required by the GPL or the LGPL. If you do not delete
00034  * the provisions above, a recipient may use your version of this file under
00035  * the terms of any one of the MPL, the GPL or the LGPL.
00036  *
00037  * ***** END LICENSE BLOCK ***** */
00038 
00039 #ifndef nsIMenuParent_h___
00040 #define nsIMenuParent_h___
00041 
00042 
00043 // {81C0BF71-9F50-4f4d-8B6A-D6B233C100C2}
00044 #define NS_IMENUPARENT_IID \
00045 { 0x81c0bf71, 0x9f50, 0x4f4d, { 0x8b, 0x6a, 0xd6, 0xb2, 0x33, 0xc1, 0x0, 0xc2 } };
00046 
00047 class nsIMenuFrame;
00048 class nsIDOMKeyEvent;
00049 
00050 /*
00051  * nsIMenuParent is implemented on frames and thus should not be
00052  * refcounted.  Eventually it should not inherit from nsISupports.
00053  */
00054 
00081 enum nsNavigationDirection {
00082   eNavigationDirection_Last,
00083   eNavigationDirection_First,
00084   eNavigationDirection_Start,
00085   eNavigationDirection_Before,
00086   eNavigationDirection_End,
00087   eNavigationDirection_After
00088 };
00089 
00090 #define NS_DIRECTION_IS_INLINE(dir) (dir == eNavigationDirection_Start ||     \
00091                                      dir == eNavigationDirection_End)
00092 #define NS_DIRECTION_IS_BLOCK(dir) (dir == eNavigationDirection_Before || \
00093                                     dir == eNavigationDirection_After)
00094 #define NS_DIRECTION_IS_BLOCK_TO_EDGE(dir) (dir == eNavigationDirection_First ||    \
00095                                             dir == eNavigationDirection_Last)
00096 
00101 static nsNavigationDirection DirectionFromKeyCode_lr_tb [6] = {
00102   eNavigationDirection_Last,   // NS_VK_END
00103   eNavigationDirection_First,  // NS_VK_HOME
00104   eNavigationDirection_Start,  // NS_VK_LEFT
00105   eNavigationDirection_Before, // NS_VK_UP
00106   eNavigationDirection_End,    // NS_VK_RIGHT
00107   eNavigationDirection_After   // NS_VK_DOWN
00108 };
00109 
00114 static nsNavigationDirection DirectionFromKeyCode_rl_tb [6] = {
00115   eNavigationDirection_Last,   // NS_VK_END
00116   eNavigationDirection_First,  // NS_VK_HOME
00117   eNavigationDirection_End,    // NS_VK_LEFT
00118   eNavigationDirection_Before, // NS_VK_UP
00119   eNavigationDirection_Start,  // NS_VK_RIGHT
00120   eNavigationDirection_After   // NS_VK_DOWN
00121 };
00122 
00123 #ifdef IBMBIDI
00124 #define NS_DIRECTION_FROM_KEY_CODE(direction, keycode)           \
00125   NS_ASSERTION(keycode >= NS_VK_END && keycode <= NS_VK_DOWN,    \
00126                "Illegal key code");                              \
00127   const nsStyleVisibility* vis = GetStyleVisibility();           \
00128   if (vis->mDirection == NS_STYLE_DIRECTION_RTL)                 \
00129     direction = DirectionFromKeyCode_rl_tb[keycode - NS_VK_END]; \
00130   else                                                           \
00131     direction = DirectionFromKeyCode_lr_tb[keycode - NS_VK_END];
00132 #else
00133 #define NS_DIRECTION_FROM_KEY_CODE(direction, keycode)           \
00134     direction = DirectionFromKeyCode_lr_tb[keycode - NS_VK_END];
00135 #endif
00136 
00137 class nsIMenuParent : public nsISupports {
00138 
00139 public:
00140   NS_DEFINE_STATIC_IID_ACCESSOR(NS_IMENUPARENT_IID)
00141 
00142   virtual nsIMenuFrame *GetCurrentMenuItem() = 0;
00143   NS_IMETHOD SetCurrentMenuItem(nsIMenuFrame* aMenuItem) = 0;
00144   virtual nsIMenuFrame *GetNextMenuItem(nsIMenuFrame* aStart) = 0;
00145   virtual nsIMenuFrame *GetPreviousMenuItem(nsIMenuFrame* aStart) = 0;
00146 
00147   NS_IMETHOD SetActive(PRBool aActiveFlag) = 0;
00148   NS_IMETHOD GetIsActive(PRBool& isActive) = 0;
00149   NS_IMETHOD GetWidget(nsIWidget **aWidget) = 0;
00150   
00151   NS_IMETHOD IsMenuBar(PRBool& isMenuBar) = 0;
00152   NS_IMETHOD ConsumeOutsideClicks(PRBool& aConsumeOutsideClicks) = 0;
00153   NS_IMETHOD ClearRecentlyRolledUp() = 0;
00154   NS_IMETHOD RecentlyRolledUp(nsIMenuFrame *aMenuFrame, PRBool *aJustRolledUp) = 0;
00155 
00156   NS_IMETHOD DismissChain() = 0;
00157   NS_IMETHOD HideChain() = 0;
00158   NS_IMETHOD KillPendingTimers() = 0;
00159 
00160   NS_IMETHOD CreateDismissalListener() = 0;
00161 
00162   NS_IMETHOD InstallKeyboardNavigator() = 0;
00163   NS_IMETHOD RemoveKeyboardNavigator() = 0;
00164 
00165   // Used to move up, down, left, and right in menus.
00166   NS_IMETHOD KeyboardNavigation(PRUint32 aKeyCode, PRBool& aHandledFlag) = 0;
00167   NS_IMETHOD ShortcutNavigation(nsIDOMKeyEvent* aKeyEvent, PRBool& aHandledFlag) = 0;
00168   // Called when the ESC key is held down to close levels of menus.
00169   NS_IMETHOD Escape(PRBool& aHandledFlag) = 0;
00170   // Called to execute a menu item.
00171   NS_IMETHOD Enter() = 0;
00172 
00173   NS_IMETHOD SetIsContextMenu(PRBool aIsContextMenu) = 0;
00174   NS_IMETHOD GetIsContextMenu(PRBool& aIsContextMenu) = 0;
00175   
00176 };
00177 
00178 #endif
00179