#ifndef ContextMenuItem_h
#define ContextMenuItem_h
#include "PlatformMenuDescription.h"
#include "PlatformString.h"
#include <wtf/OwnPtr.h>
#if PLATFORM(MAC)
#include <wtf/RetainPtr.h>
#ifdef __OBJC__
@class NSMenuItem;
#else
class NSMenuItem;
#endif
#elif PLATFORM(WIN)
typedef struct tagMENUITEMINFOW MENUITEMINFO;
#elif PLATFORM(GTK)
typedef struct _GtkMenuItem GtkMenuItem;
#elif PLATFORM(QT)
#include <QAction>
#elif PLATFORM(WX)
class wxMenuItem;
#elif PLATFORM(HAIKU)
class BMenuItem;
#endif
namespace WebCore {
class ContextMenu;
enum ContextMenuAction {
ContextMenuItemTagNoAction=0, ContextMenuItemTagOpenLinkInNewWindow=1,
ContextMenuItemTagDownloadLinkToDisk,
ContextMenuItemTagCopyLinkToClipboard,
ContextMenuItemTagOpenImageInNewWindow,
ContextMenuItemTagDownloadImageToDisk,
ContextMenuItemTagCopyImageToClipboard,
#if PLATFORM(QT) || PLATFORM(GTK)
ContextMenuItemTagCopyImageUrlToClipboard,
#endif
ContextMenuItemTagOpenFrameInNewWindow,
ContextMenuItemTagCopy,
ContextMenuItemTagGoBack,
ContextMenuItemTagGoForward,
ContextMenuItemTagStop,
ContextMenuItemTagReload,
ContextMenuItemTagCut,
ContextMenuItemTagPaste,
#if PLATFORM(GTK)
ContextMenuItemTagDelete,
#endif
#if PLATFORM(GTK) || PLATFORM(QT)
ContextMenuItemTagSelectAll,
#endif
#if PLATFORM(GTK)
ContextMenuItemTagInputMethods,
ContextMenuItemTagUnicode,
#endif
ContextMenuItemTagSpellingGuess,
ContextMenuItemTagNoGuessesFound,
ContextMenuItemTagIgnoreSpelling,
ContextMenuItemTagLearnSpelling,
ContextMenuItemTagOther,
ContextMenuItemTagSearchInSpotlight,
ContextMenuItemTagSearchWeb,
ContextMenuItemTagLookUpInDictionary,
ContextMenuItemTagOpenWithDefaultApplication,
ContextMenuItemPDFActualSize,
ContextMenuItemPDFZoomIn,
ContextMenuItemPDFZoomOut,
ContextMenuItemPDFAutoSize,
ContextMenuItemPDFSinglePage,
ContextMenuItemPDFFacingPages,
ContextMenuItemPDFContinuous,
ContextMenuItemPDFNextPage,
ContextMenuItemPDFPreviousPage,
ContextMenuItemTagOpenLink = 2000,
ContextMenuItemTagIgnoreGrammar,
ContextMenuItemTagSpellingMenu, ContextMenuItemTagShowSpellingPanel,
ContextMenuItemTagCheckSpelling,
ContextMenuItemTagCheckSpellingWhileTyping,
ContextMenuItemTagCheckGrammarWithSpelling,
ContextMenuItemTagFontMenu, ContextMenuItemTagShowFonts,
ContextMenuItemTagBold,
ContextMenuItemTagItalic,
ContextMenuItemTagUnderline,
ContextMenuItemTagOutline,
ContextMenuItemTagStyles,
ContextMenuItemTagShowColors,
ContextMenuItemTagSpeechMenu, ContextMenuItemTagStartSpeaking,
ContextMenuItemTagStopSpeaking,
ContextMenuItemTagWritingDirectionMenu, ContextMenuItemTagDefaultDirection,
ContextMenuItemTagLeftToRight,
ContextMenuItemTagRightToLeft,
ContextMenuItemTagPDFSinglePageScrolling,
ContextMenuItemTagPDFFacingPagesScrolling,
#if ENABLE(INSPECTOR)
ContextMenuItemTagInspectElement,
#endif
ContextMenuItemTagTextDirectionMenu, ContextMenuItemTagTextDirectionDefault,
ContextMenuItemTagTextDirectionLeftToRight,
ContextMenuItemTagTextDirectionRightToLeft,
#if PLATFORM(MAC)
ContextMenuItemTagCorrectSpellingAutomatically,
ContextMenuItemTagSubstitutionsMenu,
ContextMenuItemTagShowSubstitutions,
ContextMenuItemTagSmartCopyPaste,
ContextMenuItemTagSmartQuotes,
ContextMenuItemTagSmartDashes,
ContextMenuItemTagSmartLinks,
ContextMenuItemTagTextReplacement,
ContextMenuItemTagTransformationsMenu,
ContextMenuItemTagMakeUpperCase,
ContextMenuItemTagMakeLowerCase,
ContextMenuItemTagCapitalize,
ContextMenuItemTagChangeBack,
#endif
ContextMenuItemTagOpenMediaInNewWindow,
ContextMenuItemTagCopyMediaLinkToClipboard,
ContextMenuItemTagToggleMediaControls,
ContextMenuItemTagToggleMediaLoop,
ContextMenuItemTagEnterVideoFullscreen,
ContextMenuItemTagMediaPlayPause,
ContextMenuItemTagMediaMute,
ContextMenuItemBaseCustomTag = 5000,
ContextMenuItemCustomTagNoAction = 5998,
ContextMenuItemLastCustomTag = 5999,
ContextMenuItemBaseApplicationTag = 10000
};
enum ContextMenuItemType {
ActionType,
CheckableActionType,
SeparatorType,
SubmenuType
};
#if PLATFORM(MAC)
typedef NSMenuItem* PlatformMenuItemDescription;
#elif PLATFORM(QT)
struct PlatformMenuItemDescription {
PlatformMenuItemDescription()
: type(ActionType),
action(ContextMenuItemTagNoAction),
checked(false),
enabled(true)
{}
ContextMenuItemType type;
ContextMenuAction action;
String title;
QList<ContextMenuItem> subMenuItems;
bool checked;
bool enabled;
};
#elif PLATFORM(GTK)
typedef GtkMenuItem* PlatformMenuItemDescription;
#elif PLATFORM(WX)
struct PlatformMenuItemDescription {
PlatformMenuItemDescription()
: type(ActionType),
action(ContextMenuItemTagNoAction),
checked(false),
enabled(true)
{}
ContextMenuItemType type;
ContextMenuAction action;
String title;
wxMenu * subMenu;
bool checked;
bool enabled;
};
#elif PLATFORM(HAIKU)
typedef BMenuItem* PlatformMenuItemDescription;
#elif PLATFORM(CHROMIUM)
struct PlatformMenuItemDescription {
PlatformMenuItemDescription()
: type(ActionType)
, action(ContextMenuItemTagNoAction)
, checked(false)
, enabled(true) { }
ContextMenuItemType type;
ContextMenuAction action;
String title;
bool checked;
bool enabled;
};
#else
typedef void* PlatformMenuItemDescription;
#endif
class ContextMenuItem {
WTF_MAKE_FAST_ALLOCATED;
public:
ContextMenuItem(ContextMenuItemType, ContextMenuAction, const String&, ContextMenu* subMenu = 0);
ContextMenuItem(ContextMenuItemType, ContextMenuAction, const String&, bool enabled, bool checked);
~ContextMenuItem();
void setType(ContextMenuItemType);
ContextMenuItemType type() const;
void setAction(ContextMenuAction);
ContextMenuAction action() const;
void setChecked(bool = true);
bool checked() const;
void setEnabled(bool = true);
bool enabled() const;
void setSubMenu(ContextMenu*);
#if USE(CROSS_PLATFORM_CONTEXT_MENUS)
#if PLATFORM(WIN)
typedef MENUITEMINFO NativeItem;
#elif PLATFORM(EFL)
typedef void* NativeItem;
#endif
ContextMenuItem(ContextMenuAction, const String&, bool enabled, bool checked, const Vector<ContextMenuItem>& subMenuItems);
explicit ContextMenuItem(const NativeItem&);
NativeItem nativeMenuItem() const;
void setTitle(const String& title) { m_title = title; }
const String& title() const { return m_title; }
const Vector<ContextMenuItem>& subMenuItems() const { return m_subMenuItems; }
#else
public:
ContextMenuItem(PlatformMenuItemDescription);
ContextMenuItem(ContextMenu* subMenu = 0);
ContextMenuItem(ContextMenuAction, const String&, bool enabled, bool checked, Vector<ContextMenuItem>& submenuItems);
PlatformMenuItemDescription releasePlatformDescription();
String title() const;
void setTitle(const String&);
PlatformMenuDescription platformSubMenu() const;
void setSubMenu(Vector<ContextMenuItem>&);
#endif // USE(CROSS_PLATFORM_CONTEXT_MENUS)
private:
#if USE(CROSS_PLATFORM_CONTEXT_MENUS)
String m_title;
bool m_enabled;
bool m_checked;
ContextMenuAction m_action;
ContextMenuItemType m_type;
Vector<ContextMenuItem> m_subMenuItems;
#else
#if PLATFORM(MAC)
RetainPtr<NSMenuItem> m_platformDescription;
#else
PlatformMenuItemDescription m_platformDescription;
#endif
#endif // USE(CROSS_PLATFORM_CONTEXT_MENUS)
};
}
#endif // ContextMenuItem_h