gecko/modules/plugin/sdk/samples/winless/windows/plugin.cpp
Josh Aas b356ec6f5a move npapi sdk up a directory, b=360955 rs=jst
--HG--
rename : modules/plugin/tools/sdk/Makefile.in => modules/plugin/sdk/Makefile.in
rename : modules/plugin/tools/sdk/readme.txt => modules/plugin/sdk/readme.txt
rename : modules/plugin/tools/sdk/samples/Makefile.in => modules/plugin/sdk/samples/Makefile.in
rename : modules/plugin/tools/sdk/samples/basic/mac/Basic Plugin.mcp => modules/plugin/sdk/samples/basic/mac/Basic Plugin.mcp
rename : modules/plugin/tools/sdk/samples/basic/mac/Basic Plugin.xml => modules/plugin/sdk/samples/basic/mac/Basic Plugin.xml
rename : modules/plugin/tools/sdk/samples/basic/mac/Basic.rsrc => modules/plugin/sdk/samples/basic/mac/Basic.rsrc
rename : modules/plugin/tools/sdk/samples/basic/mac/plugin.cpp => modules/plugin/sdk/samples/basic/mac/plugin.cpp
rename : modules/plugin/tools/sdk/samples/basic/mac/plugin.h => modules/plugin/sdk/samples/basic/mac/plugin.h
rename : modules/plugin/tools/sdk/samples/basic/mac/pluginCarbonPrefix.h => modules/plugin/sdk/samples/basic/mac/pluginCarbonPrefix.h
rename : modules/plugin/tools/sdk/samples/basic/mac/pluginPrefix.h => modules/plugin/sdk/samples/basic/mac/pluginPrefix.h
rename : modules/plugin/tools/sdk/samples/basic/test.html => modules/plugin/sdk/samples/basic/test.html
rename : modules/plugin/tools/sdk/samples/basic/unix/Makefile.in => modules/plugin/sdk/samples/basic/unix/Makefile.in
rename : modules/plugin/tools/sdk/samples/basic/unix/plugin.cpp => modules/plugin/sdk/samples/basic/unix/plugin.cpp
rename : modules/plugin/tools/sdk/samples/basic/unix/plugin.h => modules/plugin/sdk/samples/basic/unix/plugin.h
rename : modules/plugin/tools/sdk/samples/basic/windows/Makefile.in => modules/plugin/sdk/samples/basic/windows/Makefile.in
rename : modules/plugin/tools/sdk/samples/basic/windows/basic.def => modules/plugin/sdk/samples/basic/windows/basic.def
rename : modules/plugin/tools/sdk/samples/basic/windows/basic.rc => modules/plugin/sdk/samples/basic/windows/basic.rc
rename : modules/plugin/tools/sdk/samples/basic/windows/npbasic.dsp => modules/plugin/sdk/samples/basic/windows/npbasic.dsp
rename : modules/plugin/tools/sdk/samples/basic/windows/npbasic.dsw => modules/plugin/sdk/samples/basic/windows/npbasic.dsw
rename : modules/plugin/tools/sdk/samples/basic/windows/plugin.cpp => modules/plugin/sdk/samples/basic/windows/plugin.cpp
rename : modules/plugin/tools/sdk/samples/basic/windows/plugin.h => modules/plugin/sdk/samples/basic/windows/plugin.h
rename : modules/plugin/tools/sdk/samples/basic/windows/resource.h => modules/plugin/sdk/samples/basic/windows/resource.h
rename : modules/plugin/tools/sdk/samples/common/Makefile.in => modules/plugin/sdk/samples/common/Makefile.in
rename : modules/plugin/tools/sdk/samples/common/np_entry.cpp => modules/plugin/sdk/samples/common/np_entry.cpp
rename : modules/plugin/tools/sdk/samples/common/npn_gate.cpp => modules/plugin/sdk/samples/common/npn_gate.cpp
rename : modules/plugin/tools/sdk/samples/common/npp_gate.cpp => modules/plugin/sdk/samples/common/npp_gate.cpp
rename : modules/plugin/tools/sdk/samples/include/npplat.h => modules/plugin/sdk/samples/include/npplat.h
rename : modules/plugin/tools/sdk/samples/include/pluginbase.h => modules/plugin/sdk/samples/include/pluginbase.h
rename : modules/plugin/tools/sdk/samples/scriptable/mac/Scriptable Plugin.mcp => modules/plugin/sdk/samples/scriptable/mac/Scriptable Plugin.mcp
rename : modules/plugin/tools/sdk/samples/scriptable/mac/Scriptable Plugin.xml => modules/plugin/sdk/samples/scriptable/mac/Scriptable Plugin.xml
rename : modules/plugin/tools/sdk/samples/scriptable/mac/Scriptable PluginIDL.mcp => modules/plugin/sdk/samples/scriptable/mac/Scriptable PluginIDL.mcp
rename : modules/plugin/tools/sdk/samples/scriptable/mac/Scriptable PluginIDL.xml => modules/plugin/sdk/samples/scriptable/mac/Scriptable PluginIDL.xml
rename : modules/plugin/tools/sdk/samples/scriptable/mac/Scriptable.rsrc => modules/plugin/sdk/samples/scriptable/mac/Scriptable.rsrc
rename : modules/plugin/tools/sdk/samples/scriptable/mac/nsIScriptablePluginSample.idl => modules/plugin/sdk/samples/scriptable/mac/nsIScriptablePluginSample.idl
rename : modules/plugin/tools/sdk/samples/scriptable/mac/nsScriptablePeer.cpp => modules/plugin/sdk/samples/scriptable/mac/nsScriptablePeer.cpp
rename : modules/plugin/tools/sdk/samples/scriptable/mac/nsScriptablePeer.h => modules/plugin/sdk/samples/scriptable/mac/nsScriptablePeer.h
rename : modules/plugin/tools/sdk/samples/scriptable/mac/plugin.cpp => modules/plugin/sdk/samples/scriptable/mac/plugin.cpp
rename : modules/plugin/tools/sdk/samples/scriptable/mac/plugin.h => modules/plugin/sdk/samples/scriptable/mac/plugin.h
rename : modules/plugin/tools/sdk/samples/scriptable/mac/pluginCarbonPrefix.h => modules/plugin/sdk/samples/scriptable/mac/pluginCarbonPrefix.h
rename : modules/plugin/tools/sdk/samples/scriptable/mac/pluginPrefix.h => modules/plugin/sdk/samples/scriptable/mac/pluginPrefix.h
rename : modules/plugin/tools/sdk/samples/scriptable/test.html => modules/plugin/sdk/samples/scriptable/test.html
rename : modules/plugin/tools/sdk/samples/scriptable/unix/Makefile.in => modules/plugin/sdk/samples/scriptable/unix/Makefile.in
rename : modules/plugin/tools/sdk/samples/scriptable/unix/nsIScriptablePluginSample.idl => modules/plugin/sdk/samples/scriptable/unix/nsIScriptablePluginSample.idl
rename : modules/plugin/tools/sdk/samples/scriptable/unix/nsScriptablePeer.cpp => modules/plugin/sdk/samples/scriptable/unix/nsScriptablePeer.cpp
rename : modules/plugin/tools/sdk/samples/scriptable/unix/nsScriptablePeer.h => modules/plugin/sdk/samples/scriptable/unix/nsScriptablePeer.h
rename : modules/plugin/tools/sdk/samples/scriptable/unix/plugin.cpp => modules/plugin/sdk/samples/scriptable/unix/plugin.cpp
rename : modules/plugin/tools/sdk/samples/scriptable/unix/plugin.h => modules/plugin/sdk/samples/scriptable/unix/plugin.h
rename : modules/plugin/tools/sdk/samples/scriptable/windows/Makefile.in => modules/plugin/sdk/samples/scriptable/windows/Makefile.in
rename : modules/plugin/tools/sdk/samples/scriptable/windows/npscriptable.def => modules/plugin/sdk/samples/scriptable/windows/npscriptable.def
rename : modules/plugin/tools/sdk/samples/scriptable/windows/npscriptable.dsp => modules/plugin/sdk/samples/scriptable/windows/npscriptable.dsp
rename : modules/plugin/tools/sdk/samples/scriptable/windows/npscriptable.dsw => modules/plugin/sdk/samples/scriptable/windows/npscriptable.dsw
rename : modules/plugin/tools/sdk/samples/scriptable/windows/npscriptable.rc => modules/plugin/sdk/samples/scriptable/windows/npscriptable.rc
rename : modules/plugin/tools/sdk/samples/scriptable/windows/nsIScriptablePluginSample.idl => modules/plugin/sdk/samples/scriptable/windows/nsIScriptablePluginSample.idl
rename : modules/plugin/tools/sdk/samples/scriptable/windows/nsScriptablePeer.cpp => modules/plugin/sdk/samples/scriptable/windows/nsScriptablePeer.cpp
rename : modules/plugin/tools/sdk/samples/scriptable/windows/nsScriptablePeer.h => modules/plugin/sdk/samples/scriptable/windows/nsScriptablePeer.h
rename : modules/plugin/tools/sdk/samples/scriptable/windows/plugin.cpp => modules/plugin/sdk/samples/scriptable/windows/plugin.cpp
rename : modules/plugin/tools/sdk/samples/scriptable/windows/plugin.h => modules/plugin/sdk/samples/scriptable/windows/plugin.h
rename : modules/plugin/tools/sdk/samples/scriptable/windows/readme.txt => modules/plugin/sdk/samples/scriptable/windows/readme.txt
rename : modules/plugin/tools/sdk/samples/scriptable/windows/resource.h => modules/plugin/sdk/samples/scriptable/windows/resource.h
rename : modules/plugin/tools/sdk/samples/simple/Makefile.in => modules/plugin/sdk/samples/simple/Makefile.in
rename : modules/plugin/tools/sdk/samples/simple/npsimple.def => modules/plugin/sdk/samples/simple/npsimple.def
rename : modules/plugin/tools/sdk/samples/simple/npsimple.dsp => modules/plugin/sdk/samples/simple/npsimple.dsp
rename : modules/plugin/tools/sdk/samples/simple/npsimple.dsw => modules/plugin/sdk/samples/simple/npsimple.dsw
rename : modules/plugin/tools/sdk/samples/simple/npsimple.rc => modules/plugin/sdk/samples/simple/npsimple.rc
rename : modules/plugin/tools/sdk/samples/simple/nsISimplePlugin.idl => modules/plugin/sdk/samples/simple/nsISimplePlugin.idl
rename : modules/plugin/tools/sdk/samples/simple/nsScriptablePeer.cpp => modules/plugin/sdk/samples/simple/nsScriptablePeer.cpp
rename : modules/plugin/tools/sdk/samples/simple/nsScriptablePeer.h => modules/plugin/sdk/samples/simple/nsScriptablePeer.h
rename : modules/plugin/tools/sdk/samples/simple/plugin.cpp => modules/plugin/sdk/samples/simple/plugin.cpp
rename : modules/plugin/tools/sdk/samples/simple/plugin.h => modules/plugin/sdk/samples/simple/plugin.h
rename : modules/plugin/tools/sdk/samples/simple/readme.txt => modules/plugin/sdk/samples/simple/readme.txt
rename : modules/plugin/tools/sdk/samples/simple/resource.h => modules/plugin/sdk/samples/simple/resource.h
rename : modules/plugin/tools/sdk/samples/simple/test.html => modules/plugin/sdk/samples/simple/test.html
rename : modules/plugin/tools/sdk/samples/winless/test.html => modules/plugin/sdk/samples/winless/test.html
rename : modules/plugin/tools/sdk/samples/winless/windows/Makefile.in => modules/plugin/sdk/samples/winless/windows/Makefile.in
rename : modules/plugin/tools/sdk/samples/winless/windows/npwinless.def => modules/plugin/sdk/samples/winless/windows/npwinless.def
rename : modules/plugin/tools/sdk/samples/winless/windows/npwinless.dsp => modules/plugin/sdk/samples/winless/windows/npwinless.dsp
rename : modules/plugin/tools/sdk/samples/winless/windows/npwinless.dsw => modules/plugin/sdk/samples/winless/windows/npwinless.dsw
rename : modules/plugin/tools/sdk/samples/winless/windows/npwinless.rc => modules/plugin/sdk/samples/winless/windows/npwinless.rc
rename : modules/plugin/tools/sdk/samples/winless/windows/plugin.cpp => modules/plugin/sdk/samples/winless/windows/plugin.cpp
rename : modules/plugin/tools/sdk/samples/winless/windows/plugin.h => modules/plugin/sdk/samples/winless/windows/plugin.h
rename : modules/plugin/tools/sdk/samples/winless/windows/resource.h => modules/plugin/sdk/samples/winless/windows/resource.h
2008-09-02 14:05:34 -04:00

151 lines
4.0 KiB
C++

/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include <windows.h>
#include <windowsx.h>
#include "plugin.h"
//////////////////////////////////////
//
// general initialization and shutdown
//
NPError NS_PluginInitialize()
{
return NPERR_NO_ERROR;
}
void NS_PluginShutdown()
{
}
/////////////////////////////////////////////////////////////
//
// construction and destruction of our plugin instance object
//
nsPluginInstanceBase * NS_NewPluginInstance(nsPluginCreateData * aCreateDataStruct)
{
if(!aCreateDataStruct)
return NULL;
nsPluginInstance * plugin = new nsPluginInstance(aCreateDataStruct->instance);
// now is the time to tell Mozilla that we are windowless
NPN_SetValue(aCreateDataStruct->instance, NPPVpluginWindowBool, NULL);
return plugin;
}
void NS_DestroyPluginInstance(nsPluginInstanceBase * aPlugin)
{
if(aPlugin)
delete (nsPluginInstance *)aPlugin;
}
////////////////////////////////////////
//
// nsPluginInstance class implementation
//
nsPluginInstance::nsPluginInstance(NPP aInstance) : nsPluginInstanceBase(),
mInstance(aInstance),
mInitialized(FALSE)
{
}
nsPluginInstance::~nsPluginInstance()
{
}
NPBool nsPluginInstance::init(NPWindow* aWindow)
{
// no GUI to init in windowless case
mInitialized = TRUE;
return TRUE;
}
void nsPluginInstance::shut()
{
// no GUI to shut in windowless case
mInitialized = FALSE;
}
NPBool nsPluginInstance::isInitialized()
{
return mInitialized;
}
NPError nsPluginInstance::SetWindow(NPWindow* aWindow)
{
// keep window parameters
mWindow = aWindow;
return NPERR_NO_ERROR;
}
uint16 nsPluginInstance::HandleEvent(void* aEvent)
{
NPEvent * event = (NPEvent *)aEvent;
switch (event->event) {
case WM_PAINT:
{
if(!mWindow)
break;
// get the dirty rectangle to update or repaint the whole window
RECT * drc = (RECT *)event->lParam;
if(drc)
FillRect((HDC)event->wParam, drc, (HBRUSH)(COLOR_ACTIVECAPTION+1));
else {
RECT rc;
rc.bottom = mWindow->y + mWindow->height;
rc.left = mWindow->x;
rc.right = mWindow->x + mWindow->width;
rc.top = mWindow->y;
FillRect((HDC)event->wParam, &rc, (HBRUSH)(COLOR_ACTIVECAPTION+1));
}
break;
}
case WM_KEYDOWN:
{
Beep(1000,100);
break;
}
default:
return 0;
}
return 1;
}