leocad/win/Colorlst.h

107 lines
2.1 KiB
C
Raw Normal View History

2012-04-29 22:00:16 +02:00
#ifndef _COLORLST_H_
#define _COLORLST_H_
2011-09-07 23:06:51 +02:00
2012-04-29 22:00:16 +02:00
class CColorToolTipCtrl : public CMFCToolTipCtrl
{
DECLARE_DYNAMIC(CColorToolTipCtrl)
public:
CColorToolTipCtrl(CMFCToolTipInfo* pParams = NULL)
: CMFCToolTipCtrl(pParams)
{
}
virtual ~CColorToolTipCtrl()
{
}
2011-09-07 23:06:51 +02:00
2012-04-29 22:00:16 +02:00
protected:
virtual CSize GetIconSize();
virtual BOOL OnDrawIcon(CDC* pDC, CRect rectImage);
DECLARE_MESSAGE_MAP()
};
2011-09-07 23:06:51 +02:00
2012-04-29 22:00:16 +02:00
struct CColorListGroup
2011-09-07 23:06:51 +02:00
{
2012-04-29 22:00:16 +02:00
CRect Rect;
};
2011-09-07 23:06:51 +02:00
2012-04-29 22:00:16 +02:00
struct CColorListCell
{
CRect Rect;
COLORREF Color;
int ColorIndex;
};
2011-09-07 23:06:51 +02:00
2012-04-29 22:00:16 +02:00
class CColorList : public CWnd
{
2011-09-07 23:06:51 +02:00
public:
2012-04-29 22:00:16 +02:00
CColorList();
virtual ~CColorList();
BOOL Create(DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID);
void SetColorIndex(int ColorIndex)
{
for (int CellIdx = 0; CellIdx < mCells.GetSize(); CellIdx++)
{
if (mCells[CellIdx].ColorIndex == ColorIndex)
{
SelectCell(CellIdx);
return;
}
}
}
int GetColorIndex() const
{
return mCells[mCurCell].ColorIndex;
}
protected:
CArray<CColorListGroup, const CColorListGroup&> mGroups;
CArray<CColorListCell, const CColorListCell&> mCells;
int mColumns;
int mRows;
int mCurCell;
CPoint mMouseDown;
BOOL mTracking;
CColorToolTipCtrl mToolTip;
void UpdateColors();
void UpdateLayout();
void Draw(CDC& dc);
void SelectCell(int CellIdx);
2011-09-07 23:06:51 +02:00
// Overrides
// ClassWizard generated virtual function overrides
2012-04-29 22:00:16 +02:00
//{{AFX_VIRTUAL(CColorList)
2011-09-07 23:06:51 +02:00
public:
virtual BOOL PreTranslateMessage(MSG* pMsg);
//}}AFX_VIRTUAL
// Generated message map functions
protected:
2012-04-29 22:00:16 +02:00
//{{AFX_MSG(CColorList)
afx_msg void OnPaint();
afx_msg BOOL OnEraseBkgnd(CDC* pDC);
afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
afx_msg void OnMouseMove(UINT nFlags, CPoint point);
afx_msg void OnSize(UINT nType, int cx, int cy);
2011-09-07 23:06:51 +02:00
afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
2012-04-29 22:00:16 +02:00
afx_msg void OnSetFocus(CWnd* pOldWnd);
afx_msg void OnKillFocus(CWnd* pNewWnd);
afx_msg UINT OnGetDlgCode();
afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
2011-09-07 23:06:51 +02:00
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
2012-04-29 22:00:16 +02:00
#endif // _COLORLST_H_