This documentation is for the free plugin Py4D in CINEMA 4D R11.5 and not for the C4DSDK of Python in CINEMA 4D R12. For R12, please visit PluginCafe.com
This class helps you to create custom gadgets for dialogs in Cinema 4D.
Note
Just take care about the lifetime of your GeUserArea instance. If you pass an instance of this class to a dialog, a reference is hold by the dialog and released when the dialog is freed. That also means that each instance of your GeUserArea class is still alive until the host-dialog is freed, even you dont hold a reference to it. If you want to use the same instance of your GeUserArea class on the next time you open the dialog, you have to store the instance in the class scope. See the following example.
The class to create custom user areas.
//Constructor
//Methods to override
| Return type: | GeUserArea or None |
|---|---|
| Returns: | A new user area. |
Called once when the user area is initialized by the GUI, before the layout is calculated. Override this function if you need to initialize anything. Return True if successful, or False to signalize an error.
| Return type: | bool |
|---|---|
| Returns: | Return True if successful, or False to signalize an error. |
Called after the layout is calculated, before the user area is drawn. Override this function if you need to initialize anything. Return TRUE if successful, or FALSE to signalize an error.
| Return type: | bool |
|---|---|
| Returns: | Return True if successful, or False to signalize an error. |
Override this function to specify a minimum size for the user area.
| Return type: | tuple of ints |
|---|---|
| Returns: | Return a tuple with two elements just like this:
|
Called when C4D wants you to draw your userarea. Use the drawing functions to update your user area in the region speicified by the rectangle from (x1,y1) to (x2,y2).
| Parameters: |
|
|---|
Called when an input event is received. All information about the input event is stored in the msg container.
| Parameter: | msg (BaseContainer) – The event container. |
|---|---|
| Return type: | bool |
| Returns: | Return True if the event was handled, otherwise False. |
Called when a C4D core messages is received. The message type is given by id and the message information is stored in msg.
| Parameters: |
|
|---|---|
| Return type: | bool |
| Returns: | Return True if the event was handled, otherwise False. |
If you subscribe to timer events using GeUserArea.SetTimer(), this function is called every x*th millisecond. The raw timer message is stored in *msg.
| Parameter: | color (BaseContainer) – The timer message container. |
|---|
Override this function if you want to react to more messages than covered by the other functions. Normally this is not necessary. Be sure to include a call the parent version of this function, GeUserArea.Message(self, msg, result).
| Parameters: |
|
|---|---|
| Return type: | int |
| Returns: | The return value depends on the message. |
Forces the user area to redraw itself.
| Parameter: | thread (bool) – Must be set to True if the function is called from another thread than the main C4D thread. |
|---|
Use this function to send a custom message to the parent dialog.
| Parameter: | msg (BaseContainer) – The message container. |
|---|
Returns the ID of the user area.
| Return type: | int |
|---|---|
| Returns: | The ID. |
Returns the width of the user area.
| Return type: | int |
|---|---|
| Returns: | Width in pixels. |
Returns the height of the user area.
| Return type: | int |
|---|---|
| Returns: | Height in pixels. |
Indicates the enabled state.
| Return type: | bool |
|---|---|
| Returns: | TRUE if the user area is enabled in the dialog, otherwise FALSE. |
Indicates the focus state.
| Return type: | bool |
|---|---|
| Returns: | TRUE if the user area has the focus in the dialog, otherwise FALSE. |
Initializes the timer clock, so that GeUserArea.Timer() is called every timer milliseconds.
Note
Depending on the speed of the computer, the operating system, the complexity of the dialog and the threads running in the background, there is no guarantuee that event messages will occur on a regular basis. Using a value of 500 ms should be no problem but if using a value of 1 ms one might get events with the following time spaces: 3 ms, 76 ms, 15 ms, 19 ms, 67 ms...
Note
Keep in mind that using small timer values results in heavy message traffic in the application which may slow down CINEMA 4D (and all other applications running on the computer) to a point where nothing is working any longer besides your dialog.
| Parameter: | x (int) – The timer interval in milliseconds. |
|---|
Polls a certain channel of a device for the current input state. If the return value is not None, the result container is just like an input event message, otherwise no state was available.
| Parameters: |
|
|---|
Gets the next input event for a certain device from the event queue. If the return value is not None, the result container is just like an input event message, otherwise no state was available.
| Parameters: |
|
|---|
Checks the standard navigation hotkeys.
| Parameter: | id (int) – The hotkey:
|
||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Return type: | bool | ||||||||||||||||||||||
| Returns: | TRUE if the hotkey is down. |
Gets the RGB values associated with a color code.
| Parameter: | type (int) – A color constant:
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Return type: | dict of int | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Returns: | The color or None. |
Sets the draw color.
| Param: | A color vector. |
|---|
Sets the draw color.
| Parameters: |
|---|
Draws a line with the current pen color between (x1,y1) and (x2,y2).
| Parameters: |
|
|---|
Fills a rectangular area with the current pen color between (x1,y1) and (x2,y2).
| Parameters: |
|
|---|
Draws a bitmap into the user area. The region (x,y) to (x+w,y+h) from the bitmap will be scaled and transformed into the region (wx,wy) to (wx+ww,wy+wh) of the destination area.
Note
BMP_ALLOWALPHA can be combined with the other modes.
| Parameters: |
|
|---|
Sets the text font.
| Parameter: | type (int) – Sets the text font.
|
|---|
Call this in draw_msg() to set the color for the following text elements.
| Parameters: |
|---|
Fills a rectangular area with the current pen color between (x1,y1) and (x2,y2).
| Parameters: |
|
|---|
Draws the string txt with the upper left corner at the position (x,y). Use get_font_height and get_font_width to find out where to place the text.
| Parameters: |
|
|---|
Fills the bitmap bmp with the current pen color. The offsetx and offsety parameters are used when the background is a pattern and are given in local coordinates of the user area. This can be used to make semi-transparent bitmap blits.
| Parameters: |
|
|---|
Sets the text font.
| Parameter: | fontid (int) – The font to use:
|
|---|
Returns the width in pixels of the string text, if it were drawn in the current font.
| Parameter: | text (str) – The string to measure. |
|---|---|
| Return type: | int |
| Returns: | The width in pixels. |
Returns the height in pixels of a line of text in the current font.
| Return type: | int |
|---|---|
| Returns: | Height in pixels. |
Should be used at the top of the GeUserArea.DrawMsg>() function to specify the clipping region. Without specifying a dedicated clipping region everything will be painted, even if it’s outside the user area!
Note
GeUserArea.OffScreenOn() automatically sets the clipping region to the whole user area, so normally this function isn’t necessary.
| Parameters: |
|
|---|
Enables double buffering to avoid blinking and flickering effects. The GUI will automatically switch planes. Just call this function before drawing things. Sets the clipping area to the rectangular area determined by x, y, w and h.
| Parameters: |
|
|---|---|
| Return type: | bool |
| Returns: | TRUE if double buffering could be enabled, otherwise FALSE. |
Tells C4D that the user area now has new dimensions. That causes c4d to call:
- GetMinSize
- DrawMsg
Draws a border within the rectangle from (x1,y1) to (x2,y2).
| Parameters: |
|
|---|
Retrieves the space required to draw a border.
| Parameter: | type (int) – The border type:
|
||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Return type: | dict of int | ||||||||||||||||||||||||||||||||||
| Returns: | The space. |