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