]> git.lyx.org Git - lyx.git/blob - src/frontends/qt2/lyx_gui.C
Move fontloader into lyx_gui stuff. Now Qt should compile out of the box
[lyx.git] / src / frontends / qt2 / lyx_gui.C
1 /**
2  * \file lyx_gui.C
3  * Copyright 2002 the LyX Team
4  * Read the file COPYING
5  *
6  * \author unknown
7  * \author John Levon <moz@compsoc.man.ac.uk>
8  */
9
10 #include <config.h>
11  
12 #include "support/lyxlib.h"
13 #include "support/os.h"
14 #include "support/filetools.h"
15 #include "debug.h"
16 #include "gettext.h"
17  
18 #include <fcntl.h>
19 #include <boost/bind.hpp>
20  
21 #include "lyx_gui.h"
22 #include "lyx_main.h"
23 #include "lyxrc.h"
24 #include "lyxfont.h"
25  
26 // FIXME: move this stuff out again
27 #include "bufferlist.h"
28 #include "lyxfunc.h"
29 #include "lyxserver.h"
30 #include "BufferView.h"
31
32 // Dear Lord, deliver us from Evil,
33 // aka the Qt headers
34 #include <boost/shared_ptr.hpp>
35 #include <boost/function/function0.hpp>
36 #include <boost/signals/signal1.hpp>
37  
38 #include "QtView.h"
39 #include "QLImage.h"
40 #include "qfont_loader.h"
41  
42 #include <qapplication.h>
43  
44 #ifndef CXX_GLOBAL_CSTD
45 using std::exit;
46 #endif
47
48 using std::vector;
49 using std::hex;
50 using std::endl;
51  
52 extern bool finished;
53 extern BufferList bufferlist;
54  
55 // FIXME: wrong place !
56 LyXServer * lyxserver;
57  
58 void lyx_gui::parse_init(int & argc, char * argv[])
59 {
60         static QApplication a(argc, argv);
61 }
62  
63
64 void lyx_gui::parse_lyxrc()
65 {
66         // FIXME !!!! 
67         lyxrc.dpi = 95;
68 }
69
70  
71 void lyx_gui::start(string const & batch, vector<string> files)
72 {
73         // initial geometry
74         int xpos = -1;
75         int ypos = -1;
76         unsigned int width = 690;
77         unsigned int height = 510;
78  
79         QtView view(width, height);
80         view.show(xpos, ypos, "LyX");
81         view.init();
82
83         Buffer * last = 0;
84  
85         // FIXME: some code below needs moving
86
87         lyxserver = new LyXServer(view.getLyXFunc(), lyxrc.lyxpipes);
88  
89         vector<string>::const_iterator cit = files.begin();
90         vector<string>::const_iterator end = files.end();
91         for (; cit != end; ++cit) {
92                 Buffer * b = bufferlist.loadLyXFile(*cit);
93                 if (b) {
94                         last = b;
95                 }
96         }
97
98         // switch to the last buffer successfully loaded
99         if (last) {
100                 view.view()->buffer(last);
101         }
102
103         // handle the batch commands the user asked for
104         if (!batch.empty()) {
105                 view.getLyXFunc()->verboseDispatch(batch, false);
106         }
107
108         while (!finished) {
109                 qApp->processEvents();
110         }
111                  
112         // FIXME 
113         delete lyxserver;
114 }
115  
116  
117 void lyx_gui::init_graphics()
118 {
119         using namespace grfx;
120
121         Image::newImage = boost::bind(&QLImage::newImage);
122         Image::loadableFormats = boost::bind(&QLImage::loadableFormats);
123 }
124
125
126 string const lyx_gui::hexname(LColor::color col)
127 {
128         // FIXME
129         return "";
130 }
131
132
133 void lyx_gui::update_color(LColor::color)
134 {
135         // no need
136 }
137
138
139 void lyx_gui::update_fonts()
140 {
141         fontloader.update();
142 }
143
144
145 bool lyx_gui::font_available(LyXFont const & font)
146 {
147         return fontloader.available(font);
148 }