// ///////////////////////////////////////
//http://www.codeproject.com/dialog/cpushpinframe.asp
#include "stdafx.h"
#include "resource.h"
#include ".\outview.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
#define OUTVIEW_OUTPUT 0
#define OUTVIEW_PARAMS 1
#define OUTVIEW_STACK 2
#define OUTVIEW_ERRORS 3
///// COutFrm /////////////////////////////////////////////////////////
IMPLEMENT_DYNCREATE( COutFrm, CFrameWnd )
BEGIN_MESSAGE_MAP( COutFrm, CFrameWnd )
//Too busy to handle messages in view so pass them from frame.
ON_BN_CLICKED( IDC_BUTTON1, OnBnClickedOutputout )
ON_BN_CLICKED( IDC_BUTTON2, OnBnClickedOutputparam )
ON_BN_CLICKED( IDC_BUTTON3, OnBnClickedOutputstack )
ON_BN_CLICKED( IDC_BUTTON4, OnBnClickedOutputerrors )
//ON_BN_CLICKED( IDC_OUTPUTHOLD, OnBnClickedOutputhold )
END_MESSAGE_MAP( )
COutFrm::COutFrm( )
{
CreateEx( WS_EX_TOOLWINDOW, NULL, _T("Output"),
WS_POPUPWINDOW | WS_CAPTION | WS_VISIBLE | WS_THICKFRAME | WS_POPUP,
CRect( ), AfxGetMainWnd( ), 0 );
if( !buttonBar.Create( this, IDD_DIALOGBAR_OUTPUT,
WS_CHILD | WS_VISIBLE | CBRS_TOP
| CBRS_BOTTOM | CBRS_GRIPPER
| CBRS_TOOLTIPS | CBRS_FLYBY | WS_THICKFRAME
| CBRS_SIZE_DYNAMIC, 0 )
)
return;
CCreateContext cc;
cc.m_pNewViewClass= RUNTIME_CLASS( COutputView );
//This much casting/inderection is ugly, and could be unsafe down the line...
//cc.m_pCurrentDoc=
// ( (CCLUView*)( ( (CMainFrame*)AfxGetMainWnd( ) )->GetActiveView( ) ) )->GetDocument( );
CView* view= reinterpret_cast<CView*>( CreateView( &cc ) );
ASSERT_KINDOF( COutputView, view );
SetActiveView( view );
SetWindowPos( &CWnd::wndTopMost, 60, 60, 350, 150, SWP_SHOWWINDOW | SWP_NOZORDER );
//theProject.SetWinPlacement( _T("OutputWin"), this );
}
COutFrm::~COutFrm( )
{
}
BOOL COutFrm::DestroyWindow( )
{
AfxGetMainWnd( )->SendMessage( WM_COMMAND, ID_OUTWIN_DESTROY );
//theProject.SaveWinPlacement( _T("OutputWin"), this );
return CFrameWnd::DestroyWindow( );
}
void COutFrm::OnBnClickedOutputout( )
{
//CView* v= GetActiveView( );
//v->SendMessage( WM_CHANGEMODE, OUTVIEW_OUTPUT );
}
void COutFrm::OnBnClickedOutputparam( )
{
//CView* v= GetActiveView( );
//v->SendMessage( WM_CHANGEMODE, OUTVIEW_PARAMS );
}
void COutFrm::OnBnClickedOutputstack( )
{
//CView* v= GetActiveView( );
//v->SendMessage( WM_CHANGEMODE, OUTVIEW_STACK );
}
void COutFrm::OnBnClickedOutputerrors( )
{
//CView* v= GetActiveView( );
//v->SendMessage( WM_CHANGEMODE, OUTVIEW_ERRORS );
}
void COutFrm::OnBnClickedOutputhold( )
{
//CView* v= GetActiveView( );
//v->SendMessage( WM_OUTPUTHOLD );
}
//// COutputView /////////////////////////////////////////////////////////////
// Using CView for speed as window can be active at frame rate ./////////
IMPLEMENT_DYNCREATE( COutputView, CView )
BEGIN_MESSAGE_MAP( COutputView, CView )
ON_WM_PAINT( )
//ON_BN_CLICKED( IDC_BUTTON1, OnBnClickedOutputout )
//ON_BN_CLICKED( IDC_BUTTON2, OnBnClickedOutputparam )
//ON_BN_CLICKED( IDC_BUTTON3, OnBnClickedOutputstack )
//ON_BN_CLICKED( IDC_BUTTON4, OnBnClickedOutputerrors )
//ON_MESSAGE( WM_CHANGEMODE, OnChangeMode )
//ON_MESSAGE( WM_OUTPUTHOLD, OnChangeHold )
END_MESSAGE_MAP( )
COutputView::COutputView( )
{
mode= OUTVIEW_OUTPUT;
hold= false;
}
COutputView::~COutputView( )
{
}
//TODO delete this if not needed...
BOOL COutputView::Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext)
{
if( !CView::Create(lpszClassName, lpszWindowName, dwStyle, rect, pParentWnd, nID, pContext) )
return FALSE;
return TRUE;
}
LRESULT COutputView::OnChangeMode( WPARAM newMode, LPARAM /**/ )
{
if( (BOOL)newMode == mode )
return TRUE;
mode= (int)newMode;
OnUpdate( NULL, 1, NULL );
return TRUE;
}
LRESULT COutputView::OnChangeHold( WPARAM /**/, LPARAM /**/ )
{
hold= !hold;
return TRUE;
}
void COutputView::OnUpdate(CView* /*pSender*/, LPARAM /*lHint*/, CObject* /*pHint*/)
{
//CCLUDoc& doc= *GetDocument( );
//if( hold && !lHint )
// return;
//switch( mode )
//{
//case OUTVIEW_OUTPUT:
// sOut= doc.GetParser( ).GetTextOutput( );
// if( sOut.IsEmpty( ) )
// sOut= _T("No Output Specified\n");
// break;
//case OUTVIEW_PARAMS:
// sOut= doc.GetParser( ).PrintVars( );
// break;
//case OUTVIEW_STACK:
// sOut= doc.GetParser( ).PrintStack( );
// break;
//case OUTVIEW_ERRORS:
// sOut= doc.GetParser( ).PrintCodeErrors( );
// if( sOut.IsEmpty( ) )
// sOut= _T("No Current Errors\n");
// break;
//}
Invalidate( );
}
void COutputView::OnPaint( )
{
CPaintDC dc( this );
OnDraw( &dc );
}
void COutputView::OnDraw( CDC* pDC )
{
//Requires \n line seperation and end \n;
for( int i= 0, c= 0, j= 0; j >= 0; c+= 18 )
{
j= sOut.Find( '\n', i );
pDC->DrawText( sOut.Mid( i, j - i ), CRect( 5, c, 4000, 4000 ), DT_TOP );
i= j + 1;
}
}
#ifdef _DEBUG ///////////////////////////////////////
//CCLUDoc* COutputView::GetDocument( ) const // non-debug version is inline
//{
// if( m_pDocument == NULL )
// return NULL;
//
// ASSERT( m_pDocument->IsKindOf( RUNTIME_CLASS( CCLUDoc ) ) );
// return (CCLUDoc*)m_pDocument;
//}
#endif