]> git.lyx.org Git - lyx.git/blob - src/frontends/Application.h
Document pasteParagraphList as hinted by Jean-Marc
[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 namespace lyx {
19
20 class BufferView;
21 class LyXView;
22 class LColor_color;
23 struct RGBColor;
24
25 namespace frontend {
26
27 class Clipboard;
28 class FontLoader;
29 class Gui;
30 class Selection;
31
32 /// The main application class
33 /**
34 There should be only one instance of this class. No Qt object
35 initialisation should be done before the instanciation of this class.
36
37 \todo The work areas handling could be moved to a base virtual class
38 common to all frontends.
39 */
40 class Application
41 {
42 public:
43         ///
44         Application(int & argc, char ** argv);
45         ///
46         virtual ~Application() {}
47
48         /// Start the main event loop, after executing the given batch
49         /// commands.
50         int start(std::string const & batch);
51         ///
52         virtual Gui & gui() = 0;
53         ///
54         virtual int const exec() = 0;
55
56         /// Quit running LyX.
57         /**
58         * This may either quit directly or record the exit status
59         * and only stop the event loop.
60         */
61         virtual void exit(int status) = 0;
62
63         /**
64         * Synchronise all pending events.
65         */
66         virtual void syncEvents() = 0;
67         ///
68         virtual Clipboard & clipboard() = 0;
69         ///
70         virtual Selection & selection() = 0;
71         ///
72         virtual FontLoader & fontLoader() = 0;
73
74         /// return a suitable serif font name.
75         virtual std::string const romanFontName() = 0;
76
77         /// return a suitable sans serif font name.
78         virtual std::string const sansFontName() = 0;
79
80         /// return a suitable monospaced font name.
81         virtual std::string const typewriterFontName() = 0;
82
83         /**
84         * Given col, fills r, g, b in the range 0-255.
85         * The function returns true if successful.
86         * It returns false on failure and sets r, g, b to 0.
87         */
88         virtual bool getRgbColor(LColor_color col, RGBColor & rgbcol) = 0;
89
90         /** Eg, passing LColor::black returns "000000",
91         *      passing LColor::white returns "ffffff".
92         */
93         virtual std::string const hexName(LColor_color col) = 0;
94
95         /**
96         * update an altered GUI color
97         */
98         virtual void updateColor(LColor_color col) = 0;
99
100         /**
101         * add a callback for socket read notification
102         * @param fd socket descriptor (file/socket/etc)
103         */
104         virtual void registerSocketCallback(
105                 int fd, boost::function<void()> func) = 0;
106
107         /**
108         * remove a I/O read callback
109         * @param fd socket descriptor (file/socket/etc)
110         */
111         virtual void unregisterSocketCallback(int fd) = 0;
112
113         /// Create the main window with given geometry settings.
114         LyXView & createView(unsigned int width, unsigned int height,
115                 int posx, int posy, bool maximize);
116         
117         /// 
118         LyXView const & currentView() const;
119
120         /// 
121         LyXView & currentView();
122
123         ///
124         void setCurrentView(LyXView & current_view);
125
126 private:
127         /// This LyXView is the one receiving Clipboard and Selection
128         /// Events
129         LyXView * current_view_;
130
131 }; // Application
132
133 } // namespace frontend
134
135 extern frontend::Application * theApp;
136 frontend::Application * createApplication(int & argc, char * argv[]);
137
138
139 } // namespace lyx
140
141
142 #endif // LYX_APPLICATION_H