include/OffscreenGecko/embedding.h

Go to the documentation of this file.
00001 /* ***** BEGIN LICENSE BLOCK *****
00002  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00003  *
00004  * The contents of this file are subject to the Mozilla Public License Version
00005  * 1.1 (the "License"); you may not use this file except in compliance with
00006  * the License. You may obtain a copy of the License at
00007  * http://www.mozilla.org/MPL/
00008  *
00009  * Software distributed under the License is distributed on an "AS IS" basis,
00010  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00011  * for the specific language governing rights and limitations under the
00012  * License.
00013  *
00014  * The Original Code is OffscreenGecko code.
00015  *
00016  * The Initial Developer of the Original Code is
00017  * Frank Richter <frank.richter@gmail.com>.
00018  * Portions created by the Initial Developer are Copyright (C) 2007
00019  * the Initial Developer. All Rights Reserved.
00020  *
00021  * Contributor(s):
00022  *
00023  * Alternatively, the contents of this file may be used under the terms of
00024  * either the GNU General Public License Version 2 or later (the "GPL"), or
00025  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00026  * in which case the provisions of the GPL or the LGPL are applicable instead
00027  * of those above. If you wish to allow use of your version of this file only
00028  * under the terms of either the GPL or the LGPL, and not to allow others to
00029  * use your version of this file under the terms of the MPL, indicate your
00030  * decision by deleting the provisions above and replace them with the notice
00031  * and other provisions required by the GPL or the LGPL. If you do not delete
00032  * the provisions above, a recipient may use your version of this file under
00033  * the terms of any one of the MPL, the GPL or the LGPL.
00034  *
00035  * ***** END LICENSE BLOCK ***** */
00036 
00037 #ifndef __OFFSCREENGECKO_EMBEDDING_H__
00038 #define __OFFSCREENGECKO_EMBEDDING_H__
00039 
00044 #include "baseobj.h"
00045 #include "componentmgr.h"
00046 #include "geckomem.h"
00047 #include "string.h"
00048 
00053 OSGK_DERIVEDTYPE(OSGK_EmbeddingOptions);
00054 
00059 OSGK_EXTERN_C OSGK_API OSGK_EmbeddingOptions* osgk_embedding_options_create (void);
00060 
00066 OSGK_EXTERN_C OSGK_API void osgk_embedding_options_add_search_path (
00067   OSGK_EmbeddingOptions* options, const char* path);
00068 
00074 OSGK_EXTERN_C OSGK_API void osgk_embedding_options_add_components_path (
00075   OSGK_EmbeddingOptions* options, const char* path);
00076 
00094 OSGK_EXTERN_C OSGK_API void osgk_embedding_options_set_profile_dir (
00095   OSGK_EmbeddingOptions* options, const char* profileDir,
00096   const char* localProfileDir OSGK_DEFAULT_ARG(0) );
00097 
00098 #ifdef __cplusplus
00099 
00100 namespace OSGK
00101 {
00106   struct EmbeddingOptions : public CXXAPI::Wrap<OSGK_EmbeddingOptions>
00107   {
00111     EmbeddingOptions() : WrapperType (osgk_embedding_options_create()) { }
00112 
00113     explicit EmbeddingOptions (WrappedType* obj) : WrapperType (obj) {}
00114     EmbeddingOptions& operator=(const EmbeddingOptions& other)
00115     {
00116       WrapperType::operator=(other);
00117       return *this;
00118     }
00119 
00124     void AddSearchPath (const char* path)
00125     {
00126       osgk_embedding_options_add_search_path (GetObject(), path);
00127     }
00128 
00133     void AddComponentsPath (const char* path)
00134     {
00135       osgk_embedding_options_add_components_path (GetObject(), path);
00136     }
00137 
00154     void SetProfileDir (const char* profileDir,
00155       const char* localProfileDir = 0)
00156     {
00157       osgk_embedding_options_set_profile_dir (GetObject(), profileDir,
00158         localProfileDir);
00159     }
00160   };
00161   
00162 } // namespace OSGK
00163 #endif
00164 
00169 OSGK_DERIVEDTYPE(OSGK_Embedding);
00170 
00172 #define OSGK_API_VERSION    1
00173 
00174 #ifndef OSGK___DOXYRUN__
00175 
00178 OSGK_EXTERN_C OSGK_API OSGK_Embedding* osgk_embedding_create2 (
00179   unsigned int apiVer, OSGK_EmbeddingOptions* options, 
00180   OSGK_GeckoResult* geckoResult);
00181 #endif
00182 
00188 static OSGK_INLINE OSGK_Embedding* osgk_embedding_create (
00189   OSGK_GeckoResult* geckoResult OSGK_DEFAULT_ARG(0))
00190 {
00191   return osgk_embedding_create2 (OSGK_API_VERSION, 0, geckoResult);
00192 }
00193 
00200 static OSGK_INLINE OSGK_Embedding* osgk_embedding_create_with_options (
00201   OSGK_EmbeddingOptions* options, OSGK_GeckoResult* geckoResult OSGK_DEFAULT_ARG(0))
00202 {
00203   return osgk_embedding_create2 (OSGK_API_VERSION, options, geckoResult);
00204 }
00205 
00212 OSGK_EXTERN_C OSGK_API OSGK_GeckoMem* osgk_embedding_get_gecko_mem (
00213   OSGK_Embedding* embedding);
00214 
00221 OSGK_EXTERN_C OSGK_API OSGK_ComponentMgr* osgk_embedding_get_component_mgr (
00222   OSGK_Embedding* embedding);
00223 
00224 OSGK_CLASSTYPE_DEF nsIComponentManager;
00225 OSGK_CLASSTYPE_DEF nsIComponentRegistrar;
00226 OSGK_CLASSTYPE_DEF nsIServiceManager;
00227 
00234 OSGK_EXTERN_C OSGK_API OSGK_CLASSTYPE_REF nsIComponentManager* 
00235 osgk_embedding_get_gecko_component_manager (OSGK_Embedding* embedding);
00242 OSGK_EXTERN_C OSGK_API OSGK_CLASSTYPE_REF nsIComponentRegistrar* 
00243 osgk_embedding_get_gecko_component_registrar (OSGK_Embedding* embedding);
00250 OSGK_EXTERN_C OSGK_API OSGK_CLASSTYPE_REF nsIServiceManager* 
00251 osgk_embedding_get_gecko_service_manager (OSGK_Embedding* embedding);
00252 
00253 // @@@ Right place?
00255 enum
00256 {
00258   jsgPrivileged = 1
00259 };
00273 OSGK_EXTERN_C OSGK_API int osgk_embedding_register_js_global (
00274   OSGK_Embedding* embedding, const char* name, const char* contractID,
00275   unsigned int flags, OSGK_String** previousContract OSGK_DEFAULT_ARG(0),
00276   OSGK_GeckoResult* geckoResult OSGK_DEFAULT_ARG(0));
00277 
00285 OSGK_EXTERN_C OSGK_API void osgk_embedding_clear_focus (
00286   OSGK_Embedding* embedding);
00287   
00299 OSGK_EXTERN_C OSGK_API void osgk_embedding_set_auto_focus (
00300   OSGK_Embedding* embedding, int autoFocus);
00301   
00308 OSGK_EXTERN_C OSGK_API int osgk_embedding_get_auto_focus (
00309   OSGK_Embedding* embedding);
00312 #ifdef __cplusplus
00313 
00314 namespace OSGK
00315 {
00321   struct Embedding : public CXXAPI::Wrap<OSGK_Embedding>
00322   {
00326     Embedding() : WrapperType (osgk_embedding_create()) { }
00331     Embedding (OSGK_GeckoResult& result) : 
00332       WrapperType (osgk_embedding_create (&result)) { }
00337     Embedding(EmbeddingOptions& opt) : WrapperType (
00338       osgk_embedding_create_with_options (opt.GetObject())) { }
00344     Embedding (EmbeddingOptions& opt, OSGK_GeckoResult& result) : 
00345       WrapperType (osgk_embedding_create_with_options (
00346         opt.GetObject(), &result)) { }
00347 
00348     explicit Embedding (WrappedType* obj) : WrapperType (obj) {}
00349     Embedding& operator=(const Embedding& other)
00350     {
00351       WrapperType::operator=(other);
00352       return *this;
00353     }
00354 
00358     GeckoMem GetGeckoMem ()
00359     {
00360       OSGK_GeckoMem* geckoMem = 
00361         osgk_embedding_get_gecko_mem (GetObject ());
00362       /* A reference to geckoMem was *not* implicitly added. Add one so the 
00363          wrapper works right */
00364       osgk_addref (geckoMem);
00365       return GeckoMem (geckoMem);
00366     }
00367     
00371     ComponentMgr GetComponentMgr()
00372     {
00373       OSGK_ComponentMgr* compMgr = 
00374         osgk_embedding_get_component_mgr (GetObject ());
00375       /* A reference to compMgr was *not* implicitly added. Add one so the 
00376          wrapper works right */
00377       osgk_addref (compMgr);
00378       return ComponentMgr (compMgr);
00379     }
00380     
00386     nsIComponentManager* GetGeckoComponentManager ()
00387     {
00388       return osgk_embedding_get_gecko_component_manager (GetObject());
00389     }
00395     nsIComponentRegistrar*  GetGeckoComponentRegistrar ()
00396     {
00397       return osgk_embedding_get_gecko_component_registrar (GetObject ());
00398     }
00404     nsIServiceManager* GetGeckoServiceManager ()
00405     {
00406       return osgk_embedding_get_gecko_service_manager (GetObject ());
00407     }
00408 
00417     bool RegisterJSGlobal (const char* name, const char* contractID,
00418       unsigned int flags)
00419     {
00420       return osgk_embedding_register_js_global (GetObject(), name,
00421         contractID, flags) != 0;
00422     }
00433     bool RegisterJSGlobal (const char* name, const char* contractID,
00434       unsigned int flags, String& previous)
00435     {
00436       OSGK_String* str;
00437       bool ret = osgk_embedding_register_js_global (GetObject(), name,
00438         contractID, flags, &str) != 0;
00439       previous = String (str);
00440       return ret;
00441     }
00451     bool RegisterJSGlobal (const char* name, const char* contractID,
00452       unsigned int flags, OSGK_GeckoResult& geckoResult)
00453     {
00454       return osgk_embedding_register_js_global (GetObject(), name,
00455         contractID, flags, 0, &geckoResult) != 0;
00456     }
00468     bool RegisterJSGlobal (const char* name, const char* contractID,
00469       unsigned int flags, String& previous, OSGK_GeckoResult& geckoResult)
00470     {
00471       OSGK_String* str;
00472       bool ret = osgk_embedding_register_js_global (GetObject(), name,
00473         contractID, flags, &str, &geckoResult) != 0;
00474       previous = String (str);
00475       return ret;
00476     }
00477     
00484     void ClearFocus ()
00485     {
00486       osgk_embedding_clear_focus (GetObject ());
00487     }
00488     
00498     void SetAutoFocus (bool autoFocus)
00499     {
00500       osgk_embedding_set_auto_focus (GetObject(), autoFocus);
00501     }
00502     
00508     bool GetAutoFocus ()
00509     {
00510       return osgk_embedding_get_auto_focus (GetObject()) != 0;
00511     }
00513   };
00514   
00515 } // namespace OSGK
00516 #endif
00517 
00518 #endif // __OFFSCREENGECKO_EMBEDDING_H__

Generated on Sun Nov 2 18:15:18 2008 for OffscreenGecko by  doxygen 1.5.4