]> git.lyx.org Git - features.git/commitdiff
John's AMS patch
authorAndré Pönitz <poenitz@gmx.net>
Thu, 6 Mar 2003 11:07:55 +0000 (11:07 +0000)
committerAndré Pönitz <poenitz@gmx.net>
Thu, 6 Mar 2003 11:07:55 +0000 (11:07 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6365 a592a061-630c-0410-9148-cb99ea01b6c8

src/LaTeXFeatures.C
src/buffer.C
src/bufferparams.C
src/bufferparams.h
src/frontends/qt2/QDocument.C
src/frontends/qt2/ui/PackagesModuleBase.ui
src/frontends/xforms/FormDocument.C
src/frontends/xforms/forms/form_document.fd

index 3fd615848002e728ae19946b1a33c2901dd1ebfb..8f6dc0597cd30064e28ed85ce7432e8ec8b9c917 100644 (file)
@@ -197,7 +197,8 @@ string const LaTeXFeatures::getPackages() const
        //
 
        if (isRequired("amsmath")
-           && ! tclass.provides(LyXTextClass::amsmath)) {
+           && !tclass.provides(LyXTextClass::amsmath)
+           && params.use_amsmath != BufferParams::AMS_OFF) {
                packages << "\\usepackage{amsmath}\n";
        }
 
@@ -263,7 +264,7 @@ string const LaTeXFeatures::getPackages() const
        }
 
        // amssymb.sty
-       if (isRequired("amssymb") || params.use_amsmath)
+       if (isRequired("amssymb") || params.use_amsmath == BufferParams::AMS_ON)
                packages << "\\usepackage{amssymb}\n";
        // url.sty
        if (isRequired("url") && ! tclass.provides(LyXTextClass::url))
index f61df89085ec3c753b7a7dd23d1e277fac36a1c8..d004ff58695390400820e6356d8f486918eb8391 100644 (file)
@@ -516,7 +516,8 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, Paragraph *& par,
 #endif
 
        } else if (token == "\\end_inset") {
-               lyxerr << "Solitary \\end_inset. Missing \\begin_inset?.\n"
+               lyxerr << "Solitary \\end_inset in line " << lex.getLineNo() << "\n"
+                      << "Missing \\begin_inset?.\n"
                       << "Last inset read was: " << last_inset_read
                       << endl;
                // Simply ignore this. The insets do not have
@@ -754,7 +755,8 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, Paragraph *& par,
                params.use_geometry = lex.getInteger();
        } else if (token == "\\use_amsmath") {
                lex.nextToken();
-               params.use_amsmath = lex.getInteger();
+               params.use_amsmath = static_cast<BufferParams::AMS>(
+                       lex.getInteger());
        } else if (token == "\\use_natbib") {
                lex.nextToken();
                params.use_natbib = lex.getInteger();
@@ -2809,7 +2811,8 @@ void Buffer::validate(LaTeXFeatures & features) const
        }
 
        // AMS Style is at document level
-       if (params.use_amsmath || tclass.provides(LyXTextClass::amsmath))
+       if (params.use_amsmath == BufferParams::AMS_ON
+           || tclass.provides(LyXTextClass::amsmath))
                features.require("amsmath");
 
        for_each(paragraphs.begin(), paragraphs.end(),
index 53b06e6e85877e21ac1453556168d71b00afcd6c..a2a6a3eefd1d540afd818f23e7ab09a2263b892d 100644 (file)
@@ -55,7 +55,7 @@ BufferParams::BufferParams()
        paperpackage = PACKAGE_NONE;
        orientation = ORIENTATION_PORTRAIT;
        use_geometry = false;
-       use_amsmath = false;
+       use_amsmath = AMS_AUTO;
        use_natbib = false;
        use_numerical_citations = false;
        tracking_changes = false;
index db49714f787914a6bbe435521b615956d29e3640..8fc163effff93ca73603892478894244a802bceb 100644 (file)
@@ -211,8 +211,14 @@ public:
        void readLanguage(LyXLex &);
        ///
        void readGraphicsDriver(LyXLex &);
-       ///
-       bool use_amsmath;
+
+       /// use AMS package, not, or auto
+       enum AMS {
+               AMS_OFF,
+               AMS_AUTO,
+               AMS_ON
+       };
+       AMS use_amsmath;
        ///
        bool use_natbib;
        ///
index 6b261c589f28b525325679391b9f06c58e026f95..26169e9e852cf51012de1e0906e247edb7867c54 100644 (file)
@@ -238,8 +238,12 @@ void QDocument::apply()
        params.graphicsDriver =
                fromqstr(dialog_->packagesModule->psdriverCO->currentText());
 
-       params.use_amsmath =
-               dialog_->packagesModule->amsCB->isChecked();
+       if (dialog_->packagesModule->amsautoCB->isChecked()) {
+               params.use_amsmath = BufferParams::AMS_AUTO;
+       } else {
+               params.use_amsmath =
+                       dialog_->packagesModule->amsCB->isChecked();
+       }
 
        // layout
        params.textclass =
@@ -477,7 +481,9 @@ void QDocument::update_contents()
 
 
        dialog_->packagesModule->amsCB->setChecked(
-               params.use_amsmath);
+               params.use_amsmath == BufferParams::AMS_YES);
+       dialog_->packagesModule->amsautoCB->setChecked(
+               params.use_amsmath == BufferParams::AMS_AUTO);
 
        switch (params.spacing.getSpace()) {
                case Spacing::Other: nitem = 3; break;
index 6bbeec9da13b4f5d11992545160cf52c70e71ff2..506db62c035708e51dbe74601a4e6bc3579959fa 100644 (file)
@@ -13,7 +13,7 @@
         <rect>
             <x>0</x>
             <y>0</y>
-            <width>357</width>
+            <width>353</width>
             <height>231</height>
         </rect>
     </property>
@@ -38,9 +38,9 @@
             </property>
             <property stdset="1">
                 <name>title</name>
-                <string>Packages</string>
+                <string>AMS</string>
             </property>
-            <grid>
+            <vbox>
                 <property stdset="1">
                     <name>margin</name>
                     <number>11</number>
                     <name>spacing</name>
                     <number>6</number>
                 </property>
-                <widget row="2"  column="0" >
+                <widget>
+                    <class>QCheckBox</class>
+                    <property stdset="1">
+                        <name>name</name>
+                        <cstring>amsautoCB</cstring>
+                    </property>
+                    <property stdset="1">
+                        <name>text</name>
+                        <string>&amp;Use AMS math package automatically</string>
+                    </property>
+                    <property stdset="1">
+                        <name>checked</name>
+                        <bool>false</bool>
+                    </property>
+                </widget>
+                <widget>
                     <class>QCheckBox</class>
                     <property stdset="1">
                         <name>name</name>
                     </property>
                     <property stdset="1">
                         <name>text</name>
-                        <string>Use AMS &amp;math</string>
+                        <string>Use AMS &amp;math package</string>
                     </property>
                 </widget>
-            </grid>
+            </vbox>
         </widget>
         <widget>
             <class>QGroupBox</class>
         </widget>
     </vbox>
 </widget>
+<connections>
+    <connection>
+        <sender>amsautoCB</sender>
+        <signal>toggled(bool)</signal>
+        <receiver>amsCB</receiver>
+        <slot>setDisabled(bool)</slot>
+    </connection>
+</connections>
 <tabstops>
-    <tabstop>amsCB</tabstop>
+    <tabstop>amsautoCB</tabstop>
     <tabstop>psdriverCO</tabstop>
 </tabstops>
 </UI>
index 32b4d901428a611469146fbc4fa3119b337b1811..95e8d9b6176d65fde16ab6c55468afd7cf8b191a 100644 (file)
@@ -281,7 +281,7 @@ void FormDocument::build()
        // disable for read-only documents
        bc().addReadOnly(options_->counter_secnumdepth);
        bc().addReadOnly(options_->counter_tocdepth);
-       bc().addReadOnly(options_->check_use_amsmath);
+       bc().addReadOnly(options_->choice_ams_math);
        bc().addReadOnly(options_->check_use_natbib);
        bc().addReadOnly(options_->choice_citation_format);
        bc().addReadOnly(options_->input_float_placement);
@@ -292,6 +292,9 @@ void FormDocument::build()
 
        fl_set_input_return(options_->input_float_placement, FL_RETURN_CHANGED);
 
+       fl_addto_choice(options_->choice_ams_math, 
+               _("Never | Automatically | Yes "));
+
        for (int n = 0; tex_graphics[n][0]; ++n) {
                fl_addto_choice(options_->choice_postscript_driver,
                                tex_graphics[n]);
@@ -794,7 +797,8 @@ bool FormDocument::options_apply(BufferParams & params)
        bool redo = false;
 
        params.graphicsDriver = getString(options_->choice_postscript_driver);
-       params.use_amsmath = fl_get_button(options_->check_use_amsmath);
+       params.use_amsmath = static_cast<BufferParams::AMS>(
+               fl_get_choice(options_->choice_ams_math) - 1);
        params.use_natbib  = fl_get_button(options_->check_use_natbib);
        params.use_numerical_citations  =
                fl_get_choice(options_->choice_citation_format) - 1;
@@ -963,7 +967,7 @@ 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_choice(options_->choice_ams_math, params.use_amsmath + 1);
        fl_set_button(options_->check_use_natbib,  params.use_natbib);
        fl_set_choice(options_->choice_citation_format,
                      int(params.use_numerical_citations)+1);
index 54de2d0c387a04279eaf7051a69aacda0cae18bc..6b721417c6da23d3d674d7dde8629b8727dac70b 100644 (file)
@@ -1453,54 +1453,54 @@ argument: 0
 --------------------
 class: FL_CHECKBUTTON
 type: PUSH_BUTTON
-box: 185 185 25 25
+box: 185 225 25 25
 boxtype: FL_NO_BOX
 colors: FL_COL1 FL_YELLOW
 alignment: FL_ALIGN_LEFT
 style: FL_NORMAL_STYLE
 size: FL_NORMAL_SIZE
 lcol: FL_BLACK
-label: Use AMS Math|#M
+label: Use Natbib|#N
 shortcut: 
 resize: FL_RESIZE_ALL
 gravity: FL_NoGravity FL_NoGravity
-name: check_use_amsmath
+name: check_use_natbib
 callback: C_FormBaseInputCB
 argument: 0
 
 --------------------
-class: FL_CHECKBUTTON
-type: PUSH_BUTTON
-box: 185 225 25 25
-boxtype: FL_NO_BOX
-colors: FL_COL1 FL_YELLOW
+class: FL_CHOICE
+type: NORMAL_CHOICE
+box: 185 265 140 25
+boxtype: FL_FRAME_BOX
+colors: FL_COL1 FL_BLACK
 alignment: FL_ALIGN_LEFT
 style: FL_NORMAL_STYLE
 size: FL_NORMAL_SIZE
 lcol: FL_BLACK
-label: Use Natbib|#N
+label: Citation style:|#i
 shortcut: 
 resize: FL_RESIZE_ALL
 gravity: FL_NoGravity FL_NoGravity
-name: check_use_natbib
+name: choice_citation_format
 callback: C_FormBaseInputCB
 argument: 0
 
 --------------------
 class: FL_CHOICE
 type: NORMAL_CHOICE
-box: 185 265 140 25
+box: 185 185 140 25
 boxtype: FL_FRAME_BOX
 colors: FL_COL1 FL_BLACK
 alignment: FL_ALIGN_LEFT
 style: FL_NORMAL_STYLE
 size: FL_NORMAL_SIZE
 lcol: FL_BLACK
-label: Citation style:|#i
+label: Use AMS Math:|#M
 shortcut: 
 resize: FL_RESIZE_ALL
 gravity: FL_NoGravity FL_NoGravity
-name: choice_citation_format
+name: choice_ams_math
 callback: C_FormBaseInputCB
 argument: 0