home
portfolio
services
notebook
links
This way out

 

 

 

CINEMA 4D, Revision 6

 

COFFEE plugin tutorial
Your first dialog box

 

(a link will be available for part 8 of this tutorial soon)

coffee tutorial 1:  Introduction
coffee tutorial 2:  Programming basics
coffee tutorial 3:  The nuts and bolts of a plugin
coffee tutorial 4:  Your first dialog box
coffee tutorial 5:  A better dialog box
coffee tutorial 6:  Creating a house object
coffee tutorial 7:  Interactive house modeling
coffee tutorial 8:  International resources

 

 

For QuickStarters:

* copy and paste the listing text (below) to a simple text editor and save it as a plain text file under the name 'lesson4.cof' into the C4D "plugins" folder.

* restart c4d (or use the menu command "Reload Plugins")

* Open the window "Console"

* execute the plugin-menu command "coffee-lesson-4"

* this time we create a dialog box


The Listing:


const var cPluginID = 2000002;
var gDial;
// --- GeDialog
class oDialog : GeDialog
{ public:
oDialog();
CreateLayout();
}
oDialog::oDialog() { super(cPluginID); }
oDialog::CreateLayout()
{ SetTitle("coffee-lesson-4");
AddEditNumberArrows(0,BFH_FIT,80,0);
return TRUE;
}

// --- MenuPlugin
class oMenuPlugin : MenuPlugin
{ public:
oMenuPlugin();
GetID();
GetName();
GetHelp();
Execute(doc);
RestoreLayout(secret);
}
oMenuPlugin::oMenuPlugin() { super(); }
oMenuPlugin::GetID() { return cPluginID; }
oMenuPlugin::GetName() { return "coffee-lesson-4"; }
oMenuPlugin::GetHelp() { return "A Dialogbox"; }
oMenuPlugin::Execute(doc)
{ if (!gDial) gDial=new(oDialog);
gDial->Open(TRUE,-1,-1);
}
oMenuPlugin::RestoreLayout(secret)
{ if (!gDial) gDial=new(oDialog);
gDial->RestoreLayout(secret);
}

main()
{ Register(oMenuPlugin);
}

 

The Explanation:


class oDialog : GeDialog

In comparison to coffee-lesson-3 we have parented a new class for the dialog box.


oDialog::oDialog()

claims, that this dialog box belongs to our menu-plugin.


oDialog::CreateLayout()

The dialog box gets a name and one of the many input-elements. The best thing is to test and experiment with the original SDK-documentation from MAXON; chapter GUI classes. AddEditNumberArrows is one of the more complex elements. It shows a input-field with an up- and down-button.


AddEditNumberArrows(id,flags,initw,inith)

id:
You can edit the input-field with this number (compare: the "old" C.O.F.F.E.E. involved dialog boxes from numbers 0 to 9)

flags:
BFV_FIT is a C.O.F.F.E.E.- flag and means "Arrange elements vertically".

initw,inith:
is the horizontal and vertical space needed by the elements.


oMenuPlugin::Execute(doc)

The traditional println("Hallo") has certainly been removed. Now the programm-execution creates our self-written dialog box.


oMenuPlugin::RestoreLayout(secret)

Should be added basically. This funcion is needed when our dialog box has been added into a "users layout".

----------------------------------------
Text copyright © H. G. Seib 2000, HTML copyright © M. D. Abbott 2001

 

 


Vantage Graphics and Design Limited
9 Vicarage Lane, Harbury, LEAMINGTON SPA, Warwickshire CV33 9HA, UNITED KINGDOM
Telephone: 01926 614211 Fax: 01926 614226 ISDN: 01926 614210
E-mail: studio@vgd.co.uk

Page last updated: 05 July 2001