]> git.lyx.org Git - lyx.git/blob - src/frontends/Application.h
6f34a076778c4c76bedb7c94b5cf6ecdebce342c
[lyx.git] / src / frontends / Application.h
1 /**
2  * \file frontend/Application.h
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Abdelrazak Younes
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11 #ifndef LYX_APPLICATION_H
12 #define LYX_APPLICATION_H
13
14 #include <boost/function.hpp>
15
16 #include <string>
17
18 class BufferList;
19 class BufferView;
20 class LyXFunc;
21 class LyXServer;
22 class LyXServerSocket;
23 class LyXView;
24 class LColor_color;
25         
26 namespace lyx {
27
28 struct RGBColor;
29
30 namespace frontend {
31
32 struct Application_pimpl;
33 class Clipboard;
34 class FontLoader;
35 class Gui;
36 class Selection;
37
38 /// The main application class
39 /**
40 There should be only one instance of this class. No Qt object
41 initialisation should be done before the instanciation of this class.
42
43 \todo The work areas handling could be moved to a base virtual class
44 comon to all frontends.
45 */
46 class Application
47 {
48 public:
49         ///
50         Application(int & argc, char ** argv);
51         ///
52         virtual ~Application() {}
53
54         /// Start the main event loop, after executing the given batch
55         /// commands.
56         int start(std::string const & batch);
57         ///
58         virtual Gui & gui() = 0;
59         ///
60         virtual int const exec() = 0;
61
62         /// Quit running LyX.
63         /**
64         * This may either quit directly or record the exit status
65         * and only stop the event loop.
66         */
67         virtual void exit(int status) = 0;
68
69         /**
70         * Synchronise all pending events.
71         */
72         virtual void syncEvents() = 0;
73         ///
74         virtual Clipboard & clipboard() = 0;
75         ///
76         virtual Selection & selection() = 0;
77         ///
78         virtual FontLoader & fontLoader() = 0;
79
80         /// return a suitable serif font name.
81         virtual std::string const romanFontName() = 0;
82
83         /// return a suitable sans serif font name.
84         virtual std::string const sansFontName() = 0;
85
86         /// return a suitable monospaced font name.
87         virtual std::string const typewriterFontName() = 0;
88
89         /**
90         * Given col, fills r, g, b in the range 0-255.
91         * The function returns true if successful.
92         * It returns false on failure and sets r, g, b to 0.
93         */
94         virtual bool getRgbColor(LColor_color col, lyx::RGBColor & rgbcol) = 0;
95
96         /** Eg, passing LColor::black returns "000000",
97         *      passing LColor::white returns "ffffff".
98         */
99         virtual std::string const hexName(LColor_color col) = 0;
100
101         /**
102         * update an altered GUI color
103         */
104         virtual void updateColor(LColor_color col) = 0;
105
106         /**
107         * add a callback for socket read notification
108         * @param fd socket descriptor (file/socket/etc)
109         */
110         virtual void registerSocketCallback(
111                 int fd, boost::function<void()> func) = 0;
112
113         /**
114         * remove a I/O read callback
115         * @param fd socket descriptor (file/socket/etc)
116         */
117         virtual void unregisterSocketCallback(int fd) = 0;
118
119         ///
120         LyXFunc & lyxFunc();
121         LyXFunc const & lyxFunc() const;
122         ///
123         LyXServer & server();
124         LyXServer const & server() const;
125         ///
126         LyXServerSocket & socket();
127         LyXServerSocket const & socket() const;
128
129         /// Create the main window with given geometry settings.
130         LyXView & createView(unsigned int width, unsigned int height,
131                 int posx, int posy, bool maximize);
132         
133         ///
134         void setBufferView(BufferView * buffer_view);
135
136 protected:
137         /// This BufferView is the one receiving Clipboard and Selection
138         /// Events
139         /// FIXME: \todo use Gui::currentView() in the future
140         BufferView * buffer_view_;
141
142 private:
143         /// Application private implementation.
144         Application_pimpl * pimpl_;
145
146 }; // Application
147
148 } // namespace frontend
149
150 lyx::frontend::Application * createApplication(int & argc, char * argv[]);
151
152 } // namespace lyx
153
154 extern lyx::frontend::Application * theApp;
155
156
157 #endif // LYX_APPLICATION_H