mrShaderButtonHandler Class Reference

#include <mrShaderButtonHandler.h>

+ Inheritance diagram for mrShaderButtonHandler:

Public Member Functions

 mrShaderButtonHandler (unsigned int applyTypes, int ctrlID)
 
virtual ~mrShaderButtonHandler ()
 
void OnInitDialog (HWND hDialog)
 
void OnCommand ()
 
void OnClose ()
 
void Update ()
 
void Enable (bool enable)
 
virtual SClass_ID GetDragType (HWND hwnd, POINT p)
 
virtual ReferenceTargetGetInstance (HWND hwnd, POINT p, SClass_ID type)
 
virtual BOOL OkToDrop (ReferenceTarget *dropThis, HWND hfrom, HWND hto, POINT p, SClass_ID type, BOOL isNew=FALSE)
 
virtual int SlotOwner ()
 
virtual void Drop (ReferenceTarget *dropThis, HWND hwnd, POINT p, SClass_ID type, DADMgr *srcMgr=NULL, BOOL bSrcClone=FALSE)
 
virtual BOOL AutoTooltip ()
 
- Public Member Functions inherited from DADMgr
virtual BOOL IsNew (HWND hwnd, POINT p, SClass_ID type)
 
virtual HCURSOR DropCursor (ReferenceTarget *dropThis, HWND hfrom, HWND hto, POINT p, SClass_ID type, BOOL isNew=FALSE)
 
virtual ReferenceTargetGetDestinationInstance (HWND hwnd, POINT p, SClass_ID type)
 
virtual void SameWinDragAndDrop (HWND h1, POINT p1, POINT p2)
 
virtual BOOL LetMeHandleLocalDAD ()
 
virtual void LocalDragAndDrop (HWND h1, HWND h2, POINT p1, POINT p2)
 
virtual BOOL CopyOnly (HWND hwnd, POINT p, SClass_ID type)
 
virtual BOOL AlwaysSendButtonMsgsOnDrop ()
 
virtual INT_PTR Execute (int cmd, ULONG_PTR arg1=0, ULONG_PTR arg2=0, ULONG_PTR arg3=0)
 
virtual BOOL OkToDropInstance (ReferenceTarget *dropThis, HWND hfrom, HWND hto, POINT p, SClass_ID type)
 
- Public Member Functions inherited from InterfaceServer
virtual UtilExport ~InterfaceServer ()
 Destructor. More...
 
virtual UtilExport BaseInterfaceGetInterface (Interface_ID id)
 

Protected Member Functions

virtual void SetShader (Texmap *shader)=0
 
virtual TexmapGetShader ()=0
 
virtual const MCHARGetNoneString ()=0
 

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

Constructor & Destructor Documentation

mrShaderButtonHandler ( unsigned int  applyTypes,
int  ctrlID 
)
29 : m_shaderFilter(applyTypes, TYPE_MAX_TYPE, true),
30  m_ctrlID(ctrlID),
31  m_dialogHWnd(NULL)
32 {
33 
34 }
#define NULL
Definition: autoptr.h:20
Definition: paramtype.h:352
~mrShaderButtonHandler ( )
virtual
36  {
37 
38 }

Member Function Documentation

void OnInitDialog ( HWND  hDialog)
55  {
56 
57  m_dialogHWnd = hDialog;
58 
59  DbgAssert(m_dialogHWnd != NULL);
60 
61  HWND ctrlHWnd = GetDlgItem(m_dialogHWnd, m_ctrlID);
62  ICustButton* custButton = GetICustButton(ctrlHWnd);
63  if(custButton != NULL) {
64  custButton->SetDADMgr(this);
65  ReleaseICustButton(custButton);
66  }
67  else {
68  DbgAssert(false);
69  }
70 
71  Update();
72 }
Definition: custcont.h:3124
#define NULL
Definition: autoptr.h:20
CoreExport ICustButton * GetICustButton(HWND hCtrl)
void Update()
Definition: mrShaderButtonHandler.cpp:108
virtual void SetDADMgr(DADMgr *dad)=0
CoreExport void ReleaseICustButton(ICustButton *icb)
#define DbgAssert(expr)
Definition: assert1.h:74
void OnCommand ( )
74  {
75 
76  DbgAssert(m_dialogHWnd != NULL);
77 
78  // Add the filter
80  if(filterManager != NULL) {
81  filterManager->AddFilter(m_shaderFilter);
82  }
83 
84  // Browse for a texmap
85  BOOL newMat;
86  BOOL cancel;
87  MtlBase* mtlBase = GetCOREInterface()->DoMaterialBrowseDlg(m_dialogHWnd, (BROWSE_MAPSONLY | BROWSE_INCNONE), newMat, cancel);
88  if(!cancel) {
89  DbgAssert((mtlBase == NULL) || ((mtlBase->SuperClassID() == TEXMAP_CLASS_ID)));
90 
91  Texmap* texmap = static_cast<Texmap*>(mtlBase);
92  SetShader(texmap);
93 
94  Update();
95  }
96 
97  if(filterManager != NULL) {
98  filterManager->RemoveFilter(m_shaderFilter);
99  }
100 }
virtual bool AddFilter(IMtlBrowserFilter &filter)=0
Adds a filter to the list.
IMtlBrowserFilter_Manager * Get_IMtlBrowserFilter_Manager()
Definition: IMtlBrowserFilter.h:84
#define NULL
Definition: autoptr.h:20
#define TEXMAP_CLASS_ID
Texture maps super-class ID.
Definition: plugapi.h:360
virtual bool RemoveFilter(IMtlBrowserFilter &filter)=0
Remove a filter from the list.
Definition: imtl.h:2571
void Update()
Definition: mrShaderButtonHandler.cpp:108
#define BROWSE_INCNONE
Include 'None' as an option.
Definition: render.h:550
#define BROWSE_MAPSONLY
Maps only.
Definition: render.h:549
Definition: IMtlBrowserFilter.h:36
CoreExport Interface * GetCOREInterface()
virtual MtlBase * DoMaterialBrowseDlg(HWND hParent, DWORD flags, BOOL &newMat, BOOL &cancel)=0
Definition: imtl.h:3280
#define DbgAssert(expr)
Definition: assert1.h:74
virtual CoreExport SClass_ID SuperClassID()
Retrieves a constant representing the type of the plugin.
virtual void SetShader(Texmap *shader)=0
void OnClose ( )
102  {
103 
104  DbgAssert(m_dialogHWnd != NULL);
105  m_dialogHWnd = NULL;
106 }
#define NULL
Definition: autoptr.h:20
#define DbgAssert(expr)
Definition: assert1.h:74
void Update ( )
108  {
109 
110  DbgAssert(m_dialogHWnd != NULL);
111 
112  HWND ctrlHWnd = GetDlgItem(m_dialogHWnd, m_ctrlID);
113  ICustButton* custButton = GetICustButton(ctrlHWnd);
114  if(custButton != NULL) {
115 
116  MSTR text;
117  Texmap* shader = GetShader();
118  if(shader != NULL)
119  text = shader->GetFullName();
120  else
121  text = GetNoneString();
122 
123  custButton->SetText(text.data());
124 
125  ReleaseICustButton(custButton);
126  }
127  else {
128  DbgAssert(false);
129  }
130 }
Definition: custcont.h:3124
virtual Texmap * GetShader()=0
#define NULL
Definition: autoptr.h:20
CoreExport ICustButton * GetICustButton(HWND hCtrl)
virtual const MCHAR * GetNoneString()=0
const wchar_t * data() const
virtual CoreExport MSTR GetFullName()
virtual void SetText(const MCHAR *text)=0
Definition: strclass.h:665
CoreExport void ReleaseICustButton(ICustButton *icb)
Definition: imtl.h:3280
#define DbgAssert(expr)
Definition: assert1.h:74
void Enable ( bool  enable)
40  {
41 
42  DbgAssert(m_dialogHWnd != NULL);
43 
44  HWND ctrlHWnd = GetDlgItem(m_dialogHWnd, m_ctrlID);
45  ICustButton* custButton = GetICustButton(ctrlHWnd);
46  if(custButton != NULL) {
47  custButton->Enable(enable);
48  ReleaseICustButton(custButton);
49  }
50  else {
51  DbgAssert(false);
52  }
53 }
Definition: custcont.h:3124
virtual void Enable(BOOL onOff=TRUE)=0
#define NULL
Definition: autoptr.h:20
CoreExport ICustButton * GetICustButton(HWND hCtrl)
CoreExport void ReleaseICustButton(ICustButton *icb)
#define DbgAssert(expr)
Definition: assert1.h:74
SClass_ID GetDragType ( HWND  hwnd,
POINT  p 
)
virtual
Remarks
This method is called on the item that supports drag and drop to see what (if anything) can be dragged from the point p. This method returns a super class id to indicate the type of item that can be dragged away. If it does not support anything being dragged from the specified point a SClass_ID of 0 should be returned.
Parameters:
HWND hwnd

The source window handle

POINT p

The screen point (relative to the window upper left as 0,0).

Implements DADMgr.

133  {
134 
135  return TEXMAP_CLASS_ID;
136 }
#define TEXMAP_CLASS_ID
Texture maps super-class ID.
Definition: plugapi.h:360
ReferenceTarget * GetInstance ( HWND  hwnd,
POINT  p,
SClass_ID  type 
)
virtual
Remarks
Return a pointer to the drag source.
Parameters:
HWND hwnd

The source window where the mouse down occurred.

POINT p

The point to drag from (position within hwnd).

SClass_ID type

The super class ID of the item to create.

Implements DADMgr.

138  {
139 
140  if(type == TEXMAP_CLASS_ID) {
141  Texmap* shader = GetShader();
142  return shader;
143  }
144  else {
145  return NULL;
146  }
147 }
virtual Texmap * GetShader()=0
#define NULL
Definition: autoptr.h:20
#define TEXMAP_CLASS_ID
Texture maps super-class ID.
Definition: plugapi.h:360
Definition: imtl.h:3280
BOOL OkToDrop ( ReferenceTarget dropThis,
HWND  hfrom,
HWND  hto,
POINT  p,
SClass_ID  type,
BOOL  isNew = FALSE 
)
virtual
Remarks
This method is called on potential dropee to see if can accept the specified type at the specified point.
Parameters:
ReferenceTarget *dropThis

A pointer to the item to check.

HWND hfrom

The window handle of the source.

HWND hto

The window handle of the destination.

POINT p

The point to check.

SClass_ID type

The super class ID of dropThis.

BOOL isNew = FALSE

TRUE if the item is a new instance; otherwise FALSE.
Returns
TRUE if the specified item can be dropped; otherwise FALSE.

Implements DADMgr.

149  {
150 
151  if(type == TEXMAP_CLASS_ID) {
152 
153  Texmap* texmap = static_cast<Texmap*>(dropThis);
154  if(texmap == NULL) {
155  return TRUE;
156  }
157  else {
158  return m_shaderFilter.Include(*texmap, 0);
159  }
160  }
161 
162  return FALSE;
163 }
#define NULL
Definition: autoptr.h:20
#define TEXMAP_CLASS_ID
Texture maps super-class ID.
Definition: plugapi.h:360
virtual bool Include(MtlBase &mtlBase, DWORD flags)
Returns whether the given material/map should be included in the browser, when browsing for existing ...
Definition: mrShaderFilter.cpp:70
Definition: imtl.h:3280
int SlotOwner ( )
virtual
Remarks
Returns a predefined value to indicate the source of the drag.
Returns
One of the following values:

OWNER_MEDIT_SAMPLE

From a materials editor sample slot.

OWNER_NODE

From a node in the scene.

OWNER_MTL_TEX

From a button in a material or texture.

OWNER_SCENE

From a button in a light, modifier, atmospheric effect, etc.

OWNER_BROWSE_NEW

From the browser in the new category.

OWNER_BROWSE_LIB

From the browser in the library category.

OWNER_BROWSE_MEDIT

From the browser in the materials editor category.

OWNER_BROWSE_SCENE

From the browser in the scene category. OWNER_MATERIAL_EXPLORER

From the material explorer.
Default Implementation:
{ return OWNER_MTL_TEX; }

Reimplemented from DADMgr.

165  {
166 
167  return OWNER_SCENE;
168 }
#define OWNER_SCENE
Definition: custcont.h:63
void Drop ( ReferenceTarget dropThis,
HWND  hwnd,
POINT  p,
SClass_ID  type,
DADMgr srcMgr = NULL,
BOOL  bSrcClone = FALSE 
)
virtual
Remarks
This is the method called to actually process the drop operation. This routine is called on the target with the pointer returned by the source's GetInstance(), or possibly a clone of it as the dropThis.
Parameters:
ReferenceTarget *dropThis

A pointer to the item to drop.

HWND hwnd

The destination window handle (where the mouse was released).

POINT p

The destination point (within hwnd).

SClass_ID type

The type of object being dropped – the super class ID of dropThis.

DADMgr* srcMgr

The source DADMgr pointer. NULL by default.

BOOL bSrcClone

TRUE if the dropThis is a clone of the drag source object, FALSE otherwise. FALSE by default

Implements DADMgr.

170  {
171 
172  DbgAssert(OkToDrop(dropThis, NULL, hwnd, p, type, FALSE));
173  if((dropThis == NULL) || (dropThis->SuperClassID() == TEXMAP_CLASS_ID)) {
174  Texmap* texmap = static_cast<Texmap*>(dropThis);
175  SetShader(texmap);
176 
177  Update();
178  }
179 }
#define NULL
Definition: autoptr.h:20
#define TEXMAP_CLASS_ID
Texture maps super-class ID.
Definition: plugapi.h:360
virtual BOOL OkToDrop(ReferenceTarget *dropThis, HWND hfrom, HWND hto, POINT p, SClass_ID type, BOOL isNew=FALSE)
Definition: mrShaderButtonHandler.cpp:149
void Update()
Definition: mrShaderButtonHandler.cpp:108
Definition: imtl.h:3280
#define DbgAssert(expr)
Definition: assert1.h:74
virtual CoreExport SClass_ID SuperClassID()
Retrieves a constant representing the type of the plugin.
virtual void SetShader(Texmap *shader)=0
BOOL AutoTooltip ( )
virtual
Remarks
If this method returns TRUE, then Custom Buttons that use this DAD Manager will automatically support a tooltip that matches the button text. Note that this method will only show a tooltip when the button text is too long and thus exceeds the button size.
Default Implementation:
{ return FALSE; }

Reimplemented from DADMgr.

181  {
182 
183  return TRUE;
184 }
virtual void SetShader ( Texmap shader)
protectedpure virtual
virtual Texmap* GetShader ( )
protectedpure virtual
virtual const MCHAR* GetNoneString ( )
protectedpure virtual