#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* LPMENUITEMINFO;
#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,
ContextMenuItemTagOpenFrameInNewWindow,
ContextMenuItemTagCopy,
ContextMenuItemTagGoBack,
ContextMenuItemTagGoForward,
ContextMenuItemTagStop,
ContextMenuItemTagReload,
ContextMenuItemTagCut,
ContextMenuItemTagPaste,
#if PLATFORM(GTK)
ContextMenuItemTagDelete,
ContextMenuItemTagSelectAll,
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
ContextMenuItemBaseCustomTag = 5000,
ContextMenuItemBaseApplicationTag = 10000
};
enum ContextMenuItemType {
ActionType,
CheckableActionType,
SeparatorType,
SubmenuType
};
#if PLATFORM(MAC)
typedef NSMenuItem* PlatformMenuItemDescription;
#elif PLATFORM(WIN)
typedef LPMENUITEMINFO 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)
struct PlatformMenuItemDescription {
PlatformMenuItemDescription()
: type(ActionType)
, action(ContextMenuItemTagNoAction)
, subMenu(0)
, checked(false)
, enabled(true)
{}
ContextMenuItemType type;
ContextMenuAction action;
String title;
GtkMenu* subMenu;
bool checked;
bool enabled;
};
#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 : public FastAllocBase {
public:
ContextMenuItem(PlatformMenuItemDescription);
ContextMenuItem(ContextMenu* subMenu = 0);
ContextMenuItem(ContextMenuItemType type, ContextMenuAction action, const String& title, ContextMenu* subMenu = 0);
#if PLATFORM(GTK)
ContextMenuItem(GtkMenuItem*);
#endif
~ContextMenuItem();
PlatformMenuItemDescription releasePlatformDescription();
ContextMenuItemType type() const;
void setType(ContextMenuItemType);
ContextMenuAction action() const;
void setAction(ContextMenuAction);
String title() const;
void setTitle(const String&);
PlatformMenuDescription platformSubMenu() const;
void setSubMenu(ContextMenu*);
void setChecked(bool = true);
bool checked() const;
void setEnabled(bool = true);
bool enabled() const;
#if PLATFORM(GTK)
static GtkMenuItem* createNativeMenuItem(const PlatformMenuItemDescription&);
#endif
private:
#if PLATFORM(MAC)
RetainPtr<NSMenuItem> m_platformDescription;
#else
PlatformMenuItemDescription m_platformDescription;
#endif
};
}
#endif // ContextMenuItem_h