Here it is... working and all -- for me at least. A screenshot at www.hut.fi/~mvermeer/branch.jpeg
Please let me know if a changelog entry would be appreciated :-) 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: bufferparams.C =================================================================== RCS file: /cvs/lyx/lyx-devel/src/bufferparams.C,v retrieving revision 1.55 diff -u -p -r1.55 bufferparams.C --- bufferparams.C 2003/06/10 14:39:42 1.55 +++ bufferparams.C 2003/06/30 14:46:20 @@ -65,6 +65,7 @@ BufferParams::BufferParams() secnumdepth = 3; tocdepth = 3; language = default_language; + branch_sel = ""; fonts = "default"; inputenc = "auto"; graphicsDriver = "default"; Index: bufferparams.h =================================================================== RCS file: /cvs/lyx/lyx-devel/src/bufferparams.h,v retrieving revision 1.33 diff -u -p -r1.33 bufferparams.h --- bufferparams.h 2003/06/10 14:39:42 1.33 +++ bufferparams.h 2003/06/30 14:46:20 @@ -195,6 +195,8 @@ public: int tocdepth; /// Language const * language; + /// Branch selection string: + string branch_sel; /// string inputenc; /// Index: factory.C =================================================================== RCS file: /cvs/lyx/lyx-devel/src/factory.C,v retrieving revision 1.33 diff -u -p -r1.33 factory.C --- factory.C 2003/06/04 09:16:28 1.33 +++ factory.C 2003/06/30 14:46:23 @@ -69,7 +69,7 @@ Inset * createInset(FuncRequest const & return new InsetMinipage(params); case LFUN_INSERT_NOTE: - return new InsetNote(params); + return new InsetNote(params, "Note"); case LFUN_INSET_ERT: return new InsetERT(params); @@ -346,8 +346,12 @@ Inset * readInset(LyXLex & lex, Buffer c inset = new InsetFormula; } else if (tmptok == "Graphics") { inset = new InsetGraphics; - } else if (tmptok == "Note") { - inset = new InsetNote(buf.params); + } else if ((tmptok == "Note") || (tmptok == "comment") + || (tmptok =="blind") || (tmptok == "foot") + || (tmptok == "margin") || (tmptok == "petite") + || (tmptok == "greyedout") || (tmptok == "branch") + ) { + inset = new InsetNote(buf.params, tmptok); } else if (tmptok == "Include") { InsetCommandParams p("Include"); inset = new InsetInclude(p, buf); Index: frontends/controllers/Dialog.C =================================================================== RCS file: /cvs/lyx/lyx-devel/src/frontends/controllers/Dialog.C,v retrieving revision 1.4 diff -u -p -r1.4 Dialog.C --- frontends/controllers/Dialog.C 2003/05/22 15:42:49 1.4 +++ frontends/controllers/Dialog.C 2003/06/30 14:46:33 @@ -65,8 +65,9 @@ void Dialog::RestoreButton() void Dialog::show(string const & data) { - if (controller().isBufferDependent() && !kernel().isBufferAvailable()) + if (controller().isBufferDependent() && !kernel().isBufferAvailable()) { return; + } if (!controller().initialiseParams(data)) { lyxerr << "Dialog \"" << name_ Index: frontends/controllers/Makefile.am =================================================================== RCS file: /cvs/lyx/lyx-devel/src/frontends/controllers/Makefile.am,v retrieving revision 1.55 diff -u -p -r1.55 Makefile.am --- frontends/controllers/Makefile.am 2003/05/13 21:15:47 1.55 +++ frontends/controllers/Makefile.am 2003/06/30 14:46:33 @@ -70,6 +70,8 @@ libcontrollers_la_SOURCES= \ ControlMath.h \ ControlMinipage.C \ ControlMinipage.h \ + ControlNote.C \ + ControlNote.h \ ControlParagraph.C \ ControlParagraph.h \ ControlPreamble.C \ Index: frontends/xforms/Dialogs.C =================================================================== RCS file: /cvs/lyx/lyx-devel/src/frontends/xforms/Dialogs.C,v retrieving revision 1.106 diff -u -p -r1.106 Dialogs.C --- frontends/xforms/Dialogs.C 2003/06/04 09:16:29 1.106 +++ frontends/xforms/Dialogs.C 2003/06/30 14:46:35 @@ -30,6 +30,7 @@ #include "ControlInclude.h" #include "ControlLog.h" #include "ControlMinipage.h" +#include "ControlNote.h" #include "ControlParagraph.h" #include "ControlRef.h" #include "ControlShowFile.h" @@ -54,6 +55,7 @@ #include "FormInclude.h" #include "FormLog.h" #include "FormMinipage.h" +#include "FormNote.h" #include "FormParagraph.h" #include "FormRef.h" #include "FormTabular.h" @@ -76,7 +78,7 @@ namespace { -char const * const dialognames[] = { "about", "bibitem", "bibtex", "changes", "character", "citation", "error", "errorlist" , "ert", "external", "file", "float", "graphics", "include", "index", "label", "log", "minipage", "paragraph", "ref", "tabular", "tabularcreate", +char const * const dialognames[] = { "about", "bibitem", "bibtex", "changes", "character", "citation", "error", "errorlist" , "ert", "external", "file", "float", "graphics", "include", "index", "label", "log", "minipage", "note", "paragraph", "ref", "tabular", "tabularcreate", #ifdef HAVE_LIBAIKSAURUS "thesaurus", @@ -189,6 +191,10 @@ Dialog * Dialogs::build(string const & n dialog->setController(new ControlMinipage(*dialog)); dialog->setView(new FormMinipage(*dialog)); dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy); + } else if (name == "note") { + dialog->setController(new ControlNote(*dialog)); + dialog->setView(new FormNote(*dialog)); + dialog->bc().bp(new OkApplyCancelReadOnlyPolicy); } else if (name == "paragraph") { dialog->setController(new ControlParagraph(*dialog)); dialog->setView(new FormParagraph(*dialog)); Index: frontends/xforms/FormDocument.C =================================================================== RCS file: /cvs/lyx/lyx-devel/src/frontends/xforms/FormDocument.C,v retrieving revision 1.143 diff -u -p -r1.143 FormDocument.C --- frontends/xforms/FormDocument.C 2003/06/10 14:39:45 1.143 +++ frontends/xforms/FormDocument.C 2003/06/30 14:46:39 @@ -22,6 +22,7 @@ #include "input_validators.h" // fl_unsigned_float_filter #include "xforms_helpers.h" +#include "bufferparams.h" #include "CutAndPaste.h" #include "debug.h" #include "language.h" @@ -296,6 +297,7 @@ void FormDocument::build() bcview().addReadOnly(options_->choice_citation_format); bcview().addReadOnly(options_->input_float_placement); bcview().addReadOnly(options_->choice_postscript_driver); + bcview().addReadOnly(options_->input_branch); // trigger an input event for cut&paste with middle mouse button. setPrehandler(options_->input_float_placement); @@ -312,6 +314,9 @@ void FormDocument::build() fl_addto_choice(options_->choice_citation_format, _(" Author-year | Numerical ").c_str()); + setPrehandler(options_->input_branch); + fl_set_input_return(options_->input_branch, FL_RETURN_CHANGED); + // the document bullets form bullets_.reset(build_document_bullet(this)); @@ -819,6 +824,9 @@ bool FormDocument::options_apply(BufferP params.float_placement = getString(options_->input_float_placement); + params.branch_sel = + getString(options_->input_branch); + return redo; } @@ -983,6 +991,10 @@ void FormDocument::options_update(Buffer params.float_placement.c_str()); else fl_set_input(options_->input_float_placement, ""); + if (!params.branch_sel.empty()) + fl_set_input(options_->input_branch, params.branch_sel.c_str()); + else + fl_set_input(options_->input_branch, ""); } Index: frontends/xforms/Makefile.am =================================================================== RCS file: /cvs/lyx/lyx-devel/src/frontends/xforms/Makefile.am,v retrieving revision 1.98 diff -u -p -r1.98 Makefile.am --- frontends/xforms/Makefile.am 2003/05/14 09:17:21 1.98 +++ frontends/xforms/Makefile.am 2003/06/30 14:46:54 @@ -111,6 +111,8 @@ libxforms_la_SOURCES = \ FormMathsStyle.h \ FormMinipage.C \ FormMinipage.h \ + FormNote.C \ + FormNote.h \ FormParagraph.C \ FormParagraph.h \ FormPreamble.C \ Index: frontends/xforms/forms/form_document.fd =================================================================== RCS file: /cvs/lyx/lyx-devel/src/frontends/xforms/forms/form_document.fd,v retrieving revision 1.35 diff -u -p -r1.35 form_document.fd --- frontends/xforms/forms/form_document.fd 2003/04/02 18:57:58 1.35 +++ frontends/xforms/forms/form_document.fd 2003/06/30 14:46:59 @@ -178,13 +178,13 @@ argument: 0 =============== FORM =============== Name: form_document_paper Width: 395 -Height: 310 +Height: 321 Number of Objects: 29 -------------------- class: FL_BOX type: FLAT_BOX -box: 0 0 395 310 +box: 0 0 395 321 boxtype: FL_FLAT_BOX colors: FL_COL1 FL_COL1 alignment: FL_ALIGN_CENTER @@ -247,7 +247,7 @@ size: FL_NORMAL_SIZE lcol: FL_BLACK label: Width:|#W shortcut: -resize: FL_RESIZE_ALL +resize: FL_RESIZE_X gravity: FL_NoGravity FL_NoGravity name: input_custom_width callback: C_FormBaseInputCB @@ -265,7 +265,7 @@ size: FL_DEFAULT_SIZE lcol: FL_BLACK label: shortcut: -resize: FL_RESIZE_ALL +resize: FL_RESIZE_X gravity: FL_NoGravity FL_NoGravity name: choice_custom_width_units callback: C_FormBaseInputCB @@ -283,7 +283,7 @@ size: FL_NORMAL_SIZE lcol: FL_BLACK label: Height:|#H shortcut: -resize: FL_RESIZE_ALL +resize: FL_RESIZE_X gravity: FL_NoGravity FL_NoGravity name: input_custom_height callback: C_FormBaseInputCB @@ -301,7 +301,7 @@ size: FL_DEFAULT_SIZE lcol: FL_BLACK label: shortcut: -resize: FL_RESIZE_ALL +resize: FL_RESIZE_X gravity: FL_NoGravity FL_NoGravity name: choice_custom_height_units callback: C_FormBaseInputCB @@ -328,7 +328,7 @@ argument: -------------------- class: FL_BEGIN_GROUP type: 0 -box: 0 10 10 0 +box: 0 0 0 0 boxtype: FL_NO_BOX colors: FL_COL1 FL_MCOL alignment: FL_ALIGN_CENTER @@ -400,7 +400,7 @@ argument: -------------------- class: FL_LABELFRAME type: ENGRAVED_FRAME -box: 5 130 385 175 +box: 5 130 385 185 boxtype: FL_NO_BOX colors: FL_BLACK FL_COL1 alignment: FL_ALIGN_TOP_LEFT @@ -463,7 +463,7 @@ size: FL_NORMAL_SIZE lcol: FL_BLACK label: Top:|#T shortcut: -resize: FL_RESIZE_ALL +resize: FL_RESIZE_X gravity: FL_NoGravity FL_NoGravity name: input_top_margin callback: C_FormBaseInputCB @@ -481,7 +481,7 @@ size: FL_DEFAULT_SIZE lcol: FL_BLACK label: shortcut: -resize: FL_RESIZE_ALL +resize: FL_RESIZE_X gravity: FL_NoGravity FL_NoGravity name: choice_top_margin_units callback: C_FormBaseInputCB @@ -499,7 +499,7 @@ size: FL_NORMAL_SIZE lcol: FL_BLACK label: Bottom:|#B shortcut: -resize: FL_RESIZE_ALL +resize: FL_RESIZE_X gravity: FL_NoGravity FL_NoGravity name: input_bottom_margin callback: C_FormBaseInputCB @@ -517,7 +517,7 @@ size: FL_DEFAULT_SIZE lcol: FL_BLACK label: shortcut: -resize: FL_RESIZE_ALL +resize: FL_RESIZE_X gravity: FL_NoGravity FL_NoGravity name: choice_bottom_margin_units callback: C_FormBaseInputCB @@ -526,7 +526,7 @@ argument: 0 -------------------- class: FL_INPUT type: NORMAL_INPUT -box: 75 240 50 25 +box: 75 250 50 25 boxtype: FL_DOWN_BOX colors: FL_COL1 FL_MCOL alignment: FL_ALIGN_LEFT @@ -535,7 +535,7 @@ size: FL_NORMAL_SIZE lcol: FL_BLACK label: Inner:|#I shortcut: -resize: FL_RESIZE_ALL +resize: FL_RESIZE_X gravity: FL_NoGravity FL_NoGravity name: input_inner_margin callback: C_FormBaseInputCB @@ -544,7 +544,7 @@ argument: 0 -------------------- class: FL_CHOICE type: NORMAL_CHOICE -box: 125 240 50 25 +box: 125 250 50 25 boxtype: FL_FRAME_BOX colors: FL_COL1 FL_BLACK alignment: FL_ALIGN_LEFT @@ -553,7 +553,7 @@ size: FL_DEFAULT_SIZE lcol: FL_BLACK label: shortcut: -resize: FL_RESIZE_ALL +resize: FL_RESIZE_X gravity: FL_NoGravity FL_NoGravity name: choice_inner_margin_units callback: C_FormBaseInputCB @@ -562,7 +562,7 @@ argument: 0 -------------------- class: FL_INPUT type: NORMAL_INPUT -box: 75 270 50 25 +box: 75 280 50 25 boxtype: FL_DOWN_BOX colors: FL_COL1 FL_MCOL alignment: FL_ALIGN_LEFT @@ -571,7 +571,7 @@ size: FL_NORMAL_SIZE lcol: FL_BLACK label: Outer:|#u shortcut: -resize: FL_RESIZE_ALL +resize: FL_RESIZE_X gravity: FL_NoGravity FL_NoGravity name: input_outer_margin callback: C_FormBaseInputCB @@ -580,7 +580,7 @@ argument: 0 -------------------- class: FL_CHOICE type: NORMAL_CHOICE -box: 125 270 50 25 +box: 125 280 50 25 boxtype: FL_FRAME_BOX colors: FL_COL1 FL_BLACK alignment: FL_ALIGN_LEFT @@ -589,7 +589,7 @@ size: FL_DEFAULT_SIZE lcol: FL_BLACK label: shortcut: -resize: FL_RESIZE_ALL +resize: FL_RESIZE_X gravity: FL_NoGravity FL_NoGravity name: choice_outer_margin_units callback: C_FormBaseInputCB @@ -607,7 +607,7 @@ size: FL_NORMAL_SIZE lcol: FL_BLACK label: Headheight:|#H shortcut: -resize: FL_RESIZE_ALL +resize: FL_RESIZE_X gravity: FL_NoGravity FL_NoGravity name: input_head_height callback: C_FormBaseInputCB @@ -625,7 +625,7 @@ size: FL_DEFAULT_SIZE lcol: FL_BLACK label: shortcut: -resize: FL_RESIZE_ALL +resize: FL_RESIZE_X gravity: FL_NoGravity FL_NoGravity name: choice_head_height_units callback: C_FormBaseInputCB @@ -643,7 +643,7 @@ size: FL_NORMAL_SIZE lcol: FL_BLACK label: Headsep:|#d shortcut: -resize: FL_RESIZE_ALL +resize: FL_RESIZE_X gravity: FL_NoGravity FL_NoGravity name: input_head_sep callback: C_FormBaseInputCB @@ -661,7 +661,7 @@ size: FL_DEFAULT_SIZE lcol: FL_BLACK label: shortcut: -resize: FL_RESIZE_ALL +resize: FL_RESIZE_X gravity: FL_NoGravity FL_NoGravity name: choice_head_sep_units callback: C_FormBaseInputCB @@ -679,7 +679,7 @@ size: FL_NORMAL_SIZE lcol: FL_BLACK label: Footskip:|#F shortcut: -resize: FL_RESIZE_ALL +resize: FL_RESIZE_X gravity: FL_NoGravity FL_NoGravity name: input_foot_skip callback: C_FormBaseInputCB @@ -697,7 +697,7 @@ size: FL_DEFAULT_SIZE lcol: FL_BLACK label: shortcut: -resize: FL_RESIZE_ALL +resize: FL_RESIZE_X gravity: FL_NoGravity FL_NoGravity name: choice_foot_skip_units callback: C_FormBaseInputCB @@ -865,7 +865,7 @@ size: FL_NORMAL_SIZE lcol: FL_BLACK label: Spacing:|#g shortcut: -resize: FL_RESIZE_ALL +resize: FL_RESIZE_X gravity: FL_NoGravity FL_NoGravity name: choice_spacing callback: C_FormBaseInputCB @@ -883,7 +883,7 @@ size: FL_NORMAL_SIZE lcol: FL_BLACK label: Extra Options:|#X shortcut: -resize: FL_RESIZE_ALL +resize: FL_RESIZE_X gravity: FL_NoGravity FL_NoGravity name: input_extra callback: C_FormBaseInputCB @@ -901,7 +901,7 @@ size: FL_NORMAL_SIZE lcol: FL_BLACK label: shortcut: -resize: FL_RESIZE_ALL +resize: FL_RESIZE_X gravity: FL_NoGravity FL_NoGravity name: input_skip callback: C_FormBaseInputCB @@ -919,7 +919,7 @@ size: FL_NORMAL_SIZE lcol: FL_BLACK label: Default Skip:|#u shortcut: -resize: FL_RESIZE_ALL +resize: FL_RESIZE_X gravity: FL_NoGravity FL_NoGravity name: choice_skip callback: C_FormBaseInputCB @@ -928,7 +928,7 @@ argument: 0 -------------------- class: FL_BEGIN_GROUP type: 0 -box: 0 10 10 0 +box: 0 0 0 0 boxtype: FL_NO_BOX colors: FL_COL1 FL_MCOL alignment: FL_ALIGN_CENTER @@ -1000,7 +1000,7 @@ argument: -------------------- class: FL_BEGIN_GROUP type: 0 -box: 0 10 10 0 +box: 0 0 0 0 boxtype: FL_NO_BOX colors: FL_COL1 FL_MCOL alignment: FL_ALIGN_CENTER @@ -1072,7 +1072,7 @@ argument: -------------------- class: FL_BEGIN_GROUP type: 0 -box: 0 10 10 0 +box: 0 0 0 0 boxtype: FL_NO_BOX colors: FL_COL1 FL_MCOL alignment: FL_ALIGN_CENTER @@ -1154,7 +1154,7 @@ size: FL_NORMAL_SIZE lcol: FL_BLACK label: shortcut: -resize: FL_RESIZE_ALL +resize: FL_RESIZE_X gravity: FL_NoGravity FL_NoGravity name: input_spacing callback: C_FormBaseInputCB @@ -1172,7 +1172,7 @@ size: FL_DEFAULT_SIZE lcol: FL_BLACK label: shortcut: -resize: FL_RESIZE_ALL +resize: FL_RESIZE_X gravity: FL_NoGravity FL_NoGravity name: choice_skip_units callback: C_FormBaseInputCB @@ -1259,7 +1259,7 @@ argument: 0 -------------------- class: FL_BEGIN_GROUP type: 0 -box: 0 10 10 0 +box: 0 0 0 0 boxtype: FL_NO_BOX colors: FL_COL1 FL_MCOL alignment: FL_ALIGN_CENTER @@ -1349,13 +1349,13 @@ argument: 0 =============== FORM =============== Name: form_document_options Width: 395 -Height: 310 -Number of Objects: 8 +Height: 326 +Number of Objects: 9 -------------------- class: FL_BOX type: FLAT_BOX -box: 0 0 395 310 +box: 0 0 395 326 boxtype: FL_FLAT_BOX colors: FL_COL1 FL_COL1 alignment: FL_ALIGN_CENTER @@ -1382,7 +1382,7 @@ size: FL_NORMAL_SIZE lcol: FL_BLACK label: Float Placement:|#L shortcut: -resize: FL_RESIZE_ALL +resize: FL_RESIZE_X gravity: FL_NoGravity FL_NoGravity name: input_float_placement callback: C_FormBaseInputCB @@ -1453,7 +1453,7 @@ argument: 0 -------------------- class: FL_CHECKBUTTON type: PUSH_BUTTON -box: 185 225 25 25 +box: 185 215 25 25 boxtype: FL_NO_BOX colors: FL_COL1 FL_YELLOW alignment: FL_ALIGN_LEFT @@ -1471,7 +1471,7 @@ argument: 0 -------------------- class: FL_CHOICE type: NORMAL_CHOICE -box: 185 265 140 25 +box: 185 245 140 25 boxtype: FL_FRAME_BOX colors: FL_COL1 FL_BLACK alignment: FL_ALIGN_LEFT @@ -1489,7 +1489,7 @@ argument: 0 -------------------- class: FL_CHOICE type: NORMAL_CHOICE -box: 185 185 140 25 +box: 185 180 140 25 boxtype: FL_FRAME_BOX colors: FL_COL1 FL_BLACK alignment: FL_ALIGN_LEFT @@ -1504,6 +1504,24 @@ name: choice_ams_math callback: C_FormBaseInputCB argument: 0 +-------------------- +class: FL_INPUT +type: NORMAL_INPUT +box: 185 285 180 25 +boxtype: FL_DOWN_BOX +colors: FL_COL1 FL_MCOL +alignment: FL_ALIGN_LEFT +style: FL_NORMAL_STYLE +size: FL_NORMAL_SIZE +lcol: FL_BLACK +label: Branch Selection:|#B +shortcut: +resize: FL_RESIZE_X +gravity: FL_NoGravity FL_NoGravity +name: input_branch +callback: C_FormBaseInputCB +argument: 0 + =============== FORM =============== Name: form_document_bullet Width: 395 @@ -1594,7 +1612,7 @@ size: FL_NORMAL_SIZE lcol: FL_BLACK label: LaTeX:|#L shortcut: -resize: FL_RESIZE_ALL +resize: FL_RESIZE_X gravity: FL_NoGravity FL_NoGravity name: input_latex callback: C_FormBaseInputCB @@ -1603,7 +1621,7 @@ argument: 0 -------------------- class: FL_BEGIN_GROUP type: 0 -box: 0 10 10 0 +box: 0 0 0 0 boxtype: FL_NO_BOX colors: FL_COL1 FL_MCOL alignment: FL_ALIGN_CENTER @@ -1712,7 +1730,7 @@ argument: -------------------- class: FL_BEGIN_GROUP type: 0 -box: 0 10 10 0 +box: 0 0 0 0 boxtype: FL_NO_BOX colors: FL_COL1 FL_MCOL alignment: FL_ALIGN_CENTER Index: insets/insetnote.C =================================================================== RCS file: /cvs/lyx/lyx-devel/src/insets/insetnote.C,v retrieving revision 1.25 diff -u -p -r1.25 insetnote.C --- insets/insetnote.C 2003/06/03 15:10:11 1.25 +++ insets/insetnote.C 2003/06/30 14:47:00 @@ -10,6 +10,7 @@ #include <config.h> +#include "Lsstream.h" #include "insetnote.h" #include "gettext.h" @@ -17,56 +18,246 @@ #include "language.h" #include "buffer.h" #include "BufferView.h" +#include "latexrunparams.h" +#include "lyxlex.h" #include "lyxtext.h" #include "insets/insettext.h" #include "support/LOstream.h" #include "support/lstrings.h" -#include "debug.h" + using std::ostream; void InsetNote::init() { - LyXFont font(LyXFont::ALL_SANE); - font.decSize(); - font.decSize(); - font.setColor(LColor::note); - setLabelFont(font); - setBackgroundColor(LColor::notebg); - setLabel(_("note")); setInsetName("Note"); + setButtonLabel(); } -InsetNote::InsetNote(BufferParams const & bp) +InsetNote::InsetNote(BufferParams const & bp, string const & label) : InsetCollapsable(bp) { + params_.type = label; init(); + setLabel(label); } InsetNote::InsetNote(InsetNote const & in) - : InsetCollapsable(in) + : InsetCollapsable(in), params_(in.params_) { init(); } +InsetNote::~InsetNote() // MV +{ + InsetNoteMailer mailer("note", *this); + mailer.hideDialog(); +} + Inset * InsetNote::clone() const { return new InsetNote(*this); } - string const InsetNote::editMessage() const { return _("Opened Note Inset"); } - void InsetNote::write(Buffer const * buf, ostream & os) const { - os << getInsetName() << "\n"; + params_.write(os); InsetCollapsable::write(buf, os); +} + + +void InsetNote::read(Buffer const * buf, LyXLex & lex) +{ + //params_.read(lex); + if (trim(params_.type) == "branch") { + if (lex.isOK()) { + lex.next(); + params_.branch = lex.getString(); + } + } + InsetCollapsable::read(buf, lex); + setButtonLabel(); +} + + +void InsetNote::setButtonLabel() +{ + LyXFont font(LyXFont::ALL_SANE); + font.decSize(); + font.decSize(); + + if (params_.type == "branch") { + setLabel(params_.branch); + } else { + setLabel(params_.type); + } + if (params_.type == "blind") { + font.setColor(LColor::note); + setBackgroundColor(LColor::notebg); + } else { + if (params_.type == "branch") + font.setColor(LColor::foreground); + else + font.setColor(LColor::red); + setBackgroundColor(LColor::background); + } + setLabelFont(font); } + + +dispatch_result InsetNote::localDispatch(FuncRequest const & cmd) +{ + BufferView * bv = cmd.view(); + + switch (cmd.action) { + case LFUN_INSET_MODIFY: { + InsetNoteParams params; + InsetNoteMailer::string2params(cmd.argument, params); + params_.type = params.type; + params_.branch = params.branch; + setButtonLabel(); + bv->updateInset(this); + return DISPATCHED; + } + + case LFUN_INSET_EDIT: + if (cmd.button() == mouse_button::button3) + break; + return InsetCollapsable::localDispatch(cmd); + + case LFUN_INSET_DIALOG_UPDATE: + InsetNoteMailer("note", *this).updateDialog(bv); + return DISPATCHED; + + case LFUN_MOUSE_RELEASE: + if (cmd.button() == mouse_button::button3) { + InsetNoteMailer("note", *this).showDialog(bv); + return DISPATCHED; + } + + default: + return InsetCollapsable::localDispatch(cmd); + } + + return UNDISPATCHED; // suppresses warning +} + + +int InsetNote::latex(Buffer const * buf, ostream & os, + LatexRunParams const & runparams_in) const +{ + string const pt = params_.type; + + LatexRunParams runparams = runparams_in; + if (pt == "foot") { // Is this for "thanks" handling? - MV + if (buf && parOwner()) { + LyXLayout_ptr const & layout = parOwner()->layout(); + runparams.moving_arg |= layout->intitle; + } + } + + //BufferParams bp = buf->params; + + int i = 0; + if (pt == "comment") os << "%\n\\begin{comment}{"; // remember to validate + if (pt == "foot") os << "%\n\\footnote{"; + if (pt == "margin") os << "%\n\\marginpar{"; + if (pt == "greyedout") os << "%\n\\color{grey}{"; + if ((pt != "blind") && (pt != "branch")) { + i = inset.latex(buf, os, runparams); + } + if ((pt == "branch") + && (buf->params.branch_sel.find(params_.branch, 0) != string::npos)) { + i = inset.latex(buf, os, runparams); + } + if (pt == "comment") { + os << "%\n\\end{comment}\n"; + i += 3; + } + if ((pt == "foot") || (pt == "margin") || (pt == "greyedout")) { + os << "%\n}"; + i += 2; + } + return i; +} + + +InsetNoteMailer::InsetNoteMailer(string const & name, + InsetNote & inset) + : name_(name), inset_(inset) +{ +} + + +string const InsetNoteMailer::inset2string() const +{ + return params2string(name_, inset_.params()); +} + + +string const InsetNoteMailer::params2string(string const & name, + InsetNoteParams const & params) +{ + ostringstream data; + data << name << ' '; + params.write(data); + return STRCONV(data.str()); + +} + + +void InsetNoteMailer::string2params(string const & in, + InsetNoteParams & params) +{ + params = InsetNoteParams(); + + if (in.empty()) + return; + + istringstream data(STRCONV(in)); + LyXLex lex(0,0); + lex.setStream(data); + params.read(lex); + +} + + +void InsetNoteParams::write(ostream & os) const +{ + os << type << " "; + if (trim(type) == "branch") { + os << branch << "\n"; + } +} + + +void InsetNoteParams::read(LyXLex & lex) +{ + if (lex.isOK()) { + lex.next(); + string token = lex.getString(); + } + + if (lex.isOK()) { + lex.next(); + type = lex.getString(); + } + if (trim(type) == "branch") { + if (lex.isOK()) { + lex.next(); + branch = lex.getString(); + } + } +} + + + Index: insets/insetnote.h =================================================================== RCS file: /cvs/lyx/lyx-devel/src/insets/insetnote.h,v retrieving revision 1.21 diff -u -p -r1.21 insetnote.h --- insets/insetnote.h 2003/06/03 15:10:11 1.21 +++ insets/insetnote.h 2003/06/30 14:47:00 @@ -15,16 +15,38 @@ #include "insetcollapsable.h" -/** The PostIt note inset + +struct InsetNoteParams { + /// + void write(std::ostream & os) const; + /// + void read(LyXLex & lex); + /// + string type; + /// + string branch; +}; + + + + +/** The PostIt note inset, and other annotations */ class InsetNote : public InsetCollapsable { public: /// - InsetNote(BufferParams const &); - /// + InsetNote(BufferParams const &, string const &); + /// Copy constructor InsetNote(InsetNote const &); /// + ~InsetNote(); + /// + dispatch_result InsetNote::localDispatch(FuncRequest const &); + /// + int latex(Buffer const *, std::ostream &, + LatexRunParams const &) const; + /// Inset * clone() const; /// string const editMessage() const; @@ -33,10 +55,10 @@ public: /// void write(Buffer const *, std::ostream &) const; /// - int latex(Buffer const *, std::ostream &, - LatexRunParams const &) const - { return 0; } + void read(Buffer const * buf, LyXLex & lex); /// + void setButtonLabel(); + /// int linuxdoc(Buffer const *, std::ostream &) const { return 0; } /// @@ -47,10 +69,41 @@ public: { return 0; } /// void validate(LaTeXFeatures &) const {} + /// + InsetNoteParams const & params() const { return params_; } + private: + friend class InsetNoteParams; + /// used by the constructors void init(); + /// + InsetNoteParams params_; +}; + +#include "mailinset.h" +class InsetNoteMailer : public MailInset { +public: + ///
/** * \file ControlNote.C * This file is part of LyX, the document processor. * Licence details can be found in the file COPYING. * * \author Angus Leeming * * Full author contact details are available in file CREDITS */ #include <config.h> #include "ControlNote.h" #include "funcrequest.h" #include "insets/insetnote.h" ControlNote::ControlNote(Dialog & parent) : Dialog::Controller(parent) {} bool ControlNote::initialiseParams(string const & data) { InsetNoteParams params; InsetNoteMailer::string2params(data, params); params_.reset(new InsetNoteParams(params)); return true; } void ControlNote::clearParams() { params_.reset(); } void ControlNote::dispatchParams() { string const lfun = InsetNoteMailer::params2string(string("note"), params()); kernel().dispatch(FuncRequest(LFUN_INSET_APPLY, lfun)); }
// -*- C++ -*- /** * \file ControlNote.h * This file is part of LyX, the document processor. * Licence details can be found in the file COPYING. * * \author Angus Leeming * * Full author contact details are available in file CREDITS */ #ifndef CONTROLNOTE_H #define CONTROLNOTE_H #include "Dialog.h" #include "debug.h" class InsetNoteParams; class ControlNote : public Dialog::Controller { public: /// ControlNote(Dialog &); /// virtual bool initialiseParams(string const & data); /// virtual void clearParams(); /// virtual void dispatchParams(); /// virtual bool isBufferDependent() const { return true; } /// InsetNoteParams & params() { return *params_.get(); } /// InsetNoteParams const & params() const { return *params_.get(); } /// private: /// boost::scoped_ptr<InsetNoteParams> params_; }; #endif // CONTROLNOTE_H
/** * \file FormNote.C * This file is part of LyX, the document processor. * Licence details can be found in the file COPYING. * * \author Angus Leeming * * Full author contact details are available in file CREDITS */ #include <config.h> #include "xformsBC.h" #include "ControlNote.h" #include "FormNote.h" #include "forms/form_note.h" #include "xforms_helpers.h" // formatted #include "lyx_forms.h" #include "insets/insetnote.h" typedef FormController<ControlNote, FormView<FD_note> > base_class; FormNote::FormNote(Dialog & parent) : base_class(parent, _("Note")) {} void FormNote::build() { dialog_.reset(build_note(this)); fl_addto_choice(dialog_->choice_type, _("blind|comment|foot|margin|petite|greyedout|branch").c_str()); bcview().setOK(dialog_->button_ok); bcview().setApply(dialog_->button_apply); bcview().setCancel(dialog_->button_cancel); } void FormNote::update() { string type(controller().params().type); string branch(controller().params().branch); if (type == "branch") { setEnabled(dialog_->string_branch, true); } else { setEnabled(dialog_->string_branch, false); } fl_set_choice_text(dialog_->choice_type, type.c_str()); fl_set_input(dialog_->string_branch, branch.c_str()); } void FormNote::apply() { string const type = fl_get_choice_text(dialog_->choice_type); string const branch = fl_get_input(dialog_->string_branch); controller().params().type = type; controller().params().branch = branch; }
// -*- C++ -*- /** * \file FormNote.h * This file is part of LyX, the document processor. * Licence details can be found in the file COPYING. * * \author Angus Leeming * * Full author contact details are available in file CREDITS */ #ifndef FORMNOTE_H #define FORMNOTE_H #include "FormDialogView.h" class ControlNote; struct FD_note; /** This class provides an XForms implementation of the Note Dialog. */ class FormNote : public FormController<ControlNote, FormView<FD_note> > { public: /// Constructor FormNote(Dialog &); private: /// virtual void apply(); /// Build the dialog virtual void build(); /// Update dialog before showing it virtual void update(); }; #endif // FORMNOTE_H
Magic: 13000 Internal Form Definition File (do not change) Number of forms: 1 Unit of measure: FL_COORD_PIXEL SnapGrid: 7 =============== FORM =============== Name: form_note Width: 451 Height: 162 Number of Objects: 6 -------------------- class: FL_BOX type: UP_BOX box: 0 0 451 162 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_INPUT type: NORMAL_INPUT box: 110 60 210 30 boxtype: FL_DOWN_BOX colors: FL_COL1 FL_MCOL alignment: FL_ALIGN_LEFT style: FL_NORMAL_STYLE size: FL_NORMAL_SIZE lcol: FL_BLACK label: Branch|#B shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity name: string_branch callback: C_FormDialogView_InputCB argument: 0 -------------------- class: FL_CHOICE type: NORMAL_CHOICE box: 110 20 110 30 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: 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: 49 112 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: 154 112 119 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: 287 112 126 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 ============================== create_the_forms
pgp00000.pgp
Description: PGP signature