THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 07/10/2011 at 09:57, xxxxxxxx wrote:
User Information:
Cinema 4D Version: 12
Platform: Windows ;
Language(s) : C++ ;
---------
I'm trying to figure out how to create a tag plugin that also has a dialog plugin inside of it. So when a button is pressed in the tag. It launches the dialog plugin.
But I don't know how to handle the registration for something like this.
Here's my code:
#include "c4d.h"
#include "c4d_symbols.h"
#include "tsimpletag.h"
#define TAG_PLUGIN_ID 1000003 //Be sure to use a unique ID obtained from www.plugincafe.com
#define COMMAND_PLUGIN_ID 1000004 //Be sure to use a unique ID obtained from www.plugincafe.com
///////////////////Dialog and Command sections /////////////////////////////
class myDialog : public GeDialog
{
public:
myDialog(void);
virtual Bool CreateLayout(void);
virtual Bool InitValues(void);
virtual Bool Command(LONG id,const BaseContainer &msg);
virtual LONG Message(const BaseContainer &msg,BaseContainer &result);
virtual Bool CoreMessage (LONG id,const BaseContainer &msg);
};
myDialog::myDialog(void)
{
}
Bool myDialog::CreateLayout(void)
{
SetTitle("My Tag's Dialog");
GroupBegin(0,BFH_SCALEFIT,2,0,"",0);
{
AddStaticText(0,BFH_LEFT,0,0,"Hello World",0);
}
GroupEnd();
return TRUE;
}
class mySimpleDialog : public CommandData
{
private:
myDialog dlg;
public:
virtual Bool Execute(BaseDocument *doc);
virtual LONG GetState(BaseDocument *doc);
virtual Bool RestoreLayout(void *secret);
};
LONG mySimpleDialog::GetState(BaseDocument *doc)
{
return CMD_ENABLED;
}
Bool mySimpleDialog::Execute(BaseDocument *doc)
{
return dlg.Open(DLG_TYPE_ASYNC,COMMAND_PLUGIN_ID, -1, -1, 300,150);
}
Bool mySimpleDialog::RestoreLayout(void *secret)
{
return dlg.RestoreLayout(COMMAND_PLUGIN_ID,0,secret);
}
///////////////////////// Tag Section /////////////////////////
class SimpleTag : public TagData
{
public:
virtual Bool Message(GeListNode *node, LONG type, void *t_data);
virtual Bool Init(GeListNode *node);
virtual Bool GetDDescription(GeListNode *node, Description *description,DESCFLAGS_DESC &flags);
virtual EXECUTIONRESULT Execute(BaseTag *tag, BaseDocument *doc, BaseObject *op, BaseThread *bt, LONG priority, EXECUTIONFLAGS flags);
static NodeData *Alloc(void) { return gNew SimpleTag; }
};
Bool SimpleTag::Message(GeListNode *node, LONG type, void *data)
{
switch (type)
{
case MSG_DESCRIPTION_COMMAND: // MSG_DESCRIPTION_COMMAND is sent when button is clicked
{
DescriptionCommand *dc = (DescriptionCommand* )data; // data contains the description ID of the button
LONG button = dc->id[0].id; // Get the ID of the button
switch (button) // Check for different button IDs
{
case BUTTON1:
GePrint("Button1 was pushed");
break;
case BUTTON2:
// I want this button to launch my Command dialog
break;
}
}
}
return TRUE;
}
Bool SimpleTag::Init(GeListNode *node)
{
BaseTag *tag = (BaseTag* )node; // Assigns a variable to the tag's node
BaseContainer *data = tag->GetDataInstance(); // Assigns a variable to that node's container
return TRUE;
}
Bool SimpleTag::GetDDescription(GeListNode *node, Description *description,DESCFLAGS_DESC &flags)
{
return TRUE;
}
EXECUTIONRESULT SimpleTag::Execute(BaseTag *tag, BaseDocument *doc, BaseObject *op, BaseThread *bt, LONG priority, EXECUTIONFLAGS flags)
{
return EXECUTIONRESULT_OK;
}
Bool RegisterSimpleTag(void)
{
return RegisterTagPlugin(TAG_PLUGIN_ID, GeLoadString(IDS_SIMPLETAG),TAG_EXPRESSION|TAG_VISIBLE,SimpleTag::Alloc,"tsimpletag",AutoBitmap("myicon.tif"),0);
}
I also need to figure out how to handle the button call that makes the dialog open.
I think the execute function I'm using in the mySimpleDialog class is wrong. And needs to be somehow placed in the Tag's Button code.
But first things first....I first need to know how to register the dialog plugin that's inside of the tag.
-ScottA