]> git.lyx.org Git - features.git/commitdiff
Change the LyX file format, adding a "preview" flag to Include insets.
authorAngus Leeming <leeming@lyx.org>
Fri, 2 Aug 2002 18:25:25 +0000 (18:25 +0000)
committerAngus Leeming <leeming@lyx.org>
Fri, 2 Aug 2002 18:25:25 +0000 (18:25 +0000)
Document this change in a new file FORMAT.
Enable the user to toggle preview status by modifying the Include dialog.

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

development/ChangeLog
development/FORMAT [new file with mode: 0644]
src/frontends/xforms/ChangeLog
src/frontends/xforms/FormInclude.C
src/frontends/xforms/forms/form_include.fd
src/insets/ChangeLog
src/insets/insetcommandparams.C
src/insets/insetcommandparams.h
src/insets/insetinclude.C

index b82dec864d72789e1f4087f91ab6af5b24f3604f..1e7ae0d90e0f477a06e3cd2d10df8918926beab5 100644 (file)
@@ -1,3 +1,8 @@
+2002-08-02  Angus Leeming  <leeming@lyx.org>
+
+       * FORMAT: a new file to document changes in the LyX file format.
+       Start it off with a change to Include insets.
+
 2002-06-26  André Pönitz <poenitz@gmx.de>
 
        * development/Win32/lyxwin32.c: Win32 specific patch from Claus
diff --git a/development/FORMAT b/development/FORMAT
new file mode 100644 (file)
index 0000000..0688503
--- /dev/null
@@ -0,0 +1,17 @@
+Changes to the LyX format since version 220 (LyX 1.2.0) was released.
+=====================================================================
+
+2002-08-02  Angus Leeming  <leeming@lyx.org>
+
+Added a boolean "preview" flag to InsetCommandParams.
+Currently it is written only by InsetInclude, because only this
+class can generate a preview of its contents.
+
+The LyX file now contains:
+
+ \begin_inset Include \input{snapshot_t=40.tex}
++preview true
+
+ \end_inset 
+
+Earlier versions of LyX just swallow this extra token silently.
index 5f660da64eac6639ab2cecce4b4697c6db0fd13c..e60397101b2845b795e582dba3a31fbb66479684 100644 (file)
@@ -1,3 +1,9 @@
+2002-08-02  Angus Leeming  <leeming@lyx.org>
+
+       * FormInclude.C:
+       * forms/form_include.fd: added a check_preview button and controlling
+       logic. The user can now choose to preview a \input-ed file.
+
 2002-08-02  Angus Leeming  <leeming@lyx.org>
 
        * FormTabular.C (input):
index fc5edcd837bbaffd77b5ad307e9c24fc8855d113..fcf18e902c3c63fe806f116fd368d01ebc42a9f7 100644 (file)
@@ -76,6 +76,14 @@ void FormInclude::update()
        fl_set_button(dialog_->check_typeset,
                      int(controller().params().noload));
 
+       if (cmdname == "input")
+               fl_set_button(dialog_->check_preview,
+                             int(controller().params().cparams.preview()));
+       else
+               fl_set_button(dialog_->check_preview, 0);
+
+       setEnabled(dialog_->check_preview, (cmdname == "input"));
+
        fl_set_button(dialog_->radio_useinput, cmdname == "input");
        fl_set_button(dialog_->radio_useinclude, cmdname == "include");
        if (cmdname == "verbatiminput" || cmdname == "verbatiminput*") {
@@ -97,6 +105,8 @@ void FormInclude::update()
 void FormInclude::apply()
 {
        controller().params().noload = fl_get_button(dialog_->check_typeset);
+       controller().params().cparams
+               .preview(fl_get_button(dialog_->check_preview));
 
        string const file = fl_get_input(dialog_->input_filename);
        if (controller().fileExists(file))
@@ -161,5 +171,13 @@ ButtonPolicy::SMInput FormInclude::input(FL_OBJECT * ob, long)
                        action = ButtonPolicy::SMI_INVALID;
        }
 
+       if (ob == dialog_->radio_useinput) {
+               setEnabled(dialog_->check_preview, true);
+       } else if (ob == dialog_->radio_verbatim ||
+                  ob == dialog_->radio_useinclude) {
+               fl_set_button(dialog_->check_preview, 0);
+               setEnabled(dialog_->check_preview, false);
+       }
+
        return action;
 }
index dc0bd01d3a787d3431329ae0a3ad66f4881cc7d7..191d6737250c1af4e4045402ae2607d23ea6aa8e 100644 (file)
@@ -9,13 +9,13 @@ Unit of measure: FL_COORD_PIXEL
 =============== FORM ===============
 Name: form_include
 Width: 340
-Height: 210
-Number of Objects: 14
+Height: 250
+Number of Objects: 15
 
 --------------------
 class: FL_BOX
 type: UP_BOX
-box: 0 0 340 210
+box: 0 0 340 250
 boxtype: FL_UP_BOX
 colors: FL_COL1 FL_COL1
 alignment: FL_ALIGN_CENTER
@@ -87,7 +87,7 @@ argument: 0
 --------------------
 class: FL_BUTTON
 type: RETURN_BUTTON
-box: 120 170 100 30
+box: 120 210 100 30
 boxtype: FL_UP_BOX
 colors: FL_COL1 FL_COL1
 alignment: FL_ALIGN_CENTER
@@ -105,7 +105,7 @@ argument: 0
 --------------------
 class: FL_BUTTON
 type: NORMAL_BUTTON
-box: 230 170 100 30
+box: 230 210 100 30
 boxtype: FL_UP_BOX
 colors: FL_COL1 FL_COL1
 alignment: FL_ALIGN_CENTER
@@ -123,7 +123,7 @@ argument: 0
 --------------------
 class: FL_BUTTON
 type: NORMAL_BUTTON
-box: 230 130 100 30
+box: 230 170 100 30
 boxtype: FL_UP_BOX
 colors: FL_COL1 FL_COL1
 alignment: FL_ALIGN_CENTER
@@ -177,7 +177,7 @@ argument: 0
 --------------------
 class: FL_BEGIN_GROUP
 type: 0
-box: 0 0 0
+box: 0 10 10 0
 boxtype: FL_NO_BOX
 colors: FL_COL1 FL_MCOL
 alignment: FL_ALIGN_CENTER
@@ -264,5 +264,23 @@ name:
 callback: 
 argument: 
 
+--------------------
+class: FL_CHECKBUTTON
+type: PUSH_BUTTON
+box: 180 130 150 30
+boxtype: FL_NO_BOX
+colors: FL_COL1 FL_YELLOW
+alignment: FL_ALIGN_CENTER
+style: FL_NORMAL_STYLE
+size: FL_NORMAL_SIZE
+lcol: FL_BLACK
+label: Preview|#p
+shortcut: 
+resize: FL_RESIZE_NONE
+gravity: FL_NoGravity FL_NoGravity
+name: check_preview
+callback: C_FormBaseInputCB
+argument: 0
+
 ==============================
 create_the_forms
index b75d552a6fe85c5504cd28264e987905a30c55cd..ab522377b013cfd9c5c7f60745a19ab4a024a71b 100644 (file)
@@ -1,3 +1,13 @@
+2002-08-02  Angus Leeming  <leeming@lyx.org>
+
+       * insetcommandparams.[Ch] (preview): new methods returning and setting
+       a new bool preview_ flag.
+       (read): read this flag.
+       (operator==): add flag to check.
+
+       * insetinclude.C (write): output new preview() flag.
+       (previewWanted): use this flag.
+
 2002-08-02  Angus Leeming  <leeming@lyx.org>
 
        * insetcollapsable.[Ch] (addPreview):
index d3879d0ae036e60acad6d8057f2983c2ec585dfb..5da44d6bf9c5abc94ac597abdf678e89c8b4e444 100644 (file)
@@ -29,7 +29,7 @@ InsetCommandParams::InsetCommandParams()
 InsetCommandParams::InsetCommandParams(string const & n,
                                        string const & c,
                                        string const & o)
-       : cmdname(n), contents(c), options(o)
+       : cmdname(n), contents(c), options(o), preview_(false)
 {}
 
 
@@ -137,10 +137,14 @@ void InsetCommandParams::read(LyXLex & lex)
        }
 
        while (lex.isOK()) {
-               lex.nextToken();
+               lex.next();
                token = lex.getString();
                if (token == "\\end_inset")
                        break;
+               if (token == "preview") {
+                       lex.next();
+                       preview_ = lex.getBool();
+               }
        }
        if (token != "\\end_inset") {
                lex.printError("Missing \\end_inset at this point. "
@@ -170,7 +174,8 @@ bool operator==(InsetCommandParams const & o1,
 {
        return o1.getCmdName() == o2.getCmdName()
                && o1.getContents() == o2.getContents()
-               && o1.getOptions() == o2.getOptions();
+               && o1.getOptions() == o2.getOptions()
+               && o1.preview() == o2.preview();
 }
 
 
index b6c3b75dedf04973b897765b06ce1b0485c2afdd..481151c1191711b881cf1bd918d293d79977e945 100644 (file)
@@ -56,6 +56,11 @@ public:
        string const getAsString() const;
        ///
        void setFromString(string const &);
+       ///
+       bool preview() const { return preview_; }
+       ///
+       void preview(bool p) { preview_ = p; }
+
 private:
        ///
        string cmdname;
@@ -63,6 +68,8 @@ private:
        string contents;
        ///
        string options;
+       ///
+       bool preview_;
 };
 
 
index 6ecc6142196fc938554bbc90737f223b7d4ca8bf..dfc699a713a1f1cd8e25323c127cd1dacdb94b3a 100644 (file)
@@ -162,7 +162,8 @@ void InsetInclude::edit(BufferView * bv, bool)
 
 void InsetInclude::write(Buffer const *, ostream & os) const
 {
-       os << "Include " << params_.cparams.getCommand() << "\n";
+       os << "Include " << params_.cparams.getCommand() << '\n'
+          << "preview " << tostr(params_.cparams.preview()) << '\n';
 }
 
 
@@ -528,7 +529,8 @@ void InsetInclude::addPreview(grfx::PreviewLoader & ploader) const
 
 bool InsetInclude::PreviewImpl::previewWanted() const
 {
-       return parent().params_.flag == InsetInclude::INPUT;
+       return parent().params_.flag == InsetInclude::INPUT &&
+               parent().params_.cparams.preview();
 }