]> git.lyx.org Git - lyx.git/blob - src/frontends/controllers/Kernel.h
namespace grfx -> lyx::graphics
[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
16 #include "LString.h"
17
18
19 class Buffer;
20 class BufferView;
21 class FuncRequest;
22 class LyXView;
23
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 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 prupose 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             encoded as \param fr.
40             \param verbose 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 as an identifier by the kernel
49             when the information is posted.
50          */
51         void updateDialog(string const & name) const;
52
53         /** A request from the Controller that future changes to the data
54          *  stored by the dialog are not applied to the inset currently
55          *  connected to the dialog. Instead, they will be used to generate
56          *  a new inset at the cursor position.
57          */
58         void disconnect(string const & name) const;
59
60         //@{
61         /// Simple wrapper functions to Buffer methods.
62         bool isBufferAvailable() const;
63         bool isBufferReadonly() const;
64         //@}
65
66         //@{
67         /** \enum DocTypes is used to flag the different kinds of buffer
68          *  without making the kernel header files available to the
69          *  dialog's Controller or View.
70          */
71         enum DocTypes {
72                 LATEX,
73                 LITERATE,
74                 LINUXDOC,
75                 DOCBOOK
76         };
77         /// The type of the current buffer.
78         DocTypes docType() const;
79         //@}
80
81
82         //@{
83         /** Unpleasantly public internals of the LyX kernel.
84          *  We should aim to reduce/remove these from the interface.
85          */
86         LyXView & lyxview() { return lyxview_; }
87         LyXView const & lyxview() const { return lyxview_; }
88
89         Buffer * buffer();
90         Buffer const * buffer() const;
91
92         BufferView * bufferview();
93         BufferView const * bufferview() const;
94         //@}
95
96 private:
97         LyXView & lyxview_;
98 };
99
100
101 #endif // KERNEL_H