]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/FormInset.C
iThe cursor now behaves properly in the dialogs...
[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 "LyXView.h"
19 #include "FormInset.h"
20 #include "xformsBC.h"
21
22 using SigC::slot;
23
24 FormInset::FormInset(LyXView * lv, Dialogs * d, string const & t)
25         : FormBaseBD(lv, d, t), ih_(0)
26 {}
27
28
29 void FormInset::connect()
30 {
31         u_ = d_->updateBufferDependent.
32                  connect(slot(this, &FormInset::updateSlot));
33         h_ = d_->hideBufferDependent.
34                  connect(slot(this, &FormInset::hide));
35         FormBaseDeprecated::connect();
36 }
37
38
39 void FormInset::disconnect()
40 {
41         ih_.disconnect();
42         FormBaseBD::disconnect();
43 }
44
45
46 void FormInset::updateSlot(bool switched)
47 {
48         if (switched)
49                 hide();
50         else
51                 update();
52 }
53
54
55 FormCommand::FormCommand(LyXView * lv, Dialogs * d, string const & t)
56         : FormInset(lv, d, t),
57           inset_(0)
58 {}
59
60
61 void FormCommand::disconnect()
62 {
63         inset_ = 0;
64         params = InsetCommandParams(string());
65         FormInset::disconnect();
66 }
67
68        
69 void FormCommand::showInset(InsetCommand * inset)
70 {
71         if (inset == 0) return;  // maybe we should Assert this?
72
73         // If connected to another inset, disconnect from it.
74         if (inset_)
75                 ih_.disconnect();
76
77         inset_    = inset;
78         params    = inset->params();
79         ih_ = inset->hideDialog.connect(slot(this, &FormCommand::hide));
80         show();
81 }
82
83
84 void FormCommand::createInset(string const & arg)
85 {
86         if (inset_) {
87                 ih_.disconnect();
88                 inset_ = 0;
89         }
90
91         params.setFromString(arg);
92         if ( !arg.empty())
93                 bc().valid(); // so that the user can press Ok
94         show();
95 }