]> git.lyx.org Git - lyx.git/blob - src/frontends/qt2/lyx_gui.C
remove a ColorHandler reference
[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  
25 // FIXME: move this stuff out again
26 #include "bufferlist.h"
27 #include "lyxfunc.h"
28 #include "lyxserver.h"
29 #include "BufferView.h"
30
31 // Dear Lord, deliver us from Evil,
32 // aka the Qt headers
33 #include <boost/shared_ptr.hpp>
34 #include <boost/function/function0.hpp>
35 #include <boost/signals/signal1.hpp>
36  
37 #include "QtView.h"
38 #include "QLImage.h"
39  
40 #include <qapplication.h>
41  
42 #ifndef CXX_GLOBAL_CSTD
43 using std::exit;
44 #endif
45
46 using std::vector;
47 using std::hex;
48 using std::endl;
49  
50 extern bool finished;
51 extern BufferList bufferlist;
52  
53 // FIXME: wrong place !
54 LyXServer * lyxserver;
55  
56 void lyx_gui::parse_init(int & argc, char * argv[])
57 {
58         static QApplication a(argc, argv);
59 }
60  
61
62 void lyx_gui::parse_lyxrc()
63 {
64         // FIXME !!!! 
65         lyxrc.dpi = 95;
66 }
67
68  
69 void lyx_gui::start(string const & batch, vector<string> files)
70 {
71         // initial geometry
72         int xpos = -1;
73         int ypos = -1;
74         unsigned int width = 690;
75         unsigned int height = 510;
76  
77         QtView view(width, height);
78         view.show(xpos, ypos, "LyX");
79         view.init();
80
81         Buffer * last = 0;
82  
83         // FIXME: some code below needs moving
84
85         lyxserver = new LyXServer(view.getLyXFunc(), lyxrc.lyxpipes);
86  
87         vector<string>::const_iterator cit = files.begin();
88         vector<string>::const_iterator end = files.end();
89         for (; cit != end; ++cit) {
90                 Buffer * b = bufferlist.loadLyXFile(*cit);
91                 if (b) {
92                         last = b;
93                 }
94         }
95
96         // switch to the last buffer successfully loaded
97         if (last) {
98                 view.view()->buffer(last);
99         }
100
101         // handle the batch commands the user asked for
102         if (!batch.empty()) {
103                 view.getLyXFunc()->verboseDispatch(batch, false);
104         }
105
106         while (!finished) {
107                 qApp->processEvents();
108         }
109                  
110         // FIXME 
111         delete lyxserver;
112 }
113  
114  
115 void lyx_gui::init_graphics()
116 {
117         using namespace grfx;
118
119         Image::newImage = boost::bind(&QLImage::newImage);
120         Image::loadableFormats = boost::bind(&QLImage::loadableFormats);
121 }
122
123
124 string const lyx_gui::hexname(LColor::color col)
125 {
126         // FIXME
127         return "";
128 }
129
130
131 void lyx_gui::update_color(LColor::color col)
132 {
133         // no need
134 }