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