Click here to Skip to main content
15,879,474 members
Articles / Desktop Programming / MFC

Be Sweet - a set of visual source code browsers

Rate me:
Please Sign up or sign in to vote.
4.85/5 (35 votes)
1 Jul 20038 min read 183.5K   4.9K   122  
A set of source code and project browsers to compliment Visual Studio.
#if !defined(AFX_TypeBrowserRenderer_H__B7D8D931_E2DD_11D6_A215_0080C72FE4DC__INCLUDED_)
#define AFX_TypeBrowserRenderer_H__B7D8D931_E2DD_11D6_A215_0080C72FE4DC__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// TypeBrowserRenderer.h : header file
//


#include <set>
#include <map>
#include <string>

//#include "TypeInfoLoader.h"
#include <Renderer/MFC/ESBImageList.h>
#include <Renderer/MFC/3rdParty/xySplitterWnd.h>

#include "CustomDialog.h"

/////////////////////////////////////////////////////////////////////////////
// TypeBrowserRenderer dialog

class ScopedNameBrowser;
class ScopedNameBrowserItem;


class ScopedNameBrowserRenderer : public RaisableDialog
{
private:
  typedef RaisableDialog super;

  ScopedNameBrowser *mController;
  CImageList *mImages;

  CySplitterWnd mSplitter;

  std::string mFilterDescription;

  
public:
  template<class InputIterType>
	void renderNames(const InputIterType &begin, const InputIterType &end)
  { showIn(begin, end, false, getNameListRenderer(), false); }

  template<class InputIterType>
  void renderScopes(const InputIterType &begin, const InputIterType &end)
  { showIn(begin, end, true, getScopeListRenderer(), true); }

  void setImages(CImageList &images) 
  { mImages = &images; }

  void setController(ScopedNameBrowser *c) 
  { mController = c; };
  
  void setFilterDescription(const std::string &description) 
  { mFilterDescription = description; }

protected:
  void filterChanged(const std::string&);

  void OnOK();


private:
	ScopedNameBrowser& getController() { return *mController; };
  CImageList* getImages() { return mImages; }
	CListCtrl& getNameListRenderer() { return mNameListRenderer; }
	CListCtrl& getScopeListRenderer() { return mScopeListRenderer; }

	ScopedNameBrowserItem* getSelectedItem();

	bool isSelected(NMHDR*);
	ScopedNameBrowserItem* getData(const CListCtrl&, NMHDR*);

  void append(CListCtrl&, const smart_ptr<ScopedNameBrowserItem>&, bool);

	template<class InputIterType>
	void showIn(const InputIterType &begin, const InputIterType &end, bool isFQN, CListCtrl &ctrl, bool useScopeIcon)
	{
		ctrl.SetRedraw(false);
		ctrl.DeleteAllItems();

		for(InputIterType type = begin; type != end; type++) {
			append(ctrl, *type, useScopeIcon);
		}

		ctrl.SetItemState(0, LVIS_SELECTED, LVIS_SELECTED);
    ctrl.SetColumnWidth( 0, LVSCW_AUTOSIZE );
		ctrl.SetRedraw(true);
	}

// Construction
public:
	ScopedNameBrowserRenderer(ScopedNameBrowser*, CWnd* pParent = NULL);   // standard constructor

  CEdit mFilter;
	CListCtrl	mNameListRenderer;
	CListCtrl	mScopeListRenderer;

// Dialog Data
	//{{AFX_DATA(TypeBrowserRenderer)
	enum { IDD = IDD_SCOPEDNAME_BROWSER };
	//}}AFX_DATA


// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(TypeBrowserRenderer)
	protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
	//}}AFX_VIRTUAL

// Implementation
protected:

	// Generated message map functions
	//{{AFX_MSG(TypeBrowserRenderer)
	virtual BOOL OnInitDialog();
	afx_msg void onNameSelectionChanged(NMHDR* pNMHDR, LRESULT* pResult);
	afx_msg void onScopeSelectionChanged(NMHDR* pNMHDR, LRESULT* pResult);
	afx_msg void onFilterChanged();
  afx_msg void onClose();
	afx_msg void OnShowWindow(BOOL bShow, UINT nStatus);
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};

#endif

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Switzerland Switzerland
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions