|
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
|
2 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
3 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
5 |
|
6 #ifndef nsMenuGroupOwnerX_h_ |
|
7 #define nsMenuGroupOwnerX_h_ |
|
8 |
|
9 #import <Cocoa/Cocoa.h> |
|
10 |
|
11 #include "nsMenuBaseX.h" |
|
12 #include "nsIMutationObserver.h" |
|
13 #include "nsHashKeys.h" |
|
14 #include "nsDataHashtable.h" |
|
15 #include "nsAutoPtr.h" |
|
16 #include "nsString.h" |
|
17 |
|
18 |
|
19 class nsMenuX; |
|
20 class nsMenuItemX; |
|
21 class nsChangeObserver; |
|
22 class nsIWidget; |
|
23 class nsIContent; |
|
24 class nsIDocument; |
|
25 |
|
26 class nsMenuGroupOwnerX : public nsMenuObjectX, public nsIMutationObserver |
|
27 { |
|
28 public: |
|
29 nsMenuGroupOwnerX(); |
|
30 virtual ~nsMenuGroupOwnerX(); |
|
31 |
|
32 nsresult Create(nsIContent * aContent); |
|
33 |
|
34 void RegisterForContentChanges(nsIContent* aContent, |
|
35 nsChangeObserver* aMenuObject); |
|
36 void UnregisterForContentChanges(nsIContent* aContent); |
|
37 uint32_t RegisterForCommand(nsMenuItemX* aItem); |
|
38 void UnregisterCommand(uint32_t aCommandID); |
|
39 nsMenuItemX* GetMenuItemForCommandID(uint32_t inCommandID); |
|
40 |
|
41 NS_DECL_ISUPPORTS |
|
42 NS_DECL_NSIMUTATIONOBSERVER |
|
43 |
|
44 protected: |
|
45 nsChangeObserver* LookupContentChangeObserver(nsIContent* aContent); |
|
46 |
|
47 uint32_t mCurrentCommandID; // unique command id (per menu-bar) to |
|
48 // give to next item that asks |
|
49 nsIDocument* mDocument; // pointer to document |
|
50 |
|
51 // stores observers for content change notification |
|
52 nsDataHashtable<nsPtrHashKey<nsIContent>, nsChangeObserver *> mContentToObserverTable; |
|
53 |
|
54 // stores mapping of command IDs to menu objects |
|
55 nsDataHashtable<nsUint32HashKey, nsMenuItemX *> mCommandToMenuObjectTable; |
|
56 }; |
|
57 |
|
58 #endif // nsMenuGroupOwner_h_ |