]> git.lyx.org Git - features.git/blob - src/frontends/kde/KFormBase.h
7a55b50826d88babb2a1bec8371b5f7d3e0f5102
[features.git] / src / frontends / kde / KFormBase.h
1 /**
2  * \file KDEFormBase.h
3  * Copyright 2001 the LyX Team
4  * Read the file COPYING
5  *
6  * \author John Levon
7  */
8
9 #ifndef KDEFORMBASE_H
10 #define KDEFORMBASE_H
11
12 #ifdef __GNUG__
13 #pragma interface
14 #endif
15
16 #include "boost/smart_ptr.hpp"
17  
18 #include "ViewBase.h"
19 #include "ButtonPolicies.h"
20 #include "kdeBC.h"
21
22 class QWidget;
23  
24 class KFormDialogBase : public ViewBC<kdeBC> {
25 public:
26         ///
27         KFormDialogBase(ControlButton & c);
28
29         // Functions accessible to the Controller
30
31         /// build dialog
32         virtual void build() = 0;
33         /// create dialog if necessary, update and display
34         void show();
35         /// hide dialog
36         virtual void hide();
37
38 private:
39         /// get dialog
40         virtual QWidget * dialog() const = 0;
41 };
42
43 template <class Controller, class Dialog>
44         class KFormBase : public KFormDialogBase {
45 public:
46         ///
47         KFormBase(ControlButton & c);
48  
49 protected:
50         /// parent controller 
51         Controller & controller() const;
52
53         /// get dialog 
54         virtual QWidget * dialog() const { return dialog_.get(); };
55  
56         /// dialog implemenation 
57         boost::scoped_ptr<Dialog> dialog_; 
58 };
59
60 template <class Controller, class Dialog>
61         KFormBase<Controller, Dialog>::KFormBase(ControlButton & c) 
62         : KFormDialogBase(c)
63 {
64 }
65
66
67 template <class Controller, class Dialog>
68         Controller & KFormBase<Controller, Dialog>::controller() const
69 {
70         return static_cast<Controller &>(controller_);
71 }
72  
73  
74 #endif // KDEFORMBASE_H