]> git.lyx.org Git - features.git/blob - src/frontends/xforms/FormInset.C
743293f8648db454878e3d86328cc5898bd9543c
[features.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
21 #include "Dialogs.h"
22 #include "LyXView.h"
23 #include "FormInset.h"
24
25 FormInset::FormInset(LyXView * lv, Dialogs * d, string const & t,
26                      ButtonPolicy * bp,
27                      char const * close, char const * cancel)
28         : FormBaseBD( lv, d, t, bp, close, cancel ), ih_(0)
29 {}
30
31
32 void FormInset::connect()
33 {
34         u_ = d_->updateBufferDependent.
35                  connect(slot(this, &FormInset::update));
36         h_ = d_->hideBufferDependent.
37                  connect(slot(this, &FormInset::hide));
38         FormBase::connect();
39 }
40
41
42 void FormInset::disconnect()
43 {
44         ih_.disconnect();
45         FormBaseBD::disconnect();
46 }
47
48
49 FormCommand::FormCommand( LyXView * lv, Dialogs * d, string const & t,
50                           ButtonPolicy * bp,
51                           char const * close, char const * cancel)
52         : FormInset( lv, d, t, bp, close, cancel ),
53           inset_(0)
54 {}
55
56
57 void FormCommand::disconnect()
58 {
59         inset_ = 0;
60         params = InsetCommandParams( string() );
61         FormInset::disconnect();
62 }
63
64        
65 void FormCommand::showInset( InsetCommand * inset )
66 {
67         if (inset == 0) return;  // maybe we should Assert this?
68
69         // If connected to another inset, disconnect from it.
70         if (inset_)
71                 ih_.disconnect();
72
73         inset_    = inset;
74         params    = inset->params();
75         ih_ = inset->hide.connect(slot(this, &FormCommand::hide));
76         show();
77 }
78
79
80 void FormCommand::createInset( string const & arg )
81 {
82         if (inset_) {
83                 ih_.disconnect();
84                 inset_ = 0;
85         }
86
87         params.setFromString( arg );
88         show();
89 }