remove empty dir
[reactos.git] / rosapps / dflat32 / memopad.c
1 /* --------------- memopad.c ----------- */
2
3 #include "dflat.h"
4
5 extern DF_DBOX PrintSetup;
6
7 char DFlatApplication[] = "MemoPad";
8
9 static char Untitled[] = "Untitled";
10 static int wndpos;
11
12 static int MemoPadProc(DFWINDOW, DFMESSAGE, DF_PARAM, DF_PARAM);
13 static void NewFile(DFWINDOW);
14 static void SelectFile(DFWINDOW);
15 static void PadWindow(DFWINDOW, char *);
16 static void OpenPadWindow(DFWINDOW, char *);
17 static void LoadFile(DFWINDOW);
18 static void PrintPad(DFWINDOW);
19 static void SaveFile(DFWINDOW, int);
20 static void MemoPadDeleteFile(DFWINDOW);
21 static int EditorProc(DFWINDOW, DFMESSAGE, DF_PARAM, DF_PARAM);
22 static char *NameComponent(char *);
23 static int PrintSetupProc(DFWINDOW, DFMESSAGE, DF_PARAM, DF_PARAM);
24 static void FixTabMenu(void);
25 #ifndef TURBOC
26 void Calendar(DFWINDOW);
27 #endif
28 //void BarChart(DFWINDOW);
29 char **Argv;
30
31 #define CHARSLINE 80
32 #define LINESPAGE 66
33
34 void main(int argc, char *argv[])
35 {
36 DFWINDOW wnd;
37 if (!init_messages())
38 return;
39 Argv = argv;
40 DfLoadConfig();
41 // if (!DfLoadConfig())
42 // DfCfg.ScreenLines = DF_SCREENHEIGHT;
43 wnd = DfDfCreateWindow(DF_APPLICATION,
44 "FreeDos Edit " DF_VERSION,
45 0, 0, -1, -1,
46 &DfMainMenu,
47 NULL,
48 MemoPadProc,
49 DF_MOVEABLE |
50 DF_SIZEABLE |
51 DF_HASBORDER |
52 DF_MINMAXBOX |
53 DF_HASSTATUSBAR
54 );
55
56 DfLoadHelpFile();
57 DfSendMessage(wnd, DFM_SETFOCUS, TRUE, 0);
58 while (argc > 1) {
59 PadWindow(wnd, argv[1]);
60 --argc;
61 argv++;
62 }
63 while (dispatch_message())
64 ;
65 }
66
67 /* ------ open text files and put them into editboxes ----- */
68 static void PadWindow(DFWINDOW wnd, char *FileName)
69 {
70 int ax;
71 struct _finddata_t ff;
72 char path[64];
73 char *cp;
74
75 DfCreatePath(path, FileName, FALSE, FALSE);
76 cp = path+strlen(path);
77 DfCreatePath(path, FileName, TRUE, FALSE);
78 ax = _findfirst(path, &ff);
79 if (ax == -1)
80 return;
81 do
82 {
83 strcpy(cp, ff.name);
84 OpenPadWindow(wnd, path);
85 }
86 while (_findnext (ax, &ff) == 0);
87 _findclose (ax);
88 }
89
90
91 /* ------- window processing module for the
92 memopad application window ----- */
93 static int MemoPadProc(DFWINDOW wnd,DFMESSAGE msg,DF_PARAM p1,DF_PARAM p2)
94 {
95 int rtn;
96 switch (msg) {
97 case DFM_CREATE_WINDOW:
98 rtn = DfDefaultWndProc(wnd, msg, p1, p2);
99 if (DfCfg.InsertMode)
100 DfSetCommandToggle(&DfMainMenu, DF_ID_INSERT);
101 if (DfCfg.WordWrap)
102 DfSetCommandToggle(&DfMainMenu, DF_ID_WRAP);
103 FixTabMenu();
104 return rtn;
105 case DFM_COMMAND:
106 switch ((int)p1) {
107 case DF_ID_NEW:
108 NewFile(wnd);
109 return TRUE;
110 case DF_ID_OPEN:
111 SelectFile(wnd);
112 return TRUE;
113 case DF_ID_SAVE:
114 SaveFile(DfInFocus, FALSE);
115 return TRUE;
116 case DF_ID_SAVEAS:
117 SaveFile(DfInFocus, TRUE);
118 return TRUE;
119 case DF_ID_DELETEFILE:
120 MemoPadDeleteFile(DfInFocus);
121 return TRUE;
122 case DF_ID_PRINTSETUP:
123 DfDialogBox(wnd, &PrintSetup, TRUE, PrintSetupProc);
124 return TRUE;
125 case DF_ID_PRINT:
126 PrintPad(DfInFocus);
127 return TRUE;
128 case DF_ID_EXIT:
129 if (!DfYesNoBox("Exit Memopad?"))
130 return FALSE;
131 break;
132 case DF_ID_WRAP:
133 DfCfg.WordWrap = DfGetCommandToggle(&DfMainMenu, DF_ID_WRAP);
134 return TRUE;
135 case DF_ID_INSERT:
136 DfCfg.InsertMode = DfGetCommandToggle(&DfMainMenu, DF_ID_INSERT);
137 return TRUE;
138 case DF_ID_TAB2:
139 DfCfg.Tabs = 2;
140 FixTabMenu();
141 return TRUE;
142 case DF_ID_TAB4:
143 DfCfg.Tabs = 4;
144 FixTabMenu();
145 return TRUE;
146 case DF_ID_TAB6:
147 DfCfg.Tabs = 6;
148 FixTabMenu();
149 return TRUE;
150 case DF_ID_TAB8:
151 DfCfg.Tabs = 8;
152 FixTabMenu();
153 return TRUE;
154 case DF_ID_CALENDAR:
155 #ifndef TURBOC
156 Calendar(wnd);
157 #endif
158 return TRUE;
159 // case DF_ID_BARCHART:
160 // BarChart(wnd);
161 // return TRUE;
162 case DF_ID_ABOUT:
163 DfMessageBox(
164 "About D-Flat and the MemoPad",
165 " ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿\n"
166 " ³ ÜÜÜ ÜÜÜ Ü ³\n"
167 " ³ Û Û Û Û Û ³\n"
168 " ³ Û Û Û Û Û ³\n"
169 " ³ Û Û Û Û Û Û ³\n"
170 " ³ ßßß ßßß ßß ³\n"
171 " ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ\n"
172 "D-Flat implements the SAA/CUA\n"
173 "interface in a public domain\n"
174 "C language library originally\n"
175 "published in Dr. Dobb's Journal\n"
176 " ------------------------ \n"
177 "MemoPad is a multiple document\n"
178 "editor that demonstrates D-Flat");
179 return TRUE;
180 default:
181 break;
182 }
183 break;
184 default:
185 break;
186 }
187 return DfDefaultWndProc(wnd, msg, p1, p2);
188 }
189 /* --- The New command. Open an empty editor window --- */
190 static void NewFile(DFWINDOW wnd)
191 {
192 OpenPadWindow(wnd, Untitled);
193 }
194 /* --- The Open... command. Select a file --- */
195 static void SelectFile(DFWINDOW wnd)
196 {
197 char FileName[64];
198 if (DfOpenFileDialogBox("*.PAD", FileName)) {
199 /* --- see if the document is already in a window --- */
200 DFWINDOW wnd1 = DfFirstWindow(wnd);
201 while (wnd1 != NULL) {
202 if (stricmp(FileName, wnd1->extension) == 0) {
203 DfSendMessage(wnd1, DFM_SETFOCUS, TRUE, 0);
204 DfSendMessage(wnd1, DFM_RESTORE, 0, 0);
205 return;
206 }
207 wnd1 = DfNextWindow(wnd1);
208 }
209 OpenPadWindow(wnd, FileName);
210 }
211 }
212
213 /* --- open a document window and load a file --- */
214 static void OpenPadWindow(DFWINDOW wnd, char *FileName)
215 {
216 static DFWINDOW wnd1 = NULL;
217 DFWINDOW wwnd;
218 struct stat sb;
219 char *Fname = FileName;
220 char *ermsg;
221 if (strcmp(FileName, Untitled)) {
222 if (stat(FileName, &sb)) {
223 ermsg = DfMalloc(strlen(FileName)+20);
224 strcpy(ermsg, "No such file as\n");
225 strcat(ermsg, FileName);
226 DfErrorMessage(ermsg);
227 free(ermsg);
228 return;
229 }
230 Fname = NameComponent(FileName);
231 }
232 wwnd = DfWatchIcon();
233 wndpos += 2;
234 if (wndpos == 20)
235 wndpos = 2;
236 wnd1 = DfDfCreateWindow(DF_EDITBOX,
237 Fname,
238 (wndpos-1)*2, wndpos, 10, 40,
239 NULL, wnd, EditorProc,
240 DF_SHADOW |
241 DF_MINMAXBOX |
242 DF_CONTROLBOX |
243 DF_VSCROLLBAR |
244 DF_HSCROLLBAR |
245 DF_MOVEABLE |
246 DF_HASBORDER |
247 DF_SIZEABLE |
248 DF_MULTILINE
249 );
250 if (strcmp(FileName, Untitled)) {
251 wnd1->extension = DfMalloc(strlen(FileName)+1);
252 strcpy(wnd1->extension, FileName);
253 LoadFile(wnd1);
254 }
255 DfSendMessage(wwnd, DFM_CLOSE_WINDOW, 0, 0);
256 DfSendMessage(wnd1, DFM_SETFOCUS, TRUE, 0);
257 DfSendMessage(wnd1, DFM_MAXIMIZE, 0, 0);
258 }
259
260 /* --- Load the notepad file into the editor text buffer --- */
261 static void LoadFile(DFWINDOW wnd)
262 {
263 char *Buf = NULL;
264 int recptr = 0;
265 FILE *fp;
266
267 if ((fp = fopen(wnd->extension, "rt")) != NULL) {
268 while (!feof(fp)) {
269 DfHandshake();
270 Buf = DfRealloc(Buf, recptr+150);
271 memset(Buf+recptr, 0, 150);
272 fgets(Buf+recptr, 150, fp);
273 recptr += strlen(Buf+recptr);
274 }
275 fclose(fp);
276 if (Buf != NULL) {
277 DfSendMessage(wnd, DFM_SETTEXT, (DF_PARAM) Buf, 0);
278 free(Buf);
279 }
280 }
281 }
282
283 static int LineCtr;
284 static int CharCtr;
285
286 /* ------- print a character -------- */
287 static void PrintChar(FILE *prn, int c)
288 {
289 int i;
290 if (c == '\n' || CharCtr == DfCfg.RightMargin) {
291 fputs("\r\n", prn);
292 LineCtr++;
293 if (LineCtr == DfCfg.BottomMargin) {
294 fputc('\f', prn);
295 for (i = 0; i < DfCfg.TopMargin; i++)
296 fputc('\n', prn);
297 LineCtr = DfCfg.TopMargin;
298 }
299 CharCtr = 0;
300 if (c == '\n')
301 return;
302 }
303 if (CharCtr == 0) {
304 for (i = 0; i < DfCfg.LeftMargin; i++) {
305 fputc(' ', prn);
306 CharCtr++;
307 }
308 }
309 CharCtr++;
310 fputc(c, prn);
311 }
312
313 /* --- print the current notepad --- */
314 static void PrintPad(DFWINDOW wnd)
315 {
316 if (*DfCfg.PrinterPort) {
317 FILE *prn;
318 if ((prn = fopen(DfCfg.PrinterPort, "wt")) != NULL) {
319 long percent;
320 BOOL KeepPrinting = TRUE;
321 unsigned char *text = DfGetText(wnd);
322 unsigned oldpct = 100, cct = 0, len = strlen(text);
323 DFWINDOW swnd = DfSliderBox(20, DfGetTitle(wnd), "Printing");
324 /* ------- print the notepad text --------- */
325 LineCtr = CharCtr = 0;
326 while (KeepPrinting && *text) {
327 PrintChar(prn, *text++);
328 percent = ((long) ++cct * 100) / len;
329 if ((int)percent != (int)oldpct) {
330 oldpct = (int) percent;
331 KeepPrinting = DfSendMessage(swnd, DFM_PAINT, 0, oldpct);
332 }
333 }
334 if (KeepPrinting)
335 /* ---- user did not cancel ---- */
336 if (oldpct < 100)
337 DfSendMessage(swnd, DFM_PAINT, 0, 100);
338 /* ------- follow with a form feed? --------- */
339 if (DfYesNoBox("Form Feed?"))
340 fputc('\f', prn);
341 fclose(prn);
342 }
343 else
344 DfErrorMessage("Cannot open printer file");
345 }
346 else
347 DfErrorMessage("No printer selected");
348 }
349
350 /* ---------- save a file to disk ------------ */
351 static void SaveFile(DFWINDOW wnd, int Saveas)
352 {
353 FILE *fp;
354 if (wnd->extension == NULL || Saveas) {
355 char FileName[64];
356 if (DfSaveAsDialogBox(FileName)) {
357 if (wnd->extension != NULL)
358 free(wnd->extension);
359 wnd->extension = DfMalloc(strlen(FileName)+1);
360 strcpy(wnd->extension, FileName);
361 DfAddTitle(wnd, NameComponent(FileName));
362 DfSendMessage(wnd, DFM_BORDER, 0, 0);
363 }
364 else
365 return;
366 }
367 if (wnd->extension != NULL) {
368 DFWINDOW mwnd = DfMomentaryMessage("Saving the file");
369 if ((fp = fopen(wnd->extension, "wt")) != NULL) {
370 fwrite(DfGetText(wnd), strlen(DfGetText(wnd)), 1, fp);
371 fclose(fp);
372 wnd->TextChanged = FALSE;
373 }
374 DfSendMessage(mwnd, DFM_CLOSE_WINDOW, 0, 0);
375 }
376 }
377 /* -------- delete a file ------------ */
378 static void MemoPadDeleteFile(DFWINDOW wnd)
379 {
380 if (wnd->extension != NULL) {
381 if (strcmp(wnd->extension, Untitled)) {
382 char *fn = NameComponent(wnd->extension);
383 if (fn != NULL) {
384 char msg[30];
385 sprintf(msg, "Delete %s?", fn);
386 if (DfYesNoBox(msg)) {
387 unlink(wnd->extension);
388 DfSendMessage(wnd, DFM_CLOSE_WINDOW, 0, 0);
389 }
390 }
391 }
392 }
393 }
394
395 /* ------ display the row and column in the statusbar ------ */
396 static void ShowPosition(DFWINDOW wnd)
397 {
398 char status[30];
399 sprintf(status, "Line:%4d Column: %2d",
400 wnd->CurrLine, wnd->CurrCol);
401 DfSendMessage(DfGetParent(wnd), DFM_ADDSTATUS, (DF_PARAM) status, 0);
402 }
403
404 /* ----- window processing module for the editboxes ----- */
405 static int EditorProc(DFWINDOW wnd,DFMESSAGE msg,DF_PARAM p1,DF_PARAM p2)
406 {
407 int rtn;
408 switch (msg) {
409 case DFM_SETFOCUS:
410 if ((int)p1) {
411 wnd->InsertMode = DfGetCommandToggle(&DfMainMenu, DF_ID_INSERT);
412 wnd->WordWrapMode = DfGetCommandToggle(&DfMainMenu, DF_ID_WRAP);
413 }
414 rtn = DfDefaultWndProc(wnd, msg, p1, p2);
415 if ((int)p1 == FALSE)
416 DfSendMessage(DfGetParent(wnd), DFM_ADDSTATUS, 0, 0);
417 else
418 ShowPosition(wnd);
419 return rtn;
420 case DFM_KEYBOARD_CURSOR:
421 rtn = DfDefaultWndProc(wnd, msg, p1, p2);
422 ShowPosition(wnd);
423 return rtn;
424 case DFM_COMMAND:
425 switch ((int) p1) {
426 case DF_ID_SEARCH:
427 SearchText(wnd);
428 return TRUE;
429 case DF_ID_REPLACE:
430 ReplaceText(wnd);
431 return TRUE;
432 case DF_ID_SEARCHNEXT:
433 SearchNext(wnd);
434 return TRUE;
435 case DF_ID_CUT:
436 DfCopyToClipboard(wnd);
437 DfSendMessage(wnd, DFM_COMMAND, DF_ID_DELETETEXT, 0);
438 DfSendMessage(wnd, DFM_PAINT, 0, 0);
439 return TRUE;
440 case DF_ID_COPY:
441 DfCopyToClipboard(wnd);
442 DfClearTextBlock(wnd);
443 DfSendMessage(wnd, DFM_PAINT, 0, 0);
444 return TRUE;
445 case DF_ID_PASTE:
446 DfPasteFromClipboard(wnd);
447 DfSendMessage(wnd, DFM_PAINT, 0, 0);
448 return TRUE;
449 case DF_ID_DELETETEXT:
450 case DF_ID_CLEAR:
451 rtn = DfDefaultWndProc(wnd, msg, p1, p2);
452 DfSendMessage(wnd, DFM_PAINT, 0, 0);
453 return rtn;
454 case DF_ID_HELP:
455 DfDisplayHelp(wnd, "MEMOPADDOC");
456 return TRUE;
457 case DF_ID_WRAP:
458 DfSendMessage(DfGetParent(wnd), DFM_COMMAND, DF_ID_WRAP, 0);
459 wnd->WordWrapMode = DfCfg.WordWrap;
460 return TRUE;
461 case DF_ID_INSERT:
462 DfSendMessage(DfGetParent(wnd), DFM_COMMAND, DF_ID_INSERT, 0);
463 wnd->InsertMode = DfCfg.InsertMode;
464 DfSendMessage(NULL, DFM_SHOW_CURSOR, wnd->InsertMode, 0);
465 return TRUE;
466 default:
467 break;
468 }
469 break;
470 case DFM_CLOSE_WINDOW:
471 if (wnd->TextChanged) {
472 char *cp = DfMalloc(25+strlen(DfGetTitle(wnd)));
473 DfSendMessage(wnd, DFM_SETFOCUS, TRUE, 0);
474 strcpy(cp, DfGetTitle(wnd));
475 strcat(cp, "\nText changed. Save it?");
476 if (DfYesNoBox(cp))
477 DfSendMessage(DfGetParent(wnd),
478 DFM_COMMAND, DF_ID_SAVE, 0);
479 free(cp);
480 }
481 wndpos = 0;
482 if (wnd->extension != NULL) {
483 free(wnd->extension);
484 wnd->extension = NULL;
485 }
486 break;
487 default:
488 break;
489 }
490 return DfDefaultWndProc(wnd, msg, p1, p2);
491 }
492 /* -- point to the name component of a file specification -- */
493 static char *NameComponent(char *FileName)
494 {
495 char *Fname;
496 if ((Fname = strrchr(FileName, '\\')) == NULL)
497 if ((Fname = strrchr(FileName, ':')) == NULL)
498 Fname = FileName-1;
499 return Fname + 1;
500 }
501
502 static char *ports[] = {
503 "Lpt1", "Lpt2", "Lpt3",
504 "Com1", "Com2", "Com3", "Com4",
505 NULL
506 };
507
508 static int PrintSetupProc(DFWINDOW wnd, DFMESSAGE msg, DF_PARAM p1, DF_PARAM p2)
509 {
510 int rtn, i = 0, mar;
511 char marg[10];
512 DFWINDOW cwnd;
513 switch (msg) {
514 case DFM_CREATE_WINDOW:
515 rtn = DfDefaultWndProc(wnd, msg, p1, p2);
516 DfPutItemText(wnd, DF_ID_PRINTERPORT, DfCfg.PrinterPort);
517 while (ports[i] != NULL)
518 DfPutComboListText(wnd, DF_ID_PRINTERPORT, ports[i++]);
519 for (mar = CHARSLINE; mar >= 0; --mar) {
520 sprintf(marg, "%3d", mar);
521 DfPutItemText(wnd, DF_ID_LEFTMARGIN, marg);
522 DfPutItemText(wnd, DF_ID_RIGHTMARGIN, marg);
523 }
524 for (mar = LINESPAGE; mar >= 0; --mar) {
525 sprintf(marg, "%3d", mar);
526 DfPutItemText(wnd, DF_ID_TOPMARGIN, marg);
527 DfPutItemText(wnd, DF_ID_BOTTOMMARGIN, marg);
528 }
529 cwnd = DfControlWindow(&PrintSetup, DF_ID_LEFTMARGIN);
530 DfSendMessage(cwnd, DFM_LB_SETSELECTION,
531 CHARSLINE-DfCfg.LeftMargin, 0);
532 cwnd = DfControlWindow(&PrintSetup, DF_ID_RIGHTMARGIN);
533 DfSendMessage(cwnd, DFM_LB_SETSELECTION,
534 CHARSLINE-DfCfg.RightMargin, 0);
535 cwnd = DfControlWindow(&PrintSetup, DF_ID_TOPMARGIN);
536 DfSendMessage(cwnd, DFM_LB_SETSELECTION,
537 LINESPAGE-DfCfg.TopMargin, 0);
538 cwnd = DfControlWindow(&PrintSetup, DF_ID_BOTTOMMARGIN);
539 DfSendMessage(cwnd, DFM_LB_SETSELECTION,
540 LINESPAGE-DfCfg.BottomMargin, 0);
541 return rtn;
542 case DFM_COMMAND:
543 if ((int) p1 == DF_ID_OK && (int) p2 == 0) {
544 DfGetItemText(wnd, DF_ID_PRINTERPORT, DfCfg.PrinterPort, 4);
545 cwnd = DfControlWindow(&PrintSetup, DF_ID_LEFTMARGIN);
546 DfCfg.LeftMargin = CHARSLINE -
547 DfSendMessage(cwnd, DFM_LB_CURRENTSELECTION, 0, 0);
548 cwnd = DfControlWindow(&PrintSetup, DF_ID_RIGHTMARGIN);
549 DfCfg.RightMargin = CHARSLINE -
550 DfSendMessage(cwnd, DFM_LB_CURRENTSELECTION, 0, 0);
551 cwnd = DfControlWindow(&PrintSetup, DF_ID_TOPMARGIN);
552 DfCfg.TopMargin = LINESPAGE -
553 DfSendMessage(cwnd, DFM_LB_CURRENTSELECTION, 0, 0);
554 cwnd = DfControlWindow(&PrintSetup, DF_ID_BOTTOMMARGIN);
555 DfCfg.BottomMargin = LINESPAGE -
556 DfSendMessage(cwnd, DFM_LB_CURRENTSELECTION, 0, 0);
557 }
558 break;
559 default:
560 break;
561 }
562 return DfDefaultWndProc(wnd, msg, p1, p2);
563 }
564
565 static void FixTabMenu(void)
566 {
567 char *cp = DfGetCommandText(&DfMainMenu, DF_ID_TABS);
568 if (cp != NULL) {
569 cp = strchr(cp, '(');
570 if (cp != NULL) {
571 *(cp+1) = DfCfg.Tabs + '0';
572 if (DfGetClass(DfInFocus) == DF_POPDOWNMENU)
573 DfSendMessage(DfInFocus, DFM_PAINT, 0, 0);
574 }
575 }
576 }
577
578 void DfPrepFileMenu(void *w, struct DfMenu *mnu)
579 {
580 DFWINDOW wnd = w;
581 DfDeactivateCommand(&DfMainMenu, DF_ID_SAVE);
582 DfDeactivateCommand(&DfMainMenu, DF_ID_SAVEAS);
583 DfDeactivateCommand(&DfMainMenu, DF_ID_DELETEFILE);
584 DfDeactivateCommand(&DfMainMenu, DF_ID_PRINT);
585 if (wnd != NULL && DfGetClass(wnd) == DF_EDITBOX) {
586 if (DfIsMultiLine(wnd)) {
587 DfActivateCommand(&DfMainMenu, DF_ID_SAVE);
588 DfActivateCommand(&DfMainMenu, DF_ID_SAVEAS);
589 DfActivateCommand(&DfMainMenu, DF_ID_DELETEFILE);
590 DfActivateCommand(&DfMainMenu, DF_ID_PRINT);
591 }
592 }
593 }
594
595 void DfPrepSearchMenu(void *w, struct DfMenu *mnu)
596 {
597 DFWINDOW wnd = w;
598 DfDeactivateCommand(&DfMainMenu, DF_ID_SEARCH);
599 DfDeactivateCommand(&DfMainMenu, DF_ID_REPLACE);
600 DfDeactivateCommand(&DfMainMenu, DF_ID_SEARCHNEXT);
601 if (wnd != NULL && DfGetClass(wnd) == DF_EDITBOX) {
602 if (DfIsMultiLine(wnd)) {
603 DfActivateCommand(&DfMainMenu, DF_ID_SEARCH);
604 DfActivateCommand(&DfMainMenu, DF_ID_REPLACE);
605 DfActivateCommand(&DfMainMenu, DF_ID_SEARCHNEXT);
606 }
607 }
608 }
609
610 void DfPrepEditMenu(void *w, struct DfMenu *mnu)
611 {
612 DFWINDOW wnd = w;
613 DfDeactivateCommand(&DfMainMenu, DF_ID_CUT);
614 DfDeactivateCommand(&DfMainMenu, DF_ID_COPY);
615 DfDeactivateCommand(&DfMainMenu, DF_ID_CLEAR);
616 DfDeactivateCommand(&DfMainMenu, DF_ID_DELETETEXT);
617 DfDeactivateCommand(&DfMainMenu, DF_ID_PARAGRAPH);
618 DfDeactivateCommand(&DfMainMenu, DF_ID_PASTE);
619 DfDeactivateCommand(&DfMainMenu, DF_ID_UNDO);
620 if (wnd != NULL && DfGetClass(wnd) == DF_EDITBOX) {
621 if (DfIsMultiLine(wnd)) {
622 if (DfTextBlockMarked(wnd)) {
623 DfActivateCommand(&DfMainMenu, DF_ID_CUT);
624 DfActivateCommand(&DfMainMenu, DF_ID_COPY);
625 DfActivateCommand(&DfMainMenu, DF_ID_CLEAR);
626 DfActivateCommand(&DfMainMenu, DF_ID_DELETETEXT);
627 }
628 DfActivateCommand(&DfMainMenu, DF_ID_PARAGRAPH);
629 if (!DfTestAttribute(wnd, DF_READONLY) &&
630 DfClipboard != NULL)
631 DfActivateCommand(&DfMainMenu, DF_ID_PASTE);
632 if (wnd->DeletedText != NULL)
633 DfActivateCommand(&DfMainMenu, DF_ID_UNDO);
634 }
635 }
636 }
637
638 /* EOF */