1
/* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
3
* The contents of this file are subject to the Mozilla Public
4
* License Version 1.1 (the "License"); you may not use this file
5
* except in compliance with the License. You may obtain a copy of
6
* the License at http://www.mozilla.org/MPL/
8
* Software distributed under the License is distributed on an "AS
9
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
10
* implied. See the License for the specific language governing
11
* rights and limitations under the License.
13
* The Original Code is the Mozilla browser.
15
* The Initial Developer of the Original Code is Netscape
16
* Communications, Inc. Portions created by Netscape are
17
* Copyright (C) 1999, Mozilla. All Rights Reserved.
20
* Conrad Carlen <ccarlen@netscape.com>
23
#include "CWebBrowserCMAttachment.h"
26
//*****************************************************************************
29
// This override is needed because LCMAttachment intercepts mouse clicks, tracks
30
// the click, and handles it if the click is on a context menu. We don't want so
31
// complete a solution. In our case, mozilla handles the click, determines that
32
// it's a context menu click and then calls nsIContextMenuListener::OnShowContextMenu.
33
// This override allows DoContextMenuClick to be called after the click.
35
//*****************************************************************************
37
CWebBrowserCMAttachment::CWebBrowserCMAttachment()
41
CWebBrowserCMAttachment::CWebBrowserCMAttachment(LCommander* inTarget,
42
PaneIDT inTargetPaneID)
43
: LCMAttachment(inTarget, inTargetPaneID)
47
CWebBrowserCMAttachment::CWebBrowserCMAttachment(LStream* inStream)
48
: LCMAttachment(inStream)
52
CWebBrowserCMAttachment::~CWebBrowserCMAttachment()
57
void CWebBrowserCMAttachment::ExecuteSelf(MessageT inMessage,
62
// Ensure the CMM is installed and initialized. If not, just
64
if (not mCMMInitialized) {
68
// Dispatch to the various messages we handle.
70
if (inMessage == msg_AdjustCursor) {
72
// Only display the cursor if the control key is depressed
73
if (((static_cast<EventRecord*>(ioParam))->modifiers & controlKey) != 0) {
75
//+++ This needs to be updated to use kThemeContextualMenuArrowCursor,
76
//+++ but UCursor needs to be updated to be Theme-savvy first.
77
UCursor::SetTheCursor(mCMMCursorID);
78
SetExecuteHost(false);
81
} else if (inMessage == msg_Event) {
83
} else if (inMessage == msg_Click) {
85
// It's a click, but is it a CMM click?
86
if (::IsShowContextualMenuClick(
87
&(static_cast<SMouseDownEvent*>(ioParam))->macEvent)) {
89
// It is; let's handle it. However, first we must switch the
90
// target to our object, and update the port.
92
LCommander* target = FindCommandTarget();
93
if ((target != nil) && LCommander::SwitchTarget(target)) {
94
LPane* ownerAsPane = dynamic_cast<LPane*>(mOwnerHost);
95
if (ownerAsPane != nil) {
96
ownerAsPane->UpdatePort();
104
void CWebBrowserCMAttachment::SetCommandList(SInt16 mcmdResID)
106
Handle mcmdRes = ::GetResource(ResType_MenuCommands, mcmdResID);
107
ThrowIfResFail_(mcmdRes);
108
::DetachResource(mcmdRes); // LHandleStream takes ownership and uses DisposeHandle()
109
LHandleStream inStream(mcmdRes);
111
mCommandList.RemoveItemsAt(mCommandList.GetCount(), LArray::index_First);
114
inStream >> numCommands;
116
for (SInt16 i = 1; i <= numCommands; i++) {
118
inStream >> theCommand;
119
mCommandList.AddItem(theCommand);
124
void CWebBrowserCMAttachment::DoContextMenuClick(const EventRecord& inMacEvent)
126
DoCMMClick(inMacEvent);