#include <c4d_gui.h>
A class that can be used to create custom GUI components.
There are already dozens of predefined buttons in the GUI easy available. But if one wants to make his own button, one needs to use the GeUserArea class.
Every user area has a specified drawing area and several commands for drawing lines or text. So it is possible to developer whatever needed, either a 3D trackball or a tree like object manager.
The message sequence when the user area is created:
Public Member Functions | |
Bool | OpenPopUpMenu (Int32 menuid, Int32 localx=-1, Int32 localy=-1, Int32 watchhotkey=0) |
Protected Attributes | |
GeDialog * | dlg |
Private Member Functions | |
MAXON_DISALLOW_COPY_AND_ASSIGN (GeUserArea) | |
Private Attributes | |
Bool | owncu |
CUserArea * | cu |
Friends | |
class | GeDialog |
Constructor/Destructor | |
GeUserArea () | |
virtual | ~GeUserArea () |
Internal Representation | |
CUserArea * | Get () |
void | Set (CUserArea *t_cu) |
Parent Dialog | |
GeDialog * | GetDialog () |
Override | |
virtual Bool | Init () |
virtual Bool | InitValues () |
virtual Bool | GetMinSize (Int32 &w, Int32 &h) |
virtual void | Sized (Int32 w, Int32 h) |
virtual OBSOLETE | Draw (Int32 x1, Int32 y1, Int32 x2, Int32 y2) |
virtual void | DrawMsg (Int32 x1, Int32 y1, Int32 x2, Int32 y2, const BaseContainer &msg) |
virtual Bool | InputEvent (const BaseContainer &msg) |
virtual Bool | CoreMessage (Int32 id, const BaseContainer &msg) |
virtual void | Timer (const BaseContainer &msg) |
virtual Int32 | Message (const BaseContainer &msg, BaseContainer &result) |
Basic Functions | |
void | Redraw (Bool threaded=false) |
Bool | SendParentMessage (const BaseContainer &msg) |
GeData | SendParentMessageResult (const BaseContainer &msg) |
Int32 | GetId () const |
Int32 | GetWidth () const |
Int32 | GetHeight () const |
Bool | IsEnabled () const |
Bool | IsR2L () const |
Bool | HasFocus () const |
void | LayoutChanged () |
void | SetTimer (Int32 timer) |
Input | |
Bool | GetInputState (Int32 askdevice, Int32 askchannel, BaseContainer &res) const |
Bool | GetInputEvent (Int32 askdevice, BaseContainer &res) const |
void | KillEvents () |
HOTKEYFLAGS | IsHotkeyDown (Int32 id) const |
Clipping | |
void | SetClippingRegion (Int32 x, Int32 y, Int32 w, Int32 h) |
void | ClearClippingRegion () |
Bool | OffScreenOn () |
Bool | OffScreenOn (Int32 x, Int32 y, Int32 w, Int32 h) |
Miscellaneous | |
void | ScrollArea (Int32 xdiff, Int32 ydiff, Int32 x, Int32 y, Int32 w, Int32 h) |
Float | GetPixelRatio () const |
Coordinates Transformation | |
Bool | Local2Global (Int32 *x, Int32 *y) const |
Bool | Local2Global (Float &x, Float &y) const |
Bool | Global2Local (Int32 *x, Int32 *y) const |
Bool | Global2Local (Float &x, Float &y) const |
Bool | Local2Screen (Int32 *x, Int32 *y) const |
Bool | Local2Screen (Float &x, Float &y) const |
Bool | Screen2Local (Int32 *x, Int32 *y) const |
Bool | Screen2Local (Float &x, Float &y) const |
Drag and Drop | |
Bool | GetDragPosition (const BaseContainer &msg, Int32 *x, Int32 *y) const |
Bool | GetDragObject (const BaseContainer &msg, Int32 *type, void **object) const |
Bool | HandleMouseDrag (const BaseContainer &msg, Int32 type, void *data, Int32 dragflags) |
Bool | SetDragDestination (Int32 cursor) |
Border | |
void | GetBorderSize (Int32 type, Int32 *l, Int32 *t, Int32 *r, Int32 *b) const |
void | DrawBorder (Int32 type, Int32 x1, Int32 y1, Int32 x2, Int32 y2) |
Bool | CheckDropArea (const BaseContainer &msg, Bool horiz, Bool vert) const |
Mouse Drag | |
void | MouseDragStart (Int32 button, Float mx, Float my, MOUSEDRAGFLAGS flag) |
MOUSEDRAGRESULT | MouseDrag (Float *mx, Float *my, BaseContainer *channels) |
MOUSEDRAGRESULT | MouseDragEnd () |
GeUserArea | ( | ) |
Constructs a user area that is not attached to any dialog.
|
virtual |
Destroys the user area.
|
private |
CUserArea* Get | ( | ) |
Gets the internal representation of the user area.
Needed by some areas in the API for historical reasons.
void Set | ( | CUserArea * | t_cu | ) |
Sets the internal representation of the user area.
Needed by some areas in the API for historical reasons.
[in] | t_cu | An internal user area representation. |
GeDialog* GetDialog | ( | ) |
Gets the user area's parent dialog.
|
virtual |
Called once when the user area is initialized by the GUI, before the layout is calculated.
Override this function to initialize anything.
|
virtual |
Called after the layout is calculated, before the user area is drawn.
Override this function to initialize anything.
Called to specify a minimum size for the user area.
Override this function to set the minimum size of the user area to w and h.
[in] | w | Assign the minimum width in pixels. |
[in] | h | Assign the minimum height in pixels. |
Called when the user area is resized.
Override this function to update anything.
[in] | w | The new width in pixels. |
[in] | h | The new height in pixels. |
|
virtual |
Called to draw the user area.
Use the drawing functions to update the user area in the region specified by the rectangle from (x1, y1) to (x2, y2).
Remember to use OffScreenOn() to avoid flickering.
[in] | x1 | The upper left X coordinate. |
[in] | y1 | The upper left Y coordinate. |
[in] | x2 | The lower right X coordinate. |
[in] | y2 | The lower right Y coordinate. |
[in] | msg | The draw container. |
|
virtual |
Called when an input event is received.
The information about the input event is stored in the msg container. See Input Events for more information.
[in] | msg | The event container. |
|
virtual |
Called when a core message is received.
The message type is given by id and the message information is stored in msg.
[in] | id | The message type: EVMSG |
[in] | msg | The core message container. |
|
virtual |
Called when a timer event is received.
To subscribe to timer events use SetTimer().
[in] | msg | The timer message container. |
|
virtual |
Called when a message is received.
Override this function to react to more messages than covered by the other virtual functions. Normally this is not necessary.
[in] | msg | The message container. |
[in] | result | A container to place results in. |
void Redraw | ( | Bool | threaded = false | ) |
Forces the user area to redraw itself.
[in] | threaded | Must be set to true if the function is called from another thread than the main Cinema 4D thread. |
Bool SendParentMessage | ( | const BaseContainer & | msg | ) |
Sends a custom message to the parent dialog.
[in] | msg | The message container. |
GeData SendParentMessageResult | ( | const BaseContainer & | msg | ) |
Sends a custom message to the parent dialog.
[in] | msg | The message container. |
Int32 GetId | ( | ) | const |
Gets the ID of the user area.
Int32 GetWidth | ( | ) | const |
Gets the width in pixels of the user area.
Int32 GetHeight | ( | ) | const |
Gets the height in pixels of the user area.
Bool IsEnabled | ( | ) | const |
Checks the enabled state of the user area.
Bool IsR2L | ( | ) | const |
Checks if the user area has to be drawn in right-to-left layout mode.
Bool HasFocus | ( | ) | const |
Checks if the user area has the focus.
void LayoutChanged | ( | ) |
Tells Cinema 4D that the user area has new dimensions. That causes Cinema 4D to call:
void SetTimer | ( | Int32 | timer | ) |
Initializes the timer clock, so that Timer() is called every timer milliseconds. Use SetTimer(0) to stop the timer.
[in] | timer | The timer interval in milliseconds. Pass 0 to stop the timer. |
Bool GetInputState | ( | Int32 | askdevice, |
Int32 | askchannel, | ||
BaseContainer & | res | ||
) | const |
Polls a certain channel of a device for the current input state.
If the return value is true, the container stored in res is like an input event message, otherwise no state was available.
For a list of valid devices and channels, see Input Events.
[in] | askdevice | The device to ask. |
[in] | askchannel | The channel of the device. |
[in] | res | The result container. |
Bool GetInputEvent | ( | Int32 | askdevice, |
BaseContainer & | res | ||
) | const |
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 like an input event message, otherwise no state was available.
For a list of valid devices and channels, see Input Events.
[in] | askdevice | The device to poll. |
[in] | res | The result container. |
void KillEvents | ( | ) |
Flushes all events from the window message queue.
For example if looping while the mouse is down (polling), call this function to flush all key downs/mouse clicks that are made during the loop.
HOTKEYFLAGS IsHotkeyDown | ( | Int32 | id | ) | const |
Checks the standard navigation hotkeys.
[in] | id | The hotkey to check: HOTKEY |
void DrawSetPen | ( | const Vector & | color | ) |
Sets the draw color.
[in] | color | A color vector. |
void DrawSetPen | ( | Int32 | id | ) |
Sets the draw color.
DrawSetPen(COLOR_BG)
. [in] | id | A color constant: COLOR |
Gets the RGB value of a color ID.
[in] | id | A color constant: COLOR |
void DrawSetPen | ( | const GeData & | d | ) |
Sets the draw color.
[in] | d | A color data. Can be either a color vector or a color constant in the GeData. |
void DrawSetPenToParentBackgroundColor | ( | ) |
Sets the draw color to the parent group brackground color.
DrawSetPen(COLOR_BG)
. This is equivalent to DrawSetPen(GetParentBackgroundColor())
. GeData GetParentBackgroundColor | ( | ) | const |
Gets the parent group background color. Can be either a color vector in range [0, 1] or a color constant of type Int32: COLOR
void DrawSetOpacity | ( | Float | opacity | ) |
Sets the opacity value.
[in] | opacity | The opacity. |
Sets the text foreground and background color.
[in] | fg | A color vector for the foreground. |
[in] | bg | A color constant for the background: COLOR |
Sets the text foreground and background color.
[in] | fg | A color constant for the foreground: COLOR |
[in] | bg | A color vector for the background. |
Sets the text foreground and background color.
[in] | fg | A color vector for the foreground. |
[in] | bg | A color vector for the background. |
Sets the text foreground and background color.
[in] | fg | A color data for the foreground. Can be either a color vector or a color ID. |
[in] | bg | A color data for the background. Can be either a color vector or a color ID. |
Gets the RGB values associated with a color constant.
[in] | colorid | A color constant: COLOR |
[out] | r | Assigned the red component of the color. |
[out] | g | Assigned the green component of the color. |
[out] | b | Assigned the blue component of the color. |
void ActivateFading | ( | Int32 | milliseconds | ) |
Activates the fading.
[in] | milliseconds | The time for the fading in milliseconds. |
void DrawLine | ( | Int32 | x1, |
Int32 | y1, | ||
Int32 | x2, | ||
Int32 | y2, | ||
Float | lineWidth = 1.0 , |
||
LINESTYLE | lineStyle = LINESTYLE::NORMAL |
||
) |
Draws a line with the current pen color between (x1,y1) and (x2,y2).
[in] | x1 | The X start coordinate. |
[in] | y1 | The Y start coordinate. |
[in] | x2 | The X end coordinate. |
[in] | y2 | The Y end coordinate. |
void DrawFrame | ( | Int32 | x1, |
Int32 | y1, | ||
Int32 | x2, | ||
Int32 | y2, | ||
Float | lineWidth = 1.0 , |
||
LINESTYLE | lineStyle = LINESTYLE::NORMAL |
||
) |
Draws a rectangular frame with the current pen color between (x1,y1) and (x2,y2).
[in] | x1 | The X coordinate of the first corner. |
[in] | y1 | The Y coordinate of the first corner. |
[in] | x2 | The X coordinate of the opposite corner. |
[in] | y2 | The Y coordinate of the opposite corner. |
[in] | lineWidth | Line width to draw the line. |
Fills a rectangular area with the current pen color between (x1,y1) and (x2,y2).
[in] | x1 | The X coordinate of the first corner. |
[in] | y1 | The Y coordinate of the first corner. |
[in] | x2 | The X coordinate of the opposite corner. |
[in] | y2 | The Y coordinate of the opposite corner. |
void DrawBitmap | ( | BaseBitmap * | bmp, |
Int32 | wx, | ||
Int32 | wy, | ||
Int32 | ww, | ||
Int32 | wh, | ||
Int32 | x, | ||
Int32 | y, | ||
Int32 | w, | ||
Int32 | h, | ||
Int32 | mode | ||
) |
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.
[in] | bmp | The bitmap to draw. The caller owns the pointed bitmap. |
[in] | wx | The X coordinate of the upper left corner of the destination area. |
[in] | wy | The Y coordinate of the upper left corner of the destination area. |
[in] | ww | The width of the destination area. |
[in] | wh | The height of the destination area. |
[in] | x | The X coordinate of the upper left corner of the bitmap area. |
[in] | y | The Y coordinate of the upper left corner of the bitmap area. |
[in] | w | The width of the bitmap area. |
[in] | h | The height of the bitmap area. |
[in] | mode | Can be a combination of the following flags: BMP |
void DrawImageRef | ( | maxon::ImageBaseRef & | imageRef, |
Float | wx, | ||
Float | wy, | ||
Float | ww, | ||
Float | wh, | ||
Float | opacity, | ||
maxon::IMAGEINTERPOLATIONMODE | mode | ||
) |
Draws a image into the user area.
[in] | imageRef | ImageRef to draw. |
[in] | wx | The X coordinate of the upper left corner of the destination area. |
[in] | wy | The Y coordinate of the upper left corner of the destination area. |
[in] | ww | The width of the destination area. |
[in] | wh | The height of the destination area. |
[in] | opacity | Opacity to draw with (0.0 == completely transparent, 1.0 == fully opaque). |
void DrawText | ( | const maxon::String & | txt, |
Int32 | x, | ||
Int32 | y, | ||
Int32 | flags = (0|(0<< 4)) |
||
) |
Draws the string txt with the upper left corner at the position (x,y).
[in] | txt | The text to draw. |
[in] | x | The X coordinate of the upper left corner for the text to draw. |
[in] | y | The Y coordinate of the upper left corner for the text to draw. |
[in] | flags | The draw text flags: DRAWTEXT |
void DrawBezierLine | ( | const Vector2d & | startPoint, |
const maxon::Block< const BezierPoint > & | bezierPoints, | ||
Bool | closed, | ||
Float | lineWidth = 1.0 , |
||
LINESTYLE | lineStyle = LINESTYLE::NORMAL |
||
) |
Draws concatenated Bezier curves.
[in] | startPoint | The XY coordinate of the upper left corner of the drawn curve. |
[in] | bezierPoints | An array containing a struct of Bezier curves points. |
[in] | closed | If true, the last point of the last segment connects back to the starting point (startPoint). |
[in] | lineWidth | The width of the Bezier curve. Default 1.0. |
[in] | lineStyle | The line style of the Bezier curve. |
void DrawBezierFill | ( | const Vector2d & | startPoint, |
const maxon::Block< const BezierPoint > & | bezierPoints, | ||
Bool | closed | ||
) |
void DrawPolyLine | ( | const maxon::Block< const Vector2d > & | p, |
Bool | closed, | ||
Float | lineWidth = 1.0 , |
||
LINESTYLE | lineStyle = LINESTYLE::NORMAL |
||
) |
void DrawPolyFill | ( | const maxon::Block< const Vector2d > & | p, |
Bool | closed | ||
) |
void DrawEllipseLine | ( | const Vector2d & | centerPoint, |
const Vector2d & | radius, | ||
Float | lineWidth = 1.0 , |
||
LINESTYLE | lineStyle = LINESTYLE::NORMAL |
||
) |
void DrawCustomButton | ( | Int32 | x, |
Int32 | y, | ||
Int32 | w, | ||
Int32 | h, | ||
const Int32 * | ids, | ||
Bool | nofill, | ||
Bool | focus | ||
) |
Private.
void FillBitmapBackground | ( | BaseBitmap * | bmp, |
Int32 | offsetx, | ||
Int32 | offsety | ||
) |
Fills a bitmap with the current pen color.
[in] | bmp | The bitmap to fill. The caller owns the pointed bitmap. |
[in] | offsetx | The X offset in pixels. |
[in] | offsety | The Y offset in pixels. |
Int32 DrawGetTextWidth | ( | const maxon::String & | text | ) | const |
Retrieves the width in pixels of text, if it were drawn in the current font.
[in] | text | The string to measure. |
Int32 DrawGetTextWidth_ListNodeName | ( | BaseList2D * | node, |
Int32 | fontid = FONT_STANDARD |
||
) | const |
Retrieves the width in pixels of the name of node.
[in] | node | The node to check. |
[in] | fontid | The font: FONT |
Int32 DrawGetTextIndexFromPixel | ( | const maxon::String & | text, |
Float | pixelPosition | ||
) | const |
Retrieves the index from a position within the text.
[in] | text | Text to process. |
[in] | pixelPosition | Pixel to examine. |
Int32 DrawGetFontHeight | ( | ) | const |
Retrieves the height in pixels of a line of text in the current font.
Int32 DrawGetFontBaseLine | ( | ) | const |
Retrieves the base line of the current font.
const maxon::OSFontObjectRef& DrawGetFontObject | ( | ) | const |
Private. Retrieves the font object of the current font.
void DrawSetTextRotation | ( | Float | textrotation | ) |
Rotates the font for drawing.
[in] | textrotation | The text rotation in degree. |
Specifies the clipping region for the Draw()
functions.
[in] | x | The X coordinate of the upper left corner of the clipping region. |
[in] | y | The Y coordinate of the upper left corner of the clipping region. |
[in] | w | The width of the clipping region. |
[in] | h | The height of the clipping region. |
void ClearClippingRegion | ( | ) |
Clears any clipping region set with SetClippingRegion.
Bool OffScreenOn | ( | ) |
Enables double buffering to avoid blinking and flickering effects. Automatically sets the clipping area to the whole user area.
The GUI will automatically switch planes. Just call this function before drawing things.
Enables double buffering to avoid blinking and flickering effects. Sets the clipping area to the rectangular area determined by x, y, w and h.
[in] | x | The X coordinate of the upper left corner of the clipping area. |
[in] | y | The Y coordinate of the upper left corner of the clipping area. |
[in] | w | The width of the clipping area. |
[in] | h | The height of the clipping area. |
Scrolls the area from (x,y) to (x+w,y+h) in the direction specified by xdiff and ydiff.
[in] | xdiff | The X distance to scroll. |
[in] | ydiff | The Y distance to scroll. |
[in] | x | The X coordinate of the upper left corner of the area to scroll. |
[in] | y | The Y coordinate of the upper left corner of the area to scroll. |
[in] | w | The width of the area to scroll. |
[in] | h | The height of the area to scroll. |
Float GetPixelRatio | ( | ) | const |
Private. Always returns 1.0 except for user areas shown on OS X Retina displays, where it returns 2.0.
Transforms local coordinates (relative to the top left corner of the user area) to global window coordinates (relative to the top left corner of the application window). Stores the result in *x and *y.
[in,out] | x | The local X coordinate. Assigned the global window coordinate. |
[in,out] | y | The local Y coordinate. Assigned the global window coordinate. |
Transforms global window coordinates (relative to the top left corner of the application window) to local coordinates (relative to the top left corner of the user area). Stores the result in *x and *y.
[in,out] | x | The global window X coordinate. Assigned the local coordinate. |
[in,out] | y | The global window Y coordinate. Assigned the local coordinate. |
Transforms local coordinates (relative to the top left corner of the user area) to screen coordinates (relative to the top left corner of the system screen). Stores the result in *x and *y.
[in,out] | x | The local X coordinate. Assigned the screen coordinate. |
[in,out] | y | The local Y coordinate. Assigned the screen coordinate. |
Transforms screen coordinates (relative to the top left corner of the system screen) to local coordinates (relative to the top left corner of the user area). Stores the result in *x and *y.
[in,out] | x | The screen X coordinate. Assigned the converted local coordinate. |
[in,out] | y | The screen Y coordinate. Assigned the converted local coordinate. |
Bool GetDragPosition | ( | const BaseContainer & | msg, |
Int32 * | x, | ||
Int32 * | y | ||
) | const |
Extracts local drag coordinates from a drag and drop event. Stores the result in *x and *y.
[in] | msg | The original message. |
[out] | x | Assigned the local X position. |
[out] | y | Assigned the local Y position. |
Bool GetDragObject | ( | const BaseContainer & | msg, |
Int32 * | type, | ||
void ** | object | ||
) | const |
Extracts the object from a drag and drop message. Stores the result in *type and *object.
[in] | msg | The original message. |
[out] | type | Assigned the type of the object. |
[out] | object | Assigned a pointer to the object. Cinema 4D owns the pointed object. |
Bool HandleMouseDrag | ( | const BaseContainer & | msg, |
Int32 | type, | ||
void * | data, | ||
Int32 | dragflags | ||
) |
Starts a drag and drop operation.
[in] | msg | The mouse event message that triggered the drag and drop. |
[in] | type | The type of data passed: DRAGTYPE |
[in] | data | A pointer to the data passed. |
[in] | dragflags | The drag flags. Private. |
Sets the correct cursor during drag and drop handling.
[in] | cursor | A mouse cursor: MOUSE |
Retrieves the space required to draw a border.
[in] | type | The border type: BORDER |
[out] | l | Assigned the space to the left. |
[out] | t | Assigned the space on the top. |
[out] | r | Assigned the space to the right. |
[out] | b | Assigned the space on the bottom. |
Draws a border within the rectangle from (x1,y1) to (x2,y2).
[in] | type | The border type: BORDER |
[in] | x1 | The X coordinate of the first corner. |
[in] | y1 | The Y coordinate of the first corner. |
[in] | x2 | The X coordinate of the opposite corner. |
[in] | y2 | The Y coordinate of the opposite corner. |
Bool CheckDropArea | ( | const BaseContainer & | msg, |
Bool | horiz, | ||
Bool | vert | ||
) | const |
Checks the drag position in a drag event message against the user area's position in the layout. The check can be limited to only X or Y coordinates.
[in] | msg | The drag message. |
[in] | horiz | If true the drag position is checked against the horizontal bounds of the region. |
[in] | vert | If true the drag position is checked against the vertical bounds of the region. |
Internal.
void MouseDragStart | ( | Int32 | button, |
Float | mx, | ||
Float | my, | ||
MOUSEDRAGFLAGS | flag | ||
) |
Starts a mouse drag. Only call this when a mouse down message is received. Then repeatedly poll with MouseDrag during the drag.
[in] | button | The mouse button that is pressed: BFM_INPUT_CHANNEL |
[in] | mx | The X position of the mouse. |
[in] | my | The Y position of the mouse. |
[in] | flag | The mouse drag flags: MOUSEDRAGFLAGS |
MOUSEDRAGRESULT MouseDrag | ( | Float * | mx, |
Float * | my, | ||
BaseContainer * | channels | ||
) |
Polls the mouse during a drag started with MouseDragStart::
To check for qualifiers see the channels container:
[out] | mx | Assigned the X delta-coordinate of the mouse (the amount the mouse has moved). |
[out] | my | Assigned the Y delta-coordinate of the mouse (the amount the mouse has moved). |
[out] | channels | Assigned the channels values. See Input Events. Also contains these PEN values: PEN |
MOUSEDRAGRESULT MouseDragEnd | ( | ) |
Ends a mouse drag started with MouseDragStart.
|
friend |
|
private |
|
private |
|
protected |
If the user area is attached to a dialog this points to the dialog, otherwise nullptr. Can be used by derived classes.