a99  V32.6
allegro Windows Hauptprogramm
 Alle Klassen Dateien Funktionen Variablen Typdefinitionen Aufzählungen Aufzählungswerte Makrodefinitionen
subfield.cpp
gehe zur Dokumentation dieser Datei
1 // subfield.cpp : Editfenster fuer Unterfelder eines Felds
2 // 19980120 : '²' fuer Subfield Code (p .31 178 in o.apt)
3 // Copyright 2011 Universitätsbibliothek Braunschweig, more see bottom
4 
5 #include "stdafx.h"
6 #include "ca99.h"
7 #include "a99.h"
8 #include "subfield.h"
9 
10 #ifdef _DEBUG
11 #define new DEBUG_NEW
12 #undef THIS_FILE
13 static char THIS_FILE[] = __FILE__;
14 #endif
15 
16 char ASF[3000]; // temporary store for subfield contents
17 int sc; // subfield code
18 
19 
20 
21 subField::subField(int SF , CWnd* pParent /* =0 */)
22  : CDialog(subField::IDD, pParent)
23 {
24 // subField dialog
25  sc=SF;
26  //{{AFX_DATA_INIT(subField)
27  //}}AFX_DATA_INIT
28 }
29 
31 char *Lab;
32 char *Tag;
33 
34 
35 int subField::DoModal(CHAR *Ka, CHAR *fld, char *tag, char *lab)
36 {
37 // prepare the listbox, *fld is optional!
38  int i;
39  Fld=fld;
40  Lab=lab;
41  Tag=tag;
42  nsf=0; // init the listbox
43  focn=0;
44  if(fld)
45  while(*fld)
46  {
47  i=0;
48  ASF[i++]=*fld++;
49  ASF[i++]=*fld++;
50  if(fld[-2]==sc) ASF[i++]=' ';
51  while(*fld && *fld!=sc) ASF[i++]=*fld++;
52  ASF[i]=0;
53  asf[nsf]=ASF;
54  ++nsf;
55  }
56  if(*Ka)
57  {
58  if(!nsf) asf[nsf++]=uif[457]; // strcpy(asf[nsf++],uif[457]);
59  while(*Ka)
60 // sprintf((char *)asf[nsf++],"%c%c %c",sc,*Ka++,0);
61  { sprintf(ASF,"%c%c%c",sc,*Ka++,0); asf[nsf++]=ASF; }
62  }
63 
64  // strcpy(KA,(char *)Ka);
65  return CDialog::DoModal();
66 }
67 
68 void subField::DoDataExchange(CDataExchange* pDX)
69 {
71  //{{AFX_DATA_MAP(subField)
72  DDX_Control(pDX, IDC_HOTKEY1, m_finish);
73  DDX_Control(pDX, IDC_subinfo, m_subinfo);
74  DDX_Control(pDX, IDC_EDIT_SUB, m_esub);
75  DDX_Control(pDX, IDC_LIST_SUB, m_subf);
76  //}}AFX_DATA_MAP
77 }
78 
79 
80 BEGIN_MESSAGE_MAP(subField, CDialog)
81  //{{AFX_MSG_MAP(subField)
82  ON_LBN_SETFOCUS(IDC_LIST_SUB, OnSetfocusListSub)
83  ON_BN_CLICKED(IDOK, OnSubOK)
84  ON_BN_CLICKED(IDC_HOTKEY1, OnReady)
85  ON_BN_CLICKED(IDC_SH, OnSh)
86  ON_WM_HELPINFO()
87  //}}AFX_MSG_MAP
88 END_MESSAGE_MAP()
89 
90 /////////////////////////////////////////////////////////////////////////////
91 // subField message handlers
92 
93 int subField::DoModal()
94 {
95  // TODO: Add your specialized code here and/or call the base class
96 
97  return CDialog::DoModal();
98 }
99 
101 {
102  int e=0;
103  char la[50];
104  focs=1;
105  m_finish.SetWindowText(uif[455]); // "Fertig"
106  m_subf.ResetContent();
107  m_subinfo.SetWindowText(uif[456]);
108  while(e<nsf)
109  { // 42 characters per subf for listbox:
110  strncpy(la,LPCTSTR(asf[e++]),42); la[42]=0;
111  m_subf.AddString(la);
112  }
113  m_subf.SetCurSel(focn);
114 }
115 
117 {
118 // the real, hidden OK (Enter) button
119 
120  int i=0;
121  if(focs==1) // coming from listbox
122  {
123  int m=m_subf.GetCurSel();
124  if(m<0) OnReady(); // bottom was passed
125  focn=m+1; if(focn==nsf+1) focn=0;
126 
127  if(m==LB_ERR) return;
128  focs=2;
129  strcpy(ASF,LPCTSTR(asf[m]));
130  i=2;
131  while(ASF[i]==' ') ++i;
132  if(*ASF==sc) m_esub.SetWindowText(ASF+i);
133  else if(*ASF=='*') m_esub.SetWindowText("");
134  else m_esub.SetWindowText(LPCTSTR(ASF));
135  m_esub.SetFocus();
136  m_esub.SendMessage(WM_KEYDOWN,VK_END);
137  }
138  else // from input window: transfer input back to asf
139  {
140  CString cs;
141  int m=m_subf.GetCurSel();
142  focs=1;
143  m_esub.GetWindowText(cs);
144  if(asf[m][0]==sc) i=2;
145  else i=0;
146 // sprintf((char *)asf[m]+i,"%s",cs);
147  sprintf(ASF+i," %s",cs); asf[m]=ASF;
148  m_subf.SetFocus();
149  }
150 }
151 
153 {
154  // Field is finished, return to main dialog
155  // This is the visible OK button
156  int i=0;
157  if(focs==2) OnSubOK();
158  *Fld=0;
159  while(i<nsf)
160  {
161  if(asf[i][0]=='*') ; // *normal*
162  else if(asf[i][0]!=(char)sc) strcat(Fld,LPCTSTR(asf[i])); // $xabc
163  else if(asf[i][2] && (asf[i][2]!=' ' || asf[i][3]!=0))
164  { strncat((char *)Fld,LPCTSTR(asf[i]),2);
165  if(asf[i][2]==' ') strcat(Fld,LPCTSTR(asf[i])+3); // $x abc
166  else strcat(Fld,LPCTSTR(asf[i])+2); } // $xabc
167  ++i;
168  }
169  OnOK(); // the real OK function
170 }
171 
173 {
174  extern CFont *aFont;
176  if(aFont)
177  {
178  m_subf.SetFont(aFont);
179  m_esub.SetFont(aFont);
180  }
181 // SetWindowText(uif[359]); // a99 : Subfields
182  while(!isalnum(*Lab)) ++Lab;
183  SetWindowText(Lab);
184 
185  return TRUE; // return TRUE unless you set the focus to a control
186  // EXCEPTION: OCX Property Pages should return FALSE
187 }
188 
190 {
191  extern a99 *dlg; // main dialog
192 
193  char tag[10]; strncpy(tag+1,Tag,3); *tag='h'; tag[dlg->Cfg->tgl+2]=0;
194  if(!dlg->helpinfo(tag,"!")) dlg->helpinfo("sub","!");
195  SetFocus();
196 }
197 
198 BOOL subField::OnHelpInfo(HELPINFO* pHelpInfo)
199 {
200  // TODO: Add your message handler code here and/or call default
201 
202  return CDialog::OnHelpInfo(pHelpInfo);
203 }
204 
205 // for GetLongPathName, which Win'NT doesn't know
206 
207 int GetLongPName(CString strShortPath,
208  CString& strLongPath )
209 {
210  int iFound = strShortPath.ReverseFind('\\');
211  if (iFound > 1)
212  {
213  // recurse to peel off components
214  //
215  if (GetLongPName(strShortPath.Left(iFound),
216  strLongPath) > 0)
217  {
218  strLongPath += '\\';
219 
220  if (strShortPath.Right(1) != "\\")
221  {
222  WIN32_FIND_DATA findData;
223 
224  // append the long component name to the path
225  //
226  if (INVALID_HANDLE_VALUE != ::FindFirstFile
227  (strShortPath, &findData))
228  {
229  strLongPath += findData.cFileName;
230  }
231  else
232  {
233  // if FindFirstFile fails, return the error code
234  //
235  strLongPath.Empty();
236  return 0;
237  }
238  }
239  }
240  }
241  else
242  {
243  strLongPath = strShortPath;
244  }
245 
246  return strLongPath.GetLength();
247 }
248 
249 /*
250  Copyright 2011 Universitätsbibliothek Braunschweig
251 
252  Licensed under the Apache License, Version 2.0 (the "License");
253  you may not use this file except in compliance with the License.
254  You may obtain a copy of the License at
255 
256  http://www.apache.org/licenses/LICENSE-2.0
257 
258  Unless required by applicable law or agreed to in writing, software
259  distributed under the License is distributed on an "AS IS" BASIS,
260  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
261  See the License for the specific language governing permissions and
262  limitations under the License.
263 */
264