]> git.lyx.org Git - lyx.git/blob - src/frontends/controllers/ControlDialogs.h
more latex conversion cases fixed, patch from Andre, more more funcs to lowercase...
[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
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