]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiApplication.h
simplify exit code, old code doesn't work on the Mac
[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:
87         ///
88         GuiImplementation gui_;
89         ///
90         GuiClipboard clipboard_;
91         ///
92         GuiSelection selection_;
93         ///
94         GuiFontLoader font_loader_;
95         ///
96         ColorCache color_cache_;
97         ///
98         std::map<int, boost::shared_ptr<socket_callback> > socket_callbacks_;
99
100 #ifdef Q_WS_X11
101 public:
102         bool x11EventFilter (XEvent * ev);
103 #endif
104
105 #ifdef Q_WS_MACX
106 public:
107         bool macEventFilter(EventRef event);
108 private:
109 //      static OSStatus handleOpenDocuments(
110         static pascal OSErr     handleOpenDocuments(
111                 const AppleEvent* inEvent, AppleEvent*, long);
112 #endif
113 }; // GuiApplication
114
115 extern GuiApplication * guiApp;
116
117 } // namespace frontend
118
119 } // namespace lyx
120
121
122 #endif // QT4_APPLICATION_H