- Initial work on maps
[public/netxms.git] / src / console / win32 / MapFrame.cpp
CommitLineData
3bf7e95e
VK
1// MapFrame.cpp : implementation file
2//
3
4#include "stdafx.h"
5#include "nxcon.h"
6#include "MapFrame.h"
7
8#ifdef _DEBUG
9#define new DEBUG_NEW
10#undef THIS_FILE
11static char THIS_FILE[] = __FILE__;
12#endif
13
14/////////////////////////////////////////////////////////////////////////////
15// CMapFrame
16
17IMPLEMENT_DYNCREATE(CMapFrame, CMDIChildWnd)
18
19CMapFrame::CMapFrame()
20{
21}
22
23CMapFrame::~CMapFrame()
24{
25}
26
27
28BEGIN_MESSAGE_MAP(CMapFrame, CMDIChildWnd)
29 //{{AFX_MSG_MAP(CMapFrame)
30 ON_WM_CREATE()
31 ON_WM_SIZE()
6e953858
VK
32 ON_WM_SETFOCUS()
33 ON_COMMAND(ID_VIEW_REFRESH, OnViewRefresh)
3bf7e95e
VK
34 //}}AFX_MSG_MAP
35END_MESSAGE_MAP()
36
37/////////////////////////////////////////////////////////////////////////////
38// CMapFrame message handlers
39
40BOOL CMapFrame::PreCreateWindow(CREATESTRUCT& cs)
41{
42 if (cs.lpszClass == NULL)
43 cs.lpszClass = AfxRegisterWndClass(CS_HREDRAW | CS_VREDRAW, NULL, NULL,
44 AfxGetApp()->LoadIcon(IDI_NETMAP));
45 return CMDIChildWnd::PreCreateWindow(cs);
46}
47
48
49//
50// WM_CREATE message handler
51//
52
53int CMapFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
54{
55 RECT rect;
5d8a7f11
VK
56 static TBBUTTON tbButtons[] =
57 {
58 { 0, 0, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0 },
59 { 1, 0, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0 }
60 };
3bf7e95e
VK
61
62 if (CMDIChildWnd::OnCreate(lpCreateStruct) == -1)
63 return -1;
64
5d8a7f11
VK
65 EnableDocking(CBRS_ALIGN_ANY);
66
67 // Create toolbar
68 m_wndToolBar.CreateEx(this);
69 m_wndToolBar.LoadToolBar(IDT_MAP);
70 //FloatControlBar(&m_wndToolBar, TRUE, FALSE);
71/* m_wndToolBar.Create(WS_CHILD | WS_VISIBLE | CCS_NODIVIDER | TBSTYLE_FLAT | TBSTYLE_TOOLTIPS | TBSTYLE_TRANSPARENT, rect, this, ID_TOOLBAR_CTRL);
72 m_wndToolBar.SetExtendedStyle(WS_EX_WINDOWEDGE);
73 m_wndToolBar.SetButtonSize(CSize(20, 20));
74 m_wndToolBar.LoadImages(IDB_HIST_SMALL_COLOR, HINST_COMMCTRL);
75 m_wndToolBar.AddButtons(2, tbButtons);*/
76
3bf7e95e
VK
77 // Create and initialize map view
78 GetClientRect(&rect);
5d8a7f11 79 m_wndMapView.Create(NULL, NULL, WS_CHILD | WS_VISIBLE, rect, this, 0);
3bf7e95e 80
6e953858
VK
81 PostMessage(WM_COMMAND, ID_VIEW_REFRESH, 0);
82
83 return 0;
3bf7e95e
VK
84}
85
86
87//
88// WM_SIZE message handler
89//
90
91void CMapFrame::OnSize(UINT nType, int cx, int cy)
92{
5d8a7f11
VK
93 int nToolBarHeight;
94
3bf7e95e 95 CMDIChildWnd::OnSize(nType, cx, cy);
5d8a7f11
VK
96// m_wndToolBar.AutoSize();
97 nToolBarHeight = GetWindowSize(&m_wndToolBar).cy;
98 m_wndMapView.SetWindowPos(NULL, 0, nToolBarHeight, cx, cy - nToolBarHeight, SWP_NOZORDER);
3bf7e95e 99}
6e953858
VK
100
101
102//
103// WM_SETFOCUS message handler
104//
105
106void CMapFrame::OnSetFocus(CWnd* pOldWnd)
107{
108 CMDIChildWnd::OnSetFocus(pOldWnd);
6e953858
VK
109 m_wndMapView.SetFocus();
110}
111
112
113//
114// WM_COMMAND::ID_VIEW_REFRESH message handler
115//
116
117void CMapFrame::OnViewRefresh()
118{
5d8a7f11
VK
119 m_wndMapView.SetMap(new nxMap(1, _T("Default"), _T("Default map")));
120/* NXC_OBJECT *pObject;
6e953858
VK
121 DWORD i;
122 CString strFullString, strTitle;
123
124 if (strFullString.LoadString(IDR_MAPFRAME))
125 AfxExtractSubString(strTitle, strFullString, CDocTemplate::docName);
126
127 m_wndMapView.DeleteAllItems();
128 if (m_pRootObject == NULL)
129 {
babb8280 130 pObject = NXCGetTopologyRootObject(g_hSession);
6e953858
VK
131 if (pObject != NULL)
132 AddObjectToView(pObject);
133
babb8280 134 pObject = NXCGetServiceRootObject(g_hSession);
6e953858
VK
135 if (pObject != NULL)
136 AddObjectToView(pObject);
137
babb8280 138 pObject = NXCGetTemplateRootObject(g_hSession);
6e953858
VK
139 if (pObject != NULL)
140 AddObjectToView(pObject);
141
142 // add object name to title
143 strTitle += " - [root]";
144 }
145 else
146 {
147 for(i = 0; i < m_pRootObject->dwNumChilds; i++)
148 {
babb8280 149 pObject = NXCFindObjectById(g_hSession, m_pRootObject->pdwChildList[i]);
6e953858
VK
150 if (pObject != NULL)
151 if (!pObject->bIsDeleted)
152 AddObjectToView(pObject);
153 }
154
155 // add object name to title
156 strTitle += " - [";
157 strTitle += m_pRootObject->szName;
158 strTitle += "]";
159 }
160
5d8a7f11 161 ::SetWindowText(m_hWnd, strTitle);*/
6e953858 162}