📄 visualjavaview.cpp
字号:
// VisualJavaView.cpp : implementation of the CVisualJavaView class
//
#include "stdafx.h"
#include "VisualJava.h"
#include "VisualJavaDoc.h"
#include "VisualJavaView.h"
#include "editcmd.h"
#include "editoroptionspage.h"
#include "fontpg.h"
#include "mainfrm.h"
#include "filesup.h"
#include "DebugInterface.h"
#include "FormatOptionPage.h"
#include "registry.h"
#include "JavaDeclManager.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CVisualJavaView
const UINT wm_msgEditorUpdate = ::RegisterWindowMessage(_T("7BEF451B-821F-4af7-AF6B-7EFE21C01808"));
const UINT wm_msgTabUpdate = ::RegisterWindowMessage(_T("40CBF0C8-6CFE-4b02-A465-7280C244BFD0"));
const UINT wm_msgFormatUpdate = ::RegisterWindowMessage(_T("ADDC0ADE-BC54-4988-8043-140BBC2B9AC4"));
IMPLEMENT_DYNCREATE(CVisualJavaView, CBGFEditView)
BEGIN_MESSAGE_MAP(CVisualJavaView, CBGFEditView)
//{{AFX_MSG_MAP(CVisualJavaView)
ON_WM_LBUTTONDOWN()
ON_WM_KILLFOCUS()
//}}AFX_MSG_MAP
ON_COMMAND(ID_WORKSPC_ADD_NEW_PROJECT, OnWorkspcAddNewProject)
ON_COMMAND(ID_BUILD_START_DEBUG_RUN_TO_CURSOR, OnBuildStartDebugRunToCursor)
ON_UPDATE_COMMAND_UI(ID_BUILD_START_DEBUG_RUN_TO_CURSOR, OnUpdateBuildStartDebugRunToCursor)
ON_WM_CHAR()
ON_WM_CONTEXTMENU()
// ON_COMMAND (ID_VIEW_OPTIONS, OnViewOptions)
ON_WM_TIMER()
ON_WM_CREATE()
// ON_COMMAND (ID_FILE_RELOAD, OnFileReload)
// ON_UPDATE_COMMAND_UI(ID_FILE_RELOAD, OnUpdateFileReload)
// Standard printing commands
/*
ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
*/
ON_COMMAND(ID_EDIT_TAB,OnEditTab)
ON_REGISTERED_MESSAGE(wm_msgEditorUpdate,OnEditorUpdate)
ON_REGISTERED_MESSAGE(wm_msgTabUpdate,OnTabUpdate)
ON_REGISTERED_MESSAGE(wm_msgFormatUpdate,OnFormatUpdate)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CVisualJavaView construction/destruction
CVisualJavaView::CVisualJavaView()
{
m_bRememberLastPos = (theApp.m_dwFlags & EP_REMEMBER_LASTPOS) != 0;
m_bSingle = false;
SetParser (&m_xParser);
m_bEnableColapsingAllBlocks = TRUE;
m_bEnableColapsingCode = TRUE;
//m_lszpCurFont = _T("");
m_nCurFontSize = 0;
}
CVisualJavaView::~CVisualJavaView()
{
}
BOOL CVisualJavaView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CBGFEditView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CVisualJavaView drawing
/*
void CVisualJavaView::OnDraw(CDC* pDC)
{
CVisualJavaDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
}
*/
/////////////////////////////////////////////////////////////////////////////
// CVisualJavaView printing
/*BOOL CVisualJavaView::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}*/
void CVisualJavaView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CVisualJavaView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
/////////////////////////////////////////////////////////////////////////////
// CVisualJavaView diagnostics
#ifdef _DEBUG
void CVisualJavaView::AssertValid() const
{
CBGFEditView::AssertValid();
}
void CVisualJavaView::Dump(CDumpContext& dc) const
{
CBGFEditView::Dump(dc);
}
CVisualJavaDoc* CVisualJavaView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CVisualJavaDoc)));
return (CVisualJavaDoc*)m_pDocument;
}
#endif //_DEBUG
CCrystalTextBuffer *CVisualJavaView::LocateTextBuffer()
{
return &(GetDocument()->m_xTextBuffer);
}
/////////////////////////////////////////////////////////////////////////////
// CVisualJavaView message handlers
#pragma warning ( disable : 4100 )
void CVisualJavaView::OnContextMenu(CWnd*, CPoint point)
{
theApp.ShowPopupMenu(IDR_CONTEXT_MENU, point, this);
}
void CVisualJavaView::OnActivateView(BOOL bActivate, CView* pActivateView, CView* pDeactiveView)
{
CBGFEditView::OnActivateView(bActivate, pActivateView, pDeactiveView);
if (GetDocument ()->IsModified ())
{
CString sTitle;
CWnd *pWnd = AfxGetMainWnd ();
pWnd->GetWindowText (sTitle);
BOOL bMaxi;
((CMDIFrameWnd*) pWnd)->MDIGetActive (&bMaxi);
if (sTitle.Left (2) != _T("* "))
{
sTitle = _T ("* ") + (bMaxi ? sTitle.Left (7) : sTitle);
pWnd->SetWindowText (sTitle);
}
CWnd *pWnd2 = GetParentFrame ();
if (!bMaxi)
{
pWnd2->GetWindowText (sTitle);
if (sTitle.Right (2) != _T(" *"))
{
sTitle += _T (" *");
pWnd2->SetWindowText (sTitle);
}
}
}
else
{
CString sTitle;
CWnd *pWnd = AfxGetMainWnd ();
pWnd->GetWindowText (sTitle);
BOOL bMaxi;
((CMDIFrameWnd*) pWnd)->MDIGetActive (&bMaxi);
if (sTitle.Left (2) == _T("* "))
{
sTitle = bMaxi ? sTitle.Mid (2, 7) : sTitle.Mid (2);
pWnd->SetWindowText (sTitle);
}
CWnd *pWnd2 = GetParentFrame ();
if (!bMaxi)
{
pWnd2->GetWindowText (sTitle);
if (sTitle.Right (2) == _T(" *"))
{
sTitle = sTitle.Left (sTitle.GetLength () - 2);
pWnd2->SetWindowText (sTitle);
}
}
}
if (bActivate)
{
CWnd *pWnd = AfxGetMainWnd ();
if(pWnd->IsKindOf (RUNTIME_CLASS (CMainFrame)))
((CMainFrame*) pWnd)->ChooseStatusBar (TRUE);
}
}
int CVisualJavaView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CBGFEditView::OnCreate(lpCreateStruct) == -1)
return -1;
//if (!(theApp.GetFlags () & EP_DRAG_N_DROP_EDIT))
// SetDisableDragAndDrop (TRUE);
InitSettings();
return 0;
}
void CVisualJavaView::OnInitialUpdate()
{
CCrystalTextView::OnInitialUpdate();
}
void CVisualJavaView::OnWorkspcAddNewProject()
{
}
void CVisualJavaView::OnBuildStartDebugRunToCursor()
{
//if(GetFocus() == this)
{
CPoint ptLine = ClientToText(GetCursorPos());
//if(ptLine.y>=0)
{
BreakPoint(ptLine.y);
}
}
}
void CVisualJavaView::OnUpdateBuildStartDebugRunToCursor(CCmdUI* pCmdUI)
{
pCmdUI->Enable();
}
void CVisualJavaView::OnEditorUpdate()
{
{
CReg reg;
LPCTSTR lszpBase = REGISTRY_ROOT;
if(reg.Create(HKEY_CURRENT_USER,lszpBase,KEY_READ))
{
CReg optionsReg;
if(optionsReg.Create(reg.hKey,"Options",KEY_READ))
{
CReg edtReg;
if(edtReg.Create(optionsReg.hKey,"\\Editor",KEY_READ))
{
BOOL m_bVertScrllBar = TRUE;
BOOL m_bHorizScrllBar = TRUE;
edtReg.LoadNumber(_T("Vertical Scroll bar"),(DWORD*)&m_bVertScrllBar);
edtReg.LoadNumber(_T("Horizontal Scroll bar"),(DWORD*)&m_bHorizScrllBar);
if(!m_bVertScrllBar)
ModifyStyle(WS_VSCROLL,0);
if(!m_bHorizScrllBar)
ModifyStyle(WS_HSCROLL,0);
//edtReg.LoadNumber(_T("Auto window recycling"),(DWORD*)&m_bAutoWinRecycling);
edtReg.LoadNumber(_T("Selection Margin"),(DWORD*)&m_bSelMargin);
edtReg.LoadNumber(_T("Drag and drop text editing"),(DWORD*)&m_bDisableDragAndDrop);
SetDisableDragAndDrop(!m_bDisableDragAndDrop);
//edtReg.LoadNumber(_T("Save before running tools"),(DWORD*)&m_bSaveB4RunningTools);
//edtReg.LoadNumber(_T("Prompt before saving files"),(DWORD*)&m_bPrmtB4SavingFiles);
//edtReg.LoadNumber(_T("Auto reload of externally modified files"),(DWORD*)&m_bAutoReloadExtModFiles);
//edtReg.LoadNumber(_T("Auto list members"),(DWORD*)&m_bAutoListMembers);
//edtReg.LoadNumber(_T("Code comments"),(DWORD*)&m_bCodeComments);
//edtReg.LoadNumber(_T("Auto type info"),(DWORD*)&m_bAutoTypeInfo);
//edtReg.LoadNumber(_T("Auto parameter info"),(DWORD*)&m_bAutoParamInfo);
edtReg.Close();
}
optionsReg.Close();
}
reg.Close();
}
}
setMargin();
RedrawWindow();
}
void CVisualJavaView::OnTabUpdate()
{
CReg reg;
LPCTSTR lszpBase = REGISTRY_ROOT;
if(reg.Create(HKEY_CURRENT_USER,lszpBase,KEY_READ))
{
CReg optionsReg;
if(optionsReg.Create(reg.hKey,"Options",KEY_READ))
{
CReg tabReg;
if(tabReg.Create(optionsReg.hKey,"\\Tabs",KEY_READ))
{
//tabReg.LoadNumber(_T ("File type"),(DWORD*)&m_nFileType);
//tabReg.LoadNumber(_T ("Tab size"),(DWORD*)&m_nTabSize);
//tabReg.LoadNumber(_T ("Insert spaces"),(DWORD*)&m_nInsertSpaces);
//tabReg.LoadNumber(_T ("Indent size"),(DWORD*)&m_nIndentSize);
//tabReg.LoadNumber(_T ("Keep tabs"),(DWORD*)&m_nKeepTabs);
//tabReg.LoadString(_T ("Auto Indent"),m_strAutoIndent);
//tabReg.LoadNumber(_T ("Indent open brace"),(DWORD*)&m_bIndentOpenBraces);
//tabReg.LoadNumber(_T ("Indent closing brace"),(DWORD*)&m_bIndentClosingBraces);
//tabReg.LoadNumber(_T ("Previous lines used for context"),(DWORD*)&m_nNumberOfPrevLines);
//tabReg.Close();
}
optionsReg.Close();
}
reg.Close();
}
}
void CVisualJavaView::OnFormatUpdate()
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -