home *** CD-ROM | disk | FTP | other *** search
- // objview.hpp
- //
- // Created 10/08/98
- //
- // (C)Copyright 1998-1999 Microsoft Corporation, All rights reserved.
- //
-
- #ifndef __OBJVIEW_HPP__
- #define __OBJVIEW_HPP__
-
- #include "baseview.hpp"
-
- class ANSIStringBuffer;
-
-
- #define WC_HEAPMONITOR_OBJVIEWER "JavaHeapMonitor_ObjectViewerClass"
-
-
- enum ObjectViewerEvents
- {
- WM_OVEVENT_FIRST = WM_BC_LAST,
-
- WM_OVEVENT_OBJECT_CHANGE = WM_OVEVENT_FIRST,
-
- WM_OVEVENT_PERMIT_EXPANSION,
-
- WM_OVEVENT_CLEAR_TRANSIENTS,
-
- WM_OVEVENT_LAST
- };
-
-
- // Displays a suspended heap in a split-pane window: a tree control allows
- // navigation of the heap, while a text pane displays details about the
- // selected object. The heap is navigated a single level at a time using
- // GetObjectField, as the user expands the node for the object. The 'iImage'
- // tree item field is overloaded to also be an enumeration indicating the
- // underlying type of the node. This enumeration is used to interpret the
- // associated lParam.
- //
- // Derivatives must populate the tree. This class only deals with object
- // and ID nodes - any other types are ignored.
-
- class ObjectViewer : public BasicClient
- {
- protected:
-
- static BOOL s_fRegisteredClass;
-
- // TreeView, left pane
- HWND m_htree;
- // right pane, contains description of selected item in left pane
- HWND m_htext;
- // client area of mdi client between panes
- LONG m_sliderleft;
- LONG m_sliderright;
- LONG m_sliderwid;
-
-
- //------------------------------------------------------------------------
- // UI manipulation
-
- BOOL MoveSlider (LPARAM lParam);
- VOID ClearText ();
-
- static LRESULT CALLBACK _WndProc (HWND wnd, UINT msg, WPARAM wParam, LPARAM lParam);
-
- virtual LRESULT CALLBACK WndProc (HWND wnd, UINT msg, WPARAM wParam, LPARAM lParam);
-
- BOOL OnCreateWindow ();
-
- virtual BOOL OnRightClickItem (ID id, UniqueID vmid, HWND wnd, DWORD screenpos);
- virtual BOOL GetItemText (HTREEITEM hti, PSTR &psztext, int &cchmaxtext);
- virtual BOOL GetItemDetailText (HTREEITEM hti, ANSIStringBuffer *pbuf);
-
-
- //------------------------------------------------------------------------
- // Tree-specific stuff
-
- VOID RedrawTree ()
- {
- InvalidateRect(m_htree, NULL, TRUE);
- UpdateWindow(m_htree);
- }
-
- // These are the indices into IDB_TREEIMAGES, and also serve to identify
- // the type of the tree item's lParam.
- enum ObjectViewerTreeItemTypes
- {
- // ObjectID (default if no image set)
- HVTII_OBJECT = 0,
-
- // OBJID
- HVTII_OBJID = 1,
-
- // OBJID, OID_FL_TRACKED set
- HVTII_TRACKED_OBJID = 2,
-
- // OBJID, OID_FL_MULTIPLE_REFERENCES set
- HVTII_MULTIREF_OBJID = 3,
-
- // OBJID, both OID_FL_MULTIPLE_REFERENCES and OID_FL_TRACKED set
- HVTII_MULTIREF_TRACKED_OBJID = 4,
-
- // OBJID
- HVTII_DEAD_OBJID = 5,
-
- HVTII_LAST_OBJID = HVTII_DEAD_OBJID,
-
- // (none)
- HVTII_FOLDER = 6,
-
- // PSTR
- HVTII_UNLOADED_CLASS = 7,
-
- // PSTR
- HVTII_DEAD_THREAD = 8,
-
- // ID
- HVTII_FIRST_ID = 9,
-
- // Remaining images are for HVTII_FIRST_ID + IDType.
- };
-
- static BOOL IsObjectType (ObjectViewerTreeItemTypes type)
- {
- return type <= HVTII_DEAD_OBJID;
- }
-
- static ObjectViewerTreeItemTypes GetTreeItemTypeForID (ID id);
-
- BOOL GetTreeItemTypeInfo (HTREEITEM hti, ObjectViewerTreeItemTypes *ptype, PVOID *ptoken);
-
- HTREEITEM AddTreeItem (HTREEITEM htiParent, HTREEITEM htiafter, ObjectViewerTreeItemTypes type, PVOID token);
- HTREEITEM AddTreeItem (HTREEITEM htiParent, ObjectViewerTreeItemTypes type, PVOID token);
- HTREEITEM AddTreeItemForID (HTREEITEM htiParent, ID id, BOOL fPermitDuplicates = FALSE);
- HTREEITEM AddTreeItemForID (HTREEITEM htiParent, HTREEITEM htiAfter, ID id, BOOL fPermitDuplicates = FALSE);
- HTREEITEM AddTreeItemForReferencedID (HTREEITEM htiParent, ID id);
- HTREEITEM AddTreeItemForReferencedID (HTREEITEM htiParent, HTREEITEM htiAfter, ID id, BOOL fPermitDuplicates = FALSE);
- HTREEITEM AddStaticTreeItem (HTREEITEM htiParent, PCSTR text, ObjectViewerTreeItemTypes img);
- HTREEITEM AddTreeItemForObject (HTREEITEM htiParent, ObjectID vmid);
-
- VOID DeleteTreeItem (HTREEITEM hti);
-
- BOOL WalkTree (DWORD flags, PWALKTREECBFN pfn, PVOID token);
-
- HTREEITEM FindChildItemForID (HTREEITEM htiParent, ID id);
-
- HTREEITEM FindNextSiblingForID (HTREEITEM htichild, ID id);
-
- HTREEITEM CreateRoot (HTREEITEM *proot, PCSTR name, ObjectViewerTreeItemTypes img);
-
- // Subclasses override to decide whether or not a node for the given
- // object should be retained after execution resumes. If returns FALSE,
- // the node will be kept, but its expand button will be removed.
- virtual BOOL ShouldDeleteTransientObject (HTREEITEM hti, OBJID obj);
-
-
- //------------------------------------------------------------------------
- // Object node operations
-
- // callback data for AddObjectIDReferences and AddOBJIDReferences
- struct AddReferencesInfo
- {
- ObjectViewer *ov;
- HTREEITEM hti;
- };
-
- static int AddObjectIDReferences (ObjectID vmid, PVOID /*AddReferencesInfo*/ token);
- static int AddOBJIDReferences (OBJID id, PVOID /*AddReferencesInfo*/ token);
-
- static WalkTreeCBResults UpdateObjectStatusCB (HWND htree, HTREEITEM hti, PVOID token);
-
- BOOL FindObjectReferences (ObjectID vmid);
-
- VOID ToggleObjectTracking (OBJID obj, ObjectID vmid);
-
- VOID TagObject (ObjectID vmid);
-
-
- //------------------------------------------------------------------------
-
- // IHeapMonitorClient methods
-
- static WalkTreeCBResults DeleteTransientItemsCB (HWND htree, HTREEITEM hti, PVOID token);
- static WalkTreeCBResults PermitItemExpansionCB (HWND htree, HTREEITEM hti, PVOID token);
-
- STDMETHODIMP OnStoppedExecution ()
- {
- SendMessage(m_hwnd, WM_OVEVENT_PERMIT_EXPANSION, 0, 0);
- return S_OK;
- }
-
- STDMETHODIMP OnResumeExecution ()
- {
- SendMessage(m_hwnd, WM_OVEVENT_CLEAR_TRANSIENTS, 0, 0);
- return S_OK;
- }
-
- STDMETHODIMP OnThreadCreated (THREADID thread)
- {
- return S_OK;
- }
-
- STDMETHODIMP OnDestroyThread (THREADID thread)
- {
- return S_OK;
- }
-
- STDMETHODIMP OnPackageCreated (PKGID pkg)
- {
- return S_OK;
- }
-
- STDMETHODIMP OnClassLoaded (CLASSID cls)
- {
- return S_OK;
- }
-
- STDMETHODIMP OnUnloadClass (CLASSID cls)
- {
- return S_OK;
- }
-
- STDMETHODIMP RootReferences (RootReferencesEventInfo *pinfo)
- {
- return S_OK;
- }
-
- STDMETHODIMP OnObjectStatusChange (OBJID id)
- {
- SendMessage(m_hwnd, WM_OVEVENT_OBJECT_CHANGE, 0, (LPARAM)id);
- return S_OK;
- }
-
- STDMETHODIMP RootDiscoveryComplete ()
- {
- return S_OK;
- }
-
- STDMETHODIMP ObjectDiscoveryComplete ()
- {
- return S_OK;
- }
-
-
- //------------------------------------------------------------------------
- // Initialization
-
- BOOL OVPreInitialize (HeapMonitorManager *mgr, PCSTR wndtitle);
- BOOL OVPostInitialize (HeapMonitorClientRegistrationInfo *preginfo);
-
- BOOL OVInitialize (HeapMonitorManager *mgr, PCSTR wndtitle, HeapMonitorClientRegistrationInfo *preginfo = NULL)
- {
- return OVPreInitialize(mgr, wndtitle)
- && OVPostInitialize(preginfo);
- }
- };
-
-
- #endif /* __OBJVIEW_HPP__ */
-
-