-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMainFrm.cpp
More file actions
290 lines (242 loc) · 8.33 KB
/
MainFrm.cpp
File metadata and controls
290 lines (242 loc) · 8.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
/*
* International Chemical Identifier (InChI)
* Version 1
* Software version 1.07
* April 30, 2024
*
* The InChI library and programs are free software developed under the
* auspices of the International Union of Pure and Applied Chemistry (IUPAC).
* Originally developed at NIST.
* Modifications and additions by IUPAC and the InChI Trust.
* Some portions of code were developed/changed by external contributors
* (either contractor or volunteer) which are listed in the file
* 'External-contributors' included in this distribution.
*
* IUPAC/InChI-Trust Licence No.1.0 for the
* International Chemical Identifier (InChI)
* Copyright (C) IUPAC and InChI Trust
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the IUPAC/InChI Trust InChI Licence No.1.0,
* or any later version.
*
* Please note that this library is distributed WITHOUT ANY WARRANTIES
* whatsoever, whether expressed or implied.
* See the IUPAC/InChI-Trust InChI Licence No.1.0 for more details.
*
* You should have received a copy of the IUPAC/InChI Trust InChI
* Licence No. 1.0 with this library; if not, please e-mail:
*
* info@inchi-trust.org
*
*/
// MainFrm.cpp : implementation of the CMainFrame class
//
#include "stdafx.h"
#include "wIChI.h"
#include "MainFrm.h"
#include "wIChIView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
void SetStatusText(LPCSTR Str)
{
CWnd * pWnd = AfxGetMainWnd();
if( pWnd && ::IsWindow( pWnd->GetSafeHwnd() ) )
pWnd->SendMessage( WM_APP + 1, 0, (LPARAM) Str );
}
/////////////////////////////////////////////////////////////////////////////
// CMainFrame
IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd)
BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
//{{AFX_MSG_MAP(CMainFrame)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code !
ON_WM_CREATE()
ON_MESSAGE(WM_APP + 1, OnDisplayStatus)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
static UINT indicators[] =
{
ID_SEPARATOR, // status line indicator
ID_INDICATOR_CAPS,
ID_INDICATOR_NUM,
ID_INDICATOR_SCRL,
};
/////////////////////////////////////////////////////////////////////////////
// CMainFrame construction/destruction
/////////////////////////////////////////////////////////////////////////////
CMainFrame::CMainFrame()
{
// TODO: add member initialization code here
}
/////////////////////////////////////////////////////////////////////////////
CMainFrame::~CMainFrame()
{
}
/////////////////////////////////////////////////////////////////////////////
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
return -1;
if( !m_wndDlgBar.Create(this,IDD_DIALOGBAR,CBRS_TOP|CBRS_TOOLTIPS,AFX_IDW_CONTROLBAR_FIRST ) )
{
TRACE0("Failed to create DlgBar\n");
return -1; // Fail to create.
}
CSpinButtonCtrl *pSpin = (CSpinButtonCtrl *)m_wndDlgBar.GetDlgItem(IDC_SPIN1);
pSpin->SetBuddy(m_wndDlgBar.GetDlgItem(IDC_EDIT_SPIN));
pSpin->SetRange(0,0);
m_wndDlgBar.CheckDlgButton(IDC_CHECK_TAUT,1);
if (!m_wndStatusBar.Create(this) ||
!m_wndStatusBar.SetIndicators(indicators,
sizeof(indicators)/sizeof(UINT)))
{
TRACE0("Failed to create status bar\n");
return -1; // fail to create
}
// TODO: Delete these three lines if you don't want the toolbar to
// be dockable
EnableDocking(CBRS_ALIGN_ANY);
#ifdef STD_WINCHI
SetTitle(_T("stdwInChI-1"));
#else
SetTitle(_T("wInChI v.1.07.4"));
#endif
return 0;
}
CFont Font;
/////////////////////////////////////////////////////////////////////////////
BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT /*lpcs*/,
CCreateContext* pContext)
{
CRect rect;
GetClientRect(&rect);
if( !m_wndSplitter.CreateStatic( this, 2, 1) )
return FALSE;
if( !m_wndSplitter.CreateView(0,0,RUNTIME_CLASS(CWINChIView), CSize(100,2*rect.Height()/3), pContext) )
return FALSE;
if( !m_wndSplitter.CreateView(1,0,RUNTIME_CLASS(CTextView), CSize(100,100), pContext) )
return FALSE;
LOGFONT MyLogFont;
memset( &MyLogFont, 0, sizeof( LOGFONT ) );
MyLogFont.lfHeight = -MulDiv(9, GetDC()->GetDeviceCaps(LOGPIXELSY), 72);
MyLogFont.lfWeight = FW_NORMAL;
strncpy( MyLogFont.lfFaceName, "Arial", LF_FACESIZE );
Font.CreateFontIndirect( &MyLogFont );
CEditView * pEditView = (CEditView *) m_wndSplitter.GetPane(1,0);
pEditView->SetFont(&Font);
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
if( !CFrameWnd::PreCreateWindow(cs) )
return FALSE;
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// CMainFrame diagnostics
#ifdef _DEBUG
/////////////////////////////////////////////////////////////////////////////
void CMainFrame::AssertValid() const
{
CFrameWnd::AssertValid();
}
void CMainFrame::Dump(CDumpContext& dc) const
{
CFrameWnd::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CMainFrame message handlers
LRESULT CMainFrame::OnDisplayStatus(WPARAM wParam, LPARAM lParam)
{
// AFX_IDS_IDLEMESSAGE
m_wndStatusBar.SetPaneText( 0, LPCTSTR( lParam ) );
return 0;
}
/////////////////////////////////////////////////////////////////////////////
void CMainFrame::ResetCtrls()
{
((CComboBox *) m_wndDlgBar.GetDlgItem(ID_COMPONENTS))->ResetContent();
SetRangeAndPos(0,0);
m_wndDlgBar.CheckRadioButton(IDC_RADIO_ORIGINAL,IDC_RADIO_RES,0);
m_wndDlgBar.GetDlgItem(IDC_STATIC_RESULTS)->SetWindowText("Result");
}
/////////////////////////////////////////////////////////////////////////////
BOOL CMainFrame::GetCtrlState( int& nComp, int& nRadio, int& nSet, BOOL& bTaut, BOOL& bMet, BOOL& bOriginal, BOOL& bNoEdits )
{
CComboBox *pCombo = (CComboBox *)m_wndDlgBar.GetDlgItem(ID_COMPONENTS);
CSpinButtonCtrl *pSpin = (CSpinButtonCtrl *)m_wndDlgBar.GetDlgItem(IDC_SPIN1);
nComp = pCombo->GetCurSel();
bOriginal = 0 == nComp;
if( nComp != CB_ERR )
nComp = pCombo->GetItemData(nComp);
bTaut = m_wndDlgBar.IsDlgButtonChecked(IDC_CHECK_TAUT) ? 1 : 0;
bMet = m_wndDlgBar.IsDlgButtonChecked(IDC_CHECK_REC) ? 1 : 0;
bNoEdits = m_wndDlgBar.IsDlgButtonChecked(IDC_CHECK_NOEDITS) ? 1 : 0;
nRadio = m_wndDlgBar.GetCheckedRadioButton(IDC_RADIO_ORIGINAL, IDC_RADIO_RES);
nSet = pSpin->GetPos();
return nComp != CB_ERR;
}
/////////////////////////////////////////////////////////////////////////////
void CMainFrame::SetComboFocus()
{
m_wndDlgBar.GetDlgItem(ID_COMPONENTS)->SetFocus();
}
/////////////////////////////////////////////////////////////////////////////
void CMainFrame::CheckRadio(UINT nID)
{
m_wndDlgBar.CheckRadioButton(IDC_RADIO_ORIGINAL,IDC_RADIO_RES,nID);
}
/////////////////////////////////////////////////////////////////////////////
void CMainFrame::SetRangeAndPos(int max, int pos )
{
CSpinButtonCtrl *pSpin = (CSpinButtonCtrl *)m_wndDlgBar.GetDlgItem(IDC_SPIN1);
pSpin->SetRange(0,max);
pSpin->SetPos(pos);
CWnd * pStat = m_wndDlgBar.GetDlgItem(IDC_STATIC_NSETS);
if( max == 0)
pStat->SetWindowText("No sets of");
else
{
CString Str = "1 set of";
if(max > 1 )
Str.Format("%d sets of",max);
pStat->SetWindowText(Str);
}
}
/////////////////////////////////////////////////////////////////////////////
void CMainFrame::InitCtrls(const CStringArray& ar, const CUIntArray& dat)
{
CComboBox *pCombo = (CComboBox *)m_wndDlgBar.GetDlgItem(ID_COMPONENTS);
ResetCtrls();
int sz = ar.GetSize();
if( sz )
{
if( sz == 1 )
{
m_wndDlgBar.GetDlgItem(IDC_STATIC_RESULTS)->SetWindowText("Result for one component");
pCombo->AddString(ar[0]);
pCombo->SetItemData(0,dat[0]);
}
else
{
CString str;
str.Format("Results for %d components",sz-1);
m_wndDlgBar.GetDlgItem(IDC_STATIC_RESULTS)->SetWindowText(str);
for( int i = 0; i < sz; i++ )
{
pCombo->AddString(ar[i]);
pCombo->SetItemData(i,dat[i]);
}
}
pCombo->SetCurSel(0);
}
}