af8738205ec3b858ec4079a523c63fa0e849c605
[public/netxms.git] / src / console / win32 / MapView.cpp
1 // MapView.cpp : implementation file
2 //
3
4 #include "stdafx.h"
5 #include "nxcon.h"
6 #include "MapView.h"
7
8 #ifdef _DEBUG
9 #define new DEBUG_NEW
10 #undef THIS_FILE
11 static char THIS_FILE[] = __FILE__;
12 #endif
13
14 /////////////////////////////////////////////////////////////////////////////
15 // CMapView
16
17 CMapView::CMapView()
18 {
19 }
20
21 CMapView::~CMapView()
22 {
23 }
24
25
26 BEGIN_MESSAGE_MAP(CMapView, CListCtrl)
27 //{{AFX_MSG_MAP(CMapView)
28 ON_WM_PAINT()
29 //}}AFX_MSG_MAP
30 END_MESSAGE_MAP()
31
32
33 /////////////////////////////////////////////////////////////////////////////
34 // CMapView message handlers
35
36
37
38 void CMapView::OnPaint()
39 {
40 int i, iNumItems;
41 POINT pt;
42 RECT rect;
43 LVITEM item;
44 TCHAR szBuffer[256];
45 CFont *pFont;
46
47 // Setup DC
48 CPaintDC dc(this); // device context for painting
49 pFont = dc.SelectObject(GetFont());
50
51 iNumItems = GetItemCount();
52 for(i = 0; i < iNumItems; i++)
53 {
54 GetItemPosition(i, &pt);
55
56 item.iItem = i;
57 item.iSubItem = 0;
58 item.mask = LVIF_IMAGE | LVIF_PARAM | LVIF_TEXT | LVIF_STATE;
59 item.cchTextMax = 256;
60 item.pszText = szBuffer;
61 GetItem(&item);
62
63 // Draw icon
64 GetImageList(LVSIL_NORMAL)->Draw(&dc, item.iImage, pt,
65 item.state & LVIS_SELECTED ? ILD_SELECTED : ILD_TRANSPARENT);
66
67 // Draw text under icon
68 rect.left = pt.x - 16;
69 rect.right = pt.x + 48;
70 rect.top = pt.y + 32;
71 rect.bottom = rect.top + 32;
72 dc.DrawText(item.pszText, _tcslen(item.pszText), &rect, DT_CENTER | DT_WORDBREAK);
73 }
74
75 // Cleanup DC
76 dc.SelectObject(pFont);
77 }