pleyo.com

/src/trunk2/BAL/Interfaces/ContextMenuItem.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2006 Apple Computer, Inc.  All rights reserved.
00003  * Copyright (C) 2007 Pleyo.  All rights reserved.
00004  * 
00005  * Redistribution and use in source and binary forms, with or without
00006  * modification, are permitted provided that the following conditions
00007  * are met:
00008  * 1. Redistributions of source code must retain the above copyright
00009  *    notice, this list of conditions and the following disclaimer.
00010  * 2. Redistributions in binary form must reproduce the above copyright
00011  *    notice, this list of conditions and the following disclaimer in the
00012  *    documentation and/or other materials provided with the distribution.
00013  *
00014  * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
00015  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00016  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00017  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
00018  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00019  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00020  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00021  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
00022  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00023  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00024  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
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     // This enum needs to be in sync with the WebMenuItemTag enum in WebUIDelegate.h and the
00057     // extra values in WebUIDelegatePrivate.h
00058     enum ContextMenuAction {
00059         ContextMenuItemTagNoAction=0, // This item is not actually in WebUIDelegate.h
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         // These are new tags! Not a part of API!!!!
00093         ContextMenuItemTagOpenLink = 2000,
00094         ContextMenuItemTagIgnoreGrammar,
00095         ContextMenuItemTagSpellingMenu, // Spelling or Spelling/Grammar sub-menu
00096         ContextMenuItemTagShowSpellingPanel,
00097         ContextMenuItemTagCheckSpelling,
00098         ContextMenuItemTagCheckSpellingWhileTyping,
00099         ContextMenuItemTagCheckGrammarWithSpelling,
00100         ContextMenuItemTagFontMenu, // Font sub-menu
00101         ContextMenuItemTagShowFonts,
00102         ContextMenuItemTagBold,
00103         ContextMenuItemTagItalic,
00104         ContextMenuItemTagUnderline,
00105         ContextMenuItemTagOutline,
00106         ContextMenuItemTagStyles,
00107         ContextMenuItemTagShowColors,
00108         ContextMenuItemTagSpeechMenu, // Speech sub-menu
00109         ContextMenuItemTagStartSpeaking,
00110         ContextMenuItemTagStopSpeaking,
00111         ContextMenuItemTagWritingDirectionMenu, // Writing Direction sub-menu
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         // FIXME: Do we need a keyboard accelerator here?
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

Generated on Wed Nov 21 20:04:16 2007 for Origyn Web Browser by Doxygen 1.5.3

pleyo.com
pleyo.com