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