nsEmbedAPI.h 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  2. *
  3. * ***** BEGIN LICENSE BLOCK *****
  4. * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  5. *
  6. * The contents of this file are subject to the Mozilla Public License Version
  7. * 1.1 (the "License"); you may not use this file except in compliance with
  8. * the License. You may obtain a copy of the License at
  9. * http://www.mozilla.org/MPL/
  10. *
  11. * Software distributed under the License is distributed on an "AS IS" basis,
  12. * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  13. * for the specific language governing rights and limitations under the
  14. * License.
  15. *
  16. * The Original Code is the Mozilla browser.
  17. *
  18. * The Initial Developer of the Original Code is
  19. * Netscape Communications, Inc.
  20. * Portions created by the Initial Developer are Copyright (C) 1999
  21. * the Initial Developer. All Rights Reserved.
  22. *
  23. * Contributor(s):
  24. * Adam Lock <[email protected]>
  25. * Benjamin Smedberg <[email protected]>
  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. #ifndef NSEMBEDAPI_H
  41. #define NSEMBEDAPI_H
  42. #include "nscore.h"
  43. #include "nsXPCOM.h"
  44. #include "nsILocalFile.h"
  45. #include "nsIDirectoryService.h"
  46. /**
  47. * @file
  48. * @brief The Gecko embedding API functions, structures and definitions.
  49. */
  50. /**
  51. * Initialises the Gecko embedding layer. You <I>must</I>
  52. * call this method before proceeding to use Gecko. This function ensures
  53. * XPCOM is started, creates the component registry if necessary and
  54. * starts global services.
  55. *
  56. * @status FROZEN
  57. *
  58. * @note Use <CODE>NS_NewLocalFile</CODE> to create the file object you
  59. * supply as the bin directory path in this call. The function
  60. * may be safely called before the rest of XPCOM or embedding has
  61. * been initialised.
  62. *
  63. * @param aMozBinDirectory The Gecko directory containing the component
  64. * registry and runtime libraries;
  65. * or use <CODE>nsnull</CODE> to use the working
  66. * directory.
  67. * @param aAppFileLocProvider The object to be used by Gecko that specifies
  68. * to Gecko where to find profiles, the component
  69. * registry preferences and so on; or use
  70. * <CODE>nsnull</CODE> for the default behaviour.
  71. * @param aStaticComponents An array of static components (see NS_InitXPCOM3).
  72. * may be null.
  73. * @param aStaticComponentCount Number of static components in the
  74. * aStaticComponents array.
  75. *
  76. * @see NS_NewLocalFile
  77. * @see nsILocalFile
  78. * @see nsIDirectoryServiceProvider
  79. *
  80. * @return NS_OK for success;
  81. * other error codes indicate a failure during initialisation.
  82. *
  83. */
  84. extern "C" NS_HIDDEN NS_METHOD
  85. NS_InitEmbedding(nsILocalFile *aMozBinDirectory,
  86. nsIDirectoryServiceProvider *aAppFileLocProvider,
  87. nsStaticModuleInfo const *aStaticComponents = nsnull,
  88. PRUint32 aStaticComponentCount = 0);
  89. /**
  90. * Terminates the Gecko embedding layer. Call this function during shutdown to
  91. * ensure that global services are unloaded, files are closed and
  92. * XPCOM is shutdown.
  93. *
  94. * @status FROZEN
  95. *
  96. * @note Release any XPCOM objects within Gecko that you may be holding a
  97. * reference to before calling this function.
  98. *
  99. * @return NS_OK
  100. */
  101. extern "C" NS_HIDDEN NS_METHOD
  102. NS_TermEmbedding();
  103. /*---------------------------------------------------------------------------*/
  104. /* Event processing APIs. The native OS dependencies mean you must be */
  105. /* building on a supported platform to get the functions below. */
  106. /*---------------------------------------------------------------------------*/
  107. #undef MOZ_SUPPORTS_EMBEDDING_EVENT_PROCESSING
  108. /* Win32 specific stuff */
  109. #if defined (WIN32) || defined (WINCE)
  110. #include "windows.h"
  111. /**
  112. * @var typedef MSG nsEmbedNativeEvent
  113. *
  114. * Embedding events are native <CODE>MSG</CODE> structs on Win32.
  115. */
  116. typedef MSG nsEmbedNativeEvent;
  117. #define MOZ_SUPPORTS_EMBEDDING_EVENT_PROCESSING
  118. #endif
  119. /* OS/2 specific stuff */
  120. #ifdef XP_OS2
  121. #include "os2.h"
  122. /**
  123. * @var typedef MSG nsEmbedNativeEvent
  124. *
  125. * Embedding events are native <CODE>QMSG</CODE> structs on OS/2.
  126. */
  127. typedef QMSG nsEmbedNativeEvent;
  128. #define MOZ_SUPPORTS_EMBEDDING_EVENT_PROCESSING
  129. #endif
  130. /* Mac specific stuff */
  131. /* TODO implementation left as an exercise for the reader */
  132. /* GTK specific stuff */
  133. /* TODO implementation left as an exercise for the reader */
  134. #ifdef MOZ_SUPPORTS_EMBEDDING_EVENT_PROCESSING
  135. /**
  136. * @fn nsresult NS_HandleEmbeddingEvent(nsEmbedNativeEvent &aEvent, PRBool &aWasHandled)
  137. *
  138. * This function gives Gecko the chance to process a native window events.
  139. * Call this function from your message processing loop.
  140. *
  141. * @status UNDER_REVIEW
  142. *
  143. * @param aEvent The native UI event
  144. * @param aWasHandled Returns with <CODE>PR_TRUE</CODE> if the end was
  145. * handled; in which case it should not be handled by your
  146. * application.
  147. *
  148. * @return NS_OK
  149. */
  150. extern "C" NS_HIDDEN NS_METHOD
  151. NS_HandleEmbeddingEvent(nsEmbedNativeEvent &aEvent, PRBool &aWasHandled);
  152. #endif /* MOZ_SUPPORTS_EMBEDDING_EVENT_PROCESSING */
  153. #endif /* NSEMBEDAPI_H */