]> git.lyx.org Git - lyx.git/blob - src/frontends/controllers/ViewBase.h
math-space; fixes to include inset dialog; autoconfiguration of gfx converters
[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
39         /** These shortcuts allow (e.g. xform's) global callback functions
40             access to the buttons without making the whole controller_ public.
41         */
42         ///
43         void ApplyButton() { controller_.ApplyButton(); }
44         ///
45         void OKButton() { controller_.OKButton(); }
46         ///
47         void CancelButton() { controller_.CancelButton(); }
48         ///
49         void RestoreButton() { controller_.RestoreButton(); }
50         
51         /** Defaults to nothing. Can be used by the Controller, however, to
52             indicate to the View that something has changed and that the
53             dialog therefore needs updating. */
54         virtual void partialUpdate(int) {}
55    
56 protected:
57         /// The view is, after all, controlled!
58         ControlButtons & controller_;
59 };
60
61
62 class ViewSplash {
63 public:
64         /// 
65         ViewSplash(ControlSplash & c) : controller_(c) {}
66         /// 
67         virtual ~ViewSplash() {}
68
69         /// Hide the dialog.
70         virtual void hide() = 0;
71         /// Create the dialog and show it.
72         virtual void show() = 0;
73
74         /** The shortcut allows (e.g. xform's) global callback functions
75             access without making the whole controller_ public.
76         */
77         ///
78         void Hide() { controller_.hide(); }
79
80 protected:
81         /// The view is, after all, controlled!
82         ControlSplash & controller_;
83 };
84
85
86 /** A generic class to cast the ButtonController controller_.bc_ to it's
87     daughter class. */
88 template <class GUIbc>
89 class ViewBC : public ViewBase {
90 public:
91         ///
92         ViewBC(ControlButtons & c) : ViewBase(c) {}
93
94 protected:
95         ///
96         GUIbc & bc() const
97         {
98                 return static_cast<GUIbc &>(controller_.bc());
99                 // return dynamic_cast<GUIbc &>(controller_.bc());
100         }
101 };
102
103 #endif // VIEWBASE_H