2 /* This file is part of
3 * ======================================================
5 * LyX, The Document Processor
7 * Copyright 2001 The LyX Team.
9 * ======================================================
11 * Author: Angus Leeming <a.leeming@ic.ac.uk>
17 #include <boost/utility.hpp>
18 #include "ControlButtons.h"
23 ViewBase(ControlButtons & c) : controller_(c) {}
25 virtual ~ViewBase() {}
27 /// Apply changes to LyX data from dialog.
28 virtual void apply() = 0;
30 virtual void hide() = 0;
31 /// Redraw the dialog (e.g. if the colors have been remapped).
32 virtual void redraw() {}
33 /// Create the dialog if necessary, update it and display it.
34 virtual void show() = 0;
35 /// Update dialog before/whilst showing it.
36 virtual void update() = 0;
38 virtual void build() = 0;
40 /** These shortcuts allow (e.g. xform's) global callback functions
41 access to the buttons without making the whole controller_ public.
44 void ApplyButton() { controller_.ApplyButton(); }
46 void OKButton() { controller_.OKButton(); }
48 void CancelButton() { controller_.CancelButton(); }
50 void RestoreButton() { controller_.RestoreButton(); }
52 /** Defaults to nothing. Can be used by the Controller, however, to
53 indicate to the View that something has changed and that the
54 dialog therefore needs updating. */
55 virtual void partialUpdate(int) {}
58 /// The view is, after all, controlled!
59 ControlButtons & controller_;
63 /** A generic class to cast the ButtonController controller_.bc_ to it's
65 template <class GUIbc>
66 class ViewBC : public ViewBase {
69 ViewBC(ControlButtons & c) : ViewBase(c) {}
75 return static_cast<GUIbc &>(controller_.bc());
76 // return dynamic_cast<GUIbc &>(controller_.bc());