1 #pragma once 2 3 // color_edit_dialog dialog 4 #include "studiox_includes.h" 5 #include "afxwin.h" 6 #include "afxcmn.h" 7 8 class color_edit_dialog; 9 10 class color_gradient_win : public CWnd 11 { 12 public: 13 color_gradient_win(CWnd* pParent = NULL); ~color_gradient_win()14 ~color_gradient_win() {}; 15 16 DECLARE_MESSAGE_MAP() 17 afx_msg void OnPaint(); 18 afx_msg BOOL OnEraseBkgnd(CDC* pDC); 19 afx_msg void OnLButtonDown(UINT nFlags, CPoint point); 20 virtual BOOL PreTranslateMessage(MSG* pMsg); 21 afx_msg void OnSetFocus(CWnd* pOldWnd); 22 afx_msg void OnKillFocus(CWnd* pNewWnd); 23 24 void PaintColorGradient(CDC *pDC); 25 void PaintColorGradientHighlight (CDC* pDC); 26 void PaintColorPalette(CDC *pDC); 27 void PaintColorPaletteHighlight(CDC* pDC); 28 29 protected: 30 void GetColorGradientDimension(int *rows, int *cols); 31 void GetSelectedPos(int *row, int *col); 32 void SetSelectedPos(int row, int col); 33 void InvalidateSelection(int row, int col); 34 35 protected: 36 int m_swatch_size; 37 studiox_project *mpProject; 38 color_edit_dialog *mpParent; 39 }; 40 41 class color_edit_dialog : public express_dialog 42 { 43 44 public: 45 color_edit_dialog(resource_item *res, int display_index, CWnd* pParent = NULL); // standard constructor 46 color_edit_dialog(int display_index, CWnd *pParent = NULL); 47 48 virtual ~color_edit_dialog(); 49 50 virtual void OnOK(); 51 52 GX_COLOR GetColor(); 53 CString GetName(); 54 55 static void RgbToHsl(int red, int green, int blue, int &hue, int &saturation, int &luminance); 56 static void HslToRgb(double hue, double sat, double lum, int &red, int &green, int &blue); GetPalette()57 palette_info *GetPalette() { return &mPalette; } 58 void GetHSLColor(int *hue, int *sat, int *lum); 59 void SetHSLColor(int hue, int sat); 60 void SetPaletteColor(int index); GetPaletteColor()61 int GetPaletteColor() { return mColorIndex; } 62 63 // Dialog Data 64 enum { IDD = IDD_COLOR_EDIT }; 65 66 protected: 67 virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support 68 DECLARE_MESSAGE_MAP() 69 void UpdateHSLFields(); 70 void UpdateRGBVals(); 71 void UpdateRGBFields(); 72 73 void PaintColorPreview(); 74 BOOL IsAlphaFormat(int color_format); 75 void AnnounceColorUpdate(CString msg); 76 77 public: 78 afx_msg void OnEnChangeEditRed(); 79 afx_msg void OnEnChangeEditGreen(); 80 afx_msg void OnEnChangeEditBlue(); 81 afx_msg void OnEnChangeEditAlpha(); 82 83 afx_msg void OnEnChangeEditHue(); 84 afx_msg void OnEnChangeEditSaturation(); 85 afx_msg void OnEnChangeEditLuminance(); 86 87 afx_msg void OnPaint(); 88 afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); 89 virtual BOOL OnInitDialog(); 90 afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar *bar); 91 afx_msg LRESULT OnTestMessage(WPARAM wParam, LPARAM lParam); 92 93 94 virtual BOOL PreTranslateMessage(MSG* pMsg); 95 96 private: 97 CString mName; 98 99 int mRed; 100 int mGreen; 101 int mBlue; 102 int mAlpha; 103 int mHue; 104 int mSat; 105 int mLum; 106 int mDisplayIndex; 107 int mResId; 108 int mColorIndex; 109 palette_info mPalette; 110 studiox_project *mpProject; 111 res_info *mpRes; 112 113 protected: 114 CEdit mRedEdit; 115 CEdit mGreenEdit; 116 CEdit mBlueEdit; 117 CEdit mAlphaEdit; 118 CEdit mHueEdit; 119 CEdit mSaturationEdit; 120 CEdit mLuminanceEdit; 121 CSliderCtrl mRedSlider; 122 CSliderCtrl mGreenSlider; 123 CSliderCtrl mBlueSlider; 124 CSliderCtrl mAlphaSlider; 125 CSliderCtrl mHueSlider; 126 CSliderCtrl mSaturationSlider; 127 CSliderCtrl mLuminanceSlider; 128 color_gradient_win *mpColorGradientWin; 129 CStatic mColorUpdateMsg; 130 }; 131