This patch adds support for rectangular frames containing one or more
paragraphs of text, at the width of the column, using the Note
infrastructure.

It wouldn't be too hard to extend this to fancybox support.

Does this look like the right thing to do?

- Martin

Index: lib/ui/stdmenus.ui
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/lib/ui/stdmenus.ui,v
retrieving revision 1.25
diff -u -p -r1.25 stdmenus.ui
--- lib/ui/stdmenus.ui  22 Aug 2003 10:37:25 -0000      1.25
+++ lib/ui/stdmenus.ui  18 Sep 2003 21:05:12 -0000
@@ -337,6 +337,7 @@ Menuset
                Item "LyX Note|N" "note-insert Note"
                Item "Comment|C" "note-insert Comment"
                Item "Greyed Out|G" "note-insert Greyedout"
+               Item "[Boxed]|B" "note-insert Boxed"
        End
 
        Menu "branches"
Index: src/factory.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/factory.C,v
retrieving revision 1.55
diff -u -p -r1.55 factory.C
--- src/factory.C       16 Sep 2003 10:54:23 -0000      1.55
+++ src/factory.C       18 Sep 2003 21:05:12 -0000
@@ -367,7 +367,7 @@ InsetOld * readInset(LyXLex & lex, Buffe
                } else if (tmptok == "Graphics") {
                        inset = new InsetGraphics;
                } else if (tmptok == "Note"     || tmptok == "Comment"
-                               || tmptok == "Greyedout") {
+                       || tmptok == "Greyedout" || tmptok == "Boxed") {
                        inset = new InsetNote(buf.params(), tmptok);
                } else if (tmptok == "Branch") {
                        inset = new InsetBranch(buf.params(), tmptok);
Index: src/frontends/controllers/ControlNote.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/controllers/ControlNote.C,v
retrieving revision 1.5
diff -u -p -r1.5 ControlNote.C
--- src/frontends/controllers/ControlNote.C     9 Sep 2003 18:27:22 -0000       1.5
+++ src/frontends/controllers/ControlNote.C     18 Sep 2003 21:05:12 -0000
@@ -50,11 +50,12 @@ void ControlNote::dispatchParams()
 
 void note_gui_tokens(vector<string> & ids, vector<string> & gui_names)
 {
-       char const * const ids_[] = {"Note", "Comment", "Greyedout"};
+       char const * const ids_[] = {"Note", "Comment", "Greyedout", "Boxed"};
        size_t const ids_size = sizeof(ids_) / sizeof(char *);
        ids = vector<string>(ids_, ids_ + ids_size);
        gui_names.clear();
        gui_names.push_back(_("LyX Note"));
        gui_names.push_back(_("Comment"));
        gui_names.push_back(_("Greyed Out"));
+       gui_names.push_back(_("Boxed"));
 }
Index: src/frontends/xforms/FormNote.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/xforms/FormNote.C,v
retrieving revision 1.9
diff -u -p -r1.9 FormNote.C
--- src/frontends/xforms/FormNote.C     9 Sep 2003 18:27:22 -0000       1.9
+++ src/frontends/xforms/FormNote.C     18 Sep 2003 21:05:12 -0000
@@ -35,13 +35,14 @@ void FormNote::build()
 
        note_gui_tokens(ids_, gui_names_);
 
-       for (int i = 0; i < 3; ++i) {
+       for (int i = 0; i < gui_names_.size(); ++i) {
                fl_addto_choice(dialog_->choice_type, gui_names_[i].c_str());
        }
 
        string str = _("Lyx Note: LyX internal only\n"
                       "Comment: Export to LaTeX but don't print\n"
-                      "Greyed Out: Print as grey text");
+                      "Greyed Out: Print as grey text\n"
+                          "Boxed: Place in rectangular box");
        tooltips().init(dialog_->choice_type, str);
 
        bcview().setOK(dialog_->button_ok);
Index: src/insets/insetnote.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetnote.C,v
retrieving revision 1.53
diff -u -p -r1.53 insetnote.C
--- src/insets/insetnote.C      16 Sep 2003 15:39:33 -0000      1.53
+++ src/insets/insetnote.C      18 Sep 2003 21:05:12 -0000
@@ -101,10 +101,14 @@ void InsetNote::setButtonLabel()
                setLabel(_("Comment"));
                font.setColor(LColor::comment);
                setBackgroundColor(LColor::commentbg);
-       } else {
+       } else if (params_.type == "Greyedout"){
                setLabel(_("Greyed Out"));
                font.setColor(LColor::greyedout);
                setBackgroundColor(LColor::greyedoutbg);
+       } else {
+               setLabel(_("[Boxed]"));
+               font.setColor(LColor::foreground);
+               setBackgroundColor(LColor::background);
        }
        setLabelFont(font);
 }
@@ -115,7 +119,8 @@ void InsetNote::metrics(MetricsInfo & mi
        InsetCollapsable::metrics(mi, dim);
        // Contrary to Greyedout, these cannot be construed as part of the
        // running text: make them stand on their own
-       if (params_.type == "Note" || params_.type == "Comment")
+       if (params_.type == "Note" || params_.type == "Comment" 
+        || params_.type == "Boxed")
                if (isOpen())
                        dim.wid = mi.base.textwidth;
        dim_ = dim;
@@ -178,6 +183,12 @@ int InsetNote::latex(Buffer const & buf,
        else if (pt == "Greyedout")
                 // we roll our own macro
                os << "%\n\\begin{lyxgreyedout}\n";
+       else if (pt == "Boxed") {
+               os << "%\n\\newlength\\w\\setlength\\w{\\columnwidth}";
+               os << "%\n\\addtolength\\w{-2\\fboxsep}";
+               os << "%\n\\addtolength\\w{-2\\fboxrule}";
+               os << "%\n\\fbox{\\parbox{\\w}{\n";
+       }
 
        if (pt != "Note")
                i = inset.latex(buf, os, runparams);
@@ -188,7 +199,11 @@ int InsetNote::latex(Buffer const & buf,
        } else if (pt == "Greyedout") {
                os << "%\n\\end{lyxgreyedout}\n";
                i += 4;
+       } else if (pt == "Boxed") {
+               os << "%\n}}\\par\n";
+               i += 7;
        }
+                               
        return i;
 }
 

Attachment: pgp00000.pgp
Description: PGP signature

Reply via email to