]> git.lyx.org Git - lyx.git/blob - src/frontends/controllers/ViewBase.h
Move the external dialog to the new scheme.
[lyx.git] / src / frontends / controllers / ViewBase.h
1 // -*- C++ -*-
2 /**
3  * \file ViewBase.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Angus Leeming
8  *
9  * Full author contact details are available in file CREDITS
10  */
11
12 #ifndef VIEWBASE_H
13 #define VIEWBASE_H
14
15 #include "support/LAssert.h"
16
17 #include <boost/utility.hpp>
18
19 class ControlButtons;
20
21
22 class ViewBase : boost::noncopyable {
23 public:
24         ///
25         ViewBase() : controller_ptr_(0) {}
26         ///
27         virtual ~ViewBase() {}
28
29         /// Apply changes to LyX data from dialog.
30         virtual void apply() = 0;
31         /// build the dialog
32         virtual void build() = 0;
33         /// Hide the dialog.
34         virtual void hide() = 0;
35         /// Redraw the dialog (e.g. if the colors have been remapped).
36         virtual void redraw() {}
37         /// Create the dialog if necessary, update it and display it.
38         virtual void show() = 0;
39         /// Update dialog before/whilst showing it.
40         virtual void update() = 0;
41         ///
42         virtual bool isVisible() const = 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                 lyx::Assert(controller_ptr_);
58                 return *controller_ptr_;
59         }
60         ///
61         ControlButtons const & getController() const {
62                 lyx::Assert(controller_ptr_);
63                 return *controller_ptr_;
64         }
65 protected:
66         /// We don't own this.
67         ControlButtons * controller_ptr_;
68 };
69
70
71 #endif // VIEWBASE_H