Main Index : Reference :
class GeDialog : GeUserDialog
{
public:
GeDialog();
// Overload for easy message handling
[bool] CreateLayout();
[bool] Init();
[bool] CoreMessage([int] id, [BaseContainer] msg);
[bool] Command([int] id, [BaseContainer] msg);
[bool] AskClose();
[bool] Timer([BaseContainer] msg);
[BaseContainer] DragMessage([BaseContainer] msg);
}
This class is especially designed for all the users who don't want to care about messages. Just overload some of the functions below and fill in your custom code.
[bool] CreateLayout();
Overload this function to define the layout of the dialog. Either with the preferred LoadDialogResource()
function or with the manual Add*()
functions of the GeUserDialog
class. Return TRUE
if successful.
[bool] Init();
Called when the dialog is initialized by the GUI. Overload this function to initialize local variables and the gadgtes used. Return TRUE
if successful.
[bool] CoreMessage([int] id, [BaseContainer] msg);
Overload this function if you want to react to C4D core messages. Possible message ids are:
Message | Explanation |
NEW_DOCUMENT |
New active document |
DOCUMENT_CHANGED |
Something changed in the active document |
NEW_ACTIVE_OBJECT |
New active object selected |
ACTIVE_OBJECT_CHANGED |
The active object changed |
REDRAW_ALL |
Everything is to be redrawn |
TIMELINE_CHANGED |
Something changed in the time line |
MATERIAL_CHANGED |
The active material changed |
NEW_ACTIVE_TAG |
New active tag selected |
The original message is stored in msg
.
Example: RotateIt.cof
[bool] Command([int] id, [BaseContainer] msg);
Whenever the user clicks on a gadget and/or changes its value this function will be called. Overload it to handle such events. The id of the gadget is stored in id
. The original message is stored in msg
.
[bool] AskClose();
If the user wants to close the dialog this function will be called. Overload it to avoid closing the dialog if an error situation has occured. If one returns FALSE
everything will be as usual, but if one returns TRUE
the dialog won't close. This function is especially useful in combination with the GeModalDialog
class for handling wrong user input before leaving the dialog.
[bool] Timer([BaseContainer] msg);
If one subscribes to the timer event using SetTimer(x)
, this function is called every xth millisecond. The original message is stored in msg
.
[BaseContainer] DragMessage([BaseContainer] msg);
Overload this function to be able to receive drag and drop messages. Within this function there are several possibilities. First one should check if this is a drag lost event:
if (msg->GetData(BFM_DRAG_LOST))
{
// The dialog is no longer the current drag window
// so one can reset/remove any help lines/texts.
}
In a similar way one can check if the drag operation was finished:
if (msg->GetData(BFM_DRAG_FINISHED))
{
// The user has dropped the dragged
// object somewhere in this dialog.
}
There are two ways to find out what the drag destination is. The first is to get the coordinates of the drag event directly with GetDragPosition()
:
var x = GetDragPosition(msg, 0);
var y = GetDragPosition(msg, 1);
The second is to use the convenience function CheckDropArea()
to check the event's coordinates against a certain gadget:
if (CheckDropArea(gadgetid, msg))
{
// The drag position is within the
// gadget with the id 'gadgetid'.
}
Remember that it is possible to check against groups as well, so that the sub-components aren't checked unnecessarily:
if (CheckDropArea(MAIN_GROUP, msg))
{
if (CheckDropArea(SUB_1, msg)) {}
if (CheckDropArea(SUB_2, msg)) {}
...
}
The dragged object is accessed with GetDragObject()
:
var obj = GetDragObject(msg);
Finally, if one wants to indicate to the user what will happen if the dragged object is dropped at this location, one can tell C4D to change the mouse cursor. This is done like this:
var result = new(BaseContainer, BFM_DRAGRESULT);
result->SetData(BFM_DRAGRESULT_CURSOR, MOUSE_POINT_HAND);
return result;
All the cursors from SetMousePointer()
can be used.
Example: GuiDemo.cof