]> git.lyx.org Git - lyx.git/blob - src/frontends/controllers/ViewBase.h
The reference dialog now disconnects from the inset on Apply. Its behaviour
[lyx.git] / src / frontends / controllers / ViewBase.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  * Author: Angus Leeming <a.leeming@ic.ac.uk>
12  */
13
14 #ifndef VIEWBASE_H
15 #define VIEWBASE_H
16
17 #include <boost/utility.hpp>
18 #include "ControlButtons.h"
19 #include "ControlSplash.h"
20
21 class ViewBase {
22 public:
23         /// 
24         ViewBase(ControlButtons & c) : controller_(c) {}
25         /// 
26         virtual ~ViewBase() {}
27
28         /// Apply changes to LyX data from dialog.
29         virtual void apply() = 0;
30         /// Hide the dialog.
31         virtual void hide() = 0;
32         /// Redraw the dialog (e.g. if the colors have been remapped).
33         virtual void redraw() {}
34         /// Create the dialog if necessary, update it and display it.
35         virtual void show() = 0;
36         /// Update dialog before/whilst showing it.
37         virtual void update() = 0;
38         /// build the dialog
39         virtual void build() = 0;
40
41         /** These shortcuts allow (e.g. xform's) global callback functions
42             access to the buttons without making the whole controller_ public.
43         */
44         ///
45         void ApplyButton() { controller_.ApplyButton(); }
46         ///
47         void OKButton() { controller_.OKButton(); }
48         ///
49         void CancelButton() { controller_.CancelButton(); }
50         ///
51         void RestoreButton() { controller_.RestoreButton(); }
52         
53         /** Defaults to nothing. Can be used by the Controller, however, to
54             indicate to the View that something has changed and that the
55             dialog therefore needs updating. */
56         virtual void partialUpdate(int) {}
57    
58 protected:
59         /// The view is, after all, controlled!
60         ControlButtons & controller_;
61 };
62
63
64 class ViewSplash {
65 public:
66         /// 
67         ViewSplash(ControlSplash & c) : controller_(c) {}
68         /// 
69         virtual ~ViewSplash() {}
70
71         /// Hide the dialog.
72         virtual void hide() = 0;
73         /// Create the dialog and show it.
74         virtual void show() = 0;
75
76         /** The shortcut allows (e.g. xform's) global callback functions
77             access without making the whole controller_ public.
78         */
79         ///
80         void Hide() { controller_.hide(); }
81
82 protected:
83         /// The view is, after all, controlled!
84         ControlSplash & controller_;
85 };
86
87
88 /** A generic class to cast the ButtonController controller_.bc_ to it's
89     daughter class. */
90 template <class GUIbc>
91 class ViewBC : public ViewBase {
92 public:
93         ///
94         ViewBC(ControlButtons & c) : ViewBase(c) {}
95
96 protected:
97         ///
98         GUIbc & bc() const
99         {
100                 return static_cast<GUIbc &>(controller_.bc());
101                 // return dynamic_cast<GUIbc &>(controller_.bc());
102         }
103 };
104
105 #endif // VIEWBASE_H