Click here to Skip to main content
15,892,746 members
Articles / Desktop Programming / MFC

A Java Language IDE

Rate me:
Please Sign up or sign in to vote.
4.33/5 (26 votes)
13 May 2004CPOL3 min read 80.6K   3.4K   41  
This is a partially implemented IDE for the Java platform.
//*******************************************************************************
// COPYRIGHT NOTES
// ---------------
// This source code is a part of BCGControlBar library.
// You may use, compile or redistribute it as part of your application 
// for free. You cannot redistribute it as a part of a software development 
// library without the agreement of the author. If the sources are 
// distributed along with the application, you should leave the original 
// copyright notes in the source code without any changes.
// This code can be used WITHOUT ANY WARRANTIES on your own risk.
// 
// Stas Levin <stas@iet.co.il>
//*******************************************************************************

// BCGDialogBar.cpp : implementation file
//

#include "stdafx.h"
#include "bcgcontrolbar.h"
#include "BCGDialogBar.h"
#include <../src/occimpl.h>

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CBCGDialogBar

IMPLEMENT_SERIAL(CBCGDialogBar, CBCGSizingControlBar, VERSIONABLE_SCHEMA | 1)

#pragma warning (disable : 4355)

CBCGDialogBar::CBCGDialogBar()
{
	m_bAllowSizing = FALSE;

#ifndef _AFX_NO_OCC_SUPPORT
	m_lpszTemplateName = NULL;
	m_pOccDialogInfo = NULL;
#endif
}

CBCGDialogBar::~CBCGDialogBar()
{
//	DestroyWindow();    // avoid PostNcDestroy problems
}

#pragma warning (default : 4355)


/////////////////////////////////////////////////////////////////////////////
// CBCGDialogBar message handlers

//****************************************************************************************
CSize CBCGDialogBar::CalcDynamicLayout(int nLength, DWORD dwMode)
{
	if(m_bAllowSizing)
	{
		return CBCGSizingControlBar::CalcDynamicLayout(nLength, dwMode);
	}
	else
	{
		return CControlBar::CalcDynamicLayout(nLength, dwMode);
	}
}
//****************************************************************************************
CSize CBCGDialogBar::CalcFixedLayout(BOOL bStretch, BOOL bHorz)
{
	if(m_bAllowSizing)
	{
		return CBCGSizingControlBar::CalcFixedLayout(bStretch, bHorz);
	}
	else
	{
		CSize sizeResult = m_sizeDefault;

		if (bStretch) // if not docked stretch to fit
		{
			if (bHorz)
			{
				sizeResult.cx = 32767;
			}
			else
			{
				sizeResult.cy = 32767;
			}
		}

		//BLOCK: Adjust Margins
		{
			CRect rect; rect.SetRectEmpty();
			CalcInsideRect(rect, bHorz);
			sizeResult.cy -= rect.Height();
			sizeResult.cx -= rect.Width();

			CSize size = CControlBar::CalcFixedLayout (bStretch, bHorz);
			sizeResult.cx = max(sizeResult.cx, size.cx);
			sizeResult.cy = max(sizeResult.cy, size.cy);
		}

		return sizeResult;

	}
}
//****************************************************************************************
BOOL CBCGDialogBar::Create(LPCTSTR lpszWindowName, CWnd* pParentWnd, BOOL bHasGripper, 
						   UINT nIDTemplate, UINT nStyle, UINT nID)
{ 
	return Create(lpszWindowName, pParentWnd, bHasGripper, MAKEINTRESOURCE(nIDTemplate), nStyle, nID); 
}
//****************************************************************************************
BOOL CBCGDialogBar::Create(LPCTSTR lpszWindowName, CWnd* pParentWnd, BOOL bHasGripper, 
						   LPCTSTR lpszTemplateName, UINT nStyle, UINT nID)
{
	ASSERT(pParentWnd != NULL);
	ASSERT(lpszTemplateName != NULL);


    // cannot be both fixed and dynamic
    // (CBRS_SIZE_DYNAMIC is used for resizng when floating)
    ASSERT (!((nStyle & CBRS_SIZE_FIXED) &&
              (nStyle & CBRS_SIZE_DYNAMIC)));

    m_cyGripper = bHasGripper ? 12 : 0; // set the gripper width
	m_bAllowSizing = nStyle & CBRS_SIZE_DYNAMIC ? TRUE : FALSE;

	// allow chance to modify styles
	m_dwStyle = (nStyle & CBRS_ALL);

	CREATESTRUCT cs;
	memset(&cs, 0, sizeof(cs));
	cs.lpszClass = AFX_WNDCONTROLBAR;
	cs.lpszName = lpszWindowName;
	cs.style = (DWORD)nStyle | WS_CHILD;
	cs.hMenu = (HMENU)nID;
	cs.hInstance = AfxGetInstanceHandle();
	cs.hwndParent = pParentWnd->GetSafeHwnd();
	if (!PreCreateWindow(cs))
		return FALSE;

#ifndef _AFX_NO_OCC_SUPPORT
	m_lpszTemplateName = lpszTemplateName;
#endif

	// create a modeless dialog

	// initialize common controls
	VERIFY(AfxDeferRegisterClass(AFX_WNDCOMMCTLS_REG));
	AfxDeferRegisterClass(AFX_WNDCOMMCTLSNEW_REG);

	BOOL bSuccess = CreateDlg(lpszTemplateName, pParentWnd);

#ifndef _AFX_NO_OCC_SUPPORT
	m_lpszTemplateName = NULL;
#endif

	if (!bSuccess)
		return FALSE;


    SetClassLong(m_hWnd, GCL_HBRBACKGROUND, (LPARAM)::GetSysColorBrush(COLOR_BTNFACE));


    SetBarStyle (GetBarStyle() | CBRS_SIZE_DYNAMIC);

	// dialog template MUST specify that the dialog
	//  is an invisible child window
	SetDlgCtrlID(nID);
	CRect rect;
	GetWindowRect(&rect);
	m_sizeDefault = rect.Size();    // set fixed size

    m_szHorz = m_sizeDefault; // set the size members
    m_szVert = m_sizeDefault;
    m_szFloat = m_sizeDefault;

	// force WS_CLIPSIBLINGS
	ModifyStyle(0, WS_CLIPSIBLINGS);

	if (!ExecuteDlgInit(lpszTemplateName))
		return FALSE;


	// force the size to zero - resizing bar will occur later
	SetWindowPos(NULL, 0, 0, 0, 0, SWP_NOZORDER|SWP_NOACTIVATE|SWP_SHOWWINDOW);

	return TRUE;
}
//****************************************************************************************
void CBCGDialogBar::OnUpdateCmdUI(CFrameWnd* pTarget, BOOL bDisableIfNoHndler)
{
	UpdateDialogControls(pTarget, bDisableIfNoHndler);
}

#ifndef _AFX_NO_OCC_SUPPORT

//{{AFX_MSG_MAP(CBCGDialogBar)
BEGIN_MESSAGE_MAP(CBCGDialogBar, CBCGSizingControlBar)
	ON_MESSAGE(WM_INITDIALOG, HandleInitDialog)
END_MESSAGE_MAP()
//}}AFX_MSG_MAP

LRESULT CBCGDialogBar::HandleInitDialog(WPARAM, LPARAM)
{
	Default();  // allow default to initialize first (common dialogs/etc)

	// create OLE controls
	COccManager* pOccManager = afxOccManager;
	if ((pOccManager != NULL) && (m_pOccDialogInfo != NULL))
	{
		if (!pOccManager->CreateDlgControls(this, m_lpszTemplateName,
			m_pOccDialogInfo))
		{
			TRACE0("Warning: CreateDlgControls failed during dialog bar init.\n");
			return FALSE;
		}
	}

	return TRUE;
}

BOOL CBCGDialogBar::SetOccDialogInfo(_AFX_OCC_DIALOG_INFO* pOccDialogInfo)
{
	m_pOccDialogInfo = pOccDialogInfo;
	return TRUE;
}

#endif //!_AFX_NO_OCC_SUPPORT

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, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Web Developer
United States United States
biography? I am not that old yet.

Comments and Discussions