| 1 | #ifndef _COLORLST_H_ |
|---|
| 2 | #define _COLORLST_H_ |
|---|
| 3 | |
|---|
| 4 | #define LC_COLORLIST_NUM_ROWS 6 |
|---|
| 5 | #define LC_COLORLIST_NUM_COLS 13 |
|---|
| 6 | |
|---|
| 7 | class CColorTab |
|---|
| 8 | { |
|---|
| 9 | public: |
|---|
| 10 | CColorTab(const char* Text) : m_Text(Text) { } |
|---|
| 11 | ~CColorTab() { } |
|---|
| 12 | |
|---|
| 13 | void Draw(CDC& dc, CFont& Font, BOOL Selected, BOOL Focus); |
|---|
| 14 | void GetTrapezoid(const CRect& rc, CPoint* pts) const; |
|---|
| 15 | |
|---|
| 16 | CString m_Text; |
|---|
| 17 | CRect m_Rect; |
|---|
| 18 | CRgn m_Rgn; |
|---|
| 19 | }; |
|---|
| 20 | |
|---|
| 21 | struct CColorEntry |
|---|
| 22 | { |
|---|
| 23 | CRect Rect; |
|---|
| 24 | const char* Name; |
|---|
| 25 | COLORREF Color; |
|---|
| 26 | int Index; |
|---|
| 27 | }; |
|---|
| 28 | |
|---|
| 29 | class CColorList : public CWnd |
|---|
| 30 | { |
|---|
| 31 | public: |
|---|
| 32 | CColorList(); |
|---|
| 33 | virtual ~CColorList(); |
|---|
| 34 | |
|---|
| 35 | BOOL Create(DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID); |
|---|
| 36 | |
|---|
| 37 | void SetCurColor(int Index) |
|---|
| 38 | { |
|---|
| 39 | for (int i = 0; i < m_Colors.GetSize(); i++) |
|---|
| 40 | { |
|---|
| 41 | if (m_Colors[i].Index == Index) |
|---|
| 42 | { |
|---|
| 43 | SelectColor(i); |
|---|
| 44 | break; |
|---|
| 45 | } |
|---|
| 46 | } |
|---|
| 47 | } |
|---|
| 48 | |
|---|
| 49 | int GetCurColor() const |
|---|
| 50 | { |
|---|
| 51 | return m_Colors[m_CurColor].Index; |
|---|
| 52 | } |
|---|
| 53 | |
|---|
| 54 | protected: |
|---|
| 55 | CToolTipCtrl m_ToolTip; |
|---|
| 56 | |
|---|
| 57 | CFont m_NormalFont; |
|---|
| 58 | CFont m_SelectedFont; |
|---|
| 59 | |
|---|
| 60 | CPtrArray m_Tabs; |
|---|
| 61 | int m_CurTab; |
|---|
| 62 | |
|---|
| 63 | CArray<CColorEntry, const CColorEntry&> m_Colors; |
|---|
| 64 | int m_CurColor; |
|---|
| 65 | |
|---|
| 66 | int m_ColorCols; |
|---|
| 67 | int m_ColorRows; |
|---|
| 68 | |
|---|
| 69 | void UpdateLayout(); |
|---|
| 70 | void SelectTab(int Tab); |
|---|
| 71 | void SelectColor(int Color); |
|---|
| 72 | |
|---|
| 73 | bool m_ColorFocus; |
|---|
| 74 | |
|---|
| 75 | |
|---|
| 76 | |
|---|
| 77 | |
|---|
| 78 | public: |
|---|
| 79 | virtual BOOL PreTranslateMessage(MSG* pMsg); |
|---|
| 80 | |
|---|
| 81 | |
|---|
| 82 | |
|---|
| 83 | protected: |
|---|
| 84 | |
|---|
| 85 | afx_msg void OnPaint(); |
|---|
| 86 | afx_msg void OnLButtonDown(UINT nFlags, CPoint point); |
|---|
| 87 | afx_msg void OnSize(UINT nType, int cx, int cy); |
|---|
| 88 | afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags); |
|---|
| 89 | afx_msg void OnSetFocus(CWnd* pOldWnd); |
|---|
| 90 | afx_msg void OnKillFocus(CWnd* pNewWnd); |
|---|
| 91 | afx_msg UINT OnGetDlgCode(); |
|---|
| 92 | afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message); |
|---|
| 93 | afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); |
|---|
| 94 | |
|---|
| 95 | DECLARE_MESSAGE_MAP() |
|---|
| 96 | }; |
|---|
| 97 | |
|---|
| 98 | #endif // _COLORLST_H_ |
|---|