About
GeDialog is the base class for interface elements of Cinema 4D. An asynchronous (non-modal) dialog acts as a panel that can be added to the application layout or as a free floating window. In contrast a synchronous (modal) dialog blocks the application's main thread until it is closed. A custom dialog is added by creating a subclass of GeDialog. GeDialog is also the base class of iCustomGui which is used to create custom GUI elements for NodeData parameters.
Allocation
A GeDialog based window is typically owned by a CommandData plugin. This CommandData stores and opens the dialog instance.
{
private:
ExampleDialog _dialog;
public:
{
if (_dialog.IsOpen() == false)
else
_dialog.Close();
return true;
};
{
return _dialog.RestoreLayout(g_geDialogID, 0, secret);
};
static OpenExampleDialog* Alloc() { return NewObjClear(OpenExampleDialog); }
};
#define INSTANCEOF(X, Y)
Definition: c4d_baselist.h:38
Definition: c4d_basedocument.h:497
Definition: c4d_commanddata.h:65
virtual Bool RestoreLayout(void *secret)
virtual Bool Execute(BaseDocument *doc, GeDialog *parentManager)
Definition: c4d_gui.h:1150
maxon::Bool Bool
Definition: ge_sys_math.h:51
@ ASYNC
Non-modal (asynchronous) dialog.
const char * doc
Definition: pyerrors.h:226
The GeDialog is opened with GeDialog::Open(). The different types of dialogs are:
The GeDialog window can be closed with GeDialog::Close(). This will call GeDialog::AskClose() (see below).
GeDialog Based Classes
A custom window is created by implementing a subclass of GeDialog. This subclass can implement different virtual functions to define the layout and behaviour of the dialog.
Dialog setup:
{
SetTitle("Example Dialog"_s);
this->SetTimer(1000);
return true;
}
{
SetFloat(1000, 123.456);
return true;
}
@ BFH_SCALEFIT
Scale fit. BFH_SCALE|BFH_FIT.
Definition: gui.h:316
Messages and Interaction:
{
if (id == 1000)
{
}
}
{
{
{
break;
}
{
break;
}
}
}
Definition: c4d_basecontainer.h:48
virtual Bool Command(Int32 id, const BaseContainer &msg)
PyObject PyObject * result
Definition: abstract.h:43
maxon::Int32 Int32
Definition: ge_sys_math.h:56
@ BFM_INTERACTSTART
Definition: gui.h:924
@ BFM_INTERACTEND
Sent when user interaction ends.
Definition: gui.h:943
#define ApplicationOutput(formatString,...)
Definition: debugdiagnostics.h:204
const char const char * msg
Definition: object.h:438
Timed Actions:
Read-Only Properties
It is possible to check these GeDialog properties:
It is also possible to read the pixel ratio of the current screen:
if (bitmapButtonGUI)
{
if (bitmap)
{
const Float pixelRatio = GetPixelRatio();
if (pixelRatio == 1.0)
else
{
bitmapButtonGUI->
SetImage(bitmap,
true,
false);
}
}
}
PyCompilerFlags const char * filename
Definition: ast.h:15
Definition: ge_autoptr.h:37
Definition: c4d_string.h:41
maxon::Float Float
Definition: ge_sys_math.h:62
#define BASEBITMAP_DATA_GUIPIXELRATIO
Float.
Definition: c4d_basebitmap.h:104
@ OK
Image loaded/created.
Layout
Create Layout
The layout of a GeDialog - the arrangement of groups and gadgets - is defined in the implementation of GeDialog::CreateLayout(). This layout can be defined by creating the groups and gadgets individually or by loading a dialog resource file.
General functions to handle GeDialog gadgets are:
{
return false;
if (!LoadDialogResource(DLG_CUSTOM_DIALOG, nullptr, 0))
return false;
this->SetTitle("New Title"_s);
this->Enable(IDC_CUSTOM_CHECKBOX, false);
return true;
}
virtual Bool CreateLayout()
Menus
GeDialog based windows contain a menu bar. This menu bar can contain various sub-menus and also any kind of gadget in a special sub-group.
Menus are created with:
Sub-menus are added with these functions:
Menu items are added with these functions:
MenuFlushAll();
MenuSubBegin("Cinema 4D Commands"_s);
const Int32 saveAsCommandID = 12218;
const Int32 saveCommandID = 12098;
MenuAddCommand(saveAsCommandID);
MenuAddCommand(saveCommandID);
MenuSubEnd();
MenuSubBegin("Dialog Commands"_s);
MenuAddString(ID_COMMAND_A, "Action A"_s);
MenuAddSeparator();
MenuAddString(ID_COMMAND_B, "Action B"_s);
MenuSubEnd();
MenuFinished();
MenuInitString(ID_COMMAND_B, true, true);
It is possible to add arbitrary gadgets to a special sub-group of the menu bar:
GroupBeginInMenuLine();
GroupEnd();
GroupEnd();
@ BFH_RIGHT
Aligned to the right. 1<<4.
Definition: gui.h:313
Groups
The arrangement of elements of the dialog layout is defined with groups. Such groups can define rows and columns and can contain further sub-groups.
Groups are created with these functions:
GroupEnd();
GroupEnd();
GroupEnd();
GroupEnd();
GroupEnd();
GroupEnd();
@ BORDER_NONE
No border.
Definition: gui.h:256
@ BFH_LEFT
Aligned to the left. 1<<3.
Definition: gui.h:312
@ BFV_SCALEFIT
Scale fit. BFV_SCALE|BFV_FIT.
Definition: gui.h:308
The border style and spacing of groups can be defined with these functions:
GroupSpace(100, 0);
GroupBorderSpace(10, 10, 10, 10);
GroupEnd();
@ BFV_BORDERGROUP_CHECKBOX
Checkbox in title of a border group.
Definition: gui.h:195
@ BORDER_GROUP_IN
Group border inside.
Definition: gui.h:261
If the group flag BFV_GRIDGROUP_ALLOW_WEIGHTS is set the user can change the width/height of group's columns/rows. The size of columns/rows is stored as "weights" which can be stored.
See also BFM_WEIGHTS_CHANGED in GUI and Interaction Messages Manual.
AddStaticText(100, 0, 0, 10, "Left Column"_s, 0);
GroupEnd();
AddSeparatorV(1);
AddStaticText(200, 0, 0, 10, "Right Column"_s, 0);
GroupEnd();
GroupEnd();
GroupWeightsLoad(WEIGHT_GROUP, _weights);
@ BFV_GRIDGROUP_ALLOW_WEIGHTS
Allow the user to move the weights.
Definition: gui.h:199
The content of a group can be flushed and replaced with new gadgets:
LayoutFlushGroup(100);
LayoutChanged(100);
Helper class for GeDialog::BeginLayoutChange()
Definition: c4d_gui.h:1112
A scroll group allows to scroll the content of a group using the mouse-wheel:
- Note
- A scroll group must always contain another sub-group that stores the actual gadgets.
See also BFM_SETSTATUSBAR in Specific GUI Elements.
GroupEnd();
GroupEnd();
Py_ssize_t i
Definition: abstract.h:645
@ SCROLLGROUP_VERT
Allow the group to scroll vertically.
Definition: gui.h:441
@ SCROLLGROUP_BORDERIN
Display a small border around the scroll group.
Definition: gui.h:445
@ BFV_TOP
Aligned to the top. 1<<0.
Definition: gui.h:304
if (GetVisibleArea(scrollGroupID, &x1, &y1, &x2, &y2))
{
const Int32 height = y2 - y1;
SetVisibleArea(scrollGroupID, x1, 0, x2, height);
}
#define NOTOK
Definition: ge_sys_math.h:263
Note that GeDialog::GetItemDim will take scrollbars of a scroll group into account, while GeDialog::SetVisibleArea will not. When computing the scroll area of a scroll group, e.g., for centering a gadget inside the scroll group, this must be taken into account, as otherwise GeDialog::SetVisibleArea will on scroll frames that are larger than the visible area.
{
Int32 sgx, sgy, scrollWidth, scrollHeight;
Int32 gx, gy, gadgetWidth, gadegtHeight;
if (!GetItemDim(idScrollGroup, &sgx, &sgy, &scrollWidth, &scrollHeight) ||
!GetItemDim(idGadget, &gx, &gy, &gadgetWidth, &gadegtHeight))
Int32 svax1, svay1, svax2, svay2;
if (!GetVisibleArea(idScrollGroup, &svax1, &svay1, &svax2, &svay2))
"Could not get visible area of scroll group."_s);
Int32 dx = (scrollWidth - (svax2 - svax1));
Int32 dy = (scrollHeight - (svay2 - svay1));
Int32 realScrollWidth = scrollWidth - dx;
Int32 realScrollHeight = scrollHeight - dy;
Int32 x =
static_cast<Int32>(((gadgetWidth - realScrollWidth) * .5));
Int32 y =
static_cast<Int32>(((gadegtHeight - realScrollHeight) * .5));
if (!SetVisibleArea(idScrollGroup,
x, y,
x + realScrollWidth, y + realScrollHeight))
"Could not set visible area of scroll group."_s);
}
PyObject * x
Definition: bytesobject.h:38
return OK
Definition: apibase.h:2735
#define MAXON_SOURCE_LOCATION
Definition: memoryallocationbase.h:67
#define iferr_scope
Definition: resultbase.h:1389
Gadget IDs
A gadget that is part of a GeDialog layout can be identified in two ways:
- With a GadgetPtr. This GadgetPtr is returned by functions creating the gadget in question.
- With the gadget ID. This gadget ID is used with the function that creates the gadget in question.
if (textA)
SetString(textA, "This is some text."_s);
SetString(ID_TEXT_B, "This is some other text."_s);
Represents a gadget in a dialog.
Definition: c4d_gui.h:108
Default Gadgets
Default GUI gadgets can be added to a GeDialog with these member functions:
Number related gadgets:
Text related gadgets:
Color related gadgets:
Buttons:
Seperators:
Further gadgets are:
private:
public:
{
SetTitle("Listview Dialog"_s);
return true;
}
{
return true;
}
void SetBool(Int32 id, Bool b)
Definition: c4d_basecontainer.h:580
void SetString(Int32 id, const maxon::String &s)
Definition: c4d_basecontainer.h:651
void SetInt32(Int32 id, Int32 l)
Definition: c4d_basecontainer.h:587
void DataChanged()
Forces a recalculation. Called when the list view data has been changed.
Bool AttachListView(GeDialog *cd, Int32 id)
A class for simple list views. See ListView.cpp SDK example.
Definition: c4d_listview.h:148
Bool SetLayout(Int32 columns, const BaseContainer &data)
Bool SetProperty(Int32 id, Int32 val)
Bool SetItem(Int32 id, const BaseContainer &data)
@ LV_COLUMN_CHECKBOX
Checkbox.
Definition: ge_prepass.h:5430
@ LV_COLUMN_TEXT
Text.
Definition: ge_prepass.h:5427
#define SLV_MULTIPLESELECTION
Multiple selection allowed.
Definition: c4d_listview.h:141
const char const char const char int line
Definition: object.h:440
#define NAME
Definition: token.h:14
A multi-line text edit field can be created and configured with these functions:
See also Specific GUI Elements.
SetString(4000, "import c4d\n\nprint(\"hello world\")\n"_s);
SetMultiLinePos(4000, 4, 0);
@ DR_MULTILINE_MONOSPACED
Monospaced font.
Definition: gui.h:319
@ DR_MULTILINE_PYTHON
Python line return handling.
Definition: gui.h:326
@ DR_MULTILINE_SYNTAXCOLOR
Python syntax highlighting.
Definition: gui.h:320
@ DR_MULTILINE_STATUSBAR
Display a statusbar with the cursor position.
Definition: gui.h:321
@ DR_MULTILINE_WORDWRAP
Word wrap multi-line field.
Definition: gui.h:327
@ DR_MULTILINE_HIGHLIGHTLINE
Highlight lines.
Definition: gui.h:322
Several gadgets can contain multiple child-elements, typically for selection purposes:
AddComboBox(5000,
BFH_LEFT, 100, 10,
false);
AddChild(5000, 0, "Child 0"_s);
AddChild(5000, 1, "Child 1"_s);
AddChild(5000, 2, "Child 2"_s);
AddComboButton(6000,
BFH_LEFT, 100, 10, 0);
AddChildren(6000, children);
AddComboBox(5001,
BFH_LEFT, 100, 10,
false);
AddChild(5001, 0, "Cube &" + iconData1Address + "&");
AddChild(5001, 1, "Sphere &" + iconData2Address + "&");
static String HexToString(UInt32 v, Bool prefix0x=true)
Definition: c4d_string.h:480
maxon::UInt UInt
Definition: ge_sys_math.h:61
#define Ocube
Cube.
Definition: ge_prepass.h:1119
#define Osphere
Sphere.
Definition: ge_prepass.h:1120
Bool GetIcon(Int32 lIconID, IconData *pData)
Represents a single icon in a large bitmap array.
Definition: operatingsystem.h:773
Further interaction with gadgets is typically done by sending messages to the gadget:
See also GUI and Interaction Messages Manual.
PyCompilerFlags * flags
Definition: ast.h:14
Int32 SizePix(Int32 pixels)
Definition: c4d_gui.h:3235
#define CUSTOMGUI_PROGRESSBAR
Progress bar.
Definition: lib_description.h:227
@ BFV_FIT
Fit. BFV_BOTTOM|BFV_TOP.
Definition: gui.h:306
const char * m
Definition: abstract.h:692
maxon::Vec3< maxon::Float64, 1 > Vector
Definition: ge_math.h:141
@ BFM_STATUSBAR_PROGRESSON
Bool Statusbar active.
Definition: gui.h:840
@ BFM_STATUSBAR_TINT_COLOR
Int32 Color ID for the status bar, or as RGB value (Vector).
Definition: gui.h:846
@ BFM_SETSTATUSBAR
To set a statusbar (e.g. inside a SCROLLGROUP (dialog element)):
Definition: gui.h:838
@ BFM_STATUSBAR_PROGRESS
Float Between 0.0 and 1.0.
Definition: gui.h:842
Images
There is no default gadget to display an image (BaseBitmap) in a GeDialog. Two possible solutions are:
if (bitmapButtonGUI)
{
bitmapButtonGUI->
SetImage(buttonBitmap,
true,
false);
}
#define BITMAPBUTTON_BUTTON
Definition: customgui_bitmapbutton.h:35
@ BFH_CENTER
Centered horizontally.
Definition: gui.h:311
unsigned long Py_ssize_t width
Definition: pycore_traceback.h:88
Custom GUI Elements
Further gadgets are implemented as custom GUI elements. Such custom GUI elements have to be created using their type ID.
See Custom GUI Elements.
- Note
- A custom GUI is typically configured using a BaseContainer given to GeDialog::AddCustomGui(). Only the parameters accessible with the custom GUI class itself can be changed afterwards.
-
Custom GUI element instances are based on BaseCustomGui. Using this base class it is possible to further edit the instance.
-
Some "custom GUIs" are no real custom GUI elements but are hardcoded in the DescriptionCustomGui and cannot be used in a GeDialog (e.g. CUSTOMGUI_VECTOR).
void*
const customGui = AddCustomGui(11000, customGuiID,
String(),
BFH_SCALEFIT, 100, 50, hlSettings);
if (linkGustomGui != nullptr)
{
const String linkTitle {
"MAXON" };
const String url {
"https://www.maxon.net" };
}
Definition: customgui_hyperlink.h:71
Bool SetLinkString(const maxon::String *pStrLink, const maxon::String *pStrText)
#define CUSTOMGUI_HYPER_LINK_STATIC
Hyper link custom GUI ID.
Definition: customgui_hyperlink.h:24
#define HYPERLINK_IS_LINK
Bool true for hyperlinks, static text otherwise.
Definition: customgui_hyperlink.h:34
if (gradientGUI)
{
if (gradientData)
{
gradientData->InsertKnot(firstKnot);
gradientData->InsertKnot(secondKnot);
triStateData.
Add(geData);
gradientGUI->
SetData(triStateData);
}
}
Bool SetData(const TriState< GeData > &tristate)
Definition: customgui_base.h:108
Definition: c4d_gedata.h:83
void SetCustomDataType(const DATATYPE &v)
Definition: c4d_gedata.h:747
Definition: customgui_gradient.h:327
Bool SetGradient(Gradient *grad)
Definition: customgui_gradient.h:121
Definition: c4d_gui.h:983
void Add(const TYPE &val)
Definition: c4d_gui.h:1029
#define CUSTOMGUI_GRADIENT
Gradient custom GUI ID.
Definition: customgui_gradient.h:22
Col3< Float, 1 > Color
Definition: vector.h:84
Represents a knot in a gradient.
Definition: gradient.h:40
Float pos
Position.
Definition: gradient.h:43
Color col
Color.
Definition: gradient.h:41
GeUserAreas
GeUserArea is the base class for all dialog gadgets. A subclass of GeUserArea defines a new custom gadget. Such a custom gadget can be added to the GeDialog.
See also GeUserArea Manual.
if (userarea)
this->AttachUserArea(_userArea, userarea);
Sub-Dialogs
It is possible to add a sub-dialog to a given GeDialog based window. Such a sub-dialog is based on SubDialog which in return is also based on GeDialog.
AttachSubDialog(&_subDialog, 14000);
For convenience it is possible to add a default group of gadgets to the dialog. This group can contain the standard buttons "OK" or"Cancel". See DLG.
@ DLG_OK
OK button.
Definition: ge_prepass.h:3915
@ DLG_CANCEL
Cancel button.
Definition: ge_prepass.h:3916
{
switch (id)
{
{
break;
}
}
return true;
}
#define IDC_OK
Definition: c4d_gui.h:15
Pixel Size
For most gadgets it is possible to define the size of the gadget. To define this size one must use these functions to bake the pixel size:
- SizePix(): Bakes the given pixel size.
- SizeChr(): Bakes the given character count into a size.
- SizePixChr(): Bakes the given pixel size and character count.
Layout Flags
The position and behaviour of groups and gadgets is defined with these flags:
Horizontal alignment:
Vertical alignment:
GroupEnd();
GroupEnd();
GroupEnd();
GroupEnd();
Gadget Values
GUI elements are used to display values and to allow user interaction to change these values. For default GUI elements there are three kinds of functions to edit these values:
- Plain getter/setter: Simple functions that allow to edit the value displayed in the given gadget.
- Container getter/setter: Functions that access the value from a given BaseContainer.
- TriState setter: Functions that set the value using the given TriState object (see TriState Manual)
Editing Boolean values:
Editing integer values:
Editing float values:
Editing Vector values:
Editing Time values:
Editing String values:
Editing Filename values: These functions just wrap around GeDialog::GetString() and GeDialog::SetString().
Editing Color values:
SetString(1000, "Hello World"_s);
SetInt32(2000, numberData);
Interaction
Messages
A GeDialog receives messages from both its gadget and from the Cinema 4D GUI. They are sent to GeDialog::Message().
See GUI and Interaction Messages Manual.
{
{
{
return true;
}
}
break;
}
@ BFM_INPUT_KEYBOARD
Keyboard.
Definition: gui.h:711
@ BFM_INPUT
A dialog/user area receives this message if any mouse or keyboard input is received....
Definition: gui.h:704
@ BFM_INPUT_CHANNEL
Int32 Contains the key or mouse button. See also KEY.
Definition: gui.h:714
@ BFM_INPUT_DEVICE
Int32 Device:
Definition: gui.h:709
@ KEY_F1
Definition: gui.h:85
Interaction with Gadgets
When a gadget is changed it sends a message to the parent GeDialog. This message can be caught in GeDialog::Command().
See GUI and Interaction Messages Manual.
AddButton(ID_BUTTON_ACTION,
BFH_SCALEFIT, 0, 20,
"Button"_s);
{
if (id == ID_BUTTON_ACTION)
{
}
When a gadget is changed one might need to know the state of the mouse or keyboard when this happened.
if (id == 1000)
{
if (GetString(1000,
value))
{
{
}
}
}
PyObject * value
Definition: abstract.h:715
Bool GetInputState(Int32 askdevice, Int32 askchannel, BaseContainer &res)
PyArena _PyASTOptimizeState * state
Definition: compile.h:99
@ BFM_INPUT_VALUE
Int32 Value of the input channel (true/false or a Int32 value, e.g. for scroll wheel data).
Definition: gui.h:724
@ KEY_ENTER
Definition: gui.h:70
{
{
{
{
{
{
break;
const Bool xPosChanged = currentX != xPos;
const Bool yPosChanged = currentY != yPos;
if (xPosChanged || yPosChanged)
{
xPos = currentX;
yPos = currentY;
}
}
KillEvents();
return true;
}
}
break;
}
}
}
Py_UCS4 * res
Definition: unicodeobject.h:1113
@ BFM_INPUT_MOUSELEFT
Left mouse button.
Definition: gui.h:715
@ BFM_INPUT_MOUSE
Mouse.
Definition: gui.h:710
@ BFM_INPUT_Y
Float Y value.
Definition: gui.h:727
@ BFM_INPUT_X
Float X value.
Definition: gui.h:726
Drag and Drop
The user can drag and drop various elements onto a GeDialog. The GeDialog is informed about this event through messages sent to GeDialog::Message(). These functions are used to react to these messages:
See also Drag and Drop.
{
{
{
if (CheckDropArea(ID_TEXT_NAME,
msg,
true,
true))
{
void* object = nullptr;
if (!GetDragObject(
msg, &
type, &
object))
return false;
if (typeIsAtom && isFinished)
{
if (atomArray && atomArray->
GetCount() > 0)
{
{
SetString(ID_TEXT_NAME, baselist->
GetName());
}
}
return true;
}
else
{
}
}
}
}
}
PyObject * object
Definition: asdl.h:7
Definition: c4d_baselist.h:1796
Int32 GetCount() const
Definition: c4d_baselist.h:1827
C4DAtom * GetIndex(Int32 idx) const
Definition: c4d_baselist.h:1842
Definition: c4d_baselist.h:2377
String GetName() const
Definition: c4d_baselist.h:2544
Definition: c4d_baselist.h:1521
#define atom
Definition: graminit.h:72
@ BFM_DRAG_FINISHED
Bool Drag finished.
Definition: gui.h:795
@ DRAGTYPE_ATOMARRAY
AtomArray.
Definition: gui.h:784
@ BFM_DRAGRECEIVE
Drag receive. (See DragAndDrop.)
Definition: gui.h:772
static const Int32 MOUSE_POINT_HAND
Point hand cursor.
Definition: ge_prepass.h:2711
static const Int32 MOUSE_FORBIDDEN
Forbidden cursor.
Definition: ge_prepass.h:2700
#define Tbaselist2d
2D list.
Definition: ge_prepass.h:996
PyObject ** type
Definition: pycore_pyerrors.h:34
Core Messages
A GeDialog can also receive core messages. These messages are sent to inform the dialog about global events e.g. when something in the active document changed. The messages are sent to GeDialog::CoreMessage().
See also GUI and Interaction Messages Manual and Core Messages Manual.
{
switch (id)
{
{
if (!CheckCoreMessage(
msg))
break;
this->InitValues();
break;
}
}
}
{
SetString(1000, "---"_s);
return true;
if (object == nullptr)
return true;
SetString(1000,
object->GetName());
return true;
}
BaseDocument * GetActiveDocument()
Definition: c4d_baseobject.h:248
virtual Bool CoreMessage(Int32 id, const BaseContainer &msg)
#define EVMSG_CHANGE
Sent by EventAdd().
Definition: ge_prepass.h:2746
GeDialog Parent
A GeDialog can be the base of a sub-dialog or a custom GUI element. In this case it must send messages to a parent dialog. The typical use case is a custom GUI element (based on CustomGuiData, iCustomGui) that has to inform the parent dialog that a stored value has changed.
const char * message
Definition: pyerrors.h:189
@ BFM_ACTION_VALUE
GeData Action value.
Definition: gui.h:746
@ BFM_ACTION_ID
Int32 ID of the dialog element that triggered the action.
Definition: gui.h:745
@ BFM_ACTION
One of the child elements made any action:
Definition: gui.h:744
Utility
Coordinates
These utility functions allow to access the dimensions of a gadget or to transfer given coordinates into various spaces:
if (id == 4000)
{
GetItemDim(
id, &
x, &y, &w, &h);
}
Int32 ShowPopupMenu(CDialog *cd, Int32 screenx, Int32 screeny, const BaseContainer &bc, Int32 flags=POPUP_RIGHT|POPUP_EXECUTECOMMANDS|POPUP_ALLOW_FILTERING, Int32 *res_mainid=nullptr)
GeData * InsData(Int32 id, const GeData &n)
Definition: c4d_basecontainer.h:258
const Class< R > & Get(const Id &cls)
Definition: objectbase.h:2073
Colors
Color related functions are:
@ COLOR_TEXT_EDIT
Definition: c4d_colors.h:108
Further Reading