]> git.lyx.org Git - features.git/blob - src/frontends/controllers/ViewBase.h
Nothing but a changed email address (trying to factor my tree in in small steps)
[features.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 <leeming@lyx.org>
12  */
13
14 #ifndef VIEWBASE_H
15 #define VIEWBASE_H
16
17 #include "support/LAssert.h"
18
19 #include <boost/utility.hpp>
20
21 class ControlButtons;
22
23
24 class ViewBase : boost::noncopyable {
25 public:
26         ///
27         ViewBase() : controller_ptr_(0) {}
28         ///
29         virtual ~ViewBase() {}
30
31         /// Apply changes to LyX data from dialog.
32         virtual void apply() = 0;
33         /// build the dialog
34         virtual void build() = 0;
35         /// Hide the dialog.
36         virtual void hide() = 0;
37         /// Redraw the dialog (e.g. if the colors have been remapped).
38         virtual void redraw() {}
39         /// Create the dialog if necessary, update it and display it.
40         virtual void show() = 0;
41         /// Update dialog before/whilst showing it.
42         virtual void update() = 0;
43
44         /** Defaults to nothing. Can be used by the controller, however, to
45          *  indicate to the view that something has changed and that the
46          *  dialog therefore needs updating.
47          */
48         virtual void partialUpdate(int) {}
49
50         /** This should be set by the GUI class that owns both the controller
51          *  and the view
52          */
53         void setController(ControlButtons & c) { controller_ptr_ = &c; }
54         
55         ///
56         ControlButtons & getController()
57         {
58                 lyx::Assert(controller_ptr_);
59                 return *controller_ptr_;
60         }
61         ///
62         ControlButtons const & getController() const
63         {
64                 lyx::Assert(controller_ptr_);
65                 return *controller_ptr_;
66         }
67
68 protected:
69         /// We don't own this.
70         ControlButtons * controller_ptr_;
71 };
72
73
74 #endif // VIEWBASE_H