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 extern BufferView * current_view; // called too many times in this file...
82 extern void DeleteSimpleCutBuffer(); /* for the cleanup when exiting */
84 extern bool send_fax(string const & fname, string const & sendcmd);
85 extern void MenuSendto();
87 extern LyXServer * lyxserver;
89 // this should be static, but I need it in buffer.C
90 bool quitting; // flag, that we are quitting the program
91 extern bool finished; // all cleanup done just let it run through now.
93 char ascii_type; /* for selection notify callbacks */
95 bool scrolling = false;
97 // This is used to make the dreaded font toggle problem hopefully go
98 // away. Definitely not the best solution, but I think it sorta works.
99 bool toggleall = true;
102 This is the inset locking stuff needed for mathed --------------------
104 an inset can simple call LockInset in it's edit call and *ONLY* in it's
106 Inset::Edit() can only be called by the main lyx module.
108 Then the inset may modify the menu's and/or iconbars.
110 Unlocking is either done by LyX or the inset itself with a UnlockInset-call
112 During the lock, all button and keyboard events will be modified
113 and send to the inset through the following inset-features. Note that
114 Inset::InsetUnlock will be called from inside UnlockInset. It is meant
115 to contain the code for restoring the menus and things like this.
118 virtual void InsetButtonPress(int x, int y, int button);
119 virtual void InsetButtonRelease(int x, int y, int button);
120 virtual void InsetKeyPress(XKeyEvent *ev);
121 virtual void InsetMotionNotify(int x, int y, int state);
122 virtual void InsetUnlock();
124 If a inset wishes any redraw and/or update it just has to call
126 It's is completly irrelevant, where the inset is. UpdateInset will
127 find it in any paragraph in any buffer.
128 Of course the_locking_inset and the insets in the current paragraph/buffer
129 are checked first, so no performance problem should occur.
131 Hope that's ok for the beginning, Alejandro,
132 sorry that I needed so much time,
137 //void UpdateInset(BufferView * bv, Inset * inset, bool mark_dirty = true);
139 /* these functions return 1 if an error occured,
141 // Now they work only for updatable insets. [Alejandro 080596]
142 //int LockInset(UpdatableInset * inset);
143 void ToggleLockedInsetCursor(long x, long y, int asc, int desc);
144 //void FitLockedInsetCursor(long x, long y, int asc, int desc);
145 //int UnlockInset(UpdatableInset * inset);
146 //void LockedInsetStoreUndo(Undo::undo_kind kind);
148 /* this is for asyncron updating. UpdateInsetUpdateList will be called
149 automatically from LyX. Just insert the Inset into the Updatelist */
150 //void UpdateInsetUpdateList();
151 //void PutInsetIntoInsetUpdateList(Inset * inset);
153 //InsetUpdateStruct * InsetUpdateList = 0;
157 -----------------------------------------------------------------------
160 /* some function prototypes */
162 int RunLinuxDoc(BufferView *, int, string const &);
163 int RunDocBook(int, string const &);
164 void MenuWrite(Buffer * buf);
165 void MenuWriteAs(Buffer * buffer);
166 void MenuReload(Buffer * buf);
167 void MenuLayoutSave();
170 void ShowMessage(Buffer * buf,
172 string const & msg2 = string(),
173 string const & msg3 = string(), int delay = 6)
176 buf->getUser()->owner()->getMiniBuffer()->Set(msg1, msg2,
179 // can somebody think of something more clever? cerr?
180 cout << msg1 << msg2 << msg3 << endl;
185 // only called from this file, LyXView and LyXFunc
186 char updatetimer = 0;
189 // only called from BufferView_pimpl and LyXFunc
190 void FreeUpdateTimer()
192 /* a real free timer would be better but I don't know
193 * how to do this with xforms */
198 // Only called from LyXFunc
199 void SetUpdateTimer(float time)
201 fl_set_timer(current_view->owner()->getMainForm()->timer_update, time);
214 // should be moved to lyxfunc.C
215 void MenuWrite(Buffer * buffer)
218 if (!buffer->save()) {
219 string fname = buffer->fileName();
220 string s = MakeAbsPath(fname);
221 if (AskQuestion(_("Save failed. Rename and try again?"),
222 MakeDisplayPath(s, 50),
223 _("(If not, document is not saved.)"))) {
227 lastfiles->newFile(buffer->fileName());
232 // should be moved to BufferView.C
233 // Half of this func should be in LyXView, the rest in BufferView.
234 void MenuWriteAs(Buffer * buffer)
236 // Why do we require BufferView::text to be able to write a
237 // document? I see no point in that. (Lgb)
238 //if (!bv->text) return;
240 string fname = buffer->fileName();
241 string oldname = fname;
244 ProhibitInput(current_view);
245 fileDlg.SetButton(0, _("Documents"), lyxrc.document_path);
246 fileDlg.SetButton(1, _("Templates"), lyxrc.template_path);
248 if (!IsLyXFilename(fname))
251 fname = fileDlg.Select(_("Enter Filename to Save Document as"),
254 OnlyFilename(fname));
255 AllowInput(current_view);
260 // Make sure the absolute filename ends with appropriate suffix
261 string s = MakeAbsPath(fname);
262 if (!IsLyXFilename(s))
265 // Same name as we have already?
267 if (!AskQuestion(_("Same name as document already has:"),
268 MakeDisplayPath(s, 50),
271 // Falls through to name change and save
273 // No, but do we have another file with this name open?
274 else if (bufferlist.exists(s)) {
275 if (AskQuestion(_("Another document with same name open!"),
276 MakeDisplayPath(s, 50),
277 _("Replace with current document?")))
279 bufferlist.close(bufferlist.getBuffer(s));
281 // Ok, change the name of the buffer, but don't save!
285 ShowMessage(buffer, _("Document renamed to '"),
286 MakeDisplayPath(s), _("', but not saved..."));
289 } // Check whether the file exists
292 if (myfile.isOK() && !AskQuestion(_("Document already exists:"),
293 MakeDisplayPath(s, 50),
298 // Ok, change the name of the buffer
302 // Small bug: If the save fails, we have irreversible changed the name
308 int MenuRunLaTeX(Buffer * buffer)
312 if (buffer->isLinuxDoc())
313 ret = RunLinuxDoc(buffer->getUser(), 1, buffer->fileName());
314 else if (buffer->isLiterate())
315 ret = buffer->runLiterate();
316 else if (buffer->isDocBook())
317 ret = RunDocBook(1, buffer->fileName());
319 ret = buffer->runLaTeX();
325 s = _("One error detected");
326 t = _("You should try to fix it.");
329 s += _(" errors detected.");
330 t = _("You should try to fix them.");
332 WriteAlert(_("There were errors during the LaTeX run."), s, t);
338 int MenuBuildProg(Buffer * buffer)
342 if (buffer->isLiterate())
343 ret = buffer->buildProgram();
345 string s = _("Wrong type of document");
346 string t = _("The Build operation is not allowed in this document");
347 WriteAlert(_("There were errors during the Build process."), s, t);
355 s = _("One error detected");
356 t = _("You should try to fix it.");
359 s += _(" errors detected.");
360 t = _("You should try to fix them.");
362 WriteAlert(_("There were errors during the Build process."), s, t);
368 int MenuRunChktex(Buffer * buffer)
372 if (buffer->isSGML()) {
373 WriteAlert(_("Chktex does not work with SGML derived documents."));
376 ret = buffer->runChktex();
382 s = _("No warnings found.");
383 } else if (ret == 1) {
384 s = _("One warning found.");
385 t = _("Use 'Edit->Go to Error' to find it.");
388 s += _(" warnings found.");
389 t = _("Use 'Edit->Go to Error' to find them.");
391 WriteAlert(_("Chktex run successfully"), s, t);
393 WriteAlert(_("Error!"), _("It seems chktex does not work."));
399 int MakeLaTeXOutput(Buffer * buffer)
405 string path = OnlyPath(buffer->fileName());
406 if (lyxrc.use_tempdir || (IsDirWriteable(path) < 1)) {
407 path = buffer->tmppath;
409 if (!buffer->isDviClean()) {
411 ret = MenuRunLaTeX(buffer);
417 /* wait == false means don't wait for termination */
418 /* wait == true means wait for termination */
419 // The bool should be placed last on the argument line. (Lgb)
420 // Returns false if we fail.
421 bool RunScript(Buffer * buffer, bool wait,
422 string const & command,
423 string const & orgname = string(),
424 bool need_shell = true)
428 string name = orgname;
431 if (MakeLaTeXOutput(buffer) > 0)
433 /* get DVI-Filename */
435 name = ChangeExtension(buffer->getLatexName(), ".dvi");
437 path = OnlyPath(name);
438 if (lyxrc.use_tempdir || (IsDirWriteable(path) < 1)) {
439 path = buffer->tmppath;
442 // At this point we check whether the command contains the
443 // filename parameter $$FName and if that's the case we
444 // substitute the real file name otherwise the filename is
445 // simply appended. rokrau 1/12/00
448 if ( (i=command.find("$$FName")) != string::npos)
450 cmd.replace(i,7,QuoteName(name));
453 cmd = command + ' ' + QuoteName(name);
462 // OS/2 cmd.exe has another use for '&'
464 // This is not NLS safe, but it's OK, I think.
465 string sh = OnlyFilename(GetEnvPath("EMXSHELL"));
467 // COMSPEC is set, unless user unsets
468 sh = OnlyFilename(GetEnvPath("COMSPEC"));
473 if (contains(sh, "cmd.exe")
474 || contains(sh, "4os2.exe"))
475 cmd = "start /min/n " + cmd;
480 // It seems that, if wait is false, we never get back
481 // the return code of the command. This means that all
482 // the code I added in PrintApplyCB is currently
484 // CHECK What should we do here?
485 ShowMessage(buffer, _("Executing command:"), cmd);
486 result = one.startscript(Systemcalls::System, cmd);
488 ShowMessage(buffer, _("Executing command:"), cmd);
489 result = one.startscript(wait ? Systemcalls::Wait
490 : Systemcalls::DontWait, cmd);
496 // Returns false if we fail
497 bool CreatePostscript(Buffer * buffer, bool wait = false)
503 ProhibitInput(current_view);
506 if (MakeLaTeXOutput(buffer) > 0) {
507 AllowInput(current_view);
510 // Generate postscript file
511 string psname = OnlyFilename(ChangeExtension (buffer->fileName(),
517 char real_papersize = buffer->params.papersize;
518 if (real_papersize == BufferParams::PAPER_DEFAULT)
519 real_papersize = lyxrc.default_papersize;
521 switch (real_papersize) {
522 case BufferParams::PAPER_USLETTER:
525 case BufferParams::PAPER_A3PAPER:
528 case BufferParams::PAPER_A4PAPER:
531 case BufferParams::PAPER_A5PAPER:
534 case BufferParams::PAPER_B5PAPER:
537 case BufferParams::PAPER_EXECUTIVEPAPER:
540 case BufferParams::PAPER_LEGALPAPER:
543 default: /* If nothing else fits, keep an empty value... */
547 // Make postscript file.
548 string command = lyxrc.dvi_to_ps_command + ' ' + lyxrc.print_to_file + ' ';
549 command += QuoteName(psname);
550 if (buffer->params.use_geometry
551 && buffer->params.papersize2 == BufferParams::VM_PAPER_CUSTOM
552 && !lyxrc.print_paper_dimension_flag.empty()
553 && !buffer->params.paperwidth.empty()
554 && !buffer->params.paperheight.empty()) {
555 // using a custom papersize
557 command += lyxrc.print_paper_dimension_flag + ' ';
558 command += buffer->params.paperwidth + ',';
559 command += buffer->params.paperheight;
560 } else if (!paper.empty()
561 && (real_papersize != BufferParams::PAPER_USLETTER ||
562 buffer->params.orientation == BufferParams::ORIENTATION_PORTRAIT)) {
563 // dvips won't accept -t letter -t landscape. In all other
564 // cases, include the paper size explicitly.
566 command += lyxrc.print_paper_flag + ' ' + paper;
568 if (buffer->params.orientation == BufferParams::ORIENTATION_LANDSCAPE) {
570 command += lyxrc.print_landscape_flag;
572 // push directorypath, if necessary
573 string path = OnlyPath(buffer->fileName());
574 if (lyxrc.use_tempdir || (IsDirWriteable(path) < 1)){
575 path = buffer->tmppath;
578 bool ret = RunScript(buffer, wait, command);
579 AllowInput(current_view);
584 // Returns false if we fail
585 //bool MenuPreviewPS(Buffer * buffer)
586 bool PreviewPostscript(Buffer * buffer)
592 // Generate postscript file
593 if (!CreatePostscript(buffer, true)) {
597 // Start postscript viewer
598 ProhibitInput(current_view);
599 string ps = OnlyFilename(ChangeExtension (buffer->fileName(),
601 // push directorypath, if necessary
602 string path = OnlyPath(buffer->fileName());
603 if (lyxrc.use_tempdir || (IsDirWriteable(path) < 1)){
604 path = buffer->tmppath;
607 bool ret = RunScript(buffer, false, lyxrc.view_ps_command, ps);
608 AllowInput(current_view);
613 void MenuFax(Buffer * buffer)
619 // Generate postscript file
620 if (!CreatePostscript(buffer, true)) {
625 string ps = OnlyFilename(ChangeExtension (buffer->fileName(),
627 string path = OnlyPath (buffer->fileName());
628 if (lyxrc.use_tempdir || (IsDirWriteable(path) < 1)) {
629 path = buffer->tmppath;
632 if (!lyxrc.fax_program.empty()) {
633 string help2 = subst(lyxrc.fax_program, "$$FName", ps);
635 Systemcalls one(Systemcalls::System, help2);
637 send_fax(ps, lyxrc.fax_command);
641 // Returns false if we fail
642 bool PreviewDVI(Buffer * buffer)
648 string paper = lyxrc.view_dvi_paper_option;
649 if (!paper.empty()) {
651 char real_papersize = buffer->params.papersize;
652 if (real_papersize == BufferParams::PAPER_DEFAULT)
653 real_papersize = lyxrc.default_papersize;
655 switch (real_papersize) {
656 case BufferParams::PAPER_USLETTER:
659 case BufferParams::PAPER_A3PAPER:
662 case BufferParams::PAPER_A4PAPER:
665 case BufferParams::PAPER_A5PAPER:
668 case BufferParams::PAPER_B5PAPER:
671 case BufferParams::PAPER_EXECUTIVEPAPER:
672 paper += " foolscap";
674 case BufferParams::PAPER_LEGALPAPER:
677 default: /* If nothing else fits, keep the empty value */
680 if (real_papersize==' ') {
681 // if (paper.empty()) {
682 if (buffer->params.orientation
683 == BufferParams::ORIENTATION_LANDSCAPE)
684 // we HAVE to give a size when the page is in
685 // landscape, so use USletter.
686 paper = " -paper usr";
688 // paper = " -paper " + paper;
689 if (buffer->params.orientation
690 == BufferParams::ORIENTATION_LANDSCAPE)
694 // push directorypath, if necessary
695 string path = OnlyPath(buffer->fileName());
696 if (lyxrc.use_tempdir || (IsDirWriteable(path) < 1)) {
697 path = buffer->tmppath;
701 string command = lyxrc.view_dvi_command + " " + paper;
702 bool ret = RunScript(buffer, false, command);
707 bool AskOverwrite(Buffer * buffer, string const & s)
710 // be friendly if there is a gui
713 !AskQuestion(_("File already exists:"),
714 MakeDisplayPath(s, 50),
715 _("Do you want to overwrite the file?"))) {
716 ShowMessage(buffer, _("Canceled"));
724 void MenuMakeLaTeX(Buffer * buffer)
726 // Why care about this?
730 // Get LaTeX-Filename
731 string s = buffer->getLatexName(false);
733 if (!AskOverwrite(buffer, s))
736 if (buffer->isDocBook())
737 ShowMessage(buffer, _("DocBook does not have a latex backend"));
739 if (buffer->isLinuxDoc())
740 RunLinuxDoc(buffer->getUser(), 0, buffer->fileName());
742 buffer->makeLaTeXFile(s, string(), true);
743 ShowMessage(buffer, _("Nice LaTeX file saved as"),
745 buffer->markDviDirty();
750 void MenuMakeLinuxDoc(Buffer * buffer)
753 //if (!bv->text) return;
755 if (!buffer->isLinuxDoc()) {
756 WriteAlert(_("Error!"), _("Document class must be linuxdoc."));
760 // Get LinuxDoc-Filename
761 string s = ChangeExtension(buffer->fileName(), ".sgml");
763 if (!AskOverwrite(buffer, s))
766 ShowMessage(buffer, _("Building LinuxDoc SGML file `"),
767 MakeDisplayPath(s),"'...");
769 buffer->makeLinuxDocFile(s, 65);
771 ShowMessage(buffer, _("LinuxDoc SGML file save as"),
776 void MenuMakeDocBook(Buffer * buffer)
779 //if (!bv->text) return;
781 if (!buffer->isDocBook()) {
782 WriteAlert(_("Error!"),
783 _("Document class must be docbook."));
787 // Get DocBook-Filename
788 string s = ChangeExtension(buffer->fileName(), ".sgml");
790 if (!AskOverwrite(buffer, s))
793 ShowMessage(buffer, _("Building DocBook SGML file `"),
794 MakeDisplayPath(s), "'...");
796 buffer->makeDocBookFile(s, 65);
798 ShowMessage(buffer, _("DocBook SGML file save as"),
803 void MenuMakeAscii(Buffer * buffer)
806 //if (!bv->text) return;
808 /* get LaTeX-Filename */
809 string s = ChangeExtension (buffer->fileName(), ".txt");
812 if (!AskOverwrite(buffer, s))
815 buffer->writeFileAscii(s, lyxrc.ascii_linelen);
817 ShowMessage(buffer, _("Ascii file saved as"), MakeDisplayPath(s));
821 void MenuPrint(Buffer * buffer)
827 string input_file = OnlyFilename(ChangeExtension(buffer->fileName(),
828 lyxrc.print_file_extension));
829 fl_set_input(fd_form_print->input_file, input_file.c_str());
831 if (fd_form_print->form_print->visible) {
832 fl_raise_form(fd_form_print->form_print);
835 fl_show_form(fd_form_print->form_print,
836 FL_PLACE_MOUSE, FL_FULLBORDER,
842 void MenuMakeHTML(Buffer * buffer)
844 // First, create LaTeX file
845 MenuMakeLaTeX(buffer);
847 // And now, run the converter
848 string file = buffer->fileName();
849 Path path(OnlyPath(file));
850 // the tex file name has to be correct for
851 // latex, but the html file name can be
853 string result = ChangeExtension(file, ".html");
854 string infile = buffer->getLatexName(false);
855 string tmp = lyxrc.html_command;
856 tmp = subst(tmp, "$$FName", infile);
857 tmp = subst(tmp, "$$OutName", result);
859 int res = one.startscript(Systemcalls::System, tmp);
861 ShowMessage(buffer, _("Document exported as HTML to file `")
862 + MakeDisplayPath(result) +'\'');
864 ShowMessage(buffer, _("Unable to convert to HTML the file `")
865 + MakeDisplayPath(infile)
872 void MenuMakeHTML_LinuxDoc(Buffer * buffer)
874 // First, create LinuxDoc file
875 MenuMakeLinuxDoc(buffer);
877 // And now, run the converter
878 string file = buffer->fileName();
880 string result = ChangeExtension(file, ".html");
881 string infile = ChangeExtension(file, ".sgml");
882 string tmp = lyxrc.linuxdoc_to_html_command;
883 tmp = subst(tmp, "$$FName", infile);
884 tmp = subst(tmp, "$$OutName", result);
886 int res = one.startscript(Systemcalls::System, tmp);
888 ShowMessage(buffer,_("Document exported as HTML to file `")
889 + MakeDisplayPath(result) +'\'');
891 ShowMessage(buffer,_("Unable to convert to HTML the file `")
892 + MakeDisplayPath(infile)
898 void MenuMakeHTML_DocBook(Buffer * buffer)
900 // First, create LaTeX file
901 MenuMakeDocBook(buffer);
903 // And now, run the converter
904 string file = buffer->fileName();
905 string result = ChangeExtension(file, ".html");
906 string infile = ChangeExtension(file, ".sgml");
907 string tmp = lyxrc.docbook_to_html_command;
908 tmp = subst(tmp, "$$FName", infile);
909 tmp = subst(tmp, "$$OutName", result);
911 int res = one.startscript(Systemcalls::System, tmp);
913 ShowMessage(buffer,_("Document exported as HTML to file `")
914 + MakeDisplayPath(result) +'\'');
916 ShowMessage(buffer,_("Unable to convert to HTML the file `")
917 + MakeDisplayPath(infile)
924 void MenuExport(Buffer * buffer, string const & extyp)
927 if (extyp == "latex") {
928 // make sure that this buffer is not linuxdoc
929 MenuMakeLaTeX(buffer);
932 else if (extyp == "linuxdoc") {
933 // make sure that this buffer is not latex
934 MenuMakeLinuxDoc(buffer);
937 else if (extyp == "docbook") {
938 // make sure that this buffer is not latex or linuxdoc
939 MenuMakeDocBook(buffer);
942 else if (extyp == "dvi") {
943 // Run LaTeX as "Update dvi..." Bernhard.
944 // We want the dvi in the current directory. This
945 // is achieved by temporarily disabling use of
946 // temp directory. As a side-effect, we get
947 // *.log and *.aux files also. (Asger)
948 bool flag = lyxrc.use_tempdir;
949 lyxrc.use_tempdir = false;
950 MenuRunLaTeX(buffer);
951 lyxrc.use_tempdir = flag;
954 else if (extyp == "postscript") {
955 // Start Print-dialog. Not as good as dvi... Bernhard.
957 // Since the MenuPrint is a pop-up, we can't use
958 // the same trick as above. (Asger)
959 // MISSING: Move of ps-file :-(
960 // And MenuPrint should not be used for this at all...
963 else if (extyp == "ascii") {
964 MenuMakeAscii(buffer);
966 else if (extyp == "custom") {
970 else if (extyp == "html") {
971 MenuMakeHTML(buffer);
973 // HTML from linuxdoc
974 else if (extyp == "html-linuxdoc") {
975 MenuMakeHTML_LinuxDoc(buffer);
978 else if (extyp == "html-docbook") {
979 MenuMakeHTML_DocBook(buffer);
982 ShowMessage(buffer, _("Unknown export type: ") + extyp);
989 lyxerr.debug() << "Running QuitLyX." << endl;
991 if (!bufferlist.QwriteAll())
994 lastfiles->writeFile(lyxrc.lastfiles);
996 // Set a flag that we do quitting from the program,
997 // so no refreshes are necessary.
1000 // close buffers first
1001 bufferlist.closeAll();
1003 // do any other cleanup procedures now
1004 lyxerr.debug() << "Deleting tmp dir " << system_tempdir << endl;
1006 DestroyLyXTmpDir(system_tempdir);
1013 void AutoSave(BufferView * bv)
1014 // should probably be moved into BufferList (Lgb)
1015 // Perfect target for a thread...
1017 if (!bv->available())
1020 if (bv->buffer()->isBakClean()
1021 || bv->buffer()->isReadonly()) {
1022 // We don't save now, but we'll try again later
1023 bv->owner()->resetAutosaveTimer();
1027 bv->owner()->getMiniBuffer()->Set(_("Autosaving current document..."));
1029 // create autosave filename
1030 string fname = OnlyPath(bv->buffer()->fileName());
1032 fname += OnlyFilename(bv->buffer()->fileName());
1035 // tmp_ret will be located (usually) in /tmp
1036 // will that be a problem?
1037 string tmp_ret = tmpnam(0);
1039 pid_t pid = fork(); // If you want to debug the autosave
1040 // you should set pid to -1, and comment out the
1042 if (pid == 0 || pid == -1) {
1043 // pid = -1 signifies that lyx was unable
1044 // to fork. But we will do the save
1046 bool failed = false;
1047 if (!tmp_ret.empty()) {
1048 bv->buffer()->writeFile(tmp_ret, 1);
1049 // assume successful write of tmp_ret
1050 if (rename(tmp_ret.c_str(), fname.c_str()) == -1) {
1052 // most likely couldn't move between filesystems
1053 // unless write of tmp_ret failed
1054 // so remove tmp file (if it exists)
1055 remove(tmp_ret.c_str());
1062 // failed to write/rename tmp_ret so try writing direct
1063 if (!bv->buffer()->writeFile(fname, 1)) {
1064 // It is dangerous to do this in the child,
1065 // but safe in the parent, so...
1067 bv->owner()->getMiniBuffer()->Set(_("Autosave Failed!"));
1070 if (pid == 0) { // we are the child so...
1075 bv->buffer()->markBakClean();
1076 bv->owner()->resetAutosaveTimer();
1081 // Copyright CHT Software Service GmbH
1084 // create new file with template
1087 Buffer * NewLyxFile(string const & filename)
1089 // Split argument by :
1091 string tmpname = split(filename, name, ':');
1092 #ifdef __EMX__ // Fix me! lyx_cb.C may not be low level enough to allow this.
1093 if (name.length() == 1
1094 && isalpha(static_cast<unsigned char>(name[0]))
1095 && (prefixIs(tmpname, "/") || prefixIs(tmpname, "\\"))) {
1097 name += token(tmpname, ':', 0);
1098 tmpname = split(tmpname, ':');
1101 lyxerr.debug() << "Arg is " << filename
1102 << "\nName is " << name
1103 << "\nTemplate is " << tmpname << endl;
1105 // find a free buffer
1106 Buffer * tmpbuf = bufferlist.newFile(name, tmpname);
1108 lastfiles->newFile(tmpbuf->fileName());
1113 // Insert ascii file (if filename is empty, prompt for one)
1114 void InsertAsciiFile(BufferView * bv, string const & f, bool asParagraph)
1119 if (!bv->available()) return;
1121 if (fname.empty()) {
1123 fname = fileDlg.Select(_("File to Insert"),
1124 bv->owner()->buffer()->filepath,
1127 if (fname.empty()) return;
1132 if (!fi.readable()) {
1133 WriteFSAlert(_("Error! Specified file is unreadable: "),
1134 MakeDisplayPath(fname, 50));
1138 ifstream ifs(fname.c_str());
1140 WriteFSAlert(_("Error! Cannot open specified file: "),
1141 MakeDisplayPath(fname, 50));
1145 ifs.unsetf(ios::skipws);
1146 istream_iterator<char> ii(ifs);
1147 istream_iterator<char> end;
1148 //string tmpstr(ii, end); // yet a reason for using std::string
1149 // alternate approach to get the file into a string:
1151 copy(ii, end, back_inserter(tmpstr));
1152 // insert the string
1153 current_view->hideCursor();
1155 // clear the selection
1158 bv->text->InsertStringA(tmpstr);
1160 bv->text->InsertStringB(tmpstr);
1165 void MenuShowTableOfContents()
1167 static int ow = -1, oh;
1170 if (fd_form_toc->form_toc->visible) {
1171 fl_raise_form(fd_form_toc->form_toc);
1173 fl_show_form(fd_form_toc->form_toc,
1174 FL_PLACE_MOUSE | FL_FREE_SIZE, FL_FULLBORDER,
1175 _("Table Of Contents"));
1177 ow = fd_form_toc->form_toc->w;
1178 oh = fd_form_toc->form_toc->h;
1180 fl_set_form_minsize(fd_form_toc->form_toc, ow, oh);
1185 void MenuInsertLabel(char const * arg)
1188 ProhibitInput(current_view);
1189 if (label.empty()) {
1191 result = askForText(_("Enter new label to insert:"));
1193 label = frontStrip(strip(result.second));
1196 if (!label.empty()) {
1197 InsetLabel * new_inset = new InsetLabel;
1198 new_inset->setContents(label);
1199 current_view->insertInset(new_inset);
1201 AllowInput(current_view);
1205 void MenuInsertRef()
1207 static int ow = -1, oh;
1210 if (fd_form_ref->form_ref->visible) {
1211 fl_raise_form(fd_form_ref->form_ref);
1213 fl_show_form(fd_form_ref->form_ref,
1214 FL_PLACE_MOUSE | FL_FREE_SIZE, FL_FULLBORDER,
1215 _("Insert Reference"));
1217 ow = fd_form_ref->form_ref->w;
1218 oh = fd_form_ref->form_ref->h;
1220 fl_set_form_minsize(fd_form_ref->form_ref, ow, oh);
1225 void MenuPasteSelection(char at)
1227 if (!current_view->available())
1232 Atom data_prop = XInternAtom(fl_display,
1235 if (data_prop == None)
1237 XConvertSelection(fl_display,
1238 XA_PRIMARY, XA_STRING, data_prop,
1239 current_view->owner()->getForm()->window, 0);
1246 // candidate for move to LyXView
1247 // This is only used in toolbar.C
1248 void LayoutsCB(int sel, void *)
1250 string tmp = tostr(sel);
1251 current_view->owner()->getLyXFunc()->Dispatch(LFUN_LAYOUTNO,
1257 * SGML Linuxdoc support:
1258 * (flag == 0) make TeX output
1259 * (flag == 1) make dvi output
1261 int RunLinuxDoc(BufferView * bv, int flag, string const & filename)
1268 /* generate a path-less extension name */
1269 string name = OnlyFilename(ChangeExtension (filename, ".sgml"));
1270 string path = OnlyPath (filename);
1271 if (lyxrc.use_tempdir || (IsDirWriteable(path) < 1)) {
1272 path = bv->buffer()->tmppath;
1276 if (!bv->available())
1278 bv->buffer()->makeLinuxDocFile(name, 0);
1280 // CHECK remove this once we have a proper geometry class
1282 BufferParams::PAPER_SIZE ps =
1283 static_cast<BufferParams::PAPER_SIZE>(bv->buffer()->params.papersize);
1285 case BufferParams::PAPER_A4PAPER:
1286 add_flags = "-p a4";
1288 case BufferParams::PAPER_USLETTER:
1289 add_flags = "-p letter";
1291 default: /* nothing to be done yet ;-) */ break;
1298 case 0: /* TeX output asked */
1299 bv->owner()->getMiniBuffer()->Set(_("Converting LinuxDoc SGML to TeX file..."));
1300 s2 = lyxrc.linuxdoc_to_latex_command + ' ' + add_flags + " -o tex " + ' ' + name;
1301 if (one.startscript(Systemcalls::System, s2))
1304 case 1: /* dvi output asked */
1305 bv->owner()->getMiniBuffer()->Set(_("Converting LinuxDoc SGML to dvi file..."));
1306 s2 = lyxrc.linuxdoc_to_latex_command + ' ' + add_flags + " -o dvi " + ' ' + name;
1307 if (one.startscript(Systemcalls::System, s2)) {
1310 bv->buffer()->markDviClean();
1312 default: /* unknown output */
1318 bv->buffer()->redraw();
1324 * SGML DocBook support:
1325 * (flag == 1) make dvi output
1327 int RunDocBook(int flag, string const & filename)
1329 /* generate a path-less extension name */
1330 string name = OnlyFilename(ChangeExtension (filename, ".sgml"));
1331 string path = OnlyPath (filename);
1332 if (lyxrc.use_tempdir || (IsDirWriteable(path) < 1)) {
1333 path = current_view->buffer()->tmppath;
1337 if (!current_view->available())
1340 current_view->buffer()->makeDocBookFile(name, 0);
1342 // Shall this code go or should it stay? (Lgb)
1343 // This code is a placeholder for future implementation. (Jose')
1344 // string add_flags;
1345 // LYX_PAPER_SIZE ps = (LYX_PAPER_SIZE) current_view->buffer()->params.papersize;
1347 // case BufferParams::PAPER_A4PAPER: add_flags = "-p a4"; break;
1348 // case BufferParams::PAPER_USLETTER: add_flags = "-p letter"; break;
1349 // default: /* nothing to be done yet ;-) */ break;
1351 ProhibitInput(current_view);
1356 case 1: /* dvi output asked */
1358 current_view->owner()->getMiniBuffer()->Set(_("Converting DocBook SGML to dvi file..."));
1359 string s2 = lyxrc.docbook_to_dvi_command + ' ' + name;
1360 if (one.startscript(Systemcalls::System, s2)) {
1363 current_view->buffer()->markDviClean();
1366 default: /* unknown output */
1370 AllowInput(current_view);
1372 current_view->buffer()->redraw();
1377 void MenuLayoutCharacter()
1379 static int ow = -1, oh;
1381 if (fd_form_character->form_character->visible) {
1382 fl_raise_form(fd_form_character->form_character);
1384 fl_show_form(fd_form_character->form_character,
1385 FL_PLACE_MOUSE | FL_FREE_SIZE, FL_FULLBORDER,
1386 _("Character Style"));
1388 ow = fd_form_character->form_character->w;
1389 oh = fd_form_character->form_character->h;
1391 fl_set_form_minsize(fd_form_character->form_character, ow, oh);
1397 void DeactivateParagraphButtons ()
1399 fl_deactivate_object (fd_form_paragraph->button_ok);
1400 fl_deactivate_object (fd_form_paragraph->button_apply);
1401 fl_set_object_lcol (fd_form_paragraph->button_ok, FL_INACTIVE);
1402 fl_set_object_lcol (fd_form_paragraph->button_apply, FL_INACTIVE);
1407 void ActivateParagraphButtons ()
1409 fl_activate_object (fd_form_paragraph->button_ok);
1410 fl_activate_object (fd_form_paragraph->button_apply);
1411 fl_set_object_lcol (fd_form_paragraph->button_ok, FL_BLACK);
1412 fl_set_object_lcol (fd_form_paragraph->button_apply, FL_BLACK);
1417 void DisableParagraphLayout ()
1419 DeactivateParagraphButtons();
1420 fl_deactivate_object (fd_form_paragraph->input_labelwidth);
1421 fl_deactivate_object (fd_form_paragraph->check_lines_top);
1422 fl_deactivate_object (fd_form_paragraph->check_lines_bottom);
1423 fl_deactivate_object (fd_form_paragraph->check_pagebreaks_top);
1424 fl_deactivate_object (fd_form_paragraph->check_pagebreaks_bottom);
1425 fl_deactivate_object (fd_form_paragraph->check_noindent);
1426 fl_deactivate_object (fd_form_paragraph->group_radio_alignment);
1427 fl_deactivate_object (fd_form_paragraph->radio_align_right);
1428 fl_deactivate_object (fd_form_paragraph->radio_align_left);
1429 fl_deactivate_object (fd_form_paragraph->radio_align_block);
1430 fl_deactivate_object (fd_form_paragraph->radio_align_center);
1431 fl_deactivate_object (fd_form_paragraph->input_space_above);
1432 fl_deactivate_object (fd_form_paragraph->input_space_below);
1433 fl_deactivate_object (fd_form_paragraph->choice_space_above);
1434 fl_deactivate_object (fd_form_paragraph->choice_space_below);
1435 fl_deactivate_object (fd_form_paragraph->check_space_above);
1436 fl_deactivate_object (fd_form_paragraph->check_space_below);
1441 void EnableParagraphLayout ()
1443 ActivateParagraphButtons();
1444 fl_activate_object (fd_form_paragraph->input_labelwidth);
1445 fl_activate_object (fd_form_paragraph->check_lines_top);
1446 fl_activate_object (fd_form_paragraph->check_lines_bottom);
1447 fl_activate_object (fd_form_paragraph->check_pagebreaks_top);
1448 fl_activate_object (fd_form_paragraph->check_pagebreaks_bottom);
1449 fl_activate_object (fd_form_paragraph->check_noindent);
1450 fl_activate_object (fd_form_paragraph->group_radio_alignment);
1451 fl_activate_object (fd_form_paragraph->radio_align_right);
1452 fl_activate_object (fd_form_paragraph->radio_align_left);
1453 fl_activate_object (fd_form_paragraph->radio_align_block);
1454 fl_activate_object (fd_form_paragraph->radio_align_center);
1455 fl_activate_object (fd_form_paragraph->input_space_above);
1456 fl_activate_object (fd_form_paragraph->input_space_below);
1457 fl_activate_object (fd_form_paragraph->choice_space_above);
1458 fl_activate_object (fd_form_paragraph->choice_space_below);
1459 fl_activate_object (fd_form_paragraph->check_space_above);
1460 fl_activate_object (fd_form_paragraph->check_space_below);
1464 bool UpdateLayoutParagraph()
1466 if (!current_view->available()) {
1467 if (fd_form_paragraph->form_paragraph->visible)
1468 fl_hide_form(fd_form_paragraph->form_paragraph);
1472 Buffer * buf = current_view->buffer();
1474 fl_set_input(fd_form_paragraph->input_labelwidth,
1475 current_view->text->cursor.par->GetLabelWidthString().c_str());
1476 fl_set_button(fd_form_paragraph->radio_align_right, 0);
1477 fl_set_button(fd_form_paragraph->radio_align_left, 0);
1478 fl_set_button(fd_form_paragraph->radio_align_center, 0);
1479 fl_set_button(fd_form_paragraph->radio_align_block, 0);
1481 int align = current_view->text->cursor.par->GetAlign();
1482 if (align == LYX_ALIGN_LAYOUT)
1483 align = textclasslist.Style(buf->params.textclass,
1484 current_view->text->cursor.par->GetLayout()).align;
1487 case LYX_ALIGN_RIGHT:
1488 fl_set_button(fd_form_paragraph->radio_align_right, 1);
1490 case LYX_ALIGN_LEFT:
1491 fl_set_button(fd_form_paragraph->radio_align_left, 1);
1493 case LYX_ALIGN_CENTER:
1494 fl_set_button(fd_form_paragraph->radio_align_center, 1);
1497 fl_set_button(fd_form_paragraph->radio_align_block, 1);
1501 fl_set_button(fd_form_paragraph->check_lines_top,
1502 current_view->text->cursor.par->FirstPhysicalPar()->line_top);
1503 fl_set_button(fd_form_paragraph->check_lines_bottom,
1504 current_view->text->cursor.par->FirstPhysicalPar()->line_bottom);
1505 fl_set_button(fd_form_paragraph->check_pagebreaks_top,
1506 current_view->text->cursor.par->FirstPhysicalPar()->pagebreak_top);
1507 fl_set_button(fd_form_paragraph->check_pagebreaks_bottom,
1508 current_view->text->cursor.par->FirstPhysicalPar()->pagebreak_bottom);
1509 fl_set_button(fd_form_paragraph->check_noindent,
1510 current_view->text->cursor.par->FirstPhysicalPar()->noindent);
1511 fl_set_input (fd_form_paragraph->input_space_above, "");
1513 switch (current_view->text->cursor.par->FirstPhysicalPar()->added_space_top.kind()) {
1515 fl_set_choice (fd_form_paragraph->choice_space_above, 1);
1517 case VSpace::DEFSKIP:
1518 fl_set_choice (fd_form_paragraph->choice_space_above, 2);
1520 case VSpace::SMALLSKIP:
1521 fl_set_choice (fd_form_paragraph->choice_space_above, 3);
1523 case VSpace::MEDSKIP:
1524 fl_set_choice (fd_form_paragraph->choice_space_above, 4);
1526 case VSpace::BIGSKIP:
1527 fl_set_choice (fd_form_paragraph->choice_space_above, 5);
1530 fl_set_choice (fd_form_paragraph->choice_space_above, 6);
1532 case VSpace::LENGTH:
1533 fl_set_choice (fd_form_paragraph->choice_space_above, 7);
1534 fl_set_input (fd_form_paragraph->input_space_above,
1535 current_view->text->cursor.par->FirstPhysicalPar()->added_space_top.length().asString().c_str());
1538 fl_set_button (fd_form_paragraph->check_space_above,
1539 current_view->text->cursor.par->FirstPhysicalPar()->added_space_top.keep());
1540 fl_set_input (fd_form_paragraph->input_space_below, "");
1541 switch (current_view->text->cursor.par->FirstPhysicalPar()->added_space_bottom.kind()) {
1543 fl_set_choice (fd_form_paragraph->choice_space_below,
1546 case VSpace::DEFSKIP:
1547 fl_set_choice (fd_form_paragraph->choice_space_below,
1550 case VSpace::SMALLSKIP:
1551 fl_set_choice (fd_form_paragraph->choice_space_below,
1554 case VSpace::MEDSKIP:
1555 fl_set_choice (fd_form_paragraph->choice_space_below,
1558 case VSpace::BIGSKIP:
1559 fl_set_choice (fd_form_paragraph->choice_space_below,
1563 fl_set_choice (fd_form_paragraph->choice_space_below,
1566 case VSpace::LENGTH:
1567 fl_set_choice (fd_form_paragraph->choice_space_below,
1569 fl_set_input (fd_form_paragraph->input_space_below,
1570 current_view->text->cursor.par->FirstPhysicalPar()->added_space_bottom.length().asString().c_str());
1573 fl_set_button (fd_form_paragraph->check_space_below,
1574 current_view->text->cursor.par->FirstPhysicalPar()->added_space_bottom.keep());
1576 fl_set_button(fd_form_paragraph->check_noindent,
1577 current_view->text->cursor.par->FirstPhysicalPar()->noindent);
1579 if (current_view->buffer()->isReadonly()) {
1580 DisableParagraphLayout();
1582 EnableParagraphLayout();
1588 void MenuLayoutParagraph()
1590 if (UpdateLayoutParagraph()) {
1591 if (fd_form_paragraph->form_paragraph->visible) {
1592 fl_raise_form(fd_form_paragraph->form_paragraph);
1594 fl_show_form(fd_form_paragraph->form_paragraph,
1595 FL_PLACE_MOUSE, FL_FULLBORDER,
1596 _("Paragraph Environment"));
1603 void DeactivateDocumentButtons ()
1605 fl_deactivate_object (fd_form_document->button_ok);
1606 fl_deactivate_object (fd_form_document->button_apply);
1607 fl_set_object_lcol (fd_form_document->button_ok, FL_INACTIVE);
1608 fl_set_object_lcol (fd_form_document->button_apply, FL_INACTIVE);
1613 void ActivateDocumentButtons ()
1615 fl_activate_object (fd_form_document->button_ok);
1616 fl_activate_object (fd_form_document->button_apply);
1617 fl_set_object_lcol (fd_form_document->button_ok, FL_BLACK);
1618 fl_set_object_lcol (fd_form_document->button_apply, FL_BLACK);
1623 void DisableDocumentLayout ()
1625 DeactivateDocumentButtons ();
1626 fl_deactivate_object (fd_form_document->group_radio_separation);
1627 fl_deactivate_object (fd_form_document->radio_indent);
1628 fl_deactivate_object (fd_form_document->radio_skip);
1629 fl_deactivate_object (fd_form_document->choice_class);
1630 fl_deactivate_object (fd_form_document->choice_pagestyle);
1631 fl_deactivate_object (fd_form_document->choice_fonts);
1632 fl_deactivate_object (fd_form_document->choice_fontsize);
1633 fl_deactivate_object (fd_form_document->input_float_placement);
1634 fl_deactivate_object (fd_form_document->choice_postscript_driver);
1635 fl_deactivate_object (fd_form_document->choice_inputenc);
1636 fl_deactivate_object (fd_form_document->group_radio_sides);
1637 fl_deactivate_object (fd_form_document->radio_sides_one);
1638 fl_deactivate_object (fd_form_document->radio_sides_two);
1639 fl_deactivate_object (fd_form_document->group_radio_columns);
1640 fl_deactivate_object (fd_form_document->radio_columns_one);
1641 fl_deactivate_object (fd_form_document->radio_columns_two);
1642 fl_deactivate_object (fd_form_document->input_extra);
1643 fl_deactivate_object (fd_form_document->choice_language);
1644 combo_language->deactivate();
1645 fl_deactivate_object (fd_form_document->input_default_skip);
1646 fl_deactivate_object (fd_form_document->choice_default_skip);
1647 fl_deactivate_object (fd_form_document->slider_secnumdepth);
1648 fl_deactivate_object (fd_form_document->slider_tocdepth);
1649 fl_deactivate_object (fd_form_document->choice_spacing);
1650 fl_deactivate_object (fd_form_document->input_spacing);
1651 fl_deactivate_object (fd_form_document->check_use_amsmath);
1656 void EnableDocumentLayout ()
1658 ActivateDocumentButtons ();
1659 fl_activate_object (fd_form_document->group_radio_separation);
1660 fl_activate_object (fd_form_document->radio_indent);
1661 fl_activate_object (fd_form_document->radio_skip);
1662 fl_activate_object (fd_form_document->choice_class);
1663 fl_activate_object (fd_form_document->choice_pagestyle);
1664 fl_activate_object (fd_form_document->choice_fonts);
1665 fl_activate_object (fd_form_document->choice_fontsize);
1666 fl_activate_object (fd_form_document->input_float_placement);
1667 fl_activate_object (fd_form_document->choice_postscript_driver);
1668 fl_activate_object (fd_form_document->choice_inputenc);
1669 fl_activate_object (fd_form_document->group_radio_sides);
1670 fl_activate_object (fd_form_document->radio_sides_one);
1671 fl_activate_object (fd_form_document->radio_sides_two);
1672 fl_activate_object (fd_form_document->group_radio_columns);
1673 fl_activate_object (fd_form_document->radio_columns_one);
1674 fl_activate_object (fd_form_document->radio_columns_two);
1675 fl_activate_object (fd_form_document->input_extra);
1676 fl_activate_object (fd_form_document->choice_language);
1677 combo_language->activate();
1678 fl_activate_object (fd_form_document->input_default_skip);
1679 fl_activate_object (fd_form_document->choice_default_skip);
1680 fl_activate_object (fd_form_document->slider_secnumdepth);
1681 fl_activate_object (fd_form_document->slider_tocdepth);
1682 fl_activate_object (fd_form_document->choice_spacing);
1683 fl_activate_object (fd_form_document->input_spacing);
1684 fl_activate_object (fd_form_document->check_use_amsmath);
1688 bool UpdateLayoutDocument(BufferParams * params)
1690 if (!current_view->available()) {
1691 if (fd_form_document->form_document->visible)
1692 fl_hide_form(fd_form_document->form_document);
1697 params = ¤t_view->buffer()->params;
1698 LyXTextClass const & tclass = textclasslist.TextClass(params->textclass);
1700 fl_set_choice_text(fd_form_document->choice_class,
1701 textclasslist.DescOfClass(params->textclass).c_str());
1702 combo_language->select_text(params->language.c_str());
1704 fl_set_choice_text(fd_form_document->choice_fonts,
1705 params->fonts.c_str());
1706 fl_set_choice_text(fd_form_document->choice_inputenc,
1707 params->inputenc.c_str());
1708 fl_set_choice_text(fd_form_document->choice_postscript_driver,
1709 params->graphicsDriver.c_str());
1711 // ale970405+lasgoutt970513
1712 fl_clear_choice(fd_form_document->choice_fontsize);
1713 fl_addto_choice(fd_form_document->choice_fontsize, "default");
1714 fl_addto_choice(fd_form_document->choice_fontsize,
1715 tclass.opt_fontsize().c_str());
1716 fl_set_choice(fd_form_document->choice_fontsize,
1717 tokenPos(tclass.opt_fontsize(), '|', params->fontsize) + 2);
1719 // ale970405+lasgoutt970513
1720 fl_clear_choice(fd_form_document->choice_pagestyle);
1721 fl_addto_choice(fd_form_document->choice_pagestyle, "default");
1722 fl_addto_choice(fd_form_document->choice_pagestyle,
1723 tclass.opt_pagestyle().c_str());
1725 fl_set_choice(fd_form_document->choice_pagestyle,
1726 tokenPos(tclass.opt_pagestyle(), '|', params->pagestyle) + 2);
1728 fl_set_button(fd_form_document->radio_indent, 0);
1729 fl_set_button(fd_form_document->radio_skip, 0);
1732 fl_set_button(fd_form_document->check_use_amsmath, params->use_amsmath);
1734 if (params->paragraph_separation == BufferParams::PARSEP_INDENT)
1735 fl_set_button(fd_form_document->radio_indent, 1);
1737 fl_set_button(fd_form_document->radio_skip, 1);
1739 switch (params->getDefSkip().kind()) {
1740 case VSpace::SMALLSKIP:
1741 fl_set_choice (fd_form_document->choice_default_skip, 1);
1743 case VSpace::MEDSKIP:
1744 fl_set_choice (fd_form_document->choice_default_skip, 2);
1746 case VSpace::BIGSKIP:
1747 fl_set_choice (fd_form_document->choice_default_skip, 3);
1749 case VSpace::LENGTH:
1750 fl_set_choice (fd_form_document->choice_default_skip, 4);
1751 fl_set_input (fd_form_document->input_default_skip,
1752 params->getDefSkip().asLyXCommand().c_str());
1755 fl_set_choice (fd_form_document->choice_default_skip, 2);
1759 fl_set_button(fd_form_document->radio_sides_one, 0);
1760 fl_set_button(fd_form_document->radio_sides_two, 0);
1762 switch (params->sides) {
1763 case LyXTextClass::OneSide:
1764 fl_set_button(fd_form_document->radio_sides_one, 1);
1766 case LyXTextClass::TwoSides:
1767 fl_set_button(fd_form_document->radio_sides_two, 1);
1771 fl_set_button(fd_form_document->radio_columns_one, 0);
1772 fl_set_button(fd_form_document->radio_columns_two, 0);
1774 if (params->columns == 2)
1775 fl_set_button(fd_form_document->radio_columns_two, 1);
1777 fl_set_button(fd_form_document->radio_columns_one, 1);
1779 fl_set_input(fd_form_document->input_spacing, "");
1780 switch (params->spacing.getSpace()) {
1781 case Spacing::Default: // nothing bad should happen with this
1782 case Spacing::Single:
1785 fl_set_choice(fd_form_document->choice_spacing, 1);
1788 case Spacing::Onehalf:
1791 fl_set_choice(fd_form_document->choice_spacing, 2);
1794 case Spacing::Double:
1797 fl_set_choice(fd_form_document->choice_spacing, 3);
1800 case Spacing::Other:
1802 fl_set_choice(fd_form_document->choice_spacing, 4);
1804 //sprintf(sval, "%g", params->spacing.getValue());
1806 std::ostringstream sval;
1807 sval << params->spacing.getValue(); // setw?
1808 fl_set_input(fd_form_document->input_spacing,
1809 sval.str().c_str());
1812 ostrstream sval(tval, 20);
1813 sval << params->spacing.getValue() << '\0'; // setw?
1814 fl_set_input(fd_form_document->input_spacing, sval.str());
1821 fl_set_counter_value(fd_form_document->slider_secnumdepth,
1822 params->secnumdepth);
1823 fl_set_counter_value(fd_form_document->slider_tocdepth,
1825 if (!params->float_placement.empty()) { // buffer local (Lgb)
1826 fl_set_input(fd_form_document->input_float_placement,
1827 params->float_placement.c_str());
1829 fl_set_input(fd_form_document->input_float_placement, "");
1831 if (!params->options.empty())
1832 fl_set_input(fd_form_document->input_extra,
1833 params->options.c_str());
1835 fl_set_input(fd_form_document->input_extra, "");
1837 if (current_view->buffer()->isSGML()) {
1838 // bullets not used in SGML derived documents
1839 fl_deactivate_object(fd_form_document->button_bullets);
1840 fl_set_object_lcol(fd_form_document->button_bullets,
1843 fl_activate_object(fd_form_document->button_bullets);
1844 fl_set_object_lcol(fd_form_document->button_bullets,
1848 if (current_view->buffer()->isReadonly()) {
1849 DisableDocumentLayout();
1851 EnableDocumentLayout();
1858 void MenuLayoutDocument()
1860 if (UpdateLayoutDocument()) {
1861 if (fd_form_document->form_document->visible) {
1862 fl_raise_form(fd_form_document->form_document);
1864 fl_show_form(fd_form_document->form_document,
1865 FL_PLACE_MOUSE, FL_FULLBORDER,
1866 _("Document Layout"));
1872 bool UpdateLayoutQuotes()
1875 if (!current_view->available()
1876 || current_view->buffer()->isReadonly())
1880 fl_set_choice(fd_form_quotes->choice_quotes_language,
1881 current_view->buffer()->params.quotes_language + 1);
1882 fl_set_button(fd_form_quotes->radio_single, 0);
1883 fl_set_button(fd_form_quotes->radio_double, 0);
1885 if (current_view->buffer()->params.quotes_times == InsetQuotes::SingleQ)
1886 fl_set_button(fd_form_quotes->radio_single, 1);
1888 fl_set_button(fd_form_quotes->radio_double, 1);
1889 } else if (fd_form_quotes->form_quotes->visible) {
1890 fl_hide_form(fd_form_quotes->form_quotes);
1896 void MenuLayoutQuotes()
1898 if (UpdateLayoutQuotes()) {
1899 if (fd_form_quotes->form_quotes->visible) {
1900 fl_raise_form(fd_form_quotes->form_quotes);
1902 fl_show_form(fd_form_quotes->form_quotes,
1903 FL_PLACE_MOUSE, FL_FULLBORDER,
1910 bool UpdateLayoutPreamble()
1913 if (!current_view->available())
1917 fl_set_input(fd_form_preamble->input_preamble,
1918 current_view->buffer()->params.preamble.c_str());
1920 if (current_view->buffer()->isReadonly()) {
1921 fl_deactivate_object(fd_form_preamble->input_preamble);
1922 fl_deactivate_object(fd_form_preamble->button_ok);
1923 fl_deactivate_object(fd_form_preamble->button_apply);
1924 fl_set_object_lcol(fd_form_preamble->button_ok, FL_INACTIVE);
1925 fl_set_object_lcol(fd_form_preamble->button_apply, FL_INACTIVE);
1928 fl_activate_object(fd_form_preamble->input_preamble);
1929 fl_activate_object(fd_form_preamble->button_ok);
1930 fl_activate_object(fd_form_preamble->button_apply);
1931 fl_set_object_lcol(fd_form_preamble->button_ok, FL_BLACK);
1932 fl_set_object_lcol(fd_form_preamble->button_apply, FL_BLACK);
1934 } else if (fd_form_preamble->form_preamble->visible) {
1935 fl_hide_form(fd_form_preamble->form_preamble);
1941 void MenuLayoutPreamble()
1943 static int ow = -1, oh;
1945 if (UpdateLayoutPreamble()) {
1946 if (fd_form_preamble->form_preamble->visible) {
1947 fl_raise_form(fd_form_preamble->form_preamble);
1949 fl_show_form(fd_form_preamble->form_preamble,
1950 FL_PLACE_MOUSE | FL_FREE_SIZE,
1952 _("LaTeX Preamble"));
1954 ow = fd_form_preamble->form_preamble->w;
1955 oh = fd_form_preamble->form_preamble->h;
1957 fl_set_form_minsize(fd_form_preamble->form_preamble,
1964 void MenuLayoutSave()
1966 if (!current_view->available())
1969 if (AskQuestion(_("Do you want to save the current settings"),
1970 _("for Character, Document, Paper and Quotes"),
1971 _("as default for new documents?")))
1972 current_view->buffer()->saveParamsAsDefaults();
1976 // This is both GUI and LyXFont dependent. Don't know where to put it. (Asger)
1977 // Well, it's mostly GUI dependent, so I guess it will stay here. (Asger)
1978 LyXFont UserFreeFont()
1980 LyXFont font(LyXFont::ALL_IGNORE);
1982 int pos = fl_get_choice(fd_form_character->choice_family);
1984 case 1: font.setFamily(LyXFont::IGNORE_FAMILY); break;
1985 case 2: font.setFamily(LyXFont::ROMAN_FAMILY); break;
1986 case 3: font.setFamily(LyXFont::SANS_FAMILY); break;
1987 case 4: font.setFamily(LyXFont::TYPEWRITER_FAMILY); break;
1988 case 5: font.setFamily(LyXFont::INHERIT_FAMILY); break;
1991 pos = fl_get_choice(fd_form_character->choice_series);
1993 case 1: font.setSeries(LyXFont::IGNORE_SERIES); break;
1994 case 2: font.setSeries(LyXFont::MEDIUM_SERIES); break;
1995 case 3: font.setSeries(LyXFont::BOLD_SERIES); break;
1996 case 4: font.setSeries(LyXFont::INHERIT_SERIES); break;
1999 pos = fl_get_choice(fd_form_character->choice_shape);
2001 case 1: font.setShape(LyXFont::IGNORE_SHAPE); break;
2002 case 2: font.setShape(LyXFont::UP_SHAPE); break;
2003 case 3: font.setShape(LyXFont::ITALIC_SHAPE); break;
2004 case 4: font.setShape(LyXFont::SLANTED_SHAPE); break;
2005 case 5: font.setShape(LyXFont::SMALLCAPS_SHAPE); break;
2006 case 6: font.setShape(LyXFont::INHERIT_SHAPE); break;
2009 pos = fl_get_choice(fd_form_character->choice_size);
2011 case 1: font.setSize(LyXFont::IGNORE_SIZE); break;
2012 case 2: font.setSize(LyXFont::SIZE_TINY); break;
2013 case 3: font.setSize(LyXFont::SIZE_SCRIPT); break;
2014 case 4: font.setSize(LyXFont::SIZE_FOOTNOTE); break;
2015 case 5: font.setSize(LyXFont::SIZE_SMALL); break;
2016 case 6: font.setSize(LyXFont::SIZE_NORMAL); break;
2017 case 7: font.setSize(LyXFont::SIZE_LARGE); break;
2018 case 8: font.setSize(LyXFont::SIZE_LARGER); break;
2019 case 9: font.setSize(LyXFont::SIZE_LARGEST); break;
2020 case 10: font.setSize(LyXFont::SIZE_HUGE); break;
2021 case 11: font.setSize(LyXFont::SIZE_HUGER); break;
2022 case 12: font.setSize(LyXFont::INCREASE_SIZE); break;
2023 case 13: font.setSize(LyXFont::DECREASE_SIZE); break;
2024 case 14: font.setSize(LyXFont::INHERIT_SIZE); break;
2027 pos = fl_get_choice(fd_form_character->choice_bar);
2029 case 1: font.setEmph(LyXFont::IGNORE);
2030 font.setUnderbar(LyXFont::IGNORE);
2031 font.setNoun(LyXFont::IGNORE);
2032 font.setLatex(LyXFont::IGNORE);
2034 case 2: font.setEmph(LyXFont::TOGGLE); break;
2035 case 3: font.setUnderbar(LyXFont::TOGGLE); break;
2036 case 4: font.setNoun(LyXFont::TOGGLE); break;
2037 case 5: font.setLatex(LyXFont::TOGGLE); break;
2038 case 6: font.setEmph(LyXFont::INHERIT);
2039 font.setUnderbar(LyXFont::INHERIT);
2040 font.setNoun(LyXFont::INHERIT);
2041 font.setLatex(LyXFont::INHERIT);
2045 pos = fl_get_choice(fd_form_character->choice_color);
2047 case 1: font.setColor(LColor::ignore); break;
2048 case 2: font.setColor(LColor::none); break;
2049 case 3: font.setColor(LColor::black); break;
2050 case 4: font.setColor(LColor::white); break;
2051 case 5: font.setColor(LColor::red); break;
2052 case 6: font.setColor(LColor::green); break;
2053 case 7: font.setColor(LColor::blue); break;
2054 case 8: font.setColor(LColor::cyan); break;
2055 case 9: font.setColor(LColor::magenta); break;
2056 case 10: font.setColor(LColor::yellow); break;
2057 case 11: font.setColor(LColor::inherit); break;
2060 string language = combo_language2->getline();
2061 Languages::iterator lit = languages.find(language);
2062 if (lit != languages.end())
2063 font.setLanguage(&(*lit).second);
2065 font.setLanguage(ignore_language);
2074 /* callbacks for form form_title */
2075 extern "C" void TimerCB(FL_OBJECT *, long)
2077 // only if the form still exists
2078 if (lyxrc.show_banner && fd_form_title->form_title != 0) {
2079 if (fd_form_title->form_title->visible) {
2080 fl_hide_form(fd_form_title->form_title);
2082 fl_free_form(fd_form_title->form_title);
2083 fd_form_title->form_title = 0;
2088 /* callbacks for form form_paragraph */
2090 extern "C" void ParagraphVSpaceCB(FL_OBJECT * obj, long )
2092 // "Synchronize" the choices and input fields, making it
2093 // impossible to commit senseless data.
2095 FD_form_paragraph const * fp = fd_form_paragraph;
2097 if (obj == fp->choice_space_above) {
2098 if (fl_get_choice (fp->choice_space_above) != 7) {
2099 fl_set_input (fp->input_space_above, "");
2100 ActivateParagraphButtons();
2102 } else if (obj == fp->choice_space_below) {
2103 if (fl_get_choice (fp->choice_space_below) != 7) {
2104 fl_set_input (fp->input_space_below, "");
2105 ActivateParagraphButtons();
2107 } else if (obj == fp->input_space_above) {
2108 string input = fl_get_input (fp->input_space_above);
2110 if (input.empty()) {
2111 fl_set_choice (fp->choice_space_above, 1);
2112 ActivateParagraphButtons();
2114 else if (isValidGlueLength (input)) {
2115 fl_set_choice (fp->choice_space_above, 7);
2116 ActivateParagraphButtons();
2119 fl_set_choice (fp->choice_space_above, 7);
2120 DeactivateParagraphButtons();
2122 } else if (obj == fp->input_space_below) {
2123 string input = fl_get_input (fp->input_space_below);
2125 if (input.empty()) {
2126 fl_set_choice (fp->choice_space_below, 1);
2127 ActivateParagraphButtons();
2129 else if (isValidGlueLength (input)) {
2130 fl_set_choice (fp->choice_space_below, 7);
2131 ActivateParagraphButtons();
2134 fl_set_choice (fp->choice_space_below, 7);
2135 DeactivateParagraphButtons();
2141 extern "C" void ParagraphApplyCB(FL_OBJECT *, long)
2143 if (!current_view->available())
2146 VSpace space_top, space_bottom;
2148 string labelwidthstring;
2151 // If a vspace kind is "Length" but there's no text in
2152 // the input field, reset the kind to "None".
2153 if (fl_get_choice (fd_form_paragraph->choice_space_above) == 7
2154 && !*(fl_get_input (fd_form_paragraph->input_space_above))) {
2155 fl_set_choice (fd_form_paragraph->choice_space_above, 1);
2157 if (fl_get_choice (fd_form_paragraph->choice_space_below) == 7
2158 && !*(fl_get_input (fd_form_paragraph->input_space_below))) {
2159 fl_set_choice (fd_form_paragraph->choice_space_below, 1);
2162 bool line_top = fl_get_button(fd_form_paragraph->check_lines_top);
2163 bool line_bottom = fl_get_button(fd_form_paragraph->check_lines_bottom);
2164 bool pagebreak_top = fl_get_button(fd_form_paragraph->check_pagebreaks_top);
2165 bool pagebreak_bottom = fl_get_button(fd_form_paragraph->check_pagebreaks_bottom);
2166 switch (fl_get_choice (fd_form_paragraph->choice_space_above)) {
2167 case 1: space_top = VSpace(VSpace::NONE); break;
2168 case 2: space_top = VSpace(VSpace::DEFSKIP); break;
2169 case 3: space_top = VSpace(VSpace::SMALLSKIP); break;
2170 case 4: space_top = VSpace(VSpace::MEDSKIP); break;
2171 case 5: space_top = VSpace(VSpace::BIGSKIP); break;
2172 case 6: space_top = VSpace(VSpace::VFILL); break;
2173 case 7: space_top = VSpace(LyXGlueLength (fl_get_input (fd_form_paragraph->input_space_above))); break;
2175 if (fl_get_button (fd_form_paragraph->check_space_above))
2176 space_top.setKeep (true);
2177 switch (fl_get_choice (fd_form_paragraph->choice_space_below)) {
2178 case 1: space_bottom = VSpace(VSpace::NONE); break;
2179 case 2: space_bottom = VSpace(VSpace::DEFSKIP); break;
2180 case 3: space_bottom = VSpace(VSpace::SMALLSKIP); break;
2181 case 4: space_bottom = VSpace(VSpace::MEDSKIP); break;
2182 case 5: space_bottom = VSpace(VSpace::BIGSKIP); break;
2183 case 6: space_bottom = VSpace(VSpace::VFILL); break;
2184 case 7: space_bottom = VSpace(LyXGlueLength (fl_get_input (fd_form_paragraph->input_space_below))); break;
2186 if (fl_get_button (fd_form_paragraph->check_space_below))
2187 space_bottom.setKeep (true);
2189 if (fl_get_button(fd_form_paragraph->radio_align_left))
2190 align = LYX_ALIGN_LEFT;
2191 else if (fl_get_button(fd_form_paragraph->radio_align_right))
2192 align = LYX_ALIGN_RIGHT;
2193 else if (fl_get_button(fd_form_paragraph->radio_align_center))
2194 align = LYX_ALIGN_CENTER;
2196 align = LYX_ALIGN_BLOCK;
2198 labelwidthstring = fl_get_input(fd_form_paragraph->input_labelwidth);
2199 noindent = fl_get_button(fd_form_paragraph->check_noindent);
2201 current_view->text->SetParagraph(line_top,
2210 current_view->update(1);
2211 current_view->owner()->getMiniBuffer()->Set(_("Paragraph layout set"));
2215 extern "C" void ParagraphCancelCB(FL_OBJECT *, long)
2217 fl_hide_form(fd_form_paragraph->form_paragraph);
2221 extern "C" void ParagraphOKCB(FL_OBJECT *ob, long data)
2223 ParagraphApplyCB(ob, data);
2224 ParagraphCancelCB(ob, data);
2228 /* callbacks for form form_character */
2230 extern "C" void CharacterApplyCB(FL_OBJECT *, long)
2232 // we set toggleall locally here, since it should be true for
2233 // all other uses of ToggleAndShow() (JMarc)
2234 toggleall = fl_get_button(fd_form_character->check_toggle_all);
2235 ToggleAndShow(current_view, UserFreeFont());
2236 current_view->setState();
2241 extern "C" void CharacterCloseCB(FL_OBJECT *, long)
2243 fl_hide_form(fd_form_character->form_character);
2247 extern "C" void CharacterOKCB(FL_OBJECT *ob, long data)
2249 CharacterApplyCB(ob, data);
2250 CharacterCloseCB(ob, data);
2254 /* callbacks for form form_document */
2256 void UpdateDocumentButtons(BufferParams const & params)
2258 fl_set_choice(fd_form_document->choice_pagestyle, 1);
2260 switch (params.sides) {
2261 case LyXTextClass::OneSide:
2262 fl_set_button(fd_form_document->radio_sides_one, 1);
2264 case LyXTextClass::TwoSides:
2265 fl_set_button(fd_form_document->radio_sides_two, 1);
2269 if (params.columns == 2)
2270 fl_set_button(fd_form_document->radio_columns_two, 1);
2272 fl_set_button(fd_form_document->radio_columns_one, 1);
2274 fl_set_input(fd_form_document->input_extra, params.options.c_str());
2275 fl_set_counter_value(fd_form_document->slider_secnumdepth,
2276 params.secnumdepth);
2277 fl_set_counter_value(fd_form_document->slider_tocdepth,
2282 extern "C" void ChoiceClassCB(FL_OBJECT * ob, long)
2284 ProhibitInput(current_view);
2285 if (textclasslist.Load(fl_get_choice(ob)-1)) {
2286 if (AskQuestion(_("Should I set some parameters to"),
2287 fl_get_choice_text(ob),
2288 _("the defaults of this document class?"))) {
2289 BufferParams params = BufferParams();
2290 params.textclass = fl_get_choice(ob)-1;
2291 params.useClassDefaults();
2292 UpdateLayoutDocument(¶ms);
2293 UpdateDocumentButtons(params);
2296 // unable to load new style
2297 WriteAlert(_("Conversion Errors!"),
2298 _("Unable to switch to new document class."),
2299 _("Reverting to original document class."));
2300 fl_set_choice(fd_form_document->choice_class,
2301 current_view->buffer()->params.textclass + 1);
2303 AllowInput(current_view);
2307 extern "C" void DocumentDefskipCB(FL_OBJECT * obj, long)
2309 // "Synchronize" the choice and the input field, so that it
2310 // is impossible to commit senseless data.
2311 FD_form_document const * fd = fd_form_document;
2313 if (obj == fd->choice_default_skip) {
2314 if (fl_get_choice (fd->choice_default_skip) != 4) {
2315 fl_set_input (fd->input_default_skip, "");
2316 ActivateDocumentButtons();
2318 } else if (obj == fd->input_default_skip) {
2320 char const * input = fl_get_input (fd->input_default_skip);
2323 fl_set_choice (fd->choice_default_skip, 2);
2324 ActivateDocumentButtons();
2325 } else if (isValidGlueLength (input)) {
2326 fl_set_choice (fd->choice_default_skip, 4);
2327 ActivateDocumentButtons();
2329 fl_set_choice (fd->choice_default_skip, 4);
2330 DeactivateDocumentButtons();
2336 extern "C" void DocumentSpacingCB(FL_OBJECT * obj, long)
2338 // "Synchronize" the choice and the input field, so that it
2339 // is impossible to commit senseless data.
2340 FD_form_document const * fd = fd_form_document;
2342 if (obj == fd->choice_spacing
2343 && fl_get_choice (fd->choice_spacing) != 4) {
2344 fl_set_input(fd->input_spacing, "");
2345 } else if (obj == fd->input_spacing) {
2347 const char* input = fl_get_input (fd->input_spacing);
2350 fl_set_choice (fd->choice_spacing, 1);
2352 fl_set_choice (fd->choice_spacing, 4);
2358 extern "C" void DocumentApplyCB(FL_OBJECT *, long)
2361 BufferParams * params = &(current_view->buffer()->params);
2363 Language const * old_language = params->language_info;
2364 params->language = combo_language->getline();
2365 Languages::iterator lit = languages.find(params->language);
2367 Language const * new_language;
2368 if (lit != languages.end())
2369 new_language = &(*lit).second;
2371 new_language = default_language;
2373 if (current_view->available()) {
2374 if (old_language != new_language &&
2375 old_language->RightToLeft == new_language->RightToLeft &&
2376 ! current_view->buffer()->isMultiLingual() ) {
2377 current_view->buffer()->ChangeLanguage(old_language,
2379 current_view->buffer()->redraw();
2382 params->language_info = new_language;
2384 // If default skip is a "Length" but there's no text in the
2385 // input field, reset the kind to "Medskip", which is the default.
2386 if (fl_get_choice (fd_form_document->choice_default_skip) == 4
2387 && !*(fl_get_input (fd_form_document->input_default_skip))) {
2388 fl_set_choice (fd_form_document->choice_default_skip, 2);
2391 /* this shouldn't be done automatically IMO. For example I write german
2392 * documents with an american keyboard very often. Matthias */
2394 /* ChangeKeymap(buffer->parameters.language, TRUE, false,
2395 fl_get_choice(fd_form_document->choice_language)); */
2397 fl_get_choice_text(fd_form_document->choice_fonts);
2399 fl_get_choice_text(fd_form_document->choice_inputenc);
2401 fl_get_choice_text(fd_form_document->choice_fontsize);
2403 fl_get_choice_text(fd_form_document->choice_pagestyle);
2404 params->graphicsDriver =
2405 fl_get_choice_text(fd_form_document->choice_postscript_driver);
2406 params->use_amsmath =
2407 fl_get_button(fd_form_document->check_use_amsmath);
2409 if (!current_view->available())
2412 current_view->text->SetCursor(current_view->text->cursor.par,
2413 current_view->text->cursor.pos);
2414 current_view->setState();
2416 LyXTextClassList::ClassList::size_type new_class =
2417 fl_get_choice(fd_form_document->choice_class) - 1;
2419 if (params->textclass != new_class) {
2420 // try to load new_class
2421 if (textclasslist.Load(new_class)) {
2422 // successfully loaded
2424 current_view->owner()->getMiniBuffer()->
2425 Set(_("Converting document to new document class..."));
2427 int ret = cap.SwitchLayoutsBetweenClasses(
2428 current_view->buffer()->params.textclass,
2430 current_view->buffer()->paragraph);
2435 s = _("One paragraph couldn't be converted");
2438 s += _(" paragraphs couldn't be converted");
2440 WriteAlert(_("Conversion Errors!"), s,
2441 _("into chosen document class"));
2444 params->textclass = new_class;
2446 // problem changing class -- warn user and retain old style
2447 WriteAlert(_("Conversion Errors!"),
2448 _("Unable to switch to new document class."),
2449 _("Reverting to original document class."));
2450 fl_set_choice(fd_form_document->choice_class, params->textclass + 1);
2454 char tmpsep = params->paragraph_separation;
2455 if (fl_get_button(fd_form_document->radio_indent))
2456 params->paragraph_separation = BufferParams::PARSEP_INDENT;
2458 params->paragraph_separation = BufferParams::PARSEP_SKIP;
2459 if (tmpsep != params->paragraph_separation)
2462 VSpace tmpdefskip = params->getDefSkip();
2463 switch (fl_get_choice (fd_form_document->choice_default_skip)) {
2464 case 1: params->setDefSkip(VSpace(VSpace::SMALLSKIP)); break;
2465 case 2: params->setDefSkip(VSpace(VSpace::MEDSKIP)); break;
2466 case 3: params->setDefSkip(VSpace(VSpace::BIGSKIP)); break;
2467 case 4: params->setDefSkip(
2468 VSpace (LyXGlueLength (fl_get_input
2469 (fd_form_document->input_default_skip))));
2471 // DocumentDefskipCB assures that this never happens
2472 default: params->setDefSkip(VSpace(VSpace::MEDSKIP)); break;
2474 if (!(tmpdefskip == params->getDefSkip()))
2477 if (fl_get_button(fd_form_document->radio_columns_two))
2478 params->columns = 2;
2480 params->columns = 1;
2481 if (fl_get_button(fd_form_document->radio_sides_two))
2482 params->sides = LyXTextClass::TwoSides;
2484 params->sides = LyXTextClass::OneSide;
2486 Spacing tmpSpacing = params->spacing;
2487 switch(fl_get_choice(fd_form_document->choice_spacing)) {
2489 lyxerr.debug() << "Spacing: SINGLE" << endl;
2490 params->spacing.set(Spacing::Single);
2493 lyxerr.debug() << "Spacing: ONEHALF" << endl;
2494 params->spacing.set(Spacing::Onehalf);
2497 lyxerr.debug() << "Spacing: DOUBLE" << endl;
2498 params->spacing.set(Spacing::Double);
2501 lyxerr.debug() << "Spacing: OTHER" << endl;
2502 params->spacing.set(Spacing::Other,
2503 fl_get_input(fd_form_document->input_spacing));
2506 if (tmpSpacing != params->spacing)
2509 signed char tmpchar =
2510 static_cast<signed char>(fl_get_counter_value(fd_form_document->slider_secnumdepth));
2511 if (params->secnumdepth != tmpchar)
2513 params->secnumdepth = tmpchar;
2516 static_cast<int>(fl_get_counter_value(fd_form_document->slider_tocdepth));
2518 params->float_placement =
2519 fl_get_input(fd_form_document->input_float_placement);
2521 // More checking should be done to ensure the string doesn't have
2522 // spaces or illegal placement characters in it. (thornley)
2525 current_view->redoCurrentBuffer();
2527 current_view->owner()->getMiniBuffer()->Set(_("Document layout set"));
2528 current_view->buffer()->markDirty();
2531 fl_get_input(fd_form_document->input_extra);
2536 extern "C" void DocumentCancelCB(FL_OBJECT *, long)
2538 fl_hide_form(fd_form_document->form_document);
2542 extern "C" void DocumentOKCB(FL_OBJECT * ob, long data)
2544 DocumentCancelCB(ob, data);
2545 DocumentApplyCB(ob, data);
2549 extern "C" void DocumentBulletsCB(FL_OBJECT *, long)
2552 // bullet callbacks etc. in bullet_panel.C -- ARRae
2556 /* callbacks for form form_quotes */
2558 extern "C" void QuotesApplyCB(FL_OBJECT *, long)
2560 if (!current_view->available())
2563 current_view->owner()->getMiniBuffer()->Set(_("Quotes type set"));
2564 InsetQuotes::quote_language lga = InsetQuotes::EnglishQ;
2565 switch(fl_get_choice(fd_form_quotes->choice_quotes_language) - 1) {
2567 lga = InsetQuotes::EnglishQ;
2570 lga = InsetQuotes::SwedishQ;
2573 lga = InsetQuotes::GermanQ;
2576 lga = InsetQuotes::PolishQ;
2579 lga = InsetQuotes::FrenchQ;
2582 lga = InsetQuotes::DanishQ;
2585 current_view->buffer()->params.quotes_language = lga;
2586 if (fl_get_button(fd_form_quotes->radio_single))
2587 current_view->buffer()->
2588 params.quotes_times = InsetQuotes::SingleQ;
2590 current_view->buffer()->
2591 params.quotes_times = InsetQuotes::DoubleQ;
2595 extern "C" void QuotesCancelCB(FL_OBJECT *, long)
2597 fl_hide_form(fd_form_quotes->form_quotes);
2601 extern "C" void QuotesOKCB(FL_OBJECT * ob, long data)
2603 QuotesApplyCB(ob, data);
2604 QuotesCancelCB(ob, data);
2609 /* callbacks for form form_preamble */
2611 extern "C" void PreambleCancelCB(FL_OBJECT *, long)
2613 fl_hide_form(fd_form_preamble->form_preamble);
2617 extern "C" void PreambleApplyCB(FL_OBJECT *, long)
2619 if (!current_view->available())
2622 current_view->buffer()->params.preamble =
2623 fl_get_input(fd_form_preamble->input_preamble);
2624 current_view->buffer()->markDirty();
2625 current_view->owner()->getMiniBuffer()->Set(_("LaTeX preamble set"));
2629 extern "C" void PreambleOKCB(FL_OBJECT * ob, long data)
2631 PreambleApplyCB(ob, data);
2632 PreambleCancelCB(ob, data);
2636 /* callbacks for form form_table */
2638 extern "C" void TableApplyCB(FL_OBJECT *, long)
2640 if (!current_view->available())
2643 // check for tables in tables
2644 if (current_view->text->cursor.par->table){
2645 WriteAlert(_("Impossible Operation!"),
2646 _("Cannot insert table in table."),
2651 current_view->owner()->getMiniBuffer()->Set(_("Inserting table..."));
2653 int ysize = int(fl_get_slider_value(fd_form_table->slider_columns) + 0.5);
2654 int xsize = int(fl_get_slider_value(fd_form_table->slider_rows) + 0.5);
2657 current_view->hideCursor();
2658 current_view->beforeChange();
2659 current_view->update(-2);
2661 current_view->text->SetCursorParUndo();
2662 current_view->text->FreezeUndo();
2664 current_view->text->BreakParagraph();
2665 current_view->update(-1);
2667 if (current_view->text->cursor.par->Last()) {
2668 current_view->text->CursorLeft();
2670 current_view->text->BreakParagraph();
2671 current_view->update(-1);
2674 current_view->text->current_font.setLatex(LyXFont::OFF);
2675 //if (!fl_get_button(fd_form_table->check_latex)){
2676 // insert the new wysiwy table
2677 current_view->text->SetLayout(0); // standard layout
2678 if (current_view->text->cursor.par->footnoteflag ==
2679 LyXParagraph::NO_FOOTNOTE) {
2681 ->SetParagraph(0, 0,
2683 VSpace (0.3 * current_view->buffer()->
2684 params.spacing.getValue(),
2686 VSpace (0.3 * current_view->buffer()->
2687 params.spacing.getValue(),
2694 ->SetParagraph(0, 0,
2696 VSpace(VSpace::NONE),
2697 VSpace(VSpace::NONE),
2703 current_view->text->cursor.par->table =
2704 new LyXTable(xsize, ysize);
2706 Language const * lang =
2707 current_view->text->cursor.par->getParLanguage();
2708 LyXFont font(LyXFont::ALL_INHERIT, lang);
2709 for (int i = 0; i < xsize * ysize - 1; ++i) {
2710 current_view->text->cursor.par->InsertChar(0, LyXParagraph::META_NEWLINE);
2711 current_view->text->cursor.par->SetFont(0, font);
2713 current_view->text->RedoParagraph();
2715 current_view->text->UnFreezeUndo();
2717 current_view->update(1);
2718 current_view->owner()->getMiniBuffer()->Set(_("Table inserted"));
2719 current_view->setState();
2723 extern "C" void TableCancelCB(FL_OBJECT *, long)
2725 fl_hide_form(fd_form_table->form_table);
2729 extern "C" void TableOKCB(FL_OBJECT * ob, long data)
2731 TableApplyCB(ob, data);
2732 TableCancelCB(ob, data);
2736 /* callbacks for form form_print */
2738 extern "C" void PrintCancelCB(FL_OBJECT *, long)
2740 fl_hide_form(fd_form_print->form_print);
2745 bool stringOnlyContains (string const & LStr, char const * cset)
2747 return LStr.find_first_not_of(cset) == string::npos;
2751 extern "C" void PrintApplyCB(FL_OBJECT *, long)
2753 if (!current_view->available())
2755 Buffer * buffer = current_view->buffer();
2756 string path = OnlyPath(buffer->fileName());
2759 if (fl_get_button(fd_form_print->radio_even_pages))
2760 pageflag = lyxrc.print_evenpage_flag + ' ';
2761 else if (fl_get_button(fd_form_print->radio_odd_pages))
2762 pageflag = lyxrc.print_oddpage_flag + ' ';
2764 // Changes by Stephan Witt (stephan.witt@beusen.de), 19-Jan-99
2765 // User may give a page (range) list
2766 // User may print multiple (unsorted) copies
2767 string pages = subst(fl_get_input(fd_form_print->input_pages), ';',',');
2768 pages = subst(pages, '+',',');
2769 pages = frontStrip(strip(pages)) ;
2770 while (!pages.empty()) { // a page range was given
2772 pages = split (pages, piece, ',') ;
2773 piece = strip(piece) ;
2774 piece = frontStrip(piece) ;
2775 if ( !stringOnlyContains (piece, "0123456789-") ) {
2776 WriteAlert(_("ERROR! Unable to print!"),
2777 _("Check 'range of pages'!"));
2780 if (piece.find('-') == string::npos) { // not found
2781 pageflag += lyxrc.print_pagerange_flag + piece + '-' + piece + ' ' ;
2782 } else if (suffixIs(piece, "-") ) { // missing last page
2783 pageflag += lyxrc.print_pagerange_flag + piece + "1000 ";
2784 } else if (prefixIs(piece, "-") ) { // missing first page
2785 pageflag += lyxrc.print_pagerange_flag + '1' + piece + ' ' ;
2787 pageflag += lyxrc.print_pagerange_flag + piece + ' ' ;
2791 string copies = frontStrip(strip(fl_get_input(fd_form_print->input_copies)));
2792 if (!copies.empty()) { // a number of copies was given
2793 if ( !stringOnlyContains (copies, "0123456789") ) {
2794 WriteAlert(_("ERROR! Unable to print!"),
2795 _("Check 'number of copies'!"));
2798 if (fl_get_button(fd_form_print->do_unsorted))
2799 pageflag += lyxrc.print_copies_flag;
2801 pageflag += lyxrc.print_collcopies_flag;
2802 pageflag += " " + copies + ' ' ;
2806 if (fl_get_button(fd_form_print->radio_order_reverse))
2807 reverseflag = lyxrc.print_reverse_flag + ' ';
2809 string orientationflag;
2810 if (buffer->params.orientation == BufferParams::ORIENTATION_LANDSCAPE)
2811 orientationflag = lyxrc.print_landscape_flag + ' ';
2813 string ps_file = fl_get_input(fd_form_print->input_file);
2814 string printer = strip(fl_get_input(fd_form_print->input_printer));
2817 if (lyxrc.print_adapt_output // printer name should be passed to dvips
2818 && ! printer.empty()) // a printer name has been given
2819 printerflag = lyxrc.print_to_printer + printer + ' ';
2822 if (!lyxrc.print_extra_options.empty())
2823 extraflags = lyxrc.print_extra_options + ' ';
2825 string command = lyxrc.print_command + ' '
2826 + printerflag + pageflag + reverseflag
2827 + orientationflag + extraflags;
2829 char real_papersize = buffer->params.papersize;
2830 if (real_papersize == BufferParams::PAPER_DEFAULT)
2831 real_papersize = lyxrc.default_papersize;
2834 switch (real_papersize) {
2835 case BufferParams::PAPER_USLETTER:
2838 case BufferParams::PAPER_A3PAPER:
2841 case BufferParams::PAPER_A4PAPER:
2844 case BufferParams::PAPER_A5PAPER:
2847 case BufferParams::PAPER_B5PAPER:
2850 case BufferParams::PAPER_EXECUTIVEPAPER:
2853 case BufferParams::PAPER_LEGALPAPER:
2856 default: /* If nothing else fits, keep an empty value... */
2860 if (buffer->params.use_geometry
2861 && buffer->params.papersize2 == BufferParams::VM_PAPER_CUSTOM
2862 && !lyxrc.print_paper_dimension_flag.empty()
2863 && !buffer->params.paperwidth.empty()
2864 && !buffer->params.paperheight.empty()) {
2865 // using a custom papersize
2867 command += lyxrc.print_paper_dimension_flag + ' ';
2868 command += buffer->params.paperwidth + ',';
2869 command += buffer->params.paperheight + ' ';
2870 } else if (!lyxrc.print_paper_flag.empty()
2872 && (real_papersize != BufferParams::PAPER_USLETTER ||
2873 buffer->params.orientation == BufferParams::ORIENTATION_PORTRAIT)) {
2874 command += " " + lyxrc.print_paper_flag + " " + paper + " ";
2876 if (fl_get_button(fd_form_print->radio_file))
2877 command += lyxrc.print_to_file
2878 + QuoteName(MakeAbsPath(ps_file, path));
2879 else if (!lyxrc.print_spool_command.empty())
2880 command += lyxrc.print_to_file
2881 + QuoteName(ps_file);
2883 // push directorypath, if necessary
2884 if (lyxrc.use_tempdir || (IsDirWriteable(path) < 1)){
2885 path = buffer->tmppath;
2890 if (!lyxrc.print_spool_command.empty() &&
2891 !fl_get_button(fd_form_print->radio_file)) {
2892 string command2 = lyxrc.print_spool_command + ' ';
2893 if (!printer.empty())
2894 command2 += lyxrc.print_spool_printerprefix
2896 // First run dvips and, if succesful, then spool command
2897 if ((result = RunScript(buffer, true, command))) {
2898 result = RunScript(buffer, false, command2, ps_file);
2901 result = RunScript(buffer, false, command);
2904 WriteAlert(_("Error:"),
2905 _("Unable to print"),
2906 _("Check that your parameters are correct"));
2910 extern "C" void PrintOKCB(FL_OBJECT * ob, long data)
2912 PrintCancelCB(ob, data);
2913 PrintApplyCB(ob, data);
2919 if (fd_form_figure->form_figure->visible) {
2920 fl_raise_form(fd_form_figure->form_figure);
2922 fl_show_form(fd_form_figure->form_figure,
2923 FL_PLACE_MOUSE, FL_FULLBORDER,
2924 _("Insert Figure"));
2931 if (fd_form_table->form_table->visible) {
2932 fl_raise_form(fd_form_table->form_table);
2934 fl_show_form(fd_form_table->form_table,
2935 FL_PLACE_MOUSE, FL_FULLBORDER,
2941 /* callbacks for form form_figure */
2942 extern "C" void FigureApplyCB(FL_OBJECT *, long)
2944 if (!current_view->available())
2947 Buffer * buffer = current_view->buffer();
2948 if(buffer->isReadonly()) // paranoia
2951 current_view->owner()->getMiniBuffer()->Set(_("Inserting figure..."));
2952 if (fl_get_button(fd_form_figure->radio_inline)
2953 || current_view->text->cursor.par->table) {
2954 InsetFig * new_inset = new InsetFig(100, 20, buffer);
2955 current_view->insertInset(new_inset);
2956 current_view->owner()->getMiniBuffer()->Set(_("Figure inserted"));
2957 new_inset->Edit(current_view, 0, 0, 0);
2961 current_view->hideCursor();
2962 current_view->update(-2);
2963 current_view->beforeChange();
2965 current_view->text->SetCursorParUndo();
2966 current_view->text->FreezeUndo();
2968 current_view->text->BreakParagraph();
2969 current_view->update(-1);
2971 if (current_view->text->cursor.par->Last()) {
2972 current_view->text->CursorLeft();
2974 current_view->text->BreakParagraph();
2975 current_view->update(-1);
2978 // The standard layout should always be numer 0;
2979 current_view->text->SetLayout(0);
2981 if (current_view->text->cursor.par->footnoteflag ==
2982 LyXParagraph::NO_FOOTNOTE) {
2983 current_view->text->
2986 VSpace (0.3 * buffer->params.spacing.getValue(),
2989 buffer->params.spacing.getValue(),
2991 LYX_ALIGN_CENTER, string(), 0);
2993 current_view->text->SetParagraph(0, 0,
2995 VSpace(VSpace::NONE),
2996 VSpace(VSpace::NONE),
3002 current_view->update(-1);
3004 Inset * new_inset = new InsetFig(100, 100, buffer);
3005 current_view->insertInset(new_inset);
3006 new_inset->Edit(current_view, 0, 0, 0);
3007 current_view->update(0);
3008 current_view->owner()->getMiniBuffer()->Set(_("Figure inserted"));
3009 current_view->text->UnFreezeUndo();
3010 current_view->setState();
3014 extern "C" void FigureCancelCB(FL_OBJECT *, long)
3016 fl_hide_form(fd_form_figure->form_figure);
3020 extern "C" void FigureOKCB(FL_OBJECT * ob, long data)
3022 FigureApplyCB(ob, data);
3023 FigureCancelCB(ob, data);
3027 extern "C" void ScreenApplyCB(FL_OBJECT *, long)
3029 lyxrc.roman_font_name = fl_get_input(fd_form_screen->input_roman);
3030 lyxrc.sans_font_name = fl_get_input(fd_form_screen->input_sans);
3031 lyxrc.typewriter_font_name = fl_get_input(fd_form_screen->input_typewriter);
3032 lyxrc.font_norm = fl_get_input(fd_form_screen->input_font_norm);
3033 lyxrc.zoom = atoi(fl_get_input(fd_form_screen->intinput_size));
3034 fontloader.update();
3036 // Of course we should only to the resize and the textcahce.clear
3037 // if values really changed...but not very important right now. (Lgb)
3039 // All buffers will need resize
3040 bufferlist.resize();
3041 // We also need to empty the textcache so that
3042 // the buffer will be formatted correctly after
3046 current_view->owner()->getMiniBuffer()->Set(_("Screen options set"));
3050 extern "C" void ScreenCancelCB(FL_OBJECT *, long)
3052 fl_hide_form(fd_form_screen->form_screen);
3056 extern "C" void ScreenOKCB(FL_OBJECT * ob, long data)
3058 ScreenCancelCB(ob, data);
3059 ScreenApplyCB(ob, data);
3063 void LaTeXOptions(BufferView * bv)
3065 if (!bv->available())
3068 fl_set_button(fd_latex_options->accents,
3069 int(bv->buffer()->params.allowAccents));
3071 if (fd_latex_options->LaTeXOptions->visible) {
3072 fl_raise_form(fd_latex_options->LaTeXOptions);
3074 fl_show_form(fd_latex_options->LaTeXOptions,
3075 FL_PLACE_MOUSE, FL_FULLBORDER,
3076 _("LaTeX Options"));
3081 // This function runs "configure" and then rereads lyx.defaults to
3082 // reconfigure the automatic settings.
3083 void Reconfigure(BufferView * bv)
3085 bv->owner()->getMiniBuffer()->Set(_("Running configure..."));
3087 // Run configure in user lyx directory
3088 Path p(user_lyxdir);
3089 Systemcalls one(Systemcalls::System,
3090 AddName(system_lyxdir, "configure"));
3092 bv->owner()->getMiniBuffer()->Set(_("Reloading configuration..."));
3093 lyxrc.read(LibFileSearch(string(), "lyxrc.defaults"));
3094 WriteAlert(_("The system has been reconfigured."),
3095 _("You need to restart LyX to make use of any"),
3096 _("updated document class specifications."));
3101 // Table of Contents
3104 static vector<Buffer::TocItem> toclist;
3107 extern "C" void TocSelectCB(FL_OBJECT * ob, long)
3109 if (!current_view->available())
3113 unsigned int choice = fl_get_browser(ob);
3114 if (0 < choice && choice - 1 < toclist.size()) {
3115 current_view->beforeChange();
3116 current_view->text->SetCursor(toclist[choice-1].par, 0);
3117 current_view->text->sel_cursor =
3118 current_view->text->cursor;
3119 current_view->update(0);
3121 WriteAlert(_("Error"),
3122 _("Couldn't find this label"),
3123 _("in current document."));
3128 extern "C" void TocCancelCB(FL_OBJECT *, long)
3130 fl_hide_form(fd_form_toc->form_toc);
3134 extern "C" void TocUpdateCB(FL_OBJECT *, long)
3136 if (!current_view->available()) {
3138 fl_clear_browser(fd_form_toc->browser_toc);
3139 fl_add_browser_line(fd_form_toc->browser_toc,
3140 _("*** No Document ***"));
3144 vector<vector<Buffer::TocItem> > tmp =
3145 current_view->buffer()->getTocList();
3146 if (toclist == tmp[0])
3150 static Buffer * buffer = 0;
3153 if (buffer == current_view->buffer()) {
3154 topline = fl_get_browser_topline(fd_form_toc->browser_toc);
3155 line = fl_get_browser(fd_form_toc->browser_toc);
3157 buffer = current_view->buffer();
3159 fl_clear_browser(fd_form_toc->browser_toc);
3160 fl_hide_object(fd_form_toc->browser_toc);
3162 for (vector<Buffer::TocItem>::const_iterator it = toclist.begin();
3163 it != toclist.end(); ++it)
3164 fl_add_browser_line(fd_form_toc->browser_toc,
3165 (string(4*(*it).depth,' ')+
3166 (*it).str).c_str());
3168 fl_set_browser_topline(fd_form_toc->browser_toc, topline);
3169 fl_select_browser_line(fd_form_toc->browser_toc, line);
3170 fl_show_object(fd_form_toc->browser_toc);
3174 /* callbacks for form form_ref */
3175 extern "C" void RefSelectCB(FL_OBJECT *, long data)
3177 if (!current_view->available())
3181 fl_get_browser_line(fd_form_ref->browser_ref,
3182 fl_get_browser(fd_form_ref->browser_ref));
3183 string u = frontStrip(strip(fl_get_input(fd_form_ref->ref_name)));
3189 current_view->owner()->getLyXFunc()->Dispatch(LFUN_REFGOTO, s.c_str());
3193 static string const commands[5]
3194 = { "\\ref", "\\pageref", "\\vref", "\\vpageref",
3196 string t = commands[data];
3198 if (current_view->buffer()->isSGML())
3199 t += "[" + u + "]" + "{" + s + "}";
3204 new InsetRef(t, current_view->buffer());
3205 current_view->insertInset(new_inset);
3209 extern "C" void RefUpdateCB(FL_OBJECT *, long)
3211 if (!current_view->available()) {
3212 fl_clear_browser(fd_form_ref->browser_ref);
3216 FL_OBJECT * brow = fd_form_ref->browser_ref;
3218 // Get the current line, in order to restore it later
3219 char const * const btmp = fl_get_browser_line(brow,
3220 fl_get_browser(brow));
3221 string currentstr = btmp ? btmp : "";
3223 fl_clear_browser(brow);
3224 fl_hide_object(brow);
3226 vector<string> refs = current_view->buffer()->getLabelList();
3227 if (fl_get_button(fd_form_ref->sort))
3228 sort(refs.begin(),refs.end());
3229 for (vector<string>::const_iterator it = refs.begin();
3230 it != refs.end(); ++it)
3231 fl_add_browser_line(brow, (*it).c_str());
3234 int total_lines = fl_get_browser_maxline(brow);
3235 for (int i = 1; i <= total_lines ; ++i) {
3236 if (fl_get_browser_line(brow, i) == currentstr) {
3241 fl_set_browser_topline(brow, topline);
3243 if (!fl_get_browser_maxline(brow)) {
3244 fl_add_browser_line(brow,
3245 _("*** No labels found in document ***"));
3246 fl_deactivate_object(brow);
3248 fl_select_browser_line(brow, topline);
3249 fl_activate_object(brow);
3251 if (current_view->buffer()->isReadonly()) {
3252 // would be better to de/activate insert buttons
3253 // but that's more work... besides this works. ARRae
3254 fl_hide_form(fd_form_ref->form_ref);
3256 if (!current_view->buffer()->isSGML()) {
3257 fl_deactivate_object(fd_form_ref->ref_name);
3258 fl_set_object_lcol(fd_form_ref->ref_name, FL_INACTIVE);
3260 fl_activate_object(fd_form_ref->vref);
3261 fl_set_object_lcol(fd_form_ref->vref, FL_BLACK);
3262 fl_activate_object(fd_form_ref->vpageref);
3263 fl_set_object_lcol(fd_form_ref->vpageref, FL_BLACK);
3264 fl_activate_object(fd_form_ref->prettyref);
3265 fl_set_object_lcol(fd_form_ref->prettyref, FL_BLACK);
3267 fl_activate_object(fd_form_ref->ref_name);
3268 fl_set_object_lcol(fd_form_ref->ref_name, FL_BLACK);
3270 fl_deactivate_object(fd_form_ref->vref);
3271 fl_set_object_lcol(fd_form_ref->vref, FL_INACTIVE);
3272 fl_deactivate_object(fd_form_ref->vpageref);
3273 fl_set_object_lcol(fd_form_ref->vpageref, FL_INACTIVE);
3274 fl_deactivate_object(fd_form_ref->prettyref);
3275 fl_set_object_lcol(fd_form_ref->prettyref, FL_INACTIVE);
3277 fl_show_object(brow);
3281 extern "C" void RefHideCB(FL_OBJECT *, long)
3283 fl_hide_form(fd_form_ref->form_ref);