| 1 |
#ifndef __COMBO_BOX_SUPER__ |
|---|
| 2 |
#define __COMBO_BOX_SUPER__ |
|---|
| 3 |
|
|---|
| 4 |
#if _MSC_VER > 1000 |
|---|
| 5 |
#pragma once |
|---|
| 6 |
#endif // _MSC_VER > 1000 |
|---|
| 7 |
|
|---|
| 8 |
#pragma warning ( disable : 4786 ) |
|---|
| 9 |
|
|---|
| 10 |
#include <map> |
|---|
| 11 |
#include <vector> |
|---|
| 12 |
|
|---|
| 13 |
/** |
|---|
| 14 |
* @class CComboBoxSuper |
|---|
| 15 |
* |
|---|
| 16 |
* Implements Combo-box with a colored items, icons, bold items, and multiple columns. |
|---|
| 17 |
* Based on code by Alex Hazanov - ComboBox bold - Combo box with bold text items and optional icon |
|---|
| 18 |
* |
|---|
| 19 |
* @author Ron Hashimshony |
|---|
| 20 |
* @created 01-Jun-2003 |
|---|
| 21 |
* @ChangesHistory |
|---|
| 22 |
*/ |
|---|
| 23 |
class CComboBoxSuper : public CComboBox |
|---|
| 24 |
{ |
|---|
| 25 |
// Construction |
|---|
| 26 |
public: |
|---|
| 27 |
CComboBoxSuper(); |
|---|
| 28 |
|
|---|
| 29 |
struct ItemData |
|---|
| 30 |
{ |
|---|
| 31 |
ItemData() : crTextColor(RGB(0,0,0)),nImageIndex(-1),bBold(FALSE){} |
|---|
| 32 |
COLORREF crTextColor; |
|---|
| 33 |
int nImageIndex; |
|---|
| 34 |
std::map<int,CString> mapStrings; |
|---|
| 35 |
BOOL bBold; |
|---|
| 36 |
DWORD dwItemData; |
|---|
| 37 |
}; |
|---|
| 38 |
|
|---|
| 39 |
std::vector<int> m_vecColumnWidth; |
|---|
| 40 |
|
|---|
| 41 |
CImageList* m_pImageList; |
|---|
| 42 |
BOOL m_bUseImage; |
|---|
| 43 |
|
|---|
| 44 |
static const DEFAULT_COLUMN_COUNT; |
|---|
| 45 |
static const DEFAULT_COLUMN_WIDTH; |
|---|
| 46 |
|
|---|
| 47 |
|
|---|
| 48 |
// Operations |
|---|
| 49 |
public: |
|---|
| 50 |
|
|---|
| 51 |
// Overrides |
|---|
| 52 |
// ClassWizard generated virtual function overrides |
|---|
| 53 |
//{{AFX_VIRTUAL(CComboBoxSuper) |
|---|
| 54 |
//}}AFX_VIRTUAL |
|---|
| 55 |
afx_msg void OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags); |
|---|
| 56 |
virtual BOOL PreTranslateMessage(MSG* pMsg); |
|---|
| 57 |
// Implementation |
|---|
| 58 |
public: |
|---|
| 59 |
|
|---|
| 60 |
/** Sets to TRUE for using the image list, of FALSE to disable the use of the image-list. */ |
|---|
| 61 |
void SetUseImage(BOOL bUseImage=TRUE) { m_bUseImage=bUseImage; Invalidate(); } |
|---|
| 62 |
|
|---|
| 63 |
/** Sets the number of columns to use - new columns are inserted at default width. */ |
|---|
| 64 |
void SetColumnCount(int nColumnCount); |
|---|
| 65 |
|
|---|
| 66 |
/** Sets the width of a specific column. */ |
|---|
| 67 |
void SetColumnWidth(int nColumnIndex, int nWidth); |
|---|
| 68 |
|
|---|
| 69 |
/** Sets the image list to use - will be show only if SetUseImage is called. */ |
|---|
| 70 |
void SetImageList(CImageList* pImageList) { m_pImageList = pImageList; } |
|---|
| 71 |
|
|---|
| 72 |
/** Set a specific row to bold. */ |
|---|
| 73 |
void SetItemBold(int nItemIndex, BOOL bBold = TRUE); |
|---|
| 74 |
|
|---|
| 75 |
/** Sets a row's image index. */ |
|---|
| 76 |
void SetItemImage(int nItemIndex, int nImageIndex); |
|---|
| 77 |
|
|---|
| 78 |
/** Sets a row's color. */ |
|---|
| 79 |
void SetItemColor(int nItemIndex, COLORREF rcTextColor); |
|---|
| 80 |
|
|---|
| 81 |
/** Sets an item or sub-item text. */ |
|---|
| 82 |
void SetItemText(int nItemIndex, int nColumn, CString str); |
|---|
| 83 |
|
|---|
| 84 |
/** Sets item data (override the default function) */ |
|---|
| 85 |
void SetItemData(int nItemIndex, DWORD dwData); |
|---|
| 86 |
|
|---|
| 87 |
/** Get item data(override the default function) */ |
|---|
| 88 |
DWORD GetItemData(int nItemIndex); |
|---|
| 89 |
|
|---|
| 90 |
/** Gets item or sub-item text. */ |
|---|
| 91 |
CString GetItemText(int nItemIndex,int nColumn); |
|---|
| 92 |
|
|---|
| 93 |
virtual ~CComboBoxSuper(); |
|---|
| 94 |
|
|---|
| 95 |
// Generated message map functions |
|---|
| 96 |
protected: |
|---|
| 97 |
|
|---|
| 98 |
ItemData* GetOrCreateItemData(int nItemIndex); |
|---|
| 99 |
|
|---|
| 100 |
virtual void DrawItem( LPDRAWITEMSTRUCT lpDrawItemStruct ); |
|---|
| 101 |
void MeasureItem(LPMEASUREITEMSTRUCT) {} |
|---|
| 102 |
//{{AFX_MSG(CComboBoxSuper) |
|---|
| 103 |
afx_msg void OnDeleteItem(int nIDCtl, LPDELETEITEMSTRUCT lpDeleteItemStruct); |
|---|
| 104 |
//}}AFX_MSG |
|---|
| 105 |
|
|---|
| 106 |
DECLARE_MESSAGE_MAP() |
|---|
| 107 |
}; |
|---|
| 108 |
|
|---|
| 109 |
///////////////////////////////////////////////////////////////////////////// |
|---|
| 110 |
|
|---|
| 111 |
//{{AFX_INSERT_LOCATION}} |
|---|
| 112 |
// Microsoft Visual C++ will insert additional declarations immediately before the previous line. |
|---|
| 113 |
|
|---|
| 114 |
#endif // __COMBO_BOX_SUPER__ |
|---|