~ubuntu-branches/ubuntu/precise/kompozer/precise

« back to all changes in this revision

Viewing changes to mozilla/embedding/browser/powerplant/source/CWebBrowserCMAttachment.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Anthony Yarusso
  • Date: 2007-08-27 01:11:03 UTC
  • Revision ID: james.westby@ubuntu.com-20070827011103-2jgf4s6532gqu2ka
Tags: upstream-0.7.10
ImportĀ upstreamĀ versionĀ 0.7.10

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
 
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/
 
7
 * 
 
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.
 
12
 * 
 
13
 * The Original Code is the Mozilla browser.
 
14
 * 
 
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.
 
18
 * 
 
19
 * Contributor(s):
 
20
 *   Conrad Carlen <ccarlen@netscape.com>
 
21
 */
 
22
 
 
23
#include "CWebBrowserCMAttachment.h"
 
24
 
 
25
 
 
26
//*****************************************************************************
 
27
//  CWebBrowserChrome
 
28
//
 
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.
 
34
//
 
35
//*****************************************************************************
 
36
 
 
37
CWebBrowserCMAttachment::CWebBrowserCMAttachment()
 
38
{
 
39
}
 
40
 
 
41
CWebBrowserCMAttachment::CWebBrowserCMAttachment(LCommander*    inTarget,
 
42
                                                     PaneIDT            inTargetPaneID)
 
43
        : LCMAttachment(inTarget, inTargetPaneID)
 
44
{
 
45
}
 
46
 
 
47
CWebBrowserCMAttachment::CWebBrowserCMAttachment(LStream*       inStream)
 
48
        : LCMAttachment(inStream)
 
49
{
 
50
}
 
51
 
 
52
CWebBrowserCMAttachment::~CWebBrowserCMAttachment()
 
53
{
 
54
}
 
55
 
 
56
 
 
57
void CWebBrowserCMAttachment::ExecuteSelf(MessageT      inMessage,
 
58
                                              void*             ioParam)
 
59
{
 
60
        SetExecuteHost(true);
 
61
        
 
62
                // Ensure the CMM is installed and initialized. If not, just
 
63
                // return quietly.
 
64
        if (not mCMMInitialized) {
 
65
                return;
 
66
        }
 
67
 
 
68
                // Dispatch to the various messages we handle.
 
69
                
 
70
        if (inMessage == msg_AdjustCursor) {
 
71
        
 
72
                        // Only display the cursor if the control key is depressed
 
73
                if (((static_cast<EventRecord*>(ioParam))->modifiers & controlKey) != 0) {
 
74
                
 
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);
 
79
                }
 
80
                
 
81
        } else if (inMessage == msg_Event) {
 
82
        
 
83
        } else if (inMessage == msg_Click) {
 
84
 
 
85
                        // It's a click, but is it a CMM click?
 
86
                if (::IsShowContextualMenuClick(
 
87
                                &(static_cast<SMouseDownEvent*>(ioParam))->macEvent)) {
 
88
 
 
89
                        // It is; let's handle it. However, first we must switch the
 
90
                        // target to our object, and update the port.
 
91
                        
 
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();
 
97
                                }
 
98
                        }
 
99
                }
 
100
        }
 
101
}
 
102
 
 
103
 
 
104
void CWebBrowserCMAttachment::SetCommandList(SInt16 mcmdResID)
 
105
{
 
106
    Handle mcmdRes = ::GetResource(ResType_MenuCommands, mcmdResID);
 
107
    ThrowIfResFail_(mcmdRes);
 
108
    ::DetachResource(mcmdRes);  // LHandleStream takes ownership and uses DisposeHandle()
 
109
    LHandleStream inStream(mcmdRes);
 
110
    
 
111
    mCommandList.RemoveItemsAt(mCommandList.GetCount(), LArray::index_First);
 
112
    
 
113
        UInt16 numCommands;
 
114
        inStream >> numCommands;
 
115
        
 
116
        for (SInt16 i = 1; i <= numCommands; i++) {
 
117
                CommandT theCommand;
 
118
                inStream >> theCommand;
 
119
                mCommandList.AddItem(theCommand);
 
120
        }
 
121
}
 
122
 
 
123
 
 
124
void CWebBrowserCMAttachment::DoContextMenuClick(const EventRecord&     inMacEvent)
 
125
{
 
126
    DoCMMClick(inMacEvent);
 
127
}
 
128