hsv.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /**********************************************************************
  2. *<
  3. FILE: hsv.h
  4. DESCRIPTION:
  5. CREATED BY: Dan Silva
  6. HISTORY:
  7. *> Copyright (c) 1994, All Rights Reserved.
  8. **********************************************************************/
  9. #ifndef __HSV__H
  10. #define __HSV__H
  11. #define MAXCOLORS 16
  12. // This callback proc gets called after every mouse button up to tell you the
  13. // new color, if you want to do interactive update.
  14. class HSVCallback {
  15. public:
  16. virtual void ButtonDown() {}
  17. virtual void ButtonUp(BOOL accept) {}
  18. virtual void ColorChanged(DWORD col, BOOL buttonUp)=0;
  19. virtual void BeingDestroyed(IPoint2 pos)=0; // gets called when picker is closed:
  20. };
  21. // Put up the dialog.
  22. extern CoreExport int HSVDlg_Do(
  23. HWND hwndOwner, // owning window
  24. DWORD *lpc, // pointer to color to be edited
  25. IPoint2 *spos, // starting position, set to ending position
  26. HSVCallback *callBack, // called when color changes
  27. TCHAR *name // name of color being edited
  28. );
  29. CoreExport void RGBtoHSV (DWORD rgb, int *ho, int *so, int *vo);
  30. CoreExport DWORD HSVtoRGB (int H, int S, int V);
  31. CoreExport void HSVtoHWBt (int h, int s, int v, int *ho, int *w, int *bt);
  32. CoreExport void HWBttoHSV (int h, int w, int bt, int *ho, int *s, int *v);
  33. // RB: Added floating point versions
  34. class Color;
  35. CoreExport Color RGBtoHSV(Color rgb);
  36. CoreExport Color HSVtoRGB(Color hsv);
  37. // MODELESS Version
  38. class ColorPicker {
  39. public:
  40. ColorPicker() {}
  41. virtual ~ColorPicker() {};
  42. virtual void ModifyColor (DWORD color)=0;
  43. virtual void SetNewColor (DWORD color, TCHAR *name)=0;
  44. virtual DWORD GetColor()=0;
  45. virtual IPoint2 GetPosition()=0;
  46. virtual void Destroy()=0; //when parent is going away.
  47. virtual void InstallNewCB(DWORD col, HSVCallback *pcb, TCHAR *name)=0;
  48. };
  49. CoreExport ColorPicker *CreateColorPicker(HWND hwndOwner, DWORD initColor,
  50. IPoint2* spos, HSVCallback *pcallback, TCHAR *name, int objClr=0);
  51. CoreExport void SetCPInitPos(IPoint2 &pos);
  52. CoreExport IPoint2 GetCPInitPos(void);
  53. #define WM_ADD_COLOR (WM_USER+2321) // wParam = color
  54. #endif