]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiApplication.h
new LFUN_WINDOW_CLOSE
[lyx.git] / src / frontends / qt4 / GuiApplication.h
1 /**
2  * \file qt4/GuiApplication.h
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author unknown
7  * \author John Levon
8  * \author Abdelrazak Younes
9  *
10  * Full author contact details are available in file CREDITS.
11  */
12
13 #ifndef QT4_APPLICATION_H
14 #define QT4_APPLICATION_H
15
16 #include "ColorCache.h"
17 #include "GuiFontLoader.h"
18 #include "GuiClipboard.h"
19 #include "GuiImplementation.h"
20 #include "GuiSelection.h"
21
22 #include "frontends/Application.h"
23
24 #include <QApplication>
25
26 ///////////////////////////////////////////////////////////////
27 // Specific stuff
28
29 #ifdef Q_WS_MACX
30 #include <Carbon/Carbon.h>
31 #endif
32 ///////////////////////////////////////////////////////////////
33
34 namespace lyx {
35
36 class BufferView;
37 class socket_callback;
38
39 namespace frontend {
40
41 class GuiWorkArea;
42
43 /// The Qt main application class
44 /**
45 There should be only one instance of this class. No Qt object
46 initialisation should be done before the instanciation of this class.
47
48 \todo The work areas handling could be moved to a base virtual class
49 comon to all frontends.
50 */
51 class GuiApplication : public QApplication, public Application
52 {
53         Q_OBJECT
54
55 public:
56         GuiApplication(int & argc, char ** argv);
57         ///
58         virtual ~GuiApplication();
59
60         /// Method inherited from \c Application class
61         //@{
62         virtual Clipboard& clipboard();
63         virtual Selection& selection();
64         virtual FontLoader & fontLoader() { return font_loader_; }
65         virtual int const exec();
66         virtual Gui & gui() { return gui_; }
67         virtual void exit(int status);
68         void syncEvents();
69         virtual std::string const romanFontName();
70         virtual std::string const sansFontName();
71         virtual std::string const typewriterFontName();
72         virtual bool getRgbColor(LColor_color col, lyx::RGBColor & rgbcol);
73         virtual std::string const hexName(LColor_color col);
74         virtual void updateColor(LColor_color col);
75         virtual void registerSocketCallback(
76                 int fd, boost::function<void()> func);
77         virtual void unregisterSocketCallback(int fd);
78         //@}
79
80         ///
81         ColorCache & colorCache() { return color_cache_; }
82         ///
83         ///
84         GuiFontLoader & guiFontLoader() { return font_loader_; }
85
86 private Q_SLOTS:
87         /// request an LFUN_LYX_QUIT
88         void quitLyX();
89
90 private:
91         ///
92         GuiImplementation gui_;
93         ///
94         GuiClipboard clipboard_;
95         ///
96         GuiSelection selection_;
97         ///
98         GuiFontLoader font_loader_;
99         ///
100         ColorCache color_cache_;
101         ///
102         std::map<int, boost::shared_ptr<socket_callback> > socket_callbacks_;
103
104 #ifdef Q_WS_X11
105 public:
106         bool x11EventFilter (XEvent * ev);
107 #endif
108
109 #ifdef Q_WS_MACX
110 public:
111         bool macEventFilter(EventRef event);
112 private:
113 //      static OSStatus handleOpenDocuments(
114         static pascal OSErr     handleOpenDocuments(
115                 const AppleEvent* inEvent, AppleEvent*, long);
116 #endif
117 }; // GuiApplication
118
119 extern GuiApplication * guiApp;
120
121 } // namespace frontend
122
123 } // namespace lyx
124
125
126 #endif // QT4_APPLICATION_H