On Tue, Sep 30, 2003 at 03:42:12PM +0000, Angus Leeming spake thusly: > > Martin Vermeer wrote: > > > On Mon, Sep 29, 2003 at 09:47:17AM +0100, Angus Leeming spake thusly: > > > > Next version. Hit it hard. Unless bad bugs come up, I think this is > > about ready to go in. > > > BTW I think this should replace the existing minipage > > stdmenus.ui will need the minipage entry removed.
OK > This default arg seems out of sync with those in stdmenus.ui. Do you mean > "Boxed"? > Index: src/factory.C > + case LFUN_INSERT_BOX: > + if (arg.empty()) > + arg = "Box"; OK > Really? > Index: src/frontends/controllers/ControlBox.C > Index: src/frontends/controllers/ControlBox.h > + * \author Angus Leeming Hmmm.. > You can replace string("box") with plain old "box". The conversion is > implicit. > Index: src/frontends/controllers/ControlBox.C > + string const lfun = InsetBoxMailer::params2string(string("b > ox"), params()); > > Perhaps more to the point, do you need to pass "box" to > InsetBoxMailer::params2string at all? InsetBoxMailer knows it is mailing > boxes. Cleaned up > Put the new files in in alphabetical order please: > Index: src/frontends/controllers/Makefile.am > Index: src/frontends/xforms/Makefile.am > Index: src/insets/Makefile.am OK > This line is way too long... > Index: src/frontends/xforms/Dialogs.C > +char const * const dialognames[] = { "aboutlyx", "bibitem", "bibtex", > "branch", "box", "changes", OK > This stuff belongs in the InsetBoxParams constructor. > Index: src/insets/insetbox.C > +InsetBox::InsetBox(BufferParams const & bp, string const & label) > + : InsetCollapsable(bp) > +{ > + params_.type = label; > + params_.inner_box = true; > + params_.use_parbox = false; > + params_.pos ='t'; > + params_.hor_pos ='c'; > + params_.inner_pos ='t'; > + params_.width = LyXLength("100col%"); > + params_.special = "none"; > + params_.height = LyXLength("1in"); > + params_.height_special = "totalheight"; // default is 1\\totalheight OK, except type > There is a class Translator (support/translator.h) that does exactly this: > + typedef std::map<string, BoxType> BoxMapType; > + static BoxMapType boxmap; > Please use it. Also, get this out of the header file and place it in > namespace anonymous in the .C file. OK > Ditto, this: > +void InsetBox::setButtonLabel() > + unsigned btype = boxmap[params_.type]; > + switch (btype) { > + case Frameless: > + params_.inner_box = "true"; > + if (params_.use_parbox) > + setLabel(_("Parbox")); > + else > + setLabel(_("Minipage")); > + break; > + case Boxed: > + setLabel(_("Boxed")); > + break; > + case ovalbox: > + setLabel(_("ovalbox")); > + break; > + case Ovalbox: > + setLabel(_("Ovalbox")); > + break; > > might well become > setLabel(_(boxlabel_translator.find(params_.type))); This too > Surely it is up to InsetCollapsable to decide what to do on a button3 > press? I think that the whole case can go, so that control falls through > to default. > + case LFUN_INSET_EDIT: > + if (cmd.button() == mouse_button::button3) > + return UNDISPATCHED; > + return InsetCollapsable::localDispatch(cmd); Yes, so it was... > Replace this > +int InsetBox::linuxdoc(Buffer const & buf, std::ostream & os) const > +{ > + int i = 0; > + string const pt = params_.type; > + > + i = inset.linuxdoc(buf, os); > + return i; > +} > with this > +int InsetBox::linuxdoc(Buffer const & buf, std::ostream & os) const > +{ > + return inset.linuxdoc(buf, os);; > +} > > Ditto for docbook. Done earlier > Don't need the name arg here: > + InsetBoxMailer(string const & name, InsetBox & inset); > > insetbox.h: > +class InsetBoxMailer : public MailInset { > + static string const name_; > } > > insetbox.C: > string const InsetBoxMailer::name_ = "box". Done as proposed > How about replacing those > +void InsetBoxParams::read(LyXLex & lex) > if (lex.isOK()) { > ... > } > with > if (!lex.isOK()) > return; > ... > Just a thought. Done. > Do you need the '[0]' bit. Suggests a broken data file. > + hor_pos = lex.getString()[0]; Left as is. > -- > Angus See attached (and it still works!). Sorry for the added files separately, this is my read-only CVS tree using gcc3. - Martin -- Martin Vermeer [EMAIL PROTECTED] Helsinki University of Technology Dept. of Surveying, Inst. of Geodesy P.O. Box 1200, FIN-02015 HUT, Finland :wq
Index: lib/ui/stdmenus.ui =================================================================== RCS file: /cvs/lyx/lyx-devel/lib/ui/stdmenus.ui,v retrieving revision 1.25 diff -u -p -r1.25 stdmenus.ui --- lib/ui/stdmenus.ui 2003/08/22 10:37:25 1.25 +++ lib/ui/stdmenus.ui 2003/10/01 12:33:43 @@ -101,10 +101,10 @@ Menuset OptItem "TeX Code Settings...|C" "inset-settings ert" # 'a' shortcut to match Insert entry, shouldn't clash with Table Settings OptItem "Float Settings...|a" "inset-settings float" - OptItem "Minipage Settings...|M" "inset-settings minipage" OptItem "Text Wrap Settings...|W" "inset-settings wrap" OptItem "Note Settings...|N" "inset-settings note" OptItem "Branch Settings...|B" "inset-settings branch" + OptItem "Box Settings...|x" "inset-settings box" # Hey, guess what's broken ? Surprise surprise, it's tabular stuff # This is in the Table submenu instead for now. # OptItem "Table Settings...|a" "inset-settings tabular" @@ -229,6 +229,7 @@ Menuset Submenu "Float|a" "insert_float" # YUCK Submenu "Note|N" "insert_note" + Submenu "Box" "insert_box" Submenu "Branch|B" "branches" Submenu "File|e" "insert_file" Separator @@ -243,7 +244,6 @@ Menuset Item "URL...|U" "url-insert" Item "Footnote|F" "footnote-insert" Item "Marginal Note|M" "marginalnote-insert" - Item "Minipage|p" "minipage-insert" Item "Short Title" "optional-insert" Item "TeX|X" "ert-insert" End @@ -337,6 +337,15 @@ Menuset Item "LyX Note|N" "note-insert Note" Item "Comment|C" "note-insert Comment" Item "Greyed Out|G" "note-insert Greyedout" + End + + Menu "insert_box" + Item "Frameless|F" "box-insert Frameless" + Item "Boxed|B" "box-insert Boxed" + Item "Oval Box|O" "box-insert ovalbox" + Item "Oval Box, Thick|T" "box-insert Ovalbox" + Item "Shadow Box|S" "box-insert Shadowbox" + Item "Double Box|D" "box-insert Doublebox" End Menu "branches" Index: po/POTFILES.in =================================================================== RCS file: /cvs/lyx/lyx-devel/po/POTFILES.in,v retrieving revision 1.355 diff -u -p -r1.355 POTFILES.in --- po/POTFILES.in 2003/09/26 14:27:18 1.355 +++ po/POTFILES.in 2003/10/01 12:33:43 @@ -18,6 +18,7 @@ src/format.C src/frontends/LyXView.C src/frontends/controllers/ControlAboutlyx.C src/frontends/controllers/ControlBibtex.C +src/frontends/controllers/ControlBox.C src/frontends/controllers/ControlDocument.C src/frontends/controllers/ControlExternal.C src/frontends/controllers/ControlGraphics.C @@ -93,6 +94,7 @@ src/frontends/xforms/FormAboutlyx.C src/frontends/xforms/FormBase.C src/frontends/xforms/FormBibitem.C src/frontends/xforms/FormBibtex.C +src/frontends/xforms/FormBox.C src/frontends/xforms/FormBranch.C src/frontends/xforms/FormChanges.C src/frontends/xforms/FormCharacter.C @@ -142,6 +144,7 @@ src/gettext.h src/importer.C src/insets/inset.C src/insets/insetbibtex.C +src/insets/insetbox.C src/insets/insetbranch.C src/insets/insetcaption.C src/insets/insetenv.C Index: src/LaTeXFeatures.C =================================================================== RCS file: /cvs/lyx/lyx-devel/src/LaTeXFeatures.C,v retrieving revision 1.98 diff -u -p -r1.98 LaTeXFeatures.C --- src/LaTeXFeatures.C 2003/09/18 14:13:22 1.98 +++ src/LaTeXFeatures.C 2003/10/01 12:33:43 @@ -189,7 +189,9 @@ char const * simplefeatures[] = { "prettyref", "float", "wasy", - "dvipost" + "dvipost", + "fancybox", + "calc" }; int const nb_simplefeatures = sizeof(simplefeatures) / sizeof(char const *); Index: src/LyXAction.C =================================================================== RCS file: /cvs/lyx/lyx-devel/src/LyXAction.C,v retrieving revision 1.184 diff -u -p -r1.184 LyXAction.C --- src/LyXAction.C 2003/09/21 23:00:43 1.184 +++ src/LyXAction.C 2003/10/01 12:33:44 @@ -225,6 +225,7 @@ void LyXAction::init() { LFUN_INSET_MINIPAGE, "minipage-insert", Noop }, { LFUN_INSERT_BRANCH, "branch-insert", Noop }, { LFUN_INSERT_NOTE, "note-insert", Noop }, + { LFUN_INSERT_BOX, "box-insert", Noop }, { LFUN_GOTONOTE, "note-next", ReadOnly }, { LFUN_INSET_TOGGLE, "inset-toggle", ReadOnly }, { LFUN_DOWN_PARAGRAPH, "paragraph-down", ReadOnly }, Index: src/factory.C =================================================================== RCS file: /cvs/lyx/lyx-devel/src/factory.C,v retrieving revision 1.58 diff -u -p -r1.58 factory.C --- src/factory.C 2003/09/22 07:46:26 1.58 +++ src/factory.C 2003/10/01 12:33:44 @@ -39,6 +39,7 @@ #include "insets/insetmarginal.h" #include "insets/insetminipage.h" #include "insets/insetnote.h" +#include "insets/insetbox.h" #include "insets/insetbranch.h" #include "insets/insetoptarg.h" #include "insets/insetref.h" @@ -79,6 +80,13 @@ InsetOld * createInset(FuncRequest const arg = "Note"; return new InsetNote(params, arg); } + case LFUN_INSERT_BOX: + { + string arg = cmd.getArg(0); + if (arg.empty()) + arg = "Boxed"; + return new InsetBox(params, arg); + } case LFUN_INSERT_BRANCH: { string arg = cmd.getArg(0); @@ -369,6 +377,10 @@ InsetOld * readInset(LyXLex & lex, Buffe } else if (tmptok == "Note" || tmptok == "Comment" || tmptok == "Greyedout") { inset = new InsetNote(buf.params(), tmptok); + } else if (tmptok == "Boxed" || tmptok == "ovalbox" + || tmptok == "Shadowbox" || tmptok == "Doublebox" + || tmptok == "Ovalbox" || tmptok == "Frameless") { + inset = new InsetBox(buf.params(), tmptok); } else if (tmptok == "Branch") { inset = new InsetBranch(buf.params(), string()); } else if (tmptok == "Include") { Index: src/lfuns.h =================================================================== RCS file: /cvs/lyx/lyx-devel/src/lfuns.h,v retrieving revision 1.19 diff -u -p -r1.19 lfuns.h --- src/lfuns.h 2003/09/09 18:27:21 1.19 +++ src/lfuns.h 2003/10/01 12:33:44 @@ -323,6 +323,7 @@ enum kb_action { // 245 LFUN_INSERT_BRANCH, LFUN_INSET_DIALOG_SHOW, + LFUN_INSERT_BOX, LFUN_LASTACTION // end of the table }; Index: src/lyxfunc.C =================================================================== RCS file: /cvs/lyx/lyx-devel/src/lyxfunc.C,v retrieving revision 1.506 diff -u -p -r1.506 lyxfunc.C --- src/lyxfunc.C 2003/09/21 23:00:45 1.506 +++ src/lyxfunc.C 2003/10/01 12:33:46 @@ -526,6 +526,9 @@ FuncStatus LyXFunc::getStatus(FuncReques case InsetOld::BRANCH_CODE: disable = ev.argument != "branch"; break; + case InsetOld::BOX_CODE: + disable = ev.argument != "box"; + break; default: break; } @@ -653,6 +656,9 @@ FuncStatus LyXFunc::getStatus(FuncReques break; case LFUN_INSERT_NOTE: code = InsetOld::NOTE_CODE; + break; + case LFUN_INSERT_BOX: + code = InsetOld::BOX_CODE; break; case LFUN_INSERT_BRANCH: code = InsetOld::BRANCH_CODE; Index: src/text3.C =================================================================== RCS file: /cvs/lyx/lyx-devel/src/text3.C,v retrieving revision 1.143 diff -u -p -r1.143 text3.C --- src/text3.C 2003/09/15 10:59:54 1.143 +++ src/text3.C 2003/10/01 12:33:47 @@ -1505,6 +1505,7 @@ InsetOld::RESULT LyXText::dispatch(FuncR case LFUN_INSET_CAPTION: #endif case LFUN_INSERT_NOTE: + case LFUN_INSERT_BOX: case LFUN_INSERT_BRANCH: case LFUN_INSERT_BIBITEM: case LFUN_INSET_ERT: Index: src/frontends/controllers/Makefile.am =================================================================== RCS file: /cvs/lyx/lyx-devel/src/frontends/controllers/Makefile.am,v retrieving revision 1.60 diff -u -p -r1.60 Makefile.am --- src/frontends/controllers/Makefile.am 2003/08/17 11:28:20 1.60 +++ src/frontends/controllers/Makefile.am 2003/10/01 12:33:47 @@ -31,6 +31,8 @@ libcontrollers_la_SOURCES= \ ControlBibtex.h \ ControlButtons.C \ ControlButtons.h \ + ControlBox.C \ + ControlBox.h \ ControlBranch.C \ ControlBranch.h \ ControlCharacter.C \ Index: src/frontends/xforms/Dialogs.C =================================================================== RCS file: /cvs/lyx/lyx-devel/src/frontends/xforms/Dialogs.C,v retrieving revision 1.116 diff -u -p -r1.116 Dialogs.C --- src/frontends/xforms/Dialogs.C 2003/09/05 13:15:42 1.116 +++ src/frontends/xforms/Dialogs.C 2003/10/01 12:33:48 @@ -16,6 +16,7 @@ #include "ControlAboutlyx.h" #include "ControlBibtex.h" +#include "ControlBox.h" #include "ControlBranch.h" #include "ControlChanges.h" #include "ControlCitation.h" @@ -41,6 +42,7 @@ #include "FormAboutlyx.h" #include "FormBibitem.h" #include "FormBibtex.h" +#include "FormBox.h" #include "FormBranch.h" #include "FormChanges.h" #include "FormCharacter.h" @@ -107,7 +109,8 @@ FormMathsBitmap * createFormBitmap(Dialo } -char const * const dialognames[] = { "aboutlyx", "bibitem", "bibtex", "branch", "changes", +char const * const dialognames[] = { +"aboutlyx", "bibitem", "bibtex", "branch", "box", "changes", "character", "citation", "error", "errorlist" , "ert", "external", "file", "float", "graphics", "include", "index", "label", "latexlog", "mathpanel", "mathaccents", "matharrows", "mathoperators", "mathrelations", "mathgreek", @@ -407,6 +410,10 @@ Dialog * Dialogs::build(string const & n } else if (name == "note") { dialog->setController(new ControlNote(*dialog)); dialog->setView(new FormNote(*dialog)); + dialog->bc().bp(new OkApplyCancelReadOnlyPolicy); + } else if (name == "box") { + dialog->setController(new ControlBox(*dialog)); + dialog->setView(new FormBox(*dialog)); dialog->bc().bp(new OkApplyCancelReadOnlyPolicy); } else if (name == "branch") { dialog->setController(new ControlBranch(*dialog)); Index: src/frontends/xforms/Makefile.am =================================================================== RCS file: /cvs/lyx/lyx-devel/src/frontends/xforms/Makefile.am,v retrieving revision 1.107 diff -u -p -r1.107 Makefile.am --- src/frontends/xforms/Makefile.am 2003/08/17 11:28:22 1.107 +++ src/frontends/xforms/Makefile.am 2003/10/01 12:33:48 @@ -72,6 +72,8 @@ libxforms_la_SOURCES = \ FormBibitem.h \ FormBibtex.C \ FormBibtex.h \ + FormBox.C \ + FormBox.h \ FormBrowser.C \ FormBrowser.h \ FormBranch.C \ Index: src/frontends/xforms/forms/Makefile.am =================================================================== RCS file: /cvs/lyx/lyx-devel/src/frontends/xforms/forms/Makefile.am,v retrieving revision 1.25 diff -u -p -r1.25 Makefile.am --- src/frontends/xforms/forms/Makefile.am 2003/09/05 17:23:02 1.25 +++ src/frontends/xforms/forms/Makefile.am 2003/10/01 12:33:48 @@ -12,6 +12,7 @@ noinst_LTLIBRARIES = libfdesign.la SRCS = form_aboutlyx.fd \ form_bibitem.fd \ form_bibtex.fd \ + form_box.fd \ form_browser.fd \ form_branch.fd \ form_changes.fd \ Index: src/insets/Makefile.am =================================================================== RCS file: /cvs/lyx/lyx-devel/src/insets/Makefile.am,v retrieving revision 1.66 diff -u -p -r1.66 Makefile.am --- src/insets/Makefile.am 2003/08/17 11:28:23 1.66 +++ src/insets/Makefile.am 2003/10/01 12:33:48 @@ -25,6 +25,8 @@ libinsets_la_SOURCES = \ insetbibitem.h \ insetbibtex.C \ insetbibtex.h \ + insetbox.C \ + insetbox.h \ insetbranch.C \ insetbranch.h \ insetcaption.C \ Index: src/insets/inset.h =================================================================== RCS file: /cvs/lyx/lyx-devel/src/insets/inset.h,v retrieving revision 1.121 diff -u -p -r1.121 inset.h --- src/insets/inset.h 2003/09/19 10:16:32 1.121 +++ src/insets/inset.h 2003/10/01 12:33:49 @@ -130,7 +130,9 @@ public: /// NEWLINE_CODE, /// - BRANCH_CODE + BRANCH_CODE, + /// + BOX_CODE }; ///
// -*- C++ -*- /** * \file insetbox.h * This file is part of LyX, the document processor. * Licence details can be found in the file COPYING. * * \author Angus Leeming * \author Martin Vermeer * * Full author contact details are available in file CREDITS. */ #ifndef INSETBOX_H #define INSETBOX_H #include "insetcollapsable.h" #include "lyxlength.h" #include <map> class InsetBox; struct InsetBoxParams { /// InsetBoxParams(); /// void write(std::ostream & os) const; /// void read(LyXLex & lex); /// string type; /// Use a parbox (true) or minipage (false) bool use_parbox; /// Do we have an inner parbox or minipage to format paragraphs to /// columnwidth? bool inner_box; /// LyXLength width; /// "special" widths, see usrguide.dvi §3.5 string special; /// char pos; /// char hor_pos; /// char inner_pos; /// LyXLength height; /// string height_special; }; /** The fbox/fancybox inset */ class InsetBox : public InsetCollapsable { public: /// InsetBox(BufferParams const &, string const &); /// Copy constructor InsetBox(InsetBox const &); /// ~InsetBox(); /// virtual std::auto_ptr<InsetBase> clone() const; /// string const editMessage() const; /// InsetOld::Code lyxCode() const { return InsetOld::BOX_CODE; } /// void write(Buffer const &, std::ostream &) const; /// void read(Buffer const & buf, LyXLex & lex); /// void setButtonLabel(); /// dispatch_result InsetBox::localDispatch(FuncRequest const &); /// void metrics(MetricsInfo &, Dimension &) const; /// show the Box dialog bool showInsetDialog(BufferView * bv) const; /// int latex(Buffer const &, std::ostream &, LatexRunParams const &) const; /// int linuxdoc(Buffer const &, std::ostream &) const; /// int docbook(Buffer const &, std::ostream &, bool) const; /// int ascii(Buffer const &, std::ostream &, int) const; /// void validate(LaTeXFeatures &) const; /// InsetBoxParams const & params() const { return params_; } /// enum BoxType { Frameless, Boxed, ovalbox, Ovalbox, Shadowbox, Doublebox }; private: friend class InsetBoxParams; /// used by the constructors void init(); /// InsetBoxParams params_; }; #include "mailinset.h" class InsetBoxMailer : public MailInset { public: /// InsetBoxMailer(InsetBox & inset); /// virtual InsetBase & inset() const { return inset_; } /// virtual string const & name() const { return name_; } /// virtual string const inset2string(Buffer const &) const; /// static string const params2string(InsetBoxParams const &); /// static void string2params(string const &, InsetBoxParams &); private: /// static string const name_; /// InsetBox & inset_; }; #endif // INSET_BOX_H
/** * \file insetbox.C * This file is part of LyX, the document processor. * Licence details can be found in the file COPYING. * * \author Angus Leeming * \author Martin Vermeer * \author Jürgen Spitzmüller * * Full author contact details are available in file CREDITS. */ #include <config.h> #include "insetbox.h" #include "debug.h" #include "BufferView.h" #include "funcrequest.h" #include "gettext.h" #include "LaTeXFeatures.h" #include "LColor.h" #include "lyxlex.h" #include "metricsinfo.h" #include "paragraph.h" #include "support/std_sstream.h" #include "support/translator.h" using std::auto_ptr; using std::istringstream; using std::ostream; using std::ostringstream; using std::endl; namespace { Translator<string, InsetBox::BoxType> boxTranslator("Boxed", InsetBox::Boxed); Translator<string, InsetBox::BoxType> boxLocTranslator(_("Boxed"), InsetBox::Boxed); static bool done = false; } // anon void InsetBox::init() { setInsetName("Box"); setButtonLabel(); } InsetBox::InsetBox(BufferParams const & bp, string const & label) : InsetCollapsable(bp) { params_.type = label; if (!done) { done = true; // Initialize only once: boxTranslator.addPair("Frameless", Frameless); boxTranslator.addPair("Boxed", Boxed); boxTranslator.addPair("ovalbox", ovalbox); boxTranslator.addPair("Ovalbox", Ovalbox); boxTranslator.addPair("Shadowbox", Shadowbox); boxTranslator.addPair("Doublebox", Doublebox); // Localizable strings: boxLocTranslator.addPair(_("Boxed"), Boxed); boxLocTranslator.addPair(_("ovalbox"), ovalbox); boxLocTranslator.addPair(_("Ovalbox"), Ovalbox); boxLocTranslator.addPair(_("Shadowbox"), Shadowbox); boxLocTranslator.addPair(_("Doublebox"), Doublebox); } init(); } InsetBox::InsetBox(InsetBox const & in) : InsetCollapsable(in), params_(in.params_) { init(); } InsetBox::~InsetBox() { InsetBoxMailer mailer(*this); mailer.hideDialog(); } auto_ptr<InsetBase> InsetBox::clone() const { return auto_ptr<InsetBase>(new InsetBox(*this)); } string const InsetBox::editMessage() const { return _("Opened Box Inset"); } void InsetBox::write(Buffer const & buf, ostream & os) const { params_.write(os); InsetCollapsable::write(buf, os); } void InsetBox::read(Buffer const & buf, LyXLex & lex) { params_.read(lex); InsetCollapsable::read(buf, lex); setButtonLabel(); } void InsetBox::setButtonLabel() { LyXFont font(LyXFont::ALL_SANE); font.decSize(); font.decSize(); BoxType btype = boxTranslator.find(params_.type); if (btype == Frameless) { if (params_.use_parbox) setLabel(_("Parbox")); else setLabel(_("Minipage")); } else setLabel(boxLocTranslator.find(btype)); font.setColor(LColor::foreground); setBackgroundColor(LColor::background); setLabelFont(font); } void InsetBox::metrics(MetricsInfo & mi, Dimension & dim) const { InsetCollapsable::metrics(mi, dim); if (params_.inner_box) if (isOpen()) dim.wid = mi.base.textwidth; dim_ = dim; } bool InsetBox::showInsetDialog(BufferView * bv) const { InsetBoxMailer(const_cast<InsetBox &>(*this)).showDialog(bv); return true; } dispatch_result InsetBox::localDispatch(FuncRequest const & cmd) { BufferView * bv = cmd.view(); switch (cmd.action) { case LFUN_INSET_MODIFY: { InsetBoxMailer::string2params(cmd.argument, params_); setButtonLabel(); bv->updateInset(this); return DISPATCHED; } case LFUN_INSET_DIALOG_UPDATE: InsetBoxMailer(*this).updateDialog(bv); return DISPATCHED; case LFUN_MOUSE_RELEASE: if (cmd.button() == mouse_button::button3 && hitButton(cmd)) { InsetBoxMailer(*this).showDialog(bv); return DISPATCHED; } // fallthrough: default: return InsetCollapsable::localDispatch(cmd); } } int InsetBox::latex(Buffer const & buf, ostream & os, LatexRunParams const & runparams) const { BoxType btype = boxTranslator.find(params_.type); string width_string = params_.width.asLatexString(); bool stdwidth(false); if (params_.inner_box && (width_string.find("1.0\\columnwidth") != string::npos || width_string.find("1.0\\textwidth") != string::npos)) { stdwidth = true; switch (btype) { case Frameless: break; case Boxed: width_string += " - 2\\fboxsep - 2\\fboxrule"; break; case ovalbox: width_string += " - 2\\fboxsep - 0.8pt"; break; case Ovalbox: width_string += " - 2\\fboxsep - 1.6pt"; break; case Shadowbox: // Shadow falls outside right margin... opinions? width_string += " - 2\\fboxsep - 2\\fboxrule"/* "-\\shadowsize"*/; break; case Doublebox: width_string += " - 2\\fboxsep - 7.5\\fboxrule - 1.0pt"; break; } } int i = 0; os << "%\n"; // Adapt to column/text width correctly also if paragraphs indented: if (stdwidth) os << "\\noindent"; switch (btype) { case Frameless: break; case Boxed: os << "\\framebox"; if (!params_.inner_box) { os << "{\\makebox"; // Special widths, see usrguide §3.5 if (params_.special != "none") { os << "[" << params_.width.value() << "\\" << params_.special << "]"; } else os << "[" << width_string << "]"; if (params_.hor_pos != 'c') os << "[" << params_.hor_pos << "]"; } os << "{"; break; case ovalbox: os << "\\ovalbox{"; break; case Ovalbox: os << "\\Ovalbox{"; break; case Shadowbox: os << "\\shadowbox{"; break; case Doublebox: os << "\\doublebox{"; break; } if (params_.inner_box) { if (params_.use_parbox) os << "\\parbox"; else os << "\\begin{minipage}"; os << "[" << params_.pos << "]"; if (params_.height_special == "none") { os << "[" << params_.height.asLatexString() << "]"; } else { // Special heights os << "[" << params_.height.value() << "\\" << params_.height_special << "]"; } if (params_.inner_pos != params_.pos) os << "[" << params_.inner_pos << "]"; os << "{" << width_string << "}"; if (params_.use_parbox) os << "{"; os << "%\n"; i += 1; } i += inset.latex(buf, os, runparams); if (params_.inner_box) { if (params_.use_parbox) os << "%\n}"; else os << "%\n\\end{minipage}"; } switch (btype) { case Frameless: break; case Boxed: if (!params_.inner_box) os << "}"; // for makebox os << "}"; break; case ovalbox: case Ovalbox: case Doublebox: case Shadowbox: os << "}"; break; } os << "%\n"; i += 3; return i; } int InsetBox::linuxdoc(Buffer const & buf, std::ostream & os) const { return inset.linuxdoc(buf, os); } int InsetBox::docbook(Buffer const & buf, std::ostream & os, bool mixcont) const { return inset.docbook(buf, os, mixcont); } int InsetBox::ascii(Buffer const & buf, std::ostream & os, int ll) const { int i = 0; string const pt = params_.type; BoxType btype = boxTranslator.find(params_.type); switch (btype) { case Frameless: break; case Boxed: os << "["; break; case ovalbox: os << "("; break; case Ovalbox: os << "(("; break; case Shadowbox: os << "["; break; case Doublebox: os << "[["; break; } i = inset.ascii(buf, os, ll); switch (btype) { case Frameless: break; case Boxed: os << "]"; break; case ovalbox: os << ")"; break; case Ovalbox: os << "))"; break; case Shadowbox: os << "]/"; break; case Doublebox: os << "]]"; break; } return i; } void InsetBox::validate(LaTeXFeatures & features) const { features.require("calc"); BoxType btype = boxTranslator.find(params_.type); switch (btype) { case Frameless: case Boxed: break; case ovalbox: case Ovalbox: case Shadowbox: case Doublebox: features.require("fancybox"); break; } inset.validate(features); } InsetBoxMailer::InsetBoxMailer(InsetBox & inset) : inset_(inset) { } string const InsetBoxMailer::name_ = "box"; string const InsetBoxMailer::inset2string(Buffer const &) const { return params2string(inset_.params()); } string const InsetBoxMailer::params2string(InsetBoxParams const & params) { ostringstream data; data << "box" << ' '; params.write(data); return data.str(); } void InsetBoxMailer::string2params(string const & in, InsetBoxParams & params) { params = InsetBoxParams(); if (in.empty()) return; istringstream data(in); LyXLex lex(0,0); lex.setStream(data); string token; lex.next(); token = lex.getString(); lex.next(); params.read(lex); } InsetBoxParams::InsetBoxParams() { inner_box = true; use_parbox = false; pos ='t'; hor_pos ='c'; inner_pos ='t'; width = LyXLength("100col%"); special = "none"; height = LyXLength("1in"); height_special = "totalheight"; // default is 1\\totalheight } void InsetBoxParams::write(ostream & os) const { os << type << "\n"; os << "position \"" << pos << "\"\n"; os << "hor_pos \"" << hor_pos << "\"\n"; os << "has_inner_box " << inner_box << "\n"; os << "inner_pos \"" << inner_pos << "\"\n"; os << "use_parbox " << use_parbox << "\n"; os << "width \"" << width.asString() << "\"\n"; os << "special \"" << special << "\"\n"; os << "height \"" << height.asString() << "\"\n"; os << "height_special \"" << height_special << "\"\n"; } void InsetBoxParams::read(LyXLex & lex) { if (lex.isOK()) { type = lex.getString(); } string token; if (!lex.isOK()) return; lex.next(); token = lex.getString(); if (token == "position") { lex.next(); // The [0] is needed. We need the first and only char in // this string -- MV pos = lex.getString()[0]; } else { lyxerr << "InsetBox::Read: Missing 'position'-tag!" << token << endl; lex.pushToken(token); } if (!lex.isOK()) return; lex.next(); token = lex.getString(); if (token == "hor_pos") { lex.next(); hor_pos = lex.getString()[0]; } else { lyxerr << "InsetBox::Read: Missing 'hor_pos'-tag!" << token << endl; lex.pushToken(token); } if (!lex.isOK()) return; lex.next(); token = lex.getString(); if (token == "has_inner_box") { lex.next(); inner_box = lex.getInteger(); } else { lyxerr << "InsetBox::Read: Missing 'has_inner_box'-tag!" << endl; lex.pushToken(token); } if (!lex.isOK()) return; lex.next(); token = lex.getString(); if (token == "inner_pos") { lex.next(); inner_pos = lex.getString()[0]; } else { lyxerr << "InsetBox::Read: Missing 'inner_pos'-tag!" << token << endl; lex.pushToken(token); } if (!lex.isOK()) return; lex.next(); token = lex.getString(); if (token == "use_parbox") { lex.next(); use_parbox = lex.getInteger(); } else { lyxerr << "InsetBox::Read: Missing 'use_parbox'-tag!" << endl; lex.pushToken(token); } if (!lex.isOK()) return; lex.next(); token = lex.getString(); if (token == "width") { lex.next(); width = LyXLength(lex.getString()); } else { lyxerr << "InsetBox::Read: Missing 'width'-tag!" << endl; lex.pushToken(token); } if (!lex.isOK()) return; lex.next(); token = lex.getString(); if (token == "special") { lex.next(); special = lex.getString(); } else { lyxerr << "InsetBox::Read: Missing 'special'-tag!" << endl; lex.pushToken(token); } if (!lex.isOK()) return; lex.next(); token = lex.getString(); if (token == "height") { lex.next(); height = LyXLength(lex.getString()); } else { lyxerr << "InsetBox::Read: Missing 'height'-tag!" << endl; lex.pushToken(token); } if (!lex.isOK()) return; lex.next(); token = lex.getString(); if (token == "height_special") { lex.next(); height_special = lex.getString(); } else { lyxerr << "InsetBox::Read: Missing 'height_special'-tag!" << endl; lex.pushToken(token); } }
// -*- C++ -*- /** * \file FormBox.h * This file is part of LyX, the document processor. * Licence details can be found in the file COPYING. * * \author Martin Vermeer * * Full author contact details are available in file CREDITS. */ #ifndef FORMBOX_H #define FORMBOX_H #include "FormDialogView.h" class ControlBox; struct FD_box; /** This class provides an XForms implementation of the Box Dialog. */ class FormBox : public FormController<ControlBox, FormView<FD_box> > { public: /// Constructor FormBox(Dialog &); private: /// virtual void apply(); /// Build the dialog virtual void build(); /// Update dialog before showing it virtual void update(); /// virtual ButtonPolicy::SMInput input( FL_OBJECT *, long); /// std::vector<string> ids_; /// std::vector<string> gui_names_; /// std::vector<string> ids_spec_; /// std::vector<string> gui_names_spec_; /// enum Specials { NONE = 1, HEIGHT, DEPTH, TOTALHEIGHT, WIDTH }; }; #endif // FORMBOX_H
/** * \file FormBox.C * This file is part of LyX, the document processor. * Licence details can be found in the file COPYING. * * \author Jürgen Vigna (Minipage stuff) * \author Martin Vermeer * * Full author contact details are available in file CREDITS. */ #include <config.h> #include "FormBox.h" #include "ControlBox.h" #include "forms/form_box.h" #include "controllers/ButtonPolicies.h" #include "controllers/helper_funcs.h" #include "support/lstrings.h" #include "support/tostr.h" #include "Tooltips.h" #include "xforms_helpers.h" #include "xformsBC.h" #include "insets/insetbox.h" #include "lyx_forms.h" #include "debug.h" #include <vector> using lyx::support::getStringFromVector; using lyx::support::isStrDbl; using lyx::support::subst; typedef FormController<ControlBox, FormView<FD_box> > base_class; FormBox::FormBox(Dialog & parent) : base_class(parent, _("Box")) {} void FormBox::build() { dialog_.reset(build_box(this)); box_gui_tokens(ids_, gui_names_); for (unsigned int i = 0; i < gui_names_.size(); ++i) { fl_addto_choice(dialog_->choice_type, gui_names_[i].c_str()); } string str = _("Frameless: No border\n" "Boxed: Rectangular\n" "ovalbox: Oval, thin border\n" "Ovalbox: Oval, thick border\n" "Shadowbox: Box casting shadow\n" "Doublebox: Double line border"); tooltips().init(dialog_->choice_type, str); bcview().addReadOnly(dialog_->check_inner_box); str = _("The inner box may be a parbox or a minipage,\n" "with appropriate arguments from this dialog."); tooltips().init(dialog_->check_inner_box, str); bcview().addReadOnly(dialog_->radio_parbox); bcview().addReadOnly(dialog_->radio_minipage); bcview().addReadOnly(dialog_->choice_pos); fl_addto_choice(dialog_->choice_pos, _("top").c_str()); fl_addto_choice(dialog_->choice_pos, _("middle").c_str()); fl_addto_choice(dialog_->choice_pos, _("bottom").c_str()); bcview().addReadOnly(dialog_->choice_inner_pos); fl_addto_choice(dialog_->choice_inner_pos, _("top").c_str()); fl_addto_choice(dialog_->choice_inner_pos, _("middle").c_str()); fl_addto_choice(dialog_->choice_inner_pos, _("bottom").c_str()); fl_addto_choice(dialog_->choice_inner_pos, _("stretch").c_str()); bcview().addReadOnly(dialog_->choice_hor_pos); fl_addto_choice(dialog_->choice_hor_pos, _("left").c_str()); fl_addto_choice(dialog_->choice_hor_pos, _("center").c_str()); fl_addto_choice(dialog_->choice_hor_pos, _("right").c_str()); fl_addto_choice(dialog_->choice_hor_pos, _("stretch").c_str()); bcview().addReadOnly(dialog_->input_width); bcview().addReadOnly(dialog_->choice_width_unit); bcview().addReadOnly(dialog_->choice_special); box_gui_tokens_special_length(ids_spec_, gui_names_spec_); for (unsigned int i = 0; i < gui_names_spec_.size(); ++i) { fl_addto_choice(dialog_->choice_special, gui_names_spec_[i].c_str()); } string choice = getStringFromVector(getLatexUnits(), "|"); fl_addto_choice(dialog_->choice_width_unit, subst(choice, "%", "%%").c_str()); bcview().addReadOnly(dialog_->input_height); bcview().addReadOnly(dialog_->choice_height_unit); bcview().addReadOnly(dialog_->choice_height_special); for (unsigned int i = 0; i < gui_names_spec_.size(); ++i) { fl_addto_choice(dialog_->choice_height_special, gui_names_spec_[i].c_str()); } choice = getStringFromVector(getLatexUnits(), "|"); fl_addto_choice(dialog_->choice_height_unit, subst(choice, "%", "%%").c_str()); bcview().setOK(dialog_->button_ok); bcview().setApply(dialog_->button_apply); bcview().setCancel(dialog_->button_cancel); } void FormBox::update() { string type(controller().params().type); for (unsigned int i = 0; i < gui_names_.size(); ++i) { if (type == ids_[i]) fl_set_choice_text(dialog_->choice_type, gui_names_[i].c_str()); } fl_set_button(dialog_->check_inner_box, controller().params().inner_box); if (controller().params().type == "Frameless") setEnabled(dialog_->check_inner_box, false); char c = controller().params().pos; fl_set_choice(dialog_->choice_pos, string("tcb").find(c, 0) + 1); c = controller().params().inner_pos; fl_set_choice(dialog_->choice_inner_pos, string("tcbs").find(c, 0) + 1); c = controller().params().hor_pos; fl_set_choice(dialog_->choice_hor_pos, string("lcrs").find(c, 0) + 1); setEnabled(dialog_->choice_pos, controller().params().inner_box); setEnabled(dialog_->choice_inner_pos, controller().params().inner_box); setEnabled(dialog_->choice_hor_pos, !controller().params().inner_box); fl_set_button(dialog_->radio_parbox, controller().params().use_parbox); fl_set_button(dialog_->radio_minipage, !controller().params().use_parbox); setEnabled(dialog_->radio_parbox, controller().params().inner_box); setEnabled(dialog_->radio_minipage, controller().params().inner_box); LyXLength len(controller().params().width); fl_set_input(dialog_->input_width, tostr(len.value()).c_str()); fl_set_choice(dialog_->choice_width_unit, len.unit() + 1); string special(controller().params().special); for (unsigned int i = 0; i < gui_names_spec_.size(); ++i) { if (special == ids_spec_[i]) fl_set_choice_text(dialog_->choice_special, gui_names_spec_[i].c_str()); } // Special width unit must be default for general units to be enabled if(controller().params().special != "none") setEnabled(dialog_->choice_width_unit, false); setEnabled(dialog_->choice_special, !controller().params().inner_box); LyXLength ht(controller().params().height); fl_set_input(dialog_->input_height, tostr(ht.value()).c_str()); fl_set_choice(dialog_->choice_height_unit, ht.unit() + 1); string const height_special(controller().params().height_special); for (unsigned int i = 0; i < gui_names_spec_.size(); ++i) { if (height_special == ids_spec_[i]) fl_set_choice_text(dialog_->choice_height_special, gui_names_spec_[i].c_str()); } setEnabled(dialog_->input_height, controller().params().inner_box); setEnabled(dialog_->choice_height_unit, controller().params().inner_box); setEnabled(dialog_->choice_height_special, controller().params().inner_box); // Same here if(height_special != "none") setEnabled(dialog_->choice_height_unit, false); } void FormBox::apply() { int i = fl_get_choice(dialog_->choice_type); controller().params().type = ids_[i - 1]; controller().params().inner_box = fl_get_button(dialog_->check_inner_box); controller().params().use_parbox = fl_get_button(dialog_->radio_parbox); controller().params().width = LyXLength(getLengthFromWidgets(dialog_->input_width, dialog_->choice_width_unit)); int j = fl_get_choice(dialog_->choice_pos); char c = string("tcb")[j - 1]; controller().params().pos = c; j = fl_get_choice(dialog_->choice_inner_pos); c = string("tcbs")[j - 1]; controller().params().inner_pos = c; j = fl_get_choice(dialog_->choice_hor_pos); c = string("lcrs")[j - 1]; controller().params().hor_pos = c; i = fl_get_choice(dialog_->choice_special); controller().params().special = ids_spec_[i - 1]; controller().params().height = LyXLength(getLengthFromWidgets(dialog_->input_height, dialog_->choice_height_unit)); i = fl_get_choice(dialog_->choice_height_special); controller().params().height_special = ids_spec_[i - 1]; } ButtonPolicy::SMInput FormBox::input(FL_OBJECT * ob, long) { if (ob == dialog_->check_inner_box) { setEnabled(dialog_->choice_pos, fl_get_button(dialog_->check_inner_box)); setEnabled(dialog_->radio_parbox, fl_get_button(dialog_->check_inner_box)); setEnabled(dialog_->radio_minipage, fl_get_button(dialog_->check_inner_box)); setEnabled(dialog_->choice_width_unit, true); setEnabled(dialog_->choice_special, !fl_get_button(dialog_->check_inner_box)); setEnabled(dialog_->input_height, fl_get_button(dialog_->check_inner_box)); setEnabled(dialog_->choice_height_unit, fl_get_button(dialog_->check_inner_box)); setEnabled(dialog_->choice_height_special, fl_get_button(dialog_->check_inner_box)); setEnabled(dialog_->choice_hor_pos, !fl_get_button(dialog_->check_inner_box)); setEnabled(dialog_->choice_inner_pos, fl_get_button(dialog_->check_inner_box)); // Reset to defaults to not confuse users: if (fl_get_button(dialog_->check_inner_box)) fl_set_choice(dialog_->choice_special, NONE); else fl_set_choice(dialog_->choice_height_special, NONE); } if (ob == dialog_->choice_special || ob == dialog_->check_inner_box) setEnabled(dialog_->choice_width_unit, fl_get_choice(dialog_->choice_special) == NONE); if (ob == dialog_->choice_height_special || ob == dialog_->check_inner_box) if (fl_get_choice(dialog_->choice_height_special) != NONE) setEnabled(dialog_->choice_height_unit, false); else setEnabled(dialog_->choice_height_unit, fl_get_button(dialog_->check_inner_box)); // An inner box (parbox, minipage) is mandatory if no outer box if (ob == dialog_->choice_type) { int i = fl_get_choice(dialog_->choice_type); if (ids_[i - 1] == "Frameless") { setEnabled(dialog_->check_inner_box, false); fl_set_button(dialog_->check_inner_box, true); } else { setEnabled(dialog_->check_inner_box, true); } } // disallow senseless data, warnings if input is senseless if (ob == dialog_->input_width) { string const input = getString(dialog_->input_width); bool const invalid = !isValidLength(input) && !isStrDbl(input); if (invalid) { postWarning(_("Invalid Length!")); return ButtonPolicy::SMI_INVALID; } } if (ob == dialog_->input_height) { string const input = getString(dialog_->input_height); bool const invalid = !isValidLength(input) && !isStrDbl(input); if (invalid) { postWarning(_("Invalid Length!")); return ButtonPolicy::SMI_INVALID; } } if (ob == dialog_->button_defaults) { fl_set_button(dialog_->check_inner_box, true); fl_set_button(dialog_->radio_parbox, false); fl_set_input(dialog_->input_width, "100"); fl_set_choice(dialog_->choice_width_unit, LyXLength::PCW + 1); fl_set_choice(dialog_->choice_special, NONE); fl_set_input(dialog_->input_height, "1"); fl_set_choice(dialog_->choice_height_special, TOTALHEIGHT); } return ButtonPolicy::SMI_VALID; }
Magic: 13000 Internal Form Definition File (do not change) Number of forms: 1 Unit of measure: FL_COORD_PIXEL SnapGrid: 7 =============== FORM =============== Name: form_box Width: 442 Height: 379 Number of Objects: 19 -------------------- class: FL_BOX type: UP_BOX box: 0 0 442 379 boxtype: FL_UP_BOX colors: FL_COL1 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_CHOICE type: NORMAL_CHOICE box: 175 21 231 28 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: Box Type|#T shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity name: choice_type callback: C_FormDialogView_InputCB argument: 0 -------------------- class: FL_BUTTON type: RETURN_BUTTON box: 56 322 84 28 boxtype: FL_UP_BOX colors: FL_COL1 FL_COL1 alignment: FL_ALIGN_CENTER style: FL_NORMAL_STYLE size: FL_NORMAL_SIZE lcol: FL_BLACK label: OK shortcut: ^M resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity name: button_ok callback: C_FormDialogView_OKCB argument: 0 -------------------- class: FL_BUTTON type: RETURN_BUTTON box: 147 322 98 28 boxtype: FL_UP_BOX colors: FL_COL1 FL_COL1 alignment: FL_ALIGN_CENTER style: FL_NORMAL_STYLE size: FL_NORMAL_SIZE lcol: FL_BLACK label: Apply|#A shortcut: ^M resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity name: button_apply callback: C_FormDialogView_ApplyCB argument: 0 -------------------- class: FL_BUTTON type: RETURN_BUTTON box: 252 322 105 28 boxtype: FL_UP_BOX colors: FL_COL1 FL_COL1 alignment: FL_ALIGN_CENTER style: FL_NORMAL_STYLE size: FL_NORMAL_SIZE lcol: FL_BLACK label: Cancel|^[ shortcut: ^M resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity name: button_cancel callback: C_FormDialogView_CancelCB argument: 0 -------------------- class: FL_CHECKBUTTON type: PUSH_BUTTON box: 21 70 35 28 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: Has Inner Box shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity name: check_inner_box callback: C_FormDialogView_InputCB argument: 0 -------------------- class: FL_CHOICE type: NORMAL_CHOICE2 box: 315 77 91 28 boxtype: FL_UP_BOX colors: FL_COL1 FL_BLACK alignment: FL_ALIGN_LEFT style: FL_NORMAL_STYLE size: FL_NORMAL_SIZE lcol: FL_BLACK label: Vertical Position shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity name: choice_pos callback: C_FormDialogView_InputCB argument: 0 -------------------- class: FL_CHOICE type: NORMAL_CHOICE2 box: 203 210 91 28 boxtype: FL_UP_BOX colors: FL_COL1 FL_BLACK alignment: FL_ALIGN_TOP style: FL_NORMAL_STYLE size: FL_NORMAL_SIZE lcol: FL_BLACK label: Width Unit shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity name: choice_width_unit callback: C_FormDialogView_InputCB argument: 0 -------------------- class: FL_INPUT type: NORMAL_INPUT box: 126 210 77 28 boxtype: FL_DOWN_BOX colors: FL_COL1 FL_MCOL alignment: FL_ALIGN_TOP style: FL_NORMAL_STYLE size: FL_NORMAL_SIZE lcol: FL_BLACK label: Width shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity name: input_width callback: C_FormDialogView_InputCB argument: 0 -------------------- class: FL_CHOICE type: NORMAL_CHOICE2 box: 294 210 112 28 boxtype: FL_UP_BOX colors: FL_COL1 FL_BLACK alignment: FL_ALIGN_TOP style: FL_NORMAL_STYLE size: FL_NORMAL_SIZE lcol: FL_BLACK label: Special shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity name: choice_special callback: C_FormDialogView_InputCB argument: 0 -------------------- class: FL_ROUND3DBUTTON type: RADIO_BUTTON box: 21 112 35 28 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: Parbox shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity name: radio_parbox callback: C_FormDialogView_InputCB argument: 0 -------------------- class: FL_ROUND3DBUTTON type: RADIO_BUTTON box: 21 140 35 28 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: Minipage shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity name: radio_minipage callback: C_FormDialogView_InputCB argument: 0 -------------------- class: FL_FRAME type: ENGRAVED_FRAME box: 14 112 112 63 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_CHOICE type: NORMAL_CHOICE2 box: 315 112 91 28 boxtype: FL_UP_BOX colors: FL_COL1 FL_BLACK alignment: FL_ALIGN_LEFT style: FL_NORMAL_STYLE size: FL_NORMAL_SIZE lcol: FL_BLACK label: Inner Position (Vert.) shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity name: choice_inner_pos callback: C_FormDialogView_InputCB argument: 0 -------------------- class: FL_CHOICE type: NORMAL_CHOICE2 box: 315 147 91 28 boxtype: FL_UP_BOX colors: FL_COL1 FL_BLACK alignment: FL_ALIGN_LEFT style: FL_NORMAL_STYLE size: FL_NORMAL_SIZE lcol: FL_BLACK label: Horizontal Position shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity name: choice_hor_pos callback: C_FormDialogView_InputCB argument: 0 -------------------- class: FL_INPUT type: NORMAL_INPUT box: 126 266 77 28 boxtype: FL_DOWN_BOX colors: FL_COL1 FL_MCOL alignment: FL_ALIGN_TOP style: FL_NORMAL_STYLE size: FL_NORMAL_SIZE lcol: FL_BLACK label: Height shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity name: input_height callback: C_FormDialogView_InputCB argument: 0 -------------------- class: FL_CHOICE type: NORMAL_CHOICE2 box: 203 266 91 28 boxtype: FL_UP_BOX colors: FL_COL1 FL_BLACK alignment: FL_ALIGN_TOP style: FL_NORMAL_STYLE size: FL_NORMAL_SIZE lcol: FL_BLACK label: Height Unit shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity name: choice_height_unit callback: C_FormDialogView_InputCB argument: 0 -------------------- class: FL_CHOICE type: NORMAL_CHOICE2 box: 294 266 112 28 boxtype: FL_UP_BOX colors: FL_COL1 FL_BLACK alignment: FL_ALIGN_TOP style: FL_NORMAL_STYLE size: FL_NORMAL_SIZE lcol: FL_BLACK label: Special shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity name: choice_height_special callback: C_FormDialogView_InputCB argument: 0 -------------------- class: FL_BUTTON type: NORMAL_BUTTON box: 28 238 77 28 boxtype: FL_UP_BOX colors: FL_COL1 FL_COL1 alignment: FL_ALIGN_CENTER style: FL_NORMAL_STYLE size: FL_DEFAULT_SIZE lcol: FL_BLACK label: Reset shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity name: button_defaults callback: C_FormDialogView_InputCB argument: 0 ============================== create_the_forms
// -*- C++ -*- /** * \file ControlBox.h * This file is part of LyX, the document processor. * Licence details can be found in the file COPYING. * * \author Martin Vermeer (with useful hints from Angus Leeming) * * Full author contact details are available in file CREDITS. */ #ifndef CONTROLBOX_H #define CONTROLBOX_H #include "Dialog.h" #include <vector> class InsetBoxParams; class ControlBox : public Dialog::Controller { public: /// ControlBox(Dialog &); /// virtual bool initialiseParams(string const & data); /// virtual void clearParams(); /// virtual void dispatchParams(); /// virtual bool isBufferDependent() const { return true; } /// InsetBoxParams & params() { return *params_.get(); } /// InsetBoxParams const & params() const { return *params_.get(); } /// private: /// boost::scoped_ptr<InsetBoxParams> params_; }; /// void box_gui_tokens(std::vector<string> &, std::vector<string> &); /// void box_gui_tokens_special_length(std::vector<string> &, std::vector<string> &); #endif // CONTROLBOX_H
/** * \file ControlBox.C * This file is part of LyX, the document processor. * Licence details can be found in the file COPYING. * * \author Martin Vermeer (with useful hints from Angus leeming) * * Full author contact details are available in file CREDITS. */ #include <config.h> #include "ControlBox.h" #include "funcrequest.h" #include "insets/insetbox.h" #include "gettext.h" using std::vector; ControlBox::ControlBox(Dialog & parent) : Dialog::Controller(parent) {} bool ControlBox::initialiseParams(string const & data) { InsetBoxParams params; InsetBoxMailer::string2params(data, params); params_.reset(new InsetBoxParams(params)); return true; } void ControlBox::clearParams() { params_.reset(); } void ControlBox::dispatchParams() { string const lfun = InsetBoxMailer::params2string(/*string("box"),*/ params()); kernel().dispatch(FuncRequest(LFUN_INSET_APPLY, lfun)); } void box_gui_tokens(vector<string> & ids, vector<string> & gui_names) { char const * const ids_[] = { "Frameless", "Boxed", "ovalbox", "Ovalbox", "Shadowbox", "Doublebox"}; size_t const ids_size = sizeof(ids_) / sizeof(char *); ids = vector<string>(ids_, ids_ + ids_size); gui_names.clear(); gui_names.push_back(_("No frame drawn")); gui_names.push_back(_("Rectangular box")); gui_names.push_back(_("Oval box, thin")); gui_names.push_back(_("Oval box, thick")); gui_names.push_back(_("Shadow box")); gui_names.push_back(_("Double box")); } void box_gui_tokens_special_length(vector<string> & ids, vector<string> & gui_names) { char const * const ids_[] = { "none", "height", "depth", "totalheight", "width"}; size_t const ids_size = sizeof(ids_) / sizeof(char *); ids = vector<string>(ids_, ids_ + ids_size); gui_names.clear(); gui_names.push_back(_("None")); gui_names.push_back(_("Height")); gui_names.push_back(_("Depth")); gui_names.push_back(_("Total Height")); gui_names.push_back(_("Width")); }
pgp00000.pgp
Description: PGP signature