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"
19 #include "ControlSplash.h"
24 ViewBase(ControlButtons & c) : controller_(c) {}
26 virtual ~ViewBase() {}
28 /// Apply changes to LyX data from dialog.
29 virtual void apply() = 0;
31 virtual void hide() = 0;
32 /// Redraw the dialog (e.g. if the colors have been remapped).
33 virtual void redraw() {}
34 /// Create the dialog if necessary, update it and display it.
35 virtual void show() = 0;
36 /// Update dialog before/whilst showing it.
37 virtual void update() = 0;
39 /** These shortcuts allow (e.g. xform's) global callback functions
40 access to the buttons without making the whole controller_ public.
43 void ApplyButton() { controller_.ApplyButton(); }
45 void OKButton() { controller_.OKButton(); }
47 void CancelButton() { controller_.CancelButton(); }
49 void RestoreButton() { controller_.RestoreButton(); }
51 /** Defaults to nothing. Can be used by the Controller, however, to
52 indicate to the View that something has changed and that the
53 dialog therefore needs updating. */
54 virtual void partialUpdate(int) {}
57 /// The view is, after all, controlled!
58 ControlButtons & controller_;
65 ViewSplash(ControlSplash & c) : controller_(c) {}
67 virtual ~ViewSplash() {}
70 virtual void hide() = 0;
71 /// Create the dialog and show it.
72 virtual void show() = 0;
74 /** The shortcut allows (e.g. xform's) global callback functions
75 access without making the whole controller_ public.
78 void Hide() { controller_.hide(); }
81 /// The view is, after all, controlled!
82 ControlSplash & controller_;
86 /** A generic class to cast the ButtonController controller_.bc_ to it's
88 template <class GUIbc>
89 class ViewBC : public ViewBase {
92 ViewBC(ControlButtons & c) : ViewBase(c) {}
98 return static_cast<GUIbc &>(controller_.bc());
99 // return dynamic_cast<GUIbc &>(controller_.bc());