]> git.lyx.org Git - lyx.git/blob - src/frontends/controllers/ControlDialogs.h
Controller-view split of Graphics and Index popups.
[lyx.git] / src / frontends / controllers / ControlDialogs.h
1 /* This file is part of
2  * ====================================================== 
3  *
4  *           LyX, The Document Processor
5  *
6  *           Copyright 2001 The LyX Team.
7  *
8  * ======================================================
9  *
10  * \file ControlDialogs.h
11  * \author Angus Leeming <a.leeming@ic.ac.uk>
12  *
13  * ControlDialog is to be used as a parent class for popups that are not
14  * Inset-popups. (An ugly description I know, but I hope the meaning is clear!
15  * Can anyone do any better?) Examples would be the Document and Paragraph
16  * popups.
17  */
18
19 #ifndef CONTROLDIALOGS_H
20 #define CONTROLDIALOGS_H
21
22 #include "ControlConnections.h"
23
24 /** Base class to control connection/disconnection of signals with the LyX
25     kernel for dialogs NOT used with insets.
26     The Base class will be either ControlConnectBI or ControlConnectBD.
27  */
28 template <class Base>
29 class ControlDialog : public Base
30 {
31 public:
32         ///
33         ControlDialog(LyXView &, Dialogs &);
34
35 protected:
36         /// Show the dialog.
37         virtual void show();
38         /// Hide the dialog.
39         virtual void hide();
40         /// Update the dialog.
41         virtual void update();
42
43         /// clean-up on hide.
44         virtual void clearParams() {}
45         /// set the params before show or update
46         virtual void setParams() {}
47 };
48
49
50 #include "LyXView.h"
51
52
53 template <class Base>
54 ControlDialog<Base>::ControlDialog(LyXView & lv, Dialogs & d)
55         : Base(lv, d)
56 {}
57
58
59 template <class Base>
60 void ControlDialog<Base>::show()
61 {
62         if (isBufferDependent() && !lv_.view()->available())
63                 return;
64
65         setParams();
66
67         bc().readOnly(isReadonly());
68         view().show();
69 }
70
71 template <class Base>
72 void ControlDialog<Base>::update()
73 {
74         if (isBufferDependent() && !lv_.view()->available())
75                 return;
76
77         setParams();
78         
79         bc().readOnly(isReadonly());
80         view().update();
81 }
82
83 template <class Base>
84 void ControlDialog<Base>::hide()
85 {
86         clearParams();
87
88         disconnect();
89         view().hide();
90 }
91
92 #endif // CONTROLDIALOGS_H