On Mon, Jul 28, 2003 at 08:19:55AM +0200, Juergen Spitzmueller spake thusly: > Martin Vermeer wrote: > > > - The "available" browser should be on the left. > > > > ...contrary to the FormCitation practice. > > which is a ui bug IMO (the citation layout), at least wrt left-to-right > reading cultures. > > > > - The buttons are too small ("Add" is "Hinzufügen" in german). > > > > ...and then they say finnish words are long... > > Oh, that's nothing. In 2001, we had > Rindfleischetikettierungsübertragungsaufgabenüberwachungsgesetz > which aimed to be a serious name for a law. > > Juergen. > > BTW, did you see my latest corrections on the document dialog/branches tab, > which disables some buttons when the browsers are empty? > http://www.mail-archive.com/[EMAIL PROTECTED]/msg59332.html
Yes, those are the ones I have in my local copy (good work!). I simplified FormDocument a little further after that still: replaced all_branches_ etc. by a class instantiation branchlist_. Attached. Martin
Index: FormDocument.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/xforms/FormDocument.C,v retrieving revision 1.146 diff -u -p -r1.146 FormDocument.C --- FormDocument.C 26 Jul 2003 23:04:36 -0000 1.146 +++ FormDocument.C 28 Jul 2003 06:18:06 -0000 @@ -5,6 +5,8 @@ * * \author Jürgen Vigna * \author Rob Lahaye + * \author Martin Vermeer + * \author Juergen Spitzmueller * * Full author contact details are available in file CREDITS */ @@ -19,9 +21,11 @@ #include "bmtable.h" #include "checkedwidgets.h" +#include "Tooltips.h" #include "input_validators.h" // fl_unsigned_float_filter #include "xforms_helpers.h" +#include "bufferparams.h" #include "CutAndPaste.h" #include "debug.h" #include "language.h" @@ -342,6 +346,36 @@ void FormDocument::build() fl_set_bmtable_pixmap_file(bullets_->bmtable_panel, 6, 6, bmtablefile.c_str()); + + // the document branches form + branch_.reset(build_document_branch(this)); + + bcview().addReadOnly(branch_->input_all_branches); + bcview().addReadOnly(branch_->button_add_branch); + bcview().addReadOnly(branch_->button_remove_branch); + bcview().addReadOnly(branch_->button_select); + bcview().addReadOnly(branch_->button_deselect); + + // set up the tooltips for branches form + string str = _("Enter the name of a new branch."); + tooltips().init(branch_->input_all_branches, str); + str = _("Add a new branch to the document."); + tooltips().init(branch_->button_add_branch, str); + str = _("Remove the selected branch from the document."); + tooltips().init(branch_->button_remove_branch, str); + str = _("Activate the selected branch for output."); + tooltips().init(branch_->button_select, str); + str = _("Deactivate the selected activated branch."); + tooltips().init(branch_->button_deselect, str); + str = _("Available branches for this document."); + tooltips().init(branch_->browser_all_branches, str); + str = _("Activated branches. Content will occur in the document\'s output"); + tooltips().init(branch_->browser_selection, str); + + // Handle middle mouse paint: + setPrehandler(branch_->input_all_branches); + fl_set_input_return(branch_->input_all_branches, FL_RETURN_CHANGED); + // Enable the tabfolder to be rescaled correctly. if (scalableTabfolders) fl_set_tabfolder_autofit(dialog_->tabfolder, FL_FIT); @@ -365,6 +399,9 @@ void FormDocument::build() fl_deactivate_object(fbullet); fl_set_object_lcol(fbullet, FL_INACTIVE); } + + fl_addto_tabfolder(dialog_->tabfolder,_("Branches").c_str(), + branch_->form); } @@ -377,6 +414,7 @@ void FormDocument::apply() language_apply(params); options_apply(params); bullets_apply(params); + branch_apply(params); } @@ -394,6 +432,7 @@ void FormDocument::update() language_update(params); options_update(params); bullets_update(params); + branch_update(params); } @@ -455,6 +494,13 @@ ButtonPolicy::SMInput FormDocument::inpu setEnabled(options_->choice_citation_format, fl_get_button(options_->check_use_natbib)); + } else if (ob == branch_->browser_all_branches || + ob == branch_->browser_selection || + ob == branch_->button_add_branch || + ob == branch_->button_remove_branch || + ob == branch_->button_select || + ob == branch_->button_deselect) { + branch_input(ob); } else if (ob == dialog_->button_save_defaults) { apply(); controller().saveAsDefault(); @@ -605,6 +651,89 @@ ButtonPolicy::SMInput FormDocument::inpu } +void FormDocument::branch_input(FL_OBJECT * ob) +{ + BufferParams & params = controller().params(); + std::vector<string> vec; + + if (ob == branch_->button_add_branch) { + string new_branch = fl_get_input(branch_->input_all_branches); + if (!new_branch.empty()) { + params.branchlist.add(new_branch); + fl_set_input(branch_->input_all_branches, ""); + // Update branch list + string const all_branches = params.branchlist.allBranches(); + fl_clear_browser(branch_->browser_all_branches); + vec = getVectorFromString(all_branches, "|"); + for (unsigned i = 0; i < vec.size(); ++i) { + fl_addto_browser(branch_->browser_all_branches, + vec[i].c_str()); + } + } + + } else if (ob == branch_->button_remove_branch) { + unsigned i = fl_get_browser(branch_->browser_all_branches); + string const current_branch = + fl_get_browser_line(branch_->browser_all_branches, i); + if (!current_branch.empty()) { + params.branchlist.remove(current_branch); + // Update branch list + string const all_branches = params.branchlist.allBranches(); + fl_clear_browser(branch_->browser_all_branches); + vec = getVectorFromString(all_branches, "|"); + for (unsigned i = 0; i < vec.size(); ++i) { + fl_addto_browser(branch_->browser_all_branches, + vec[i].c_str()); + } + // Update selected-list... + string const all_selected = params.branchlist.allSelected(); + fl_clear_browser(branch_->browser_selection); + vec = getVectorFromString(all_selected, "|"); + for (unsigned i = 0; i < vec.size(); ++i) { + fl_addto_browser(branch_->browser_selection, vec[i].c_str()); + } + } + + } else if (ob == branch_->button_select) { + unsigned i = fl_get_browser(branch_->browser_all_branches); + string const current_branch = + fl_get_browser_line(branch_->browser_all_branches, i); + if (!current_branch.empty()) { + fl_clear_browser(branch_->browser_selection); + params.branchlist.setSelected(current_branch, true); + string const all_selected = params.branchlist.allSelected(); + vec = getVectorFromString(all_selected, "|"); + for (unsigned i = 0; i < vec.size(); ++i) { + fl_addto_browser(branch_->browser_selection, + vec[i].c_str()); + } + } + } else if (ob == branch_->button_deselect) { + unsigned i = fl_get_browser(branch_->browser_selection); + string const current_sel = + fl_get_browser_line(branch_->browser_selection, i); + if (!current_sel.empty()) { + fl_clear_browser(branch_->browser_selection); + params.branchlist.setSelected(current_sel, false); + string const all_selected = params.branchlist.allSelected(); + vec = getVectorFromString(all_selected, "|"); + for (unsigned i = 0; i < vec.size(); ++i) { + fl_addto_browser(branch_->browser_selection, + vec[i].c_str()); + } + } + } + + setEnabled(branch_->button_select, + (fl_get_browser(branch_->browser_all_branches) > 0)); + setEnabled(branch_->button_deselect, + (fl_get_browser(branch_->browser_selection) > 0)); + setEnabled(branch_->button_remove_branch, + (fl_get_browser(branch_->browser_all_branches) > 0)); + + branchlist_ = params.branchlist; +} + bool FormDocument::class_apply(BufferParams ¶ms) { bool redo = false; @@ -829,6 +958,12 @@ void FormDocument::bullets_apply(BufferP } +void FormDocument::branch_apply(BufferParams & params) +{ + params.branchlist = branchlist_; +} + + void FormDocument::UpdateClassParams(BufferParams const & params) { // These are the params that have to be updated on any class change @@ -1090,6 +1225,44 @@ void FormDocument::bullets_update(Buffer params.user_defined_bullets[0].getText().c_str()); fl_set_choice(bullets_->choice_size, params.user_defined_bullets[0].getSize() + 2); +} + + + +void FormDocument::branch_update(BufferParams const & params) +{ + if (!branch_.get()) + return; + + string const all_branches = params.branchlist.allBranches(); + fl_clear_browser(branch_->browser_all_branches); + + if (!all_branches.empty()) { + std::vector<string> vec = getVectorFromString(all_branches, "|"); + for (unsigned i = 0; i < vec.size(); ++i) { + fl_addto_browser(branch_->browser_all_branches, vec[i].c_str()); + } + fl_select_browser_line(branch_->browser_all_branches, 1); + string const current_branch = + fl_get_browser_line(branch_->browser_all_branches, 1); + } + + // display proper selection... + string const all_selected = params.branchlist.allSelected(); + fl_clear_browser(branch_->browser_selection); + if (!all_selected.empty()) { + std::vector<string> vec = getVectorFromString(all_selected, "|"); + for (unsigned i = 0; i < vec.size(); ++i) { + fl_addto_browser(branch_->browser_selection, vec[i].c_str()); + } + } + + setEnabled(branch_->button_select, + (fl_get_browser(branch_->browser_all_branches) > 0)); + setEnabled(branch_->button_deselect, + (fl_get_browser(branch_->browser_selection) > 0)); + setEnabled(branch_->button_remove_branch, + (fl_get_browser(branch_->browser_all_branches) > 0)); } Index: FormDocument.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/xforms/FormDocument.h,v retrieving revision 1.37 diff -u -p -r1.37 FormDocument.h --- FormDocument.h 2 Apr 2003 14:20:29 -0000 1.37 +++ FormDocument.h 28 Jul 2003 06:18:06 -0000 @@ -29,6 +29,7 @@ struct FD_document_class; struct FD_document_language; struct FD_document_options; struct FD_document_bullet; +struct FD_document_branch; /** This class provides an XForms implementation of the FormDocument dialog. * The table-layout-form here changes values for latex-tabulars @@ -50,6 +51,8 @@ private: virtual void apply(); /// + void branch_input( FL_OBJECT *); + /// void ChoiceBulletSize(FL_OBJECT * ob, long); /// void InputBulletLaTeX(FL_OBJECT * ob, long); @@ -78,6 +81,8 @@ private: void options_update(BufferParams const &); /// void bullets_update(BufferParams const &); + /// + void branch_update(BufferParams const &); /// void paper_apply(BufferParams &); @@ -89,6 +94,8 @@ private: bool options_apply(BufferParams &); /// void bullets_apply(BufferParams &); + /// + void branch_apply(BufferParams &); /// Real GUI implementation. boost::scoped_ptr<FD_document_paper> paper_; @@ -101,6 +108,8 @@ private: /// boost::scoped_ptr<FD_document_bullet> bullets_; /// + boost::scoped_ptr<FD_document_branch> branch_; + /// int ActCell; /// int Confirmed; @@ -112,6 +121,13 @@ private: FL_OBJECT * fbullet; /// std::vector<string> lang_; + /// Contains all legal branches for this doc + BranchList branchlist_; + ///string all_branches_; + /// + ///string all_selected_; + /// + ///string all_colors_; }; #endif
pgp00000.pgp
Description: PGP signature