aboutsummaryrefslogtreecommitdiff
path: root/Src/nprt_plugin/gecko/1.8/win/include/nsEmbedAPI.h
blob: a50a766274898f299ea402e1ad58ca9048b2930d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
/* -*- Mode: C++; tab-width: 4; 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 the Mozilla browser.
 *
 * The Initial Developer of the Original Code is
 * Netscape Communications, Inc.
 * Portions created by the Initial Developer are Copyright (C) 1999
 * the Initial Developer. All Rights Reserved.
 *
 * Contributor(s):
 *   Adam Lock <adamlock@netscape.com>
 *   Benjamin Smedberg <benjamin@smedbergs.us>
 *
 * 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 ***** */

#ifndef NSEMBEDAPI_H
#define NSEMBEDAPI_H

#include "nscore.h"
#include "nsXPCOM.h"
#include "nsILocalFile.h"
#include "nsIDirectoryService.h"

/**
 * @file
 * @brief The Gecko embedding API functions, structures and definitions.
 */

/**
 * Initialises the Gecko embedding layer. You <I>must</I>
 * call this method before proceeding to use Gecko. This function ensures
 * XPCOM is started, creates the component registry if necessary and
 * starts global services.
 *
 * @status FROZEN
 *
 * @note Use <CODE>NS_NewLocalFile</CODE> to create the file object you
 *       supply as the bin directory path in this call. The function
 *       may be safely called before the rest of XPCOM or embedding has
 *       been initialised.
 *
 * @param aMozBinDirectory The Gecko directory containing the component
 *                         registry and runtime libraries;
 *                         or use <CODE>nsnull</CODE> to use the working
 *                         directory.
 * @param aAppFileLocProvider The object to be used by Gecko that specifies
 *                         to Gecko where to find profiles, the component
 *                         registry preferences and so on; or use
 *                         <CODE>nsnull</CODE> for the default behaviour.
 * @param aStaticComponents An array of static components (see NS_InitXPCOM3).
 *                         may be null.
 * @param aStaticComponentCount Number of static components in the
 *                              aStaticComponents array.
 *
 * @see NS_NewLocalFile
 * @see nsILocalFile
 * @see nsIDirectoryServiceProvider
 *
 * @return NS_OK for success;
 *         other error codes indicate a failure during initialisation.
 *
 */
extern "C" NS_HIDDEN NS_METHOD
NS_InitEmbedding(nsILocalFile *aMozBinDirectory,
                 nsIDirectoryServiceProvider *aAppFileLocProvider,
                 nsStaticModuleInfo const *aStaticComponents = nsnull,
                 PRUint32 aStaticComponentCount = 0);


/**
 * Terminates the Gecko embedding layer. Call this function during shutdown to
 * ensure that global services are unloaded, files are closed and
 * XPCOM is shutdown.
 *
 * @status FROZEN
 *
 * @note Release any XPCOM objects within Gecko that you may be holding a
 *       reference to before calling this function.
 *
 * @return NS_OK
 */
extern "C" NS_HIDDEN NS_METHOD
NS_TermEmbedding();

/*---------------------------------------------------------------------------*/
/* Event processing APIs. The native OS dependencies mean you must be        */
/* building on a supported platform to get the functions below.              */
/*---------------------------------------------------------------------------*/

#undef MOZ_SUPPORTS_EMBEDDING_EVENT_PROCESSING

/* Win32 specific stuff */
#if defined (WIN32) || defined (WINCE)
#include "windows.h"
/**
 * @var typedef MSG nsEmbedNativeEvent
 * 
 * Embedding events are native <CODE>MSG</CODE> structs on Win32.
 */
typedef MSG nsEmbedNativeEvent;
#define MOZ_SUPPORTS_EMBEDDING_EVENT_PROCESSING
#endif

/* OS/2 specific stuff */
#ifdef XP_OS2
#include "os2.h"

/**
 * @var typedef MSG nsEmbedNativeEvent
 * 
 * Embedding events are native <CODE>QMSG</CODE> structs on OS/2.
 */
typedef QMSG nsEmbedNativeEvent;
#define MOZ_SUPPORTS_EMBEDDING_EVENT_PROCESSING
#endif

/* Mac specific stuff */
/* TODO implementation left as an exercise for the reader */

/* GTK specific stuff */
/* TODO implementation left as an exercise for the reader */


#ifdef MOZ_SUPPORTS_EMBEDDING_EVENT_PROCESSING

/**
 * @fn nsresult NS_HandleEmbeddingEvent(nsEmbedNativeEvent &aEvent, PRBool &aWasHandled)
 *
 * This function gives Gecko the chance to process a native window events.
 * Call this function from your message processing loop.
 *
 * @status UNDER_REVIEW
 *
 * @param aEvent The native UI event
 * @param aWasHandled Returns with <CODE>PR_TRUE</CODE> if the end was
 *                    handled; in which case it should not be handled by your
 *                    application.
 *
 * @return NS_OK
 */
extern "C" NS_HIDDEN NS_METHOD
NS_HandleEmbeddingEvent(nsEmbedNativeEvent &aEvent, PRBool &aWasHandled);

#endif /* MOZ_SUPPORTS_EMBEDDING_EVENT_PROCESSING */

#endif /* NSEMBEDAPI_H */