Public Member Functions | Protected Attributes

ViewportTextButton Class Reference

This reference page is linked to from the following overview topics: Viewport Button.


Search for all occurrences

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.

#include <IViewportButton.h>

Inheritance diagram for ViewportTextButton:
Inheritance graph
[legend]

List of all members.

Public Member Functions

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

Protected Attributes

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

Constructor & Destructor Documentation

CoreExport ViewportTextButton ( )
CoreExport ~ViewportTextButton ( )

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:
v TRUE 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:
&loc The 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:
hwnd The Window handle issueing the update request
*vpt A 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:
t The current time
*vpt THe 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:
t The current time
*vpt The active viewport
*rect The 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]

ViewportTextButton ViewportTextButton ViewportTextButton ViewportTextButton ViewportTextButton ViewportTextButton ViewportTextButton ViewportTextButton ViewportTextButton ViewportTextButton
ViewportTextButton ViewportTextButton ViewportTextButton ViewportTextButton ViewportTextButton ViewportTextButton ViewportTextButton ViewportTextButton ViewportTextButton ViewportTextButton