summaryrefslogtreecommitdiffstats
path: root/widget/gtk/nsMenuContainer.h
diff options
context:
space:
mode:
authorLootyhoof <lootyhoofer@gmail.com>2020-06-06 00:37:29 +0100
committerwolfbeast <mcwerewolf@wolfbeast.com>2020-06-13 11:49:36 +0200
commit6235023c8bff80273981c70a06cb9decb4a4ffa5 (patch)
tree9673404b3735e8a8b6bd3e890c3d6b5d2d34d76c /widget/gtk/nsMenuContainer.h
parentf51beb3fdab3d586af081ac14478ea59e0523af4 (diff)
downloadUXP-6235023c8bff80273981c70a06cb9decb4a4ffa5.tar
UXP-6235023c8bff80273981c70a06cb9decb4a4ffa5.tar.gz
UXP-6235023c8bff80273981c70a06cb9decb4a4ffa5.tar.lz
UXP-6235023c8bff80273981c70a06cb9decb4a4ffa5.tar.xz
UXP-6235023c8bff80273981c70a06cb9decb4a4ffa5.zip
Issue MoonchildProductions/UXP#1578 - Add global menubar support for GTK
Diffstat (limited to 'widget/gtk/nsMenuContainer.h')
-rw-r--r--widget/gtk/nsMenuContainer.h66
1 files changed, 66 insertions, 0 deletions
diff --git a/widget/gtk/nsMenuContainer.h b/widget/gtk/nsMenuContainer.h
new file mode 100644
index 000000000..95d65a2f1
--- /dev/null
+++ b/widget/gtk/nsMenuContainer.h
@@ -0,0 +1,66 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#ifndef __nsMenuContainer_h__
+#define __nsMenuContainer_h__
+
+#include "mozilla/UniquePtr.h"
+#include "nsTArray.h"
+
+#include "nsMenuObject.h"
+
+class nsIContent;
+class nsNativeMenuDocListener;
+
+// Base class for containers (menus and menubars)
+class nsMenuContainer : public nsMenuObject {
+public:
+ typedef nsTArray<mozilla::UniquePtr<nsMenuObject> > ChildTArray;
+
+ // Determine if this container is being displayed on screen. Must be
+ // implemented by subclasses. Must return true if the container is
+ // in the fully open state, or false otherwise
+ virtual bool IsBeingDisplayed() const = 0;
+
+ // Determine if this container will be rebuilt the next time it opens.
+ // Returns false by default but can be overridden by subclasses
+ virtual bool NeedsRebuild() const;
+
+ // Return the first previous sibling that is of a type supported by the
+ // menu system
+ static nsIContent* GetPreviousSupportedSibling(nsIContent* aContent);
+
+ static const ChildTArray::index_type NoIndex;
+
+protected:
+ nsMenuContainer(nsMenuContainer* aParent, nsIContent* aContent);
+ nsMenuContainer(nsNativeMenuDocListener* aListener, nsIContent* aContent);
+
+ // Create a new child element for the specified content node
+ mozilla::UniquePtr<nsMenuObject> CreateChild(nsIContent* aContent);
+
+ // Return the index of the child for the specified content node
+ size_t IndexOf(nsIContent* aChild) const;
+
+ size_t ChildCount() const { return mChildren.Length(); }
+ nsMenuObject* ChildAt(size_t aIndex) const { return mChildren[aIndex].get(); }
+
+ void RemoveChildAt(size_t aIndex, bool aUpdateNative = true);
+
+ // Remove the child that owns the specified content node
+ void RemoveChild(nsIContent* aChild, bool aUpdateNative = true);
+
+ // Insert a new child after the child that owns the specified content node
+ void InsertChildAfter(mozilla::UniquePtr<nsMenuObject> aChild,
+ nsIContent* aPrevSibling,
+ bool aUpdateNative = true);
+
+ void AppendChild(mozilla::UniquePtr<nsMenuObject> aChild,
+ bool aUpdateNative = true);
+
+private:
+ ChildTArray mChildren;
+};
+
+#endif /* __nsMenuContainer_h__ */