]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/FormBranch.C
Introduce LFUN_PRINT.
[lyx.git] / src / frontends / xforms / FormBranch.C
1 /**
2  * \file FormBranch.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Martin Vermeer
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11
12 #include <config.h>
13
14 #include "FormBranch.h"
15 #include "forms/form_branch.h"
16 #include "xformsBC.h"
17
18 #include "BranchList.h"
19
20 #include "controllers/ControlBranch.h"
21
22 #include "insets/insetbranch.h"
23
24 #include "lyx_forms.h"
25
26 using std::string;
27
28
29 typedef FormController<ControlBranch, FormView<FD_branch> > base_class;
30
31 FormBranch::FormBranch(Dialog & parent)
32         : base_class(parent, _("Branch"))
33 {}
34
35
36 void FormBranch::build()
37 {
38         dialog_.reset(build_branch(this));
39
40         bcview().setOK(dialog_->button_ok);
41         bcview().setApply(dialog_->button_apply);
42         bcview().setCancel(dialog_->button_cancel);
43 }
44
45
46 void FormBranch::update()
47 {
48         typedef BranchList::const_iterator const_iterator;
49
50         BranchList const & branchlist = controller().branchlist();
51         string const cur_branch = controller().params().branch;
52
53         fl_clear_choice(dialog_->choice_branch);
54
55         const_iterator const begin = branchlist.begin();
56         const_iterator const end = branchlist.end();
57         int id = 1;
58         int count = 1;
59         for (const_iterator it = begin; it != end; ++it, ++count) {
60                 string const & branch = it->getBranch();
61                 fl_addto_choice(dialog_->choice_branch, branch.c_str());
62
63                 if (cur_branch == branch)
64                         id = count;
65         }
66         fl_set_choice(dialog_->choice_branch, id);
67 }
68
69
70 void FormBranch::apply()
71 {
72         string const type = fl_get_choice_text(dialog_->choice_branch);
73         controller().params().branch = type;
74 }