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>
32 /// The main application class
34 There should be only one instance of this class. No Qt object
35 initialisation should be done before the instanciation of this class.
37 \todo The work areas handling could be moved to a base virtual class
38 common to all frontends.
44 Application(int & argc, char ** argv);
46 virtual ~Application() {}
48 /// Start the main event loop, after executing the given batch
50 int start(std::string const & batch);
52 virtual Gui & gui() = 0;
54 virtual int const exec() = 0;
58 * This may either quit directly or record the exit status
59 * and only stop the event loop.
61 virtual void exit(int status) = 0;
64 * Synchronise all pending events.
66 virtual void syncEvents() = 0;
68 virtual Clipboard & clipboard() = 0;
70 virtual Selection & selection() = 0;
72 virtual FontLoader & fontLoader() = 0;
74 /// return a suitable serif font name.
75 virtual std::string const romanFontName() = 0;
77 /// return a suitable sans serif font name.
78 virtual std::string const sansFontName() = 0;
80 /// return a suitable monospaced font name.
81 virtual std::string const typewriterFontName() = 0;
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.
88 virtual bool getRgbColor(LColor_color col, RGBColor & rgbcol) = 0;
90 /** Eg, passing LColor::black returns "000000",
91 * passing LColor::white returns "ffffff".
93 virtual std::string const hexName(LColor_color col) = 0;
96 * update an altered GUI color
98 virtual void updateColor(LColor_color col) = 0;
101 * add a callback for socket read notification
102 * @param fd socket descriptor (file/socket/etc)
104 virtual void registerSocketCallback(
105 int fd, boost::function<void()> func) = 0;
108 * remove a I/O read callback
109 * @param fd socket descriptor (file/socket/etc)
111 virtual void unregisterSocketCallback(int fd) = 0;
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);
118 void setBufferView(BufferView * buffer_view);
121 /// This BufferView is the one receiving Clipboard and Selection
123 /// FIXME: \todo use Gui::currentView() in the future
124 BufferView * buffer_view_;
128 } // namespace frontend
130 extern frontend::Application * theApp;
131 frontend::Application * createApplication(int & argc, char * argv[]);
137 #endif // LYX_APPLICATION_H