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