Click here to Skip to main content
15,887,683 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.9K   4.9K   122  
A set of source code and project browsers to compliment Visual Studio.
#include "stdafx.h"
#include "Resource.h"

#include "TypeBrowser.h"

#include <Model/Editor.h>

#include <Renderer/MFC/ESBImageList.h>
#include <Renderer/MFC/Browsers/TypeBrowserRenderer.h>

using namespace std;

TagbrowserItem::TagbrowserItem(const smart_ptr<CppTag>& tag)
  : mTag(tag) 
{ 
}

std::string TagbrowserItem::getNameLabel() const 
{ 
  return getTag()->getName(); 
}  

std::string TagbrowserItem::getScopeLabel() const 
{ 
  return getTag()->getFQN(); 
}  
  
int TagbrowserItem::getNameIcon() const 
{ 
  return ESBImageList::instance().getIcon(*getTag());
}

int TagbrowserItem::getScopeIcon() const 
{ 
  return ESBImageList::instance().getIcon(*getTag()->getScope(), true);
}

const smart_ptr<CppTag>& TagbrowserItem::getTag() const
{
  return mTag;
}
  
TypeBrowserModel::TypeBrowserModel(const TypeInfoLoader::TypeList &tl)
{ 
  std::transform(tl.begin(), tl.end(), std::inserter(mDatastore, mDatastore.begin()), makeDataItem);
}

smart_ptr<ScopedNameBrowserItem> TypeBrowserModel::makeDataItem(const smart_ptr<CppTag> &tag)
{ 
  return smart_ptr<TagbrowserItem>(new TagbrowserItem(tag)); 
}

TagBrowser::TagBrowser(const string &label)
{
  setRenderer(smart_ptr<ScopedNameBrowserRenderer>(new TagBrowserRenderer(label)));  
}

void TagBrowser::typeSelected(ModelItemType *sel)
{
  ScopedNameBrowser::typeSelected(sel);
  
  TagbrowserItem *selection = dynamic_cast<TagbrowserItem*>(getSelection());
  Editor e(selection->getTag()->getDeclaration().getFile());
  e.goToLine(selection->getTag()->getDeclaration().getLine());
}


MethodBrowserItem::MethodBrowserItem(const smart_ptr<Function>& function)
: TagbrowserItem(function)
{
}

std::string MethodBrowserItem::getScopeLabel() const 
{
  Function *f = dynamic_cast<Function*>(getTag().get());
  return f->getReturnType() + " " + f->getFQN().toString() + "(...)";
}

MethodBrowserModel::MethodBrowserModel(const std::list<smart_ptr<Function> > &fl)
{
    std::transform(fl.begin(), fl.end(), std::inserter(mDatastore, mDatastore.begin()), makeDataItem);
}

smart_ptr<ScopedNameBrowserItem> MethodBrowserModel::makeDataItem(const smart_ptr<Function> &function)
{
  return smart_ptr<TagbrowserItem>(new MethodBrowserItem(function)); 
}

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