]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/FormInset.C
More pref work from Angus
[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
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::updateSlot));
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 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                           ButtonPolicy * bp,
60                           char const * close, char const * cancel)
61         : FormInset( lv, d, t, bp, close, cancel ),
62           inset_(0)
63 {}
64
65
66 void FormCommand::disconnect()
67 {
68         inset_ = 0;
69         params = InsetCommandParams( string() );
70         FormInset::disconnect();
71 }
72
73        
74 void FormCommand::showInset( InsetCommand * inset )
75 {
76         if (inset == 0) return;  // maybe we should Assert this?
77
78         // If connected to another inset, disconnect from it.
79         if (inset_)
80                 ih_.disconnect();
81
82         inset_    = inset;
83         params    = inset->params();
84         ih_ = inset->hide.connect(slot(this, &FormCommand::hide));
85         show();
86 }
87
88
89 void FormCommand::createInset( string const & arg )
90 {
91         if (inset_) {
92                 ih_.disconnect();
93                 inset_ = 0;
94         }
95
96         params.setFromString( arg );
97         show();
98 }