a99  V32.6
allegro Windows Hauptprogramm
 Alle Klassen Dateien Funktionen Variablen Typdefinitionen Aufzählungen Aufzählungswerte Makrodefinitionen
ariched.cpp
gehe zur Dokumentation dieser Datei
1 // RichEditCtrl.cpp : implementation file
2 // 2000
3 // Copyright 2011 Universitätsbibliothek Braunschweig, more see bottom
4 
5 
6 #include "stdafx.h"
7 #include "ca99.h"
8 #include "a99.h"
9 #include "winx.h"
10 #include "ariched.h"
11 #include "program.h"
12 
13 // #define ND2
14 
15 #ifdef _DEBUG
16 #define new DEBUG_NEW
17 #undef THIS_FILE
18 static char THIS_FILE[] = __FILE__;
19 #endif
20 
21 extern a99 *dlg;
22 /////////////////////////////////////////////////////////////////////////////
23 // CaRichEditCtrl
24 
26 {
27  B=0;
28  clkmd=1;
29 }
30 
32 {
33 }
34 
35 BEGIN_MESSAGE_MAP(CaRichEditCtrl, CRichEditCtrl)
36  //{{AFX_MSG_MAP(CaRichEditCtrl)
37  ON_WM_CHAR()
38  ON_WM_KEYDOWN()
39  ON_WM_CONTEXTMENU()
40  ON_WM_RBUTTONDOWN()
41  ON_WM_LBUTTONDBLCLK()
42  ON_COMMAND(IDM_CUT,OnCut)
43  ON_COMMAND(IDM_PASTE,OnPaste)
44  ON_COMMAND(IDM_COPY,OnCopy)
45  ON_COMMAND(IDM_SALL,OnSall)
46  ON_COMMAND(ID_M320,OnLastHelp)
47  ON_COMMAND(ID_DISPSIZE,OnDisp)
48  ON_COMMAND(IDM_BOLD,OnBold)
49  ON_COMMAND(IDM_BUTTON4,OnResets)
50  ON_COMMAND(IDM_ITAL,OnItal)
51  ON_COMMAND(IDM_UNDL,OnUndl)
52  ON_COMMAND(IDM_FLIP,OnFlip)
53  ON_COMMAND(IDM_BLU,OnBlu)
54  ON_COMMAND(IDM_GRE,OnGre)
55  ON_COMMAND(IDM_RED,OnRed)
56  ON_COMMAND(IDM_COL,OnCol)
57  ON_COMMAND(IDM_FONT,OnFont)
58 #ifdef A99
59  ON_COMMAND(ID_MPRINT,OnM261p)
60  ON_COMMAND(ID_MSAVE,OnM258s)
61  ON_COMMAND(ID_MEXTRA,OnExtra)
62 #endif
63  //}}AFX_MSG_MAP
64 END_MESSAGE_MAP()
65 
66 /////////////////////////////////////////////////////////////////////////////
67 // CaRichEditCtrl message handlers
68 
69 int isc;
70 
71 
72 #ifdef A99
74 {
75  dlg->OnM258m();
76 }
77 
79 {
80  dlg->OnPrint();
81 }
82 
84 {
85  dlg->FLEXecute("X onprop");
86 }
87 
88 #endif
89 
90 void CaRichEditCtrl::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
91 {
92  int i=nChar; int j=EOF; CHAR *p;
93  extern int Esc; // default: 92
94 if(i==27) return;
95  if(i<27) j=UtPfind(i);
96  if(i==Esc) { if(!isc) { isc=1; return; } else isc=0; }
97  if(i>27 && isc==1)
98  {
99  if(i=='0') { CHAR w[24]; SyTime(w); UtPinst(w,48); }
100  j=UtPfind(i);
101  }
102  isc=0;
103  if(j!=EOF)
104  {
105  p=pa[j];
106  if(tolower((char)*p)=='x' && p[1]==' ') dlg->FLEXecute((char *)p);
107  else while(*p) SendMessage(WM_CHAR, *p++);
108  }
109  else CRichEditCtrl::OnChar(nChar, nRepCnt, nFlags);
110 
111 }
112 
113 void CaRichEditCtrl::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
114 {
115  extern long ecA; // for OnHotlink() in a99.cpp
116 
117 if(nChar==27) return;
118  ecA=-1L; // to prevent Flip from cursor movement
119  if(nChar>112 && nChar<124)
120 {
121  extern char fowi;
122  fowi=4;
123  GetParent()->PostMessage(WM_GOODBYE, 31, nChar);
124  return;
125 }
126  // 33=PgUp, 34=PgDn, 35=End, 36=HOME, 37=LEFT, 113=F2...
127  CRichEditCtrl::OnChar(nChar, nRepCnt, nFlags);
128 }
129 
130 void CaRichEditCtrl::OnContextMenu(CWnd* pWnd, CPoint point)
131 {
132 /*
133  CMenu menu;
134  menu.LoadMenu(IDR_MENU2);
135  menu.GetSubMenu(0)->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y,this);
136 */
137 }
138 void CaRichEditCtrl::OnRButtonDown(UINT nFlags, CPoint point)
139 {
140  WINDOWPLACEMENT mwpl;
141 
142  dlg->GetWindowPlacement(&mwpl);
143  int p,q,r,b;
144  p=mwpl.rcNormalPosition.left;
145  r=mwpl.rcNormalPosition.right;
146  q=mwpl.rcNormalPosition.top;
147  b=mwpl.rcNormalPosition.bottom;
148 
149 extern char Dfs;
150 if(Dfs!='n') q=q*0.8; else p=p+100;
151  CMenu menu, *menus;
152  menu.LoadMenu(IDR_MENU2);
153  menus=menu.GetSubMenu(0);
154  menus->ModifyMenu(IDM_CUT,MF_BYCOMMAND,IDM_CUT,uif[303]);
155  menus->ModifyMenu(IDM_COPY,MF_BYCOMMAND,IDM_COPY,uif[310]);
156  menus->ModifyMenu(IDM_PASTE,MF_BYCOMMAND,IDM_PASTE,uif[304]);
157  menus->ModifyMenu(IDM_SALL,MF_BYCOMMAND,IDM_SALL,uif[301]);
158  menus->ModifyMenu(ID_M320,MF_BYCOMMAND,ID_M320,uif[320]);
159  menus->ModifyMenu(ID_DISPSIZE,MF_BYCOMMAND,ID_DISPSIZE,uif[151]);
160  menus->ModifyMenu(IDM_BOLD,MF_BYCOMMAND,IDM_BOLD,uif[152]);
161  menus->ModifyMenu(IDM_ITAL,MF_BYCOMMAND,IDM_ITAL,uif[153]);
162  menus->ModifyMenu(IDM_UNDL,MF_BYCOMMAND,IDM_UNDL,uif[154]);
163  menus->ModifyMenu(IDM_FONT,MF_BYCOMMAND,IDM_FONT,uif[155]);
164  menus->ModifyMenu(8,MF_BYPOSITION,0,uif[155]);
165  menus->ModifyMenu(IDM_BLU,MF_BYCOMMAND,IDM_BLU,uif[157]);
166  menus->ModifyMenu(IDM_GRE,MF_BYCOMMAND,IDM_GRE,uif[158]);
167  menus->ModifyMenu(IDM_RED,MF_BYCOMMAND,IDM_RED,uif[159]);
168  menus->ModifyMenu(9,MF_BYPOSITION,0,uif[160]);
169  menus->ModifyMenu(IDM_COL,MF_BYCOMMAND,IDM_COL,uif[160]);
170  menus->ModifyMenu(IDM_FLIP,MF_BYCOMMAND,IDM_FLIP,uif[161]);
171  menus->ModifyMenu(IDM_BUTTON4,MF_BYCOMMAND,IDM_BUTTON4,uif[472]);
172 #ifdef A99
173  menus->ModifyMenu(ID_MPRINT,MF_BYCOMMAND,ID_MPRINT,uif[261]);
174  menus->ModifyMenu(ID_MSAVE,MF_BYCOMMAND,ID_MSAVE,uif[258]);
175  menus->ModifyMenu(ID_MEXTRA,MF_BYCOMMAND,ID_MEXTRA,uif[162]);
176 #endif
177  menus->TrackPopupMenu(TPM_LEFTBUTTON, point.x+p, point.y+q,this);
178  menu.DestroyMenu();
179 }
180 
181 
182 void CaRichEditCtrl::movewin(int cx,int cy)
183 {
184 extern int wihi, wiwi;
185 int wh=wihi,ww=wiwi;
186 if(!B) // Nur beim ersten Mal: Position feststellen
187 {
188  WINDOWPLACEMENT pl;
189  GetWindowPlacement(&pl);
190  L=L0=pl.rcNormalPosition.left;
191  R=pl.rcNormalPosition.right;
192  T=pl.rcNormalPosition.top;
193  B=B0=pl.rcNormalPosition.bottom;
194 // sprintf(Aerror,"eL=%d,eR=%d,eT=%d,eB=%d",L,R,T,B); MessageBox(Aerror);
195 }
196 #ifdef ND2
197  MoveWindow(L*cx/ww,22,((R-L)*cx)/ww,((B-T)*cy)/wh);
198 #else
199  MoveWindow(L*cx/ww,T*cy/wh,((R-L)*cx)/ww,((B-T)*cy)/wh);
200 #endif
201  Ln=L0*cx/ww;
202  Ba=B0*cy/wh;
203 
204 }
205 
207 {
208  Cut();
209 }
211 {
212  if(CanPaste()) Paste();
213 }
215 {
216  Copy();
217 }
219 {
220  SetSel(0,65535);
221 }
222 
224 {
225  CF.cbSize=sizeof(CHARFORMAT);
226  GetSelectionCharFormat(CF);
227  CF.dwMask=CF.dwMask|CFM_BOLD;
228  if(CF.dwEffects&CFE_BOLD) CF.dwEffects=CF.dwEffects-CFE_BOLD;
229  else CF.dwEffects=CF.dwEffects|CFE_BOLD;
230  SetSelectionCharFormat(CF);
231 }
232 
234 {
235  CF.cbSize=sizeof(CHARFORMAT);
236  GetSelectionCharFormat(CF);
237  CF.dwMask=CF.dwMask|CFM_ITALIC;
238  if(CF.dwEffects&CFE_ITALIC) CF.dwEffects=CF.dwEffects-CFE_ITALIC;
239  else CF.dwEffects=CF.dwEffects|CFE_ITALIC;
240  SetSelectionCharFormat(CF);
241 }
242 
244 {
245  CF.cbSize=sizeof(CHARFORMAT);
246  GetSelectionCharFormat(CF);
247  CF.dwMask=CF.dwMask|CFM_UNDERLINE;
248  if(CF.dwEffects&CFE_UNDERLINE) CF.dwEffects=CF.dwEffects-CFE_UNDERLINE;
249  else CF.dwEffects=CF.dwEffects|CFE_UNDERLINE;
250  SetSelectionCharFormat(CF);
251 }
252 
254 {
255  char sel[255];
256  long start,end,len;
257  *sel='`';
258  GetSel(start,end);
259  if(start==end) return;
260  GetSelText(sel+1);
261  strcat(sel,"`");
262  ReplaceSel(sel,TRUE);
263  SetSel(++start,++end);
264  CF.cbSize=sizeof(CHARFORMAT);
265  GetSelectionCharFormat(CF);
266  CF.dwMask=CF.dwMask|CFM_UNDERLINE|CFM_COLOR;
267  CF.dwEffects=CFE_UNDERLINE|CFE_BOLD;
268  CF.crTextColor=0x00ff0000;
269  SetSelectionCharFormat(CF);
270  len=GetTextLength();
271  SetSel(len,len);
272  *sel='?'; sel[strlen(sel)-1]='=';
273  ReplaceSel(sel);
274 }
275 
277 {
278  CF.cbSize=sizeof(CHARFORMAT);
279  GetSelectionCharFormat(CF);
280  CF.dwMask=CF.dwMask|CFM_COLOR;
281  CF.dwEffects=0;
282  CF.crTextColor=0x00ff0000;
283  SetSelectionCharFormat(CF);
284 }
285 
287 {
288  CF.cbSize=sizeof(CHARFORMAT);
289  GetSelectionCharFormat(CF);
290  CF.dwMask=CF.dwMask|CFM_COLOR;
291  CF.dwEffects=0;
292  CF.crTextColor=0x0000b000;
293  SetSelectionCharFormat(CF);
294 }
295 
297 {
298  CF.cbSize=sizeof(CHARFORMAT);
299  GetSelectionCharFormat(CF);
300  CF.dwMask=CF.dwMask|CFM_COLOR;
301  CF.dwEffects=0;
302  CF.crTextColor=0x000000ff;
303  SetSelectionCharFormat(CF);
304 }
305 
307 {
308 
309  CF.cbSize=sizeof(CHARFORMAT);
310  GetSelectionCharFormat(CF);
311  CColorDialog *CD=new CColorDialog();
312 
313  if(CD->DoModal()!=IDOK) return;
314 
315 
316  CF.dwMask=CF.dwMask|CFM_COLOR;
317  CF.dwEffects=0;
318  CF.crTextColor=CD->GetColor();
319  SetSelectionCharFormat(CF);
320 }
321 
323 {
324  LOGFONT lplf;
325  CF.cbSize=sizeof(CHARFORMAT);
326  GetSelectionCharFormat(CF);
327  CFontDialog *cfn = new CFontDialog();
328 
329  if(cfn->DoModal()!=IDOK) return;
330  cfn->GetCurrentFont( &lplf );
331 
332  CF.bCharSet=lplf.lfCharSet;
333  CF.yHeight=lplf.lfHeight;
334  CF.bPitchAndFamily=lplf.lfPitchAndFamily;
335  strcpy(CF.szFaceName,lplf.lfFaceName);
336  SetSelectionCharFormat(CF);
337 
338  delete cfn;
339  return;
340 }
341 
343 {
344  dlg->OnM320();
345 }
346 
348 {
349  dlg->OnButton4();
350 }
351 
353 {
354  dlg->DispField('0');
355 }
356 
357 // Doppelklick ausblenden, sonst Flip-Probleme
358 void CaRichEditCtrl::OnLButtonDblClk(UINT nFlags, CPoint point )
359 {
360  return;
361 }
362 
363 /*
364  Copyright 2011 Universitätsbibliothek Braunschweig
365 
366  Licensed under the Apache License, Version 2.0 (the "License");
367  you may not use this file except in compliance with the License.
368  You may obtain a copy of the License at
369 
370  http://www.apache.org/licenses/LICENSE-2.0
371 
372  Unless required by applicable law or agreed to in writing, software
373  distributed under the License is distributed on an "AS IS" BASIS,
374  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
375  See the License for the specific language governing permissions and
376  limitations under the License.
377 */
378