28 #include "../../idlib/precompiled.h"
33 #define TOGGLELIST_ITEMHEIGHT 22
42 ON_WM_MEASUREITEM_REFLECT()
43 ON_NOTIFY_REFLECT(NM_CLICK, OnNMClick)
50 ToggleListView::ToggleListView() {
75 onIcon = (HICON)LoadImage ( AfxGetInstanceHandle(), on, IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR|LR_LOADMAP3DCOLORS );
81 offIcon = (HICON)LoadImage ( AfxGetInstanceHandle(), off, IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR|LR_LOADMAP3DCOLORS );
87 disabledIcon = (HICON)LoadImage ( AfxGetInstanceHandle(), disabled, IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR|LR_LOADMAP3DCOLORS );
101 CListCtrl& list = GetListCtrl();
102 assert(index >= 0 && index < list.GetItemCount());
105 list.SetItemData(index, toggleState);
107 if(notify && oldState != toggleState)
116 CListCtrl& list = GetListCtrl();
117 assert(index >= 0 && index < list.GetItemCount());
127 if (CListView::OnCreate(lpCreateStruct) == -1)
130 CListCtrl& list = GetListCtrl();
132 list.SetExtendedStyle(LVS_EX_FULLROWSELECT);
136 list.ModifyStyle(WS_HSCROLL, 0
L);
142 list.InsertColumn(0, &col);
153 CListView::OnSize(nType, cx, cy);
155 CListCtrl& list = GetListCtrl();
156 list.SetColumnWidth(0, cx-1);
170 CListCtrl& list = GetListCtrl();
172 DWORD dwpos = GetMessagePos();
175 info.pt.x = LOWORD(dwpos);
176 info.pt.y = HIWORD(dwpos);
178 ::MapWindowPoints(HWND_DESKTOP, pNMHDR->hwndFrom, &info.pt, 1);
180 int index = list.HitTest(&info);
186 list.GetItemRect(index, &rItem, LVIR_BOUNDS);
205 cs.style &= ~LVS_TYPEMASK;
206 cs.style |= LVS_REPORT | LVS_OWNERDRAWFIXED | LVS_NOCOLUMNHEADER | LVS_SHOWSELALWAYS;
208 return CListView::PreCreateWindow(cs);
216 CListCtrl& ListCtrl=GetListCtrl();
217 int nItem = lpDrawItemStruct->itemID;
221 _TCHAR szBuff[MAX_PATH];
223 memset(&lvi, 0,
sizeof(LV_ITEM));
224 lvi.mask = LVIF_TEXT;
226 lvi.pszText = szBuff;
227 lvi.cchTextMax =
sizeof(szBuff);
228 ListCtrl.GetItem(&lvi);
233 CopyRect ( &rDraw, &lpDrawItemStruct->rcItem );
238 FrameRect ( lpDrawItemStruct->hDC, &rDraw, (HBRUSH)GetStockObject ( BLACK_BRUSH ) );
241 FillRect ( lpDrawItemStruct->hDC, &rDraw, GetSysColorBrush ( COLOR_3DFACE ) );
243 Draw3dRect ( lpDrawItemStruct->hDC, &rDraw, GetSysColorBrush ( COLOR_3DHILIGHT ), GetSysColorBrush ( COLOR_3DSHADOW ) );
245 InflateRect ( &rDraw, -3, -3 );
246 Draw3dRect ( lpDrawItemStruct->hDC, &rDraw, GetSysColorBrush ( COLOR_3DSHADOW ), GetSysColorBrush ( COLOR_3DHILIGHT ) );
251 DrawIconEx ( lpDrawItemStruct->hDC, rDraw.left, rDraw.top,
disabledIcon, 16, 16,0,
NULL, DI_NORMAL );
256 DrawIconEx ( lpDrawItemStruct->hDC, rDraw.left, rDraw.top,
onIcon, 16, 16,0,
NULL, DI_NORMAL );
261 DrawIconEx ( lpDrawItemStruct->hDC, rDraw.left, rDraw.top,
offIcon, 16, 16,0,
NULL, DI_NORMAL );
266 CopyRect ( &rDraw, &lpDrawItemStruct->rcItem );
270 if ( lpDrawItemStruct->itemState & ODS_SELECTED ) {
271 FillRect ( lpDrawItemStruct->hDC, &rDraw, GetSysColorBrush ( COLOR_HIGHLIGHT ) );
273 FillRect ( lpDrawItemStruct->hDC, &rDraw, GetSysColorBrush ( COLOR_WINDOW ) );
278 int colorIndex = ( (lpDrawItemStruct->itemState & ODS_SELECTED ) ? COLOR_HIGHLIGHTTEXT : COLOR_WINDOWTEXT );
279 SetTextColor ( lpDrawItemStruct->hDC, GetSysColor ( colorIndex ) );
280 DrawText ( lpDrawItemStruct->hDC, szBuff, strlen(szBuff), &rDraw, DT_LEFT|DT_VCENTER|DT_SINGLELINE );
291 SetRect ( &rOut, rect->left, rect->top, rect->right - 1, rect->top + 1 );
292 FillRect ( hDC,&rOut, topLeft );
294 SetRect ( &rOut, rect->left, rect->top, rect->left + 1, rect->bottom );
295 FillRect( hDC,&rOut, topLeft );
297 SetRect ( &rOut, rect->right, rect->top, rect->right -1, rect->bottom );
298 FillRect( hDC,&rOut, bottomRight );
300 SetRect ( &rOut, rect->left, rect->bottom, rect->right, rect->bottom - 1 );
301 FillRect( hDC,&rOut, bottomRight );
assert(prefInfo.fullscreenBtn)
CONST PIXELFORMATDESCRIPTOR UINT
virtual BOOL PreCreateWindow(CREATESTRUCT &cs)
Sets some window styles before the window is created.
int GetToggleState(int index)
Gets the state of an item in the list.
void SetToggleState(int index, int toggleState, bool notify=false)
Sets the state of an item in the list.
virtual void OnStateChanged(int index, int toggleState)
void SetToggleIcons(LPCSTR disabled=NULL, LPCSTR on=NULL, LPCSTR off=NULL)
Sets the tree icons to dispay for each of the three states.
afx_msg void OnNMClick(NMHDR *pNMHDR, LRESULT *pResult)
Toggles the state of an item when the user clicks in the window.
virtual ~ToggleListView()
Destructor.
void Draw3dRect(HDC hDC, RECT *rect, HBRUSH topLeft, HBRUSH bottomRight)
Draws a 3d rectangle using the given brushes this code was taken from the gui editor.
GLsizei GLsizei GLenum GLenum const GLvoid * data
typedef HDC(WINAPI *PFNWGLGETCURRENTREADDCARBPROC)(void)
IMPLEMENT_DYNCREATE(CCamWnd, CWnd)
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct)
Called as the window is being created and initializes icons and window styles.
afx_msg void MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct)
Returns the size of each item in the toggle list.
A simple list view that supports a toggle button.
afx_msg void OnSize(UINT nType, int cx, int cy)
Called when the window is being resized.
#define TOGGLELIST_ITEMHEIGHT
virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
Responsible for drawing each list item.