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

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

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