Object browser now fully functional
authorVictor Kirhenshtein <victor@netxms.org>
Thu, 13 May 2004 15:17:58 +0000 (15:17 +0000)
committerVictor Kirhenshtein <victor@netxms.org>
Thu, 13 May 2004 15:17:58 +0000 (15:17 +0000)
12 files changed:
.gitattributes
src/console/win32/EditBox.cpp [new file with mode: 0644]
src/console/win32/EditBox.h [new file with mode: 0644]
src/console/win32/ObjectBrowser.cpp
src/console/win32/ObjectBrowser.h
src/console/win32/ObjectPreview.cpp
src/console/win32/ObjectPreview.h
src/console/win32/ObjectSearchBox.cpp
src/console/win32/ObjectSearchBox.h
src/console/win32/globals.h
src/console/win32/nxcon.clw
src/console/win32/nxcon.dsp

index cdafd4f..34e6bcf 100644 (file)
@@ -45,6 +45,8 @@ src/console/win32/ControlPanel.cpp -text
 src/console/win32/ControlPanel.h -text
 src/console/win32/DebugFrame.cpp -text
 src/console/win32/DebugFrame.h -text
+src/console/win32/EditBox.cpp -text
+src/console/win32/EditBox.h -text
 src/console/win32/EditEventDlg.cpp -text
 src/console/win32/EditEventDlg.h -text
 src/console/win32/EventBrowser.cpp -text
diff --git a/src/console/win32/EditBox.cpp b/src/console/win32/EditBox.cpp
new file mode 100644 (file)
index 0000000..71280ef
--- /dev/null
@@ -0,0 +1,41 @@
+// EditBox.cpp : implementation file
+//
+
+#include "stdafx.h"
+#include "nxcon.h"
+#include "EditBox.h"
+
+#ifdef _DEBUG
+#define new DEBUG_NEW
+#undef THIS_FILE
+static char THIS_FILE[] = __FILE__;
+#endif
+
+/////////////////////////////////////////////////////////////////////////////
+// CEditBox
+
+CEditBox::CEditBox()
+{
+}
+
+CEditBox::~CEditBox()
+{
+}
+
+
+BEGIN_MESSAGE_MAP(CEditBox, CEdit)
+       //{{AFX_MSG_MAP(CEditBox)
+       ON_WM_KEYDOWN()
+       //}}AFX_MSG_MAP
+END_MESSAGE_MAP()
+
+/////////////////////////////////////////////////////////////////////////////
+// CEditBox message handlers
+
+void CEditBox::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) 
+{
+   if ((nChar == VK_RETURN) && (nRepCnt == 1))
+      GetParent()->PostMessage(WM_EDITBOX_EVENT, GetDlgCtrlID(), EDITBOX_ENTER_PRESSED);
+   else
+          CEdit::OnKeyDown(nChar, nRepCnt, nFlags);
+}
diff --git a/src/console/win32/EditBox.h b/src/console/win32/EditBox.h
new file mode 100644 (file)
index 0000000..7c8d4c4
--- /dev/null
@@ -0,0 +1,56 @@
+#if !defined(AFX_EDITBOX_H__C9AF5371_49AF_4379_BB9B_39D77BEC1471__INCLUDED_)
+#define AFX_EDITBOX_H__C9AF5371_49AF_4379_BB9B_39D77BEC1471__INCLUDED_
+
+#if _MSC_VER > 1000
+#pragma once
+#endif // _MSC_VER > 1000
+// EditBox.h : header file
+//
+
+
+//
+// Events
+//
+
+#define EDITBOX_ENTER_PRESSED    1
+
+
+/////////////////////////////////////////////////////////////////////////////
+// CEditBox window
+
+class CEditBox : public CEdit
+{
+// Construction
+public:
+       CEditBox();
+
+// Attributes
+public:
+
+// Operations
+public:
+
+// Overrides
+       // ClassWizard generated virtual function overrides
+       //{{AFX_VIRTUAL(CEditBox)
+       //}}AFX_VIRTUAL
+
+// Implementation
+public:
+       virtual ~CEditBox();
+
+       // Generated message map functions
+protected:
+       //{{AFX_MSG(CEditBox)
+       afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
+       //}}AFX_MSG
+
+       DECLARE_MESSAGE_MAP()
+};
+
+/////////////////////////////////////////////////////////////////////////////
+
+//{{AFX_INSERT_LOCATION}}
+// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
+
+#endif // !defined(AFX_EDITBOX_H__C9AF5371_49AF_4379_BB9B_39D77BEC1471__INCLUDED_)
index 0bfafd3..ff718d7 100644 (file)
@@ -145,12 +145,13 @@ BEGIN_MESSAGE_MAP(CObjectBrowser, CMDIChildWnd)
        ON_COMMAND(ID_OBJECT_VIEW_SHOWPREVIEWPANE, OnObjectViewShowpreviewpane)
        ON_COMMAND(ID_OBJECT_VIEW_VIEWASLIST, OnObjectViewViewaslist)
        ON_COMMAND(ID_OBJECT_VIEW_VIEWASTREE, OnObjectViewViewastree)
+       ON_WM_CONTEXTMENU()
        //}}AFX_MSG_MAP
-       ON_NOTIFY(NM_RCLICK, IDC_TREE_VIEW, OnRclickTreeView)
    ON_NOTIFY(TVN_SELCHANGED, IDC_TREE_VIEW, OnTreeViewSelChange)
        ON_NOTIFY(LVN_COLUMNCLICK, IDC_LIST_VIEW, OnListViewColumnClick)
        ON_NOTIFY(LVN_ITEMCHANGED, IDC_LIST_VIEW, OnListViewItemChange)
    ON_MESSAGE(WM_OBJECT_CHANGE, OnObjectChange)
+   ON_MESSAGE(WM_FIND_OBJECT, OnFindObject)
 END_MESSAGE_MAP()
 
 /////////////////////////////////////////////////////////////////////////////
@@ -188,7 +189,7 @@ int CObjectBrowser::OnCreate(LPCREATESTRUCT lpCreateStruct)
       rect.left = PREVIEW_PANE_WIDTH;
       rect.right -= PREVIEW_PANE_WIDTH;
    }
-   m_wndTreeCtrl.Create(WS_CHILD | TVS_HASLINES | TVS_HASBUTTONS | TVS_LINESATROOT,
+   m_wndTreeCtrl.Create(WS_CHILD | TVS_HASLINES | TVS_HASBUTTONS | TVS_LINESATROOT | TVS_SHOWSELALWAYS,
                         rect, this, IDC_TREE_VIEW);
 
    // Create list view control
@@ -356,16 +357,6 @@ BOOL CObjectBrowser::PreCreateWindow(CREATESTRUCT& cs)
 }
 
 
-//
-// WM_NOTIFY::NM_RCLICK message handler
-//
-
-void CObjectBrowser::OnRclickTreeView(NMHDR* pNMHDR, LRESULT* pResult) 
-{
-       *pResult = 0;
-}
-
-
 //
 // WM_GETMINMAXINFO message handler
 //
@@ -817,3 +808,93 @@ void CObjectBrowser::OnListViewItemChange(LPNMLISTVIEW pNMHDR, LRESULT *pResult)
    }   
    *pResult = 0;
 }
+
+
+//
+// WM_FIND_OBJECT message handler
+//
+
+void CObjectBrowser::OnFindObject(WPARAM wParam, LPARAM lParam)
+{
+   if (*((char *)lParam) != 0)
+   {
+      NXC_OBJECT *pObject;
+
+      pObject = NXCFindObjectByName((char *)lParam);
+      if (pObject != NULL)
+      {
+         // Object found, select it in the current view
+         if (m_dwFlags & VIEW_OBJECTS_AS_TREE)
+         {
+            DWORD dwIndex;
+
+            dwIndex = FindObjectInTree(pObject->dwId);
+            if (dwIndex != INVALID_INDEX)
+               m_wndTreeCtrl.Select(m_pTreeHash[dwIndex].hTreeItem, TVGN_CARET);
+            else
+               MessageBox("Object found, but it's hidden and cannot be displayed at the moment",
+                          "Find", MB_OK | MB_ICONEXCLAMATION);
+            m_wndTreeCtrl.SetFocus();
+         }
+         else
+         {
+            LVFINDINFO lvfi;
+            int iItem, iOldItem;
+
+            lvfi.flags = LVFI_PARAM;
+            lvfi.lParam = (LPARAM)pObject;
+            iItem = m_wndListCtrl.FindItem(&lvfi);
+            if (iItem != -1)
+            {
+               ClearListSelection();
+               iOldItem = m_wndListCtrl.GetNextItem(-1, LVNI_FOCUSED);
+               if (iOldItem != -1)
+                  m_wndListCtrl.SetItemState(iOldItem, 0, LVIS_FOCUSED);
+               m_wndListCtrl.EnsureVisible(iItem, FALSE);
+               m_wndListCtrl.SetItemState(iItem, LVIS_SELECTED | LVIS_FOCUSED, 
+                                          LVIS_SELECTED | LVIS_FOCUSED);
+            }
+            else
+            {
+               MessageBox("Object found, but it's hidden and cannot be displayed at the moment",
+                          "Find", MB_OK | MB_ICONEXCLAMATION);
+            }
+            m_wndListCtrl.SetFocus();
+         }
+      }
+      else
+      {
+         char szBuffer[384];
+
+         sprintf(szBuffer, "Matching object for pattern \"%s\" not found", lParam);
+         MessageBox(szBuffer, "Find", MB_OK | MB_ICONSTOP);
+      }
+   }
+}
+
+
+//
+// Clear selection from list control
+//
+
+void CObjectBrowser::ClearListSelection()
+{
+   int iItem;
+
+   iItem = m_wndListCtrl.GetNextItem(-1, LVNI_SELECTED);
+   while(iItem != -1)
+   {
+      m_wndListCtrl.SetItemState(iItem, 0, LVIS_SELECTED);
+      iItem = m_wndListCtrl.GetNextItem(iItem, LVNI_SELECTED);
+   }
+}
+
+
+//
+// WM_CONTEXTMENU message handler
+//
+
+void CObjectBrowser::OnContextMenu(CWnd* pWnd, CPoint point) 
+{
+   theApp.DebugPrintf("Menu at %d %d", point.x, point.y);
+}
index 42ab2d6..b887a4b 100644 (file)
@@ -94,6 +94,7 @@ public:
 
 // Implementation
 protected:
+       void ClearListSelection(void);
        void AddObjectToList(NXC_OBJECT *pObject);
        CListCtrl m_wndListCtrl;
        void DeleteObjectTreeItem(HTREEITEM hItem);
@@ -113,16 +114,17 @@ protected:
        afx_msg void OnSize(UINT nType, int cx, int cy);
        afx_msg void OnSetFocus(CWnd* pOldWnd);
        afx_msg void OnViewRefresh();
-       afx_msg void OnRclickTreeView(NMHDR* pNMHDR, LRESULT* pResult);
        afx_msg void OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI);
        afx_msg void OnObjectViewShowpreviewpane();
-   afx_msg void OnTreeViewSelChange(LPNMTREEVIEW lpnmt);
-   afx_msg void OnObjectChange(WPARAM wParam, LPARAM lParam);
        afx_msg void OnObjectViewViewaslist();
        afx_msg void OnObjectViewViewastree();
-       afx_msg void OnListViewColumnClick(LPNMLISTVIEW pNMHDR, LRESULT* pResult);
-   afx_msg void OnListViewItemChange(LPNMLISTVIEW pNMHDR, LRESULT *pResult);
+       afx_msg void OnContextMenu(CWnd* pWnd, CPoint point);
        //}}AFX_MSG
+   afx_msg void OnFindObject(WPARAM wParam, LPARAM lParam);
+   afx_msg void OnTreeViewSelChange(LPNMTREEVIEW lpnmt);
+   afx_msg void OnObjectChange(WPARAM wParam, LPARAM lParam);
+   afx_msg void OnListViewColumnClick(LPNMLISTVIEW pNMHDR, LRESULT *pResult);
+   afx_msg void OnListViewItemChange(LPNMLISTVIEW pNMHDR, LRESULT *pResult);
        DECLARE_MESSAGE_MAP()
 private:
        DWORD m_dwSortMode;
index 4078cc4..60823bc 100644 (file)
@@ -37,6 +37,7 @@ BEGIN_MESSAGE_MAP(CObjectPreview, CWnd)
        ON_WM_CREATE()
        ON_WM_PAINT()
        //}}AFX_MSG_MAP
+   ON_MESSAGE(WM_FIND_OBJECT, OnFindObject)
 END_MESSAGE_MAP()
 
 
@@ -122,3 +123,13 @@ void CObjectPreview::Refresh()
    m_wndObjectPreview.Invalidate();
    m_wndObjectPreview.UpdateWindow();
 }
+
+
+//
+// WM_FIND_OBJECT message handler
+//
+
+void CObjectPreview::OnFindObject(WPARAM wParam, LPARAM lParam)
+{
+   GetParent()->SendMessage(WM_FIND_OBJECT, wParam, lParam);
+}
index 91a4048..1736895 100644 (file)
@@ -52,6 +52,7 @@ protected:
        afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
        afx_msg void OnPaint();
        //}}AFX_MSG
+   afx_msg void OnFindObject(WPARAM wParam, LPARAM lParam);
        DECLARE_MESSAGE_MAP()
 };
 
index 77fc8d4..1c1d54f 100644 (file)
@@ -38,6 +38,7 @@ BEGIN_MESSAGE_MAP(CObjectSearchBox, CToolBox)
        ON_WM_CTLCOLOR()
        //}}AFX_MSG_MAP
        ON_COMMAND(ID_FIND_OBJECT, OnFindObject)
+   ON_MESSAGE(WM_EDITBOX_EVENT, OnEditBoxEvent)
 END_MESSAGE_MAP()
 
 
@@ -111,5 +112,19 @@ HBRUSH CObjectSearchBox::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
 
 void CObjectSearchBox::OnFindObject()
 {
-   MessageBox("FIND");
+   char szBuffer[256];
+
+   m_wndEditBox.GetWindowText(szBuffer, 255);
+   GetParent()->SendMessage(WM_FIND_OBJECT, 0, (LPARAM)szBuffer);
+}
+
+
+//
+// WM_EDITBOX_EVENT message handler
+//
+
+void CObjectSearchBox::OnEditBoxEvent(WPARAM wParam, LPARAM lParam)
+{
+   if ((wParam == IDC_EDIT_SEARCH_STRING) && (lParam == EDITBOX_ENTER_PRESSED))
+      PostMessage(WM_COMMAND, ID_FIND_OBJECT, 0);
 }
index 069549f..f0ed1fb 100644 (file)
@@ -8,6 +8,7 @@
 //
 
 #include "ToolBox.h"
+#include "EditBox.h"
 
 
 /////////////////////////////////////////////////////////////////////////////
@@ -38,13 +39,14 @@ public:
 protected:
        CFont m_fontNormal;
        CButton m_wndButton;
-       CEdit m_wndEditBox;
+       CEditBox m_wndEditBox;
        CStatic m_wndStatic;
        //{{AFX_MSG(CObjectSearchBox)
        afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
        afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
-       afx_msg void OnFindObject();
        //}}AFX_MSG
+       afx_msg void OnFindObject();
+   afx_msg void OnEditBoxEvent(WPARAM wParam, LPARAM lParam);
        DECLARE_MESSAGE_MAP()
 };
 
index 56810d6..4a40fdd 100644 (file)
@@ -50,6 +50,8 @@ extern CConsoleApp theApp;
 #define WM_REQUEST_COMPLETED     (WM_USER + 1)
 #define WM_CLOSE_STATUS_DLG      (WM_USER + 2)
 #define WM_OBJECT_CHANGE         (WM_USER + 3)
+#define WM_FIND_OBJECT           (WM_USER + 4)
+#define WM_EDITBOX_EVENT         (WM_USER + 5)
 
 
 //
index c5baae9..6e4301c 100644 (file)
@@ -2,13 +2,13 @@
 
 [General Info]
 Version=1
-LastClass=CObjectSearchBox
-LastTemplate=generic CWnd
+LastClass=CEditBox
+LastTemplate=CEdit
 NewFileInclude1=#include "stdafx.h"
 NewFileInclude2=#include "nxcon.h"
 LastPage=0
 
-ClassCount=20
+ClassCount=21
 Class1=CConsoleApp
 Class3=CMainFrame
 Class4=CChildFrame
@@ -20,7 +20,7 @@ Resource1=IDM_VIEW_SPECIFIC (English (U.S.))
 Resource2=IDR_MAINFRAME
 Resource3=IDD_OBJECT_PROPERTIES
 Resource4=IDD_ABOUTBOX
-Resource5=IDD_ABOUTBOX (English (U.S.))
+Resource5=IDD_PROGRESS (English (U.S.))
 Class2=CChildView
 Class5=CAboutDlg
 Class6=CControlPanel
@@ -28,13 +28,13 @@ Class8=CMapFrame
 Class10=CLoginDialog
 Resource6=IDA_MDI_DEFAULT
 Class11=CProgressDialog
-Resource7=IDD_OBJECT_PROPERTIES (English (U.S.))
+Resource7=IDA_MDI_DEFAULT (English (U.S.))
 Class12=CObjectBrowser
 Resource8=IDD_PROGRESS
 Class13=CObjectPropDlg
 Resource9=IDM_VIEW_SPECIFIC
-Resource10=IDA_OBJECT_BROWSER (English (U.S.))
-Resource11=IDA_MDI_DEFAULT (English (U.S.))
+Resource10=IDD_LOGIN (English (U.S.))
+Resource11=IDD_ABOUTBOX (English (U.S.))
 Resource12=IDR_CTRLPANEL (English (U.S.))
 Resource13=IDR_EVENTS (English (U.S.))
 Resource14=IDR_MAPFRAME (English (U.S.))
@@ -42,18 +42,19 @@ Resource15=IDR_OBJECTS (English (U.S.))
 Resource16=IDD_DUMMY (English (U.S.))
 Class14=CEventEditor
 Class15=CEditEventDlg
-Resource17=IDD_EDIT_EVENT (English (U.S.))
+Resource17=IDA_OBJECT_BROWSER (English (U.S.))
 Class16=CDebugFrame
 Resource18=IDA_OBJECT_BROWSER
-Resource19=IDD_LOGIN (English (U.S.))
-Resource20=IDR_MAINFRAME (English (U.S.))
+Resource19=IDD_OBJECT_PROPERTIES (English (U.S.))
+Resource20=IDD_EDIT_EVENT
 Class17=CObjectPreview
-Resource21=IDD_PROGRESS (English (U.S.))
+Resource21=IDR_MAINFRAME (English (U.S.))
 Class18=CToolBox
 Class19=CObjectInfoBox
 Class20=CObjectSearchBox
 Resource22=IDD_LOGIN
-Resource23=IDD_EDIT_EVENT
+Class21=CEditBox
+Resource23=IDD_EDIT_EVENT (English (U.S.))
 
 [CLS:CConsoleApp]
 Type=0
@@ -580,3 +581,11 @@ Command4=ID_OBJECT_VIEW_VIEWASTREE
 Command5=ID_VIEW_REFRESH
 CommandCount=5
 
+[CLS:CEditBox]
+Type=0
+HeaderFile=EditBox.h
+ImplementationFile=EditBox.cpp
+BaseClass=CEdit
+Filter=W
+VirtualFilter=WC
+
index 94f2a2e..2c70b87 100644 (file)
@@ -104,6 +104,10 @@ SOURCE=.\DebugFrame.cpp
 # End Source File
 # Begin Source File
 
+SOURCE=.\EditBox.cpp
+# End Source File
+# Begin Source File
+
 SOURCE=.\EditEventDlg.cpp
 # End Source File
 # Begin Source File
@@ -189,6 +193,10 @@ SOURCE=.\DebugFrame.h
 # End Source File
 # Begin Source File
 
+SOURCE=.\EditBox.h
+# End Source File
+# Begin Source File
+
 SOURCE=.\EditEventDlg.h
 # End Source File
 # Begin Source File