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