2 * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 #ifndef ContextMenuItem_h
27 #define ContextMenuItem_h
29 #include "PlatformMenuDescription.h"
30 #include "PlatformString.h"
31 #include <wtf/OwnPtr.h>
34 #include <wtf/RetainPtr.h>
42 typedef struct tagMENUITEMINFOW
* LPMENUITEMINFO
;
44 typedef struct _GtkMenuItem GtkMenuItem
;
55 // This enum needs to be in sync with the WebMenuItemTag enum in WebUIDelegate.h and the
56 // extra values in WebUIDelegatePrivate.h
57 enum ContextMenuAction
{
58 ContextMenuItemTagNoAction
=0, // This item is not actually in WebUIDelegate.h
59 ContextMenuItemTagOpenLinkInNewWindow
=1,
60 ContextMenuItemTagDownloadLinkToDisk
,
61 ContextMenuItemTagCopyLinkToClipboard
,
62 ContextMenuItemTagOpenImageInNewWindow
,
63 ContextMenuItemTagDownloadImageToDisk
,
64 ContextMenuItemTagCopyImageToClipboard
,
65 ContextMenuItemTagOpenFrameInNewWindow
,
66 ContextMenuItemTagCopy
,
67 ContextMenuItemTagGoBack
,
68 ContextMenuItemTagGoForward
,
69 ContextMenuItemTagStop
,
70 ContextMenuItemTagReload
,
71 ContextMenuItemTagCut
,
72 ContextMenuItemTagPaste
,
74 ContextMenuItemTagDelete
,
75 ContextMenuItemTagSelectAll
,
76 ContextMenuItemTagInputMethods
,
77 ContextMenuItemTagUnicode
,
79 ContextMenuItemTagSpellingGuess
,
80 ContextMenuItemTagNoGuessesFound
,
81 ContextMenuItemTagIgnoreSpelling
,
82 ContextMenuItemTagLearnSpelling
,
83 ContextMenuItemTagOther
,
84 ContextMenuItemTagSearchInSpotlight
,
85 ContextMenuItemTagSearchWeb
,
86 ContextMenuItemTagLookUpInDictionary
,
87 ContextMenuItemTagOpenWithDefaultApplication
,
88 ContextMenuItemPDFActualSize
,
89 ContextMenuItemPDFZoomIn
,
90 ContextMenuItemPDFZoomOut
,
91 ContextMenuItemPDFAutoSize
,
92 ContextMenuItemPDFSinglePage
,
93 ContextMenuItemPDFFacingPages
,
94 ContextMenuItemPDFContinuous
,
95 ContextMenuItemPDFNextPage
,
96 ContextMenuItemPDFPreviousPage
,
97 // These are new tags! Not a part of API!!!!
98 ContextMenuItemTagOpenLink
= 2000,
99 ContextMenuItemTagIgnoreGrammar
,
100 ContextMenuItemTagSpellingMenu
, // Spelling or Spelling/Grammar sub-menu
101 ContextMenuItemTagShowSpellingPanel
,
102 ContextMenuItemTagCheckSpelling
,
103 ContextMenuItemTagCheckSpellingWhileTyping
,
104 ContextMenuItemTagCheckGrammarWithSpelling
,
105 ContextMenuItemTagFontMenu
, // Font sub-menu
106 ContextMenuItemTagShowFonts
,
107 ContextMenuItemTagBold
,
108 ContextMenuItemTagItalic
,
109 ContextMenuItemTagUnderline
,
110 ContextMenuItemTagOutline
,
111 ContextMenuItemTagStyles
,
112 ContextMenuItemTagShowColors
,
113 ContextMenuItemTagSpeechMenu
, // Speech sub-menu
114 ContextMenuItemTagStartSpeaking
,
115 ContextMenuItemTagStopSpeaking
,
116 ContextMenuItemTagWritingDirectionMenu
, // Writing Direction sub-menu
117 ContextMenuItemTagDefaultDirection
,
118 ContextMenuItemTagLeftToRight
,
119 ContextMenuItemTagRightToLeft
,
120 ContextMenuItemTagPDFSinglePageScrolling
,
121 ContextMenuItemTagPDFFacingPagesScrolling
,
122 ContextMenuItemTagInspectElement
,
123 ContextMenuItemTagTextDirectionMenu
, // Text Direction sub-menu
124 ContextMenuItemTagTextDirectionDefault
,
125 ContextMenuItemTagTextDirectionLeftToRight
,
126 ContextMenuItemTagTextDirectionRightToLeft
,
127 ContextMenuItemBaseApplicationTag
= 10000
130 enum ContextMenuItemType
{
138 typedef void* PlatformMenuItemDescription
;
140 typedef LPMENUITEMINFO PlatformMenuItemDescription
;
142 struct PlatformMenuItemDescription
{
143 PlatformMenuItemDescription()
145 action(ContextMenuItemTagNoAction
),
150 ContextMenuItemType type
;
151 ContextMenuAction action
;
153 QList
<ContextMenuItem
> subMenuItems
;
158 struct PlatformMenuItemDescription
{
159 PlatformMenuItemDescription()
161 , action(ContextMenuItemTagNoAction
)
167 ContextMenuItemType type
;
168 ContextMenuAction action
;
175 struct PlatformMenuItemDescription
{
176 PlatformMenuItemDescription()
178 action(ContextMenuItemTagNoAction
),
183 ContextMenuItemType type
;
184 ContextMenuAction action
;
191 typedef void* PlatformMenuItemDescription
;
194 class ContextMenuItem
{
196 ContextMenuItem(PlatformMenuItemDescription
);
197 ContextMenuItem(ContextMenu
* subMenu
= 0);
198 ContextMenuItem(ContextMenuItemType type
, ContextMenuAction action
, const String
& title
, ContextMenu
* subMenu
= 0);
200 ContextMenuItem(GtkMenuItem
*);
204 PlatformMenuItemDescription
releasePlatformDescription();
206 ContextMenuItemType
type() const;
207 void setType(ContextMenuItemType
);
209 ContextMenuAction
action() const;
210 void setAction(ContextMenuAction
);
212 String
title() const;
213 void setTitle(const String
&);
215 PlatformMenuDescription
platformSubMenu() const;
216 void setSubMenu(ContextMenu
*);
218 void setChecked(bool = true);
220 void setEnabled(bool = true);
221 bool enabled() const;
223 // FIXME: Do we need a keyboard accelerator here?
225 static GtkMenuItem
* createNativeMenuItem(const PlatformMenuItemDescription
&);
230 RetainPtr
<NSMenuItem
> m_platformDescription
;
232 PlatformMenuItemDescription m_platformDescription
;
238 #endif // ContextMenuItem_h