Changeset 39416 in webkit


Ignore:
Timestamp:
Dec 19, 2008 4:28:32 PM (15 years ago)
Author:
kevino@webkit.org
Message:

Reviewed by Kevin Ollivier.

Add Context Menu support to wx bindings.

https://bugs.webkit.org/show_bug.cgi?id=22675

Location:
trunk
Files:
2 added
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r39414 r39416  
     12008-12-19  miggilin  <mr.diggilin@gmail.com>
     2
     3        Reviewed by Kevin Ollivier.
     4
     5        Add Context Menu support to wx bindings.
     6       
     7        https://bugs.webkit.org/show_bug.cgi?id=22675
     8
     9        * platform/ContextMenu.h:
     10        * platform/ContextMenuItem.h:
     11        (WebCore::PlatformMenuItemDescription::PlatformMenuItemDescription):
     12        * platform/wx/ContextMenuItemWx.cpp: Added.
     13        * platform/wx/ContextMenuWx.cpp: Added.
     14        * platform/wx/LocalizedStringsWx.cpp:
     15        * platform/wx/TemporaryLinkStubs.cpp:
     16        * webcore-wx.bkl:
     17
     18
    1192008-12-19  Beth Dakin  <bdakin@apple.com>
    220
  • trunk/WebCore/platform/ContextMenu.h

    r27644 r39416  
    7070
    7171        PlatformMenuDescription releasePlatformDescription();
    72 
     72#if PLATFORM(WX)
     73        static ContextMenuItem* itemWithId(int);
     74#endif
    7375    private:
    7476        HitTestResult m_hitTestResult;
    75 
    7677#if PLATFORM(MAC)
    7778        // Keep this in sync with the PlatformMenuDescription typedef
  • trunk/WebCore/platform/ContextMenuItem.h

    r38591 r39416  
    173173    };
    174174#elif PLATFORM(WX)
    175     typedef wxMenuItem* PlatformMenuItemDescription;
     175    struct PlatformMenuItemDescription {
     176        PlatformMenuItemDescription()
     177            : type(ActionType),
     178              action(ContextMenuItemTagNoAction),
     179              checked(false),
     180              enabled(true)
     181        {}
     182
     183        ContextMenuItemType type;
     184        ContextMenuAction action;
     185        String title;
     186        wxMenu * subMenu;
     187        bool checked;
     188        bool enabled;
     189    };
    176190#else
    177191    typedef void* PlatformMenuItemDescription;
  • trunk/WebCore/platform/wx/LocalizedStringsWx.cpp

    r38415 r39416  
    6969String contextMenuItemTagOpenLinkInNewWindow()
    7070{
    71     return String();
     71    return String("Open Link in New Window");
    7272}
    7373
    7474String contextMenuItemTagDownloadLinkToDisk()
    7575{
    76     return String();
     76    return String("Download Link to Disk");
    7777}
    7878
    7979String contextMenuItemTagCopyLinkToClipboard()
    8080{
    81     return String();
     81    return String("Copy Link to Clipboard");
    8282}
    8383
    8484String contextMenuItemTagOpenImageInNewWindow()
    8585{
    86     return String();
     86    return String("Open Image in New Window");
    8787}
    8888
    8989String contextMenuItemTagDownloadImageToDisk()
    9090{
    91     return String();
     91    return String("Download Image to Disk");
    9292}
    9393
    9494String contextMenuItemTagCopyImageToClipboard()
    9595{
    96     return String();
     96    return String("Copy Image to Clipboard");
    9797}
    9898
    9999String contextMenuItemTagOpenFrameInNewWindow()
    100100{
    101     return String();
     101    return String("Open Frame in New Window");
    102102}
    103103
    104104String contextMenuItemTagCopy()
    105105{
    106     return String();
     106    return String("Copy");
    107107}
    108108
    109109String contextMenuItemTagGoBack()
    110110{
    111     return String();
     111    return String("Go Back");
    112112}
    113113
    114114String contextMenuItemTagGoForward()
    115115{
    116     return String();
     116    return String("Go Forward");
    117117}
    118118
    119119String contextMenuItemTagStop()
    120120{
    121     return String();
     121    return String("Stop");
    122122}
    123123
    124124String contextMenuItemTagReload()
    125125{
    126     return String();
     126    return String("Reload");
    127127}
    128128
    129129String contextMenuItemTagCut()
    130130{
    131     return String();
     131    return String("Cut");
    132132}
    133133
    134134String contextMenuItemTagPaste()
    135135{
    136     return String();
     136    return String("Paste");
    137137}
    138138
    139139String contextMenuItemTagNoGuessesFound()
    140140{
    141     return String();
     141    return String("No Guesses Found");
    142142}
    143143
    144144String contextMenuItemTagIgnoreSpelling()
    145145{
    146     return String();
     146    return String("Ignore Spelling");
    147147}
    148148
    149149String contextMenuItemTagLearnSpelling()
    150150{
    151     return String();
     151    return String("Learn Spelling");
    152152}
    153153
    154154String contextMenuItemTagSearchWeb()
    155155{
    156     return String();
     156    return String("Search Web");
    157157}
    158158
    159159String contextMenuItemTagLookUpInDictionary()
    160160{
    161     return String();
     161    return String("Look Up in Dictionary");
    162162}
    163163
    164164String contextMenuItemTagOpenLink()
    165165{
    166     return String();
     166    return String("Open Link");
    167167}
    168168
    169169String contextMenuItemTagIgnoreGrammar()
    170170{
    171     return String();
     171    return String("Ignore Grammar");
    172172}
    173173
    174174String contextMenuItemTagSpellingMenu()
    175175{
    176     return String();
     176    return String("Spelling");
    177177}
    178178
    179179String contextMenuItemTagShowSpellingPanel(bool show)
    180180{
    181     return String();
     181    return String("Show Spelling Panel");
    182182}
    183183
    184184String contextMenuItemTagCheckSpelling()
    185185{
    186     return String();
     186    return String("Check Spelling");
    187187}
    188188
    189189String contextMenuItemTagCheckSpellingWhileTyping()
    190190{
    191     return String();
     191    return String("Check Spelling While Typing");
    192192}
    193193
    194194String contextMenuItemTagCheckGrammarWithSpelling()
    195195{
    196     return String();
     196    return String("Check Grammar with Spelling");
    197197}
    198198
    199199String contextMenuItemTagFontMenu()
    200200{
    201     return String();
     201    return String("Font");
    202202}
    203203
    204204String contextMenuItemTagBold()
    205205{
    206     return String();
     206    return String("Bold");
    207207}
    208208
    209209String contextMenuItemTagItalic()
    210210{
    211     return String();
     211    return String("Italic");
    212212}
    213213
    214214String contextMenuItemTagUnderline()
    215215{
    216     return String();
     216    return String("Underline");
    217217}
    218218
    219219String contextMenuItemTagOutline()
    220220{
    221     return String();
     221    return String("Outline");
    222222}
    223223
    224224String contextMenuItemTagWritingDirectionMenu()
    225225{
    226     return String();
     226    return String("Writing Direction");
    227227}
    228228
    229229String contextMenuItemTagTextDirectionMenu()
    230230{
    231     return String();
     231    return String("Text Direction");
    232232}
    233233
    234234String contextMenuItemTagDefaultDirection()
    235235{
    236     return String();
     236    return String("Default Direction");
    237237}
    238238
    239239String contextMenuItemTagLeftToRight()
    240240{
    241     return String();
     241    return String("Left to Right");
    242242}
    243243
    244244String contextMenuItemTagRightToLeft()
    245245{
    246     return String();
     246    return String("Right to Left");
    247247}
    248248
  • trunk/WebCore/platform/wx/TemporaryLinkStubs.cpp

    r38057 r39416  
    137137void Icon::paint(GraphicsContext*, const IntRect&) { notImplemented(); }
    138138
    139 ContextMenu::ContextMenu(const HitTestResult& result) : m_hitTestResult(result) { notImplemented(); }
    140 ContextMenu::~ContextMenu() { notImplemented(); }
    141 void ContextMenu::appendItem(ContextMenuItem&) { notImplemented(); }
    142 void ContextMenu::setPlatformDescription(PlatformMenuDescription) { notImplemented(); }
    143 
    144 ContextMenuItem::ContextMenuItem(PlatformMenuItemDescription) { notImplemented(); }
    145 ContextMenuItem::ContextMenuItem(ContextMenu*) { notImplemented(); }
    146 ContextMenuItem::ContextMenuItem(ContextMenuItemType type, ContextMenuAction action, const String& title, ContextMenu* subMenu) { notImplemented(); }
    147 ContextMenuItem::~ContextMenuItem() { notImplemented(); }
    148 PlatformMenuItemDescription ContextMenuItem::releasePlatformDescription() { notImplemented(); return m_platformDescription; }
    149 ContextMenuItemType ContextMenuItem::type() const { notImplemented(); return ActionType; }
    150 void ContextMenuItem::setType(ContextMenuItemType) { notImplemented(); }
    151 ContextMenuAction ContextMenuItem::action() const { notImplemented(); return ContextMenuItemTagNoAction; }
    152 void ContextMenuItem::setAction(ContextMenuAction) { notImplemented(); }
    153 String ContextMenuItem::title() const { notImplemented(); return String(); }
    154 void ContextMenuItem::setTitle(const String&) { notImplemented(); }
    155 //PlatformMenuDescription ContextMenuItem::platformSubMenu() const { notImplemented(); return 0; }
    156 void ContextMenuItem::setSubMenu(ContextMenu*) { notImplemented(); }
    157 void ContextMenuItem::setChecked(bool) { notImplemented(); }
    158 void ContextMenuItem::setEnabled(bool) { notImplemented(); }
    159 
    160139void Editor::showColorPanel() { notImplemented(); }
    161140void Editor::showFontPanel() { notImplemented(); }
  • trunk/WebCore/webcore-wx.bkl

    r38766 r39416  
    9292            platform/wx/SystemTimeWx.cpp
    9393            platform/wx/WidgetWx.cpp
     94            platform/wx/ContextMenuWx.cpp
     95            platform/wx/ContextMenuItemWx.cpp
    9496           
    9597            <!-- files from other ports we currently rely on -->
  • trunk/WebKit/wx/ChangeLog

    r39409 r39416  
     12008-12-19  miggilin  <mr.diggilin@gmail.com>
     2
     3        Reviewed by Kevin Ollivier.
     4
     5        Add Context Menu support to wx bindings.
     6       
     7        https://bugs.webkit.org/show_bug.cgi?id=22675
     8
     9        * WebKitSupport/ContextMenuClientWx.cpp:
     10        (WebCore::ContextMenuClientWx::contextMenuDestroyed):
     11        (WebCore::ContextMenuClientWx::getCustomMenuFromDefaultItems):
     12        * WebView.cpp:
     13        (wxWebView::OnMouseEvents):
     14        (wxWebView::OnContextMenuEvents):
     15        (wxWebView::OnMenuSelectEvents):
     16        * WebView.h:
     17
     18
    1192008-12-19  Kevin Ollivier  <kevino@theolliviers.com>
    220
  • trunk/WebKit/wx/WebKitSupport/ContextMenuClientWx.cpp

    r29663 r39416  
    2929#include "ContextMenuClientWx.h"
    3030#include "NotImplemented.h"
     31#include "ContextMenu.h"
    3132#include <stdio.h>
    3233
     
    3940void ContextMenuClientWx::contextMenuDestroyed()
    4041{
    41     notImplemented();
     42    delete this;
    4243}
    4344
    44 PlatformMenuDescription ContextMenuClientWx::getCustomMenuFromDefaultItems(ContextMenu*)
     45PlatformMenuDescription ContextMenuClientWx::getCustomMenuFromDefaultItems(ContextMenu* menu)
    4546{
    46     notImplemented();
    47     return 0;
     47    return menu->releasePlatformDescription();
    4848}
    4949
  • trunk/WebKit/wx/WebView.cpp

    r39273 r39416  
    3838#include "markup.h"
    3939#include "Page.h"
     40#include "ContextMenu.h"
     41#include "ContextMenuItem.h"
     42#include "ContextMenuController.h"
    4043#include "PlatformKeyboardEvent.h"
    4144#include "PlatformMouseEvent.h"
     
    173176    EVT_SIZE(wxWebView::OnSize)
    174177    EVT_MOUSE_EVENTS(wxWebView::OnMouseEvents)
     178    EVT_CONTEXT_MENU(wxWebView::OnContextMenuEvents)
     179    EVT_MENU(wxID_ANY, wxWebView::OnMenuSelectEvents)
    175180    EVT_KEY_DOWN(wxWebView::OnKeyEvents)
    176181    EVT_KEY_UP(wxWebView::OnKeyEvents)
     
    516521    else if (type == wxEVT_MOTION)
    517522        frame->eventHandler()->mouseMoved(wkEvent);
     523}
     524
     525void wxWebView::OnContextMenuEvents(wxContextMenuEvent& event)
     526{
     527    m_impl->page->contextMenuController()->clearContextMenu();
     528    wxPoint localEventPoint = ScreenToClient(event.GetPosition());
     529
     530    if (!m_mainFrame)
     531        return;
     532       
     533    WebCore::Frame* focusedFrame = m_mainFrame->GetFrame();
     534    if (!focusedFrame->view())
     535        return;
     536
     537    //Create WebCore mouse event from the wxContextMenuEvent
     538    wxMouseEvent mouseEvent(wxEVT_RIGHT_DOWN);
     539    mouseEvent.m_x = localEventPoint.x;
     540    mouseEvent.m_y = localEventPoint.y;
     541    WebCore::PlatformMouseEvent wkEvent(mouseEvent, event.GetPosition());
     542
     543    bool handledEvent = focusedFrame->eventHandler()->sendContextMenuEvent(wkEvent);
     544    if (!handledEvent)
     545        return;
     546
     547    WebCore::ContextMenu* coreMenu = m_impl->page->contextMenuController()->contextMenu();
     548    if (!coreMenu)
     549        return;
     550
     551    WebCore::PlatformMenuDescription menuWx = coreMenu->platformDescription();
     552    if (!menuWx)
     553        return;
     554
     555    PopupMenu(menuWx, localEventPoint);
     556}
     557
     558void wxWebView::OnMenuSelectEvents(wxCommandEvent& event)
     559{
     560    WebCore::ContextMenuItem* item = WebCore::ContextMenu::itemWithId (event.GetId());
     561    if (!item)
     562        return;
     563
     564    m_impl->page->contextMenuController()->contextMenuItemSelected(item);
     565    delete item;
    518566}
    519567
  • trunk/WebKit/wx/WebView.h

    r39273 r39416  
    150150    void OnSize(wxSizeEvent& event);
    151151    void OnMouseEvents(wxMouseEvent& event);
     152    void OnContextMenuEvents(wxContextMenuEvent& event);
     153    void OnMenuSelectEvents(wxCommandEvent& event);
    152154    void OnKeyEvents(wxKeyEvent& event);
    153155    void OnSetFocus(wxFocusEvent& event);
Note: See TracChangeset for help on using the changeset viewer.