Click here to Skip to main content
15,886,864 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.8K   4.9K   122  
A set of source code and project browsers to compliment Visual Studio.
/**
/*   Copyright (c) 2003by  Marco Welti
/*
/*   This document is  bound by the  QT Public License
/*   (http://www.trolltech.com/licenses/qpl.html).
/*   See License.txt for more information.
/*
/*
/*
/*   ALL RIGHTS RESERVED.  
/* 
/*   THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
/*   OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
/*   WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
/*   ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
/*   DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
/*   DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
/*   GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
/*   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
/*   WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
/*   NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
/*   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
/* 
/***********************************************************************/

#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;
  std::string mNameFilter;
  
public:
  template<class InputIterType>
	void renderNames(const InputIterType &begin, const InputIterType &end)
  { 
    showIn(begin, end, getNameListRenderer(), false); 
    if(begin != end) {
      getController().typeSelectionChanged((*begin).get()); 
    }
  }

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

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

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

  void close()
  { super::OnOK(); }

  void setFilter(const std::string &);

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, 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);
	}

  ScopedNameBrowserItem* getData(char key, int index, const CListCtrl &ctrl);

// 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 void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
  afx_msg void onFocusNames(NMHDR* pNMHDR, LRESULT* pResult);
  afx_msg void onFocusQualifiers(NMHDR* pNMHDR, LRESULT* pResult);
  //}}AFX_MSG
  afx_msg void onNameKeyPressed(NMHDR* pNMHDR, LRESULT* pResult);
  afx_msg void onQualifierKeyPressed(NMHDR* pNMHDR, LRESULT* pResult);
	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