ViewportTextButton Class Reference

#include <IViewportButton.h>

Class 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.

+ Inheritance diagram for ViewportTextButton:

Public Member Functions

CoreExport ViewportTextButton ()
 
CoreExport ~ViewportTextButton ()
 
CoreExport bool GetEnabled () const
 Access to the enabled flag. More...
 
CoreExport void SetEnabled (bool v)
 Set the Enabled flag. More...
 
CoreExport MSTR GetLabel () const
 Access to the button text to be displayed in the viewport. More...
 
CoreExport void SetLabel (MSTR &label)
 The developer simply sends in an unformated string, this class will then format it correct to [ XXXXX ]. More...
 
CoreExport IPoint2 GetLocation () const
 Get the current location for the button. More...
 
CoreExport void SetLocation (IPoint2 &loc)
 Set the location of the button. More...
 
CoreExport void SetColor (Color &c)
 The default color will be defined by Viewport Text CUI entry. More...
 
CoreExport Color GetColor () const
 Get the current color for the button. More...
 
CoreExport bool ShowInActiveViewportOnly ()
 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)
 Implementation of OnAction. More...
 
CoreExport bool OnUpdate (HWND hwnd, ViewExp *vpt)
 An update callback that can be used to update internal data structures. More...
 
CoreExport void Display (TimeValue t, ViewExp *vpt, int flags)
 Callback to display the button. More...
 
CoreExport void GetViewportRect (TimeValue t, ViewExp *vpt, Rect *rect)
 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...
 

Constructor & Destructor Documentation

Member Function Documentation

CoreExport bool GetEnabled ( ) const
virtual

Access to the enabled flag.

Returns
TRUE if enabled

Implements IViewportButton.

CoreExport void SetEnabled ( bool  v)
virtual

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.

CoreExport MSTR GetLabel ( ) const
virtual

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

Returns
A string containing the current label to be displayed.

Implements IViewportButton.

CoreExport void SetLabel ( MSTR label)
virtual

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

Implements IViewportButton.

CoreExport IPoint2 GetLocation ( ) const
virtual

Get the current location for the button.

Returns
The location of the button

Implements IViewportButton.

CoreExport void SetLocation ( IPoint2 loc)
virtual

Set the location of the button.

Parameters
locThe new location for the button

Implements IViewportButton.

CoreExport void SetColor ( Color c)
virtual

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.

CoreExport Color GetColor ( ) const
virtual

Get the current color for the button.

Returns
The current color

Implements IViewportButton.

CoreExport bool ShowInActiveViewportOnly ( )
virtual

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

Returns
TRUE if only drawn in the active viewport

Implements IViewportButton.

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

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.

CoreExport bool OnUpdate ( HWND  hwnd,
ViewExp vpt 
)
virtual

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.

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

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.

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

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

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