]> git.lyx.org Git - lyx.git/blob - src/frontends/controllers/Kernel.h
Make the Qt Alert boxes recognize their parent.
[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 purpose 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          */
41         void dispatch(FuncRequest const & fr) const;
42
43         /** The dialog has received a request from the user
44          *  (who pressed the "Restore" button) to update contents.
45          *  It must, therefore, ask the kernel to provide this information.
46          *  \param name is used to identify the dialog to the kernel.
47          */
48         void updateDialog(std::string const & name) const;
49
50         /** A request from the Controller that future changes to the data
51          *  stored by the dialog are not applied to the inset currently
52          *  connected to the dialog. Instead, they will be used to generate
53          *  a new inset at the cursor position.
54          *  \param name is used to identify the dialog to the kernel.
55          */
56         void disconnect(std::string const & name) const;
57
58         /** \name Kernel Wrappers
59          *  Simple wrapper functions to Buffer methods.
60          */
61         //@{
62         bool isBufferAvailable() const;
63         bool isBufferReadonly() const;
64         std::string const bufferFilepath() const;
65         //@}
66
67         /** \enum DocType 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 DocType {
72                 LATEX,
73                 LITERATE,
74                 LINUXDOC,
75                 DOCBOOK
76         };
77         /// The type of the current buffer.
78         DocType docType() const;
79
80         /** A request that the GUI be redrawn,
81          *  e.g. because the colors have been remapped.
82          */
83         void redrawGUI() const;
84
85         /** \name Kernel Nasties
86          *  Unpleasantly public internals of the LyX kernel.
87          *  We should aim to reduce/remove these from the interface.
88          */
89         //@{
90         LyXView & lyxview() { return lyxview_; }
91         LyXView const & lyxview() const { return lyxview_; }
92
93         Buffer & buffer();
94         Buffer const & buffer() const;
95
96         BufferView * bufferview();
97         BufferView const * bufferview() const;
98         //@}
99
100 private:
101         LyXView & lyxview_;
102 };
103
104
105 /** \c KernelDocType is a wrapper for Kernel::DocType.
106  *  It can be forward-declared and passed as a function argument without
107  *  having to expose Kernel.h.
108  */
109 class KernelDocType {
110 public:
111         KernelDocType(Kernel::DocType val) : val_(val) {}
112         operator Kernel::DocType() const { return val_; }
113 private:
114         Kernel::DocType val_;
115 };
116
117 } // namespace frontend
118 } // namespace lyx
119
120 #endif // KERNEL_H