3ds Max C++ API Reference
IColorSwatch Class Referenceabstract

#include <custcont.h>

+ Inheritance diagram for IColorSwatch:

Public Member Functions

virtual COLORREF SetColor (COLORREF c, int notify=FALSE)=0
 
COLORREF SetColor (Color c, int notify=FALSE)
 
virtual AColor SetAColor (AColor c, int notify=FALSE)=0
 
virtual COLORREF InitColor (COLORREF c, int notify=FALSE)=0
 
COLORREF InitColor (Color c, int notify=FALSE)
 
virtual AColor InitAColor (AColor c, int notify=FALSE)=0
 
virtual void SetUseAlpha (BOOL onOff)=0
 
virtual BOOL GetUseAlpha ()=0
 
virtual void SetIgnoreColorCorrection (bool ignore)
 Sets whether the color swatch should ignore the application-wide color correction and display the raw RGB(A) value. More...
 
virtual bool GetIgnoreColorCorrection () const
 Determines whether the color swatch should ignore the application-wide color correction and display the raw RGB(A) value. More...
 
virtual COLORREF GetColor ()=0
 
virtual AColor GetAColor ()=0
 
virtual void ForceDitherMode (BOOL onOff)=0
 
virtual void SetModal ()=0
 
virtual void Activate (int onOff)=0
 
virtual void EditThis (BOOL startNew=TRUE)=0
 
virtual void SetKeyBrackets (BOOL onOff)=0
 
virtual void SetNotifyAfterAccept (BOOL onOff)=0
 
virtual BOOL GetNotifyAfterAccept ()=0
 
- Public Member Functions inherited from ICustomControl
virtual HWND GetHwnd ()=0
 
virtual void Enable (BOOL onOff=TRUE)=0
 
virtual void Disable ()=0
 
virtual BOOL IsEnabled ()=0
 
virtual void Enable2 (BOOL onOff=TRUE)=0
 
virtual INT_PTR Execute (int cmd, ULONG_PTR arg1=0, ULONG_PTR arg2=0, ULONG_PTR arg3=0)
 
virtual void SetTooltip (bool bEnable, const MCHAR *text)=0
 Sets a tooltip for the custom control. More...
 
CoreExport void UpdateEnableState (Animatable *anim, int subNum)
 Helper function to disable or enable this UI control based on whether the Animatable associated with it is keyframable or not (locked parameter or scripted parameters are not keyframable). More...
 
- Public Member Functions inherited from InterfaceServer
virtual UtilExport ~InterfaceServer ()
 Destructor. More...
 
virtual UtilExport BaseInterfaceGetInterface (Interface_ID id)
 
template<class InterfaceType >
InterfaceType * GetTypedInterface ()
 

Additional Inherited Members

- 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

See also
Class ICustomControl, Custom User Interface Controls, COLORREF.

Description:
The color swatch control puts up the standard 3ds Max modeless color selector when the control is clicked on. The plug-in may be notified as the user interactively selects new colors.

To initialize the pointer to the control call:
*GetIColorSwatch(HWND hCtrl, COLORREF col, MCHAR *name);

For example: custCSw = GetIColorSwatch(GetDlgItem(hDlg, IDC_CSWATCH), RGB(255,255,255), _M("New Wireframe Color"));

This returns the pointer to the control, sets the initial color selected, and displays the text string passed in the title bar of the selection dialog.

To release the control call: ReleaseIColorSwatch(IColowSwatch ics);

The value to use in the Class field of the Custom Control Properties dialog is: ColorSwatch This message is sent as the color is being adjusted in the ColorPicker.

CC_COLOR_CHANGE

lParam = pointer to ColorSwatchControl

LOWORD(wParam) contains the ID of the control. This is the named established in the ID field of the Custom Control Properties dialog.

HIWORD(wParam) contains 1 if button UP, or 0 if mouse drag.

This message is sent if the color has been clicked on, before bringing up the color picker.

CC_COLOR_SEL

lParam contains a pointer to the ColorSwatch Control.

LOWORD(wParam) contains the ID of the control. This is the named established in the ID field of the Custom Control Properties dialog.

HIWORD(wParam) contains 0.

This message is sent if another color swatch has been dragged and dropped on this swatch.

CC_COLOR_DROP

lParam contains a pointer to the ColorSwatch Control.

LOWORD(wParam) contains the ID of the control. This is the named established in the ID field of the Custom Control Properties dialog.

HIWORD(wParam) contains 0.

This message is sent when the color picker is closed.

CC_COLOR_CLOSE

lParam contains a pointer to the ColorSwatch Control.

LOWORD(wParam) contains the ID of the control. This is the named established in the ID field of the Custom Control Properties dialog.

HIWORD(wParam) contains 0.

Member Function Documentation

◆ SetColor() [1/2]

virtual COLORREF SetColor ( COLORREF  c,
int  notify = FALSE 
)
pure virtual
Remarks
This method sets the current color value.
Parameters:
COLORREF c

You can pass specific RGB values in using the RGB macro. For example, to pass in pure blue you would use RGB(0,0,255).

int notify=FALSE

If you pass TRUE for this parameter, the dialog proc for the dialog will receive the CC_COLOR_CHANGE message each time the color is changed.
Returns
This method returns the old color.

◆ SetColor() [2/2]

COLORREF SetColor ( Color  c,
int  notify = FALSE 
)
inline
4149 {return SetColor(c.toRGB(), notify);} // returns old color
DWORD toRGB()
Definition: color.h:283
virtual COLORREF SetColor(COLORREF c, int notify=FALSE)=0

◆ SetAColor()

virtual AColor SetAColor ( AColor  c,
int  notify = FALSE 
)
pure virtual

◆ InitColor() [1/2]

virtual COLORREF InitColor ( COLORREF  c,
int  notify = FALSE 
)
pure virtual

◆ InitColor() [2/2]

COLORREF InitColor ( Color  c,
int  notify = FALSE 
)
inline
4154 {return InitColor(c.toRGB(), notify);} // returns old color
virtual COLORREF InitColor(COLORREF c, int notify=FALSE)=0

◆ InitAColor()

virtual AColor InitAColor ( AColor  c,
int  notify = FALSE 
)
pure virtual

◆ SetUseAlpha()

virtual void SetUseAlpha ( BOOL  onOff)
pure virtual

◆ GetUseAlpha()

virtual BOOL GetUseAlpha ( )
pure virtual

◆ SetIgnoreColorCorrection()

virtual void SetIgnoreColorCorrection ( bool  ignore)
inlinevirtual

Sets whether the color swatch should ignore the application-wide color correction and display the raw RGB(A) value.

See also
GetIgnoreColorCorrection()
4163 { ; }

◆ GetIgnoreColorCorrection()

virtual bool GetIgnoreColorCorrection ( ) const
inlinevirtual

Determines whether the color swatch should ignore the application-wide color correction and display the raw RGB(A) value.

See also
SetIgnoreColorCorrection()
4168 { return false; }

◆ GetColor()

virtual COLORREF GetColor ( )
pure virtual
Remarks
This method may be used to retrieve the color selected by the user.
Returns
The COLORREF structure returned may be broken down into individual RGB values by using the GetRValue(color), GetGValue(color), and GetBValue(color) macros.

◆ GetAColor()

virtual AColor GetAColor ( )
pure virtual

◆ ForceDitherMode()

virtual void ForceDitherMode ( BOOL  onOff)
pure virtual
Remarks
This method sets if the color shown in the color swatch is dithered on not.
Parameters:
BOOL onOff

TRUE to force the color to be dithered; otherwise FALSE.

◆ SetModal()

virtual void SetModal ( )
pure virtual
Remarks
Call this method to have the color selector comes up in a modal dialog. This forces the user to select OK before the user may operate the rest of the program.

◆ Activate()

virtual void Activate ( int  onOff)
pure virtual
Remarks
This method is called to indicate that the color swatch is in a dialog that has been become active or inactive. A color swatch that is in an inactive dialog will be drawn as dithered due to the limited number of color registers available on an 8-bit display.
Parameters:
int onOff

If TRUE the color swatch is in an active dialog. If FALSE the control is in an inactive dialog.

◆ EditThis()

virtual void EditThis ( BOOL  startNew = TRUE)
pure virtual
Remarks
If there is already a color picker up for a color swatch, this method switches it over to edit the color swatch on which EditThis() was called.
Parameters:
BOOL startNew=TRUE

If there was no color picker up, if this parameter is set to TRUE, then a color picker is created. If this parameter is set to FALSE, and there was no color picker up, then nothing happens.

◆ SetKeyBrackets()

virtual void SetKeyBrackets ( BOOL  onOff)
pure virtual

◆ SetNotifyAfterAccept()

virtual void SetNotifyAfterAccept ( BOOL  onOff)
pure virtual
Remarks
This method controls when change notifications are sent, while the color picker is open.
Parameters:
BOOL onOff

If you pass FALSE for this parameter, the dialog proc for the dialog will receive multiple CC_COLOR_CHANGE messages as the user makes changes interactively in the color picker. If you pass TRUE for this parameter, the dialog proc for the dialog will receive only one CC_COLOR_CHANGE message, when the color picker is closed, and only if the user clicks OK instead of Cancel.

◆ GetNotifyAfterAccept()

virtual BOOL GetNotifyAfterAccept ( )
pure virtual
Remarks
This methods indicates how change notifications are sent, while the color picker is open.
Returns
FALSE indicates the dialog proc for the dialog receives multiple CC_COLOR_CHANGE messages as the user makes changes interactively in the color picker. TRUE indicates the dialog proc for the dialog receives only one CC_COLOR_CHANGE message, when the color picker is closed, and only if the user clicks OK instead of Cancel.