version 1.3, 2001/04/02 01:03:31 |
version 1.10, 2005/05/10 09:52:12 |
|
|
#include "asir32guiView.h" |
#include "asir32guiView.h" |
#include "FatalDialog.h" |
#include "FatalDialog.h" |
#include <direct.h> |
#include <direct.h> |
|
#include <io.h> |
|
|
#ifdef _DEBUG |
#ifdef _DEBUG |
#define new DEBUG_NEW |
#define new DEBUG_NEW |
|
|
static char THIS_FILE[] = __FILE__; |
static char THIS_FILE[] = __FILE__; |
#endif |
#endif |
|
|
const TextBufferSize = 32768; |
// const TextBufferSize = 32768; |
|
const TextBufferSize = 16384; |
|
|
CAsir32guiView *theView; |
CAsir32guiView *theView; |
|
|
Line 65 BEGIN_MESSAGE_MAP(CAsir32guiView, CEditView) |
|
Line 67 BEGIN_MESSAGE_MAP(CAsir32guiView, CEditView) |
|
ON_COMMAND(ID_EDIT_PASTE, OnEditPaste) |
ON_COMMAND(ID_EDIT_PASTE, OnEditPaste) |
ON_COMMAND(IDR_FONT, OnFont) |
ON_COMMAND(IDR_FONT, OnFont) |
ON_WM_CREATE() |
ON_WM_CREATE() |
|
ON_COMMAND(ID_CONTRIBHELP, OnContribhelp) |
|
ON_UPDATE_COMMAND_UI(ID_CONTRIBHELP, OnUpdateContribhelp) |
|
ON_WM_SIZE() |
//}}AFX_MSG_MAP |
//}}AFX_MSG_MAP |
// 標準印刷コマンド |
// 標準印刷コマンド |
// ON_COMMAND(ID_FILE_PRINT, CEditView::OnFilePrint) |
// ON_COMMAND(ID_FILE_PRINT, CEditView::OnFilePrint) |
Line 85 CAsir32guiView::CAsir32guiView() |
|
Line 90 CAsir32guiView::CAsir32guiView() |
|
read_input_history(); |
read_input_history(); |
DebugMode = 0; |
DebugMode = 0; |
DebugInMain = 0; |
DebugInMain = 0; |
MaxLineLength = 80; |
// MaxLineLength = 80; |
LogStart = 0; |
LogStart = 0; |
Logging = 0; |
Logging = 0; |
Logfp = NULL; |
Logfp = NULL; |
Line 164 CAsir32guiDoc* CAsir32guiView::GetDocument() // 非デバ |
|
Line 169 CAsir32guiDoc* CAsir32guiView::GetDocument() // 非デバ |
|
|
|
void CAsir32guiView::PutChar(int c) |
void CAsir32guiView::PutChar(int c) |
{ |
{ |
int i; |
int i,len; |
char buf[2]; |
char buf[2]; |
|
|
|
if ( EndPos >= sizeof(Buffer)-1 ) { |
|
Beep(); return; |
|
} |
for ( i = EndPos-1; i >= CurrentPos; i-- ) |
for ( i = EndPos-1; i >= CurrentPos; i-- ) |
Buffer[i+1] = Buffer[i]; |
Buffer[i+1] = Buffer[i]; |
Buffer[CurrentPos] = (char)c; |
Buffer[CurrentPos] = (char)c; |
buf[0] = (char)c; buf[1] = 0; |
// buf[0] = (char)c; buf[1] = 0; |
Insert(buf,FALSE); |
// Insert(buf,FALSE); |
|
len = GetWindowTextLength(); |
|
if ( len+1 >= TextBufferSize ) |
|
DeleteTop(); |
|
CEditView::OnChar(c, 1, 0); |
CurrentPos++; |
CurrentPos++; |
EndPos++; |
EndPos++; |
} |
} |
Line 236 void CAsir32guiView::DeleteTop() |
|
Line 248 void CAsir32guiView::DeleteTop() |
|
} |
} |
} |
} |
if ( Logging ) { |
if ( Logging ) { |
len1 = (len0 - len - LogStart); |
if ( len < LogStart ) |
if ( len1 > 0 ) { |
LogStart -= len; |
fwrite(buf+LogStart,1,len1,Logfp); |
else { |
LogStart = 0; |
fwrite(buf+LogStart,1,len-LogStart,Logfp); |
} else |
LogStart = 0; |
LogStart = -len1; |
} |
} |
} |
UnlockBuffer(); |
UnlockBuffer(); |
if ( q ) { |
if ( q ) { |
Line 279 void CAsir32guiView::Beep(void) { |
|
Line 291 void CAsir32guiView::Beep(void) { |
|
} |
} |
|
|
void CAsir32guiView::Paste(void) { |
void CAsir32guiView::Paste(void) { |
char buf[2*BUFSIZ]; |
char buf[2*BUFSIZ]; |
const char *src; |
const char *src; |
char c; |
char c; |
int i,j,l; |
int i,j,l; |
HGLOBAL hClip; |
HGLOBAL hClip; |
|
|
if ( asirgui_kind == ASIRGUI_MESSAGE ) { |
if ( asirgui_kind == ASIRGUI_MESSAGE ) { |
Beep(); return; |
Beep(); return; |
} |
} |
|
|
if ( OpenClipboard() == FALSE ) { |
if ( OpenClipboard() == FALSE ) { |
Beep(); return; |
Beep(); return; |
} |
} |
hClip = GetClipboardData(CF_TEXT); |
hClip = GetClipboardData(CF_TEXT); |
src = (const char *)::GlobalLock(hClip); |
src = (const char *)::GlobalLock(hClip); |
if ( !src || (l = strlen(src)) >= 2*BUFSIZ ) { |
if ( !src || (l=strlen(src)) >= sizeof(Buffer)-EndPos ) { |
::CloseClipboard(); |
::CloseClipboard(); |
Beep(); return; |
Beep(); return; |
} |
} |
for ( i = j = 0; i < l; i++ ) |
for ( i = j = 0; i < l; i++ ) |
if ( (c = src[i]) != '\n' && c != '\r' ) |
if ( (c = src[i]) != '\n' && c != '\r' ) |
buf[j++] = c; |
buf[j++] = c; |
buf[j] = 0; |
buf[j] = 0; |
::GlobalUnlock(hClip); |
::GlobalUnlock(hClip); |
::CloseClipboard(); |
::CloseClipboard(); |
GetEditCtrl().ReplaceSel(buf); |
GetEditCtrl().ReplaceSel(buf); |
strncpy(Buffer+EndPos,buf,j); |
l = strlen(buf); |
EndPos += j; CurrentPos = EndPos; |
for ( i = EndPos-1; i >= CurrentPos; i-- ) |
|
Buffer[i+l] = Buffer[i]; |
|
for ( j = 0, i = CurrentPos; j < l; j++, i++ ) |
|
Buffer[i] = buf[j]; |
|
EndPos += l; CurrentPos += l; |
} |
} |
|
|
#define CTRL(c) (c)&0x1f |
#define CTRL(c) (c)&0x1f |
Line 510 void CAsir32guiView::OnEditPaste() |
|
Line 526 void CAsir32guiView::OnEditPaste() |
|
Paste(); |
Paste(); |
} |
} |
|
|
|
void CAsir32guiView::UpdateMetrics() |
|
{ |
|
TEXTMETRIC tm; |
|
RECT r; |
|
|
|
GetEditCtrl().GetRect(&r); |
|
CDC *pDC = GetDC(); |
|
pDC->SelectObject(GetFont()); |
|
pDC->GetTextMetrics(&tm); |
|
MaxLineLength = (r.right-r.left)/tm.tmAveCharWidth-1; |
|
} |
|
|
void CAsir32guiView::OnFont() |
void CAsir32guiView::OnFont() |
{ |
{ |
// TODO: この位置にコマンド ハンドラ用のコードを追加してください |
// TODO: この位置にコマンド ハンドラ用のコードを追加してください |
int ret; |
int ret; |
CFontDialog fd(NULL,CF_EFFECTS | CF_SCREENFONTS | CF_FIXEDPITCHONLY); |
|
static CFont *f = 0; |
|
LOGFONT lf; |
LOGFONT lf; |
|
|
|
GetFont()->GetLogFont(&lf); |
|
CFontDialog fd(&lf,CF_EFFECTS | CF_SCREENFONTS | CF_FIXEDPITCHONLY); |
|
static CFont *f = 0; |
|
|
ret = fd.DoModal(); |
ret = fd.DoModal(); |
if ( ret == IDOK ) { |
if ( ret == IDOK ) { |
fd.GetCurrentFont(&lf); |
fd.GetCurrentFont(&lf); |
Line 526 void CAsir32guiView::OnFont() |
|
Line 556 void CAsir32guiView::OnFont() |
|
f = new CFont; |
f = new CFont; |
f->CreateFontIndirect(&lf); |
f->CreateFontIndirect(&lf); |
SetFont(f); |
SetFont(f); |
|
UpdateMetrics(); |
} |
} |
} |
} |
|
|
Line 535 int CAsir32guiView::OnCreate(LPCREATESTRUCT lpCreateSt |
|
Line 566 int CAsir32guiView::OnCreate(LPCREATESTRUCT lpCreateSt |
|
return -1; |
return -1; |
|
|
// TODO: この位置に固有の作成用コードを追加してください |
// TODO: この位置に固有の作成用コードを追加してください |
|
|
LOGFONT logFont; memset(&logFont, 0, sizeof(LOGFONT)); |
LOGFONT logFont; memset(&logFont, 0, sizeof(LOGFONT)); |
logFont.lfHeight = 20; |
logFont.lfHeight = 20; |
logFont.lfCharSet = DEFAULT_CHARSET; |
logFont.lfCharSet = DEFAULT_CHARSET; |
Line 543 int CAsir32guiView::OnCreate(LPCREATESTRUCT lpCreateSt |
|
Line 574 int CAsir32guiView::OnCreate(LPCREATESTRUCT lpCreateSt |
|
CFont *f = new CFont; |
CFont *f = new CFont; |
f->CreateFontIndirect(&logFont); |
f->CreateFontIndirect(&logFont); |
SetFont(f); |
SetFont(f); |
|
UpdateMetrics(); |
GetEditCtrl().LimitText(nMaxSize); |
GetEditCtrl().LimitText(nMaxSize); |
GetEditCtrl().SetTabStops(m_nTabStops); |
GetEditCtrl().SetTabStops(m_nTabStops); |
|
|
return 0; |
return 0; |
|
} |
|
|
|
void CAsir32guiView::OnContribhelp() |
|
{ |
|
// TODO: この位置にコマンド ハンドラ用のコードを追加してください |
|
char root[BUFSIZ],errmsg[BUFSIZ],helpfile[BUFSIZ]; |
|
|
|
get_rootdir(root,sizeof(root),errmsg); |
|
sprintf(helpfile,"%s\\bin\\cmanhelp.chm",root); |
|
HtmlHelp(NULL, helpfile, HH_DISPLAY_TOPIC, 0); |
|
} |
|
|
|
void CAsir32guiView::OnUpdateContribhelp(CCmdUI* pCmdUI) |
|
{ |
|
// TODO: この位置に command update UI ハンドラ用のコードを追加してください |
|
char root[BUFSIZ],errmsg[BUFSIZ],helpfile[BUFSIZ]; |
|
|
|
if ( getenv("OpenXM_WIN_ROOT") ) { |
|
get_rootdir(root,sizeof(root),errmsg); |
|
sprintf(helpfile,"%s\\bin\\cmanhelp.chm",root); |
|
if ( _access(helpfile,04) != -1 ) { |
|
pCmdUI->Enable( TRUE ); |
|
return; |
|
} |
|
} |
|
pCmdUI->Enable( FALSE ); |
|
} |
|
|
|
void CAsir32guiView::OnSize(UINT nType, int cx, int cy) |
|
{ |
|
CEditView::OnSize(nType, cx, cy); |
|
|
|
// TODO: この位置にメッセージ ハンドラ用のコードを追加してください |
|
UpdateMetrics(); |
} |
} |