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.
6 * \author Abdelrazak Younes
8 * Full author contact details are available in file CREDITS.
11 #ifndef LYX_APPLICATION_H
12 #define LYX_APPLICATION_H
14 #include <boost/function.hpp>
22 class LyXServerSocket;
32 struct Application_pimpl;
38 /// The main application class
40 There should be only one instance of this class. No Qt object
41 initialisation should be done before the instanciation of this class.
43 \todo The work areas handling could be moved to a base virtual class
44 comon to all frontends.
50 Application(int & argc, char ** argv);
52 virtual ~Application() {}
54 /// Start the main event loop, after executing the given batch
56 int start(std::string const & batch);
58 virtual Gui & gui() = 0;
60 virtual int const exec() = 0;
64 * This may either quit directly or record the exit status
65 * and only stop the event loop.
67 virtual void exit(int status) = 0;
70 * Synchronise all pending events.
72 virtual void syncEvents() = 0;
74 virtual Clipboard & clipboard() = 0;
76 virtual Selection & selection() = 0;
78 virtual FontLoader & fontLoader() = 0;
80 /// return a suitable serif font name.
81 virtual std::string const romanFontName() = 0;
83 /// return a suitable sans serif font name.
84 virtual std::string const sansFontName() = 0;
86 /// return a suitable monospaced font name.
87 virtual std::string const typewriterFontName() = 0;
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.
94 virtual bool getRgbColor(LColor_color col, lyx::RGBColor & rgbcol) = 0;
96 /** Eg, passing LColor::black returns "000000",
97 * passing LColor::white returns "ffffff".
99 virtual std::string const hexName(LColor_color col) = 0;
102 * update an altered GUI color
104 virtual void updateColor(LColor_color col) = 0;
107 * add a callback for socket read notification
108 * @param fd socket descriptor (file/socket/etc)
110 virtual void registerSocketCallback(
111 int fd, boost::function<void()> func) = 0;
114 * remove a I/O read callback
115 * @param fd socket descriptor (file/socket/etc)
117 virtual void unregisterSocketCallback(int fd) = 0;
121 LyXFunc const & lyxFunc() const;
123 LyXServer & server();
124 LyXServer const & server() const;
126 LyXServerSocket & socket();
127 LyXServerSocket const & socket() const;
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);
134 void setBufferView(BufferView * buffer_view);
137 /// This BufferView is the one receiving Clipboard and Selection
139 /// FIXME: \todo use Gui::currentView() in the future
140 BufferView * buffer_view_;
143 /// Application private implementation.
144 Application_pimpl * pimpl_;
148 } // namespace frontend
150 lyx::frontend::Application * createApplication(int & argc, char * argv[]);
154 extern lyx::frontend::Application * theApp;
157 #endif // LYX_APPLICATION_H