[BACK]Return to asir32guiview.cpp CVS log [TXT][DIR] Up to [local] / OpenXM_contrib2 / windows / asir32gui

Annotation of OpenXM_contrib2/windows/asir32gui/asir32guiview.cpp, Revision 1.27

1.1       noro        1: // asir32guiView.cpp : CAsir32guiView クラスの動作の定義を行います。
                      2: //
                      3:
                      4: #include "stdafx.h"
                      5:
                      6: #include "asir32gui.h"
                      7: #include "asir32guiDoc.h"
                      8: #include "asir32guiView.h"
                      9: #include "FatalDialog.h"
1.3       noro       10: #include <direct.h>
1.6       noro       11: #include <io.h>
1.1       noro       12:
                     13: #ifdef _DEBUG
                     14: #define new DEBUG_NEW
                     15: #undef THIS_FILE
                     16: static char THIS_FILE[] = __FILE__;
                     17: #endif
                     18:
1.5       noro       19: // const TextBufferSize     = 32768;
1.19      ohara      20: const int TextBufferSize     = 16384;
1.1       noro       21:
                     22: CAsir32guiView *theView;
                     23:
                     24: extern "C"
                     25: {
                     26: char *prev_hist(void), *next_hist(void), *search_hist(char *p);
                     27: void read_input_history(),write_input_history();
                     28: void init_input_history();
                     29: void add_hist(char *p), reset_traverse(void);
                     30: void asir_terminate(void);
                     31: void Main(int,char*[]);
                     32: void loadfile(char *);
                     33: void put_line(char *);
                     34: void send_intr(void);
                     35: void insert_to_theView(char *);
1.26      ohara      36: BOOL get_rootdir(char *,int,char *);
1.1       noro       37: extern int bigfloat, prtime, prresult;
                     38: extern char *asir_libdir;
1.2       noro       39: extern int asirgui_kind;
1.1       noro       40:
                     41: void insert_to_theView(char *str)
                     42: {
                     43:        (void)theView->Insert(str);
                     44: }
                     45: void flush_log()
                     46: {
                     47:        if ( theView->Logging )
                     48:                theView->OnFileLog();
                     49: }
                     50: }
                     51:
                     52: /////////////////////////////////////////////////////////////////////////////
                     53: // CAsir32guiView
                     54:
                     55: IMPLEMENT_DYNCREATE(CAsir32guiView, CEditView)
                     56:
                     57: BEGIN_MESSAGE_MAP(CAsir32guiView, CEditView)
                     58:        //{{AFX_MSG_MAP(CAsir32guiView)
                     59:        ON_WM_KEYDOWN()
                     60:        ON_WM_CHAR()
                     61:        ON_WM_LBUTTONUP()
                     62:        ON_WM_RBUTTONDOWN()
                     63:        ON_COMMAND(ID_FILE_OPEN, OnFileOpen)
                     64:        ON_COMMAND(ID_FILE_LOG, OnFileLog)
                     65:        ON_COMMAND(ID_ASIRHELP, OnAsirhelp)
                     66:        ON_UPDATE_COMMAND_UI(ID_FILE_LOG, OnUpdateFileLog)
                     67:        ON_COMMAND(ID_EDIT_PASTE, OnEditPaste)
1.3       noro       68:        ON_COMMAND(IDR_FONT, OnFont)
                     69:        ON_WM_CREATE()
1.6       noro       70:        ON_COMMAND(ID_CONTRIBHELP, OnContribhelp)
1.9       noro       71:        ON_WM_SIZE()
1.11      noro       72:        ON_COMMAND(ID_DSOLV, OnDsolv)
                     73:        ON_COMMAND(ID_GNUPLOT, OnGnuplot)
                     74:        ON_COMMAND(ID_OKDIFF, OnOkdiff)
                     75:        ON_COMMAND(ID_OKDMODULE, OnOkdmodule)
                     76:        ON_COMMAND(ID_OM, OnOm)
                     77:        ON_COMMAND(ID_PFPCOH, OnPfpcoh)
                     78:        ON_COMMAND(ID_PLUCKER, OnPlucker)
                     79:        ON_COMMAND(ID_SM1, OnSm1)
                     80:        ON_COMMAND(ID_TIGERS, OnTigers)
                     81:        ON_COMMAND(ID_TODOPARAMETRIZE, OnTodoparametrize)
1.24      noro       82:        ON_COMMAND(ID_NOROMATRIX, OnNoromatrix)
                     83:        ON_COMMAND(ID_NOROMWL, OnNoromwl)
                     84:        ON_COMMAND(ID_NNNDBF, OnNnndbf)
1.25      noro       85:        ON_COMMAND(ID_NOROPD, OnNoropd)
                     86:        ON_COMMAND(ID_NSTWLG, OnNstwistedlog)
1.1       noro       87:        //}}AFX_MSG_MAP
                     88:        // 標準印刷コマンド
                     89: //     ON_COMMAND(ID_FILE_PRINT, CEditView::OnFilePrint)
                     90: //     ON_COMMAND(ID_FILE_PRINT_DIRECT, CEditView::OnFilePrint)
                     91: //     ON_COMMAND(ID_FILE_PRINT_PREVIEW, CEditView::OnFilePrintPreview)
                     92: END_MESSAGE_MAP()
                     93:
                     94: /////////////////////////////////////////////////////////////////////////////
                     95: // CAsir32guiView クラスの構築/消滅
                     96:
                     97: CAsir32guiView::CAsir32guiView()
                     98: {
                     99:        // TODO: この場所に構築用のコードを追加してください。
                    100:        static int tmpView_created = 0;
                    101:
                    102:        init_input_history();
                    103:        read_input_history();
                    104:        DebugMode = 0;
                    105:        DebugInMain = 0;
1.9       noro      106: //     MaxLineLength = 80;
1.1       noro      107:        LogStart = 0;
                    108:        Logging = 0;
                    109:        Logfp = NULL;
                    110:        ResetIndex();
                    111:        theView = this;
1.23      ohara     112: #if _MSC_VER > 1300
                    113:        /* VS2003.NET or later */
                    114:        (AfxGetApp())->EnableHtmlHelp();
                    115: #endif
1.1       noro      116: }
                    117:
                    118: CAsir32guiView::~CAsir32guiView()
                    119: {
                    120:        write_input_history();
                    121: }
                    122:
                    123: BOOL CAsir32guiView::PreCreateWindow(CREATESTRUCT& cs)
                    124: {
                    125:        // TODO: この位置で CREATESTRUCT cs を修正して Window クラスまたはスタイルを
                    126:        //       修正してください。
                    127:
                    128:        m_dwDefaultStyle = dwStyleDefault & ~ES_AUTOHSCROLL ;
                    129:        m_dwDefaultStyle &= ~WS_HSCROLL;
                    130:        return CCtrlView::PreCreateWindow(cs);
                    131: }
                    132:
                    133: /////////////////////////////////////////////////////////////////////////////
                    134: // CAsir32guiView クラスの描画
                    135:
                    136: void CAsir32guiView::OnDraw(CDC* pDC)
                    137: {
                    138:        CAsir32guiDoc* pDoc = GetDocument();
                    139:        ASSERT_VALID(pDoc);
                    140:
                    141:        // TODO: この場所にネイティブ データ用の描画コードを追加します。
                    142: }
                    143:
                    144: /////////////////////////////////////////////////////////////////////////////
                    145: // CAsir32guiView クラスの印刷
                    146:
                    147: BOOL CAsir32guiView::OnPreparePrinting(CPrintInfo* pInfo)
                    148: {
                    149:        // デフォルトの印刷準備
                    150:        return DoPreparePrinting(pInfo);
                    151: }
                    152:
                    153: void CAsir32guiView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
                    154: {
                    155:        // TODO: 印刷前の特別な初期化処理を追加してください。
                    156: }
                    157:
                    158: void CAsir32guiView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
                    159: {
                    160:        // TODO: 印刷後の後処理を追加してください。
                    161: }
                    162:
                    163: /////////////////////////////////////////////////////////////////////////////
                    164: // CAsir32guiView クラスの診断
                    165:
                    166: #ifdef _DEBUG
                    167: void CAsir32guiView::AssertValid() const
                    168: {
                    169:        CEditView::AssertValid();
                    170: }
                    171:
                    172: void CAsir32guiView::Dump(CDumpContext& dc) const
                    173: {
                    174:        CEditView::Dump(dc);
                    175: }
                    176:
                    177: CAsir32guiDoc* CAsir32guiView::GetDocument() // 非デバッグ バージョンはインラインです。
                    178: {
                    179:        ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CAsir32guiDoc)));
                    180:        return (CAsir32guiDoc*)m_pDocument;
                    181: }
                    182: #endif //_DEBUG
                    183:
                    184: /////////////////////////////////////////////////////////////////////////////
                    185: // CAsir32guiView クラスのメッセージ ハンドラ
                    186:
                    187: void CAsir32guiView::PutChar(int c)
                    188: {
1.8       noro      189:   int i,len;
1.1       noro      190:   char buf[2];
                    191:
1.8       noro      192:   if ( EndPos >= sizeof(Buffer)-1 ) {
                    193:       Beep(); return;
                    194:   }
1.1       noro      195:   for ( i = EndPos-1; i >= CurrentPos; i-- )
1.8       noro      196:       Buffer[i+1] = Buffer[i];
1.1       noro      197:   Buffer[CurrentPos] = (char)c;
1.8       noro      198: //  buf[0] = (char)c; buf[1] = 0;
                    199: //  Insert(buf,FALSE);
                    200:   len = GetWindowTextLength();
                    201:   if ( len+1 >= TextBufferSize )
                    202:       DeleteTop();
                    203:   CEditView::OnChar(c, 1, 0);
1.1       noro      204:   CurrentPos++;
                    205:   EndPos++;
                    206: }
                    207:
                    208: void CAsir32guiView::DeleteChar(int count) {
                    209:   int i,s,e;
                    210:   char null = 0;
                    211:
                    212:   if ( count > (EndPos-CurrentPos) )
                    213:     count = EndPos - CurrentPos;
1.15      noro      214:   if ( count > 0 ) {
1.1       noro      215:     EndPos -= count;
                    216:     for ( i = CurrentPos; i < EndPos; i++ )
                    217:       Buffer[i] = Buffer[i+count];
                    218:     GetEditCtrl().GetSel(s,e);
                    219:     GetEditCtrl().SetSel(s,s+count);
                    220:     GetEditCtrl().ReplaceSel(&null);
                    221:   }
                    222: }
                    223:
                    224: void CAsir32guiView::Insert(char *buf,BOOL wrap)
                    225: {
                    226:        char t[BUFSIZ*4];
                    227:        char *p,*q,c;
                    228:        int len;
                    229:        int i;
                    230:
                    231:        if ( wrap ) {
                    232:                i = GetEditCtrl().LineLength(-1);
                    233:                for ( p = t, q = buf; (c = *p++ = *q++) != 0; )
                    234:                        if ( c == '\r' ) {
                    235:                                *p++ = *q++; i = 0;
                    236:                        } else if ( (*q != '\r') && (++i == MaxLineLength) ) {
                    237:                                *p++ = '\r'; *p++ = '\r'; *p++ = '\n'; i = 0;
                    238:                        }
                    239:                p = t;
                    240:        } else
                    241:                p = buf;
                    242:        len = GetWindowTextLength();
                    243:        if ( strlen(p) + len >= TextBufferSize )
                    244:                DeleteTop();
                    245:        GetEditCtrl().ReplaceSel(p);
                    246: }
                    247:
                    248: void CAsir32guiView::DeleteTop()
                    249: {
                    250:   const char *p,*q;
                    251:   const char *buf;
                    252:   char null = 0;
1.20      ohara     253:   int len,len0;
1.1       noro      254:
                    255:   buf = LockBuffer();
                    256:   len0 = len = strlen(buf);
                    257:   for ( p = buf; len >= TextBufferSize/2; ) {
                    258:     q = strchr(p,'\n');
                    259:     if ( !q ) {
                    260:        len = 0; break;
                    261:     } else {
                    262:       q++; len -= (q-p); p = q;
                    263:     }
                    264:   }
                    265:   if ( Logging ) {
1.4       noro      266:     if ( len < LogStart )
                    267:        LogStart -= len;
                    268:     else {
                    269:        fwrite(buf+LogStart,1,len-LogStart,Logfp);
                    270:        LogStart = 0;
                    271:     }
1.1       noro      272:   }
                    273:   UnlockBuffer();
                    274:   if ( q ) {
                    275:        GetEditCtrl().SetSel(0,len);
                    276:        GetEditCtrl().ReplaceSel(&null);
                    277:   }
                    278:   UpdateCursor(EndPos);
                    279: }
                    280:
                    281: void CAsir32guiView::UpdateCursor(int pos)
                    282: {
                    283:   int s;
                    284:   int len;
                    285:
                    286:   if ( pos < 0 || pos > EndPos )
                    287:     Beep();
                    288:   else {
                    289:     len = GetWindowTextLength();
                    290:     CurrentPos = pos;
                    291:     s = len-EndPos+CurrentPos;
                    292:     GetEditCtrl().SetSel(s,s);
                    293:   }
                    294: }
                    295:
                    296: void CAsir32guiView::ReplaceString(char *str)
                    297: {
                    298:   UpdateCursor(0); DeleteChar(EndPos);
                    299:   Insert(str,FALSE);
                    300:   strcpy(Buffer,str);
                    301:   EndPos = CurrentPos = strlen(str);
                    302: }
                    303:
                    304: void CAsir32guiView::Beep(void) {
                    305:   ::MessageBeep(0xffffffff);
                    306: }
                    307:
                    308: void CAsir32guiView::Paste(void) {
1.8       noro      309:     char buf[2*BUFSIZ];
                    310:     const char *src;
                    311:     char c;
                    312:     int i,j,l;
                    313:     HGLOBAL hClip;
                    314:
                    315:     if ( asirgui_kind == ASIRGUI_MESSAGE ) {
                    316:         Beep(); return;
                    317:     }
1.2       noro      318:
1.8       noro      319:     if ( OpenClipboard() == FALSE ) {
                    320:         Beep(); return;
1.1       noro      321:     }
                    322:     hClip = GetClipboardData(CF_TEXT);
                    323:     src = (const char *)::GlobalLock(hClip);
1.10      noro      324:     if ( !src || (l=strlen(src)) >= sizeof(Buffer)-EndPos ) {
1.1       noro      325:        ::CloseClipboard();
                    326:        Beep(); return;
                    327:     }
1.8       noro      328:     for ( i = j = 0; i < l; i++ )
                    329:         if ( (c = src[i]) != '\n' && c != '\r' )
                    330:              buf[j++] = c;
                    331:     buf[j] = 0;
1.1       noro      332:     ::GlobalUnlock(hClip);
                    333:     ::CloseClipboard();
                    334:     GetEditCtrl().ReplaceSel(buf);
1.10      noro      335:     l = strlen(buf);
                    336:     for ( i = EndPos-1; i >= CurrentPos; i-- )
                    337:        Buffer[i+l] = Buffer[i];
                    338:     for ( j = 0, i = CurrentPos; j < l; j++, i++ )
                    339:        Buffer[i] = buf[j];
                    340:     EndPos += l; CurrentPos += l;
1.1       noro      341: }
                    342:
                    343: #define CTRL(c) (c)&0x1f
                    344:
                    345: void CAsir32guiView::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
                    346: {
                    347:        // TODO: この位置にメッセージ ハンドラ用のコードを追加するかまたはデフォルトの処理を呼び出してください
                    348:        char *exp_result;
                    349:
                    350:        switch ( nChar ) {
                    351:                case VK_LEFT:
                    352:                        UpdateCursor(CurrentPos-1); return;
                    353:                case VK_RIGHT:
                    354:                        UpdateCursor(CurrentPos+1); return;
                    355:                case VK_DELETE:
                    356:                        DeleteChar(1); return;
                    357:                case VK_UP:
                    358:                        if ( (exp_result = prev_hist()) != 0 )
                    359:                                ReplaceString(exp_result);
                    360:                        else
                    361:                                Beep();
                    362:                        return;
                    363:                case VK_DOWN:
                    364:                        if ( (exp_result = next_hist()) != 0 )
                    365:                                ReplaceString(exp_result);
                    366:                        else
                    367:                                Beep();
                    368:                        return;
                    369:                default:
                    370:                        break;
                    371:        }
                    372:        CEditView::OnKeyDown(nChar, nRepCnt, nFlags);
                    373: }
                    374:
                    375: void CAsir32guiView::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
                    376: {
                    377:        // TODO: この位置にメッセージ ハンドラ用のコードを追加するかまたはデフォルトの処理を呼び出してください
                    378:        char *exp_result;
1.13      noro      379:        char tmp[BUFSIZ];
1.27    ! noro      380:        int i;
1.1       noro      381:
1.2       noro      382:        if ( asirgui_kind == ASIRGUI_MESSAGE ) {
                    383:                Beep(); return;
                    384:        }
                    385:
1.1       noro      386:        switch ( nChar ) {
                    387:        case CTRL('M'): case CTRL('J'):
                    388:                UpdateCursor(EndPos);
                    389:                Buffer[EndPos] = 0;
                    390:                reset_traverse();
                    391:                if ( Buffer[0] == '!' ) {
                    392:                exp_result = search_hist(Buffer+1);
                    393:                if ( exp_result )
                    394:                        ReplaceString(exp_result);
                    395:                else {
                    396:                        UpdateCursor(0); DeleteChar(EndPos); Beep();
                    397:                }
                    398:                return;
                    399:                } else {
                    400:                        add_hist(Buffer);
                    401:                        put_line(Buffer);
                    402:                        ResetIndex();
                    403:                        nChar = CTRL('M');
                    404:                }
                    405:                break;
                    406:        case CTRL('N'):
                    407:                if ( (exp_result = next_hist()) != 0 )
                    408:                ReplaceString(exp_result);
                    409:                else
                    410:                Beep();
                    411:                return;
                    412:        case CTRL('P'):
                    413:                if ( (exp_result = prev_hist()) != 0 )
                    414:                ReplaceString(exp_result);
                    415:                else
                    416:                Beep();
                    417:                return;
                    418:        case CTRL('A'):
                    419:                UpdateCursor(0); return;
                    420:        case CTRL('E'):
                    421:                UpdateCursor(EndPos); return;
                    422:        case CTRL('F'):
                    423:                UpdateCursor(CurrentPos+1); return;
                    424:        case CTRL('B'):
                    425:                UpdateCursor(CurrentPos-1); return;
                    426:        case CTRL('K'):
                    427:                DeleteChar(EndPos-CurrentPos); return;
                    428:        case CTRL('U'):
                    429:                UpdateCursor(0); DeleteChar(EndPos); return;
                    430:        case CTRL('D'):
                    431:                DeleteChar(1); return;
                    432:        case CTRL('H'):
                    433:                if ( CurrentPos > 0 ) {
                    434:                UpdateCursor(CurrentPos-1); DeleteChar(1);
                    435:                } else
                    436:                Beep();
                    437:                return;
                    438:        case CTRL('C'):
                    439:                send_intr();
                    440:                /* wake up the engine */
1.13      noro      441:                tmp[0] = 0;
                    442:                put_line(tmp);
1.1       noro      443:                return;
1.27    ! noro      444:        case CTRL('Y'):
        !           445:                Paste(); return;
        !           446:        case CTRL('I'):
        !           447:                return;
1.1       noro      448:        default :
                    449:                if ( nChar >= 0x20 && nChar < 0x7f )
                    450:                        PutChar(nChar);
                    451:                else
                    452:                        Beep();
                    453:                return;
                    454:        }
                    455:        CEditView::OnChar(nChar, nRepCnt, nFlags);
                    456: }
                    457:
                    458: void CAsir32guiView::OnLButtonUp(UINT nFlags, CPoint point)
                    459: {
                    460:        // TODO: この位置にメッセージ ハンドラ用のコードを追加するかまたはデフォルトの処理を呼び出してください
                    461:     GetEditCtrl().Copy(); UpdateCursor(EndPos);
                    462:        CEditView::OnLButtonUp(nFlags, point);
                    463: }
                    464:
                    465: void CAsir32guiView::OnRButtonDown(UINT nFlags, CPoint point)
                    466: {
                    467:        // TODO: この位置にメッセージ ハンドラ用のコードを追加するかまたはデフォルトの処理を呼び出してください
                    468:     Paste();
                    469:
                    470: //     CEditView::OnRButtonDown(nFlags, point);
                    471: }
                    472:
                    473: void CAsir32guiView::OnFileOpen()
                    474: {
                    475:        // TODO: この位置にコマンド ハンドラ用のコードを追加してください
                    476:        char cmd[BUFSIZ*2]; // XXX
                    477:        char *p;
1.3       noro      478:        static char errmsg[BUFSIZ];
                    479:        static char prevdir[BUFSIZ];
1.1       noro      480:
1.3       noro      481:        if ( !prevdir[0] ) {
                    482:                get_rootdir(prevdir,sizeof(prevdir),errmsg);
                    483:                strcat(prevdir,"\\lib");
                    484:        }
                    485:
                    486:        _chdir(prevdir);
1.1       noro      487:        CFileDialog     fileDialog(TRUE);
1.14      noro      488:        fileDialog.m_ofn.lpstrInitialDir = prevdir;
1.1       noro      489:        if ( fileDialog.DoModal() == IDOK ) {
                    490:                CString pathName = fileDialog.GetPathName();
                    491:                sprintf(cmd,"load(\"%s\");",pathName);
                    492:                for ( p = cmd; *p; p++ )
                    493:                        if ( *p == '\\' )
                    494:                                *p = '/';
                    495:                put_line(cmd);
1.20      ohara     496:                strcpy(cmd,pathName);
                    497:                p = strrchr(cmd,'\\');
1.3       noro      498:                if ( p ) {
                    499:                        *p = 0;
1.20      ohara     500:                        strcpy(prevdir,cmd);
1.3       noro      501:                }
1.1       noro      502:        }
                    503: }
1.21      ohara     504: void CAsir32guiView::viewHtmlHelp(char *help)
                    505: {
1.23      ohara     506:        char *helpfile;
                    507:        char fmt[] = "%s\\help\\%shelp.chm";
                    508:        char root[BUFSIZ],errmsg[BUFSIZ];
                    509:        get_rootdir(root,sizeof(root),errmsg);
                    510:        helpfile = (char *)malloc(sizeof(fmt) + strlen(root) + strlen(help));
                    511:        sprintf(helpfile,fmt,root,help);
1.21      ohara     512: #if _MSC_VER < 1300
                    513:     /* Visual C++ 6.0 */
                    514:        ::HtmlHelp(NULL, helpfile, HH_DISPLAY_TOPIC, 0);
1.23      ohara     515: #else
                    516:        CWinApp *top = AfxGetApp();
                    517:        top->SetHelpMode(AFX_HELP_TYPE::afxHTMLHelp);
                    518:        if (top->m_pszHelpFilePath) {
                    519:                free((void*)top->m_pszHelpFilePath);
                    520:        }
                    521:        top->m_pszHelpFilePath = helpfile;
                    522:        HtmlHelp(HH_DISPLAY_TOPIC, 0);
1.21      ohara     523: #endif
                    524: }
1.1       noro      525:
                    526: void CAsir32guiView::OnAsirhelp()
                    527: {
                    528:        // TODO: この位置にコマンド ハンドラ用のコードを追加してください
1.21      ohara     529:        viewHtmlHelp("asir");
1.1       noro      530: }
                    531:
                    532: void CAsir32guiView::OnFileLog()
                    533: {
                    534:        // TODO: この位置にコマンド ハンドラ用のコードを追加してください
                    535:        if ( !Logging ) {
                    536:                CFileDialog     fileDialog(TRUE);
                    537:                if ( fileDialog.DoModal() == IDOK ) {
                    538:                        CString logfile = fileDialog.GetPathName();
                    539:                        Logfp = fopen(logfile,"ab");
                    540:                        if ( Logfp ) {
                    541:                                LogStart = GetWindowTextLength();
                    542:                                Logging = 1;
                    543:                        }
                    544:                }
                    545:        } else {
                    546:                const char *buf;
                    547:                buf = LockBuffer();
                    548:                fwrite(buf+LogStart,1,strlen(buf)-LogStart,Logfp);
                    549:                UnlockBuffer();
                    550:                fclose(Logfp);
                    551:                Logging = 0;
                    552:        }
                    553: }
                    554:
                    555: void CAsir32guiView::OnUpdateFileLog(CCmdUI* pCmdUI)
                    556: {
                    557:        // TODO: この位置に command update UI ハンドラ用のコードを追加してください
                    558:        if ( Logging )
                    559:                pCmdUI->SetCheck(1);
                    560:        else
                    561:                pCmdUI->SetCheck(0);
                    562: }
                    563:
                    564: void CAsir32guiView::OnEditPaste()
                    565: {
                    566:        // TODO: この位置にコマンド ハンドラ用のコードを追加してください
                    567:     Paste();
1.3       noro      568: }
                    569:
1.9       noro      570: void CAsir32guiView::UpdateMetrics()
                    571: {
                    572:    TEXTMETRIC tm;
                    573:    RECT r;
                    574:
                    575:    GetEditCtrl().GetRect(&r);
                    576:    CDC *pDC = GetDC();
                    577:    pDC->SelectObject(GetFont());
                    578:    pDC->GetTextMetrics(&tm);
                    579:    MaxLineLength = (r.right-r.left)/tm.tmAveCharWidth-1;
                    580: }
                    581:
1.3       noro      582: void CAsir32guiView::OnFont()
                    583: {
                    584:        // TODO: この位置にコマンド ハンドラ用のコードを追加してください
1.26      ohara     585:        INT_PTR ret;
1.9       noro      586:        LOGFONT lf;
                    587:
                    588:        GetFont()->GetLogFont(&lf);
                    589:        CFontDialog fd(&lf,CF_EFFECTS | CF_SCREENFONTS | CF_FIXEDPITCHONLY);
1.3       noro      590:        static CFont *f = 0;
                    591:
                    592:        ret = fd.DoModal();
                    593:        if ( ret == IDOK ) {
                    594:                fd.GetCurrentFont(&lf);
                    595:                if ( f )
                    596:                        delete f;
                    597:                f = new CFont;
                    598:                f->CreateFontIndirect(&lf);
                    599:                SetFont(f);
1.9       noro      600:                UpdateMetrics();
1.3       noro      601:        }
                    602: }
                    603:
                    604: int CAsir32guiView::OnCreate(LPCREATESTRUCT lpCreateStruct)
                    605: {
                    606:        if (CEditView::OnCreate(lpCreateStruct) == -1)
                    607:                return -1;
                    608:
                    609:        // TODO: この位置に固有の作成用コードを追加してください
1.9       noro      610:
1.3       noro      611:        LOGFONT logFont; memset(&logFont, 0, sizeof(LOGFONT));
                    612:        logFont.lfHeight = 20;
                    613:        logFont.lfCharSet = DEFAULT_CHARSET;
                    614:        strcpy(logFont.lfFaceName, "Terminal");
                    615:        CFont *f = new CFont;
                    616:        f->CreateFontIndirect(&logFont);
                    617:        SetFont(f);
1.9       noro      618:        UpdateMetrics();
1.3       noro      619:        GetEditCtrl().LimitText(nMaxSize);
1.9       noro      620:        GetEditCtrl().SetTabStops(m_nTabStops);
1.3       noro      621:
                    622:        return 0;
1.6       noro      623: }
                    624:
                    625: void CAsir32guiView::OnContribhelp()
                    626: {
                    627:        // TODO: この位置にコマンド ハンドラ用のコードを追加してください
1.21      ohara     628:        viewHtmlHelp("cman");
1.6       noro      629: }
                    630:
1.11      noro      631: void CAsir32guiView::OnSize(UINT nType, int cx, int cy)
                    632: {
                    633:        CEditView::OnSize(nType, cx, cy);
                    634:
                    635:        // TODO: この位置にメッセージ ハンドラ用のコードを追加してください
                    636:        UpdateMetrics();
                    637: }
                    638:
                    639: void CAsir32guiView::OnDsolv()
                    640: {
                    641:        // TODO: この位置にコマンド ハンドラ用のコードを追加してください
1.21      ohara     642:        viewHtmlHelp("dsolv");
1.11      noro      643: }
                    644:
                    645: void CAsir32guiView::OnGnuplot()
                    646: {
                    647:        // TODO: この位置にコマンド ハンドラ用のコードを追加してください
1.21      ohara     648:        viewHtmlHelp("gnuplot");
1.11      noro      649: }
                    650:
                    651: void CAsir32guiView::OnOkdiff()
                    652: {
                    653:        // TODO: この位置にコマンド ハンドラ用のコードを追加してください
1.21      ohara     654:        viewHtmlHelp("ok_diff");
1.11      noro      655: }
                    656:
                    657: void CAsir32guiView::OnOkdmodule()
                    658: {
                    659:        // TODO: この位置にコマンド ハンドラ用のコードを追加してください
1.21      ohara     660:        viewHtmlHelp("ok_dmodule");
1.11      noro      661: }
                    662:
                    663: void CAsir32guiView::OnOm()
                    664: {
                    665:        // TODO: この位置にコマンド ハンドラ用のコードを追加してください
1.21      ohara     666:        viewHtmlHelp("om");
1.11      noro      667: }
                    668:
                    669: void CAsir32guiView::OnPfpcoh()
                    670: {
                    671:        // TODO: この位置にコマンド ハンドラ用のコードを追加してください
1.21      ohara     672:        viewHtmlHelp("pfpcoh");
1.11      noro      673: }
                    674:
                    675: void CAsir32guiView::OnPlucker()
                    676: {
                    677:        // TODO: この位置にコマンド ハンドラ用のコードを追加してください
1.21      ohara     678:        viewHtmlHelp("plucker");
1.11      noro      679: }
                    680:
                    681: void CAsir32guiView::OnSm1()
                    682: {
                    683:        // TODO: この位置にコマンド ハンドラ用のコードを追加してください
1.21      ohara     684:        viewHtmlHelp("sm1");
1.11      noro      685: }
                    686:
                    687: void CAsir32guiView::OnTigers()
1.6       noro      688: {
1.11      noro      689:        // TODO: この位置にコマンド ハンドラ用のコードを追加してください
1.21      ohara     690:        viewHtmlHelp("tigers");
1.9       noro      691: }
                    692:
1.11      noro      693: void CAsir32guiView::OnTodoparametrize()
1.9       noro      694: {
1.11      noro      695:        // TODO: この位置にコマンド ハンドラ用のコードを追加してください
1.21      ohara     696:        viewHtmlHelp("todo_parametrize");
1.1       noro      697: }
1.16      noro      698:
1.24      noro      699: void CAsir32guiView::OnNoromatrix()
                    700: {
                    701:        // TODO: この位置にコマンド ハンドラ用のコードを追加してください
                    702:        viewHtmlHelp("noro_matrix");
                    703: }
                    704:
                    705: void CAsir32guiView::OnNoromwl()
                    706: {
                    707:        // TODO: この位置にコマンド ハンドラ用のコードを追加してください
                    708:        viewHtmlHelp("noro_mwl");
                    709: }
                    710:
1.25      noro      711: void CAsir32guiView::OnNoropd()
                    712: {
                    713:        // TODO: この位置にコマンド ハンドラ用のコードを追加してください
                    714:        viewHtmlHelp("noro_pd");
                    715: }
                    716:
1.24      noro      717: void CAsir32guiView::OnNnndbf()
                    718: {
                    719:        // TODO: この位置にコマンド ハンドラ用のコードを追加してください
                    720:        viewHtmlHelp("nn_ndbf");
                    721: }
                    722:
1.25      noro      723: void CAsir32guiView::OnNstwistedlog()
                    724: {
                    725:        // TODO: この位置にコマンド ハンドラ用のコードを追加してください
                    726:        viewHtmlHelp("ns_twistedlog");
                    727: }
                    728:
1.16      noro      729: BOOL CAsir32guiView::Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext)
                    730: {
                    731:        // TODO: この位置に固有の処理を追加するか、または基本クラスを呼び出してください
                    732:
                    733:        BOOL ret = CWnd::Create(lpszClassName, lpszWindowName, dwStyle, rect, pParentWnd, nID, pContext);
1.26      ohara     734:        FILE *fp = NULL;
1.17      noro      735:        char *temp;
1.26      ohara     736:        char rootdir[BUFSIZ], errmsg[BUFSIZ], hndname[_MAX_PATH];
1.17      noro      737:
1.26      ohara     738:        if (get_rootdir(rootdir, BUFSIZ, errmsg)) {
                    739:                sprintf(hndname, "%s\\bin\\asirgui.hnd", rootdir);
                    740:                fp = fopen(hndname,"w");
                    741:        }
1.18      noro      742:        if ( fp ) {
1.17      noro      743:                fprintf(fp,"%d",(unsigned int)theView->m_hWnd);
                    744:                fclose(fp);
1.18      noro      745:                if ( temp = getenv("TEMP") ) {
1.26      ohara     746:                        size_t len;
1.18      noro      747:                        char *name;
                    748:
                    749:                        len = strlen(temp);
                    750:                        name = (char *)malloc(len+BUFSIZ);
                    751:                        sprintf(name,"%s\\asirgui.hnd",temp);
                    752:                        fopen(name,"w");
                    753:                        fprintf(fp,"%d",(unsigned int)theView->m_hWnd);
                    754:                        fclose(fp);
                    755:                }
1.17      noro      756:        }
1.16      noro      757:        return ret;
                    758: }

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>