00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifndef ContextMenuItem_h
00028 #define ContextMenuItem_h
00029
00030 #include "PlatformMenuDescription.h"
00031 #include "PlatformString.h"
00032 #include <wtf/OwnPtr.h>
00033
00034 #if PLATFORM(MAC)
00035 #include <wtf/RetainPtr.h>
00036
00037 #ifdef __OBJC__
00038 @class NSMenuItem;
00039 #else
00040 class NSMenuItem;
00041 #endif
00042 #elif PLATFORM(WIN)
00043 typedef struct tagMENUITEMINFOW* LPMENUITEMINFO;
00044 #elif PLATFORM(GTK)
00045 typedef struct _GtkMenuItem GtkMenuItem;
00046 #elif PLATFORM(QT)
00047 #include <QAction>
00048 #elif defined __OWB__
00049 typedef void* PlatformMenuItemDescription;
00050 #endif
00051
00052 namespace WebCore {
00053
00054 class ContextMenu;
00055
00056
00057
00058 enum ContextMenuAction {
00059 ContextMenuItemTagNoAction=0,
00060 ContextMenuItemTagOpenLinkInNewWindow=1,
00061 ContextMenuItemTagDownloadLinkToDisk,
00062 ContextMenuItemTagCopyLinkToClipboard,
00063 ContextMenuItemTagOpenImageInNewWindow,
00064 ContextMenuItemTagDownloadImageToDisk,
00065 ContextMenuItemTagCopyImageToClipboard,
00066 ContextMenuItemTagOpenFrameInNewWindow,
00067 ContextMenuItemTagCopy,
00068 ContextMenuItemTagGoBack,
00069 ContextMenuItemTagGoForward,
00070 ContextMenuItemTagStop,
00071 ContextMenuItemTagReload,
00072 ContextMenuItemTagCut,
00073 ContextMenuItemTagPaste,
00074 ContextMenuItemTagSpellingGuess,
00075 ContextMenuItemTagNoGuessesFound,
00076 ContextMenuItemTagIgnoreSpelling,
00077 ContextMenuItemTagLearnSpelling,
00078 ContextMenuItemTagOther,
00079 ContextMenuItemTagSearchInSpotlight,
00080 ContextMenuItemTagSearchWeb,
00081 ContextMenuItemTagLookUpInDictionary,
00082 ContextMenuItemTagOpenWithDefaultApplication,
00083 ContextMenuItemPDFActualSize,
00084 ContextMenuItemPDFZoomIn,
00085 ContextMenuItemPDFZoomOut,
00086 ContextMenuItemPDFAutoSize,
00087 ContextMenuItemPDFSinglePage,
00088 ContextMenuItemPDFFacingPages,
00089 ContextMenuItemPDFContinuous,
00090 ContextMenuItemPDFNextPage,
00091 ContextMenuItemPDFPreviousPage,
00092
00093 ContextMenuItemTagOpenLink = 2000,
00094 ContextMenuItemTagIgnoreGrammar,
00095 ContextMenuItemTagSpellingMenu,
00096 ContextMenuItemTagShowSpellingPanel,
00097 ContextMenuItemTagCheckSpelling,
00098 ContextMenuItemTagCheckSpellingWhileTyping,
00099 ContextMenuItemTagCheckGrammarWithSpelling,
00100 ContextMenuItemTagFontMenu,
00101 ContextMenuItemTagShowFonts,
00102 ContextMenuItemTagBold,
00103 ContextMenuItemTagItalic,
00104 ContextMenuItemTagUnderline,
00105 ContextMenuItemTagOutline,
00106 ContextMenuItemTagStyles,
00107 ContextMenuItemTagShowColors,
00108 ContextMenuItemTagSpeechMenu,
00109 ContextMenuItemTagStartSpeaking,
00110 ContextMenuItemTagStopSpeaking,
00111 ContextMenuItemTagWritingDirectionMenu,
00112 ContextMenuItemTagDefaultDirection,
00113 ContextMenuItemTagLeftToRight,
00114 ContextMenuItemTagRightToLeft,
00115 ContextMenuItemTagPDFSinglePageScrolling,
00116 ContextMenuItemTagPDFFacingPagesScrolling,
00117 ContextMenuItemTagInspectElement,
00118 ContextMenuItemBaseApplicationTag = 10000
00119 };
00120
00121 enum ContextMenuItemType {
00122 ActionType,
00123 SeparatorType,
00124 SubmenuType
00125 };
00126
00127 #if PLATFORM(MAC)
00128 typedef NSMenuItem* PlatformMenuItemDescription;
00129 #elif PLATFORM(WIN)
00130 typedef LPMENUITEMINFO PlatformMenuItemDescription;
00131 #elif PLATFORM(QT)
00132 struct PlatformMenuItemDescriptionType {
00133 PlatformMenuItemDescriptionType() : qaction(0), menu(0), action(ContextMenuItemTagNoAction), type(ActionType), subMenu(0) {}
00134 QAction *qaction;
00135 QMenu *menu;
00136 ContextMenuAction action;
00137 QString title;
00138 ContextMenuItemType type;
00139 PlatformMenuDescription subMenu;
00140 };
00141 typedef PlatformMenuItemDescriptionType* PlatformMenuItemDescription;
00142 #elif PLATFORM(GTK)
00143 typedef GtkMenuItem* PlatformMenuItemDescription;
00144 #endif
00145
00146 class ContextMenuItem {
00147 public:
00148 ContextMenuItem(PlatformMenuItemDescription);
00149 ContextMenuItem(ContextMenu* subMenu = 0);
00150 ContextMenuItem(ContextMenuItemType type, ContextMenuAction action, const String& title, ContextMenu* subMenu = 0);
00151 ~ContextMenuItem();
00152
00153 PlatformMenuItemDescription releasePlatformDescription();
00154
00155 ContextMenuItemType type() const;
00156 void setType(ContextMenuItemType);
00157
00158 ContextMenuAction action() const;
00159 void setAction(ContextMenuAction);
00160
00161 String title() const;
00162 void setTitle(const String&);
00163
00164 PlatformMenuDescription platformSubMenu() const;
00165 void setSubMenu(ContextMenu*);
00166
00167 void setChecked(bool = true);
00168
00169 void setEnabled(bool = true);
00170 bool enabled() const;
00171
00172
00173
00174 private:
00175 #if PLATFORM(MAC)
00176 RetainPtr<NSMenuItem> m_platformDescription;
00177 #else
00178 PlatformMenuItemDescription m_platformDescription;
00179 #endif
00180 };
00181
00182 }
00183
00184 #endif // ContextMenuItem_h