Browser Plugin

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 04/02/2011 at 18:26, xxxxxxxx wrote:

User Information:
Cinema 4D Version:   12 
Platform:   Windows  ;   
Language(s) :     C++  ;

---------
Hey everyone.

I am in the process of trying to write a Browser Plugin and I was able to finally get a working skeleton to work with .  So I thought I'd share this skeleton with you in case anyone out there needs to make a browser plugin.

  
//=====================================//  
//    PLANET X GENERATOR v. 2.0          //  
//  (c) Copyright 2011 - Shawn Foster  //  
//  pxgbrowserplugin.cpp               //  
//=====================================//  
  
//BROWSER INTERFACE PLUGIN  
  
#include "c4d.h"  
#include "c4d_symbols.h"  
#include "lib_browser.h"  
#include "ge_dynamicarray.h"  
  
//PLUGIN ID  
#define PXG_BROWSER_PLUGIN [REMOVED ID NUMBER]  
  
class PXGBrowserPlugin : public SDKBrowserPluginInterfaceInfo{  
  
public:  
 // SDKBrowserPluginInterfaceInfo(void);  
 // SDKBrowserPluginRef GetPlugin(void) const;  
  
  virtual LONG GetPluginID(String* plugin_name);  
  virtual Bool Identify(const SDKBrowserURL& url, UCHAR* probe, LONG size, ULONG flags);  
  virtual String GetTypeName(const SDKBrowserContentNodeRef node, const SDKBrowserURL* url, LONG mode);  
  virtual String* GetTypeNames(LONG mode, LONG* no_strings);  
  
  virtual SDKBrowserPreviewData* OpenPreviewBitmap(BaseThread* thread, const SDKBrowserContentNodeRef node, const SDKBrowserURL* url, SDKBrowserPreviewInfo* info);  
  virtual void ClosePreviewBitmap(SDKBrowserPreviewData* data);  
  virtual BaseBitmap* GetPreviewBitmap(SDKBrowserPreviewData* data, LONG w, LONG h, LONG quality);  
  
  virtual SDKBrowserIcon* GetIcon(const SDKBrowserURL& url, LONG pref_wh);  
  
  virtual SubDialog* OpenPreviewDialog(SDKBrowserContentNodeRef node, LONG tab_id);  
  virtual LONG ClosePreviewDialog(SDKBrowserContentNodeRef node, SubDialog* s);  
  virtual Bool Open(SDKBrowserContentNodeRef node, const SDKBrowserURL* url, LONG flags);  
  virtual LONG UpdatePreviewDialog( SDKBrowserContentNodeRef node, SubDialog *s );  
};  
/*  
void PXGBrowserPlugin::SDKBrowserPluginInterfaceInfo(){  
  
}  
  
void PXGBrowserPlugin::SDKBrowserPluginRef GetPlugin() const{  
  
}*/  
  
LONG PXGBrowserPlugin::GetPluginID(String* plugin_name){  
    
  return NULL;  
}  
  
Bool PXGBrowserPlugin::Identify(const SDKBrowserURL& url, UCHAR* probe, LONG size, ULONG flags){  
  
  return TRUE;  
}  
  
String PXGBrowserPlugin::GetTypeName(const SDKBrowserContentNodeRef node, const SDKBrowserURL* url, LONG mode){  
  
  String test = "test";  
  
  return test;  
  
}  
  
String* PXGBrowserPlugin::GetTypeNames(LONG mode, LONG* no_strings){  
  
  String *test = (String* ) GeAlloc (sizeof(String)*33);   
  
  return test;  
}  
  
SDKBrowserPreviewData* PXGBrowserPlugin::OpenPreviewBitmap(BaseThread* thread, const SDKBrowserContentNodeRef node, const SDKBrowserURL* url, SDKBrowserPreviewInfo* info){  
  
  SDKBrowserPreviewData* pd;  
  
  return pd;  
}  
  
  
void PXGBrowserPlugin::ClosePreviewBitmap(SDKBrowserPreviewData* data){  
  
}  
  
BaseBitmap* PXGBrowserPlugin::GetPreviewBitmap(SDKBrowserPreviewData* data, LONG w, LONG h, LONG quality){  
  
  AutoAlloc<BaseBitmap> bmap;  
  return bmap;  
}  
  
SDKBrowserIcon* PXGBrowserPlugin::GetIcon(const SDKBrowserURL& url, LONG pref_wh){  
  
  SDKBrowserIcon *ico;  
  return ico;  
}  
  
SubDialog* PXGBrowserPlugin::OpenPreviewDialog(SDKBrowserContentNodeRef node, LONG tab_id){  
    
  SubDialog* sd;  
  return sd;  
}  
  
LONG PXGBrowserPlugin::ClosePreviewDialog(SDKBrowserContentNodeRef node, SubDialog* s){  
  
  return NULL;  
}  
  
Bool PXGBrowserPlugin::Open(SDKBrowserContentNodeRef node, const SDKBrowserURL* url, LONG flags){  
  
  return TRUE;  
}  
  
LONG PXGBrowserPlugin::UpdatePreviewDialog( SDKBrowserContentNodeRef node, SubDialog *s ){  
  return NULL;  
}  
  
Bool RegisterPXGBrowserPlugin(void)  
{  
  return SDKBrowser::RegisterBrowserPlugin(gNew PXGBrowserPlugin, 0);  
}  
  

You would of course need to change the class name and all the classes before the methods but this will hopefully help some of you with the process.

Enjoy!

~Shawn

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 05/02/2011 at 08:43, xxxxxxxx wrote:

Thanks, mate! :)