CustomGuiData Class Referenceabstract

#include <c4d_customguidata.h>

Inheritance diagram for CustomGuiData:

Detailed Description

A data class for creating custom GUIs for data types. These can be used in descriptions for the Attribute Manager.
Use RegisterCustomGuiPlugin() to register the custom GUI plugin.

Note
Even if a library is not created it is needed to call InstallLibrary() for a dummy library during registration:
Bool RegisterExampleDataTypeGui()
{
static BaseCustomGuiLib mylib;
ClearMem(&mylib, sizeof(mylib));
if (!InstallLibrary(MYCUSTOMGUI_ID, &mylib, 1000, sizeof(mylib)))
return false;
return RegisterCustomGuiPlugin("My Custom GUI", 0, NewObj(MyCustomGui));
}
Bool RegisterCustomGuiPlugin(const maxon::String &str, Int32 info, CustomGuiData *dat)
Bool InstallLibrary(Int32 id, C4DLibrary *lib, Int32 version, Int32 size)
void ClearMem(void *d, Int size, Int32 value=0)
Definition: c4d_memory.h:53
void FillBaseCustomGui(BaseCustomGuiLib &lib)
maxon::Bool Bool
Definition: ge_sys_math.h:51
#define NewObj(T,...)
Definition: newobj.h:108

Public Member Functions

virtual Int32 GetId ()=0
 
virtual CDialog * Alloc (const BaseContainer &settings)=0
 
virtual void Free (CDialog *dlg, void *userdata)=0
 
virtual const CharGetResourceSym ()=0
 
virtual CustomPropertyGetProperties ()
 
virtual Int32 GetResourceDataType (Int32 *&table)
 
CUSTOMGUIPLUGIN * GetPlugin ()
 
- Public Member Functions inherited from BaseData
virtual ~BaseData ()
 
void Destructor ()
 

Member Function Documentation

◆ GetId()

virtual Int32 GetId ( )
pure virtual

Called to get the plugin ID of the custom GUI.

Returns
A unique plugin ID. Must be obtained from http://www.plugincafe.com

◆ Alloc()

virtual CDialog* Alloc ( const BaseContainer settings)
pure virtual

Called to allocate a sub-dialog for the custom GUI.
Normally this method override should look like this:

virtual CDialog* Alloc(const BaseContainer& settings)
{
T* dlg = NewObj(T(settings, GetPlugin()));
if (!dlg)
return nullptr;
CDialog *cdlg = dlg->Get();
if (!cdlg)
return nullptr;
return cdlg;
}
Definition: c4d_basecontainer.h:48
CUSTOMGUIPLUGIN * GetPlugin()
virtual CDialog * Alloc(const BaseContainer &settings)=0

In the above code T stands for a type derived from iCustomGui.

Parameters
[in]settingsThe settings for the GUI. (Using the IDs defined by GetProperties().)
Returns
The allocated sub-dialog.

◆ Free()

virtual void Free ( CDialog *  dlg,
void *  userdata 
)
pure virtual

Called to free sub-dialogs allocated by Alloc().
Normally this method override should look like this:

virtual void Free(CDialog *dlg, void *userdata)
{
if (!dlg || !userdata)
return;
T* sub = static_cast<T*>(userdata);
DeleteObj(sub);
}
virtual void Free(CDialog *dlg, void *userdata)=0
#define DeleteObj(obj)
Definition: newobj.h:159

In the above code T stands for a type derived from iCustomGui.

Parameters
[in,out]dlgThe sub-dialog to free.
[in]userdataThe user data.

◆ GetResourceSym()

virtual const Char* GetResourceSym ( )
pure virtual

Called to get the symbol to use in resource files, for example "GRADIENT".

Note
Only 7-bit ASCII characters are allowed, hence the Char type.
Returns
A pointer to a global const Char* string with the resource symbol.

◆ GetProperties()

virtual CustomProperty* GetProperties ( )
virtual

Called to get the properties that the custom GUI accepts in resource files.

See also
CustomProperty.
Returns
A pointer to a global array of CustomProperty elements, ended with a CUSTOMTYPE::END property:
CustomProperty bitmapbuttonprops[] =
{
{ CUSTOMTYPE::END, 0, nullptr }
};
#define BITMAPBUTTON_BUTTON
Definition: customgui_bitmapbutton.h:35
#define BITMAPBUTTON_BORDER
Definition: customgui_bitmapbutton.h:33
@ FLAG
Bool data. (Either the property is there or not.)
@ END
End marker.
Definition: c4d_customguidata.h:114

◆ GetResourceDataType()

virtual Int32 GetResourceDataType ( Int32 *&  table)
virtual

Called to return the IDs of compatible data types for the custom GUI.

See also
CustomDataTypeClass::GetConversionsFrom.
Parameters
[out]tableSet this to point to a global array with the IDs of compatible data types for the custom GUI.
Returns
The length of the array pointed by table, or 0 if table has not been set.

◆ GetPlugin()

CUSTOMGUIPLUGIN* GetPlugin ( )

Gets the plugin structure for the custom GUI.

Returns
The custom GUI plugin structure. Cinema 4D owns the pointed plugin structure.