📄 c02ide.cpp
字号:
// C02IDE.cpp : Defines the class behaviors for the application.
//
#include "stdafx.h"
#include "C02IDE.h"
#include "MainFrm.h"
#include "C02IDEDoc.h"
#include "C02IDEView.h"
#include "ChildFrm.h"
#include <winspool.h>
#include "WorkspaceView.h"
#include "KSFileDialog.h"
#include "editcmd.h"
#include "ProjectNew.h"
#include <afxtempl.h>
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
//CRichEditCtrl myeditctrl;
int i_usermode=0;
int i_newblankfile=0;
AddFunc * functionadd=NULL;
// CObArray * proinfstru=NULL;
CObArray projectinfo;
CObArray oa_error;
// CObArray projectfile;
FileList * m_pfile=NULL;
fileitem fileitemarray[30];
// AddFunc *functionadd=NULL;
CObArray a_searchinfo; //保存搜索信息
// int idxcurwnd=0;
int n_filenumber=0;
int n_funcnumber=0;
int allcanshunum=0;
int addcanshunum=0;
// CObArray a_searchinfo;
CTabFileDoc* m_pDocFile=NULL;
CTabClassDoc* m_pDocClass=NULL;
int gotoline=0;
CString findstring;
int findstringcurhang;
int findstringcurlie;
cursel curselpos;
int m_nItem=0;
int m_nSubItem=0;
CMapPtrToPtr m_mappro;
/////////////////////////////////////////////////////////////////////////////
// CC02IDEApp
BEGIN_MESSAGE_MAP(CC02IDEApp, CWinApp)
//{{AFX_MSG_MAP(CC02IDEApp)
ON_COMMAND(ID_FILE_NEWPRO,OnProjectNew)
ON_COMMAND(ID_FILE_NEW, OnFileNew)
ON_COMMAND(ID_FILE_NEWC02,OnFileNewC02)
ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
ON_COMMAND(ID_FILE_OPEN, OnFileOpen)
ON_COMMAND(ID_FILE_SAVE_ALL, OnFileSaveAll)
ON_UPDATE_COMMAND_UI(ID_FILE_MRU_FILE1, OnUpdateFileMruFile1)
ON_COMMAND_EX_RANGE(ID_FILE_MRU_FILE1, ID_FILE_MRU_FILE16, OnOpenRecentFileEx)
//}}AFX_MSG_MAP
// Standard file based document commands
// ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
// ON_COMMAND(ID_FILE_SAVE_AS, OnFileSaveAs)
// Standard print setup command
ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CC02IDEApp construction
CC02IDEApp::CC02IDEApp()
{
// TODO: add construction code here,
// Place all significant initialization in InitInstance
m_pMainFrame = NULL;
}
/////////////////////////////////////////////////////////////////////////////
// The one and only CC02IDEApp object
CC02IDEApp theApp;
/////////////////////////////////////////////////////////////////////////////
// CC02IDEApp initialization
BOOL CC02IDEApp::InitInstance()
{
// Initialize OLE libraries
if (!AfxOleInit())
{
AfxMessageBox(IDP_OLE_INIT_FAILED);
return FALSE;
}
AfxEnableControlContainer();
// Standard initialization
// If you are not using these features and wish to reduce the size
// of your final executable, you should remove from the following
// the specific initialization routines you do not need.
#ifdef _AFXDLL
Enable3dControls(); // Call this when using MFC in a shared DLL
#else
Enable3dControlsStatic(); // Call this when linking to MFC statically
#endif
// Change the registry key under which our settings are stored.
// You should modify this string to be something appropriate
// such as the name of your company or organization.
SetRegistryKey(_T("CodeJockey"));
LoadStdProfileSettings(); // Load standard INI file options (including MRU)
// Register the application's document templates. Document templates
// serve as the connection between documents, frame windows and views.
m_pDocTemplate = new CMultiDocTemplate(
IDR_C02IDETYPE,
RUNTIME_CLASS(CC02IDEDoc),
RUNTIME_CLASS(CChildFrame), // custom MDI child frame
RUNTIME_CLASS(CC02IDEView));
m_pDocTemplate->SetContainerInfo(IDR_C02IDETYPE_CNTR_IP);
AddDocTemplate(m_pDocTemplate);
/*
m_pDocWorkspTemplate = new CMultiDocTemplate(
IDR_C02IDE_VITYPE,
RUNTIME_CLASS(CC02IDEDoc),
RUNTIME_CLASS(CChildFrame), // custom MDI child frame
RUNTIME_CLASS(CWorkspaceView));
AddDocTemplate(m_pDocWorkspTemplate);
*/
// create main MDI Frame window
m_pMainFrame = new CMainFrame;
if (!m_pMainFrame->LoadFrame(IDR_MAINFRAME))
return FALSE;
m_pMainWnd = m_pMainFrame;
// Parse command line for standard shell commands, DDE, file open
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);
cmdInfo.m_nShellCommand=CCommandLineInfo::FileNothing;
// Dispatch commands specified on the command line
if (!ProcessShellCommand(cmdInfo))
return FALSE;
// The one and only window has been initialized, so show and update it.
m_pMainWnd->ShowWindow(SW_SHOW);
m_pMainWnd->UpdateWindow();
// pMainFrame->ShowWindow(m_nCmdShow);
// pMainFrame->UpdateWindow();
struct ProjectList * firstpro=NULL;
firstpro=new ProjectList;
firstpro->str_projectname="project1";
firstpro->proinfstru.RemoveAll();
// projectinfo.RemoveAll();
projectinfo.InsertAt(0,(CObject*)firstpro);
// projectfile.InsertAt(0,(CObject*)firstpro);
// gotofuncname="";
gotoline=0;
findstring="";
findstringcurhang=0;
findstringcurlie=-1;
curselpos.n_min=0;
curselpos.n_max=0;
_CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
class CAboutDlg : public CDialog
{
public:
void UpdateFont();
CAboutDlg();
// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
//}}AFX_DATA
CFont m_Font;
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
//{{AFX_MSG(CAboutDlg)
virtual BOOL OnInitDialog();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
// m_C02IDEDisclaimer = _T("");
//}}AFX_DATA_INIT
// m_C02IDEDisclaimer.LoadString(IDS_DISCLAIMER);
// UpdateFont();
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
// DDX_Control(pDX, IDC_STATIC_MAILME, m_staticEmail);
// DDX_Control(pDX, IDC_STATIC_DISCLAIMER, m_staticDisclaimer);
// DDX_Control(pDX, IDC_STATIC_ADDRESS, m_staticAddress);
// DDX_Text(pDX, IDC_C02IDE_DISCLAIMER, m_C02IDEDisclaimer);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
void CAboutDlg::UpdateFont()
{
/* NONCLIENTMETRICS ncm;
memset(&ncm, 0, sizeof(NONCLIENTMETRICS));
ncm.cbSize = sizeof(NONCLIENTMETRICS);
VERIFY(::SystemParametersInfo(SPI_GETNONCLIENTMETRICS,
sizeof(NONCLIENTMETRICS), &ncm, 0));
ncm.lfMessageFont.lfWeight = 700;
m_Font.CreateFontIndirect(&ncm.lfMessageFont);
*/
}
BOOL CAboutDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// set the hyperlinks and static font.
// m_staticEmail.SetURL(_T("mailto:kstowell@codejockeys.com"));
// m_staticAddress.SetURL(_T("http://www.codejockeys.com/kstowell/"));
// m_staticDisclaimer.SetFont(&m_Font);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
/////////////////////////////////////////////////////////////////////////////
// App command to run the dialog
void CC02IDEApp::OnAppAbout()
{
CAboutDlg aboutDlg;
aboutDlg.DoModal();
}
/////////////////////////////////////////////////////////////////////////////
// CC02IDEApp commands
void CC02IDEApp::OnFileNew()
{
// m_pDocTemplate->OpenDocumentFile(NULL);
gotoline=0;
findstring="";
findstringcurhang=0;
findstringcurlie=-1;
// strreplacewith="";
CWinApp::OnFileNew();
CCJMDIFrameWnd *pFrame = (CCJMDIFrameWnd*)AfxGetApp()->m_pMainWnd;
CCJMDIChildWnd *pChild = (CCJMDIChildWnd *) pFrame->GetActiveFrame();
FileList * m_pnewfile;
m_pnewfile=new FileList;
TCHAR* ch_wndtitle=NULL;
int n=pChild->GetWindowText(ch_wndtitle,100);
m_pnewfile->m_pChildWnd= pChild;
ProjectList *curpro;
curpro=new ProjectList;
curpro=(ProjectList*)(projectinfo.GetAt(0));
int n_file=curpro->proinfstru.GetSize();
CString str_newfilename=_T("");
if(n!=0)
m_pnewfile->str_filename=ch_wndtitle;
else
{
i_newblankfile++;
str_newfilename.Format("%d",i_newblankfile);//n_file
str_newfilename="new file "+str_newfilename;
m_pnewfile->str_filename=str_newfilename;
pChild->SetWindowText(str_newfilename);
// pChild->SetWindowText(str_newfilename);
}
curpro->proinfstru.Add((CObject *)m_pnewfile);
// CObArray curproob;
projectinfo.RemoveAll();
projectinfo.InsertAt(0,(CObject *)curpro);
m_pnewfile->str_proname=_T("1");
m_mappro.SetAt(pChild->GetSafeHwnd(),(void*&)m_pnewfile);
m_pDocFile->UpdateTabView();
m_pDocClass->UpdateTabView();
CMainFrame *m_pmainFrame = (CMainFrame*)AfxGetApp()->m_pMainWnd;
m_pfile=m_pnewfile;
m_pmainFrame->updatecomfile();
}
void CC02IDEApp::OnFileOpen()
{
CString Filter;
Filter = "All Source files (*.c, *.cpp, *.h *.hpp, "
" *.rc,*.txt)|*.c;*.cpp;*.h;*.hpp;*.rc;*.txt|";
Filter += "All Files (*.*)|*.*|";
Filter += "Header Files (*.h;*.hpp)|*.h;*.hpp|";
Filter += "Source Files (*.c;*.cpp)|*.c;*.cpp|";
Filter += "Resource Files (*.rc)|*.rc|";
Filter += "Text Files (*.txt)|*.txt|";
CFileDialog fd(true, NULL, NULL, OFN_HIDEREADONLY
| OFN_OVERWRITEPROMPT, Filter);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -