]> git.lyx.org Git - lyx.git/blob - src/frontends/controllers/ControlDialog.tmpl
This file is part of LyX, the document processor.
[lyx.git] / src / frontends / controllers / ControlDialog.tmpl
1 // -*- C++ -*-
2 /**
3  * \file ControlDialog.tmpl
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Angus Leeming 
8  *
9  * Full author contact details are available in file CREDITS
10  *
11  * ControlDialog is a base class and so these templatised methods will be
12  * instantiated if this file is #included in the derived classes' .C file.
13  */
14
15 #include "ControlDialog.h"
16
17 #include "ButtonControllerBase.h"
18 #include "ViewBase.h"
19
20
21 template <class Base>
22 ControlDialog<Base>::ControlDialog(LyXView & lv, Dialogs & d)
23         : Base(lv, d), dialog_built_(false)
24 {}
25
26
27 template <class Base>
28 void ControlDialog<Base>::show()
29 {
30         if (isBufferDependent() && !bufferIsAvailable())
31                 return;
32
33         connect();
34
35         setParams();
36         if (emergency_exit_) {
37                 hide();
38                 return;
39         }
40
41         if (!dialog_built_) {
42                 view().build();
43                 dialog_built_ = true;
44         }
45
46         bc().readOnly(bufferIsReadonly());
47         view().show();
48 }
49
50 template <class Base>
51 void ControlDialog<Base>::update()
52 {
53         if (isBufferDependent() && !bufferIsAvailable())
54                 return;
55
56         setParams();
57         if (emergency_exit_) {
58                 hide();
59                 return;
60         }
61
62         bc().readOnly(bufferIsReadonly());
63         view().update();
64 }
65
66 template <class Base>
67 void ControlDialog<Base>::hide()
68 {
69         emergency_exit_ = false;
70         clearParams();
71
72         disconnect();
73         view().hide();
74 }