]> git.lyx.org Git - features.git/blob - src/frontends/controllers/ViewBase.h
No longer pass Controller & or Dialogs & to the View c-tors.
[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 <a.leeming@ic.ac.uk>
12  */
13
14 #ifndef VIEWBASE_H
15 #define VIEWBASE_H
16
17 #include "support/LAssert.h"
18
19 class ControlButtons;
20
21
22 class ViewBase {
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         /** Defaults to nothing. Can be used by the controller, however, to
43          *  indicate to the view that something has changed and that the
44          *  dialog therefore needs updating.
45          */
46         virtual void partialUpdate(int) {}
47
48         /** This should be set by the GUI class that owns both the controller
49          *  and the view
50          */
51         void setController(ControlButtons & c) { controller_ptr_ = &c; }
52         
53         ///
54         ControlButtons & getController()
55         {
56                 lyx::Assert(controller_ptr_);
57                 return *controller_ptr_;
58         }
59         ///
60         ControlButtons const & getController() const
61         {
62                 lyx::Assert(controller_ptr_);
63                 return *controller_ptr_;
64         }
65
66 protected:
67         /// We don't own this.
68         ControlButtons * controller_ptr_;
69 };
70
71
72 #endif // VIEWBASE_H