root / trunk / win / Colorlst.h

Revision 717, 1.9 kB (checked in by leo, 16 months ago)

Improved focus handling on the color list control.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1#ifndef _COLORLST_H_
2#define _COLORLST_H_
3
4#define LC_COLORLIST_NUM_ROWS 6
5#define LC_COLORLIST_NUM_COLS 13
6
7class CColorTab
8{
9public:
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
21struct CColorEntry
22{
23    CRect Rect;
24    const char* Name;
25    COLORREF Color;
26    int Index;
27};
28
29class CColorList : public CWnd
30{
31public:
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
54protected:
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// Overrides
76    // ClassWizard generated virtual function overrides
77    //{{AFX_VIRTUAL(CColorList)
78    public:
79    virtual BOOL PreTranslateMessage(MSG* pMsg);
80    //}}AFX_VIRTUAL
81
82    // Generated message map functions
83protected:
84    //{{AFX_MSG(CColorList)
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    //}}AFX_MSG
95    DECLARE_MESSAGE_MAP()
96};
97
98#endif // _COLORLST_H_
Note: See TracBrowser for help on using the browser.