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.
- c4d.gui.GeUserArea
Return type: | GeUserArea |
---|---|
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:
def GetMinSize(self):
#do a calculation here
return self.width, self.height
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.
Parameters: | 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. |
Called when the user area is resized. Override if you need to update anything.
Parameters: |
|
---|
If you subscribe to timer events using SetTimer() (x), this function is called every x th millisecond. The raw timer message is stored in msg.
Parameters: | msg (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, Message():
def Message(self, msg, result):
if msg.GetId():
pass #do something
return True
return GeUserArea.Message(self, msg, result)
Parameters: |
|
---|---|
Return type: |
int |
Returns: |
The return value depends on the message. |
Forces the user area to redraw itself.
Parameters: | 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.
Parameters: | 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 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.
Parameters: | x (int) – The timer interval in milliseconds. |
---|
Polls a certain channel of a device for the current input state. If the return value is True, the container stored in res is just like an input event message, otherwise no state was available. For a list of valid devices and channels, Input Events.
Parameters: |
|
---|---|
Return type: |
bool |
Returns: |
True if an event could be retrieved, otherwise False. |
Gets the next input event for a certain device from the event queue. If the return value is True, the container stored in res is just like an input event message, otherwise no event was available. For a list of valid devices and channels, please see Input events.
Parameters: |
|
---|---|
Return type: |
bool |
Returns: |
True if an event could be retrieved, otherwise False. |
Flushes all events from the window message queue. For example if you loop while the mouse is down (polling) you can call this command to flush all keydowns/mouseclicks that are made during the loop.
Checks the standard navigation hotkeys.
Parameters: |
id (int) –
The hotkey:
|
||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Return type: | bool | ||||||||||||||||||||||
Returns: | True if the hotkey is down. |
Gets the RGB values associated with a color code.
Parameters: |
type (int) –
A color constant:
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Return type: | dict{r: int, g: int, b: 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.
Parameters: |
type (int) –
Sets the text font.
|
---|
Call this in DrawMsg() 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.
Parameters: |
fontid (int) –
The font to use:
|
---|
Returns the width in pixels of the string text, if it were drawn in the current font.
Parameters: | 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. |
New in version R13.029.
Returns the base line of the set font.
Return type: | int |
---|---|
Returns: | The base line of the set font. |
New in version R13.029.
Rotates the font for drawing.
Note
Rotation is clockwise and must be set to 0 after drawing.
Parameters: | textrotation (float) – The text rotation in degree. |
---|
Should be used at the top of the 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
The method OffScreenOn() automatically sets the clipping region to the whole user area, so normally this function isn’t necessary.
Parameters: |
|
---|
Clears any clipping region set with SetClippingRegion().
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. |
Scrolls the area from (x,y) to (x+w,y+h) in the direction specified by xdiff and ydiff.
Parameters: |
|
---|
Transforms local coordinates (relative to the top left corner of the dialog) to global coordinates (relative to the top left corner of the physical window). Result is a dict with member keys x and y of type int.
Return type: | dict{x: int, y: int} |
---|---|
Returns: | The converted coordinates or None. |
Transforms global coordinates (relative to the top left corner of the physical window) to local coordinates (relative to the top left corner of the dialog). Result is a dict with member keys x and y of type int.
Return type: | dict{x: int, y: int} |
---|---|
Returns: | The converted coordinates or None. |
Transforms local coordinates (relative to the top left corner of the dialog) to screen coordinates (relative to the top left corner of the system screen). Result is a dict with member keys x and y of type int.
Return type: | dict{x: int, y: int} |
---|---|
Returns: | The converted coordinates or None. |
Transforms screen coordinates (relative to the top left corner of the system screen) to local coordinates (relative to the top left corner of the dialog). Result is a dict with member keys x and y of type int.
Return type: | dict{x: int, y: int} |
---|---|
Returns: | The converted coordinates or None. |
Tells C4D that the user area now has new dimensions. That causes c4d to call:
Draws a border within the rectangle from (x1,y1) to (x2,y2).
Parameters: |
|
---|
Retrieves the space required to draw a border.
Parameters: |
type (int) –
The border type:
|
||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Return type: | dict{l: int, t: int, r: int, b: int} | ||||||||||||||||||||||||||||||||||
Returns: | The space. |