Dialogs within Tags

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

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

On 07/10/2011 at 11:20, xxxxxxxx wrote:

Hey ScottA,

I think your way to handle button call is not false. 🙂

When you will look in my thread: https://plugincafe.maxon.net/topic/6048/6199_dialog-in-dialog you will read about starting a dialog from an other. I think it is the same.

Not tested:

  
  
. . .  
  
///////////////////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;  
}  
  
  
///////////////////////// Tag Section /////////////////////////  
  
class SimpleTag : public TagData  
{  
  private  
      mySimpleDialog* dlg;  
  public:  
      SimpleTag();  
      ~SimpleTag();  
      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; }  
};  
  
SimpleTag::SimpleTag  
{  
  dlg = NULL;  
}  
  
SimpleTag::~SimpleTag  
{  
  GeFree(dlg);  
}  
  
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:  
                  dlg.Open(DLG_TYPE_MODAL, TAG_PLUGIN_ID)  
                  // 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  
    
  dlg = gNew SimpleTag;  
  
  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);  
}  

You don´t need the CommandData. But if you want to use the CommandData, you can use SendModelingCommand().

Oh and you don´t registrate the CommandData anywhere.

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

On 07/10/2011 at 12:08, xxxxxxxx wrote:

Thanks Toni.

I think you're on the right track. But I'm getting lots of errors.
Starting with the declaration of the CommandData class from within the TagData class:

  
class SimpleTag : public TagData  
{  
  private  
      mySimpleDialog *dlg; //This does not work

From there it all goes down hill because of that bad declaration.
I'm not sure how to fix this.

-ScottA

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

On 07/10/2011 at 12:09, xxxxxxxx wrote:

Oh my fault.  Now it should work.

. . .  
  
///////////////////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;  
}  
  
  
///////////////////////// Tag Section /////////////////////////  
  
class SimpleTag : public TagData  
{  
  private  
      myDialog\* dlg;  
  public:  
      SimpleTag();  
      ~SimpleTag();  
      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; }  
};  
  
SimpleTag::SimpleTag  
{  
  dlg = NULL;  
}  
  
SimpleTag::~SimpleTag  
{  
  GeFree(dlg);  
}  
  
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:  
                  dlg = gNew myDialog;  
                  dlg->Open(DLG_TYPE_MODAL, TAG_PLUGIN_ID);  
                  // 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  
    
  dlg = gNew myDialog;  
  
  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);  
}

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

On 07/10/2011 at 12:23, xxxxxxxx wrote:

Hmmm. Nope. Still doesn't work for me.
It's probably my fault because I'm missing something simple.
Same type of declaration problems:

class SimpleTag : public TagData  
{  
  private  
      myDialog* dlg;// Does not work..Intellisense says needs a : 

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

On 07/10/2011 at 12:45, xxxxxxxx wrote:

Just change private to private :

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

On 07/10/2011 at 13:42, xxxxxxxx wrote:

Doh!
See. I knew it was something simple.😊
I actually figured out how to do it another way.

Here's the entire code example minus the resource stuff:

#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  
  
///////////////////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(10005,BFH_LEFT,200,10,"Hello World",0);  
  AddCheckbox(10006, BFH_LEFT, 4, 4, "mycheckbox");  
  }  
  GroupEnd();  
  
  return TRUE;  
}  
  
Bool myDialog::InitValues(void)  
{  
  // first call the parent instance  
  if (!GeDialog::InitValues()) return FALSE;          
  
  SetString(10005, "Hello World");  
  SetBool(10006, FALSE);  
    
  return TRUE;  
}  
  
Bool myDialog::Command(LONG id,const BaseContainer &msg)  
{  
        
  switch (id) //id is the variable used to trigger an event   
  {  
      case 10006:              
          SetString(10005, "CheckBox is enabled");              
          break;  
  }      
  
  return TRUE;  
}  
  
  
  
Bool myDialog::CoreMessage(LONG id,const BaseContainer &msg)  
{  
  return GeDialog::CoreMessage(id,msg);  
}  
  
LONG myDialog::Message(const BaseContainer &msg,BaseContainer &result)  
{  
  
  return GeDialog::Message(msg,result);  
}  
  
  
  
///////////////////////// 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:  
                  myDialog *dlg = gNew myDialog;  
                  dlg->Open(DLG_TYPE_MODAL, TAG_PLUGIN_ID);  
                  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);  
}

Thanks for the help. 🍺

-ScottA