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.
class OpenExampleDialog : public CommandData
{
private:
ExampleDialog _dialog;
public:
Bool Execute(BaseDocument*
doc, GeDialog* parentManager)
{
if (_dialog.IsOpen() == false)
else
_dialog.Close();
return true;
};
Bool RestoreLayout(
void* secret)
{
return _dialog.RestoreLayout(g_geDialogID, 0, secret);
};
static OpenExampleDialog* Alloc() { return NewObjClear(OpenExampleDialog); }
};
#define INSTANCEOF(X, Y)
Definition: c4d_baselist.h:49
ASYNC
Asynchronous thread.
Definition: ge_prepass.h:1
maxon::Bool Bool
Definition: ge_sys_math.h:46
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:
- GeDialog::CreateLayout(): Creates the dialog layout, see Create Layout.
- GeDialog::InitValues(): Initializes the values stored and displayed in the GeDialog.
- GeDialog::DestroyWindow(): Called when the dialog is temporarily closed; GeDialog::CreateLayout() will be called when the dialog is restored.
{
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:
- GeDialog::CoreMessage(): Receives core messages, see Core Messages Manual.
- GeDialog::Command(): Receives commands from the dialog's GUI elements.
- GeDialog::Message(): Receives various GUI and interaction messages, see GUI and Interaction Messages Manual.
- GeDialog::AskClose(): Called when the dialog should be closed.
{
if (id == 1000)
{
}
return GeDialog::Command(
id,
msg);
}
{
{
{
break;
}
{
break;
}
}
}
PyObject PyObject * result
Definition: abstract.h:43
@ BFM_INTERACTSTART
Definition: gui.h:926
@ BFM_INTERACTEND
Sent when user interaction ends.
Definition: gui.h:945
#define ApplicationOutput(formatString,...)
Definition: debugdiagnostics.h:204
maxon::Int32 Int32
Definition: ge_sys_math.h:51
const char const char * msg
Definition: object.h:438
Timed Actions:
- GeDialog::Timer(): Called in intervals set with GeDialog::SetTimer().
void Timer(
const BaseContainer&
msg)
{
}
Read-Only Properties
It is possible to check these GeDialog properties:
- GeDialog::IsOpen(): Returns true if the dialog is currently open.
- GeDialog::IsVisible(): Returns true if the dialog is visible.
- GeDialog::CheckClose(): Returns true if the dialog can be closed.
It is also possible to read the pixel ratio of the current screen:
- GeDialog::GetPixelRatio(): Returns the screen pixel ratio to indicate Retina displays.
BitmapButtonCustomGui* const bitmapButtonGUI = static_cast<BitmapButtonCustomGui*>(customGUI);
if (bitmapButtonGUI)
{
AutoAlloc<BaseBitmap> bitmap;
if (bitmap)
{
const Float pixelRatio = GetPixelRatio();
if (pixelRatio == 1.0)
else
const String fullFileName = GetFullFilename(
filename);
{
bitmapButtonGUI->SetImage(bitmap, true, false);
}
}
}
PyCompilerFlags const char * filename
Definition: ast.h:15
OK
User has selected a font.
Definition: customgui_fontchooser.h:0
#define BASEBITMAP_DATA_GUIPIXELRATIO
::Float.
Definition: c4d_basebitmap.h:103
maxon::Float Float
Definition: ge_sys_math.h:57
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.
- GeDialog::LoadDialogResource(): Loads and applies a dialog resource file. See Resource Files Manual.
- GeDialog::SetTitle(): Sets the title of the dialog window.
General functions to handle GeDialog gadgets are:
- GeDialog::Activate(): Sets the focus to the given gadget.
- GeDialog::IsActive(): Returns true if the given gadget has the focus.
- GeDialog::RemoveElement(): Removes the given gadget from the layout.
- GeDialog::HideElement(): Hides the given gadget.
- GeDialog::Enable(): Enables or disables the given gadget.
- GeDialog::IsEnabled(): Returns true if the given gadget is enabled.
{
if (!GeDialog::CreateLayout())
return false;
if (!LoadDialogResource(DLG_CUSTOM_DIALOG, nullptr, 0))
return false;
this->SetTitle("New Title"_s);
this->Enable(IDC_CUSTOM_CHECKBOX, false);
return true;
}
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:
- GeDialog::MenuFlushAll(): Flushes the content of the menu bar.
- GeDialog::MenuFinished(): Has to be called when all menus and all items have been added.
- GeDialog::MenuSetResource(): Loads the menu from a given menu ID.
Sub-menus are added with these functions:
- GeDialog::MenuSubBegin(): Adds a new sub-menu.
- GeDialog::MenuSubEnd(): Closes the current sub-menu.
Menu items are added with these functions:
- GeDialog::MenuAddCommand(): Adds a command item referencing a Cinema 4D command. See also Command Utility Manual.
- GeDialog::MenuAddString(): Adds a string item. GeLoadString() is used to load strings from *.str files.
- GeDialog::MenuAddSeparator(): Adds a separator.
- GeDialog::MenuInitString(): Sets the checked and enabled state of menu items.
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:
- GeDialog::GroupBeginInMenuLine(): Begins a sub-group on the right side 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:
- GeDialog::GroupBegin(): Begins a new group. See flags BFV_GROUP.
- GeDialog::GroupEnd(): Closes the current group.
- GeDialog::TabGroupBegin(): Begins a new tab group.
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:
- GeDialog::GroupSpace(): Defines the space between elements inside the group.
- GeDialog::GroupBorderSpace(): Defines the space around the group.
- GeDialog::GroupBorder(): Defines the border type of the current group. See also BORDER.
- GeDialog::GroupBorderNoTitle(): Defines the border type of the current group without displaying the title. See also BORDER.
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.
- GeDialog::GroupWeightsSave(): Retrieves the weights of the given group.
- GeDialog::GroupWeightsLoad(): Sets the weights of the given group.
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:
- GeDialog::LayoutFlushGroup(): Removes all gadgets from the given group and re-starts this group.
- GeDialog::LayoutChanged(): Notifies the dialog that the layout has changed.
- GeDialog::LayoutChangedNoRedraw(): Notifies the dialog that the layout has changed without redrawing the dialog.
- GeDialog::BeginLayoutChange(): Returns a UpdateDialogHelper object to flush and re-layout the given gadget.
- GeDialog::LayoutFlushDisableRedraw(): Used to flush a group.
LayoutFlushGroup(100);
LayoutChanged(100);
UpdateDialogHelper updateDialog = BeginLayoutChange(1000, true);
updateDialog.CommitChanges();
A scroll group allows to scroll the content of a group using the mouse-wheel:
- GeDialog::ScrollGroupBegin(): Begins a scrollable group.
- GeDialog::GetVisibleArea(): Gets the visible area of the given scroll group.
- GeDialog::SetVisibleArea(): Sets the visible area of the given scroll group.
- 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:442
@ SCROLLGROUP_BORDERIN
Display a small border around the scroll group.
Definition: gui.h:446
@ 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:258
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:2740
#define MAXON_SOURCE_LOCATION
Definition: memoryallocationbase.h:69
#define iferr_scope
Definition: resultbase.h:1396
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.
C4DGadget*
const textA = AddEditText(ID_TEXT_A,
BFH_SCALEFIT, 0, 10, 0);
if (textA)
SetString(textA, "This is some text."_s);
SetString(ID_TEXT_B, "This is some other text."_s);
Default Gadgets
Default GUI gadgets can be added to a GeDialog with these member functions:
Number related gadgets:
- GeDialog::AddEditNumber(): Adds a number field.
- GeDialog::AddEditNumberArrows(): Adds a number field with arrows.
- GeDialog::AddEditSlider(): Adds a number field with a slider.
- GeDialog::AddSlider(): Adds a slider.
Text related gadgets:
- GeDialog::AddStaticText(): Adds a static text field.
- GeDialog::AddEditText(): Adds an editable text field
Color related gadgets:
- GeDialog::AddColorField(): Adds a color field.
- GeDialog::AddColorChooser(): Adds a color chooser.
Buttons:
- GeDialog::AddButton(): Adds a button.
- GeDialog::AddArrowButton(): Adds a small arrow button.
Seperators:
- GeDialog::AddSeparatorH(): Adds a horizontal separator.
- GeDialog::AddSeparatorV(): Adds a vertical separator.
Further gadgets are:
- GeDialog::AddCheckbox(): Adds a checkbox.
- GeDialog::AddEditShortcut(): Adds a shortcut edit field.
- GeDialog::AddListView(): Adds a list view (SimpleListView).
private:
SimpleListView _listview;
public:
{
SetTitle("Listview Dialog"_s);
_listview.AttachListView(this, 1000);
return true;
}
{
BaseContainer layout;
_listview.SetLayout(2, layout);
BaseContainer data;
data.SetBool(CHECKBOX, true);
data.SetString(
NAME,
"Element A"_s);
_listview.SetItem(
line, data);
data.SetBool(CHECKBOX, false);
data.SetString(
NAME,
"Element B"_s);
_listview.SetItem(
line, data);
_listview.DataChanged();
return true;
}
@ LV_COLUMN_CHECKBOX
Checkbox.
Definition: ge_prepass.h:5452
@ LV_COLUMN_TEXT
Text.
Definition: ge_prepass.h:5449
#define SLV_MULTIPLESELECTION
Multiple selection allowed.
Definition: c4d_listview.h:140
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:
- GeDialog::AddMultiLineEditText(): Adds a multi line edit field.
- GeDialog::SetMultiLineMode(): Sets the script mode of the given field, see ::SCRIPTMODE.
- GeDialog::SetMultiLineLock(): Locks the given field.
- GeDialog::SetMultiLinePos(): Sets the position of the cursor in the given field.
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:
- GeDialog::AddRadioGroup(): Adds a radio group.
- GeDialog::AddRadioButton(): Adds a radio button.
- GeDialog::AddRadioText(): Adds a radio text field.
- GeDialog::AddComboBox(): Adds a combo box.
- GeDialog::AddComboButton(): Adds a combo button.
- GeDialog::AddPopupButton(): Adds a popup button.
- GeDialog::AddChild(): Adds a child element to the given gadget.
- GeDialog::AddChildren(): Adds multiple children stored in a BaseContainer to the given gadget.
- GeDialog::FreeChildren(): Deletes the child elements of the given gadget.
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);
BaseContainer children;
children.SetString(0, "Child 0"_s);
children.SetString(1, "Child 1"_s);
AddChildren(6000, children);
IconData data1, data2;
AddComboBox(5001,
BFH_LEFT, 100, 10,
false);
const String iconData1Address = String::HexToString((
UInt) & data1);
AddChild(5001, 0, "Cube &" + iconData1Address + "&");
const String iconData2Address = String::HexToString((
UInt) & data2);
AddChild(5001, 1, "Sphere &" + iconData2Address + "&");
#define Ocube
Cube.
Definition: ge_prepass.h:1118
#define Osphere
Sphere.
Definition: ge_prepass.h:1119
Bool GetIcon(Int32 lIconID, IconData *pData)
maxon::UInt UInt
Definition: ge_sys_math.h:56
Further interaction with gadgets is typically done by sending messages to the gadget:
- GeDialog::SendMessage(): Sends a message to a dialog gadget.
See also GUI and Interaction Messages Manual.
const BaseContainer settings;
PyCompilerFlags * flags
Definition: ast.h:14
#define CUSTOMGUI_PROGRESSBAR
Progress bar.
Definition: lib_description.h:228
Int32 SizePix(Int32 pixels)
Definition: c4d_gui.h:3234
@ BFV_FIT
Fit. BFV_BOTTOM|BFV_TOP.
Definition: gui.h:306
const char * m
Definition: abstract.h:692
@ BFM_STATUSBAR_PROGRESSON
Bool Statusbar active.
Definition: gui.h:842
@ BFM_STATUSBAR_TINT_COLOR
Int32 Color ID for the status bar, or as RGB value (Vector).
Definition: gui.h:848
@ BFM_SETSTATUSBAR
To set a statusbar (e.g. inside a SCROLLGROUP (dialog element)):
Definition: gui.h:840
@ BFM_STATUSBAR_PROGRESS
Float Between 0.0 and 1.0.
Definition: gui.h:844
maxon::Vec3< maxon::Float64, 1 > Vector
Definition: ge_math.h:140
Images
There is no default gadget to display an image (BaseBitmap) in a GeDialog. Two possible solutions are:
- To use a custom gadget based on GeUserArea to draw the BaseBitmap, see GeUserArea Manual.
- Or to use a BitmapButtonCustomGui custom GUI element.
BaseContainer settings;
BitmapButtonCustomGui* const bitmapButtonGUI = static_cast<BitmapButtonCustomGui*>(customGUI);
if (bitmapButtonGUI)
{
bitmapButtonGUI->SetImage(buttonBitmap, true, false);
}
#define BITMAPBUTTON_BUTTON
Definition: customgui_bitmapbutton.h:34
@ 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.
- GeDialog::AddCustomGui(): Adds a custom GUI element of the given type.
- GeDialog::FindCustomGui(): Finds a custom GUI element with the given ID and the given type.
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).
BaseContainer hlSettings;
void*
const customGui = AddCustomGui(11000, customGuiID, String(),
BFH_SCALEFIT, 100, 50, hlSettings);
HyperLinkCustomGui* const linkGustomGui = static_cast<HyperLinkCustomGui*>(customGui);
if (linkGustomGui != nullptr)
{
const String linkTitle { "MAXON" };
const String url { "https://www.maxon.net" };
linkGustomGui->SetLinkString(&url, &linkTitle);
}
#define CUSTOMGUI_HYPER_LINK_STATIC
Hyper link custom GUI ID.
Definition: customgui_hyperlink.h:23
#define HYPERLINK_IS_LINK
::Bool true for hyperlinks, static text otherwise.
Definition: customgui_hyperlink.h:33
GradientCustomGui* const gradientGUI = static_cast<GradientCustomGui*>(customGUI);
if (gradientGUI)
{
AutoAlloc<Gradient> gradientData;
if (gradientData)
{
gradientData->InsertKnot(firstKnot);
gradientGUI->SetGradient(gradientData);
gradientData->InsertKnot(secondKnot);
GeData geData;
geData.SetCustomDataType<Gradient>(gradientData);
TriState<GeData> triStateData;
triStateData.Add(geData);
gradientGUI->SetData(triStateData);
}
}
#define CUSTOMGUI_GRADIENT
Gradient custom GUI ID.
Definition: customgui_gradient.h:21
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.
- GeDialog::AddUserArea(): Adds a user area to the dialog layout.
- GeDialog::AttachUserArea(): Connects the user area gadget with the actual user area instance.
See also GeUserArea Manual.
C4DGadget* userarea = this->AddUserArea(12000,
BFH_LEFT, 300, 100);
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.
- GeDialog::AddSubDialog(): Adds a sub-dialog to the dialog layout.
- GeDialog::AttachSubDialog(): Connects the sub-dialog gadget with the actual sub-dialog instance.
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.
- GeDialog::AddDlgGroup(): Adds a group with standard buttons to the dialog.
@ DLG_OK
OK button.
Definition: ge_prepass.h:3937
@ DLG_CANCEL
Cancel button.
Definition: ge_prepass.h:3938
{
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:
- ::BFH_CENTER: Centered horizontally.
- ::BFH_LEFT: Aligned to the left.
- ::BFH_RIGHT: Aligned to the right.
- ::BFH_FIT: Fit. (::BFH_LEFT|::BFH_RIGHT)
- ::BFH_SCALE: Scale if there is more space.
- ::BFH_SCALEFIT: Scale fit. (::BFH_SCALE|::BFH_FIT)
- ::BFH_MASK: Masks out flags.
Vertical alignment:
- ::BFV_CENTER: Centered vertically.
- ::BFV_TOP: Aligned to the top.
- ::BFV_BOTTOM: Aligned to the bottom.
- ::BFV_FIT: Fit. (::BFV_BOTTOM|::BFV_TOP)
- ::BFV_SCALE: Scale if there is more space.
- ::BFV_SCALEFIT: Scale fit. (::BFV_SCALE|::BFV_FIT)
- ::BFV_MASK: Masks out flags.
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:
- GeDialog::GetBool(): Gets the Boolean value displayed by the given gadget.
- GeDialog::SetBool(): Sets the Boolean value displayed by the given gadget.
Editing integer values:
- GeDialog::GetInt32(): Gets the integer value displayed by the given gadget.
- GeDialog::SetInt32(): Sets the integer value displayed by the given gadget.
Editing float values:
- GeDialog::GetFloat(): Gets the float value displayed by the given gadget.
- GeDialog::SetFloat(): Sets the float value displayed by the given gadget. See FORMAT_NUMBERS.
- GeDialog::SetMeter(): Sets the float value in meters displayed by the given gadget.
- GeDialog::SetDegree(): Sets the float value in degree displayed by the given gadget.
- GeDialog::SetPercent(): Sets the float value in percent displayed by the given gadget.
Editing Vector values:
- GeDialog::GetVector(): Gets the Vector value displayed by the given gadgets. This function is just a wrapper around GeDialog::GetFloat().
Editing Time values:
- GeDialog::GetTime(): Gets the time value displayed by the given gadget.
- GeDialog::SetTime(): Sets the time value displayed by the given gadget.
Editing String values:
- GeDialog::GetString(): Gets the String value displayed by the given gadget.
- GeDialog::SetString(): Sets the String value displayed by the given gadget.
Editing Filename values: These functions just wrap around GeDialog::GetString() and GeDialog::SetString().
- GeDialog::GetFilename(): Gets the Filename value displayed by the given gadget.
- GeDialog::SetFilename(): Sets the Filename value displayed by the given gadget.
Editing Color values:
- GeDialog::GetColorField(): Gets the color value displayed by the given gadget.
- GeDialog::SetColorField(): Sets the color value displayed by the given gadget.
SetString(1000, "Hello World"_s);
TriState<Int32> numberData;
numberData.Add(100);
numberData.Add(200);
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:712
@ BFM_INPUT
A dialog/user area receives this message if any mouse or keyboard input is received....
Definition: gui.h:705
@ BFM_INPUT_CHANNEL
Int32 Contains the key or mouse button. See also KEY.
Definition: gui.h:715
@ BFM_INPUT_DEVICE
Int32 Device:
Definition: gui.h:710
@ 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
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:726
@ KEY_ENTER
Definition: gui.h:70
Bool GetInputState(Int32 askdevice, Int32 askchannel, BaseContainer &res)
{
{
{
{
{
{
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:716
@ BFM_INPUT_MOUSE
Mouse.
Definition: gui.h:711
@ BFM_INPUT_Y
Float Y value.
Definition: gui.h:729
@ BFM_INPUT_X
Float X value.
Definition: gui.h:728
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:
- GeDialog::CheckDropArea(): Returns true if the drag event is over the given gadget.
- GeDialog::GetDragPosition(): Gets the coordinates of the drag event.
- GeDialog::GetDragObject(): Gets the object that is dragged.
- GeDialog::SetDragDestination(): Sets the cursor that should be displayed. See MOUSE.
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)
{
const AtomArray*
const atomArray =
static_cast<AtomArray*
>(
object);
if (atomArray && atomArray->GetCount() > 0)
{
C4DAtom*
const atom = atomArray->GetIndex(0);
{
BaseList2D*
const baselist =
static_cast<BaseList2D*
>(
atom);
SetString(ID_TEXT_NAME, baselist->GetName());
}
}
return true;
}
else
{
}
}
}
}
}
PyObject * object
Definition: asdl.h:7
#define atom
Definition: graminit.h:72
@ BFM_DRAG_FINISHED
Bool Drag finished.
Definition: gui.h:797
@ DRAGTYPE_ATOMARRAY
AtomArray.
Definition: gui.h:786
@ BFM_DRAGRECEIVE
Drag receive. (See DragAndDrop.)
Definition: gui.h:774
static const Int32 MOUSE_POINT_HAND
Point hand cursor.
Definition: ge_prepass.h:2733
static const Int32 MOUSE_FORBIDDEN
Forbidden cursor.
Definition: ge_prepass.h:2722
#define Tbaselist2d
2D list.
Definition: ge_prepass.h:995
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().
- GeDialog::CheckCoreMessage(): Speedup function that checks if the given core message is new or has been already processed.
See also GUI and Interaction Messages Manual and Core Messages Manual.
{
switch (id)
{
{
if (!CheckCoreMessage(
msg))
break;
this->InitValues();
break;
}
}
return GeDialog::CoreMessage(
id,
msg);
}
{
SetString(1000, "---"_s);
return true;
BaseObject*
const object =
doc->GetActiveObject();
if (object == nullptr)
return true;
SetString(1000,
object->GetName());
return true;
}
#define EVMSG_CHANGE
Sent by EventAdd().
Definition: ge_prepass.h:2768
BaseDocument * GetActiveDocument()
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.
- GeDialog::SendParentMessage(): Sends a message to the parent dialog.
- GeDialog::GetId(): Returns the ID of the dialog. Typically needed in a custom GUI element to send the message ::BFM_ACTION_ID.
const char * message
Definition: pyerrors.h:189
@ BFM_ACTION_VALUE
::GeData Action value.
Definition: gui.h:748
@ BFM_ACTION_ID
Int32 ID of the dialog element that triggered the action.
Definition: gui.h:747
@ BFM_ACTION
One of the child elements made any action:
Definition: gui.h:746
Utility
Coordinates
These utility functions allow to access the dimensions of a gadget or to transfer given coordinates into various spaces:
- GeDialog::GetItemDim(): Gets the dimensions of the given gadget.
- GeDialog::Local2Global(): Transforms the given local coordinates into global space.
- GeDialog::Global2Local(): Transforms the given global coordinates into local space.
- GeDialog::Screen2Local(): Transforms the given screen coordinates into local space.
- GeDialog::Local2Screen(): Transforms the given local coordinates into screen space.
if (id == 4000)
{
GetItemDim(
id, &
x, &y, &w, &h);
BaseContainer bc;
bc.InsData(5159, "CMD");
bc.InsData(0, String());
bc.InsData(5160, "CMD");
}
Int32 ShowPopupMenu(CDialog *cd, Int32 screenx, Int32 screeny, const BaseContainer &bc, Int32 flags=POPUP_RIGHT|POPUP_EXECUTECOMMANDS|POPUP_ALLOW_FILTERING, Int32 *res_mainid=nullptr)
const Class< R > & Get(const Id &cls)
Definition: objectbase.h:2090
Colors
Color related functions are:
- GeDialog::GetColorRGB(): Gets the color value for the given color ID. See
c4d_colors.h
.
- GeDialog::SetDefaultColor(): Sets the value of a color ID for the given gadget.
@ COLOR_TEXT_EDIT
Definition: c4d_colors.h:108
Further Reading