// -*- C++ -*-
-/* This file is part of
- * ======================================================
+/**
+ * \file ViewBase.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
*
- * LyX, The Document Processor
+ * \author Angus Leeming
*
- * Copyright 2001 The LyX Team.
- *
- * ======================================================
- *
- * Author: Angus Leeming <a.leeming@ic.ac.uk>
+ * Full author contact details are available in file CREDITS.
*/
#ifndef VIEWBASE_H
#define VIEWBASE_H
+class ControlButtons;
+class ButtonController;
+
+#include "support/std_string.h"
+
#include <boost/utility.hpp>
-#include "ControlButtons.h"
-#include "ControlSplash.h"
-class ViewBase {
+class ViewBase : boost::noncopyable {
public:
- ///
- ViewBase(ControlButtons & c) : controller_(c) {}
- ///
+ ///
+ ViewBase(string const &);
+ ///
virtual ~ViewBase() {}
/// Apply changes to LyX data from dialog.
virtual void apply() = 0;
+ /// build the dialog
+ virtual void build() = 0;
/// Hide the dialog.
virtual void hide() = 0;
/// Redraw the dialog (e.g. if the colors have been remapped).
virtual void show() = 0;
/// Update dialog before/whilst showing it.
virtual void update() = 0;
+ ///
+ virtual bool isVisible() const = 0;
- /** These shortcuts allow (e.g. xform's) global callback functions
- access to the buttons without making the whole controller_ public.
- */
- ///
- void ApplyButton() { controller_.ApplyButton(); }
- ///
- void OKButton() { controller_.OKButton(); }
- ///
- void CancelButton() { controller_.CancelButton(); }
- ///
- void RestoreButton() { controller_.RestoreButton(); }
-
- /** Defaults to nothing. Can be used by the Controller, however, to
- indicate to the View that something has changed and that the
- dialog therefore needs updating. */
- virtual void partialUpdate(int id) {}
-
-protected:
- /// The view is, after all, controlled!
- ControlButtons & controller_;
-};
-
-
-class ViewSplash {
-public:
- ///
- ViewSplash(ControlSplash & c) : controller_(c) {}
- ///
- virtual ~ViewSplash() {}
+ /** Defaults to nothing. Can be used by the controller, however, to
+ * indicate to the view that something has changed and that the
+ * dialog therefore needs updating.
+ */
+ virtual void partialUpdate(int) {}
- /// Hide the dialog.
- virtual void hide() = 0;
- /// Create the dialog and show it.
- virtual void show() = 0;
+ /** This should be set by the GUI class that owns both the controller
+ * and the view
+ */
+ void setController(ControlButtons &);
- /** The shortcut allows (e.g. xform's) global callback functions
- access without making the whole controller_ public.
- */
- ///
- void Hide() { controller_.hide(); }
+ ///
+ ControlButtons & getController();
+ ///
+ ControlButtons const & getController() const;
+ ///
+ ButtonController & bc();
+ /// sets the title of the dialog (window caption)
+ void setTitle(string const &);
+ /// gets the title of the dialog
+ string const & getTitle() const;
protected:
- /// The view is, after all, controlled!
- ControlSplash & controller_;
-};
-
+ /// We don't own this.
+ ControlButtons * controller_ptr_;
-/** A generic class to cast the ButtonController controller_.bc_ to it's
- daughter class. */
-template <class GUIbc>
-class ViewBC : public ViewBase {
-public:
- ///
- ViewBC(ControlButtons & c) : ViewBase(c) {}
+private:
+ string title_;
-protected:
- ///
- GUIbc & bc() const
- {
- return static_cast<GUIbc &>(controller_.bc());
- // return dynamic_cast<GUIbc &>(controller_.bc());
- }
};
#endif // VIEWBASE_H