]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/FormInset.C
fix tooltips in toolbar
[lyx.git] / src / frontends / xforms / FormInset.C
1 /**
2  * \file FormInset.C
3  * Copyright 2000-2001 The LyX Team.
4  * See the file COPYING.
5  *
6  * \author Angus Leeming, a.leeming@ic.ac.uk
7  */
8
9 #include <config.h>
10
11 #include FORMS_H_LOCATION
12
13 #ifdef __GNUG__
14 #pragma implementation
15 #endif
16
17 #include "Dialogs.h"
18 #include "frontends/LyXView.h"
19 #include "FormInset.h"
20 #include "xformsBC.h"
21 #include "insets/insetcommand.h"
22
23 #include <boost/bind.hpp>
24
25 FormInset::FormInset(LyXView * lv, Dialogs * d, string const & t)
26         : FormBaseBD(lv, d, t)
27 {}
28
29
30 void FormInset::connect()
31 {
32         u_ = d_->updateBufferDependent.
33                 connect(boost::bind(&FormInset::updateSlot, this, _1));
34         h_ = d_->hideBufferDependent.
35                 connect(boost::bind(&FormInset::hide, this));
36         FormBaseDeprecated::connect();
37 }
38
39
40 void FormInset::disconnect()
41 {
42         ih_.disconnect();
43         FormBaseBD::disconnect();
44 }
45
46
47 void FormInset::updateSlot(bool switched)
48 {
49         if (switched)
50                 hide();
51         else
52                 update();
53 }
54
55
56 FormCommand::FormCommand(LyXView * lv, Dialogs * d, string const & t)
57         : FormInset(lv, d, t),
58           inset_(0)
59 {}
60
61
62 void FormCommand::disconnect()
63 {
64         inset_ = 0;
65         params = InsetCommandParams(string());
66         FormInset::disconnect();
67 }
68
69
70 void FormCommand::showInset(InsetCommand * inset)
71 {
72         if (inset == 0) return;  // maybe we should Assert this?
73
74         // If connected to another inset, disconnect from it.
75         if (inset_)
76                 ih_.disconnect();
77
78         inset_    = inset;
79         params    = inset->params();
80         ih_ = inset->hideDialog.connect(boost::bind(&FormCommand::hide, this));
81         show();
82 }
83
84
85 void FormCommand::createInset(string const & arg)
86 {
87         if (inset_) {
88                 ih_.disconnect();
89                 inset_ = 0;
90         }
91
92         params.setFromString(arg);
93         if ( !arg.empty())
94                 bc().valid(); // so that the user can press Ok
95         show();
96 }