Click here to Skip to main content
15,896,063 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.7K   3.4K   41  
This is a partially implemented IDE for the Java platform.
// ParamWnd.cpp : implementation file
//

#include "stdafx.h"
#include "visualjava.h"
#include "ParamWnd.h"
#include "VisualJavaView.h"

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

/////////////////////////////////////////////////////////////////////////////
// CParamWnd

CParamWnd::CParamWnd()
{
   m_pCurParam = NULL;
}

CParamWnd::~CParamWnd()
{
}


BEGIN_MESSAGE_MAP(CParamWnd, CStatic)
	//{{AFX_MSG_MAP(CParamWnd)
	ON_WM_PAINT()
	ON_WM_NCPAINT()
	ON_WM_CREATE()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CParamWnd message handlers

void CParamWnd::OnPaint() 
{
	CPaintDC dc(this); // device context for painting
    CDC mdc;
    CRect rc;
    GetClientRect(&rc);

    mdc.CreateCompatibleDC(&dc);
    CBitmap bm;
    bm.CreateCompatibleBitmap(&dc, rc.Width(), rc.Height());
    CBitmap* pOldBm = mdc.SelectObject(&bm);

	//draw basic bk
    mdc.FillRect(&rc,&m_brBackground);

    //DrawItems(&mdc);
    dc.BitBlt(0, 0, rc.Width(), rc.Height(), &mdc, 0, 0, SRCCOPY);

    mdc.SelectObject(pOldBm);
    ReleaseDC(&dc);
    bm.DeleteObject();
    mdc.DeleteDC();	// Do not call CStatic::OnPaint() for painting messages
}

void CParamWnd::OnNcPaint() 
{
	CWindowDC dc(this);


	CRect rectClient;
	GetClientRect(rectClient);
	CRect rectWindow;
	GetWindowRect(rectWindow);
	ScreenToClient(rectWindow);
	rectClient.OffsetRect(-rectWindow.left, -rectWindow.top);
	if(rectClient.top<rectClient.bottom && rectClient.top<rectClient.bottom)
		dc.ExcludeClipRect(rectClient);


	// erase parts not drawn
	SendMessage(WM_ERASEBKGND, (WPARAM)dc.m_hDC);

	// draw borders in non-client area
	rectWindow.OffsetRect(-rectWindow.left, -rectWindow.top);

	CRect rcClip;
	dc.GetClipBox(&rcClip);
	CDC mdc;
	mdc.CreateCompatibleDC(&dc);
	CBitmap memBmp;
	memBmp.CreateCompatibleBitmap(&dc,rectWindow.Width(),rectWindow.Height());
    CBitmap* pOldBmp = mdc.SelectObject(&memBmp);

    {
      CBrush cb;
	  cb.CreateSolidBrush(RGB(0,0,255));
	  mdc.FillRect(rectWindow,&cb);
	  cb.DeleteObject();
	  //rectWindow.DeflateRect(0,1,0,1);
	}

	{/*
	  CBrush cb;
	  cb.CreateSolidBrush(m_bMenuBar?GetSysColor(COLOR_3DFACE):
	                                               GuiDrawLayer::GetRGBColorXP());
	  mdc.FillRect(rectWindow,&cb);
	  cb.DeleteObject();*/
	}

    dc.BitBlt (rcClip.left, rcClip.top, rcClip.Width(), rcClip.Height(),
					   &mdc, rcClip.left, rcClip.top, SRCCOPY);
	mdc.SelectObject(pOldBmp);
	ReleaseDC(&dc);
	mdc.DeleteDC();
}

int CParamWnd::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{
	if (CStatic::OnCreate(lpCreateStruct) == -1)
		return -1;
	
	m_pCurFont = new CFont;
    m_pCurFont->CreatePointFont(100,"Times New Roman",GetDC());
	SetFont(m_pCurFont);
	m_brBackground.CreateSolidBrush(RGB(255,255,255));
	return 0;
}

CParamWnd::ParamBlock* CParamWnd::GetParam(CPoint pt)
{
  return NULL;
}

void CParamWnd::OnEdit(UINT nOpCode,CPoint pCursorPos,CString strText /*= _T("")*/)
{
   switch(nOpCode)
   {
      case EDIT_INSERTTEXT:
           if(m_pCurParam)
		   {
			 m_pCurParam->cx++;
		   }else
		   {
			 m_pCurParam = new ParamBlock;
			 m_pCurParam->x = m_pCurParam->cx  = pCursorPos.x;
			 m_pCurParam->y = m_pCurParam->cy  = pCursorPos.y;
             m_pCurParam->cx++;
			 arParams.Add(m_pCurParam);
		   }break;
	  case EDIT_DELETETEXT:

	  case EDIT_BACKSPACE:

      case EDIT_PASTE:

           break;
      case DELIMITER:
	  {
	       ParamBlock* pParam = GetParam(pCursorPos);
		   if(pParam)//if delimiter was entered in a parameter block..then split the param.
		   {
              m_pCurParam = new ParamBlock;
              m_pCurParam->x  =  pCursorPos.x;
			  m_pCurParam->y  =  pCursorPos.y;
              m_pCurParam->cx =  pParam->cx;
			  m_pCurParam->cy =  pParam->cy;
			  pParam->cx = m_pCurParam->cx-1;
			  pParam->cy = m_pCurParam->y;
			  arParams.Add(m_pCurParam);
		   }
		   else
		   if(m_nDelimiterCount<m_nParamCount)//create new parameter
		   {
              // OnEdit(ggg,ggg,ggg,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
			   m_pCurParam = new ParamBlock;
               m_pCurParam->x = m_pCurParam->cx  = pCursorPos.x;
			   m_pCurParam->y = m_pCurParam->cy  = pCursorPos.y;
               m_pCurParam->cx++;
			   arParams.Add(m_pCurParam);
		   }
		   else
		   {
			 m_pCurParam = NULL;//refresh
		   }
           break;
	  }default:;
   }
}

void CParamWnd::OnArrowMove(UINT nOpCode,CPoint pCursorPos)
{

}


///////////////////////////////////////////////////////////////////////////////
bool CParamWnd::XPopupCtrlEvent::OnInit ()
{
    METHOD_PROLOGUE_(CParamWnd, PopupCtrlEvent);

    TRACE ("CCodeFinisherListBox::OnInit ()\n");
    pThis->ModifyStyle (0, WS_BORDER, SWP_DRAWFRAME);

    return true;
}

///////////////////////////////////////////////////////////////////////////////
void CParamWnd::XPopupCtrlEvent::OnShow ()
{
    METHOD_PROLOGUE_(CParamWnd, PopupCtrlEvent);

    TRACE ("CCodeFinisherListBox::OnShow ()\n");
    pThis->SetFocus();
}

///////////////////////////////////////////////////////////////////////////////
void CParamWnd::XPopupCtrlEvent::OnHide (bool bAbort)
{
    METHOD_PROLOGUE_(CParamWnd, PopupCtrlEvent);
    TRACE ("CCodeFinisherListBox::OnHide (Abort = %s)\n", bAbort ? "true" : "false");
}
///////////////////////////////////////////////////////////////////////////////
#define IS_DIGIT(c) (c>47&&c<58)

#define IS_IDENTIFIER_SYM(c) ((IS_DIGIT(c))||(c>64&&c<91)||(c>96&&c<123)||(c=='_'))


#define TERM(c) ((!IS_IDENTIFIER_SYM(c)) && ( c != VK_DOWN) && ( c != VK_UP ) && ( c != VK_HOME )\
                 &&( c != VK_END ) && (c != VK_LEFT ) && ( c != VK_RIGHT ) && ( c != VK_CAPITAL ) \
				 &&( c != VK_NUMLOCK ))


///////////////////////////////////////////////////////////////////////////////
int CParamWnd::XPopupCtrlEvent::OnKeyDown (UINT nChar, UINT, UINT)
{
    METHOD_PROLOGUE_(CParamWnd, PopupCtrlEvent);
    if(TERM(nChar))
    {
       return CPopup::end;
    }
	else
	if(char(nChar) == ',')
	{
        CVisualJavaView* pView = (CVisualJavaView*)((CMDIFrameWnd*)AfxGetMainWnd())->GetActiveFrame()->GetActiveView();
       ((CParamWnd*)pThis);

	}
	else //char
	{
       

	}
	return CPopup::doNothing;
}

///////////////////////////////////////////////////////////////////////////////
int CParamWnd::XPopupCtrlEvent::OnLButtonDown (UINT, CPoint pt)
{
    METHOD_PROLOGUE_(CParamWnd, PopupCtrlEvent);
    return CPopup::doNothing;
}

///////////////////////////////////////////////////////////////////////////////
int CParamWnd::XPopupCtrlEvent::OnLButtonUp (UINT, CPoint pt)
{
    METHOD_PROLOGUE_(CParamWnd, PopupCtrlEvent);
    return CPopup::doNothing;
}

//////////////////////////////////////////////////////////////////////////////
int CParamWnd::XPopupCtrlEvent::OnLButtonDblClk(UINT nFlags,CPoint point)
{
    METHOD_PROLOGUE_(CParamWnd, PopupCtrlEvent);
    return CPopup::end;
}

///////////////////////////////////////////////////////////////////////////////
IPopupCtrlEvent* CParamWnd::XPopupCtrlEvent::GetInterfaceOf (HWND)
{
    // Not used here because this control doesn't include other controls
    return NULL;
}

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