3ds Max C++ API Reference
ViewportTextButton Class Reference

A simple text based button implementation of the IViewportButton. More...

#include <IViewportButton.h>

+ Inheritance diagram for ViewportTextButton:

Public Member Functions

CoreExport ViewportTextButton ()
 
CoreExport ~ViewportTextButton ()
 
CoreExport bool GetEnabled () const override
 Access to the enabled flag. More...
 
CoreExport void SetEnabled (bool v) override
 Set the Enabled flag. More...
 
CoreExport MSTR GetLabel () const override
 Access to the button text to be displayed in the viewport. More...
 
CoreExport void SetLabel (MSTR &label) override
 The developer simply sends in an unformated string, this class will then format it correct to [ XXXXX ]. More...
 
CoreExport IPoint2 GetLocation () const override
 Get the current location for the button. More...
 
CoreExport void SetLocation (IPoint2 &loc) override
 Set the location of the button. More...
 
CoreExport void SetColor (Color &c) override
 The default color will be defined by Viewport Text CUI entry. More...
 
CoreExport Color GetColor () const override
 Get the current color for the button. More...
 
CoreExport bool ShowInActiveViewportOnly () override
 Defines whether the button is only shown in the current active viewport. More...
 
CoreExport bool OnAction (HWND hwnd, GraphicsWindow *gw, IPoint2 hitLoc, IViewportButton::Action action) override
 Implementation of OnAction. More...
 
CoreExport bool OnUpdate (HWND hwnd, ViewExp *vpt) override
 An update callback that can be used to update internal data structures. More...
 
CoreExport void Display (TimeValue t, ViewExp *vpt, int flags) override
 Callback to display the button. More...
 
CoreExport void GetViewportRect (TimeValue t, ViewExp *vpt, Rect *rect) override
 Get the viewport rect for the button. More...
 
- Public Member Functions inherited from IViewportButton
 IViewportButton ()
 
virtual ~IViewportButton ()
 

Protected Attributes

bool mEnabled
 
MSTR mButtonText
 
MSTR mLabel
 
IPoint2 mLocation
 
Color mColor
 
bool mMouseOver
 
bool mOldMouseOver
 

Additional Inherited Members

- Public Types inherited from IViewportButton
enum  Action { eLeftClick = 0x0 , eRightClick , eMouseMove }
 
- Static Public Member Functions inherited from MaxHeapOperators
static UtilExport voidoperator new (size_t size)
 Standard new operator used to allocate objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, const std::nothrow_t &e)
 Standard new operator used to allocate objects if there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new (size_t size, const char *filename, int line)
 New operator used to allocate objects that takes the filename and line number where the new was called If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, int block_type, const char *filename, int line)
 New operator used to allocate objects that takes the type of memory, filename and line number where the new was called If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, const std::nothrow_t &e, const char *filename, int line)
 New operator used to allocate objects that takes the filename and line number where the new was called If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new (size_t size, unsigned long flags)
 New operator used to allocate objects that takes extra flags to specify special operations If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, const std::nothrow_t &e, unsigned long flags)
 New operator used to allocate objects that takes extra flags to specify special operations If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new[] (size_t size)
 New operator used to allocate arrays of objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new[] (size_t size, const std::nothrow_t &e)
 New operator used to allocate arrays of objects If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new[] (size_t size, const char *filename, int line)
 New operator used to allocate arrays of objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new[] (size_t size, int block_type, const char *filename, int line)
 New operator used to allocate arrays of objects. More...
 
static UtilExport voidoperator new[] (size_t size, const std::nothrow_t &e, const char *filename, int line)
 New operator used to allocate arrays of objects If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new[] (size_t size, unsigned long flags)
 New operator used to allocate arrays of objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new[] (size_t size, const std::nothrow_t &e, unsigned long flags)
 New operator used to allocate arrays of objects If there is insufficient memory, NULL will be returned. More...
 
static UtilExport void operator delete (void *ptr)
 Standard delete operator used to deallocate an object If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, const std::nothrow_t &e)
 Standard delete operator used to deallocate an object If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete (void *ptr, const char *filename, int line)
 Delete operator used to deallocate an object that takes the filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, int block_type, const char *filename, int line)
 Delete operator used to deallocate an object that takes the type of memory, filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, const std::nothrow_t &e, const char *filename, int line)
 Delete operator used to deallocate an object that takes the filename and line number where the delete was called If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete (void *ptr, unsigned long flags)
 Delete operator used to deallocate an object that takes extra flags to specify special operations If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, const std::nothrow_t &e, unsigned long flags)
 Delete operator used to deallocate an object that takes extra flags to specify special operations If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete[] (void *ptr)
 Standard delete operator used to deallocate an array of objects If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, const std::nothrow_t &e)
 Standard delete operator used to deallocate an array of objects If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete[] (void *ptr, const char *filename, int line)
 Delete operator used to deallocate an array of objects that takes the filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, int block_type, const char *filename, int line)
 Delete operator used to deallocate an array of objects that takes the type of memory, filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, const std::nothrow_t &e, const char *filename, int line)
 Delete operator used to deallocate an array of objects that takes the filename and line number where the delete was called If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete[] (void *ptr, unsigned long flags)
 Delete operator used to deallocate an array of objects that takes extra flags to specify special operations If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, const std::nothrow_t &e, unsigned long flags)
 Delete operator used to deallocate an array of objects that takes extra flags to specify special operations If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, void *placement_ptr)
 Placement new operator. More...
 
static UtilExport void operator delete (void *ptr, void *placement_ptr)
 Placement delete operator. More...
 
static UtilExport voidaligned_malloc (size_t size, size_t alignment)
 Allocates memory on a specified alignment boundary. More...
 
static UtilExport voidaligned_realloc (void *ptr, size_t size, size_t alignment)
 Reallocates memory on a specified alignment boundary. More...
 
static UtilExport void aligned_free (void *ptr)
 Frees a block of memory that was allocated with aligned_malloc/aligned_realloc. More...
 

Detailed Description

A simple text based button implementation of the IViewportButton.

A new viewport text button that is used to cerate the new viewport buttons in 3ds max 2010 It create a [XXXXX] button format, and support mouse over high lights. Developers can derive from this class to provide their own actions and update functions. TO use this class you must import CORE.LIB into your projects.

Please read the IViewportButton help section for an explanation of the methods.

Constructor & Destructor Documentation

◆ ViewportTextButton()

◆ ~ViewportTextButton()

Member Function Documentation

◆ GetEnabled()

CoreExport bool GetEnabled ( ) const
overridevirtual

Access to the enabled flag.

Returns
TRUE if enabled

Implements IViewportButton.

◆ SetEnabled()

CoreExport void SetEnabled ( bool  v)
overridevirtual

Set the Enabled flag.

If set to false, the button will not be drawn

Parameters
vTRUE to enable, FALSE to disable the button.

Implements IViewportButton.

◆ GetLabel()

CoreExport MSTR GetLabel ( ) const
overridevirtual

Access to the button text to be displayed in the viewport.

Returns
A string containing the current label to be displayed.

Implements IViewportButton.

◆ SetLabel()

CoreExport void SetLabel ( MSTR label)
overridevirtual

The developer simply sends in an unformated string, this class will then format it correct to [ XXXXX ].

Implements IViewportButton.

◆ GetLocation()

CoreExport IPoint2 GetLocation ( ) const
overridevirtual

Get the current location for the button.

Returns
The location of the button

Implements IViewportButton.

◆ SetLocation()

CoreExport void SetLocation ( IPoint2 loc)
overridevirtual

Set the location of the button.

Parameters
locThe new location for the button

Implements IViewportButton.

◆ SetColor()

CoreExport void SetColor ( Color c)
overridevirtual

The default color will be defined by Viewport Text CUI entry.

There is a new entry called Viewport Text Highlight that defines the mouse over color

Implements IViewportButton.

◆ GetColor()

CoreExport Color GetColor ( ) const
overridevirtual

Get the current color for the button.

Returns
The current color

Implements IViewportButton.

◆ ShowInActiveViewportOnly()

CoreExport bool ShowInActiveViewportOnly ( )
overridevirtual

Defines whether the button is only shown in the current active viewport.

Returns
TRUE if only drawn in the active viewport

Implements IViewportButton.

◆ OnAction()

CoreExport bool OnAction ( HWND  hwnd,
GraphicsWindow gw,
IPoint2  hitLoc,
IViewportButton::Action  action 
)
overridevirtual

Implementation of OnAction.

Developers must perform hittesting in there derived function and update the mMouseOver flag, followed by calling the base implementation. This is to allow the mouse over highlighting to work.

Implements IViewportButton.

◆ OnUpdate()

CoreExport bool OnUpdate ( HWND  hwnd,
ViewExp vpt 
)
overridevirtual

An update callback that can be used to update internal data structures.

The ViewportTextButton uses this to determine the Label to be used and location based on the current viewport being drawn.

Parameters
hwndThe Window handle issueing the update request
vptA pointer to current View
Returns
TRUE if an update was implemented.

Implements IViewportButton.

◆ Display()

CoreExport void Display ( TimeValue  t,
ViewExp vpt,
int  flags 
)
overridevirtual

Callback to display the button.

The ViewportTextButton uses this to draw text into the viewport using GraphicsWindow API. All drawing should go through this API - no GDI.

Parameters
tThe current time
vptTHe viewport to draw into
flags

Implements IViewportButton.

◆ GetViewportRect()

CoreExport void GetViewportRect ( TimeValue  t,
ViewExp vpt,
Rect rect 
)
overridevirtual

Get the viewport rect for the button.

Parameters
tThe current time
vptThe active viewport
rectThe result of the viewport rect is stored here.

Implements IViewportButton.

Member Data Documentation

◆ mEnabled

bool mEnabled
protected

◆ mButtonText

MSTR mButtonText
protected

◆ mLabel

MSTR mLabel
protected

◆ mLocation

IPoint2 mLocation
protected

◆ mColor

Color mColor
protected

◆ mMouseOver

bool mMouseOver
protected

◆ mOldMouseOver

bool mOldMouseOver
protected