Annotation of OpenXM_contrib2/windows/engine2000/MainFrm.cpp, Revision 1.1.1.1
1.1 noro 1: // MainFrm.cpp : CMainFrame クラスの動作の定義を行います。
2: //
3:
4: #include "stdafx.h"
5: #include "ox_plot.h"
6:
7: #include "MainFrm.h"
8:
9: extern "C" {
10: #include "ca.h"
11: #include "ifplot.h"
12: }
13:
14: #ifdef _DEBUG
15: #define new DEBUG_NEW
16: #undef THIS_FILE
17: static char THIS_FILE[] = __FILE__;
18: #endif
19:
20: /////////////////////////////////////////////////////////////////////////////
21: // CMainFrame
22:
23: IMPLEMENT_DYNAMIC(CMainFrame, CFrameWnd)
24:
25: BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
26: //{{AFX_MSG_MAP(CMainFrame)
27: ON_WM_CREATE()
28: ON_WM_SETFOCUS()
29: ON_WM_CLOSE()
30: ON_COMMAND(ID_APP_EXIT, OnAppExit)
31: //}}AFX_MSG_MAP
32: ON_COMMAND(ID_FILE_PRINT, OnFilePrint)
33: ON_COMMAND(ID_FILE_PRINT_SETUP, OnFilePrintSetup)
34: ON_UPDATE_COMMAND_UI(ID_INDICATOR_PROGRESS,OnUpdateProgress)
35: END_MESSAGE_MAP()
36:
37: static UINT indicators[] =
38: {
39: ID_SEPARATOR, // ステータス ライン インジケータ
40: ID_INDICATOR_PROGRESS,
41: // ID_INDICATOR_KANA,
42: // ID_INDICATOR_CAPS,
43: // ID_INDICATOR_NUM,
44: // ID_INDICATOR_SCRL,
45: };
46: /////////////////////////////////////////////////////////////////////////////
47: // CMainFrame クラスの構築/消滅
48:
49: CMainFrame::CMainFrame()
50: {
51: // TODO: この位置にメンバの初期化処理コードを追加してください。
52:
53: }
54:
55: CMainFrame::~CMainFrame()
56: {
57: }
58:
59: int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
60: {
61: if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
62: return -1;
63: // フレームのクライアント領域全体を占めるビューを作成します。
64: if (!m_wndView.Create(NULL, NULL, AFX_WS_DEFAULT_VIEW,
65: CRect(0, 0, 0, 0), this, AFX_IDW_PANE_FIRST, NULL))
66: {
67: TRACE0("Failed to create view window\n");
68: return -1;
69: }
70: if (!m_wndStatusBar.Create(this) ||
71: !m_wndStatusBar.SetIndicators(indicators,
72: sizeof(indicators)/sizeof(UINT)))
73: {
74: TRACE0("Failed to create status bar\n");
75: return -1; // 作成に失敗
76: }
77:
78: m_nProgress = 100;
79:
80: UINT nID,nStyle;
81: int cxWidth;
82:
83: m_wndStatusBar.GetPaneInfo(0,nID,nStyle,cxWidth);
84: cxWidth = 0;
85: m_wndStatusBar.SetPaneInfo(0,nID,nStyle,cxWidth);
86:
87: m_wndStatusBar.GetPaneInfo(1,nID,nStyle,cxWidth);
88: cxWidth = 150;
89: m_wndStatusBar.SetPaneInfo(1,nID,nStyle,cxWidth);
90:
91: return 0;
92: }
93:
94: BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
95: {
96: if( !CFrameWnd::PreCreateWindow(cs) )
97: return FALSE;
98: // TODO: この位置で CREATESTRUCT cs を修正して、Window クラスやスタイルを
99: // 修正してください。
100:
101: cs.dwExStyle &= ~WS_EX_CLIENTEDGE;
102: cs.lpszClass = AfxRegisterWndClass(0);
103: cs.lpszName = m_pWindowName;
104: cs.cx = m_cansize.cx+20; /* XXX */
105: cs.cy = m_cansize.cy+80; /* XXX */
106: return TRUE;
107: }
108:
109: /////////////////////////////////////////////////////////////////////////////
110: // CMainFrame クラスの診断
111:
112: #ifdef _DEBUG
113: void CMainFrame::AssertValid() const
114: {
115: CFrameWnd::AssertValid();
116: }
117:
118: void CMainFrame::Dump(CDumpContext& dc) const
119: {
120: CFrameWnd::Dump(dc);
121: }
122:
123: #endif //_DEBUG
124:
125: /////////////////////////////////////////////////////////////////////////////
126: // CMainFrame メッセージ ハンドラ
127: void CMainFrame::OnSetFocus(CWnd* pOldWnd)
128: {
129: // ビュー ウィンドウにフォーカスを与えます。
130: m_wndView.SetFocus();
131: }
132:
133: BOOL CMainFrame::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo)
134: {
135: // ビューに最初にコマンドを処理する機会を与えます。
136: if (m_wndView.OnCmdMsg(nID, nCode, pExtra, pHandlerInfo))
137: return TRUE;
138:
139: // 処理されなかった場合にはデフォルトの処理を行います。
140: return CFrameWnd::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo);
141: }
142:
143:
144: void CMainFrame::OnClose()
145: {
146: // TODO: この位置にメッセージ ハンドラ用のコードを追加するかまたはデフォルトの処理を呼び出してください
147: m_wndView.DestroyCanvas();
148: CFrameWnd::OnClose();
149: }
150:
151: void CMainFrame::OnAppExit()
152: {
153: // TODO: この位置にコマンド ハンドラ用のコードを追加してください
154: OnClose();
155: }
156:
157: void CMainFrame::OnUpdateProgress(CCmdUI *pCmdUI)
158: {
159: int mode;
160: CString strProgress;
161:
162: if ( !m_wndView.can )
163: return;
164: switch ( mode = m_wndView.can->mode ) {
165: case MODE_IFPLOT: case MODE_CONPLOT:
166: pCmdUI->Enable();
167: strProgress.Format("%s%d%%",m_wndView.can->prefix,m_wndView.can->percentage);
168: pCmdUI->SetText(strProgress);
169: break;
170: default:
171: break;
172: }
173: }
174:
175: void CMainFrame::OnFilePrintSetup()
176: {
177: theApp.OnFilePrintSetup();
178: }
179:
180: void CMainFrame::OnFilePrint()
181: {
182: CDC dc;
183: CPrintDialog pd(TRUE);
184: int ret;
185:
186: ret = theApp.DoPrintDialog(&pd);
187: if ( ret == IDOK ) {
188: theApp.CreatePrinterDC(dc);
189: m_wndView.OnPrint(dc);
190: }
191: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>