]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/xforms/FormDocument.C
Disable various buttons when buffer is read only
[lyx.git] / src / frontends / xforms / FormDocument.C
index 2150c229b9d14c320f20b946625d95adb8c80e52..b88a029bcd595b2a92c06c4c030935156abb0dc0 100644 (file)
@@ -3,7 +3,7 @@
  * 
  *           LyX, The Document Processor
  *      
- *           Copyright 2000 The LyX Team.
+ *           Copyright 2000-2001 The LyX Team.
  *
  *           @author Jürgen Vigna
  *
@@ -31,6 +31,7 @@
 #include "vspace.h"
 #include "bmtable.h"
 #include "support/filetools.h"
+#include "support/lstrings.h"
 #include "language.h"
 #include "LyXView.h"
 #include "BufferView.h"
@@ -39,6 +40,7 @@
 #include "CutAndPaste.h"
 #include "bufferview_funcs.h"
 #include "xforms_helpers.h" 
+#include "debug.h"
 
 using Liason::setMinibuffer;
 using SigC::slot;
@@ -46,10 +48,10 @@ using SigC::slot;
 FormDocument::FormDocument(LyXView * lv, Dialogs * d)
        : FormBaseBD(lv, d, _("Document Layout")), fbullet(0)
 {
-    // let the popup be shown
+    // let the dialog be shown
     // This is a permanent connection so we won't bother
     // storing a copy because we won't be disconnecting.
-    d->showLayoutDocument.connect(slot(this, &FormDocument::show));
+    d->showDocument.connect(slot(this, &FormDocument::show));
 }
 
 
@@ -84,12 +86,7 @@ void FormDocument::build()
     bc().setOK(dialog_->button_ok);
     bc().setApply(dialog_->button_apply);
     bc().setCancel(dialog_->button_cancel);
-    bc().setUndoAll(dialog_->button_restore);
-    bc().refresh();
-
-    // Workaround dumb xforms sizing bug
-    minw_ = form()->w;
-    minh_ = form()->h;
+    bc().setRestore(dialog_->button_restore);
 
     // the document paper form
     paper_.reset(build_doc_paper());
@@ -144,7 +141,7 @@ void FormDocument::build()
     for (LyXTextClassList::const_iterator cit = textclasslist.begin();
         cit != textclasslist.end(); ++cit)
     {
-       combo_doc_class->addto((*cit).description());
+       combo_doc_class->addto(cit->description());
     }
 
     fl_addto_choice(class_->choice_doc_spacing,
@@ -180,7 +177,7 @@ void FormDocument::build()
     // the document language form
     language_.reset(build_doc_language());
     fl_addto_choice(language_->choice_inputenc,
-                   "default|auto|latin1|latin2|latin5"
+                   "default|auto|latin1|latin2|latin5|latin9"
                    "|koi8-r|koi8-u|cp866|cp1251|iso88595");
 
     // The language is a combo-box and has to be inserted manually
@@ -196,7 +193,7 @@ void FormDocument::build()
 
     for (Languages::const_iterator cit = languages.begin();
        cit != languages.end(); ++cit) {
-       combo_language->addto((*cit).second.lang());
+       combo_language->addto(cit->second.lang());
     }
 
     fl_addto_choice(language_->choice_quotes_language,
@@ -204,6 +201,9 @@ void FormDocument::build()
                      " «text» | »text« "));
 
     bc().addReadOnly (language_->choice_inputenc);
+    bc().addReadOnly (language_->choice_quotes_language);
+    bc().addReadOnly (language_->radio_single);
+    bc().addReadOnly (language_->radio_double);
 
     // the document options form
     options_.reset(build_doc_options());
@@ -217,12 +217,16 @@ void FormDocument::build()
     for (n=0; tex_graphics[n][0]; ++n) {
        fl_addto_choice(options_->choice_postscript_driver, tex_graphics[n]);
     }
+    fl_addto_choice(options_->choice_citation_format,
+                   _(" Author-year | Numerical "));
 
-    bc().addReadOnly (options_->slider_secnumdepth);
-    bc().addReadOnly (options_->slider_tocdepth);
-    bc().addReadOnly (options_->check_use_amsmath);
-    bc().addReadOnly (options_->input_float_placement);
-    bc().addReadOnly (options_->choice_postscript_driver);
+    bc_.addReadOnly (options_->slider_secnumdepth);
+    bc_.addReadOnly (options_->slider_tocdepth);
+    bc_.addReadOnly (options_->check_use_amsmath);
+    bc_.addReadOnly (options_->check_use_natbib);
+    bc_.addReadOnly (options_->choice_citation_format);
+    bc_.addReadOnly (options_->input_float_placement);
+    bc_.addReadOnly (options_->choice_postscript_driver);
 
     // the document bullets form
     bullets_.reset(build_doc_bullet());
@@ -236,6 +240,8 @@ void FormDocument::build()
     bc().addReadOnly (bullets_->bmtable_bullet_panel);
     bc().addReadOnly (bullets_->choice_bullet_size);
     bc().addReadOnly (bullets_->input_bullet_latex);
+    bc().addReadOnly (bullets_->radio_bullet_depth);
+    bc().addReadOnly (bullets_->radio_bullet_panel);
 
     fl_addto_tabfolder(dialog_->tabbed_folder,_("Document"),
                       class_->form);
@@ -249,7 +255,7 @@ void FormDocument::build()
                                 bullets_->form);
     if ((XpmVersion < 4) || (XpmVersion == 4 && XpmRevision < 7)) {
            lyxerr << _("Your version of libXpm is older than 4.7.\n"
-                       "The `bullet' tab of the document popup "
+                       "The `bullet' tab of the document dialog "
                        "has been disabled") << '\n';
        fl_deactivate_object(fbullet);
        fl_set_object_lcol(fbullet, FL_INACTIVE);
@@ -387,8 +393,7 @@ bool FormDocument::class_apply()
                        // successfully loaded
                        redo = true;
                        setMinibuffer(lv_, _("Converting document to new document class..."));
-                       CutAndPaste cap;
-                       int ret = cap.SwitchLayoutsBetweenClasses(
+                       int ret = CutAndPaste::SwitchLayoutsBetweenClasses(
                            params.textclass, new_class,
                            lv_->buffer()->paragraph);
                        if (ret) {
@@ -548,7 +553,7 @@ bool FormDocument::language_apply()
     if (old_language != new_language
        && old_language->RightToLeft() == new_language->RightToLeft()
        && !lv_->buffer()->isMultiLingual())
-       lv_->buffer()->ChangeLanguage(old_language, new_language);
+       lv_->buffer()->changeLanguage(old_language, new_language);
     if (old_language != new_language) {
        redo = true;
     }
@@ -567,6 +572,9 @@ bool FormDocument::options_apply()
     params.graphicsDriver =
        fl_get_choice_text(options_->choice_postscript_driver);
     params.use_amsmath = fl_get_button(options_->check_use_amsmath);
+    params.use_natbib  = fl_get_button(options_->check_use_natbib);
+    params.use_numerical_citations  =
+           fl_get_choice(options_->choice_citation_format)-1;
 
     int tmpchar = int(fl_get_counter_value(options_->slider_secnumdepth));
     if (params.secnumdepth != tmpchar)
@@ -710,6 +718,9 @@ void FormDocument::options_update(BufferParams const & params)
     fl_set_choice_text(options_->choice_postscript_driver,
                       params.graphicsDriver.c_str());
     fl_set_button(options_->check_use_amsmath, params.use_amsmath);
+    fl_set_button(options_->check_use_natbib,  params.use_natbib);
+    fl_set_choice(options_->choice_citation_format,
+                 int(params.use_numerical_citations)+1);
     fl_set_counter_value(options_->slider_secnumdepth, params.secnumdepth);
     fl_set_counter_value(options_->slider_tocdepth, params.tocdepth);
     if (!params.float_placement.empty())
@@ -1030,7 +1041,7 @@ void FormDocument::CheckChoiceClass(FL_OBJECT * ob, long)
     if (!ob)
        ob = class_->choice_doc_class;
 
-    ProhibitInput(lv_->view());
+    lv_->prohibitInput();
 
     unsigned int tc = combo_doc_class->get() - 1;
     if (textclasslist.Load(tc)) {
@@ -1052,7 +1063,7 @@ void FormDocument::CheckChoiceClass(FL_OBJECT * ob, long)
                   _("Reverting to original document class."));
        combo_doc_class->select(int(lv_->buffer()->params.textclass) + 1);
     }
-    AllowInput(lv_->view());
+    lv_->allowInput();
 }