]> git.lyx.org Git - lyx.git/blob - src/frontends/controllers/ControlDialog.tmpl
Rob's patch, part 1: the checked widget stuff.
[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         // The widgets may not be valid, so refresh the button controller
50         bc().refresh();
51 }
52
53 template <class Base>
54 void ControlDialog<Base>::update()
55 {
56         if (isBufferDependent() && !bufferIsAvailable())
57                 return;
58
59         setParams();
60         if (emergency_exit_) {
61                 hide();
62                 return;
63         }
64
65         bc().readOnly(bufferIsReadonly());
66         view().update();
67
68         // The widgets may not be valid, so refresh the button controller
69         bc().refresh();
70 }
71
72 template <class Base>
73 void ControlDialog<Base>::hide()
74 {
75         emergency_exit_ = false;
76         clearParams();
77
78         disconnect();
79         view().hide();
80 }