]> git.lyx.org Git - lyx.git/blob - src/frontends/controllers/ViewBase.h
small changes read changelog
[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 protected:
52         /// The view is, after all, controlled!
53         ControlButtons & controller_;
54 };
55
56
57 class ViewSplash {
58 public:
59         /// 
60         ViewSplash(ControlSplash & c) : controller_(c) {}
61         /// 
62         virtual ~ViewSplash() {}
63
64         /// Hide the dialog.
65         virtual void hide() = 0;
66         /// Create the dialog and show it.
67         virtual void show() = 0;
68
69         /** The shortcut allows (e.g. xform's) global callback functions
70             access without making the whole controller_ public.
71         */
72         ///
73         void Hide() { controller_.hide(); }
74
75 protected:
76         /// The view is, after all, controlled!
77         ControlSplash & controller_;
78 };
79
80
81 /** A generic class to cast the ButtonController controller_.bc_ to it's
82     daughter class. */
83 template <class GUIbc>
84 class ViewBC : public ViewBase {
85 public:
86         ///
87         ViewBC(ControlButtons & c) : ViewBase(c) {}
88
89 protected:
90         ///
91         GUIbc & bc() const
92         {
93                 return static_cast<GUIbc &>(controller_.bc());
94                 // return dynamic_cast<GUIbc &>(controller_.bc());
95         }
96 };
97
98 #endif // VIEWBASE_H