// -*- 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 2000 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 "ControlBase.h"
-class ViewBase {
+class ViewBase : boost::noncopyable {
public:
- ///
- ViewBase(ControlBase & 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(); }
-
-protected:
- /// The view is, after all, controlled!
- ControlBase & controller_;
-};
+ /** 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) {}
+ /** This should be set by the GUI class that owns both the controller
+ * and the view
+ */
+ void setController(ControlButtons &);
-/** A generic class to cast the ButtonController controller_.bc_ to it's
- daughter class. */
-template <class GUIbc>
-class ViewBC : public ViewBase {
-public:
///
- ViewBC(ControlBase & c) : ViewBase(c) {}
+ 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:
- ///
- GUIbc & bc() const
- {
- return static_cast<GUIbc &>(controller_.bc());
- // return dynamic_cast<GUIbc &>(controller_.bc());
- }
+ /// We don't own this.
+ ControlButtons * controller_ptr_;
+
+private:
+ string title_;
+
};
#endif // VIEWBASE_H