#ifndef ContextMenu_h
#define ContextMenu_h
#include <wtf/Noncopyable.h>
#include "ContextMenuItem.h"
#include "PlatformMenuDescription.h"
#include "PlatformString.h"
#if PLATFORM(MAC)
#include <wtf/RetainPtr.h>
#elif PLATFORM(QT)
#include <QMenu>
#endif
namespace WebCore {
class ContextMenuController;
class ContextMenu {
WTF_MAKE_NONCOPYABLE(ContextMenu); WTF_MAKE_FAST_ALLOCATED;
public:
ContextMenu();
ContextMenuItem* itemWithAction(unsigned);
#if USE(CROSS_PLATFORM_CONTEXT_MENUS)
#if PLATFORM(WIN)
typedef HMENU NativeMenu;
#elif PLATFORM(EFL)
typedef void* NativeMenu;
#endif
explicit ContextMenu(NativeMenu);
NativeMenu nativeMenu() const;
static NativeMenu createNativeMenuFromItems(const Vector<ContextMenuItem>&);
static void getContextMenuItems(NativeMenu, Vector<ContextMenuItem>&);
ContextMenuItem* itemAtIndex(unsigned index) { return &m_items[index]; }
void setItems(const Vector<ContextMenuItem>& items) { m_items = items; }
const Vector<ContextMenuItem>& items() const { return m_items; }
void appendItem(const ContextMenuItem& item) { m_items.append(item); }
#else
ContextMenu(const PlatformMenuDescription);
~ContextMenu();
void insertItem(unsigned position, ContextMenuItem&);
void appendItem(ContextMenuItem&);
ContextMenuItem* itemAtIndex(unsigned, const PlatformMenuDescription);
unsigned itemCount() const;
PlatformMenuDescription platformDescription() const;
void setPlatformDescription(PlatformMenuDescription);
PlatformMenuDescription releasePlatformDescription();
#if PLATFORM(WX)
static ContextMenuItem* itemWithId(int);
#endif
#endif // USE(CROSS_PLATFORM_CONTEXT_MENUS)
private:
#if USE(CROSS_PLATFORM_CONTEXT_MENUS)
Vector<ContextMenuItem> m_items;
#else
#if PLATFORM(MAC)
RetainPtr<NSMutableArray> m_platformDescription;
#elif PLATFORM(QT)
QList<ContextMenuItem> m_items;
#elif PLATFORM(CHROMIUM)
Vector<ContextMenuItem> m_items;
#else
PlatformMenuDescription m_platformDescription;
#if OS(WINCE)
unsigned m_itemCount;
#endif
#endif
#endif // USE(CROSS_PLATFORM_CONTEXT_MENUS)
};
#if !USE(CROSS_PLATFORM_CONTEXT_MENUS)
Vector<ContextMenuItem> contextMenuItemVector(PlatformMenuDescription);
PlatformMenuDescription platformMenuDescription(Vector<ContextMenuItem>&);
#endif
}
#endif // ContextMenu_h