/*
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 1, or (at your option)
** any later version.

** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
** GNU General Public License for more details.

** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/

/*
 * Author : Alexandre Parenteau <aubonbeurre@hotmail.com> --- December 1997
 */

// ChildFrm.cpp : implementation of the CLogFrame class
//

#include "stdafx.h"
#include "wincvs.h"

#include "LogFrm.h"
#include "WinCvsBrowser.h"
#include "BrowseFileView.h"
#include "WincvsView.h"
#include "MainFrm.h"


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

/////////////////////////////////////////////////////////////////////////////
// inline function(s)

inline BOOL IsKeyMovingFocus(MSG* pMsg) 
{
 	 return ((pMsg->message == WM_KEYDOWN) && (pMsg->wParam == VK_TAB) &&
		 (!(0x8000 & GetKeyState(VK_CONTROL)))
		 );
}

/////////////////////////////////////////////////////////////////////////////
// CLogFrame

IMPLEMENT_DYNCREATE(CLogFrame, CCJMDIChildWnd)

BEGIN_MESSAGE_MAP(CLogFrame, CCJMDIChildWnd)
	//{{AFX_MSG_MAP(CLogFrame)
	ON_WM_CLOSE()
	ON_WM_DESTROY()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CLogFrame construction/destruction

CLogFrame::CLogFrame()
{
	// TODO: add member initialization code here
	
}

CLogFrame::~CLogFrame()
{
}

BOOL CLogFrame::OnCreateClient(LPCREATESTRUCT lpcs,
	 CCreateContext* pContext)
{
	BOOL res = CCJMDIChildWnd::OnCreateClient(lpcs, pContext);
	MDIMaximize();

	return res;
}

/////////////////////////////////////////////////////////////////////////////
// CLogFrame diagnostics

#ifdef _DEBUG
void CLogFrame::AssertValid() const
{
	CCJMDIChildWnd::AssertValid();
}

void CLogFrame::Dump(CDumpContext& dc) const
{
	CCJMDIChildWnd::Dump(dc);
}

#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CLogFrame message handlers

void CLogFrame::OnClose() 
{
	// prevent from closing the main frame
	//CCJMDIChildWnd::OnClose();
}

BOOL CLogFrame::PreTranslateMessage(MSG* pMsg) 
{
/*	if (IsKeyMovingFocus(pMsg))
	{
		CWnd* pWnd;
		if (0x8000 & GetKeyState(VK_SHIFT))
			pWnd = FindPrevWindow(GetFocus());
		else
			pWnd = FindNextWindow(GetFocus());
		if(pWnd) 
		{
			LRESULT DlgCode = ::SendMessage(pMsg->hwnd, WM_GETDLGCODE, 0, 0);
			if (!(DlgCode & (DLGC_WANTTAB | DLGC_WANTALLKEYS)))
			{
				if (pWnd->IsKindOf(RUNTIME_CLASS(CView)))
					SetActiveView((CView*)pWnd, TRUE);
				else
					pWnd->SetFocus();
			}
		}
		return TRUE;
	}*/

	return CCJMDIChildWnd::PreTranslateMessage(pMsg);
}

BOOL CLogFrame::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo) 
{
	CWincvsApp* app = (CWincvsApp*)AfxGetApp();
	if( app->GetMainFrame()->OnBroadcastCmdMsg(nID, nCode, pExtra, pHandlerInfo) )
		return TRUE;

	return CCJMDIChildWnd::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo);
}
