FreeWRL / FreeX3D 4.3.0
nsPluginNativeWindow.h
1/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2/* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 *
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
9 *
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
13 * License.
14 *
15 * The Original Code is mozilla.org code.
16 *
17 * The Initial Developer of the Original Code is
18 * Netscape Communications Corporation.
19 * Portions created by the Initial Developer are Copyright (C) 1998
20 * the Initial Developer. All Rights Reserved.
21 *
22 * Contributor(s):
23 * Andrei Volkov <av@netscape.com>
24 * Brian Stell <bstell@netscape.com>
25 * Peter Lubczynski <peterl@netscape.com>
26 *
27 * Alternatively, the contents of this file may be used under the terms of
28 * either the GNU General Public License Version 2 or later (the "GPL"), or
29 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
30 * in which case the provisions of the GPL or the LGPL are applicable instead
31 * of those above. If you wish to allow use of your version of this file only
32 * under the terms of either the GPL or the LGPL, and not to allow others to
33 * use your version of this file under the terms of the MPL, indicate your
34 * decision by deleting the provisions above and replace them with the notice
35 * and other provisions required by the GPL or the LGPL. If you do not delete
36 * the provisions above, a recipient may use your version of this file under
37 * the terms of any one of the MPL, the GPL or the LGPL.
38 *
39 * ***** END LICENSE BLOCK ***** */
40
41#ifndef _nsPluginNativeWindow_h_
42#define _nsPluginNativeWindow_h_
43
44#include "nscore.h"
45#include "nsCOMPtr.h"
46#include "nsIPluginInstance.h"
47#include "nsplugindefs.h"
48#include "nsIWidget.h"
49#include "nsTraceRefcnt.h"
50
55{
56public:
58 MOZ_COUNT_CTOR(nsPluginNativeWindow);
59 }
60
61 virtual ~nsPluginNativeWindow() {
62 MOZ_COUNT_DTOR(nsPluginNativeWindow);
63 }
64
75public:
76 nsresult GetPluginInstance(nsCOMPtr<nsIPluginInstance> &aPluginInstance) {
77 aPluginInstance = mPluginInstance;
78 return NS_OK;
79 }
80 nsresult SetPluginInstance(nsIPluginInstance *aPluginInstance) {
81 if (mPluginInstance != aPluginInstance)
82 mPluginInstance = aPluginInstance;
83 return NS_OK;
84 }
85
86 nsresult GetPluginWidget(nsIWidget **aWidget) {
87 NS_IF_ADDREF(*aWidget = mWidget);
88 return NS_OK;
89 }
90 nsresult SetPluginWidget(nsIWidget *aWidget) {
91 mWidget = aWidget;
92 return NS_OK;
93 }
94
95public:
96 virtual nsresult CallSetWindow(nsCOMPtr<nsIPluginInstance> &aPluginInstance) {
97 // null aPluginInstance means that we want to call SetWindow(null)
98 if (aPluginInstance)
99 aPluginInstance->SetWindow(this);
100 else if (mPluginInstance)
101 mPluginInstance->SetWindow(nsnull);
102
103 SetPluginInstance(aPluginInstance);
104 return NS_OK;
105 }
106#if (MOZ_PLATFORM_MAEMO == 5)
107#define MOZ_COMPOSITED_PLUGINS
108#endif
109#ifdef MOZ_COMPOSITED_PLUGINS
110 /* XXX: we use this to leak the socket widget out from nsPlugNativeWindowGtk2
111 so that Renderer::NativeDraw() in nsObjectFrame.cpp can draw the widget.
112 I don't currently know a better way to do this... */
113 void *mPlugWindow;
114#endif
115
116protected:
117 nsCOMPtr<nsIPluginInstance> mPluginInstance;
118 nsCOMPtr<nsIWidget> mWidget;
119};
120
121nsresult PLUG_NewPluginNativeWindow(nsPluginNativeWindow ** aPluginNativeWindow);
122nsresult PLUG_DeletePluginNativeWindow(nsPluginNativeWindow * aPluginNativeWindow);
123
124#endif //_nsPluginNativeWindow_h_
base class for native plugin window implementations
nsresult GetPluginInstance(nsCOMPtr< nsIPluginInstance > &aPluginInstance)
!!! CAUTION !!!