On Thu, Jul 31, 2003 at 11:00:49AM +0300, Martin Vermeer spake thusly: > > Attached. > > New: > - open/close selected/deselected branches on FormDocument exit > - clean in-document format for branch definitions > - branchlist editor cleaned up a bit > - branch colours not yet implemented (more discussion required; > Pref-definable, how?) but infrastructure is ready > > ...for your benevolent consideration. > > - Martin
Now added (at Juergen's request) dynamic menu items for inserting Branch insets. Attached the files that changed. 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: /usr/local/lyx/cvsroot/lyx-devel/lib/ui/stdmenus.ui,v retrieving revision 1.20 diff -u -p -r1.20 stdmenus.ui --- lib/ui/stdmenus.ui 30 Jul 2003 13:08:12 -0000 1.20 +++ lib/ui/stdmenus.ui 31 Jul 2003 11:35:42 -0000 @@ -235,6 +235,7 @@ Menuset Item "Footnote|F" "footnote-insert" Item "Marginal Note|M" "marginalnote-insert" Submenu "Note|N" "insert_note" + Submenu "Branch|B" "branches" Item "Minipage|p" "minipage-insert" Item "Short Title" "optional-insert" Item "TeX|X" "ert-insert" @@ -329,6 +330,10 @@ Menuset Item "LyX Note|N" "note-insert Note" Item "Comment|C" "note-insert Comment" Item "Greyed Out|G" "note-insert Greyedout" + End + + Menu "branches" + Branches End # Index: src/insets/insetbranch.h =================================================================== RCS file: src/insets/insetbranch.h diff -N src/insets/insetbranch.h --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/insets/insetbranch.h 31 Jul 2003 11:35:42 -0000 @@ -0,0 +1,107 @@ +// -*- C++ -*- +/** + * \file insetbranch.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 INSETBRANCH_H +#define INSETBRANCH_H + + +#include "insetcollapsable.h" +#include "BranchList.h" + + struct InsetBranchParams { + /// + void write(std::ostream & os) const; + /// + void read(LyXLex & lex); + /// + string branch; + /// Hack -- MV + BranchList branchlist; + }; + + +/** The Branch inset for alternative, conditional output. + +*/ +class InsetBranch : public InsetCollapsable { +public: + /// + + + InsetBranch(BufferParams const &, string const &); + /// Copy constructor + InsetBranch(InsetBranch const &); + /// + ~InsetBranch(); + /// + virtual std::auto_ptr<InsetBase> clone() const; + /// + string const editMessage() const; + /// + InsetOld::Code lyxCode() const { return InsetOld::BRANCH_CODE; } + /// + void write(Buffer const *, std::ostream &) const; + /// + void read(Buffer const * buf, LyXLex & lex); + /// + void setButtonLabel(); + /// + dispatch_result InsetBranch::localDispatch(FuncRequest 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; + /// + InsetBranchParams const & params() const { return params_; } + +private: + friend class InsetBranchParams; + + /// used by the constructors + void init(); + /// + InsetBranchParams params_; +}; + +#include "mailinset.h" + +class InsetBranchMailer : public MailInset { +public: + /// + InsetBranchMailer(string const & name, InsetBranch & 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(string const &, InsetBranchParams const &); + /// + static void string2params(string const &, InsetBranchParams &); + +private: + /// + string const name_; + /// + InsetBranch & inset_; +}; + + + +#endif Index: src/factory.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/factory.C,v retrieving revision 1.43 diff -u -p -r1.43 factory.C --- src/factory.C 30 Jul 2003 13:55:44 -0000 1.43 +++ src/factory.C 31 Jul 2003 11:35:42 -0000 @@ -37,6 +37,7 @@ #include "insets/insetmarginal.h" #include "insets/insetminipage.h" #include "insets/insetnote.h" +#include "insets/insetbranch.h" #include "insets/insetoptarg.h" #include "insets/insetref.h" #include "insets/insetspace.h" @@ -62,7 +63,7 @@ InsetOld * createInset(FuncRequest const { BufferView * bv = cmd.view(); BufferParams const & params = bv->buffer()->params; - + switch (cmd.action) { case LFUN_HFILL: return new InsetHFill(); @@ -77,6 +78,14 @@ InsetOld * createInset(FuncRequest const arg = "Note"; return new InsetNote(params, arg); } + case LFUN_INSERT_BRANCH: + { + string arg = cmd.getArg(0); + if (arg.empty()) + arg = "none"; + return new InsetBranch(params, arg); + } + case LFUN_INSET_ERT: return new InsetERT(params); @@ -358,6 +367,8 @@ InsetOld * readInset(LyXLex & lex, Buffe } else if (tmptok == "Note" || tmptok == "Comment" || tmptok == "Greyedout") { inset = new InsetNote(buf.params, tmptok); + } else if (tmptok == "Branch") { + inset = new InsetBranch(buf.params, tmptok); } else if (tmptok == "Include") { InsetCommandParams p("Include"); inset = new InsetInclude(p, buf); Index: src/MenuBackend.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/MenuBackend.C,v retrieving revision 1.75 diff -u -p -r1.75 MenuBackend.C --- src/MenuBackend.C 27 Jul 2003 13:18:54 -0000 1.75 +++ src/MenuBackend.C 31 Jul 2003 11:35:42 -0000 @@ -69,6 +69,7 @@ MenuItem::MenuItem(Kind kind, string con case FloatListInsert: case FloatInsert: case PasteRecent: + case Branches: break; case Command: action_ = lyxaction.LookupFunc(command); @@ -189,6 +190,7 @@ Menu & Menu::read(LyXLex & lex) { enum Menutags { md_item = 1, + md_branches, md_documents, md_endmenu, md_exportformats, @@ -208,6 +210,7 @@ Menu & Menu::read(LyXLex & lex) }; struct keyword_item menutags[md_last - 1] = { + { "branches", md_branches }, { "documents", md_documents }, { "end", md_endmenu }, { "exportformats", md_exportformats }, @@ -293,6 +296,10 @@ Menu & Menu::read(LyXLex & lex) add(MenuItem(MenuItem::PasteRecent)); break; + case md_branches: + add(MenuItem(MenuItem::Branches)); + break; + case md_optsubmenu: optional = true; // fallback to md_submenu @@ -635,6 +642,26 @@ void expandPasteRecent(Menu & tomenu, Ly } +void expandBranches(Menu & tomenu, LyXView const * view) +{ + int ii = 1; + BufferParams params = view->buffer()->params; + + std::list<Branch>::const_iterator cit = params.branchlist.begin(); + std::list<Branch>::const_iterator end = params.branchlist.end(); + + for (; cit != end && ii < 10; ++cit, ++ii) { + string const label = tostr(ii) + " " + + (cit->getSelected() ? "*" : " ") + + cit->getBranch() + " " + "|" + tostr(ii); + int const action = lyxaction. + getPseudoAction(LFUN_INSERT_BRANCH, + (cit->getBranch())); + tomenu.add(MenuItem(MenuItem::Command, label, action), view); + } +} + + } // namespace anon @@ -669,6 +696,10 @@ void MenuBackend::expand(Menu const & fr case MenuItem::PasteRecent: expandPasteRecent(tomenu, view); + break; + + case MenuItem::Branches: + expandBranches(tomenu, view); break; case MenuItem::Toc: Index: src/MenuBackend.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/MenuBackend.h,v retrieving revision 1.27 diff -u -p -r1.27 MenuBackend.h --- src/MenuBackend.h 17 Jun 2003 15:33:45 -0000 1.27 +++ src/MenuBackend.h 31 Jul 2003 11:35:42 -0000 @@ -65,7 +65,9 @@ public: FloatInsert, /** This is the list of selections that can be pasted. */ - PasteRecent + PasteRecent, + /** Available branches in document */ + Branches }; /// Create a Command type MenuItem MenuItem(Kind kind, @@ -196,7 +198,7 @@ public: /// Expands some special entries of the menu /** The entries with the following kind are expanded to a sequence of Command MenuItems: Lastfiles, Documents, - ViewFormats, ExportFormats, UpdateFormats + ViewFormats, ExportFormats, UpdateFormats, Branches */ void expand(Menu const & frommenu, Menu & tomenu, LyXView const *) const;
pgp00000.pgp
Description: PGP signature