THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 06/10/2009 at 15:06, xxxxxxxx wrote:
The code:
> \> #include "c4d.h" \> \> const LONG CINDIGO_REAL_CUSTOMGUI = 1000001; //TODO: get plugin ID \> \> static LONG restypetable[] = { DA_REAL }; \> \> class CindigoRealDlg : public iCustomGui \> { \> INSTANCEOF(CindigoRealDlg, iCustomGui) \> private: \> BaseContainer m_settings; \> \> Real m_real; \> Bool m_tristate; \> \> public: \> CindigoRealDlg(const BaseContainer &settings;, CUSTOMGUIPLUGIN \*plugin) \> : iCustomGui(settings, plugin), m_real(), m_tristate(false), m_settings(settings) \> { \> \> } \> \> virtual void CustomGuiRedraw() \> { \> } \> \> virtual void DestroyWindow(void) \> { \> \> } \> \> virtual Bool CreateLayout (void) \> { \> AddEditNumberArrows(1000,0,80,0); \> \> return TRUE; \> } \> \> virtual Bool SupportLayoutSwitch() \> { \> return FALSE; \> } \> \> virtual Bool InitValues() \> { \> SetUnclampedReal(m_real); \> \> return TRUE; \> } \> \> void SetUnclampedReal(Real r) \> { \> SetReal(1000, r); \> String s = RealToString(r,-1,5); \> \> //if r == 0.0 set 0 \> if (r == 0.0) { \> s = "0"; \> } else { \> //cut of trailing zeros \> LONG i = 0; \> for(i = s.GetLength()-1; i > 0; i--) \> { \> if (s[i] != '0') break; \> } \> s = s.SubStr(0, i+1); \> } \> \> SetString(1000, s); \> } \> \> virtual LONG Message(const BaseContainer& msg, BaseContainer& result) \> { \> if ((msg.GetId() == BFM_ACTION) && msg.GetLong(BFM_ACTION_ID) == 1000) \> { \> if (msg.GetLong(BFM_ACTION_VALCHG) || msg.GetReal(BFM_ACTION_VALUE,MAXREAL) != MAXREAL) \> { \> m_real = msg.GetReal(BFM_ACTION_VALUE); \> \> SetUnclampedReal(m_real); \> \> return TRUE; //message processed \> } \> } \> \> return GeDialog::Message(msg,result); \> } \> \> virtual Bool Command(LONG id, const BaseContainer& msg) \> { \> switch (id) \> { \> case 1000: \> { \> BaseContainer m(msg); \> m.SetLong(BFM_ACTION_ID, GetId()); \> m.RemoveData(BFM_ACTION_VALUE); \> m.SetData(BFM_ACTION_VALUE, GetData().GetValue()); \> SendParentMessage(m); \> \> break; \> } \> } \> return TRUE; \> } \> \> virtual Bool SetData(const TriState<GeData> &tristate;) \> { \> m_real = tristate.GetValue().GetReal(); \> m_tristate = tristate.GetTri(); \> \> return TRUE; \> } \> \> virtual TriState<GeData> GetData() \> { \> GetReal(1000, m_real); \> return GeData(m_real); \> } \> }; \> \> class CindigoRealGui : public CustomGuiData \> { \> public: \> virtual LONG GetId() { return CINDIGO_REAL_CUSTOMGUI; } \> \> virtual CDialog\* Alloc(const BaseContainer &settings;) \> { \> CindigoRealDlg\* dlg = gNew CindigoRealDlg(settings, GetPlugin()); \> if (!dlg) return NULL; \> \> CDialog \*cdlg = dlg->Get(); \> if (!cdlg) return NULL; \> \> return cdlg; \> } \> \> virtual void Free(CDialog \*dlg, void \*userdata) \> { \> if (!dlg || !userdata) return; \> CindigoRealDlg \*sub = static_cast<CindigoRealDlg\*>(userdata); \> gDelete(sub); \> } \> \> #ifdef CINDIGO_C4D_VERSION_R115 \> virtual const CHAR \*GetResourceSym() \> #else \> virtual CHAR \*GetResourceSym() \> #endif \> { \> return "CINDIGO_REAL_GUI"; \> } \> \> virtual LONG GetResourceDataType(LONG \*&table;) \> { \> table = restypetable; \> return sizeof(restypetable)/sizeof(LONG); \> } \> }; \> \> \> \> Bool RegisterRealGUI() \> { \> static BaseCustomGuiLib mylib; \> ClearMem(&mylib;,sizeof(mylib)); \> FillBaseCustomGui(mylib); \> \> return InstallLibrary(CINDIGO_REAL_CUSTOMGUI, &mylib;, 1000, sizeof(mylib)) \> \> && \> \> RegisterCustomGuiPlugin("My String GUI", PLUGINFLAG_HIDE, gNew CindigoRealGui); \> } \>