]> git.lyx.org Git - lyx.git/blob - src/frontends/controllers/Kernel.h
some support for pch
[lyx.git] / src / frontends / controllers / Kernel.h
1 // -*- C++ -*-
2 /**
3  * \file Kernel.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Angus Leeming
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #ifndef KERNEL_H
13 #define KERNEL_H
14
15 #include <string>
16
17 class Buffer;
18 class BufferView;
19 class FuncRequest;
20 class LyXView;
21
22 namespace lyx {
23 namespace frontend {
24
25 /** \c Kernel is a wrapper making the LyX kernel available to the dialog.
26  * (Ie, it provides an interface to the Model part of the Model-Controller-
27  *  View split.
28  *  In an ideal world, it will shrink as more info is passed to the
29  *  Dialog::show() and Dialog::update() methods.
30  */
31 class Kernel {
32 public:
33         /// \param lv is the access point for the dialog to the LyX kernel.
34         Kernel(LyXView & lv);
35
36         /** This method is the primary puypose of the class. It provides
37          *  the "gateway" by which the dialog can send a request (of a
38          *  change in the data, for more information) to the kernel.
39          *  \param fr is the encoding of the request.
40          *  \param verbose is set to true if the completed action should
41          *  be displayed in the minibuffer.
42          */
43         void dispatch(FuncRequest const & fr, bool verbose = false) const;
44
45         /** The dialog has received a request from the user
46          *  (who pressed the "Restore" buuton) to update contents.
47          *  It must, therefore, ask the kernel to provide this information.
48          *  \param name is used to identify the dialog to the kernel.
49          */
50         void updateDialog(std::string const & name) const;
51
52         /** A request from the Controller that future changes to the data
53          *  stored by the dialog are not applied to the inset currently
54          *  connected to the dialog. Instead, they will be used to generate
55          *  a new inset at the cursor position.
56          *  \param name is used to identify the dialog to the kernel.
57          */
58         void disconnect(std::string const & name) const;
59
60         /** \name Kernel Wrappers
61          *  Simple wrapper functions to Buffer methods.
62          */
63         //@{
64         bool isBufferAvailable() const;
65         bool isBufferReadonly() const;
66         std::string const bufferFilepath() const;
67         //@}
68
69         /** \enum DocTypes used to flag the different kinds of buffer
70          *  without making the kernel header files available to the
71          *  dialog's Controller or View.
72          */
73         enum DocTypes {
74                 LATEX,
75                 LITERATE,
76                 LINUXDOC,
77                 DOCBOOK
78         };
79         /// The type of the current buffer.
80         DocTypes docType() const;
81
82         /** A request that the GUI be redrawn,
83          *  e.g. because the colors have been remapped.
84          */
85         void redrawGUI() const;
86
87         /** \name Kernel Nasties
88          *  Unpleasantly public internals of the LyX kernel.
89          *  We should aim to reduce/remove these from the interface.
90          */
91         //@{
92         LyXView & lyxview() { return lyxview_; }
93         LyXView const & lyxview() const { return lyxview_; }
94
95         Buffer & buffer();
96         Buffer const & buffer() const;
97
98         BufferView * bufferview();
99         BufferView const * bufferview() const;
100         //@}
101
102 private:
103         LyXView & lyxview_;
104 };
105
106 } // namespace frontend
107 } // namespace lyx
108
109 #endif // KERNEL_H