2 /* This file is part of
3 * ======================================================
5 * LyX, The Document Processor
7 * Copyright 2000 The LyX Team.
9 * ======================================================
11 * Author: Angus Leeming <a.leeming@ic.ac.uk>
17 #include <boost/utility.hpp>
18 #include "ControlBase.h"
23 ViewBase(ControlBase & 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 /** These shortcuts allow (e.g. xform's) global callback functions
39 access to the buttons without making the whole controller_ public.
42 void ApplyButton() { controller_.ApplyButton(); }
44 void OKButton() { controller_.OKButton(); }
46 void CancelButton() { controller_.CancelButton(); }
48 void RestoreButton() { controller_.RestoreButton(); }
51 /// The view is, after all, controlled!
52 ControlBase & controller_;
56 /** A generic class to cast the ButtonController controller_.bc_ to it's
58 template <class GUIbc>
59 class ViewBC : public ViewBase {
62 ViewBC(ControlBase & c) : ViewBase(c) {}
66 return static_cast<GUIbc &>(controller_.bc());
67 // return dynamic_cast<GUIbc &>(controller_.bc());