[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.26

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.1       noro      380:
1.2       noro      381:        if ( asirgui_kind == ASIRGUI_MESSAGE ) {
                    382:                Beep(); return;
                    383:        }
                    384:
1.1       noro      385:        switch ( nChar ) {
                    386:        case CTRL('M'): case CTRL('J'):
                    387:                UpdateCursor(EndPos);
                    388:                Buffer[EndPos] = 0;
                    389:                reset_traverse();
                    390:                if ( Buffer[0] == '!' ) {
                    391:                exp_result = search_hist(Buffer+1);
                    392:                if ( exp_result )
                    393:                        ReplaceString(exp_result);
                    394:                else {
                    395:                        UpdateCursor(0); DeleteChar(EndPos); Beep();
                    396:                }
                    397:                return;
                    398:                } else {
                    399:                        add_hist(Buffer);
                    400:                        put_line(Buffer);
                    401:                        ResetIndex();
                    402:                        nChar = CTRL('M');
                    403:                }
                    404:                break;
                    405:        case CTRL('N'):
                    406:                if ( (exp_result = next_hist()) != 0 )
                    407:                ReplaceString(exp_result);
                    408:                else
                    409:                Beep();
                    410:                return;
                    411:        case CTRL('P'):
                    412:                if ( (exp_result = prev_hist()) != 0 )
                    413:                ReplaceString(exp_result);
                    414:                else
                    415:                Beep();
                    416:                return;
                    417:        case CTRL('A'):
                    418:                UpdateCursor(0); return;
                    419:        case CTRL('E'):
                    420:                UpdateCursor(EndPos); return;
                    421:        case CTRL('F'):
                    422:                UpdateCursor(CurrentPos+1); return;
                    423:        case CTRL('B'):
                    424:                UpdateCursor(CurrentPos-1); return;
                    425:        case CTRL('K'):
                    426:                DeleteChar(EndPos-CurrentPos); return;
                    427:        case CTRL('U'):
                    428:                UpdateCursor(0); DeleteChar(EndPos); return;
                    429:        case CTRL('D'):
                    430:                DeleteChar(1); return;
                    431:        case CTRL('H'):
                    432:                if ( CurrentPos > 0 ) {
                    433:                UpdateCursor(CurrentPos-1); DeleteChar(1);
                    434:                } else
                    435:                Beep();
                    436:                return;
                    437:        case CTRL('C'):
                    438:                send_intr();
                    439:                /* wake up the engine */
1.13      noro      440:                tmp[0] = 0;
                    441:                put_line(tmp);
1.1       noro      442:                return;
                    443:        default :
                    444:                if ( nChar >= 0x20 && nChar < 0x7f )
                    445:                        PutChar(nChar);
                    446:                else
                    447:                        Beep();
                    448:                return;
                    449:        }
                    450:        CEditView::OnChar(nChar, nRepCnt, nFlags);
                    451: }
                    452:
                    453: void CAsir32guiView::OnLButtonUp(UINT nFlags, CPoint point)
                    454: {
                    455:        // TODO: この位置にメッセージ ハンドラ用のコードを追加するかまたはデフォルトの処理を呼び出してください
                    456:     GetEditCtrl().Copy(); UpdateCursor(EndPos);
                    457:        CEditView::OnLButtonUp(nFlags, point);
                    458: }
                    459:
                    460: void CAsir32guiView::OnRButtonDown(UINT nFlags, CPoint point)
                    461: {
                    462:        // TODO: この位置にメッセージ ハンドラ用のコードを追加するかまたはデフォルトの処理を呼び出してください
                    463:     Paste();
                    464:
                    465: //     CEditView::OnRButtonDown(nFlags, point);
                    466: }
                    467:
                    468: void CAsir32guiView::OnFileOpen()
                    469: {
                    470:        // TODO: この位置にコマンド ハンドラ用のコードを追加してください
                    471:        char cmd[BUFSIZ*2]; // XXX
                    472:        char *p;
1.3       noro      473:        static char errmsg[BUFSIZ];
                    474:        static char prevdir[BUFSIZ];
1.1       noro      475:
1.3       noro      476:        if ( !prevdir[0] ) {
                    477:                get_rootdir(prevdir,sizeof(prevdir),errmsg);
                    478:                strcat(prevdir,"\\lib");
                    479:        }
                    480:
                    481:        _chdir(prevdir);
1.1       noro      482:        CFileDialog     fileDialog(TRUE);
1.14      noro      483:        fileDialog.m_ofn.lpstrInitialDir = prevdir;
1.1       noro      484:        if ( fileDialog.DoModal() == IDOK ) {
                    485:                CString pathName = fileDialog.GetPathName();
                    486:                sprintf(cmd,"load(\"%s\");",pathName);
                    487:                for ( p = cmd; *p; p++ )
                    488:                        if ( *p == '\\' )
                    489:                                *p = '/';
                    490:                put_line(cmd);
1.20      ohara     491:                strcpy(cmd,pathName);
                    492:                p = strrchr(cmd,'\\');
1.3       noro      493:                if ( p ) {
                    494:                        *p = 0;
1.20      ohara     495:                        strcpy(prevdir,cmd);
1.3       noro      496:                }
1.1       noro      497:        }
                    498: }
1.21      ohara     499: void CAsir32guiView::viewHtmlHelp(char *help)
                    500: {
1.23      ohara     501:        char *helpfile;
                    502:        char fmt[] = "%s\\help\\%shelp.chm";
                    503:        char root[BUFSIZ],errmsg[BUFSIZ];
                    504:        get_rootdir(root,sizeof(root),errmsg);
                    505:        helpfile = (char *)malloc(sizeof(fmt) + strlen(root) + strlen(help));
                    506:        sprintf(helpfile,fmt,root,help);
1.21      ohara     507: #if _MSC_VER < 1300
                    508:     /* Visual C++ 6.0 */
                    509:        ::HtmlHelp(NULL, helpfile, HH_DISPLAY_TOPIC, 0);
1.23      ohara     510: #else
                    511:        CWinApp *top = AfxGetApp();
                    512:        top->SetHelpMode(AFX_HELP_TYPE::afxHTMLHelp);
                    513:        if (top->m_pszHelpFilePath) {
                    514:                free((void*)top->m_pszHelpFilePath);
                    515:        }
                    516:        top->m_pszHelpFilePath = helpfile;
                    517:        HtmlHelp(HH_DISPLAY_TOPIC, 0);
1.21      ohara     518: #endif
                    519: }
1.1       noro      520:
                    521: void CAsir32guiView::OnAsirhelp()
                    522: {
                    523:        // TODO: この位置にコマンド ハンドラ用のコードを追加してください
1.21      ohara     524:        viewHtmlHelp("asir");
1.1       noro      525: }
                    526:
                    527: void CAsir32guiView::OnFileLog()
                    528: {
                    529:        // TODO: この位置にコマンド ハンドラ用のコードを追加してください
                    530:        if ( !Logging ) {
                    531:                CFileDialog     fileDialog(TRUE);
                    532:                if ( fileDialog.DoModal() == IDOK ) {
                    533:                        CString logfile = fileDialog.GetPathName();
                    534:                        Logfp = fopen(logfile,"ab");
                    535:                        if ( Logfp ) {
                    536:                                LogStart = GetWindowTextLength();
                    537:                                Logging = 1;
                    538:                        }
                    539:                }
                    540:        } else {
                    541:                const char *buf;
                    542:                buf = LockBuffer();
                    543:                fwrite(buf+LogStart,1,strlen(buf)-LogStart,Logfp);
                    544:                UnlockBuffer();
                    545:                fclose(Logfp);
                    546:                Logging = 0;
                    547:        }
                    548: }
                    549:
                    550: void CAsir32guiView::OnUpdateFileLog(CCmdUI* pCmdUI)
                    551: {
                    552:        // TODO: この位置に command update UI ハンドラ用のコードを追加してください
                    553:        if ( Logging )
                    554:                pCmdUI->SetCheck(1);
                    555:        else
                    556:                pCmdUI->SetCheck(0);
                    557: }
                    558:
                    559: void CAsir32guiView::OnEditPaste()
                    560: {
                    561:        // TODO: この位置にコマンド ハンドラ用のコードを追加してください
                    562:     Paste();
1.3       noro      563: }
                    564:
1.9       noro      565: void CAsir32guiView::UpdateMetrics()
                    566: {
                    567:    TEXTMETRIC tm;
                    568:    RECT r;
                    569:
                    570:    GetEditCtrl().GetRect(&r);
                    571:    CDC *pDC = GetDC();
                    572:    pDC->SelectObject(GetFont());
                    573:    pDC->GetTextMetrics(&tm);
                    574:    MaxLineLength = (r.right-r.left)/tm.tmAveCharWidth-1;
                    575: }
                    576:
1.3       noro      577: void CAsir32guiView::OnFont()
                    578: {
                    579:        // TODO: この位置にコマンド ハンドラ用のコードを追加してください
1.26    ! ohara     580:        INT_PTR ret;
1.9       noro      581:        LOGFONT lf;
                    582:
                    583:        GetFont()->GetLogFont(&lf);
                    584:        CFontDialog fd(&lf,CF_EFFECTS | CF_SCREENFONTS | CF_FIXEDPITCHONLY);
1.3       noro      585:        static CFont *f = 0;
                    586:
                    587:        ret = fd.DoModal();
                    588:        if ( ret == IDOK ) {
                    589:                fd.GetCurrentFont(&lf);
                    590:                if ( f )
                    591:                        delete f;
                    592:                f = new CFont;
                    593:                f->CreateFontIndirect(&lf);
                    594:                SetFont(f);
1.9       noro      595:                UpdateMetrics();
1.3       noro      596:        }
                    597: }
                    598:
                    599: int CAsir32guiView::OnCreate(LPCREATESTRUCT lpCreateStruct)
                    600: {
                    601:        if (CEditView::OnCreate(lpCreateStruct) == -1)
                    602:                return -1;
                    603:
                    604:        // TODO: この位置に固有の作成用コードを追加してください
1.9       noro      605:
1.3       noro      606:        LOGFONT logFont; memset(&logFont, 0, sizeof(LOGFONT));
                    607:        logFont.lfHeight = 20;
                    608:        logFont.lfCharSet = DEFAULT_CHARSET;
                    609:        strcpy(logFont.lfFaceName, "Terminal");
                    610:        CFont *f = new CFont;
                    611:        f->CreateFontIndirect(&logFont);
                    612:        SetFont(f);
1.9       noro      613:        UpdateMetrics();
1.3       noro      614:        GetEditCtrl().LimitText(nMaxSize);
1.9       noro      615:        GetEditCtrl().SetTabStops(m_nTabStops);
1.3       noro      616:
                    617:        return 0;
1.6       noro      618: }
                    619:
                    620: void CAsir32guiView::OnContribhelp()
                    621: {
                    622:        // TODO: この位置にコマンド ハンドラ用のコードを追加してください
1.21      ohara     623:        viewHtmlHelp("cman");
1.6       noro      624: }
                    625:
1.11      noro      626: void CAsir32guiView::OnSize(UINT nType, int cx, int cy)
                    627: {
                    628:        CEditView::OnSize(nType, cx, cy);
                    629:
                    630:        // TODO: この位置にメッセージ ハンドラ用のコードを追加してください
                    631:        UpdateMetrics();
                    632: }
                    633:
                    634: void CAsir32guiView::OnDsolv()
                    635: {
                    636:        // TODO: この位置にコマンド ハンドラ用のコードを追加してください
1.21      ohara     637:        viewHtmlHelp("dsolv");
1.11      noro      638: }
                    639:
                    640: void CAsir32guiView::OnGnuplot()
                    641: {
                    642:        // TODO: この位置にコマンド ハンドラ用のコードを追加してください
1.21      ohara     643:        viewHtmlHelp("gnuplot");
1.11      noro      644: }
                    645:
                    646: void CAsir32guiView::OnOkdiff()
                    647: {
                    648:        // TODO: この位置にコマンド ハンドラ用のコードを追加してください
1.21      ohara     649:        viewHtmlHelp("ok_diff");
1.11      noro      650: }
                    651:
                    652: void CAsir32guiView::OnOkdmodule()
                    653: {
                    654:        // TODO: この位置にコマンド ハンドラ用のコードを追加してください
1.21      ohara     655:        viewHtmlHelp("ok_dmodule");
1.11      noro      656: }
                    657:
                    658: void CAsir32guiView::OnOm()
                    659: {
                    660:        // TODO: この位置にコマンド ハンドラ用のコードを追加してください
1.21      ohara     661:        viewHtmlHelp("om");
1.11      noro      662: }
                    663:
                    664: void CAsir32guiView::OnPfpcoh()
                    665: {
                    666:        // TODO: この位置にコマンド ハンドラ用のコードを追加してください
1.21      ohara     667:        viewHtmlHelp("pfpcoh");
1.11      noro      668: }
                    669:
                    670: void CAsir32guiView::OnPlucker()
                    671: {
                    672:        // TODO: この位置にコマンド ハンドラ用のコードを追加してください
1.21      ohara     673:        viewHtmlHelp("plucker");
1.11      noro      674: }
                    675:
                    676: void CAsir32guiView::OnSm1()
                    677: {
                    678:        // TODO: この位置にコマンド ハンドラ用のコードを追加してください
1.21      ohara     679:        viewHtmlHelp("sm1");
1.11      noro      680: }
                    681:
                    682: void CAsir32guiView::OnTigers()
1.6       noro      683: {
1.11      noro      684:        // TODO: この位置にコマンド ハンドラ用のコードを追加してください
1.21      ohara     685:        viewHtmlHelp("tigers");
1.9       noro      686: }
                    687:
1.11      noro      688: void CAsir32guiView::OnTodoparametrize()
1.9       noro      689: {
1.11      noro      690:        // TODO: この位置にコマンド ハンドラ用のコードを追加してください
1.21      ohara     691:        viewHtmlHelp("todo_parametrize");
1.1       noro      692: }
1.16      noro      693:
1.24      noro      694: void CAsir32guiView::OnNoromatrix()
                    695: {
                    696:        // TODO: この位置にコマンド ハンドラ用のコードを追加してください
                    697:        viewHtmlHelp("noro_matrix");
                    698: }
                    699:
                    700: void CAsir32guiView::OnNoromwl()
                    701: {
                    702:        // TODO: この位置にコマンド ハンドラ用のコードを追加してください
                    703:        viewHtmlHelp("noro_mwl");
                    704: }
                    705:
1.25      noro      706: void CAsir32guiView::OnNoropd()
                    707: {
                    708:        // TODO: この位置にコマンド ハンドラ用のコードを追加してください
                    709:        viewHtmlHelp("noro_pd");
                    710: }
                    711:
1.24      noro      712: void CAsir32guiView::OnNnndbf()
                    713: {
                    714:        // TODO: この位置にコマンド ハンドラ用のコードを追加してください
                    715:        viewHtmlHelp("nn_ndbf");
                    716: }
                    717:
1.25      noro      718: void CAsir32guiView::OnNstwistedlog()
                    719: {
                    720:        // TODO: この位置にコマンド ハンドラ用のコードを追加してください
                    721:        viewHtmlHelp("ns_twistedlog");
                    722: }
                    723:
1.16      noro      724: BOOL CAsir32guiView::Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext)
                    725: {
                    726:        // TODO: この位置に固有の処理を追加するか、または基本クラスを呼び出してください
                    727:
                    728:        BOOL ret = CWnd::Create(lpszClassName, lpszWindowName, dwStyle, rect, pParentWnd, nID, pContext);
1.26    ! ohara     729:        FILE *fp = NULL;
1.17      noro      730:        char *temp;
1.26    ! ohara     731:        char rootdir[BUFSIZ], errmsg[BUFSIZ], hndname[_MAX_PATH];
1.17      noro      732:
1.26    ! ohara     733:        if (get_rootdir(rootdir, BUFSIZ, errmsg)) {
        !           734:                sprintf(hndname, "%s\\bin\\asirgui.hnd", rootdir);
        !           735:                fp = fopen(hndname,"w");
        !           736:        }
1.18      noro      737:        if ( fp ) {
1.17      noro      738:                fprintf(fp,"%d",(unsigned int)theView->m_hWnd);
                    739:                fclose(fp);
1.18      noro      740:                if ( temp = getenv("TEMP") ) {
1.26    ! ohara     741:                        size_t len;
1.18      noro      742:                        char *name;
                    743:
                    744:                        len = strlen(temp);
                    745:                        name = (char *)malloc(len+BUFSIZ);
                    746:                        sprintf(name,"%s\\asirgui.hnd",temp);
                    747:                        fopen(name,"w");
                    748:                        fprintf(fp,"%d",(unsigned int)theView->m_hWnd);
                    749:                        fclose(fp);
                    750:                }
1.17      noro      751:        }
1.16      noro      752:        return ret;
                    753: }

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