1 /* This file is part of
2 * ======================================================
4 * LyX, The Document Processor
6 * Copyright 1995 Matthias Ettrich,
7 * Copyright 1995-2000 The LyX Team.
9 * ====================================================== */
18 #include FORMS_H_LOCATION
20 #include "layout_forms.h"
21 #include "bullet_forms.h"
22 #include "print_form.h"
26 #include "insets/insetref.h"
27 #include "insets/insetlabel.h"
28 #include "insets/figinset.h"
30 #include "minibuffer.h"
32 #include "bufferlist.h"
34 #include "lyx_gui_misc.h"
36 #include "BufferView.h"
37 #include "lastfiles.h"
38 #include "bufferview_funcs.h"
39 #include "support/FileInfo.h"
40 #include "support/syscall.h"
41 #include "support/filetools.h"
42 #include "support/path.h"
43 #include "lyxserver.h"
44 #include "FontLoader.h"
47 #include "CutAndPaste.h"
48 #include "TextCache.h"
52 using std::back_inserter;
56 using std::istream_iterator;
61 extern Combox * combo_language;
62 extern Combox * combo_language2;
63 extern BufferList bufferlist;
64 extern void show_symbols_form();
65 extern FD_form_title * fd_form_title;
66 extern FD_form_paragraph * fd_form_paragraph;
67 extern FD_form_character * fd_form_character;
68 extern FD_form_document * fd_form_document;
69 extern FD_form_quotes * fd_form_quotes;
70 extern FD_form_preamble * fd_form_preamble;
71 extern FD_form_table * fd_form_table;
72 extern FD_form_print * fd_form_print;
73 extern FD_form_figure * fd_form_figure;
74 extern FD_form_screen * fd_form_screen;
75 extern FD_form_toc * fd_form_toc;
76 extern FD_form_ref * fd_form_ref;
77 extern FD_LaTeXOptions * fd_latex_options;
78 extern FD_form_bullet * fd_form_bullet;
80 #define XFORMS_CLIPBOARD 1
82 extern BufferView * current_view; // called too many times in this file...
84 extern void DeleteSimpleCutBuffer(); /* for the cleanup when exiting */
86 extern bool send_fax(string const & fname, string const & sendcmd);
87 extern void MenuSendto();
89 extern LyXServer * lyxserver;
91 // this should be static, but I need it in buffer.C
92 bool quitting; // flag, that we are quitting the program
93 extern bool finished; // all cleanup done just let it run through now.
95 char ascii_type; /* for selection notify callbacks */
97 bool scrolling = false;
99 // This is used to make the dreaded font toggle problem hopefully go
100 // away. Definitely not the best solution, but I think it sorta works.
101 bool toggleall = true;
104 This is the inset locking stuff needed for mathed --------------------
106 an inset can simple call LockInset in it's edit call and *ONLY* in it's
108 Inset::Edit() can only be called by the main lyx module.
110 Then the inset may modify the menu's and/or iconbars.
112 Unlocking is either done by LyX or the inset itself with a UnlockInset-call
114 During the lock, all button and keyboard events will be modified
115 and send to the inset through the following inset-features. Note that
116 Inset::InsetUnlock will be called from inside UnlockInset. It is meant
117 to contain the code for restoring the menus and things like this.
120 virtual void InsetButtonPress(int x, int y, int button);
121 virtual void InsetButtonRelease(int x, int y, int button);
122 virtual void InsetKeyPress(XKeyEvent *ev);
123 virtual void InsetMotionNotify(int x, int y, int state);
124 virtual void InsetUnlock();
126 If a inset wishes any redraw and/or update it just has to call
128 It's is completly irrelevant, where the inset is. UpdateInset will
129 find it in any paragraph in any buffer.
130 Of course the_locking_inset and the insets in the current paragraph/buffer
131 are checked first, so no performance problem should occur.
133 Hope that's ok for the beginning, Alejandro,
134 sorry that I needed so much time,
139 //void UpdateInset(BufferView * bv, Inset * inset, bool mark_dirty = true);
141 /* these functions return 1 if an error occured,
143 // Now they work only for updatable insets. [Alejandro 080596]
144 //int LockInset(UpdatableInset * inset);
145 void ToggleLockedInsetCursor(long x, long y, int asc, int desc);
146 //void FitLockedInsetCursor(long x, long y, int asc, int desc);
147 //int UnlockInset(UpdatableInset * inset);
148 //void LockedInsetStoreUndo(Undo::undo_kind kind);
150 /* this is for asyncron updating. UpdateInsetUpdateList will be called
151 automatically from LyX. Just insert the Inset into the Updatelist */
152 //void UpdateInsetUpdateList();
153 //void PutInsetIntoInsetUpdateList(Inset * inset);
155 //InsetUpdateStruct * InsetUpdateList = 0;
159 -----------------------------------------------------------------------
162 /* some function prototypes */
164 int RunLinuxDoc(BufferView *, int, string const &);
165 int RunDocBook(int, string const &);
166 void MenuWrite(Buffer * buf);
167 void MenuWriteAs(Buffer * buffer);
168 void MenuReload(Buffer * buf);
169 void MenuLayoutSave();
172 void ShowMessage(Buffer * buf,
174 string const & msg2 = string(),
175 string const & msg3 = string(), int delay = 6)
178 buf->getUser()->owner()->getMiniBuffer()->Set(msg1, msg2,
181 // can somebody think of something more clever? cerr?
182 cout << msg1 << msg2 << msg3 << endl;
187 // only called from this file, LyXView and LyXFunc
188 char updatetimer = 0;
191 // only called from BufferView_pimpl and LyXFunc
192 void FreeUpdateTimer()
194 /* a real free timer would be better but I don't know
195 * how to do this with xforms */
200 // Only called from LyXFunc
201 void SetUpdateTimer(float time)
203 fl_set_timer(current_view->owner()->getMainForm()->timer_update, time);
216 // should be moved to lyxfunc.C
217 void MenuWrite(Buffer * buffer)
220 if (!buffer->save()) {
221 string fname = buffer->fileName();
222 string s = MakeAbsPath(fname);
223 if (AskQuestion(_("Save failed. Rename and try again?"),
224 MakeDisplayPath(s, 50),
225 _("(If not, document is not saved.)"))) {
229 lastfiles->newFile(buffer->fileName());
234 // should be moved to BufferView.C
235 // Half of this func should be in LyXView, the rest in BufferView.
236 void MenuWriteAs(Buffer * buffer)
238 // Why do we require BufferView::text to be able to write a
239 // document? I see no point in that. (Lgb)
240 //if (!bv->text) return;
242 string fname = buffer->fileName();
243 string oldname = fname;
246 ProhibitInput(current_view);
247 fileDlg.SetButton(0, _("Documents"), lyxrc.document_path);
248 fileDlg.SetButton(1, _("Templates"), lyxrc.template_path);
250 if (!IsLyXFilename(fname))
253 fname = fileDlg.Select(_("Enter Filename to Save Document as"),
256 OnlyFilename(fname));
257 AllowInput(current_view);
262 // Make sure the absolute filename ends with appropriate suffix
263 string s = MakeAbsPath(fname);
264 if (!IsLyXFilename(s))
267 // Same name as we have already?
269 if (!AskQuestion(_("Same name as document already has:"),
270 MakeDisplayPath(s, 50),
273 // Falls through to name change and save
275 // No, but do we have another file with this name open?
276 else if (bufferlist.exists(s)) {
277 if (AskQuestion(_("Another document with same name open!"),
278 MakeDisplayPath(s, 50),
279 _("Replace with current document?")))
281 bufferlist.close(bufferlist.getBuffer(s));
283 // Ok, change the name of the buffer, but don't save!
287 ShowMessage(buffer, _("Document renamed to '"),
288 MakeDisplayPath(s), _("', but not saved..."));
291 } // Check whether the file exists
294 if (myfile.isOK() && !AskQuestion(_("Document already exists:"),
295 MakeDisplayPath(s, 50),
300 // Ok, change the name of the buffer
304 // Small bug: If the save fails, we have irreversible changed the name
310 int MenuRunLaTeX(Buffer * buffer)
314 if (buffer->isLinuxDoc())
315 ret = RunLinuxDoc(buffer->getUser(), 1, buffer->fileName());
316 else if (buffer->isLiterate())
317 ret = buffer->runLiterate();
318 else if (buffer->isDocBook())
319 ret = RunDocBook(1, buffer->fileName());
321 ret = buffer->runLaTeX();
327 s = _("One error detected");
328 t = _("You should try to fix it.");
331 s += _(" errors detected.");
332 t = _("You should try to fix them.");
334 WriteAlert(_("There were errors during the LaTeX run."), s, t);
340 int MenuBuildProg(Buffer * buffer)
344 if (buffer->isLiterate())
345 ret = buffer->buildProgram();
347 string s = _("Wrong type of document");
348 string t = _("The Build operation is not allowed in this document");
349 WriteAlert(_("There were errors during the Build process."), s, t);
357 s = _("One error detected");
358 t = _("You should try to fix it.");
361 s += _(" errors detected.");
362 t = _("You should try to fix them.");
364 WriteAlert(_("There were errors during the Build process."), s, t);
370 int MenuRunChktex(Buffer * buffer)
374 if (buffer->isSGML()) {
375 WriteAlert(_("Chktex does not work with SGML derived documents."));
378 ret = buffer->runChktex();
384 s = _("No warnings found.");
385 } else if (ret == 1) {
386 s = _("One warning found.");
387 t = _("Use 'Edit->Go to Error' to find it.");
390 s += _(" warnings found.");
391 t = _("Use 'Edit->Go to Error' to find them.");
393 WriteAlert(_("Chktex run successfully"), s, t);
395 WriteAlert(_("Error!"), _("It seems chktex does not work."));
401 int MakeLaTeXOutput(Buffer * buffer)
407 string path = OnlyPath(buffer->fileName());
408 if (lyxrc.use_tempdir || (IsDirWriteable(path) < 1)) {
409 path = buffer->tmppath;
411 if (!buffer->isDviClean()) {
413 ret = MenuRunLaTeX(buffer);
419 /* wait == false means don't wait for termination */
420 /* wait == true means wait for termination */
421 // The bool should be placed last on the argument line. (Lgb)
422 // Returns false if we fail.
423 bool RunScript(Buffer * buffer, bool wait,
424 string const & command,
425 string const & orgname = string(),
426 bool need_shell = true)
430 string name = orgname;
433 if (MakeLaTeXOutput(buffer) > 0)
435 /* get DVI-Filename */
437 name = ChangeExtension(buffer->getLatexName(), ".dvi");
439 path = OnlyPath(name);
440 if (lyxrc.use_tempdir || (IsDirWriteable(path) < 1)) {
441 path = buffer->tmppath;
444 // At this point we check whether the command contains the
445 // filename parameter $$FName and if that's the case we
446 // substitute the real file name otherwise the filename is
447 // simply appended. rokrau 1/12/00
450 if ( (i=command.find("$$FName")) != string::npos)
452 cmd.replace(i,7,QuoteName(name));
455 cmd = command + ' ' + QuoteName(name);
464 // OS/2 cmd.exe has another use for '&'
466 // This is not NLS safe, but it's OK, I think.
467 string sh = OnlyFilename(GetEnvPath("EMXSHELL"));
469 // COMSPEC is set, unless user unsets
470 sh = OnlyFilename(GetEnvPath("COMSPEC"));
475 if (contains(sh, "cmd.exe")
476 || contains(sh, "4os2.exe"))
477 cmd = "start /min/n " + cmd;
482 // It seems that, if wait is false, we never get back
483 // the return code of the command. This means that all
484 // the code I added in PrintApplyCB is currently
486 // CHECK What should we do here?
487 ShowMessage(buffer, _("Executing command:"), cmd);
488 result = one.startscript(Systemcalls::System, cmd);
490 ShowMessage(buffer, _("Executing command:"), cmd);
491 result = one.startscript(wait ? Systemcalls::Wait
492 : Systemcalls::DontWait, cmd);
498 // Returns false if we fail
499 bool CreatePostscript(Buffer * buffer, bool wait = false)
505 ProhibitInput(current_view);
508 if (MakeLaTeXOutput(buffer) > 0) {
509 AllowInput(current_view);
512 // Generate postscript file
513 string psname = OnlyFilename(ChangeExtension (buffer->fileName(),
519 char real_papersize = buffer->params.papersize;
520 if (real_papersize == BufferParams::PAPER_DEFAULT)
521 real_papersize = lyxrc.default_papersize;
523 switch (real_papersize) {
524 case BufferParams::PAPER_USLETTER:
527 case BufferParams::PAPER_A3PAPER:
530 case BufferParams::PAPER_A4PAPER:
533 case BufferParams::PAPER_A5PAPER:
536 case BufferParams::PAPER_B5PAPER:
539 case BufferParams::PAPER_EXECUTIVEPAPER:
542 case BufferParams::PAPER_LEGALPAPER:
545 default: /* If nothing else fits, keep an empty value... */
549 // Make postscript file.
550 string command = lyxrc.dvi_to_ps_command + ' ' + lyxrc.print_to_file + ' ';
551 command += QuoteName(psname);
552 if (buffer->params.use_geometry
553 && buffer->params.papersize2 == BufferParams::VM_PAPER_CUSTOM
554 && !lyxrc.print_paper_dimension_flag.empty()
555 && !buffer->params.paperwidth.empty()
556 && !buffer->params.paperheight.empty()) {
557 // using a custom papersize
559 command += lyxrc.print_paper_dimension_flag + ' ';
560 command += buffer->params.paperwidth + ',';
561 command += buffer->params.paperheight;
562 } else if (!paper.empty()
563 && (real_papersize != BufferParams::PAPER_USLETTER ||
564 buffer->params.orientation == BufferParams::ORIENTATION_PORTRAIT)) {
565 // dvips won't accept -t letter -t landscape. In all other
566 // cases, include the paper size explicitly.
568 command += lyxrc.print_paper_flag + ' ' + paper;
570 if (buffer->params.orientation == BufferParams::ORIENTATION_LANDSCAPE) {
572 command += lyxrc.print_landscape_flag;
574 // push directorypath, if necessary
575 string path = OnlyPath(buffer->fileName());
576 if (lyxrc.use_tempdir || (IsDirWriteable(path) < 1)){
577 path = buffer->tmppath;
580 bool ret = RunScript(buffer, wait, command);
581 AllowInput(current_view);
586 // Returns false if we fail
587 //bool MenuPreviewPS(Buffer * buffer)
588 bool PreviewPostscript(Buffer * buffer)
594 // Generate postscript file
595 if (!CreatePostscript(buffer, true)) {
599 // Start postscript viewer
600 ProhibitInput(current_view);
601 string ps = OnlyFilename(ChangeExtension (buffer->fileName(),
603 // push directorypath, if necessary
604 string path = OnlyPath(buffer->fileName());
605 if (lyxrc.use_tempdir || (IsDirWriteable(path) < 1)){
606 path = buffer->tmppath;
609 bool ret = RunScript(buffer, false, lyxrc.view_ps_command, ps);
610 AllowInput(current_view);
615 void MenuFax(Buffer * buffer)
621 // Generate postscript file
622 if (!CreatePostscript(buffer, true)) {
627 string ps = OnlyFilename(ChangeExtension (buffer->fileName(),
629 string path = OnlyPath (buffer->fileName());
630 if (lyxrc.use_tempdir || (IsDirWriteable(path) < 1)) {
631 path = buffer->tmppath;
634 if (!lyxrc.fax_program.empty()) {
635 string help2 = subst(lyxrc.fax_program, "$$FName", ps);
637 Systemcalls one(Systemcalls::System, help2);
639 send_fax(ps, lyxrc.fax_command);
643 // Returns false if we fail
644 bool PreviewDVI(Buffer * buffer)
650 string paper = lyxrc.view_dvi_paper_option;
651 if (!paper.empty()) {
653 char real_papersize = buffer->params.papersize;
654 if (real_papersize == BufferParams::PAPER_DEFAULT)
655 real_papersize = lyxrc.default_papersize;
657 switch (real_papersize) {
658 case BufferParams::PAPER_USLETTER:
661 case BufferParams::PAPER_A3PAPER:
664 case BufferParams::PAPER_A4PAPER:
667 case BufferParams::PAPER_A5PAPER:
670 case BufferParams::PAPER_B5PAPER:
673 case BufferParams::PAPER_EXECUTIVEPAPER:
674 paper += " foolscap";
676 case BufferParams::PAPER_LEGALPAPER:
679 default: /* If nothing else fits, keep the empty value */
682 if (real_papersize==' ') {
683 // if (paper.empty()) {
684 if (buffer->params.orientation
685 == BufferParams::ORIENTATION_LANDSCAPE)
686 // we HAVE to give a size when the page is in
687 // landscape, so use USletter.
688 paper = " -paper usr";
690 // paper = " -paper " + paper;
691 if (buffer->params.orientation
692 == BufferParams::ORIENTATION_LANDSCAPE)
696 // push directorypath, if necessary
697 string path = OnlyPath(buffer->fileName());
698 if (lyxrc.use_tempdir || (IsDirWriteable(path) < 1)) {
699 path = buffer->tmppath;
703 string command = lyxrc.view_dvi_command + " " + paper;
704 bool ret = RunScript(buffer, false, command);
709 bool AskOverwrite(Buffer * buffer, string const & s)
712 // be friendly if there is a gui
715 !AskQuestion(_("File already exists:"),
716 MakeDisplayPath(s, 50),
717 _("Do you want to overwrite the file?"))) {
718 ShowMessage(buffer, _("Canceled"));
726 void MenuMakeLaTeX(Buffer * buffer)
728 // Why care about this?
732 // Get LaTeX-Filename
733 string s = buffer->getLatexName(false);
735 if (!AskOverwrite(buffer, s))
738 if (buffer->isDocBook())
739 ShowMessage(buffer, _("DocBook does not have a latex backend"));
741 if (buffer->isLinuxDoc())
742 RunLinuxDoc(buffer->getUser(), 0, buffer->fileName());
744 buffer->makeLaTeXFile(s, string(), true);
745 ShowMessage(buffer, _("Nice LaTeX file saved as"),
747 buffer->markDviDirty();
752 void MenuMakeLinuxDoc(Buffer * buffer)
755 //if (!bv->text) return;
757 if (!buffer->isLinuxDoc()) {
758 WriteAlert(_("Error!"), _("Document class must be linuxdoc."));
762 // Get LinuxDoc-Filename
763 string s = ChangeExtension(buffer->fileName(), ".sgml");
765 if (!AskOverwrite(buffer, s))
768 ShowMessage(buffer, _("Building LinuxDoc SGML file `"),
769 MakeDisplayPath(s),"'...");
771 buffer->makeLinuxDocFile(s, 65);
773 ShowMessage(buffer, _("LinuxDoc SGML file save as"),
778 void MenuMakeDocBook(Buffer * buffer)
781 //if (!bv->text) return;
783 if (!buffer->isDocBook()) {
784 WriteAlert(_("Error!"),
785 _("Document class must be docbook."));
789 // Get DocBook-Filename
790 string s = ChangeExtension(buffer->fileName(), ".sgml");
792 if (!AskOverwrite(buffer, s))
795 ShowMessage(buffer, _("Building DocBook SGML file `"),
796 MakeDisplayPath(s), "'...");
798 buffer->makeDocBookFile(s, 65);
800 ShowMessage(buffer, _("DocBook SGML file save as"),
805 void MenuMakeAscii(Buffer * buffer)
808 //if (!bv->text) return;
810 /* get LaTeX-Filename */
811 string s = ChangeExtension (buffer->fileName(), ".txt");
814 if (!AskOverwrite(buffer, s))
817 buffer->writeFileAscii(s, lyxrc.ascii_linelen);
819 ShowMessage(buffer, _("Ascii file saved as"), MakeDisplayPath(s));
823 void MenuPrint(Buffer * buffer)
829 string input_file = OnlyFilename(ChangeExtension(buffer->fileName(),
830 lyxrc.print_file_extension));
831 fl_set_input(fd_form_print->input_file, input_file.c_str());
833 if (fd_form_print->form_print->visible) {
834 fl_raise_form(fd_form_print->form_print);
837 fl_show_form(fd_form_print->form_print,
838 FL_PLACE_MOUSE, FL_FULLBORDER,
844 void MenuMakeHTML(Buffer * buffer)
846 // First, create LaTeX file
847 MenuMakeLaTeX(buffer);
849 // And now, run the converter
850 string file = buffer->fileName();
851 Path path(OnlyPath(file));
852 // the tex file name has to be correct for
853 // latex, but the html file name can be
855 string result = ChangeExtension(file, ".html");
856 string infile = buffer->getLatexName(false);
857 string tmp = lyxrc.html_command;
858 tmp = subst(tmp, "$$FName", infile);
859 tmp = subst(tmp, "$$OutName", result);
861 int res = one.startscript(Systemcalls::System, tmp);
863 ShowMessage(buffer, _("Document exported as HTML to file `")
864 + MakeDisplayPath(result) +'\'');
866 ShowMessage(buffer, _("Unable to convert to HTML the file `")
867 + MakeDisplayPath(infile)
874 void MenuMakeHTML_LinuxDoc(Buffer * buffer)
876 // First, create LinuxDoc file
877 MenuMakeLinuxDoc(buffer);
879 // And now, run the converter
880 string file = buffer->fileName();
882 string result = ChangeExtension(file, ".html");
883 string infile = ChangeExtension(file, ".sgml");
884 string tmp = lyxrc.linuxdoc_to_html_command;
885 tmp = subst(tmp, "$$FName", infile);
886 tmp = subst(tmp, "$$OutName", result);
888 int res = one.startscript(Systemcalls::System, tmp);
890 ShowMessage(buffer,_("Document exported as HTML to file `")
891 + MakeDisplayPath(result) +'\'');
893 ShowMessage(buffer,_("Unable to convert to HTML the file `")
894 + MakeDisplayPath(infile)
900 void MenuMakeHTML_DocBook(Buffer * buffer)
902 // First, create LaTeX file
903 MenuMakeDocBook(buffer);
905 // And now, run the converter
906 string file = buffer->fileName();
907 string result = ChangeExtension(file, ".html");
908 string infile = ChangeExtension(file, ".sgml");
909 string tmp = lyxrc.docbook_to_html_command;
910 tmp = subst(tmp, "$$FName", infile);
911 tmp = subst(tmp, "$$OutName", result);
913 int res = one.startscript(Systemcalls::System, tmp);
915 ShowMessage(buffer,_("Document exported as HTML to file `")
916 + MakeDisplayPath(result) +'\'');
918 ShowMessage(buffer,_("Unable to convert to HTML the file `")
919 + MakeDisplayPath(infile)
926 void MenuExport(Buffer * buffer, string const & extyp)
929 if (extyp == "latex") {
930 // make sure that this buffer is not linuxdoc
931 MenuMakeLaTeX(buffer);
934 else if (extyp == "linuxdoc") {
935 // make sure that this buffer is not latex
936 MenuMakeLinuxDoc(buffer);
939 else if (extyp == "docbook") {
940 // make sure that this buffer is not latex or linuxdoc
941 MenuMakeDocBook(buffer);
944 else if (extyp == "dvi") {
945 // Run LaTeX as "Update dvi..." Bernhard.
946 // We want the dvi in the current directory. This
947 // is achieved by temporarily disabling use of
948 // temp directory. As a side-effect, we get
949 // *.log and *.aux files also. (Asger)
950 bool flag = lyxrc.use_tempdir;
951 lyxrc.use_tempdir = false;
952 MenuRunLaTeX(buffer);
953 lyxrc.use_tempdir = flag;
956 else if (extyp == "postscript") {
957 // Start Print-dialog. Not as good as dvi... Bernhard.
959 // Since the MenuPrint is a pop-up, we can't use
960 // the same trick as above. (Asger)
961 // MISSING: Move of ps-file :-(
962 // And MenuPrint should not be used for this at all...
965 else if (extyp == "ascii") {
966 MenuMakeAscii(buffer);
968 else if (extyp == "custom") {
972 else if (extyp == "html") {
973 MenuMakeHTML(buffer);
975 // HTML from linuxdoc
976 else if (extyp == "html-linuxdoc") {
977 MenuMakeHTML_LinuxDoc(buffer);
980 else if (extyp == "html-docbook") {
981 MenuMakeHTML_DocBook(buffer);
984 ShowMessage(buffer, _("Unknown export type: ") + extyp);
991 lyxerr.debug() << "Running QuitLyX." << endl;
993 if (!bufferlist.QwriteAll())
996 lastfiles->writeFile(lyxrc.lastfiles);
998 // Set a flag that we do quitting from the program,
999 // so no refreshes are necessary.
1002 // close buffers first
1003 bufferlist.closeAll();
1005 // do any other cleanup procedures now
1006 lyxerr.debug() << "Deleting tmp dir " << system_tempdir << endl;
1008 DestroyLyXTmpDir(system_tempdir);
1015 void AutoSave(BufferView * bv)
1016 // should probably be moved into BufferList (Lgb)
1017 // Perfect target for a thread...
1019 if (!bv->available())
1022 if (bv->buffer()->isBakClean()
1023 || bv->buffer()->isReadonly()) {
1024 // We don't save now, but we'll try again later
1025 bv->owner()->resetAutosaveTimer();
1029 bv->owner()->getMiniBuffer()->Set(_("Autosaving current document..."));
1031 // create autosave filename
1032 string fname = OnlyPath(bv->buffer()->fileName());
1034 fname += OnlyFilename(bv->buffer()->fileName());
1037 // tmp_ret will be located (usually) in /tmp
1038 // will that be a problem?
1039 string tmp_ret = tmpnam(0);
1041 pid_t pid = fork(); // If you want to debug the autosave
1042 // you should set pid to -1, and comment out the
1044 if (pid == 0 || pid == -1) {
1045 // pid = -1 signifies that lyx was unable
1046 // to fork. But we will do the save
1048 bool failed = false;
1049 if (!tmp_ret.empty()) {
1050 bv->buffer()->writeFile(tmp_ret, 1);
1051 // assume successful write of tmp_ret
1052 if (rename(tmp_ret.c_str(), fname.c_str()) == -1) {
1054 // most likely couldn't move between filesystems
1055 // unless write of tmp_ret failed
1056 // so remove tmp file (if it exists)
1057 remove(tmp_ret.c_str());
1064 // failed to write/rename tmp_ret so try writing direct
1065 if (!bv->buffer()->writeFile(fname, 1)) {
1066 // It is dangerous to do this in the child,
1067 // but safe in the parent, so...
1069 bv->owner()->getMiniBuffer()->Set(_("Autosave Failed!"));
1072 if (pid == 0) { // we are the child so...
1077 bv->buffer()->markBakClean();
1078 bv->owner()->resetAutosaveTimer();
1083 // Copyright CHT Software Service GmbH
1086 // create new file with template
1089 Buffer * NewLyxFile(string const & filename)
1091 // Split argument by :
1093 string tmpname = split(filename, name, ':');
1094 #ifdef __EMX__ // Fix me! lyx_cb.C may not be low level enough to allow this.
1095 if (name.length() == 1
1096 && isalpha(static_cast<unsigned char>(name[0]))
1097 && (prefixIs(tmpname, "/") || prefixIs(tmpname, "\\"))) {
1099 name += token(tmpname, ':', 0);
1100 tmpname = split(tmpname, ':');
1103 lyxerr.debug() << "Arg is " << filename
1104 << "\nName is " << name
1105 << "\nTemplate is " << tmpname << endl;
1107 // find a free buffer
1108 Buffer * tmpbuf = bufferlist.newFile(name, tmpname);
1110 lastfiles->newFile(tmpbuf->fileName());
1115 // Insert ascii file (if filename is empty, prompt for one)
1116 void InsertAsciiFile(BufferView * bv, string const & f, bool asParagraph)
1121 if (!bv->available()) return;
1123 if (fname.empty()) {
1125 fname = fileDlg.Select(_("File to Insert"),
1126 bv->owner()->buffer()->filepath,
1129 if (fname.empty()) return;
1134 if (!fi.readable()) {
1135 WriteFSAlert(_("Error! Specified file is unreadable: "),
1136 MakeDisplayPath(fname, 50));
1140 ifstream ifs(fname.c_str());
1142 WriteFSAlert(_("Error! Cannot open specified file: "),
1143 MakeDisplayPath(fname, 50));
1147 ifs.unsetf(ios::skipws);
1148 istream_iterator<char> ii(ifs);
1149 istream_iterator<char> end;
1150 //string tmpstr(ii, end); // yet a reason for using std::string
1151 // alternate approach to get the file into a string:
1153 copy(ii, end, back_inserter(tmpstr));
1154 // insert the string
1155 current_view->hideCursor();
1157 // clear the selection
1160 bv->text->InsertStringA(tmpstr);
1162 bv->text->InsertStringB(tmpstr);
1167 void MenuShowTableOfContents()
1169 static int ow = -1, oh;
1172 if (fd_form_toc->form_toc->visible) {
1173 fl_raise_form(fd_form_toc->form_toc);
1175 fl_show_form(fd_form_toc->form_toc,
1176 FL_PLACE_MOUSE | FL_FREE_SIZE, FL_FULLBORDER,
1177 _("Table Of Contents"));
1179 ow = fd_form_toc->form_toc->w;
1180 oh = fd_form_toc->form_toc->h;
1182 fl_set_form_minsize(fd_form_toc->form_toc, ow, oh);
1187 void MenuInsertLabel(char const * arg)
1190 ProhibitInput(current_view);
1191 if (label.empty()) {
1193 result = askForText(_("Enter new label to insert:"));
1195 label = frontStrip(strip(result.second));
1198 if (!label.empty()) {
1199 InsetLabel * new_inset = new InsetLabel;
1200 new_inset->setContents(label);
1201 current_view->insertInset(new_inset);
1203 AllowInput(current_view);
1207 void MenuInsertRef()
1209 static int ow = -1, oh;
1212 if (fd_form_ref->form_ref->visible) {
1213 fl_raise_form(fd_form_ref->form_ref);
1215 fl_show_form(fd_form_ref->form_ref,
1216 FL_PLACE_MOUSE | FL_FREE_SIZE, FL_FULLBORDER,
1217 _("Insert Reference"));
1219 ow = fd_form_ref->form_ref->w;
1220 oh = fd_form_ref->form_ref->h;
1222 fl_set_form_minsize(fd_form_ref->form_ref, ow, oh);
1227 #ifndef XFORMS_CLIPBOARD
1228 void MenuPasteSelection(char at)
1230 if (!current_view->available())
1234 Atom data_prop = XInternAtom(fl_display,
1237 if (data_prop == None)
1239 XConvertSelection(fl_display,
1240 XA_PRIMARY, XA_STRING, data_prop,
1241 current_view->owner()->getForm()->window, 0);
1249 // candidate for move to LyXView
1250 // This is only used in toolbar.C
1251 void LayoutsCB(int sel, void *)
1253 string tmp = tostr(sel);
1254 current_view->owner()->getLyXFunc()->Dispatch(LFUN_LAYOUTNO,
1260 * SGML Linuxdoc support:
1261 * (flag == 0) make TeX output
1262 * (flag == 1) make dvi output
1264 int RunLinuxDoc(BufferView * bv, int flag, string const & filename)
1271 /* generate a path-less extension name */
1272 string name = OnlyFilename(ChangeExtension (filename, ".sgml"));
1273 string path = OnlyPath (filename);
1274 if (lyxrc.use_tempdir || (IsDirWriteable(path) < 1)) {
1275 path = bv->buffer()->tmppath;
1279 if (!bv->available())
1281 bv->buffer()->makeLinuxDocFile(name, 0);
1283 // CHECK remove this once we have a proper geometry class
1285 BufferParams::PAPER_SIZE ps =
1286 static_cast<BufferParams::PAPER_SIZE>(bv->buffer()->params.papersize);
1288 case BufferParams::PAPER_A4PAPER:
1289 add_flags = "-p a4";
1291 case BufferParams::PAPER_USLETTER:
1292 add_flags = "-p letter";
1294 default: /* nothing to be done yet ;-) */ break;
1301 case 0: /* TeX output asked */
1302 bv->owner()->getMiniBuffer()->Set(_("Converting LinuxDoc SGML to TeX file..."));
1303 s2 = lyxrc.linuxdoc_to_latex_command + ' ' + add_flags + " -o tex " + ' ' + name;
1304 if (one.startscript(Systemcalls::System, s2))
1307 case 1: /* dvi output asked */
1308 bv->owner()->getMiniBuffer()->Set(_("Converting LinuxDoc SGML to dvi file..."));
1309 s2 = lyxrc.linuxdoc_to_latex_command + ' ' + add_flags + " -o dvi " + ' ' + name;
1310 if (one.startscript(Systemcalls::System, s2)) {
1313 bv->buffer()->markDviClean();
1315 default: /* unknown output */
1321 bv->buffer()->redraw();
1327 * SGML DocBook support:
1328 * (flag == 1) make dvi output
1330 int RunDocBook(int flag, string const & filename)
1332 /* generate a path-less extension name */
1333 string name = OnlyFilename(ChangeExtension (filename, ".sgml"));
1334 string path = OnlyPath (filename);
1335 if (lyxrc.use_tempdir || (IsDirWriteable(path) < 1)) {
1336 path = current_view->buffer()->tmppath;
1340 if (!current_view->available())
1343 current_view->buffer()->makeDocBookFile(name, 0);
1345 // Shall this code go or should it stay? (Lgb)
1346 // This code is a placeholder for future implementation. (Jose')
1347 // string add_flags;
1348 // LYX_PAPER_SIZE ps = (LYX_PAPER_SIZE) current_view->buffer()->params.papersize;
1350 // case BufferParams::PAPER_A4PAPER: add_flags = "-p a4"; break;
1351 // case BufferParams::PAPER_USLETTER: add_flags = "-p letter"; break;
1352 // default: /* nothing to be done yet ;-) */ break;
1354 ProhibitInput(current_view);
1359 case 1: /* dvi output asked */
1361 current_view->owner()->getMiniBuffer()->Set(_("Converting DocBook SGML to dvi file..."));
1362 string s2 = lyxrc.docbook_to_dvi_command + ' ' + name;
1363 if (one.startscript(Systemcalls::System, s2)) {
1366 current_view->buffer()->markDviClean();
1369 default: /* unknown output */
1373 AllowInput(current_view);
1375 current_view->buffer()->redraw();
1380 void MenuLayoutCharacter()
1382 static int ow = -1, oh;
1384 if (fd_form_character->form_character->visible) {
1385 fl_raise_form(fd_form_character->form_character);
1387 fl_show_form(fd_form_character->form_character,
1388 FL_PLACE_MOUSE | FL_FREE_SIZE, FL_FULLBORDER,
1389 _("Character Style"));
1391 ow = fd_form_character->form_character->w;
1392 oh = fd_form_character->form_character->h;
1394 fl_set_form_minsize(fd_form_character->form_character, ow, oh);
1400 void DeactivateParagraphButtons ()
1402 fl_deactivate_object (fd_form_paragraph->button_ok);
1403 fl_deactivate_object (fd_form_paragraph->button_apply);
1404 fl_set_object_lcol (fd_form_paragraph->button_ok, FL_INACTIVE);
1405 fl_set_object_lcol (fd_form_paragraph->button_apply, FL_INACTIVE);
1410 void ActivateParagraphButtons ()
1412 fl_activate_object (fd_form_paragraph->button_ok);
1413 fl_activate_object (fd_form_paragraph->button_apply);
1414 fl_set_object_lcol (fd_form_paragraph->button_ok, FL_BLACK);
1415 fl_set_object_lcol (fd_form_paragraph->button_apply, FL_BLACK);
1420 void DisableParagraphLayout ()
1422 DeactivateParagraphButtons();
1423 fl_deactivate_object (fd_form_paragraph->input_labelwidth);
1424 fl_deactivate_object (fd_form_paragraph->check_lines_top);
1425 fl_deactivate_object (fd_form_paragraph->check_lines_bottom);
1426 fl_deactivate_object (fd_form_paragraph->check_pagebreaks_top);
1427 fl_deactivate_object (fd_form_paragraph->check_pagebreaks_bottom);
1428 fl_deactivate_object (fd_form_paragraph->check_noindent);
1429 fl_deactivate_object (fd_form_paragraph->group_radio_alignment);
1430 fl_deactivate_object (fd_form_paragraph->radio_align_right);
1431 fl_deactivate_object (fd_form_paragraph->radio_align_left);
1432 fl_deactivate_object (fd_form_paragraph->radio_align_block);
1433 fl_deactivate_object (fd_form_paragraph->radio_align_center);
1434 fl_deactivate_object (fd_form_paragraph->input_space_above);
1435 fl_deactivate_object (fd_form_paragraph->input_space_below);
1436 fl_deactivate_object (fd_form_paragraph->choice_space_above);
1437 fl_deactivate_object (fd_form_paragraph->choice_space_below);
1438 fl_deactivate_object (fd_form_paragraph->check_space_above);
1439 fl_deactivate_object (fd_form_paragraph->check_space_below);
1444 void EnableParagraphLayout ()
1446 ActivateParagraphButtons();
1447 fl_activate_object (fd_form_paragraph->input_labelwidth);
1448 fl_activate_object (fd_form_paragraph->check_lines_top);
1449 fl_activate_object (fd_form_paragraph->check_lines_bottom);
1450 fl_activate_object (fd_form_paragraph->check_pagebreaks_top);
1451 fl_activate_object (fd_form_paragraph->check_pagebreaks_bottom);
1452 fl_activate_object (fd_form_paragraph->check_noindent);
1453 fl_activate_object (fd_form_paragraph->group_radio_alignment);
1454 fl_activate_object (fd_form_paragraph->radio_align_right);
1455 fl_activate_object (fd_form_paragraph->radio_align_left);
1456 fl_activate_object (fd_form_paragraph->radio_align_block);
1457 fl_activate_object (fd_form_paragraph->radio_align_center);
1458 fl_activate_object (fd_form_paragraph->input_space_above);
1459 fl_activate_object (fd_form_paragraph->input_space_below);
1460 fl_activate_object (fd_form_paragraph->choice_space_above);
1461 fl_activate_object (fd_form_paragraph->choice_space_below);
1462 fl_activate_object (fd_form_paragraph->check_space_above);
1463 fl_activate_object (fd_form_paragraph->check_space_below);
1467 bool UpdateLayoutParagraph()
1469 if (!current_view->available()) {
1470 if (fd_form_paragraph->form_paragraph->visible)
1471 fl_hide_form(fd_form_paragraph->form_paragraph);
1475 Buffer * buf = current_view->buffer();
1477 fl_set_input(fd_form_paragraph->input_labelwidth,
1478 current_view->text->cursor.par->GetLabelWidthString().c_str());
1479 fl_set_button(fd_form_paragraph->radio_align_right, 0);
1480 fl_set_button(fd_form_paragraph->radio_align_left, 0);
1481 fl_set_button(fd_form_paragraph->radio_align_center, 0);
1482 fl_set_button(fd_form_paragraph->radio_align_block, 0);
1484 int align = current_view->text->cursor.par->GetAlign();
1485 if (align == LYX_ALIGN_LAYOUT)
1486 align = textclasslist.Style(buf->params.textclass,
1487 current_view->text->cursor.par->GetLayout()).align;
1490 case LYX_ALIGN_RIGHT:
1491 fl_set_button(fd_form_paragraph->radio_align_right, 1);
1493 case LYX_ALIGN_LEFT:
1494 fl_set_button(fd_form_paragraph->radio_align_left, 1);
1496 case LYX_ALIGN_CENTER:
1497 fl_set_button(fd_form_paragraph->radio_align_center, 1);
1500 fl_set_button(fd_form_paragraph->radio_align_block, 1);
1504 fl_set_button(fd_form_paragraph->check_lines_top,
1505 current_view->text->cursor.par->FirstPhysicalPar()->line_top);
1506 fl_set_button(fd_form_paragraph->check_lines_bottom,
1507 current_view->text->cursor.par->FirstPhysicalPar()->line_bottom);
1508 fl_set_button(fd_form_paragraph->check_pagebreaks_top,
1509 current_view->text->cursor.par->FirstPhysicalPar()->pagebreak_top);
1510 fl_set_button(fd_form_paragraph->check_pagebreaks_bottom,
1511 current_view->text->cursor.par->FirstPhysicalPar()->pagebreak_bottom);
1512 fl_set_button(fd_form_paragraph->check_noindent,
1513 current_view->text->cursor.par->FirstPhysicalPar()->noindent);
1514 fl_set_input (fd_form_paragraph->input_space_above, "");
1516 switch (current_view->text->cursor.par->FirstPhysicalPar()->added_space_top.kind()) {
1518 fl_set_choice (fd_form_paragraph->choice_space_above, 1);
1520 case VSpace::DEFSKIP:
1521 fl_set_choice (fd_form_paragraph->choice_space_above, 2);
1523 case VSpace::SMALLSKIP:
1524 fl_set_choice (fd_form_paragraph->choice_space_above, 3);
1526 case VSpace::MEDSKIP:
1527 fl_set_choice (fd_form_paragraph->choice_space_above, 4);
1529 case VSpace::BIGSKIP:
1530 fl_set_choice (fd_form_paragraph->choice_space_above, 5);
1533 fl_set_choice (fd_form_paragraph->choice_space_above, 6);
1535 case VSpace::LENGTH:
1536 fl_set_choice (fd_form_paragraph->choice_space_above, 7);
1537 fl_set_input (fd_form_paragraph->input_space_above,
1538 current_view->text->cursor.par->FirstPhysicalPar()->added_space_top.length().asString().c_str());
1541 fl_set_button (fd_form_paragraph->check_space_above,
1542 current_view->text->cursor.par->FirstPhysicalPar()->added_space_top.keep());
1543 fl_set_input (fd_form_paragraph->input_space_below, "");
1544 switch (current_view->text->cursor.par->FirstPhysicalPar()->added_space_bottom.kind()) {
1546 fl_set_choice (fd_form_paragraph->choice_space_below,
1549 case VSpace::DEFSKIP:
1550 fl_set_choice (fd_form_paragraph->choice_space_below,
1553 case VSpace::SMALLSKIP:
1554 fl_set_choice (fd_form_paragraph->choice_space_below,
1557 case VSpace::MEDSKIP:
1558 fl_set_choice (fd_form_paragraph->choice_space_below,
1561 case VSpace::BIGSKIP:
1562 fl_set_choice (fd_form_paragraph->choice_space_below,
1566 fl_set_choice (fd_form_paragraph->choice_space_below,
1569 case VSpace::LENGTH:
1570 fl_set_choice (fd_form_paragraph->choice_space_below,
1572 fl_set_input (fd_form_paragraph->input_space_below,
1573 current_view->text->cursor.par->FirstPhysicalPar()->added_space_bottom.length().asString().c_str());
1576 fl_set_button (fd_form_paragraph->check_space_below,
1577 current_view->text->cursor.par->FirstPhysicalPar()->added_space_bottom.keep());
1579 fl_set_button(fd_form_paragraph->check_noindent,
1580 current_view->text->cursor.par->FirstPhysicalPar()->noindent);
1582 if (current_view->buffer()->isReadonly()) {
1583 DisableParagraphLayout();
1585 EnableParagraphLayout();
1591 void MenuLayoutParagraph()
1593 if (UpdateLayoutParagraph()) {
1594 if (fd_form_paragraph->form_paragraph->visible) {
1595 fl_raise_form(fd_form_paragraph->form_paragraph);
1597 fl_show_form(fd_form_paragraph->form_paragraph,
1598 FL_PLACE_MOUSE, FL_FULLBORDER,
1599 _("Paragraph Environment"));
1606 void DeactivateDocumentButtons ()
1608 fl_deactivate_object (fd_form_document->button_ok);
1609 fl_deactivate_object (fd_form_document->button_apply);
1610 fl_set_object_lcol (fd_form_document->button_ok, FL_INACTIVE);
1611 fl_set_object_lcol (fd_form_document->button_apply, FL_INACTIVE);
1616 void ActivateDocumentButtons ()
1618 fl_activate_object (fd_form_document->button_ok);
1619 fl_activate_object (fd_form_document->button_apply);
1620 fl_set_object_lcol (fd_form_document->button_ok, FL_BLACK);
1621 fl_set_object_lcol (fd_form_document->button_apply, FL_BLACK);
1626 void DisableDocumentLayout ()
1628 DeactivateDocumentButtons ();
1629 fl_deactivate_object (fd_form_document->group_radio_separation);
1630 fl_deactivate_object (fd_form_document->radio_indent);
1631 fl_deactivate_object (fd_form_document->radio_skip);
1632 fl_deactivate_object (fd_form_document->choice_class);
1633 fl_deactivate_object (fd_form_document->choice_pagestyle);
1634 fl_deactivate_object (fd_form_document->choice_fonts);
1635 fl_deactivate_object (fd_form_document->choice_fontsize);
1636 fl_deactivate_object (fd_form_document->input_float_placement);
1637 fl_deactivate_object (fd_form_document->choice_postscript_driver);
1638 fl_deactivate_object (fd_form_document->choice_inputenc);
1639 fl_deactivate_object (fd_form_document->group_radio_sides);
1640 fl_deactivate_object (fd_form_document->radio_sides_one);
1641 fl_deactivate_object (fd_form_document->radio_sides_two);
1642 fl_deactivate_object (fd_form_document->group_radio_columns);
1643 fl_deactivate_object (fd_form_document->radio_columns_one);
1644 fl_deactivate_object (fd_form_document->radio_columns_two);
1645 fl_deactivate_object (fd_form_document->input_extra);
1646 fl_deactivate_object (fd_form_document->choice_language);
1647 combo_language->deactivate();
1648 fl_deactivate_object (fd_form_document->input_default_skip);
1649 fl_deactivate_object (fd_form_document->choice_default_skip);
1650 fl_deactivate_object (fd_form_document->slider_secnumdepth);
1651 fl_deactivate_object (fd_form_document->slider_tocdepth);
1652 fl_deactivate_object (fd_form_document->choice_spacing);
1653 fl_deactivate_object (fd_form_document->input_spacing);
1654 fl_deactivate_object (fd_form_document->check_use_amsmath);
1659 void EnableDocumentLayout ()
1661 ActivateDocumentButtons ();
1662 fl_activate_object (fd_form_document->group_radio_separation);
1663 fl_activate_object (fd_form_document->radio_indent);
1664 fl_activate_object (fd_form_document->radio_skip);
1665 fl_activate_object (fd_form_document->choice_class);
1666 fl_activate_object (fd_form_document->choice_pagestyle);
1667 fl_activate_object (fd_form_document->choice_fonts);
1668 fl_activate_object (fd_form_document->choice_fontsize);
1669 fl_activate_object (fd_form_document->input_float_placement);
1670 fl_activate_object (fd_form_document->choice_postscript_driver);
1671 fl_activate_object (fd_form_document->choice_inputenc);
1672 fl_activate_object (fd_form_document->group_radio_sides);
1673 fl_activate_object (fd_form_document->radio_sides_one);
1674 fl_activate_object (fd_form_document->radio_sides_two);
1675 fl_activate_object (fd_form_document->group_radio_columns);
1676 fl_activate_object (fd_form_document->radio_columns_one);
1677 fl_activate_object (fd_form_document->radio_columns_two);
1678 fl_activate_object (fd_form_document->input_extra);
1679 fl_activate_object (fd_form_document->choice_language);
1680 combo_language->activate();
1681 fl_activate_object (fd_form_document->input_default_skip);
1682 fl_activate_object (fd_form_document->choice_default_skip);
1683 fl_activate_object (fd_form_document->slider_secnumdepth);
1684 fl_activate_object (fd_form_document->slider_tocdepth);
1685 fl_activate_object (fd_form_document->choice_spacing);
1686 fl_activate_object (fd_form_document->input_spacing);
1687 fl_activate_object (fd_form_document->check_use_amsmath);
1691 bool UpdateLayoutDocument(BufferParams * params)
1693 if (!current_view->available()) {
1694 if (fd_form_document->form_document->visible)
1695 fl_hide_form(fd_form_document->form_document);
1700 params = ¤t_view->buffer()->params;
1701 LyXTextClass const & tclass = textclasslist.TextClass(params->textclass);
1703 fl_set_choice_text(fd_form_document->choice_class,
1704 textclasslist.DescOfClass(params->textclass).c_str());
1705 combo_language->select_text(params->language.c_str());
1707 fl_set_choice_text(fd_form_document->choice_fonts,
1708 params->fonts.c_str());
1709 fl_set_choice_text(fd_form_document->choice_inputenc,
1710 params->inputenc.c_str());
1711 fl_set_choice_text(fd_form_document->choice_postscript_driver,
1712 params->graphicsDriver.c_str());
1714 // ale970405+lasgoutt970513
1715 fl_clear_choice(fd_form_document->choice_fontsize);
1716 fl_addto_choice(fd_form_document->choice_fontsize, "default");
1717 fl_addto_choice(fd_form_document->choice_fontsize,
1718 tclass.opt_fontsize().c_str());
1719 fl_set_choice(fd_form_document->choice_fontsize,
1720 tokenPos(tclass.opt_fontsize(), '|', params->fontsize) + 2);
1722 // ale970405+lasgoutt970513
1723 fl_clear_choice(fd_form_document->choice_pagestyle);
1724 fl_addto_choice(fd_form_document->choice_pagestyle, "default");
1725 fl_addto_choice(fd_form_document->choice_pagestyle,
1726 tclass.opt_pagestyle().c_str());
1728 fl_set_choice(fd_form_document->choice_pagestyle,
1729 tokenPos(tclass.opt_pagestyle(), '|', params->pagestyle) + 2);
1731 fl_set_button(fd_form_document->radio_indent, 0);
1732 fl_set_button(fd_form_document->radio_skip, 0);
1735 fl_set_button(fd_form_document->check_use_amsmath, params->use_amsmath);
1737 if (params->paragraph_separation == BufferParams::PARSEP_INDENT)
1738 fl_set_button(fd_form_document->radio_indent, 1);
1740 fl_set_button(fd_form_document->radio_skip, 1);
1742 switch (params->getDefSkip().kind()) {
1743 case VSpace::SMALLSKIP:
1744 fl_set_choice (fd_form_document->choice_default_skip, 1);
1746 case VSpace::MEDSKIP:
1747 fl_set_choice (fd_form_document->choice_default_skip, 2);
1749 case VSpace::BIGSKIP:
1750 fl_set_choice (fd_form_document->choice_default_skip, 3);
1752 case VSpace::LENGTH:
1753 fl_set_choice (fd_form_document->choice_default_skip, 4);
1754 fl_set_input (fd_form_document->input_default_skip,
1755 params->getDefSkip().asLyXCommand().c_str());
1758 fl_set_choice (fd_form_document->choice_default_skip, 2);
1762 fl_set_button(fd_form_document->radio_sides_one, 0);
1763 fl_set_button(fd_form_document->radio_sides_two, 0);
1765 switch (params->sides) {
1766 case LyXTextClass::OneSide:
1767 fl_set_button(fd_form_document->radio_sides_one, 1);
1769 case LyXTextClass::TwoSides:
1770 fl_set_button(fd_form_document->radio_sides_two, 1);
1774 fl_set_button(fd_form_document->radio_columns_one, 0);
1775 fl_set_button(fd_form_document->radio_columns_two, 0);
1777 if (params->columns == 2)
1778 fl_set_button(fd_form_document->radio_columns_two, 1);
1780 fl_set_button(fd_form_document->radio_columns_one, 1);
1782 fl_set_input(fd_form_document->input_spacing, "");
1783 switch (params->spacing.getSpace()) {
1784 case Spacing::Default: // nothing bad should happen with this
1785 case Spacing::Single:
1788 fl_set_choice(fd_form_document->choice_spacing, 1);
1791 case Spacing::Onehalf:
1794 fl_set_choice(fd_form_document->choice_spacing, 2);
1797 case Spacing::Double:
1800 fl_set_choice(fd_form_document->choice_spacing, 3);
1803 case Spacing::Other:
1805 fl_set_choice(fd_form_document->choice_spacing, 4);
1807 //sprintf(sval, "%g", params->spacing.getValue());
1809 std::ostringstream sval;
1810 sval << params->spacing.getValue(); // setw?
1811 fl_set_input(fd_form_document->input_spacing,
1812 sval.str().c_str());
1815 ostrstream sval(tval, 20);
1816 sval << params->spacing.getValue() << '\0'; // setw?
1817 fl_set_input(fd_form_document->input_spacing, sval.str());
1824 fl_set_counter_value(fd_form_document->slider_secnumdepth,
1825 params->secnumdepth);
1826 fl_set_counter_value(fd_form_document->slider_tocdepth,
1828 if (!params->float_placement.empty()) { // buffer local (Lgb)
1829 fl_set_input(fd_form_document->input_float_placement,
1830 params->float_placement.c_str());
1832 fl_set_input(fd_form_document->input_float_placement, "");
1834 if (!params->options.empty())
1835 fl_set_input(fd_form_document->input_extra,
1836 params->options.c_str());
1838 fl_set_input(fd_form_document->input_extra, "");
1840 if (current_view->buffer()->isSGML()) {
1841 // bullets not used in SGML derived documents
1842 fl_deactivate_object(fd_form_document->button_bullets);
1843 fl_set_object_lcol(fd_form_document->button_bullets,
1846 fl_activate_object(fd_form_document->button_bullets);
1847 fl_set_object_lcol(fd_form_document->button_bullets,
1851 if (current_view->buffer()->isReadonly()) {
1852 DisableDocumentLayout();
1854 EnableDocumentLayout();
1861 void MenuLayoutDocument()
1863 if (UpdateLayoutDocument()) {
1864 if (fd_form_document->form_document->visible) {
1865 fl_raise_form(fd_form_document->form_document);
1867 fl_show_form(fd_form_document->form_document,
1868 FL_PLACE_MOUSE, FL_FULLBORDER,
1869 _("Document Layout"));
1875 bool UpdateLayoutQuotes()
1878 if (!current_view->available()
1879 || current_view->buffer()->isReadonly())
1883 fl_set_choice(fd_form_quotes->choice_quotes_language,
1884 current_view->buffer()->params.quotes_language + 1);
1885 fl_set_button(fd_form_quotes->radio_single, 0);
1886 fl_set_button(fd_form_quotes->radio_double, 0);
1888 if (current_view->buffer()->params.quotes_times == InsetQuotes::SingleQ)
1889 fl_set_button(fd_form_quotes->radio_single, 1);
1891 fl_set_button(fd_form_quotes->radio_double, 1);
1892 } else if (fd_form_quotes->form_quotes->visible) {
1893 fl_hide_form(fd_form_quotes->form_quotes);
1899 void MenuLayoutQuotes()
1901 if (UpdateLayoutQuotes()) {
1902 if (fd_form_quotes->form_quotes->visible) {
1903 fl_raise_form(fd_form_quotes->form_quotes);
1905 fl_show_form(fd_form_quotes->form_quotes,
1906 FL_PLACE_MOUSE, FL_FULLBORDER,
1913 bool UpdateLayoutPreamble()
1916 if (!current_view->available())
1920 fl_set_input(fd_form_preamble->input_preamble,
1921 current_view->buffer()->params.preamble.c_str());
1923 if (current_view->buffer()->isReadonly()) {
1924 fl_deactivate_object(fd_form_preamble->input_preamble);
1925 fl_deactivate_object(fd_form_preamble->button_ok);
1926 fl_deactivate_object(fd_form_preamble->button_apply);
1927 fl_set_object_lcol(fd_form_preamble->button_ok, FL_INACTIVE);
1928 fl_set_object_lcol(fd_form_preamble->button_apply, FL_INACTIVE);
1931 fl_activate_object(fd_form_preamble->input_preamble);
1932 fl_activate_object(fd_form_preamble->button_ok);
1933 fl_activate_object(fd_form_preamble->button_apply);
1934 fl_set_object_lcol(fd_form_preamble->button_ok, FL_BLACK);
1935 fl_set_object_lcol(fd_form_preamble->button_apply, FL_BLACK);
1937 } else if (fd_form_preamble->form_preamble->visible) {
1938 fl_hide_form(fd_form_preamble->form_preamble);
1944 void MenuLayoutPreamble()
1946 static int ow = -1, oh;
1948 if (UpdateLayoutPreamble()) {
1949 if (fd_form_preamble->form_preamble->visible) {
1950 fl_raise_form(fd_form_preamble->form_preamble);
1952 fl_show_form(fd_form_preamble->form_preamble,
1953 FL_PLACE_MOUSE | FL_FREE_SIZE,
1955 _("LaTeX Preamble"));
1957 ow = fd_form_preamble->form_preamble->w;
1958 oh = fd_form_preamble->form_preamble->h;
1960 fl_set_form_minsize(fd_form_preamble->form_preamble,
1967 void MenuLayoutSave()
1969 if (!current_view->available())
1972 if (AskQuestion(_("Do you want to save the current settings"),
1973 _("for Character, Document, Paper and Quotes"),
1974 _("as default for new documents?")))
1975 current_view->buffer()->saveParamsAsDefaults();
1979 // This is both GUI and LyXFont dependent. Don't know where to put it. (Asger)
1980 // Well, it's mostly GUI dependent, so I guess it will stay here. (Asger)
1981 LyXFont UserFreeFont()
1983 LyXFont font(LyXFont::ALL_IGNORE);
1985 int pos = fl_get_choice(fd_form_character->choice_family);
1987 case 1: font.setFamily(LyXFont::IGNORE_FAMILY); break;
1988 case 2: font.setFamily(LyXFont::ROMAN_FAMILY); break;
1989 case 3: font.setFamily(LyXFont::SANS_FAMILY); break;
1990 case 4: font.setFamily(LyXFont::TYPEWRITER_FAMILY); break;
1991 case 5: font.setFamily(LyXFont::INHERIT_FAMILY); break;
1994 pos = fl_get_choice(fd_form_character->choice_series);
1996 case 1: font.setSeries(LyXFont::IGNORE_SERIES); break;
1997 case 2: font.setSeries(LyXFont::MEDIUM_SERIES); break;
1998 case 3: font.setSeries(LyXFont::BOLD_SERIES); break;
1999 case 4: font.setSeries(LyXFont::INHERIT_SERIES); break;
2002 pos = fl_get_choice(fd_form_character->choice_shape);
2004 case 1: font.setShape(LyXFont::IGNORE_SHAPE); break;
2005 case 2: font.setShape(LyXFont::UP_SHAPE); break;
2006 case 3: font.setShape(LyXFont::ITALIC_SHAPE); break;
2007 case 4: font.setShape(LyXFont::SLANTED_SHAPE); break;
2008 case 5: font.setShape(LyXFont::SMALLCAPS_SHAPE); break;
2009 case 6: font.setShape(LyXFont::INHERIT_SHAPE); break;
2012 pos = fl_get_choice(fd_form_character->choice_size);
2014 case 1: font.setSize(LyXFont::IGNORE_SIZE); break;
2015 case 2: font.setSize(LyXFont::SIZE_TINY); break;
2016 case 3: font.setSize(LyXFont::SIZE_SCRIPT); break;
2017 case 4: font.setSize(LyXFont::SIZE_FOOTNOTE); break;
2018 case 5: font.setSize(LyXFont::SIZE_SMALL); break;
2019 case 6: font.setSize(LyXFont::SIZE_NORMAL); break;
2020 case 7: font.setSize(LyXFont::SIZE_LARGE); break;
2021 case 8: font.setSize(LyXFont::SIZE_LARGER); break;
2022 case 9: font.setSize(LyXFont::SIZE_LARGEST); break;
2023 case 10: font.setSize(LyXFont::SIZE_HUGE); break;
2024 case 11: font.setSize(LyXFont::SIZE_HUGER); break;
2025 case 12: font.setSize(LyXFont::INCREASE_SIZE); break;
2026 case 13: font.setSize(LyXFont::DECREASE_SIZE); break;
2027 case 14: font.setSize(LyXFont::INHERIT_SIZE); break;
2030 pos = fl_get_choice(fd_form_character->choice_bar);
2032 case 1: font.setEmph(LyXFont::IGNORE);
2033 font.setUnderbar(LyXFont::IGNORE);
2034 font.setNoun(LyXFont::IGNORE);
2035 font.setLatex(LyXFont::IGNORE);
2037 case 2: font.setEmph(LyXFont::TOGGLE); break;
2038 case 3: font.setUnderbar(LyXFont::TOGGLE); break;
2039 case 4: font.setNoun(LyXFont::TOGGLE); break;
2040 case 5: font.setLatex(LyXFont::TOGGLE); break;
2041 case 6: font.setEmph(LyXFont::INHERIT);
2042 font.setUnderbar(LyXFont::INHERIT);
2043 font.setNoun(LyXFont::INHERIT);
2044 font.setLatex(LyXFont::INHERIT);
2048 pos = fl_get_choice(fd_form_character->choice_color);
2050 case 1: font.setColor(LColor::ignore); break;
2051 case 2: font.setColor(LColor::none); break;
2052 case 3: font.setColor(LColor::black); break;
2053 case 4: font.setColor(LColor::white); break;
2054 case 5: font.setColor(LColor::red); break;
2055 case 6: font.setColor(LColor::green); break;
2056 case 7: font.setColor(LColor::blue); break;
2057 case 8: font.setColor(LColor::cyan); break;
2058 case 9: font.setColor(LColor::magenta); break;
2059 case 10: font.setColor(LColor::yellow); break;
2060 case 11: font.setColor(LColor::inherit); break;
2063 string language = combo_language2->getline();
2064 Languages::iterator lit = languages.find(language);
2065 if (lit != languages.end())
2066 font.setLanguage(&(*lit).second);
2068 font.setLanguage(ignore_language);
2077 /* callbacks for form form_title */
2078 extern "C" void TimerCB(FL_OBJECT *, long)
2080 // only if the form still exists
2081 if (lyxrc.show_banner && fd_form_title->form_title != 0) {
2082 if (fd_form_title->form_title->visible) {
2083 fl_hide_form(fd_form_title->form_title);
2085 fl_free_form(fd_form_title->form_title);
2086 fd_form_title->form_title = 0;
2091 /* callbacks for form form_paragraph */
2093 extern "C" void ParagraphVSpaceCB(FL_OBJECT * obj, long )
2095 // "Synchronize" the choices and input fields, making it
2096 // impossible to commit senseless data.
2098 FD_form_paragraph const * fp = fd_form_paragraph;
2100 if (obj == fp->choice_space_above) {
2101 if (fl_get_choice (fp->choice_space_above) != 7) {
2102 fl_set_input (fp->input_space_above, "");
2103 ActivateParagraphButtons();
2105 } else if (obj == fp->choice_space_below) {
2106 if (fl_get_choice (fp->choice_space_below) != 7) {
2107 fl_set_input (fp->input_space_below, "");
2108 ActivateParagraphButtons();
2110 } else if (obj == fp->input_space_above) {
2111 string input = fl_get_input (fp->input_space_above);
2113 if (input.empty()) {
2114 fl_set_choice (fp->choice_space_above, 1);
2115 ActivateParagraphButtons();
2117 else if (isValidGlueLength (input)) {
2118 fl_set_choice (fp->choice_space_above, 7);
2119 ActivateParagraphButtons();
2122 fl_set_choice (fp->choice_space_above, 7);
2123 DeactivateParagraphButtons();
2125 } else if (obj == fp->input_space_below) {
2126 string input = fl_get_input (fp->input_space_below);
2128 if (input.empty()) {
2129 fl_set_choice (fp->choice_space_below, 1);
2130 ActivateParagraphButtons();
2132 else if (isValidGlueLength (input)) {
2133 fl_set_choice (fp->choice_space_below, 7);
2134 ActivateParagraphButtons();
2137 fl_set_choice (fp->choice_space_below, 7);
2138 DeactivateParagraphButtons();
2144 extern "C" void ParagraphApplyCB(FL_OBJECT *, long)
2146 if (!current_view->available())
2149 VSpace space_top, space_bottom;
2151 string labelwidthstring;
2154 // If a vspace kind is "Length" but there's no text in
2155 // the input field, reset the kind to "None".
2156 if (fl_get_choice (fd_form_paragraph->choice_space_above) == 7
2157 && !*(fl_get_input (fd_form_paragraph->input_space_above))) {
2158 fl_set_choice (fd_form_paragraph->choice_space_above, 1);
2160 if (fl_get_choice (fd_form_paragraph->choice_space_below) == 7
2161 && !*(fl_get_input (fd_form_paragraph->input_space_below))) {
2162 fl_set_choice (fd_form_paragraph->choice_space_below, 1);
2165 bool line_top = fl_get_button(fd_form_paragraph->check_lines_top);
2166 bool line_bottom = fl_get_button(fd_form_paragraph->check_lines_bottom);
2167 bool pagebreak_top = fl_get_button(fd_form_paragraph->check_pagebreaks_top);
2168 bool pagebreak_bottom = fl_get_button(fd_form_paragraph->check_pagebreaks_bottom);
2169 switch (fl_get_choice (fd_form_paragraph->choice_space_above)) {
2170 case 1: space_top = VSpace(VSpace::NONE); break;
2171 case 2: space_top = VSpace(VSpace::DEFSKIP); break;
2172 case 3: space_top = VSpace(VSpace::SMALLSKIP); break;
2173 case 4: space_top = VSpace(VSpace::MEDSKIP); break;
2174 case 5: space_top = VSpace(VSpace::BIGSKIP); break;
2175 case 6: space_top = VSpace(VSpace::VFILL); break;
2176 case 7: space_top = VSpace(LyXGlueLength (fl_get_input (fd_form_paragraph->input_space_above))); break;
2178 if (fl_get_button (fd_form_paragraph->check_space_above))
2179 space_top.setKeep (true);
2180 switch (fl_get_choice (fd_form_paragraph->choice_space_below)) {
2181 case 1: space_bottom = VSpace(VSpace::NONE); break;
2182 case 2: space_bottom = VSpace(VSpace::DEFSKIP); break;
2183 case 3: space_bottom = VSpace(VSpace::SMALLSKIP); break;
2184 case 4: space_bottom = VSpace(VSpace::MEDSKIP); break;
2185 case 5: space_bottom = VSpace(VSpace::BIGSKIP); break;
2186 case 6: space_bottom = VSpace(VSpace::VFILL); break;
2187 case 7: space_bottom = VSpace(LyXGlueLength (fl_get_input (fd_form_paragraph->input_space_below))); break;
2189 if (fl_get_button (fd_form_paragraph->check_space_below))
2190 space_bottom.setKeep (true);
2192 if (fl_get_button(fd_form_paragraph->radio_align_left))
2193 align = LYX_ALIGN_LEFT;
2194 else if (fl_get_button(fd_form_paragraph->radio_align_right))
2195 align = LYX_ALIGN_RIGHT;
2196 else if (fl_get_button(fd_form_paragraph->radio_align_center))
2197 align = LYX_ALIGN_CENTER;
2199 align = LYX_ALIGN_BLOCK;
2201 labelwidthstring = fl_get_input(fd_form_paragraph->input_labelwidth);
2202 noindent = fl_get_button(fd_form_paragraph->check_noindent);
2204 current_view->text->SetParagraph(line_top,
2213 current_view->update(1);
2214 current_view->owner()->getMiniBuffer()->Set(_("Paragraph layout set"));
2218 extern "C" void ParagraphCancelCB(FL_OBJECT *, long)
2220 fl_hide_form(fd_form_paragraph->form_paragraph);
2224 extern "C" void ParagraphOKCB(FL_OBJECT *ob, long data)
2226 ParagraphApplyCB(ob, data);
2227 ParagraphCancelCB(ob, data);
2231 /* callbacks for form form_character */
2233 extern "C" void CharacterApplyCB(FL_OBJECT *, long)
2235 // we set toggleall locally here, since it should be true for
2236 // all other uses of ToggleAndShow() (JMarc)
2237 toggleall = fl_get_button(fd_form_character->check_toggle_all);
2238 ToggleAndShow(current_view, UserFreeFont());
2239 current_view->setState();
2244 extern "C" void CharacterCloseCB(FL_OBJECT *, long)
2246 fl_hide_form(fd_form_character->form_character);
2250 extern "C" void CharacterOKCB(FL_OBJECT *ob, long data)
2252 CharacterApplyCB(ob, data);
2253 CharacterCloseCB(ob, data);
2257 /* callbacks for form form_document */
2259 void UpdateDocumentButtons(BufferParams const & params)
2261 fl_set_choice(fd_form_document->choice_pagestyle, 1);
2263 switch (params.sides) {
2264 case LyXTextClass::OneSide:
2265 fl_set_button(fd_form_document->radio_sides_one, 1);
2267 case LyXTextClass::TwoSides:
2268 fl_set_button(fd_form_document->radio_sides_two, 1);
2272 if (params.columns == 2)
2273 fl_set_button(fd_form_document->radio_columns_two, 1);
2275 fl_set_button(fd_form_document->radio_columns_one, 1);
2277 fl_set_input(fd_form_document->input_extra, params.options.c_str());
2278 fl_set_counter_value(fd_form_document->slider_secnumdepth,
2279 params.secnumdepth);
2280 fl_set_counter_value(fd_form_document->slider_tocdepth,
2285 extern "C" void ChoiceClassCB(FL_OBJECT * ob, long)
2287 ProhibitInput(current_view);
2288 if (textclasslist.Load(fl_get_choice(ob)-1)) {
2289 if (AskQuestion(_("Should I set some parameters to"),
2290 fl_get_choice_text(ob),
2291 _("the defaults of this document class?"))) {
2292 BufferParams params = BufferParams();
2293 params.textclass = fl_get_choice(ob)-1;
2294 params.useClassDefaults();
2295 UpdateLayoutDocument(¶ms);
2296 UpdateDocumentButtons(params);
2299 // unable to load new style
2300 WriteAlert(_("Conversion Errors!"),
2301 _("Unable to switch to new document class."),
2302 _("Reverting to original document class."));
2303 fl_set_choice(fd_form_document->choice_class,
2304 current_view->buffer()->params.textclass + 1);
2306 AllowInput(current_view);
2310 extern "C" void DocumentDefskipCB(FL_OBJECT * obj, long)
2312 // "Synchronize" the choice and the input field, so that it
2313 // is impossible to commit senseless data.
2314 FD_form_document const * fd = fd_form_document;
2316 if (obj == fd->choice_default_skip) {
2317 if (fl_get_choice (fd->choice_default_skip) != 4) {
2318 fl_set_input (fd->input_default_skip, "");
2319 ActivateDocumentButtons();
2321 } else if (obj == fd->input_default_skip) {
2323 char const * input = fl_get_input (fd->input_default_skip);
2326 fl_set_choice (fd->choice_default_skip, 2);
2327 ActivateDocumentButtons();
2328 } else if (isValidGlueLength (input)) {
2329 fl_set_choice (fd->choice_default_skip, 4);
2330 ActivateDocumentButtons();
2332 fl_set_choice (fd->choice_default_skip, 4);
2333 DeactivateDocumentButtons();
2339 extern "C" void DocumentSpacingCB(FL_OBJECT * obj, long)
2341 // "Synchronize" the choice and the input field, so that it
2342 // is impossible to commit senseless data.
2343 FD_form_document const * fd = fd_form_document;
2345 if (obj == fd->choice_spacing
2346 && fl_get_choice (fd->choice_spacing) != 4) {
2347 fl_set_input(fd->input_spacing, "");
2348 } else if (obj == fd->input_spacing) {
2350 const char* input = fl_get_input (fd->input_spacing);
2353 fl_set_choice (fd->choice_spacing, 1);
2355 fl_set_choice (fd->choice_spacing, 4);
2361 extern "C" void DocumentApplyCB(FL_OBJECT *, long)
2364 BufferParams * params = &(current_view->buffer()->params);
2366 Language const * old_language = params->language_info;
2367 params->language = combo_language->getline();
2368 Languages::iterator lit = languages.find(params->language);
2370 Language const * new_language;
2371 if (lit != languages.end())
2372 new_language = &(*lit).second;
2374 new_language = default_language;
2376 if (current_view->available()) {
2377 if (old_language != new_language &&
2378 old_language->RightToLeft == new_language->RightToLeft &&
2379 ! current_view->buffer()->isMultiLingual() ) {
2380 current_view->buffer()->ChangeLanguage(old_language,
2382 current_view->buffer()->redraw();
2385 params->language_info = new_language;
2387 // If default skip is a "Length" but there's no text in the
2388 // input field, reset the kind to "Medskip", which is the default.
2389 if (fl_get_choice (fd_form_document->choice_default_skip) == 4
2390 && !*(fl_get_input (fd_form_document->input_default_skip))) {
2391 fl_set_choice (fd_form_document->choice_default_skip, 2);
2394 /* this shouldn't be done automatically IMO. For example I write german
2395 * documents with an american keyboard very often. Matthias */
2397 /* ChangeKeymap(buffer->parameters.language, TRUE, false,
2398 fl_get_choice(fd_form_document->choice_language)); */
2400 fl_get_choice_text(fd_form_document->choice_fonts);
2402 fl_get_choice_text(fd_form_document->choice_inputenc);
2404 fl_get_choice_text(fd_form_document->choice_fontsize);
2406 fl_get_choice_text(fd_form_document->choice_pagestyle);
2407 params->graphicsDriver =
2408 fl_get_choice_text(fd_form_document->choice_postscript_driver);
2409 params->use_amsmath =
2410 fl_get_button(fd_form_document->check_use_amsmath);
2412 if (!current_view->available())
2415 current_view->text->SetCursor(current_view->text->cursor.par,
2416 current_view->text->cursor.pos);
2417 current_view->setState();
2419 LyXTextClassList::ClassList::size_type new_class =
2420 fl_get_choice(fd_form_document->choice_class) - 1;
2422 if (params->textclass != new_class) {
2423 // try to load new_class
2424 if (textclasslist.Load(new_class)) {
2425 // successfully loaded
2427 current_view->owner()->getMiniBuffer()->
2428 Set(_("Converting document to new document class..."));
2430 int ret = cap.SwitchLayoutsBetweenClasses(
2431 current_view->buffer()->params.textclass,
2433 current_view->buffer()->paragraph);
2438 s = _("One paragraph couldn't be converted");
2441 s += _(" paragraphs couldn't be converted");
2443 WriteAlert(_("Conversion Errors!"), s,
2444 _("into chosen document class"));
2447 params->textclass = new_class;
2449 // problem changing class -- warn user and retain old style
2450 WriteAlert(_("Conversion Errors!"),
2451 _("Unable to switch to new document class."),
2452 _("Reverting to original document class."));
2453 fl_set_choice(fd_form_document->choice_class, params->textclass + 1);
2457 char tmpsep = params->paragraph_separation;
2458 if (fl_get_button(fd_form_document->radio_indent))
2459 params->paragraph_separation = BufferParams::PARSEP_INDENT;
2461 params->paragraph_separation = BufferParams::PARSEP_SKIP;
2462 if (tmpsep != params->paragraph_separation)
2465 VSpace tmpdefskip = params->getDefSkip();
2466 switch (fl_get_choice (fd_form_document->choice_default_skip)) {
2467 case 1: params->setDefSkip(VSpace(VSpace::SMALLSKIP)); break;
2468 case 2: params->setDefSkip(VSpace(VSpace::MEDSKIP)); break;
2469 case 3: params->setDefSkip(VSpace(VSpace::BIGSKIP)); break;
2470 case 4: params->setDefSkip(
2471 VSpace (LyXGlueLength (fl_get_input
2472 (fd_form_document->input_default_skip))));
2474 // DocumentDefskipCB assures that this never happens
2475 default: params->setDefSkip(VSpace(VSpace::MEDSKIP)); break;
2477 if (!(tmpdefskip == params->getDefSkip()))
2480 if (fl_get_button(fd_form_document->radio_columns_two))
2481 params->columns = 2;
2483 params->columns = 1;
2484 if (fl_get_button(fd_form_document->radio_sides_two))
2485 params->sides = LyXTextClass::TwoSides;
2487 params->sides = LyXTextClass::OneSide;
2489 Spacing tmpSpacing = params->spacing;
2490 switch(fl_get_choice(fd_form_document->choice_spacing)) {
2492 lyxerr.debug() << "Spacing: SINGLE" << endl;
2493 params->spacing.set(Spacing::Single);
2496 lyxerr.debug() << "Spacing: ONEHALF" << endl;
2497 params->spacing.set(Spacing::Onehalf);
2500 lyxerr.debug() << "Spacing: DOUBLE" << endl;
2501 params->spacing.set(Spacing::Double);
2504 lyxerr.debug() << "Spacing: OTHER" << endl;
2505 params->spacing.set(Spacing::Other,
2506 fl_get_input(fd_form_document->input_spacing));
2509 if (tmpSpacing != params->spacing)
2512 signed char tmpchar =
2513 static_cast<signed char>(fl_get_counter_value(fd_form_document->slider_secnumdepth));
2514 if (params->secnumdepth != tmpchar)
2516 params->secnumdepth = tmpchar;
2519 static_cast<int>(fl_get_counter_value(fd_form_document->slider_tocdepth));
2521 params->float_placement =
2522 fl_get_input(fd_form_document->input_float_placement);
2524 // More checking should be done to ensure the string doesn't have
2525 // spaces or illegal placement characters in it. (thornley)
2528 current_view->redoCurrentBuffer();
2530 current_view->owner()->getMiniBuffer()->Set(_("Document layout set"));
2531 current_view->buffer()->markDirty();
2534 fl_get_input(fd_form_document->input_extra);
2539 extern "C" void DocumentCancelCB(FL_OBJECT *, long)
2541 fl_hide_form(fd_form_document->form_document);
2545 extern "C" void DocumentOKCB(FL_OBJECT * ob, long data)
2547 DocumentCancelCB(ob, data);
2548 DocumentApplyCB(ob, data);
2552 extern "C" void DocumentBulletsCB(FL_OBJECT *, long)
2555 // bullet callbacks etc. in bullet_panel.C -- ARRae
2559 /* callbacks for form form_quotes */
2561 extern "C" void QuotesApplyCB(FL_OBJECT *, long)
2563 if (!current_view->available())
2566 current_view->owner()->getMiniBuffer()->Set(_("Quotes type set"));
2567 InsetQuotes::quote_language lga = InsetQuotes::EnglishQ;
2568 switch(fl_get_choice(fd_form_quotes->choice_quotes_language) - 1) {
2570 lga = InsetQuotes::EnglishQ;
2573 lga = InsetQuotes::SwedishQ;
2576 lga = InsetQuotes::GermanQ;
2579 lga = InsetQuotes::PolishQ;
2582 lga = InsetQuotes::FrenchQ;
2585 lga = InsetQuotes::DanishQ;
2588 current_view->buffer()->params.quotes_language = lga;
2589 if (fl_get_button(fd_form_quotes->radio_single))
2590 current_view->buffer()->
2591 params.quotes_times = InsetQuotes::SingleQ;
2593 current_view->buffer()->
2594 params.quotes_times = InsetQuotes::DoubleQ;
2598 extern "C" void QuotesCancelCB(FL_OBJECT *, long)
2600 fl_hide_form(fd_form_quotes->form_quotes);
2604 extern "C" void QuotesOKCB(FL_OBJECT * ob, long data)
2606 QuotesApplyCB(ob, data);
2607 QuotesCancelCB(ob, data);
2612 /* callbacks for form form_preamble */
2614 extern "C" void PreambleCancelCB(FL_OBJECT *, long)
2616 fl_hide_form(fd_form_preamble->form_preamble);
2620 extern "C" void PreambleApplyCB(FL_OBJECT *, long)
2622 if (!current_view->available())
2625 current_view->buffer()->params.preamble =
2626 fl_get_input(fd_form_preamble->input_preamble);
2627 current_view->buffer()->markDirty();
2628 current_view->owner()->getMiniBuffer()->Set(_("LaTeX preamble set"));
2632 extern "C" void PreambleOKCB(FL_OBJECT * ob, long data)
2634 PreambleApplyCB(ob, data);
2635 PreambleCancelCB(ob, data);
2639 /* callbacks for form form_table */
2641 extern "C" void TableApplyCB(FL_OBJECT *, long)
2643 if (!current_view->available())
2646 // check for tables in tables
2647 if (current_view->text->cursor.par->table){
2648 WriteAlert(_("Impossible Operation!"),
2649 _("Cannot insert table in table."),
2654 current_view->owner()->getMiniBuffer()->Set(_("Inserting table..."));
2656 int ysize = int(fl_get_slider_value(fd_form_table->slider_columns) + 0.5);
2657 int xsize = int(fl_get_slider_value(fd_form_table->slider_rows) + 0.5);
2660 current_view->hideCursor();
2661 current_view->beforeChange();
2662 current_view->update(-2);
2664 current_view->text->SetCursorParUndo();
2665 current_view->text->FreezeUndo();
2667 current_view->text->BreakParagraph();
2668 current_view->update(-1);
2670 if (current_view->text->cursor.par->Last()) {
2671 current_view->text->CursorLeft();
2673 current_view->text->BreakParagraph();
2674 current_view->update(-1);
2677 current_view->text->current_font.setLatex(LyXFont::OFF);
2678 //if (!fl_get_button(fd_form_table->check_latex)){
2679 // insert the new wysiwy table
2680 current_view->text->SetLayout(0); // standard layout
2681 if (current_view->text->cursor.par->footnoteflag ==
2682 LyXParagraph::NO_FOOTNOTE) {
2684 ->SetParagraph(0, 0,
2686 VSpace (0.3 * current_view->buffer()->
2687 params.spacing.getValue(),
2689 VSpace (0.3 * current_view->buffer()->
2690 params.spacing.getValue(),
2697 ->SetParagraph(0, 0,
2699 VSpace(VSpace::NONE),
2700 VSpace(VSpace::NONE),
2706 current_view->text->cursor.par->table =
2707 new LyXTable(xsize, ysize);
2709 Language const * lang =
2710 current_view->text->cursor.par->getParLanguage();
2711 LyXFont font(LyXFont::ALL_INHERIT, lang);
2712 for (int i = 0; i < xsize * ysize - 1; ++i) {
2713 current_view->text->cursor.par->InsertChar(0, LyXParagraph::META_NEWLINE);
2714 current_view->text->cursor.par->SetFont(0, font);
2716 current_view->text->RedoParagraph();
2718 current_view->text->UnFreezeUndo();
2720 current_view->update(1);
2721 current_view->owner()->getMiniBuffer()->Set(_("Table inserted"));
2722 current_view->setState();
2726 extern "C" void TableCancelCB(FL_OBJECT *, long)
2728 fl_hide_form(fd_form_table->form_table);
2732 extern "C" void TableOKCB(FL_OBJECT * ob, long data)
2734 TableApplyCB(ob, data);
2735 TableCancelCB(ob, data);
2739 /* callbacks for form form_print */
2741 extern "C" void PrintCancelCB(FL_OBJECT *, long)
2743 fl_hide_form(fd_form_print->form_print);
2748 bool stringOnlyContains (string const & LStr, char const * cset)
2750 return LStr.find_first_not_of(cset) == string::npos;
2754 extern "C" void PrintApplyCB(FL_OBJECT *, long)
2756 if (!current_view->available())
2758 Buffer * buffer = current_view->buffer();
2759 string path = OnlyPath(buffer->fileName());
2762 if (fl_get_button(fd_form_print->radio_even_pages))
2763 pageflag = lyxrc.print_evenpage_flag + ' ';
2764 else if (fl_get_button(fd_form_print->radio_odd_pages))
2765 pageflag = lyxrc.print_oddpage_flag + ' ';
2767 // Changes by Stephan Witt (stephan.witt@beusen.de), 19-Jan-99
2768 // User may give a page (range) list
2769 // User may print multiple (unsorted) copies
2770 string pages = subst(fl_get_input(fd_form_print->input_pages), ';',',');
2771 pages = subst(pages, '+',',');
2772 pages = frontStrip(strip(pages)) ;
2773 while (!pages.empty()) { // a page range was given
2775 pages = split (pages, piece, ',') ;
2776 piece = strip(piece) ;
2777 piece = frontStrip(piece) ;
2778 if ( !stringOnlyContains (piece, "0123456789-") ) {
2779 WriteAlert(_("ERROR! Unable to print!"),
2780 _("Check 'range of pages'!"));
2783 if (piece.find('-') == string::npos) { // not found
2784 pageflag += lyxrc.print_pagerange_flag + piece + '-' + piece + ' ' ;
2785 } else if (suffixIs(piece, "-") ) { // missing last page
2786 pageflag += lyxrc.print_pagerange_flag + piece + "1000 ";
2787 } else if (prefixIs(piece, "-") ) { // missing first page
2788 pageflag += lyxrc.print_pagerange_flag + '1' + piece + ' ' ;
2790 pageflag += lyxrc.print_pagerange_flag + piece + ' ' ;
2794 string copies = frontStrip(strip(fl_get_input(fd_form_print->input_copies)));
2795 if (!copies.empty()) { // a number of copies was given
2796 if ( !stringOnlyContains (copies, "0123456789") ) {
2797 WriteAlert(_("ERROR! Unable to print!"),
2798 _("Check 'number of copies'!"));
2801 if (fl_get_button(fd_form_print->do_unsorted))
2802 pageflag += lyxrc.print_copies_flag;
2804 pageflag += lyxrc.print_collcopies_flag;
2805 pageflag += " " + copies + ' ' ;
2809 if (fl_get_button(fd_form_print->radio_order_reverse))
2810 reverseflag = lyxrc.print_reverse_flag + ' ';
2812 string orientationflag;
2813 if (buffer->params.orientation == BufferParams::ORIENTATION_LANDSCAPE)
2814 orientationflag = lyxrc.print_landscape_flag + ' ';
2816 string ps_file = fl_get_input(fd_form_print->input_file);
2817 string printer = strip(fl_get_input(fd_form_print->input_printer));
2820 if (lyxrc.print_adapt_output // printer name should be passed to dvips
2821 && ! printer.empty()) // a printer name has been given
2822 printerflag = lyxrc.print_to_printer + printer + ' ';
2825 if (!lyxrc.print_extra_options.empty())
2826 extraflags = lyxrc.print_extra_options + ' ';
2828 string command = lyxrc.print_command + ' '
2829 + printerflag + pageflag + reverseflag
2830 + orientationflag + extraflags;
2832 char real_papersize = buffer->params.papersize;
2833 if (real_papersize == BufferParams::PAPER_DEFAULT)
2834 real_papersize = lyxrc.default_papersize;
2837 switch (real_papersize) {
2838 case BufferParams::PAPER_USLETTER:
2841 case BufferParams::PAPER_A3PAPER:
2844 case BufferParams::PAPER_A4PAPER:
2847 case BufferParams::PAPER_A5PAPER:
2850 case BufferParams::PAPER_B5PAPER:
2853 case BufferParams::PAPER_EXECUTIVEPAPER:
2856 case BufferParams::PAPER_LEGALPAPER:
2859 default: /* If nothing else fits, keep an empty value... */
2863 if (buffer->params.use_geometry
2864 && buffer->params.papersize2 == BufferParams::VM_PAPER_CUSTOM
2865 && !lyxrc.print_paper_dimension_flag.empty()
2866 && !buffer->params.paperwidth.empty()
2867 && !buffer->params.paperheight.empty()) {
2868 // using a custom papersize
2870 command += lyxrc.print_paper_dimension_flag + ' ';
2871 command += buffer->params.paperwidth + ',';
2872 command += buffer->params.paperheight + ' ';
2873 } else if (!lyxrc.print_paper_flag.empty()
2875 && (real_papersize != BufferParams::PAPER_USLETTER ||
2876 buffer->params.orientation == BufferParams::ORIENTATION_PORTRAIT)) {
2877 command += " " + lyxrc.print_paper_flag + " " + paper + " ";
2879 if (fl_get_button(fd_form_print->radio_file))
2880 command += lyxrc.print_to_file
2881 + QuoteName(MakeAbsPath(ps_file, path));
2882 else if (!lyxrc.print_spool_command.empty())
2883 command += lyxrc.print_to_file
2884 + QuoteName(ps_file);
2886 // push directorypath, if necessary
2887 if (lyxrc.use_tempdir || (IsDirWriteable(path) < 1)){
2888 path = buffer->tmppath;
2893 if (!lyxrc.print_spool_command.empty() &&
2894 !fl_get_button(fd_form_print->radio_file)) {
2895 string command2 = lyxrc.print_spool_command + ' ';
2896 if (!printer.empty())
2897 command2 += lyxrc.print_spool_printerprefix
2899 // First run dvips and, if succesful, then spool command
2900 if ((result = RunScript(buffer, true, command))) {
2901 result = RunScript(buffer, false, command2, ps_file);
2904 result = RunScript(buffer, false, command);
2907 WriteAlert(_("Error:"),
2908 _("Unable to print"),
2909 _("Check that your parameters are correct"));
2913 extern "C" void PrintOKCB(FL_OBJECT * ob, long data)
2915 PrintCancelCB(ob, data);
2916 PrintApplyCB(ob, data);
2922 if (fd_form_figure->form_figure->visible) {
2923 fl_raise_form(fd_form_figure->form_figure);
2925 fl_show_form(fd_form_figure->form_figure,
2926 FL_PLACE_MOUSE, FL_FULLBORDER,
2927 _("Insert Figure"));
2934 if (fd_form_table->form_table->visible) {
2935 fl_raise_form(fd_form_table->form_table);
2937 fl_show_form(fd_form_table->form_table,
2938 FL_PLACE_MOUSE, FL_FULLBORDER,
2944 /* callbacks for form form_figure */
2945 extern "C" void FigureApplyCB(FL_OBJECT *, long)
2947 if (!current_view->available())
2950 Buffer * buffer = current_view->buffer();
2951 if(buffer->isReadonly()) // paranoia
2954 current_view->owner()->getMiniBuffer()->Set(_("Inserting figure..."));
2955 if (fl_get_button(fd_form_figure->radio_inline)
2956 || current_view->text->cursor.par->table) {
2957 InsetFig * new_inset = new InsetFig(100, 20, buffer);
2958 current_view->insertInset(new_inset);
2959 current_view->owner()->getMiniBuffer()->Set(_("Figure inserted"));
2960 new_inset->Edit(current_view, 0, 0, 0);
2964 current_view->hideCursor();
2965 current_view->update(-2);
2966 current_view->beforeChange();
2968 current_view->text->SetCursorParUndo();
2969 current_view->text->FreezeUndo();
2971 current_view->text->BreakParagraph();
2972 current_view->update(-1);
2974 if (current_view->text->cursor.par->Last()) {
2975 current_view->text->CursorLeft();
2977 current_view->text->BreakParagraph();
2978 current_view->update(-1);
2981 // The standard layout should always be numer 0;
2982 current_view->text->SetLayout(0);
2984 if (current_view->text->cursor.par->footnoteflag ==
2985 LyXParagraph::NO_FOOTNOTE) {
2986 current_view->text->
2989 VSpace (0.3 * buffer->params.spacing.getValue(),
2992 buffer->params.spacing.getValue(),
2994 LYX_ALIGN_CENTER, string(), 0);
2996 current_view->text->SetParagraph(0, 0,
2998 VSpace(VSpace::NONE),
2999 VSpace(VSpace::NONE),
3005 current_view->update(-1);
3007 Inset * new_inset = new InsetFig(100, 100, buffer);
3008 current_view->insertInset(new_inset);
3009 new_inset->Edit(current_view, 0, 0, 0);
3010 current_view->update(0);
3011 current_view->owner()->getMiniBuffer()->Set(_("Figure inserted"));
3012 current_view->text->UnFreezeUndo();
3013 current_view->setState();
3017 extern "C" void FigureCancelCB(FL_OBJECT *, long)
3019 fl_hide_form(fd_form_figure->form_figure);
3023 extern "C" void FigureOKCB(FL_OBJECT * ob, long data)
3025 FigureApplyCB(ob, data);
3026 FigureCancelCB(ob, data);
3030 extern "C" void ScreenApplyCB(FL_OBJECT *, long)
3032 lyxrc.roman_font_name = fl_get_input(fd_form_screen->input_roman);
3033 lyxrc.sans_font_name = fl_get_input(fd_form_screen->input_sans);
3034 lyxrc.typewriter_font_name = fl_get_input(fd_form_screen->input_typewriter);
3035 lyxrc.font_norm = fl_get_input(fd_form_screen->input_font_norm);
3036 lyxrc.zoom = atoi(fl_get_input(fd_form_screen->intinput_size));
3037 fontloader.update();
3039 // Of course we should only to the resize and the textcahce.clear
3040 // if values really changed...but not very important right now. (Lgb)
3042 // All buffers will need resize
3043 bufferlist.resize();
3044 // We also need to empty the textcache so that
3045 // the buffer will be formatted correctly after
3049 current_view->owner()->getMiniBuffer()->Set(_("Screen options set"));
3053 extern "C" void ScreenCancelCB(FL_OBJECT *, long)
3055 fl_hide_form(fd_form_screen->form_screen);
3059 extern "C" void ScreenOKCB(FL_OBJECT * ob, long data)
3061 ScreenCancelCB(ob, data);
3062 ScreenApplyCB(ob, data);
3066 void LaTeXOptions(BufferView * bv)
3068 if (!bv->available())
3071 fl_set_button(fd_latex_options->accents,
3072 int(bv->buffer()->params.allowAccents));
3074 if (fd_latex_options->LaTeXOptions->visible) {
3075 fl_raise_form(fd_latex_options->LaTeXOptions);
3077 fl_show_form(fd_latex_options->LaTeXOptions,
3078 FL_PLACE_MOUSE, FL_FULLBORDER,
3079 _("LaTeX Options"));
3084 // This function runs "configure" and then rereads lyx.defaults to
3085 // reconfigure the automatic settings.
3086 void Reconfigure(BufferView * bv)
3088 bv->owner()->getMiniBuffer()->Set(_("Running configure..."));
3090 // Run configure in user lyx directory
3091 Path p(user_lyxdir);
3092 Systemcalls one(Systemcalls::System,
3093 AddName(system_lyxdir, "configure"));
3095 bv->owner()->getMiniBuffer()->Set(_("Reloading configuration..."));
3096 lyxrc.read(LibFileSearch(string(), "lyxrc.defaults"));
3097 WriteAlert(_("The system has been reconfigured."),
3098 _("You need to restart LyX to make use of any"),
3099 _("updated document class specifications."));
3104 // Table of Contents
3107 static vector<Buffer::TocItem> toclist;
3110 extern "C" void TocSelectCB(FL_OBJECT * ob, long)
3112 if (!current_view->available())
3116 unsigned int choice = fl_get_browser(ob);
3117 if (0 < choice && choice - 1 < toclist.size()) {
3118 current_view->beforeChange();
3119 current_view->text->SetCursor(toclist[choice-1].par, 0);
3120 current_view->text->sel_cursor =
3121 current_view->text->cursor;
3122 current_view->update(0);
3124 WriteAlert(_("Error"),
3125 _("Couldn't find this label"),
3126 _("in current document."));
3131 extern "C" void TocCancelCB(FL_OBJECT *, long)
3133 fl_hide_form(fd_form_toc->form_toc);
3137 extern "C" void TocUpdateCB(FL_OBJECT *, long)
3139 if (!current_view->available()) {
3141 fl_clear_browser(fd_form_toc->browser_toc);
3142 fl_add_browser_line(fd_form_toc->browser_toc,
3143 _("*** No Document ***"));
3147 vector<vector<Buffer::TocItem> > tmp =
3148 current_view->buffer()->getTocList();
3149 if (toclist == tmp[0])
3153 static Buffer * buffer = 0;
3156 if (buffer == current_view->buffer()) {
3157 topline = fl_get_browser_topline(fd_form_toc->browser_toc);
3158 line = fl_get_browser(fd_form_toc->browser_toc);
3160 buffer = current_view->buffer();
3162 fl_clear_browser(fd_form_toc->browser_toc);
3163 fl_hide_object(fd_form_toc->browser_toc);
3165 for (vector<Buffer::TocItem>::const_iterator it = toclist.begin();
3166 it != toclist.end(); ++it)
3167 fl_add_browser_line(fd_form_toc->browser_toc,
3168 (string(4*(*it).depth,' ')+
3169 (*it).str).c_str());
3171 fl_set_browser_topline(fd_form_toc->browser_toc, topline);
3172 fl_select_browser_line(fd_form_toc->browser_toc, line);
3173 fl_show_object(fd_form_toc->browser_toc);
3177 /* callbacks for form form_ref */
3178 extern "C" void RefSelectCB(FL_OBJECT *, long data)
3180 if (!current_view->available())
3184 fl_get_browser_line(fd_form_ref->browser_ref,
3185 fl_get_browser(fd_form_ref->browser_ref));
3186 string u = frontStrip(strip(fl_get_input(fd_form_ref->ref_name)));
3192 current_view->owner()->getLyXFunc()->Dispatch(LFUN_REFGOTO, s.c_str());
3196 static string const commands[5]
3197 = { "\\ref", "\\pageref", "\\vref", "\\vpageref",
3199 string t = commands[data];
3201 if (current_view->buffer()->isSGML())
3202 t += "[" + u + "]" + "{" + s + "}";
3207 new InsetRef(t, current_view->buffer());
3208 current_view->insertInset(new_inset);
3212 extern "C" void RefUpdateCB(FL_OBJECT *, long)
3214 if (!current_view->available()) {
3215 fl_clear_browser(fd_form_ref->browser_ref);
3219 FL_OBJECT * brow = fd_form_ref->browser_ref;
3221 // Get the current line, in order to restore it later
3222 char const * const btmp = fl_get_browser_line(brow,
3223 fl_get_browser(brow));
3224 string currentstr = btmp ? btmp : "";
3226 fl_clear_browser(brow);
3227 fl_hide_object(brow);
3229 vector<string> refs = current_view->buffer()->getLabelList();
3230 if (fl_get_button(fd_form_ref->sort))
3231 sort(refs.begin(),refs.end());
3232 for (vector<string>::const_iterator it = refs.begin();
3233 it != refs.end(); ++it)
3234 fl_add_browser_line(brow, (*it).c_str());
3237 int total_lines = fl_get_browser_maxline(brow);
3238 for (int i = 1; i <= total_lines ; ++i) {
3239 if (fl_get_browser_line(brow, i) == currentstr) {
3244 fl_set_browser_topline(brow, topline);
3246 if (!fl_get_browser_maxline(brow)) {
3247 fl_add_browser_line(brow,
3248 _("*** No labels found in document ***"));
3249 fl_deactivate_object(brow);
3251 fl_select_browser_line(brow, topline);
3252 fl_activate_object(brow);
3254 if (current_view->buffer()->isReadonly()) {
3255 // would be better to de/activate insert buttons
3256 // but that's more work... besides this works. ARRae
3257 fl_hide_form(fd_form_ref->form_ref);
3259 if (!current_view->buffer()->isSGML()) {
3260 fl_deactivate_object(fd_form_ref->ref_name);
3261 fl_set_object_lcol(fd_form_ref->ref_name, FL_INACTIVE);
3263 fl_activate_object(fd_form_ref->vref);
3264 fl_set_object_lcol(fd_form_ref->vref, FL_BLACK);
3265 fl_activate_object(fd_form_ref->vpageref);
3266 fl_set_object_lcol(fd_form_ref->vpageref, FL_BLACK);
3267 fl_activate_object(fd_form_ref->prettyref);
3268 fl_set_object_lcol(fd_form_ref->prettyref, FL_BLACK);
3270 fl_activate_object(fd_form_ref->ref_name);
3271 fl_set_object_lcol(fd_form_ref->ref_name, FL_BLACK);
3273 fl_deactivate_object(fd_form_ref->vref);
3274 fl_set_object_lcol(fd_form_ref->vref, FL_INACTIVE);
3275 fl_deactivate_object(fd_form_ref->vpageref);
3276 fl_set_object_lcol(fd_form_ref->vpageref, FL_INACTIVE);
3277 fl_deactivate_object(fd_form_ref->prettyref);
3278 fl_set_object_lcol(fd_form_ref->prettyref, FL_INACTIVE);
3280 fl_show_object(brow);
3284 extern "C" void RefHideCB(FL_OBJECT *, long)
3286 fl_hide_form(fd_form_ref->form_ref);