Class IMaxBitmapViewer

3DS Max Plug-In SDK

Class IMaxBitmapViewer

See Also: Class IImageViewer, Class Bitmap, Class CropCallback

class IMaxBitmapViewer : public IImageViewer

Description:

This class is available in release 4.0 and later only.

This class represents an abstract interface class for a default bitmap viewer.

The following functions are available for use but are not part of the class IMaxBitmapViewer.

Note that the minimum size of the floating window is 390 x 325.

Function:

IMaxBitmapViewer* CreateIMaxBitmapViewer(Bitmap* pBitmap, IImageViewer::DisplayStyle displayStyle);

Remarks:

This function allows you to create a new bitmap viewer as either a floating window or docked in a viewport.

Parameters:

Bitmap* pBitmap

The bitmap to use with the viewer. This should not be NULL.

IImageViewer::DisplayStyle displayStyle

The display style for the viewer, which is either IV_FLOATING or IV_DOCKED.

Return Value:

A pointer to a new IMaxBitmapViewer or NULL if the viewer could not be created.

Function:

void ReleaseIMaxBitmapViewer(IMaxBitmapViewer *);

Remarks:

This method will delete and release the specified bitmap viewer. This method should not be used while the viewer is being displayed. Use UnDisplay() or Hide() before calling this method.

Parameters:

IMaxBitmapViewer *

A pointer to the viewer.

Methods:

public:

Prototype:

virtual void SetBitmap(Bitmap* pBitmap) = 0;

Remarks:

This method allows you to set the bitmap which should be displayed in the bitmap viewer.

Note: This is for internal use only.

Parameters:

Bitmap* pBitmap

A pointer to the bitmap to display.

Prototype:

virtual Bitmap* GetBitmap() const = 0;

Remarks:

This method returns a pointer to the bitmap that is being displayed by the bitmap viewer.

Prototype:

virtual void SetCropCB(CropCallback* pCropCallback) = 0;

Remarks:

This method allows you to set the crop callback function which will assist in interactive adjustments of the bitmap cropping rectangle. This method should not be called after the window has been displayed. Preferably the callback should be set before the window is displayed or after the window has been destroyed.

Parameters:

CropCallback* pCropCallback

A pointer to the callback function to set.

Prototype:

virtual CropCallback* GetCropCB() const = 0;

Remarks:

This method returns a pointer to the crop callback function used by the bitmap viewer.

Prototype:

virtual void SetAutonomous(bool isAutonomous) = 0;

Remarks:

This method allows you to set whether the bitmap viewer is autonomous or not. When the bitmap viewer is set in autonomous mode, the viewer will not have a clone button, although the viewer will not display a clone button unless the save button is also displayed. Changes will not take effect until the next time the viewer is displayed using Display().

Parameters:

bool isAutonomous

TRUE to set the viewer to autonomous, otherwise FALSE.

Prototype:

virtual bool GetAutonomous() const = 0;

Remarks:

This method returns TRUE if the viewer is autonomous, otherwise FALSE. When the bitmap viewer is set in autonomous mode, the viewer will not have a clone button, although the viewer will not display a clone button unless the save button is also displayed.

Prototype:

virtual void SetCurrentPosition(WindowPosition currentPosition) = 0;

Remarks:

A call to this method will never impact the current opened window. This function should be used prior to calling Display() in order to specify the position of the next created window.

Prototype:

virtual WindowPosition GetCurrentPosition() const = 0;

Remarks:

This method returns the current position of the bitmap viewer.

Prototype:

virtual void SetShowSaveButton(bool showSaveButton) = 0;

Remarks:

This method allows you to set whether or not the save button should be shown as part of the bitmap viewer window. A change will not take effect until the next time the viewer is opened via Display().

Parameters:

bool showSaveButton

TRUE to show; FALSE to hide.

Prototype:

virtual bool GetShowSaveButton() const = 0;

Remarks:

This method returns TRUE if the save button is shown as part of the bitmap viewer window, otherwise FALSE.

Prototype:

virtual bool Display(TCHAR *title, WindowPosition position = WPos_Center) = 0;

Remarks:

This method will display the bitmap image viewer. Note that the Show() and Hide() methods have no effect until the window is initialized by a call to Display(). This method should not be called when the window is already open and this method can’t be used to create a docked viewer.

You should also not call this twice on this interface. The second time the function is called, the viewer will loose all references to the previoulsy opened window. To switch images using the same bitmap viewer, a call to "UnDisplay" should be made to close the previous window before calling this method again.

 

Parameters:

TCHAR *title

The title of the window to set.

WindowPosition position = WPos_Center

The window position you wish to set, which is one of the following enum values; WPos_NULL, WPos_UpperLeft, WPos_LowerLeft, WPos_UpperRight, WPos_LowerRight, WPos_Center.

Return Value:

TRUE if successful, otherwise FALSE.

Prototype:

virtual bool Display(TCHAR *title, HWND hParent, int x, int y, int w, int h) = 0;

Remarks:

This method will display the bitmap image viewer. Note that the Show() and Hide() methods have no effect until the window is initialized by a call to Display(). For docked viewers, the hParent parameter is the window into which te viewer will be docked. For floating viewers, the parameter has no effect.

You should also not call this twice on this interface. The second time the function is called, the viewer will loose all references to the previoulsy opened window. To switch images using the same bitmap viewer, a call to "UnDisplay" should be made to close the previous window before calling this method again.

Parameters:

TCHAR *title

The title of the window to set.

HWND hParent

A handle to the parent window.

int x, y, h, w

The position and dimensions of the window.

Note that these parameters will be ignored unless 'Current Position' is WPos_NULL.

Return Value:

TRUE if successful, otherwise FALSE.

Prototype:

virtual bool UnDisplay() = 0;

Remarks:

This method will undisplay the current bitmap image. The Show() and Hide() methods will no longer function after the window is destroyed.

Prototype:

virtual void ClearScreen() = 0;

Remarks:

This method will clear the bitmap image viewer window contents. This will not delete the window as it would using the Delete button on the viewer toolbar which actually deletes the contents of the bitmap.

Prototype:

virtual POINT XFormScreenToBitmap(const POINT &pt) const = 0;

Remarks:

This method will transform a specified point between the window’s client coordinates and the bitmap coordinates and return the result.

Parameters:

const POINT &pt

The point on screen.

Prototype:

virtual POINT XFormBitmapToScreen(const POINT &pt) const = 0;

Remarks:

This method will transform a specified point between the window’s client coordinates and the bitmap coordinates and return the result.

Parameters:

const POINT &pt

The point on the bitmap.

Prototype:

virtual Rect XFormScreenToBitmap(const Rect &rect) const = 0;

Remarks:

This method will transform a specified rectangle between the window’s client coordinates and the bitmap coordinates and return the result.

Parameters:

const Rect &rect

The screen rectangle.

Prototype:

virtual Rect XFormBitmapToScreen(const Rect &rect) const = 0;

Remarks:

This method will transform a specified rectangle between the window’s client coordinates and the bitmap coordinates and return the result.

Parameters:

const Rect &rect

The bitmap rectangle.

Prototype:

virtual void ShowToolbar(bool show) = 0;

Remarks:

This method allows you to set whether the toolbar should be shown as part of the bitmap image viewer window.

Parameters:

bool show

TRUE to show; FALSE to hide.

Prototype:

virtual void ToggleToolbar() = 0;

Remarks:

This method allows you to toggle the toolbar of the bitmap image viewer window on and off.

Prototype:

virtual void GetDrawableRect(Rect& drawableRect) = 0;

Remarks:

This method will retrieve the portion of the window's client area that is safe to draw in (in client coordinates and below the toolbar). This method can return a value larger than the displayed bitmap if the window size is large enough.

Parameters:

Rect& drawableRect

The client area.

Prototype:

virtual void RefreshWindow(Rect* pRefreshRegion = NULL) = 0;

Remarks:

This method will refresh the region of the window, or the entire window if region is NULL

Parameters:

Rect* pRefreshRegion = NULL

The region of the window you wish to refresh.