Click here to Skip to main content
15,885,366 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.7K   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.
/* 
/***********************************************************************/

#include "stdafx.h"
#include "resource.h"
#include "ESBServerManagerRenderer.h"

#include "OptionSheet.h"
#include "OptionPageStaticText.h"

#include <Renderer/Mfc/Properties/AppearancePropertyPanel.h>
#include <Renderer/Mfc/Properties/CTagsPropertyPanel.h>
#include <Renderer/Mfc/Properties/OutlinePropertyPanel.h>
#include <Renderer/Mfc/Properties/HierarchyPropertyPanel.h>

#include "Properties/PropertiesTree.h"

#include <string>

using namespace std;

BOOL ESBServerManagerRenderer::OnInitDialog()
{
  COptionSheet::OnInitDialog();

	// Add "About..." menu item to system menu.

	// IDM_ABOUTBOX must be in the system command range.
	ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
	ASSERT(IDM_ABOUTBOX < 0xF000);

	CMenu* pSysMenu = GetSystemMenu(FALSE);
	if (pSysMenu != NULL)
	{
		CString strAboutMenu;
		strAboutMenu.LoadString(IDS_ABOUTBOX);
		if (!strAboutMenu.IsEmpty())
		{
			pSysMenu->AppendMenu(MF_SEPARATOR);
			pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
		}
	}
  
  //http://www.codeproject.com/shell/systemtray.asp
  HICON icon = AfxGetApp()->LoadIcon(IDI_ESBSERVER_MANAGER);
  getSystemTray().Create(this, WM_SYSTRAY_NOTIFY, "ESB-Server", icon, IDR_ESBSERVER_POPUPMENU);
  getSystemTray().SetIcon(icon);
  
  #ifndef DEBUG
    onMinimize();
  #endif

  SetIcon(icon, TRUE);			// Set big icon
	SetIcon(icon, FALSE);		// Set small icon

  SetWindowText("Be Sweet");

  SetDlgItemText(IDCANCEL, "Minimize");
  SetDlgItemText(IDOK, "Exit");
  GetDlgItem(ID_APPLY_NOW)->ModifyStyle(WS_VISIBLE, 0,0);

  //thats a real hack here !!! we remove the dummy page inserter
  //in ESBServerManager::InitInstance() 
  if(GetPageCount() != 0) {
    RemovePage(0);
  }

  return TRUE;
}

LRESULT ESBServerManagerRenderer::onSystemTrayNotification(WPARAM wParam, LPARAM lParam)
{
	// Delegate all the work back to the default implementation in CSystemTray
	return getSystemTray().OnTrayNotification(wParam, lParam);
}

void ESBServerManagerRenderer::onMaximize() 
{
  getSystemTray().MaximiseFromTray(this);
}

void ESBServerManagerRenderer::onMinimize() 
{
	getSystemTray().MinimiseToTray(this);
}

void ESBServerManagerRenderer::OnCancel()
{
  onMinimize();
}

void ESBServerManagerRenderer::onExit() 
{
  OnOK();
}

void ESBServerManagerRenderer::onPreferences() 
{
  COptionSheet          optionSheet;
  CTags::PropertyPanel  ctags;
  COptionPageStaticText browserGroup(IDS_BROWSERS, "");
  
  AppearancePropertyPanel appearance;
  Browsers::OutlinePropertyPanel	outline;
  Browsers::HierarchyPropertyPanel	hierarchy;
  
  PropertiesTree tree;
	optionSheet.SetListControl(&tree);
	optionSheet.AddGroup(&browserGroup);
	optionSheet.AddPage(&ctags);
  optionSheet.AddPage(&appearance,&browserGroup);
  optionSheet.AddPage(&outline,&browserGroup);
  optionSheet.AddPage(&hierarchy,&browserGroup);
  
	optionSheet.DoModal();
}

#include <RemoteInterface/COM/IESBServer.h>
#include <ComHelper.h>
LRESULT ESBServerManagerRenderer::onCloseWorkspace(WPARAM wParam, LPARAM lParam)
{
  const static string function = "ESBServerManagerRenderer::onCloseWorkspace";
  try {
    CComPtr<IESBServerManager> mgr;
    cex_ = mgr.CoCreateInstance(CLSID_ESBServerManagerCoClass);
    auto_ptr<string> name(reinterpret_cast<string*>(lParam));
    cex_ = mgr->removeWorkspaceServer(CComBSTR(name->c_str()));
    
  } catch(std::exception &e) {
    message_box(function + e.what());
    
  } catch(...) {
    message_box(function + "unknown exception occured");
  }

  return S_OK;
}

BEGIN_MESSAGE_MAP(ESBServerManagerRenderer, COptionSheet)
  ON_MESSAGE(WM_SYSTRAY_NOTIFY, onSystemTrayNotification)  
  ON_MESSAGE(WM_CLOSE_WORKSPACE, onCloseWorkspace)  
  ON_COMMAND(ID_ESBSERVER_MAXIMIZE, onMaximize)
	ON_COMMAND(ID_ESBSERVER_MINIMIZE, onMinimize)
  ON_COMMAND(ID_ESBSERVER_EXIT, OnOK)
	ON_COMMAND(ID_ESBSERVER_PREFERENCES, onPreferences)
END_MESSAGE_MAP()

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