hsv.h

Go to the documentation of this file.
00001 /**********************************************************************
00002  *<
00003     FILE: hsv.h
00004 
00005     DESCRIPTION:
00006 
00007     CREATED BY: Dan Silva
00008 
00009     HISTORY:
00010 
00011     NH 16|05|03 - Added AColor support.
00012 
00013  *> Copyright (c) 1994, All Rights Reserved.
00014  **********************************************************************/
00015 
00016 #pragma once
00017 #include "maxheap.h"
00018 #include "coreexp.h"
00019 #include <WTypes.h>
00020 #include "acolor.h"
00021 #include "ipoint2.h"
00022 #include "baseinterface.h"
00023 #include "strbasic.h"
00024 
00025 #define MAXCOLORS 16
00026 
00027 
00028 // This callback proc gets called after every mouse button up to tell you the
00029 // new color, if you want to do interactive update.
00030 
00035 #pragma warning(push)
00036 #pragma warning(disable:4100)
00037 
00038 class HSVCallback : public MaxHeapOperators {
00039     public:
00041         virtual ~HSVCallback() {;}
00045         virtual void ButtonDown() {}
00053         virtual void ButtonUp(BOOL accept) {}
00062         virtual void ColorChanged(DWORD col, BOOL buttonUp) {}
00071         virtual void ColorChanged(AColor col, BOOL ButtonUp) {}
00076         virtual void BeingDestroyed(IPoint2 pos)=0; // gets called when picker is closed: 
00081         CoreExport virtual void OnOK();
00086         CoreExport virtual void OnCancel();
00087     };
00088 
00089 // Put up the Modal dialog.
00110 extern CoreExport INT_PTR HSVDlg_Do(
00111                              HWND hwndOwner,        // owning window
00112                              DWORD*   lpc,          // pointer to color to be edited
00113                              IPoint2*   spos,       // starting position, set to ending position
00114                              HSVCallback* callBack, // called when color changes
00115                              MCHAR* name            // name of color being edited
00116                              );
00117 
00118 // NH 16|05|03 Added this method to support AColor.
00136 extern CoreExport INT_PTR HSVDlg_Do(
00137                                     HWND hwndOwner,         // owning window
00138                                     AColor *lpc,                // pointer to color to be edited
00139                                     IPoint2 *spos,          // starting position, set to ending position
00140                                     HSVCallback *callBack,  // called when color changes
00141                                     MCHAR *name             // name of color being edited
00142                                     );
00143 
00144 CoreExport void RGBtoHSV (DWORD rgb, int *ho, int *so, int *vo);
00145 CoreExport DWORD HSVtoRGB (int H, int S, int V);
00146 CoreExport void HSVtoHWBt (int h, int s, int v, int *ho, int *w, int *bt);
00147 CoreExport void HWBttoHSV (int h, int w, int bt, int *ho, int *s, int *v);
00148 
00149 // RB: Added floating point versions
00150 class Color;
00151 CoreExport Color RGBtoHSV(Color rgb);
00152 CoreExport Color HSVtoRGB(Color hsv);
00153 
00154 // MODELESS Version
00155 
00165 class ColorPicker : public InterfaceServer {
00166     protected:
00168     ~ColorPicker() {}
00169     public:
00171         ColorPicker() {}
00177         virtual void ModifyColor (DWORD color)=0;
00184         virtual void SetNewColor (DWORD color, MCHAR *name)=0;  
00186         virtual DWORD GetColor()=0;
00189         virtual IPoint2 GetPosition()=0;
00191         virtual void Destroy()=0;  // remove window and delete ColorPicker.
00201         virtual void InstallNewCB(DWORD col, HSVCallback *pcb, MCHAR *name)=0;
00205         virtual void RefreshUI() {}  // Called when display gamma changes
00206 
00207 
00208         // NH 16|05|03 Added this method to support AColor. 
00214         virtual void ModifyColor(AColor color){}
00215         // NH 16|05|03 Added this method to support AColor. 
00222         virtual void SetNewColor(AColor, MCHAR * name){}
00223         // NH 16|05|03 Added this method to support AColor. THis will return the AColor from the picker.
00226         virtual AColor GetAColor(){return AColor(0,0,0,0);}
00227         // NH 16|05|03 Added this method to support AColor. 
00237         virtual void InstallNewCB(AColor col, HSVCallback *pcb, MCHAR *name){}
00238         //Brian Duan 22|05|08 Add this method to support Managed ColorPicker 
00239         //in Scene Explorer and Material Explorer.
00242         CoreExport virtual RECT GetRect()const;
00243         
00250         CoreExport virtual bool IsColorSamplerMode()const;
00251     };
00252 
00253 // Create A Modeless Color Picker
00272 CoreExport ColorPicker *CreateColorPicker(HWND hwndOwner, DWORD initColor,
00273      IPoint2* spos, HSVCallback *pcallback, MCHAR *name, int objClr=0);
00274 
00275 
00276 // Create A Modeless Color Picker
00277 // NH 16|05|03 Added this method to support AColor.
00278 CoreExport ColorPicker *CreateColorPicker(HWND hwndOwner, AColor initColor,
00279      IPoint2* spos, HSVCallback *pcallback, MCHAR *name, int objClr=0);
00280      
00285 CoreExport void SetCPInitPos(IPoint2 &pos);
00289 CoreExport IPoint2 GetCPInitPos(void);  
00290 
00291 #define WM_ADD_COLOR    (WM_USER+2321)  // wParam = color
00292 
00293 //--------------------------------------------------------------------------
00294 // Pluggable color picker class ( COLPICK_CLASS_ID )
00295 //--------------------------------------------------------------------------
00296 
00297 
00310 class ColPick : public InterfaceServer {
00311     public:
00312     // Do Modal dialog
00313     virtual INT_PTR ModalColorPicker(
00314         HWND hwndOwner,         // owning window
00315         DWORD *lpc,             // pointer to color to be edited
00316         IPoint2 *spos,          // starting position, set to ending position
00317         HSVCallback *callBack,  // called when color changes
00318         MCHAR *name             // name of color being edited
00319         )=0;
00335     virtual INT_PTR ModalColorPicker(
00336         HWND hwndOwner,         // owning window
00337         AColor *lpc,                // pointer to color to be edited
00338         IPoint2 *spos,          // starting position, set to ending position
00339         HSVCallback *callBack,  // called when color changes
00340         MCHAR *name             // name of color being edited
00341         ){return 0;}
00342 
00343     // Create Modeless dialog.
00361     virtual ColorPicker *CreateColorPicker(
00362         HWND hwndOwner,   // owning window
00363         DWORD initColor,  // inital value of color
00364         IPoint2* spos,    // starting position of dialog
00365         HSVCallback *pcallback, // call back when color changes
00366         MCHAR *name,      // name of color being edited
00367         BOOL isObjectColor=FALSE)=0;
00368 
00385     virtual ColorPicker *CreateColorPicker(
00386         HWND hwndOwner,   // owning window
00387         AColor initColor,  // inital value of color
00388         IPoint2* spos,    // starting position of dialog
00389         HSVCallback *pcallback, // call back when color changes
00390         MCHAR *name,      // name of color being edited
00391         BOOL isObjectColor=FALSE){return NULL;}
00392 
00395     virtual const MCHAR* ClassName()=0;
00398     virtual Class_ID ClassID()=0;
00400     virtual void DeleteThis()=0;
00402     virtual INT_PTR Execute(int cmd, ULONG_PTR arg1=0, ULONG_PTR arg2=0, ULONG_PTR arg3=0)=0; 
00403     };
00404 
00405 #pragma warning(pop)
00406 //--------------------------------------------------------------------------
00407 // the class id for the default color picker is Class_ID(DEFAULT_COLPICK_CLASS_ID,0)
00408 
00409 #define DEFAULT_COLPICK_CLASS_ID 1
00410 
00411 //--------------------------------------------------------------------------
00412 // These are used by the MAX to plug in the current color picker.  
00413 // Developers should not need to access these.
00421 CoreExport ColPick *SetCurColPick(ColPick *colpick);
00424 CoreExport ColPick *GetCurColPick();
00425 //--------------------------------------------------------------------------
00426    
00427 //--------------------------------------------------------------------------
00428 
00429