]> git.lyx.org Git - features.git/commitdiff
Baruch's graphics patch + some small tweaks to the buttoncontroller stuff
authorAngus Leeming <leeming@lyx.org>
Sat, 28 Jul 2001 12:24:16 +0000 (12:24 +0000)
committerAngus Leeming <leeming@lyx.org>
Sat, 28 Jul 2001 12:24:16 +0000 (12:24 +0000)
Kayvan's footnote patch
Added a "Buffer const *" parameter to InsetButton::getScreenLabel and all
daughter classes. Labels can now be tuned to suit, although non are yet.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2375 a592a061-630c-0410-9148-cb99ea01b6c8

47 files changed:
lib/ui/default.ui
src/ChangeLog
src/buffer.C
src/frontends/controllers/ChangeLog
src/frontends/controllers/ControlGraphics.C
src/frontends/xforms/ChangeLog
src/frontends/xforms/FormGraphics.C
src/frontends/xforms/FormGraphics.h
src/frontends/xforms/form_graphics.C
src/frontends/xforms/form_graphics.h
src/frontends/xforms/forms/form_graphics.fd
src/frontends/xforms/input_validators.C
src/frontends/xforms/input_validators.h
src/insets/ChangeLog
src/insets/insetbib.C
src/insets/insetbib.h
src/insets/insetbutton.C
src/insets/insetbutton.h
src/insets/insetcite.C
src/insets/insetcite.h
src/insets/insetcommand.h
src/insets/insetert.C
src/insets/insetexternal.C
src/insets/insetexternal.h
src/insets/insetfloatlist.C
src/insets/insetfloatlist.h
src/insets/insetfoot.C
src/insets/insetfoot.h
src/insets/insetgraphics.C
src/insets/insetgraphics.h
src/insets/insetgraphicsParams.C
src/insets/insetgraphicsParams.h
src/insets/insetinclude.C
src/insets/insetinclude.h
src/insets/insetindex.C
src/insets/insetindex.h
src/insets/insetlabel.h
src/insets/insetparent.C
src/insets/insetparent.h
src/insets/insetref.C
src/insets/insetref.h
src/insets/insettoc.C
src/insets/insettoc.h
src/insets/inseturl.C
src/insets/inseturl.h
src/support/ChangeLog
src/support/lyxlib.h

index 08feb4807ade04920f7b44bb5ccd4c4f49173c0a..c3397dada2c02cf3fe810e4d025973514f8f46f2 100644 (file)
@@ -203,7 +203,8 @@ Menuset
        Separator
        Item "TeX|T" "ert-insert"
        Item "Minipage|p" "minipage-insert"
-       Item "Graphics...|G" "figure-insert"
+       Item "Old-Graphics..." "figure-insert"
+       Item "Graphics...|G" "graphics-insert"
        Item "Tabular Material...|b" "dialog-tabular-insert"
        Submenu "Floats|a" "insert_floats"
        Separator
index 30bbef3549ba034fd5fefa7c809fd277b7543c91..ee55afb0415f2c4bb466c11f90506dfe7d77eca2 100644 (file)
        * text2.C (toggleFree): do selection with WHOLE_WORD_STRICT
        scheme.
 
+2001-07-26  Baruch Even  <baruch@lyx.org>
+
+       * buffer.C (readInset): Changed to call up InsetGraphics when reading
+       an InsetFig figure, backwards compatible reading of old figure code.
+
 2001-07-27  Juergen Vigna  <jug@sad.it>
 
        * text2.C: font.realize function adaption.
index 3701b7768301e033e35fd04db72f5353d9aee5df..e9316c6e3cce22f483e05b9854ead5c4c7c398c4 100644 (file)
@@ -1453,8 +1453,11 @@ void Buffer::readInset(LyXLex & lex, Paragraph *& par,
                        inset = new InsetFormulaMacro;
                } else if (tmptok == "Formula") {
                        inset = new InsetFormula;
-               } else if (tmptok == "Figure") {
-                       inset = new InsetFig(100, 100, *this);
+               } else if (tmptok == "Figure") { // Backward compatibility
+                       //inset = new InsetFig(100, 100, *this);
+                       inset = new InsetGraphics;
+               } else if (tmptok == "GRAPHICS") {
+                       inset = new InsetGraphics;
                } else if (tmptok == "Info") {// backwards compatibility
                        inset = new InsetNote(this,
                                              lex.getLongString("\\end_inset"),
@@ -1489,8 +1492,6 @@ void Buffer::readInset(LyXLex & lex, Paragraph *& par,
 #endif
                } else if (tmptok == "Caption") {
                        inset = new InsetCaption;
-               } else if (tmptok == "GRAPHICS") {
-                       inset = new InsetGraphics;
                } else if (tmptok == "FloatList") {
                        inset = new InsetFloatList;
                }
index cba478db16922cb3bd4b6855c806da89acb7c5e4..e0b35b4227de1c2c2026da24bbf243ca6857e5c2 100644 (file)
@@ -1,3 +1,8 @@
+2001-07-26  Baruch Even  <baruch@lyx.org>
+
+       * ControlGraphics.C: changed file search string to cover eps, jpeg, gif
+       and png.
+
 2001-07-23  John Levon  <moz@compsoc.man.ac.uk>
 
        * ControlInclude.h:
index c3a2f4779d38841738e60d0987a28219b44816b7..ba54e93ad96682b18575239d1b553a1d9b41200b 100644 (file)
@@ -79,7 +79,7 @@ string const ControlGraphics::Browse(string const & in_name)
 {
        string const title = N_("Graphics");
        // FIXME: currently we need the second '|' to prevent mis-interpretation 
-       string const pattern = "*.(ps|png)|";
+       string const pattern = "*.(eps|png|jpeg|gif)|";
 
        // Does user clipart directory exist?
        string clipdir = AddName (user_lyxdir, "clipart");
index 8278b4a52b586fe188048d27e0c45c4619b9ac52..77f5545b26622c081e2a1273aae72a642fb8a437 100644 (file)
@@ -1,3 +1,23 @@
+2001-07-26  Angus Leeming  <a.leeming@ic.ac.uk>
+
+       * input_validators.[Ch] (fl_int_filter, fl_float_filter): new methods.
+
+       * FormGraphics.C (build): uncommented the fl_set_input_return call for
+       input_rotate_angle. Set input filter on rotate_angle to make it accept
+       only floating point numbers.
+       (input): Browse now activates the Ok button approriately.
+
+2001-07-26  Baruch Even  <baruch@lyx.org>
+
+       * FormGraphics.h:
+       * FormGraphics.C: Removed hide method since it was interfering with the
+       needed work, it cleared several vectors that were needed for proper
+       functioning. Also changed rotateAngle to float.
+
+       * FormGraphics.C:
+       * forms/form_graphics.fd: Removed inline option, all InsetGraphics figures
+       are inlined.
+       
 2001-07-23  John Levon  <moz@compsoc.man.ac.uk>
 
        * FormInclude.C: add load file facility back
index a4ef19ad23bcf1e44f69cab5c5119952e1c344b6..e76973ff006fa39812c0c120f8cac5565c4d4e04 100644 (file)
@@ -41,17 +41,6 @@ FormGraphics::FormGraphics(ControlGraphics & c)
 {}
 
 
-void FormGraphics::hide()
-{
-       // Remove all associations for the radio buttons
-       widthButtons.reset();
-       heightButtons.reset();
-       displayButtons.reset();
-
-       FormBase::hide();
-}
-
-
 void FormGraphics::build()
 {
        dialog_.reset(build_graphics());
@@ -67,8 +56,8 @@ void FormGraphics::build()
                              FL_RETURN_CHANGED);
        fl_set_input_return (dialog_->input_filename,
                              FL_RETURN_CHANGED);
-       //    fl_set_input_return(dialog_->input_rotate_angle,
-       //            FL_RETURN_CHANGED);
+       fl_set_input_return (dialog_->input_rotate_angle,
+                             FL_RETURN_CHANGED);
 
        // Set the maximum characters that can be written in the input texts.
        fl_set_input_maxchars(dialog_->input_width, WIDTH_MAXDIGITS);
@@ -83,6 +72,9 @@ void FormGraphics::build()
        fl_set_input_filter(dialog_->input_height,
                            fl_unsigned_int_filter);
 
+       // Set input filter on rotate_angle to make it accept only
+       // floating point numbers.
+       fl_set_input_filter(dialog_->input_rotate_angle, fl_float_filter);
 
        // Add the widgets of the width radio buttons to their group
        widthButtons.reset();
@@ -133,7 +125,6 @@ void FormGraphics::build()
        bc().addReadOnly(dialog_->radio_button_group_height);
        bc().addReadOnly(dialog_->radio_button_group_display);
        bc().addReadOnly(dialog_->input_rotate_angle);
-       bc().addReadOnly(dialog_->check_inline);
        bc().addReadOnly(dialog_->input_subcaption);
        bc().addReadOnly(dialog_->check_subcaption);
 }
@@ -157,17 +148,17 @@ void FormGraphics::apply()
                           (heightButtons.getButton());
        igp.heightSize = strToDbl(fl_get_input(dialog_->input_height));
 
-       igp.rotateAngle = strToInt(fl_get_input(dialog_->input_rotate_angle));
+       igp.rotateAngle = strToDbl(fl_get_input(dialog_->input_rotate_angle));
+       /* // Need to redo it for floats, but I'm lazy now - BE 20010725
        if (igp.rotateAngle >= 360)
                igp.rotateAngle = igp.rotateAngle % 360;
        if (igp.rotateAngle <= -360)
                igp.rotateAngle = - (( -igp.rotateAngle) % 360);
+       */
 
        igp.subcaption = fl_get_button(dialog_->check_subcaption);
        igp.subcaptionText = fl_get_input(dialog_->input_subcaption);
 
-       igp.inlineFigure = fl_get_button(dialog_->check_inline);
-
        igp.testInvariant();
 }
 
@@ -204,10 +195,6 @@ void FormGraphics::update()
        fl_set_input(dialog_->input_subcaption,
                     igp.subcaptionText.c_str());
 
-       // Update the inline figure check button
-       fl_set_button(dialog_->check_inline,
-                     igp.inlineFigure);
-
        // Now make sure that the buttons are set correctly.
        input(0, 0);
 }
@@ -231,7 +218,7 @@ ButtonPolicy::SMInput FormGraphics::input(FL_OBJECT *, long data)
 
                if (out_name != in_name && !out_name.empty()) {
                        fl_set_input(dialog_->input_filename, out_name.c_str());
-                       input(0, 0);
+                       activate = input(0, CHECKINPUT);
                }
                break;
        }
index 4563f3193b38fa633583979852307a02eb61ab17..2c6b26ef80c64d895f32bf0fd5629ca563b9a173 100644 (file)
@@ -37,8 +37,6 @@ private:
        virtual void apply();
        /// Build the dialog.
        virtual void build();
-       /// Hide the dialog.
-       virtual void hide();
        /// Update dialog before/whilst showing it.
        virtual void update();
        /// Filter the inputs on callback from xforms
index f37e4496cf0612dc4117dd304132a6af2ac7168f..ec76c10092d774b852da30182cc36560be821a4f 100644 (file)
@@ -28,7 +28,6 @@ FD_form_graphics * FormGraphics::build_graphics()
     fl_set_object_lsize(obj, FL_NORMAL_SIZE);
     fl_set_object_gravity(obj, FL_NorthWest, FL_SouthEast);
   obj = fl_add_frame(FL_ENGRAVED_FRAME, 20, 310, 138, 30, "");
-  obj = fl_add_frame(FL_ENGRAVED_FRAME, 279, 250, 201, 50, "");
   {
     char const * const dummy = N_("Graphics File|#F");
     fdui->input_filename = obj = fl_add_input(FL_NORMAL_INPUT, 150, 20, 210, 30, idex(_(dummy)));
@@ -109,19 +108,13 @@ FD_form_graphics * FormGraphics::build_graphics()
   }
   fl_end_group();
 
-  obj = fl_add_labelframe(FL_ENGRAVED_FRAME, 20, 250, 236, 50, _("Rotate"));
+  obj = fl_add_labelframe(FL_ENGRAVED_FRAME, 20, 250, 240, 50, _("Rotate"));
   {
     char const * const dummy = N_("Angle|#A");
     fdui->input_rotate_angle = obj = fl_add_input(FL_INT_INPUT, 91, 260, 94, 30, idex(_(dummy)));
     fl_set_button_shortcut(obj, scex(_(dummy)), 1);
   }
     fl_set_object_callback(obj, C_FormBaseInputCB, CHECKINPUT);
-  {
-    char const * const dummy = N_("Inline Figure|#I");
-    fdui->check_inline = obj = fl_add_checkbutton(FL_PUSH_BUTTON, 279, 260, 201, 30, idex(_(dummy)));
-    fl_set_button_shortcut(obj, scex(_(dummy)), 1);
-  }
-    fl_set_object_callback(obj, C_FormBaseInputCB, CHECKINPUT);
   fdui->input_subcaption = obj = fl_add_input(FL_NORMAL_INPUT, 158, 310, 322, 30, "");
     fl_set_object_callback(obj, C_FormBaseInputCB, CHECKINPUT);
   {
index 0b33ef9e0d2dc422eea1e68cc5b8e8ba3f7a9ba4..224f3d176553bdd8307041c77d2f2802b43591aa 100644 (file)
@@ -38,7 +38,6 @@ struct FD_form_graphics {
        FL_OBJECT *radio_display_color;
        FL_OBJECT *radio_no_display;
        FL_OBJECT *input_rotate_angle;
-       FL_OBJECT *check_inline;
        FL_OBJECT *input_subcaption;
        FL_OBJECT *check_subcaption;
        FL_OBJECT *button_restore;
index aa6609a3be3194eeb16f7be50aa26783e43f937a..0a6543a784162c47fb458d83f1bdb25aed5ee0ff 100644 (file)
@@ -10,7 +10,7 @@ Unit of measure: FL_COORD_PIXEL
 Name: form_graphics
 Width: 490
 Height: 390
-Number of Objects: 38
+Number of Objects: 36
 
 --------------------
 class: FL_BOX
@@ -48,24 +48,6 @@ name:
 callback: 
 argument: 
 
---------------------
-class: FL_FRAME
-type: ENGRAVED_FRAME
-box: 279 250 201 50
-boxtype: FL_NO_BOX
-colors: FL_BLACK FL_COL1
-alignment: FL_ALIGN_CENTER
-style: FL_NORMAL_STYLE
-size: FL_DEFAULT_SIZE
-lcol: FL_BLACK
-label: 
-shortcut: 
-resize: FL_RESIZE_ALL
-gravity: FL_NoGravity FL_NoGravity
-name: 
-callback: 
-argument: 
-
 --------------------
 class: FL_INPUT
 type: NORMAL_INPUT
@@ -540,7 +522,7 @@ argument:
 --------------------
 class: FL_LABELFRAME
 type: ENGRAVED_FRAME
-box: 20 250 236 50
+box: 20 250 240 50
 boxtype: FL_NO_BOX
 colors: FL_BLACK FL_COL1
 alignment: FL_ALIGN_TOP_LEFT
@@ -573,24 +555,6 @@ name: input_rotate_angle
 callback: C_FormBaseInputCB
 argument: CHECKINPUT
 
---------------------
-class: FL_CHECKBUTTON
-type: PUSH_BUTTON
-box: 279 260 201 30
-boxtype: FL_NO_BOX
-colors: FL_COL1 FL_YELLOW
-alignment: FL_ALIGN_CENTER
-style: FL_NORMAL_STYLE
-size: FL_DEFAULT_SIZE
-lcol: FL_BLACK
-label: Inline Figure|#I
-shortcut: 
-resize: FL_RESIZE_ALL
-gravity: FL_NoGravity FL_NoGravity
-name: check_inline
-callback: C_FormBaseInputCB
-argument: CHECKINPUT
-
 --------------------
 class: FL_INPUT
 type: NORMAL_INPUT
index e511e10e59cce3400867108b64041bd5411ac540..f22740e67e859b685381454f0f939f129fdc5a67 100644 (file)
@@ -14,10 +14,20 @@ extern "C"
 {
 #endif
 
+int fl_int_filter(FL_OBJECT * ob,
+                 char const *, char const *, int c)
+{
+       if (c == 0 /* final test before handing contents to app */
+           || strchr("0123456789+-", c)) {
+               if (isStrInt(fl_get_input(ob)))
+                       return FL_VALID;
+       }
+       return FL_INVALID|FL_RINGBELL;
+}
+
+
 int fl_unsigned_int_filter(FL_OBJECT * /*ob*/,
-                          char const * /*not_used*/,
-                          char const * /*unused*/,
-                          int c)
+                          char const *, char const *, int c)
 {
        if (c == 0 /* final test before handing contents to app */
            || strchr("0123456789", c)) {
@@ -28,6 +38,18 @@ int fl_unsigned_int_filter(FL_OBJECT * /*ob*/,
 }
 
 
+int fl_float_filter(FL_OBJECT * ob,
+                   char const *, char const *, int c)
+{
+       if (c == 0 /* final test before handing contents to app */
+           || strchr("0123456789.+-", c)) {
+               if (isStrDbl(fl_get_input(ob)))
+                       return FL_VALID;
+       }
+       return FL_INVALID|FL_RINGBELL;
+}
+
+
 int fl_unsigned_float_filter(FL_OBJECT * ob,
                             char const * /*not_used*/,
                             char const * /*unused*/,
@@ -37,8 +59,6 @@ int fl_unsigned_float_filter(FL_OBJECT * ob,
            || strchr("0123456789.", c)) {
                if (isStrDbl(fl_get_input(ob)))
                        return FL_VALID;
-               else
-                       return FL_INVALID|FL_RINGBELL;
        }
        return FL_INVALID|FL_RINGBELL;
 }
index cb111ba49a7795c0b5a74b5396cdb521010e7dae..26cb7571b9a5387c9bac38eee82e5d711143dd2a 100644 (file)
@@ -25,9 +25,15 @@ extern "C"
 {
 #endif
 
-    /** Only allow whole numbers no '+' or '-' signs or exponents. */
+    /** Only allow integer numbers,
+       possibly preceeded by a +' or '-' sign */
+int fl_int_filter(FL_OBJECT *, char const *, char const *, int);
+    /** Only allow integer numbers. No '+' or '-' signs. */
 int fl_unsigned_int_filter(FL_OBJECT *, char const *, char const *, int);
-    /** Only allow whole numbers no '+' or '-' signs or exponents. */
+    /** Only allow floating point numbers,
+       possibly preceeded by a +' or '-' sign */
+int fl_float_filter(FL_OBJECT *, char const *, char const *, int);
+    /** Only allow floating point numbers. No '+' or '-' signs. */
 int fl_unsigned_float_filter(FL_OBJECT *, char const *, char const *, int);
 
     /** Only allow lowercase letters. */
index fa4c5b4a58d4d5379640125ac92c721a649d2dbf..c9763f552709637dea62e3a4e723db10c0b1b2a3 100644 (file)
@@ -1,3 +1,51 @@
+2001-07-28  Angus Leeming  <a.leeming@ic.ac.uk>
+
+       * insetert.C (get_new_label): int -> Paragraph::size_type to get
+       std::min working.
+
+       * insetgraphics.C: added a using std::endl directive.
+
+       * insetcommand.h (getScreenLabel): removed pure virtual function,
+       as it duplicates that in InsetButton.
+
+       * insetbib.[Ch] (getScreenLabel):
+       * insetbutton.[Ch] (getScreenLabel):
+       * insetcite.[Ch] (getScreenLabel):
+       * insetert.[Ch] (getScreenLabel):
+       * insetexternal.[Ch] (getScreenLabel):
+       * insetfloatlist.[Ch] (getScreenLabel):
+       * insetinclude.[Ch] (getScreenLabel):
+       * insetindex.[Ch] (getScreenLabel):
+       * insetlabel.h (getScreenLabel):
+       * insetparent.[Ch] (getScreenLabel):
+       * insetref.[Ch] (getScreenLabel):
+       * insettoc.[Ch] (getScreenLabel):
+       * inseturl.[Ch] (getScreenLabel): passed a Buffer const * parameter.
+
+       * insetcite.C (getScreenLabel): use this Buffer parameter in creating
+       the label.
+       (validate): remove check on "cite" when using natbib.
+
+2001-07-26  Baruch Even  <baruch@lyx.org>
+
+       * insetgraphics.C (draw): changed casting to be in one place rather than 
+       all over the function.
+
+       * insetgraphics.h:
+       * insetgraphics.C (read): Added compatibility reads of InsetFig.
+       
+       * insetgraphicsParams.h:
+       * insetgraphicsParams.C: 
+       * insetgraphics.C: Removed inline option and changed rotateAngle to float.
+
+2001-07-28  Kayvan A. Sylvan  <kayvan@sylvan.com>
+
+       * insetfoot.C (validate): Added method to ensure that the
+       right bit of LaTeX is emitted.
+
+       * insetfoot.h: Added validate method to set the correct
+       LaTeXFeatures bit for the special footnote code.
+
 2001-07-26  Yves Bastide  <stid@libd-pc11.univ-bpclermont.fr>
 
        * insetquotes.C (dispString): display the right ISO8859-{1,9,15}
index 9f4caab3f9359a27173cbe23ca7ae776365bec85..4699700505bb8a7d99ca5dad12d7022cfd43f47b 100644 (file)
@@ -100,7 +100,7 @@ string const InsetBibKey::getBibLabel() const
        return tostr(counter);
 }
 
-string const InsetBibKey::getScreenLabel() const
+string const InsetBibKey::getScreenLabel(Buffer const *) const
 {
        return getContents() + " [" + getBibLabel() + "]";
 }
@@ -128,7 +128,7 @@ InsetBibtex::~InsetBibtex()
 }
 
 
-string const InsetBibtex::getScreenLabel() const
+string const InsetBibtex::getScreenLabel(Buffer const *) const
 {
        return _("BibTeX Generated References");
 }
index 50cf26f368cb19c7627fdbce6c86a11570828513..408d24b16175b22c8729fed2a6929899e7f40ddb 100644 (file)
@@ -41,7 +41,7 @@ public:
        ///
        void read(Buffer const *, LyXLex & lex);
        ///
-       virtual string const getScreenLabel() const;
+       virtual string const getScreenLabel(Buffer const *) const;
        ///
        void edit(BufferView *, int x, int y, unsigned int button);
        ///
@@ -87,7 +87,7 @@ public:
                return new InsetBibtex(params(), same_id);
        }
        ///
-       string const getScreenLabel() const;
+       string const getScreenLabel(Buffer const *) const;
        ///
        EDITABLE editable() const { return IS_EDITABLE; }
        ///
index 617b2bf8200dba10272bf095ed2692842173e3bb..c3b8907f6ea462826753dcbd49ef53606655a678 100644 (file)
@@ -36,7 +36,7 @@ int InsetButton::ascent(BufferView * bv, LyXFont const &) const
        int width;
        int ascent;
        int descent;
-        string const s = getScreenLabel();
+        string const s = getScreenLabel(bv->buffer());
 
 #if 0
         if (editable()) {
@@ -68,7 +68,7 @@ int InsetButton::descent(BufferView * bv, LyXFont const &) const
        int width;
        int ascent;
        int descent;
-        string const s = getScreenLabel();
+        string const s = getScreenLabel(bv->buffer());
 
 #if 0
         if (editable()) {
@@ -100,7 +100,7 @@ int InsetButton::width(BufferView * bv, LyXFont const &) const
        int width;
        int ascent;
        int descent;
-        string const s = getScreenLabel();
+        string const s = getScreenLabel(bv->buffer());
 
 #if 0
         if (editable()) {
@@ -132,7 +132,7 @@ void InsetButton::draw(BufferView * bv, LyXFont const &,
        LyXFont font(LyXFont::ALL_SANE);
        font.setColor(LColor::command).decSize();
 
-       string const s = getScreenLabel();
+       string const s = getScreenLabel(bv->buffer());
 
 #if 0
        int width;
index 23f4e73f6a5e8457935924976b593030be4d916a..35c85c4f2385c71d158921e7dd477504ce4f4eef 100644 (file)
@@ -34,7 +34,7 @@ public:
 
 protected:
        /// This should provide the text for the button
-       virtual string const getScreenLabel() const = 0;
+       virtual string const getScreenLabel(Buffer const *) const = 0;
 };
 
 #endif
index 934e463e6065dc9e281e1f11ebb2cd3ccd921620..d89732c80dd5c60e239b0ee5837b0c8597a7bfa5 100644 (file)
@@ -25,7 +25,7 @@ InsetCitation::InsetCitation(InsetCommandParams const & p, bool)
        : InsetCommand(p)
 {}
 
-string const InsetCitation::getScreenLabel() const
+string const InsetCitation::getScreenLabel(Buffer const *) const
 {
        string keys(getContents());
 
@@ -98,6 +98,6 @@ int InsetCitation::latex(Buffer const * buffer, std::ostream & os,
 
 void InsetCitation::validate(LaTeXFeatures & features) const
 {
-       if (getCmdName() != "cite" && features.bufferParams().use_natbib)
+       if (features.bufferParams().use_natbib)
                features.natbib = true;
 }
index 75db049ea2e69c7b76379ccb8d67da3f5f9b86fe..efa21fd17883dfb5f3e2f1af2832cfc058d81b39 100644 (file)
@@ -28,7 +28,7 @@ public:
                return new InsetCitation(params(), same_id);
        }
        ///
-       string const getScreenLabel() const;
+       string const getScreenLabel(Buffer const *) const;
        ///
        EDITABLE editable() const { return IS_EDITABLE; }
        ///
index 6dd6ad05da935d539d415fc2ba793b4fbbe1cbc5..10eee357740d822f65b18a08dd5a7ceabdd73c01 100644 (file)
@@ -101,13 +101,6 @@ public:
        ///
        Inset::Code lyxCode() const { return Inset::NO_CODE; }
        
-       /** Get the label that appears at screen.
-         
-         I thought it was enough to eliminate the argument to avoid
-         confusion with lyxinset::getLabel(int), but I've seen that
-         it wasn't. I hope you never confuse again both methods.  (ale)
-        */
-       virtual string const getScreenLabel() const = 0;
        ///
        string const getCommand() const { return p_.getCommand(); }
        ///
index 4f2a75c9648659867838ded742593ced5eb0a1eb..d6df241c66ac00c7e398beaa8348c95a960e09cf 100644 (file)
@@ -222,8 +222,8 @@ string const InsetERT::get_new_label() const
        string la;
        Paragraph::size_type const max_length = 15;
 
-       int const p_siz = inset.paragraph()->size();
-       int const n = std::min(max_length, p_siz);
+       Paragraph::size_type const p_siz = inset.paragraph()->size();
+       Paragraph::size_type const n = std::min(max_length, p_siz);
        int i = 0;
        int j = 0;
        for(; i < n && j < p_siz; ++j) {
index 51f177de40f5cecb313db0678db8da7dbc454220..47a7afdce1e86548e6a82a33bb387aaac9bff84b 100644 (file)
@@ -202,7 +202,7 @@ Inset * InsetExternal::clone(Buffer const &, bool same_id) const
 }
 
 
-string const InsetExternal::getScreenLabel() const
+string const InsetExternal::getScreenLabel(Buffer const *) const
 {
        ExternalTemplate const & et = params_.templ;
        if (et.guiName.empty())
index fee519ee71d1fcb120e252cea4f469d1360ff905..2dfd03ef87e052e4d449578c99a480308a108486 100644 (file)
@@ -79,7 +79,7 @@ public:
        virtual Inset * clone(Buffer const &, bool same_id = false) const;
 
        /// returns the text of the button
-       virtual string const getScreenLabel() const;
+       virtual string const getScreenLabel(Buffer const *) const;
 
        // The following public members are used from the frontends code
 
index 3cb79a2c25c2d32143ec42d82ea1d10f3f86f5b5..5b35f22f56f9c5bfa88bee7e193ce3a18d05ea56 100644 (file)
@@ -12,7 +12,7 @@
 
 using std::endl;
 
-string const InsetFloatList::getScreenLabel() const 
+string const InsetFloatList::getScreenLabel(Buffer const *) const 
 {
        string const guiName = floatList[float_type]->second.name();
        if (!guiName.empty()) {
@@ -104,7 +104,7 @@ int InsetFloatList::latex(Buffer const *, std::ostream & os, bool, bool) const
 
 int InsetFloatList::ascii(Buffer const * buffer, std::ostream & os, int) const
 {
-       os << getScreenLabel() << "\n\n";
+       os << getScreenLabel(buffer) << "\n\n";
 
        Buffer::Lists const toc_list = buffer->getLists();
        Buffer::Lists::const_iterator cit =
index bf50f8ea10e2ce6c3afff6048d09bd648164974c..a279574a7f34130efabd1d6a6d4bedd773fc3ab4 100644 (file)
@@ -32,7 +32,7 @@ public:
                return new InsetFloatList(*this);
        }
        ///
-       string const getScreenLabel() const;
+       string const getScreenLabel(Buffer const *) const;
        ///
        void edit(BufferView * bv, int, int, unsigned int);
        ///
index a9a103db497d6d5451ef5559a55c431a759c1f08..1e0ccb8f3964b2d778a868a8ebf6bed94694a813 100644 (file)
@@ -62,3 +62,8 @@ int InsetFoot::latex(Buffer const * buf,
        
        return i + 2;
 }
+
+void InsetFoot::validate(LaTeXFeatures & features) const
+{
+        features.NeedLyXFootnoteCode = true;
+}
index 5f10835f91a79f7eb033a4e97ee7be074b6bc2ad..d8e1f8cb4dd347a5e613d092d32982eb2082d265 100644 (file)
@@ -18,6 +18,7 @@
 #pragma interface
 #endif
 
+#include "LaTeXFeatures.h"
 #include "insetfootlike.h"
 
 /** The footnote inset
@@ -37,6 +38,8 @@ public:
        int latex(Buffer const *, std::ostream &, bool fragile, bool fp) const;
        ///
        string const editMessage() const;
+       ///
+       void InsetFoot::validate(LaTeXFeatures & features) const;
 };
 
 #endif
index 6ffb2d4155ed3475b7601549e7c7813914abc524..530db1b0527415d5b491571de165e7a236d9105a 100644 (file)
@@ -150,6 +150,7 @@ TODO Extended features:
 extern string system_tempdir;
 
 using std::ostream;
+using std::endl;
 
 // This function is a utility function
 inline
@@ -337,6 +338,20 @@ void InsetGraphics::write(Buffer const * buf, ostream & os) const
 
 
 void InsetGraphics::read(Buffer const * buf, LyXLex & lex)
+{
+       string const token = lex.GetString();
+
+       if (token == "GRAPHICS")
+               readInsetGraphics(buf, lex);
+       else if (token == "Figure") // Compatibility reading of FigInset figures.
+               readFigInset(buf, lex);
+       else
+               lyxerr[Debug::INFO] << "Not a GRAPHICS or Figure inset!\n";
+
+       updateInset();
+}
+
+void InsetGraphics::readInsetGraphics(Buffer const * buf, LyXLex & lex)
 {
        bool finished = false;
 
@@ -368,8 +383,70 @@ void InsetGraphics::read(Buffer const * buf, LyXLex & lex)
                                        << std::endl;
                }
        }
+}
 
-       updateInset();
+
+void InsetGraphics::readFigInset(Buffer const * buf, LyXLex & lex)
+{
+       bool finished = false;
+       
+       while (lex.IsOK() && !finished) {
+               lex.next();
+
+               string const token = lex.GetString();
+               lyxerr[Debug::INFO] << "Token: " << token << endl;
+               
+               if (token.empty())
+                       continue;
+               else if (token == "\\end_inset") {
+                       finished = true;
+               } else if (token == "file") {
+                       if (lex.next()) {
+                               string const name = lex.GetString();
+                               string const path = OnlyPath(buf->fileName());
+                               params.filename = MakeAbsPath(name, path);
+                       }
+               } else if (token == "extra") {
+                       if (lex.next());
+                       // kept for backwards compability. Delete in 0.13.x
+               } else if (token == "subcaption") {
+                       if (lex.EatLine())
+                               params.subcaptionText = lex.GetString();
+               } else if (token == "label") {
+                       if (lex.next());
+                       // kept for backwards compability. Delete in 0.13.x
+               } else if (token == "angle") {
+                       if (lex.next())
+                               params.rotateAngle = lex.GetFloat();
+               } else if (token == "size") {
+                       // Size of image on screen is ignored in InsetGraphics, just eat
+                       // the input.
+                       if (lex.next())
+                               lex.GetInteger();
+                       if (lex.next())
+                               lex.GetInteger();
+               } else if (token == "flags") {
+                       InsetGraphicsParams::DisplayType tmp = InsetGraphicsParams::COLOR;
+                       if (lex.next())
+                               switch (lex.GetInteger()) {
+                               case 1: tmp = InsetGraphicsParams::MONOCHROME; break;
+                               case 2: tmp = InsetGraphicsParams::GRAYSCALE; break;
+                               }
+                       params.display = tmp;
+               } else if (token == "subfigure") {
+                       params.subcaption = true;
+               } else if (token == "width") {
+                       if (lex.next())
+                               params.widthResize = static_cast<InsetGraphicsParams::Resize>(lex.GetInteger());
+                       if (lex.next())
+                               params.widthSize = lex.GetFloat();
+               } else if (token == "height") {
+                       if (lex.next())
+                               params.heightResize = static_cast<InsetGraphicsParams::Resize>(lex.GetInteger());
+                       if (lex.next())
+                               params.heightSize = lex.GetFloat();
+               }
+       }
 }
 
 
@@ -415,7 +492,9 @@ InsetGraphics::createLatexOptions() const
        formatResize(options, "width", params.widthResize, params.widthSize);
        formatResize(options, "height", params.heightResize, params.heightSize);
 
-       if (params.rotateAngle != 0) {
+       // Make sure it's not very close to zero, a float can be effectively
+       // zero but not exactly zero.
+       if (lyx::float_equal(params.rotateAngle, 0, 0.001)) {
                options << "angle="
                        << params.rotateAngle << ',';
        }
@@ -511,13 +590,6 @@ int InsetGraphics::latex(Buffer const *buf, ostream & os,
        string before;
        string after;
 
-       // If it's not an inline image, surround it with the centering paragraph.
-       if (! params.inlineFigure) {
-               before += "\n" "\\vspace{0.3cm}\n" "{\\par\\centering ";
-               after = " \\par}\n" "\\vspace{0.3cm}\n" + after;
-               newlines += 4;
-       }
-
        // Do we want subcaptions?
        if (params.subcaption) {
                before += "\\subfigure[" + params.subcaptionText + "]{";
index 045995b7649ab51175a09f3b214c3abb5e53714f..ab83affc1b025a63aa97b4a064720dd1e61557ba 100644 (file)
@@ -98,6 +98,11 @@ public:
        SigC::Signal0<void> hideDialog;
 
 private:
+       /// Read the inset native format
+       void readInsetGraphics(Buffer const * buf, LyXLex & lex);
+       /// Read the FigInset file format
+       void readFigInset(Buffer const * buf, LyXLex & lex);
+       
        /// Update the inset after parameter change.
        void updateInset() const;
        /// Get the status message, depends on the image loading status.
index 0218ac1ddcdc6a1e2108181490417cf49713dab2..6626aea3503cf0c806a70d6fd0bb9dbc42123fb2 100644 (file)
@@ -18,6 +18,7 @@
 
 #include "support/translator.h"
 #include "support/filetools.h"
+#include "support/lyxlib.h"
 
 #include "support/LAssert.h"
 
@@ -109,7 +110,6 @@ void InsetGraphicsParams::init()
 {
        subcaptionText = filename = string();
        display = MONOCHROME;
-       inlineFigure = false;
        subcaption = false;
        keepAspectRatio = true;
        widthResize = DEFAULT_SIZE;
@@ -117,7 +117,7 @@ void InsetGraphicsParams::init()
        heightResize = DEFAULT_SIZE;
        heightSize = 0.0;
        rotateOrigin = DEFAULT;
-       rotateAngle = 0;
+       rotateAngle = 0.0;
 
        testInvariant();
 }
@@ -126,7 +126,6 @@ void InsetGraphicsParams::copy(InsetGraphicsParams const & igp)
 {
        filename = igp.filename;
        display = igp.display;
-       inlineFigure = igp.inlineFigure;
        subcaption = igp.subcaption;
        subcaptionText = igp.subcaptionText;
        keepAspectRatio = igp.keepAspectRatio;
@@ -171,8 +170,8 @@ void InsetGraphicsParams::testInvariant() const
        // The reason for this is that in latex there is a meaning for the
        // different angles and they are not necessarliy interchangeable,
        // it depends on the rotation origin.
-       lyx::Assert(rotateAngle < 360);
-       lyx::Assert(rotateAngle > -360);
+       lyx::Assert(rotateAngle < 360.0);
+       lyx::Assert(rotateAngle > -360.0);
 
 }
 
@@ -181,7 +180,6 @@ bool operator==(InsetGraphicsParams const & left,
 {
        if (left.filename == right.filename &&
                left.display == right.display &&
-               left.inlineFigure == right.inlineFigure &&
                left.subcaption == right.subcaption &&
                left.subcaptionText == right.subcaptionText &&
                left.keepAspectRatio == right.keepAspectRatio &&
@@ -190,7 +188,7 @@ bool operator==(InsetGraphicsParams const & left,
                left.heightResize == right.heightResize &&
                left.heightSize == right.heightSize &&
                left.rotateOrigin == right.rotateOrigin &&
-               left.rotateAngle == right.rotateAngle
+               lyx::float_equal(left.rotateAngle, right.rotateAngle, 0.001)
           )
                return true;
 
@@ -237,10 +235,6 @@ void InsetGraphicsParams::Write(Buffer const * buf, ostream & os) const
        // Save the display type
        os << " display " << displayTranslator.find(display) << '\n';
 
-       // Save the inline status
-       if (inlineFigure)
-               os << " inline";
-
        // Save the subcaption status
        if (subcaption)
                os << " subcaption";
@@ -252,7 +246,7 @@ void InsetGraphicsParams::Write(Buffer const * buf, ostream & os) const
        writeResize(os, "height", heightResize, heightSize);
 
        writeOrigin(os, rotateOrigin);
-       if (rotateAngle != 0)
+       if (lyx::float_equal(rotateAngle, 0.0, 0.001))
                os << " rotateAngle " << rotateAngle << '\n';
 }
 
@@ -298,8 +292,6 @@ bool InsetGraphicsParams::Read(Buffer const * buf, LyXLex & lex,
                string const type = lex.GetString();
 
                display = displayTranslator.find(type);
-       } else if (token == "inline") {
-               inlineFigure = true;
        } else if (token == "subcaption") {
                subcaption = true;
        } else if (token == "subcaptionText") {
@@ -328,7 +320,7 @@ bool InsetGraphicsParams::Read(Buffer const * buf, LyXLex & lex,
                readOrigin(this, token);
        } else if (token == "rotateAngle") {
                lex.next();
-               rotateAngle = lex.GetInteger();
+               rotateAngle = lex.GetFloat();
        } else {
                // If it's none of the above, its not ours.
                return false;
index c774df827f3b12321fd93984b9ef24afd8b02b5d..5eb3415ffce0e11f14249a7e21a16789bb113c3a 100644 (file)
@@ -44,9 +44,6 @@ struct InsetGraphicsParams
        /// How to display the image
        DisplayType display;
 
-       /// Is the figure inlined? (not in a paragraph of its own).
-       bool inlineFigure;
-
        /// Do we have a subcaption?
        bool subcaption;
 
@@ -97,7 +94,7 @@ struct InsetGraphicsParams
        /// Origin point of rotation
        Origin rotateOrigin;
        /// Rotation angle.
-       int rotateAngle;
+       float rotateAngle;
        ///
        InsetGraphicsParams();
        ///
index 12315f3cc37c096106535b93d34575e46cb88b3c..2ff7aa82b0f94d09facbb403855e93102ad0455c 100644 (file)
@@ -162,7 +162,7 @@ bool InsetInclude::display() const
 }
 
 
-string const InsetInclude::getScreenLabel() const
+string const InsetInclude::getScreenLabel(Buffer const *) const
 {
        string temp;
 
index 892ed6be2063802e430fe6c2aa0c2f59f5384cee..043f23c27391db9fc8490eef6286d64cdc49fcfb 100644 (file)
@@ -119,7 +119,7 @@ public:
        SigC::Signal0<void> hideDialog;
 private:
        /// get the text displayed on the button
-       string const getScreenLabel() const;
+       string const getScreenLabel(Buffer const *) const;
        /// is this a verbatim include ?
        bool isVerbatim() const;
         /// get the filename of the master buffer
index 87b3cfaa19570aa5152d1e862fe2f20e6680dee8..dc91d1f3c8fa5fb545e80b7740b35bf8d43ccbf4 100644 (file)
@@ -16,7 +16,7 @@ InsetIndex::InsetIndex(InsetCommandParams const & p, bool)
 {}
 
 
-string const InsetIndex::getScreenLabel() const
+string const InsetIndex::getScreenLabel(Buffer const *) const
 {
        return _("Idx");
 }
@@ -44,7 +44,7 @@ InsetPrintIndex::InsetPrintIndex(InsetCommandParams const & p, bool)
        : InsetCommand(p)
 {}
 
-string const InsetPrintIndex::getScreenLabel() const
+string const InsetPrintIndex::getScreenLabel(Buffer const *) const
 {
        return _("Index");
 }
index 051d78cd3f7d8f4cc2230d236d8d99768d9a0339..36707af81ddd48e8ac523e0b133b5a3c06d70e04 100644 (file)
@@ -31,7 +31,7 @@ public:
                return new InsetIndex(params(), same_id);
        }
        ///
-       string const getScreenLabel() const;
+       string const getScreenLabel(Buffer const *) const;
        ///
        EDITABLE editable() const { return IS_EDITABLE; }
        ///
@@ -64,7 +64,7 @@ public:
        ///
        Inset::Code lyxCode() const;
        ///
-       string const getScreenLabel() const;
+       string const getScreenLabel(Buffer const *) const;
 };
 
 #endif
index 094965e3c767eabb51d155af57903dc2f38c6add..8fbfeeaa5a15f58d25bc7eb8e9e9c86f4aa28d5a 100644 (file)
@@ -27,7 +27,7 @@ public:
                return new InsetLabel(params(), same_id);
        }
        ///
-       string const getScreenLabel() const { return getContents(); }
+       string const getScreenLabel(Buffer const *) const { return getContents(); }
        ///
        EDITABLE editable() const { return IS_EDITABLE; }
        ///
index 26d5cf0cfa6cc148e17ed43066eee8adec8c28f0..cf495ec7ec44ed4a0055b7ca8892705e9037c0dd 100644 (file)
@@ -37,7 +37,7 @@ InsetParent::InsetParent(InsetCommandParams const & p, Buffer const & bf, bool)
 }
 
 
-string const InsetParent::getScreenLabel() const 
+string const InsetParent::getScreenLabel(Buffer const *) const 
 {
        return string(_("Parent:")) + getContents();
 }
index 70e2e2434db2d40ae2cbc96f570f2d011a572f77..63e61b2e1edefd4d5ccf40f3b48617b4aa36cedc 100644 (file)
@@ -33,7 +33,7 @@ public:
                return new InsetParent(params(), buffer, same_id);
        }
        ///
-       string const getScreenLabel() const;
+       string const getScreenLabel(Buffer const *) const;
        ///
        EDITABLE editable() const { return IS_EDITABLE; }
        ///
index ef0da4aa727f18185ce5c9c1e23f7a96f0ed018b..8910dcb4b8593dd09769957511bbf5fb39dda8d6 100644 (file)
@@ -38,7 +38,7 @@ void InsetRef::edit(BufferView *, bool)
 }
 
 
-string const InsetRef::getScreenLabel() const
+string const InsetRef::getScreenLabel(Buffer const *) const
 {
        string temp;
        for (int i = 0; !types[i].latex_name.empty(); ++ i)
index eec668ea791453c0903249e43573ff171aedd9cf..31eed6a1e44c7250c4e5867cb58f74881659f57c 100644 (file)
@@ -44,7 +44,7 @@ public:
                return new InsetRef(params(), buffer, same_id);
        }
        ///
-       string const getScreenLabel() const;
+       string const getScreenLabel(Buffer const *) const;
        ///
        EDITABLE editable() const { return IS_EDITABLE; }
        ///
index 32d9560d6b9b54e2399b5a994e81794f4688224b..d78ef8f37b8999dc1db3f926e3f3cc03c4e5ce0b 100644 (file)
@@ -14,7 +14,7 @@
 
 using std::vector;
 
-string const InsetTOC::getScreenLabel() const 
+string const InsetTOC::getScreenLabel(Buffer const *) const 
 {
        string const cmdname(getCmdName());
        
@@ -47,7 +47,7 @@ void InsetTOC::edit(BufferView * bv, bool)
 
 int InsetTOC::ascii(Buffer const * buffer, std::ostream & os, int) const
 {
-       os << getScreenLabel() << "\n\n";
+       os << getScreenLabel(buffer) << "\n\n";
 
        string type;
        string const cmdname = getCmdName();
index 4107d128a0b76fbd1f403e31b0cab5c7f27ef1c7..349cf61171328c58067a8561300b0cf9f6f37f4d 100644 (file)
@@ -30,7 +30,7 @@ public:
                return new InsetTOC(params(), same_id);
        }
        ///
-       string const getScreenLabel() const;
+       string const getScreenLabel(Buffer const *) const;
        ///
        void edit(BufferView * bv, int, int, unsigned int);
        ///
index 241c69fffe65baf599a6847dd8517bffb5f5d30d..03531c8db8fc764b90567179e28cf1c2a011684a 100644 (file)
@@ -32,7 +32,7 @@ void InsetUrl::edit(BufferView * bv, bool)
 }
 
 
-string const InsetUrl::getScreenLabel() const
+string const InsetUrl::getScreenLabel(Buffer const *) const
 {
        string temp;
        if (getCmdName() == "url" )
index 4fffbcae6d8606afabe5d912a181f7f82d133445..b97913009d41574b8e9106f2e8b0daa1c26cde61 100644 (file)
@@ -35,7 +35,7 @@ public:
        ///
        void validate(LaTeXFeatures &) const;
        ///
-       string const getScreenLabel() const;
+       string const getScreenLabel(Buffer const *) const;
        ///
        EDITABLE editable() const { return IS_EDITABLE; }
        ///
index d0d4a5e15ae18b56d45fecc2a15254ebe3d3603c..7c7ec802d044ef2e4c130704e121b90a83ed7ff0 100644 (file)
@@ -1,3 +1,8 @@
+2001-07-26  Baruch Even  <baruch@lyx.org>
+
+       * lyxlib.h (float_equal): Added function to compare floats almost equal
+       (see function comment).
+
 2001-07-13  Angus Leeming  <a.leeming@ic.ac.uk>
 
        Consistent use of Lsstream.h:
index 290043e88decec9653a4b648e42bf317788579f1..8554ca0ec8e952b32805c2f99c01be4c15a6d584 100644 (file)
@@ -53,5 +53,23 @@ int atoi(string const & nstr);
 string const tempName(string const & dir = string(),
                      string const & mask = string());
 
+
+/** Returns true if var is approximately equal to number with allowed error
+ * of 'error'.
+ *
+ * Reason: A float can be very close to the number, yet still need not be 
+ * exactly equal, you can have exp(-10) which is very close to zero but not
+ * zero. If you only need an approximate equality (you usually do), use this
+ * template.
+ *
+ * Usage: if (float_equal(var, number, 0.0001)) { }
+ * 
+ * This will check if 'var' is approx. equal to 'number' with error of 1/1000
+ */
+inline bool float_equal(float var, float number, float error)
+{
+       return (number - error <= var && var <= number + error);
+}
+
 } // namespace lyx
 #endif /* LYX_LIB_H */